Skip to content

Commit

Permalink
feat(LinearAlgebra/TensorProduct): add TensorProduct.map₂ (#10986)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjaassoonn committed Feb 28, 2024
1 parent d613681 commit f5e8fa1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 28 deletions.
17 changes: 17 additions & 0 deletions Mathlib/LinearAlgebra/TensorProduct.lean
Expand Up @@ -945,6 +945,19 @@ def homTensorHomMap : (M →ₗ[R] P) ⊗[R] (N →ₗ[R] Q) →ₗ[R] M ⊗[R]

variable {R M N P Q}

/--
This is a binary version of `TensorProduct.map`: Given a bilinear map `f : M ⟶ P ⟶ Q` and a
bilinear map `g : N ⟶ S ⟶ T`, if we think `f` and `g` as linear maps with two inputs, then
`map₂ f g` is a bilinear map taking two inputs `M ⊗ N → P ⊗ S → Q ⊗ S` defined by
`map₂ f g (m ⊗ n) (p ⊗ s) = f m p ⊗ g n s`.
Mathematically, `TensorProduct.map₂` is defined as the composition
`M ⊗ N -map→ Hom(P, Q) ⊗ Hom(S, T) -homTensorHomMap→ Hom(P ⊗ S, Q ⊗ T)`.
-/
def map₂ (f : M →ₗ[R] P →ₗ[R] Q) (g : N →ₗ[R] S →ₗ[R] T) :
M ⊗[R] N →ₗ[R] P ⊗[R] S →ₗ[R] Q ⊗[R] T :=
homTensorHomMap R _ _ _ _ ∘ₗ map f g

@[simp]
theorem mapBilinear_apply (f : M →ₗ[R] P) (g : N →ₗ[R] Q) : mapBilinear R M N P Q f g = map f g :=
rfl
Expand All @@ -968,6 +981,10 @@ theorem homTensorHomMap_apply (f : M →ₗ[R] P) (g : N →ₗ[R] Q) :
rfl
#align tensor_product.hom_tensor_hom_map_apply TensorProduct.homTensorHomMap_apply

@[simp]
theorem map₂_apply_tmul (f : M →ₗ[R] P →ₗ[R] Q) (g : N →ₗ[R] S →ₗ[R] T) (m : M) (n : N) :
map₂ f g (m ⊗ₜ n) = map (f m) (g n) := rfl

@[simp]
theorem map_zero_left (g : N →ₗ[R] Q) : map (0 : M →ₗ[R] P) g = 0 :=
(mapBilinear R M N P Q).map_zero₂ _
Expand Down
31 changes: 3 additions & 28 deletions Mathlib/RingTheory/TensorProduct.lean
Expand Up @@ -213,40 +213,15 @@ variable [CommSemiring R]
variable [NonUnitalNonAssocSemiring A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A]
variable [NonUnitalNonAssocSemiring B] [Module R B] [SMulCommClass R B B] [IsScalarTower R B B]

/-- (Implementation detail)
The multiplication map on `A ⊗[R] B`,
for a fixed pure tensor in the first argument,
as an `R`-linear map.
-/
def mulAux (a₁ : A) (b₁ : B) : A ⊗[R] B →ₗ[R] A ⊗[R] B :=
TensorProduct.map (LinearMap.mulLeft R a₁) (LinearMap.mulLeft R b₁)
#align algebra.tensor_product.mul_aux Algebra.TensorProduct.mulAux

@[simp]
theorem mulAux_apply (a₁ a₂ : A) (b₁ b₂ : B) :
(mulAux a₁ b₁) (a₂ ⊗ₜ[R] b₂) = (a₁ * a₂) ⊗ₜ[R] (b₁ * b₂) :=
rfl
#align algebra.tensor_product.mul_aux_apply Algebra.TensorProduct.mulAux_apply
#noalign algebra.tensor_product.mul_aux
#noalign algebra.tensor_product.mul_aux_apply

/-- (Implementation detail)
The multiplication map on `A ⊗[R] B`,
as an `R`-bilinear map.
-/
def mul : A ⊗[R] B →ₗ[R] A ⊗[R] B →ₗ[R] A ⊗[R] B :=
TensorProduct.lift <|
LinearMap.mk₂ R mulAux
(fun x₁ x₂ y =>
TensorProduct.ext' fun x' y' => by
simp only [mulAux_apply, LinearMap.add_apply, add_mul, add_tmul])
(fun c x y =>
TensorProduct.ext' fun x' y' => by
simp only [mulAux_apply, LinearMap.smul_apply, smul_tmul', smul_mul_assoc])
(fun x y₁ y₂ =>
TensorProduct.ext' fun x' y' => by
simp only [mulAux_apply, LinearMap.add_apply, add_mul, tmul_add])
fun c x y =>
TensorProduct.ext' fun x' y' => by
simp only [mulAux_apply, LinearMap.smul_apply, smul_tmul, smul_tmul', smul_mul_assoc]
TensorProduct.map₂ (LinearMap.mul R A) (LinearMap.mul R B)
#align algebra.tensor_product.mul Algebra.TensorProduct.mul

@[simp]
Expand Down

0 comments on commit f5e8fa1

Please sign in to comment.