Datasets:
Tasks:
Text Generation
Modalities:
Text
Sub-tasks:
language-modeling
Languages:
English
Size:
100K - 1M
License:
/- | |
Copyright (c) 2020 Oliver Nash. All rights reserved. | |
Released under Apache 2.0 license as described in the file LICENSE. | |
Authors: Oliver Nash, Antoine Labelle | |
-/ | |
import linear_algebra.dual | |
import linear_algebra.matrix.to_lin | |
import linear_algebra.tensor_product_basis | |
import linear_algebra.free_module.finite.rank | |
/-! | |
Given modules $M, N$ over a commutative ring $R$, this file defines the natural linear maps: | |
$M^* \otimes M \to R$, $M \otimes M^* \to R$, and $M^* \otimes N β Hom(M, N)$, as well as proving | |
some basic properties of these maps. | |
contraction, dual module, tensor product | |
-/ | |
variables {ΞΉ : Type*} (R M N P Q : Type*) | |
local attribute [ext] tensor_product.ext | |
section contraction | |
open tensor_product linear_map matrix module | |
open_locale tensor_product big_operators | |
section comm_semiring | |
variables [comm_semiring R] | |
variables [add_comm_monoid M] [add_comm_monoid N] [add_comm_monoid P] [add_comm_monoid Q] | |
variables [module R M] [module R N] [module R P] [module R Q] | |
variables [decidable_eq ΞΉ] [fintype ΞΉ] (b : basis ΞΉ R M) | |
/-- The natural left-handed pairing between a module and its dual. -/ | |
def contract_left : (module.dual R M) β M ββ[R] R := (uncurry _ _ _ _).to_fun linear_map.id | |
/-- The natural right-handed pairing between a module and its dual. -/ | |
def contract_right : M β (module.dual R M) ββ[R] R := | |
(uncurry _ _ _ _).to_fun (linear_map.flip linear_map.id) | |
/-- The natural map associating a linear map to the tensor product of two modules. -/ | |
def dual_tensor_hom : (module.dual R M) β N ββ[R] M ββ[R] N := | |
let M' := module.dual R M in | |
(uncurry R M' N (M ββ[R] N) : _ β M' β N ββ[R] M ββ[R] N) linear_map.smul_rightβ | |
variables {R M N P Q} | |
@[simp] lemma contract_left_apply (f : module.dual R M) (m : M) : | |
contract_left R M (f ββ m) = f m := by apply uncurry_apply | |
@[simp] lemma contract_right_apply (f : module.dual R M) (m : M) : | |
contract_right R M (m ββ f) = f m := by apply uncurry_apply | |
@[simp] lemma dual_tensor_hom_apply (f : module.dual R M) (m : M) (n : N) : | |
dual_tensor_hom R M N (f ββ n) m = (f m) β’ n := | |
by { dunfold dual_tensor_hom, rw uncurry_apply, refl, } | |
@[simp] lemma transpose_dual_tensor_hom (f : module.dual R M) (m : M) : | |
dual.transpose (dual_tensor_hom R M M (f ββ m)) = dual_tensor_hom R _ _ (dual.eval R M m ββ f) := | |
by { ext f' m', simp only [dual.transpose_apply, coe_comp, function.comp_app, dual_tensor_hom_apply, | |
linear_map.map_smulββ, ring_hom.id_apply, algebra.id.smul_eq_mul, dual.eval_apply, smul_apply], | |
exact mul_comm _ _ } | |
@[simp] lemma dual_tensor_hom_prod_map_zero (f : module.dual R M) (p : P) : | |
((dual_tensor_hom R M P) (f ββ[R] p)).prod_map (0 : N ββ[R] Q) = | |
dual_tensor_hom R (M Γ N) (P Γ Q) ((f ββ fst R M N) ββ inl R P Q p) := | |
by {ext; simp only [coe_comp, coe_inl, function.comp_app, prod_map_apply, dual_tensor_hom_apply, | |
fst_apply, prod.smul_mk, zero_apply, smul_zero]} | |
@[simp] lemma zero_prod_map_dual_tensor_hom (g : module.dual R N) (q : Q) : | |
(0 : M ββ[R] P).prod_map ((dual_tensor_hom R N Q) (g ββ[R] q)) = | |
dual_tensor_hom R (M Γ N) (P Γ Q) ((g ββ snd R M N) ββ inr R P Q q) := | |
by {ext; simp only [coe_comp, coe_inr, function.comp_app, prod_map_apply, dual_tensor_hom_apply, | |
snd_apply, prod.smul_mk, zero_apply, smul_zero]} | |
lemma map_dual_tensor_hom (f : module.dual R M) (p : P) (g : module.dual R N) (q : Q) : | |
tensor_product.map (dual_tensor_hom R M P (f ββ[R] p)) (dual_tensor_hom R N Q (g ββ[R] q)) = | |
dual_tensor_hom R (M β[R] N) (P β[R] Q) (dual_distrib R M N (f ββ g) ββ[R] (p ββ[R] q)) := | |
begin | |
ext m n, simp only [comprβ_apply, mk_apply, map_tmul, dual_tensor_hom_apply, | |
dual_distrib_apply, βsmul_tmul_smul], | |
end | |
@[simp] lemma comp_dual_tensor_hom (f : module.dual R M) (n : N) (g : module.dual R N) (p : P) : | |
(dual_tensor_hom R N P (g ββ[R] p)) ββ (dual_tensor_hom R M N (f ββ[R] n)) = | |
g n β’ dual_tensor_hom R M P (f ββ p) := | |
begin | |
ext m, simp only [coe_comp, function.comp_app, dual_tensor_hom_apply, linear_map.map_smul, | |
ring_hom.id_apply, smul_apply], rw smul_comm, | |
end | |
/-- As a matrix, `dual_tensor_hom` evaluated on a basis element of `M* β N` is a matrix with a | |
single one and zeros elsewhere -/ | |
theorem to_matrix_dual_tensor_hom | |
{m : Type*} {n : Type*} [fintype m] [fintype n] [decidable_eq m] [decidable_eq n] | |
(bM : basis m R M) (bN : basis n R N) (j : m) (i : n) : | |
to_matrix bM bN (dual_tensor_hom R M N (bM.coord j ββ bN i)) = std_basis_matrix i j 1 := | |
begin | |
ext i' j', | |
by_cases hij : (i = i' β§ j = j'); | |
simp [linear_map.to_matrix_apply, finsupp.single_eq_pi_single, hij], | |
rw [and_iff_not_or_not, not_not] at hij, cases hij; simp [hij], | |
end | |
end comm_semiring | |
section comm_ring | |
variables [comm_ring R] | |
variables [add_comm_group M] [add_comm_group N] [add_comm_group P] [add_comm_group Q] | |
variables [module R M] [module R N] [module R P] [module R Q] | |
variables [decidable_eq ΞΉ] [fintype ΞΉ] (b : basis ΞΉ R M) | |
variables {R M N P Q} | |
/-- If `M` is free, the natural linear map $M^* β N β Hom(M, N)$ is an equivalence. This function | |
provides this equivalence in return for a basis of `M`. -/ | |
@[simps apply] | |
noncomputable def dual_tensor_hom_equiv_of_basis : | |
(module.dual R M) β[R] N ββ[R] M ββ[R] N := | |
linear_equiv.of_linear | |
(dual_tensor_hom R M N) | |
(β i, (tensor_product.mk R _ N (b.dual_basis i)) ββ linear_map.applyβ (b i)) | |
(begin | |
ext f m, | |
simp only [applyβ_apply_apply, coe_fn_sum, dual_tensor_hom_apply, mk_apply, id_coe, id.def, | |
fintype.sum_apply, function.comp_app, basis.coe_dual_basis, coe_comp, | |
basis.coord_apply, β f.map_smul, (dual_tensor_hom R M N).map_sum, β f.map_sum, b.sum_repr], | |
end) | |
(begin | |
ext f m, | |
simp only [applyβ_apply_apply, coe_fn_sum, dual_tensor_hom_apply, mk_apply, id_coe, id.def, | |
fintype.sum_apply, function.comp_app, basis.coe_dual_basis, coe_comp, | |
comprβ_apply, tmul_smul, smul_tmul', β sum_tmul, basis.sum_dual_apply_smul_coord], | |
end) | |
@[simp] lemma dual_tensor_hom_equiv_of_basis_to_linear_map : | |
(dual_tensor_hom_equiv_of_basis b : (module.dual R M) β[R] N ββ[R] M ββ[R] N).to_linear_map = | |
dual_tensor_hom R M N := | |
rfl | |
@[simp] lemma dual_tensor_hom_equiv_of_basis_symm_cancel_left (x : (module.dual R M) β[R] N) : | |
(dual_tensor_hom_equiv_of_basis b).symm (dual_tensor_hom R M N x) = x := | |
by rw [βdual_tensor_hom_equiv_of_basis_apply b, linear_equiv.symm_apply_apply] | |
@[simp] lemma dual_tensor_hom_equiv_of_basis_symm_cancel_right (x : M ββ[R] N) : | |
dual_tensor_hom R M N ((dual_tensor_hom_equiv_of_basis b).symm x) = x := | |
by rw [βdual_tensor_hom_equiv_of_basis_apply b, linear_equiv.apply_symm_apply] | |
variables (R M N P Q) | |
variables [module.free R M] [module.finite R M] [nontrivial R] | |
open_locale classical | |
/-- If `M` is finite free, the natural map $M^* β N β Hom(M, N)$ is an | |
equivalence. -/ | |
@[simp] noncomputable def dual_tensor_hom_equiv : (module.dual R M) β[R] N ββ[R] M ββ[R] N := | |
dual_tensor_hom_equiv_of_basis (module.free.choose_basis R M) | |
end comm_ring | |
end contraction | |
section hom_tensor_hom | |
open_locale tensor_product | |
open module tensor_product linear_map | |
section comm_ring | |
variables [comm_ring R] | |
variables [add_comm_group M] [add_comm_group N] [add_comm_group P] [add_comm_group Q] | |
variables [module R M] [module R N] [module R P] [module R Q] | |
variables [free R M] [finite R M] [free R N] [finite R N] [nontrivial R] | |
/-- When `M` is a finite free module, the map `ltensor_hom_to_hom_ltensor` is an equivalence. Note | |
that `ltensor_hom_equiv_hom_ltensor` is not defined directly in terms of | |
`ltensor_hom_to_hom_ltensor`, but the equivalence between the two is given by | |
`ltensor_hom_equiv_hom_ltensor_to_linear_map` and `ltensor_hom_equiv_hom_ltensor_apply`. -/ | |
noncomputable def ltensor_hom_equiv_hom_ltensor : P β[R] (M ββ[R] Q) ββ[R] (M ββ[R] P β[R] Q) := | |
congr (linear_equiv.refl R P) (dual_tensor_hom_equiv R M Q).symm βͺβ«β | |
tensor_product.left_comm R P _ Q βͺβ«β dual_tensor_hom_equiv R M _ | |
/-- When `M` is a finite free module, the map `rtensor_hom_to_hom_rtensor` is an equivalence. Note | |
that `rtensor_hom_equiv_hom_rtensor` is not defined directly in terms of | |
`rtensor_hom_to_hom_rtensor`, but the equivalence between the two is given by | |
`rtensor_hom_equiv_hom_rtensor_to_linear_map` and `rtensor_hom_equiv_hom_rtensor_apply`. -/ | |
noncomputable def rtensor_hom_equiv_hom_rtensor : (M ββ[R] P) β[R] Q ββ[R] (M ββ[R] P β[R] Q) := | |
congr (dual_tensor_hom_equiv R M P).symm (linear_equiv.refl R Q) βͺβ«β | |
tensor_product.assoc R _ P Q βͺβ«β dual_tensor_hom_equiv R M _ | |
@[simp] lemma ltensor_hom_equiv_hom_ltensor_to_linear_map : | |
(ltensor_hom_equiv_hom_ltensor R M P Q).to_linear_map = ltensor_hom_to_hom_ltensor R M P Q := | |
begin | |
let e := congr (linear_equiv.refl R P) (dual_tensor_hom_equiv R M Q), | |
have h : function.surjective e.to_linear_map := e.surjective, | |
refine (cancel_right h).1 _, | |
ext p f q m, | |
simp only [ltensor_hom_equiv_hom_ltensor, dual_tensor_hom_equiv, comprβ_apply, mk_apply, coe_comp, | |
linear_equiv.coe_to_linear_map, function.comp_app, map_tmul, linear_equiv.coe_coe, | |
dual_tensor_hom_equiv_of_basis_apply, linear_equiv.trans_apply, congr_tmul, | |
linear_equiv.refl_apply, dual_tensor_hom_equiv_of_basis_symm_cancel_left, left_comm_tmul, | |
dual_tensor_hom_apply, ltensor_hom_to_hom_ltensor_apply, tmul_smul], | |
end | |
@[simp] lemma rtensor_hom_equiv_hom_rtensor_to_linear_map : | |
(rtensor_hom_equiv_hom_rtensor R M P Q).to_linear_map = rtensor_hom_to_hom_rtensor R M P Q := | |
begin | |
let e := congr (dual_tensor_hom_equiv R M P) (linear_equiv.refl R Q), | |
have h : function.surjective e.to_linear_map := e.surjective, | |
refine (cancel_right h).1 _, | |
ext f p q m, | |
simp only [rtensor_hom_equiv_hom_rtensor, dual_tensor_hom_equiv, comprβ_apply, mk_apply, coe_comp, | |
linear_equiv.coe_to_linear_map, function.comp_app, map_tmul, linear_equiv.coe_coe, | |
dual_tensor_hom_equiv_of_basis_apply, linear_equiv.trans_apply, congr_tmul, | |
dual_tensor_hom_equiv_of_basis_symm_cancel_left, linear_equiv.refl_apply, assoc_tmul, | |
dual_tensor_hom_apply, rtensor_hom_to_hom_rtensor_apply, smul_tmul'], | |
end | |
variables {R M N P Q} | |
@[simp] lemma ltensor_hom_equiv_hom_ltensor_apply (x : P β[R] (M ββ[R] Q)) : | |
ltensor_hom_equiv_hom_ltensor R M P Q x = ltensor_hom_to_hom_ltensor R M P Q x := | |
by rw [βlinear_equiv.coe_to_linear_map, ltensor_hom_equiv_hom_ltensor_to_linear_map] | |
@[simp] lemma rtensor_hom_equiv_hom_rtensor_apply (x : (M ββ[R] P) β[R] Q) : | |
rtensor_hom_equiv_hom_rtensor R M P Q x = rtensor_hom_to_hom_rtensor R M P Q x := | |
by rw [βlinear_equiv.coe_to_linear_map, rtensor_hom_equiv_hom_rtensor_to_linear_map] | |
variables (R M N P Q) | |
/-- | |
When `M` and `N` are free `R` modules, the map `hom_tensor_hom_map` is an equivalence. Note that | |
`hom_tensor_hom_equiv` is not defined directly in terms of `hom_tensor_hom_map`, but the equivalence | |
between the two is given by `hom_tensor_hom_equiv_to_linear_map` and `hom_tensor_hom_equiv_apply`. | |
-/ | |
noncomputable | |
def hom_tensor_hom_equiv : (M ββ[R] P) β[R] (N ββ[R] Q) ββ[R] (M β[R] N ββ[R] P β[R] Q) := | |
rtensor_hom_equiv_hom_rtensor R M P _ βͺβ«β | |
(linear_equiv.refl R M).arrow_congr (ltensor_hom_equiv_hom_ltensor R N _ Q) βͺβ«β | |
lift.equiv R M N _ | |
@[simp] | |
lemma hom_tensor_hom_equiv_to_linear_map : | |
(hom_tensor_hom_equiv R M N P Q).to_linear_map = hom_tensor_hom_map R M N P Q := | |
begin | |
ext f g m n, | |
simp only [hom_tensor_hom_equiv, comprβ_apply, mk_apply, linear_equiv.coe_to_linear_map, | |
linear_equiv.trans_apply, lift.equiv_apply, linear_equiv.arrow_congr_apply, | |
linear_equiv.refl_symm, linear_equiv.refl_apply, rtensor_hom_equiv_hom_rtensor_apply, | |
ltensor_hom_equiv_hom_ltensor_apply, ltensor_hom_to_hom_ltensor_apply, | |
rtensor_hom_to_hom_rtensor_apply, hom_tensor_hom_map_apply, map_tmul], | |
end | |
variables {R M N P Q} | |
@[simp] | |
lemma hom_tensor_hom_equiv_apply (x : (M ββ[R] P) β[R] (N ββ[R] Q)) : | |
hom_tensor_hom_equiv R M N P Q x = hom_tensor_hom_map R M N P Q x := | |
by rw [βlinear_equiv.coe_to_linear_map, hom_tensor_hom_equiv_to_linear_map] | |
end comm_ring | |
end hom_tensor_hom | |