math / data /lean /OAI /LinearAlgebra /MatrixFields /Tensors /ComplexSeparatedTensorDecomposition.lean
Download data/lean/OAI/LinearAlgebra/MatrixFields/Tensors/ComplexSeparatedTensorDecomposition.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 12.8 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/MatrixFields/Tensors/ComplexSeparatedTensorDecomposition.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/LinearAlgebra/MatrixFields/Tensors/ComplexSeparatedTensorDecomposition.lean
-
curl -L -o ComplexSeparatedTensorDecomposition.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/MatrixFields/Tensors/ComplexSeparatedTensorDecomposition.lean
12.8 kB
| import Mathlib | |
| import OAI.LinearAlgebra.MatrixFields.Extraction.ComplexFiniteSeparation | |
| namespace OAI | |
| namespace MatrixAllFields | |
| open scoped BigOperators Topology Polynomial | |
| open scoped BigOperators | |
| namespace MatrixMultiplication.Foundation | |
| namespace Tensor | |
| variable {K S : Type*} [CommSemiring K] [DecidableEq S] | |
| variable {X Y Z : S β Type*} | |
| def dependentDirectSum (T : β s, Tensor K (X s) (Y s) (Z s)) : | |
| Tensor K (Ξ£ s, X s) (Ξ£ s, Y s) (Ξ£ s, Z s) := | |
| fun x y z => | |
| if hxy : y.1 = x.1 then | |
| if hxz : z.1 = x.1 then T x.1 x.2 (hxy βΈ y.2) (hxz βΈ z.2) | |
| else 0 | |
| else 0 | |
| @[simp] theorem dependentDirectSum_matching | |
| (T : β s, Tensor K (X s) (Y s) (Z s)) | |
| (s : S) (x : X s) (y : Y s) (z : Z s) : | |
| dependentDirectSum T β¨s, xβ© β¨s, yβ© β¨s, zβ© = T s x y z := by | |
| simp [dependentDirectSum] | |
| theorem dependentDirectSum_zero_of_left_ne | |
| (T : β s, Tensor K (X s) (Y s) (Z s)) | |
| (x : Ξ£ s, X s) (y : Ξ£ s, Y s) (z : Ξ£ s, Z s) | |
| (h : x.1 β y.1) : dependentDirectSum T x y z = 0 := by | |
| simp [dependentDirectSum, Ne.symm h] | |
| def directSumCoordinateEquiv {A : Type*} (e : β s, X s β A) : | |
| (Ξ£ s, X s) β S Γ A where | |
| toFun x := (x.1, e x.1 x.2) | |
| invFun x := β¨x.1, (e x.1).symm x.2β© | |
| left_inv := by | |
| rintro β¨s, xβ© | |
| simp | |
| right_inv := by | |
| rintro β¨s, xβ© | |
| simp | |
| theorem dependentDirectSum_reindex {A B C : Type*} | |
| (T : β s, Tensor K (X s) (Y s) (Z s)) | |
| (ex : β s, X s β A) (ey : β s, Y s β B) (ez : β s, Z s β C) : | |
| pullback (directSumCoordinateEquiv ex).symm | |
| (directSumCoordinateEquiv ey).symm (directSumCoordinateEquiv ez).symm | |
| (dependentDirectSum T) = | |
| directSum (fun s => pullback (ex s).symm (ey s).symm (ez s).symm (T s)) := by | |
| funext x y z | |
| rcases x with β¨s, xβ© | |
| rcases y with β¨t, yβ© | |
| rcases z with β¨v, zβ© | |
| by_cases ht : t = s | |
| Β· subst t | |
| by_cases hv : v = s | |
| Β· subst v | |
| simp [pullback, directSumCoordinateEquiv, dependentDirectSum, directSum] | |
| Β· simp [pullback, directSumCoordinateEquiv, dependentDirectSum, directSum, | |
| hv, Ne.symm hv] | |
| Β· simp [pullback, directSumCoordinateEquiv, dependentDirectSum, directSum, | |
| ht, Ne.symm ht] | |
| end Tensor | |
| variable {X Y Z S U : Type*} [DecidableEq S] [DecidableEq U] | |
| def labelFiberTensor (lx : X β S) (ly : Y β S) (T : Tensor β X Y Z) (s : S) : | |
| Tensor β {x // lx x = s} {y // ly y = s} Z := | |
| fun x y z => T x.1 y.1 z | |
| def fiberCoordinateEquiv (lx : X β S) : | |
| (Ξ£ s, {x // lx x = s} Γ U) β X Γ U where | |
| toFun x := (x.2.1.1, x.2.2) | |
| invFun x := β¨lx x.1, (β¨x.1, rflβ©, x.2)β© | |
| left_inv := by | |
| rintro β¨s, β¨β¨x, hxβ©, uβ©β© | |
| cases hx | |
| rfl | |
| right_inv := by | |
| rintro β¨x, uβ© | |
| rfl | |
| def tagCoordinateEquiv : (Ξ£ _ : S, Z Γ Unit) β Z Γ S where | |
| toFun z := (z.2.1, z.1) | |
| invFun z := β¨z.2, (z.1, ())β© | |
| left_inv := by | |
| rintro β¨s, z, uβ© | |
| cases u | |
| rfl | |
| right_inv := by | |
| rintro β¨z, sβ© | |
| rfl | |
| theorem separatedTensor_eq_fiber_directSum | |
| (T : Tensor β X Y Z) (lx : X β S) (ly : Y β S) | |
| (hlabels : β x y z, T x y z β 0 β lx x = ly y) : | |
| Tensor.pullback (fiberCoordinateEquiv (U := U) lx) | |
| (fiberCoordinateEquiv (U := U) ly) (tagCoordinateEquiv (Z := Z) (S := S)) | |
| (separatedTensor lx T) = | |
| Tensor.dependentDirectSum (fun s => | |
| Tensor.product (labelFiberTensor lx ly T s) (Tensor.dotPairing U)) := by | |
| classical | |
| funext x y z | |
| rcases x with β¨s, x, uβ© | |
| rcases y with β¨t, y, vβ© | |
| rcases z with β¨w, z, qβ© | |
| by_cases ht : t = s | |
| Β· subst t | |
| by_cases hw : w = s | |
| Β· subst w | |
| rw [Tensor.dependentDirectSum_matching] | |
| simp [Tensor.pullback, fiberCoordinateEquiv, tagCoordinateEquiv, | |
| separatedTensor, Tensor.product, labelFiberTensor, Tensor.dotPairing, | |
| x.property, mul_ite] | |
| Β· simp [Tensor.pullback, fiberCoordinateEquiv, tagCoordinateEquiv, | |
| separatedTensor, Tensor.dependentDirectSum, x.property, hw, Ne.symm hw] | |
| Β· have hzero : T x.1 y.1 z = 0 := by | |
| by_contra hzero | |
| have hxy := hlabels x.1 y.1 z hzero | |
| exact ht (y.property.symm.trans (hxy.symm.trans x.property)) | |
| simp [Tensor.pullback, fiberCoordinateEquiv, tagCoordinateEquiv, | |
| separatedTensor, Tensor.dependentDirectSum, ht, hzero] | |
| theorem fiber_directSum_eq_separatedTensor | |
| (T : Tensor β X Y Z) (lx : X β S) (ly : Y β S) | |
| (hlabels : β x y z, T x y z β 0 β lx x = ly y) : | |
| Tensor.pullback (fiberCoordinateEquiv (U := U) lx).symm | |
| (fiberCoordinateEquiv (U := U) ly).symm | |
| (tagCoordinateEquiv (Z := Z) (S := S)).symm | |
| (Tensor.dependentDirectSum (fun s => | |
| Tensor.product (labelFiberTensor lx ly T s) (Tensor.dotPairing U))) = | |
| separatedTensor lx T := by | |
| rw [β separatedTensor_eq_fiber_directSum T lx ly hlabels] | |
| funext x y z | |
| simp [Tensor.pullback] | |
| theorem separatedTensor_fiber_directSum_rankAtMost | |
| (T : Tensor β X Y Z) (lx : X β S) (ly : Y β S) {r : β} | |
| (hlabels : β x y z, T x y z β 0 β lx x = ly y) | |
| (h : Tensor.RankAtMost (separatedTensor (U := U) lx T) r) : | |
| Tensor.RankAtMost (Tensor.dependentDirectSum (fun s => | |
| Tensor.product (labelFiberTensor lx ly T s) (Tensor.dotPairing U))) r := by | |
| rw [β separatedTensor_eq_fiber_directSum T lx ly hlabels] | |
| exact h.pullback _ _ _ | |
| theorem separatedTensor_fiber_directSum_rankAtMost_iff | |
| (T : Tensor β X Y Z) (lx : X β S) (ly : Y β S) {r : β} | |
| (hlabels : β x y z, T x y z β 0 β lx x = ly y) : | |
| Tensor.RankAtMost (separatedTensor (U := U) lx T) r β | |
| Tensor.RankAtMost (Tensor.dependentDirectSum (fun s => | |
| Tensor.product (labelFiberTensor lx ly T s) (Tensor.dotPairing U))) r := by | |
| constructor | |
| Β· exact separatedTensor_fiber_directSum_rankAtMost T lx ly hlabels | |
| Β· intro h | |
| rw [β fiber_directSum_eq_separatedTensor T lx ly hlabels] | |
| exact h.pullback _ _ _ | |
| theorem separatedTensor_fiber_directSum_borderRankAtMost | |
| [Fintype X] [Fintype Y] [Fintype Z] [Fintype S] [Fintype U] | |
| (T : Tensor β X Y Z) (lx : X β S) (ly : Y β S) {r : β} | |
| (hlabels : β x y z, T x y z β 0 β lx x = ly y) | |
| (h : Tensor.BorderRankAtMost (separatedTensor (U := U) lx T) r) : | |
| Tensor.BorderRankAtMost (Tensor.dependentDirectSum (fun s => | |
| Tensor.product (labelFiberTensor lx ly T s) (Tensor.dotPairing U))) r := by | |
| classical | |
| rw [β separatedTensor_eq_fiber_directSum T lx ly hlabels] | |
| rw [Tensor.pullback_eq_restrict] | |
| exact h.restrict _ _ _ | |
| theorem separatedTensor_uniform_directSum_rankAtMost {A B : Type*} | |
| (T : Tensor β X Y Z) (lx : X β S) (ly : Y β S) | |
| (ex : β s, {x // lx x = s} β A) (ey : β s, {y // ly y = s} β B) | |
| {r : β} (hlabels : β x y z, T x y z β 0 β lx x = ly y) | |
| (h : Tensor.RankAtMost (separatedTensor (U := U) lx T) r) : | |
| Tensor.RankAtMost (Tensor.directSum (fun s => Tensor.pullback | |
| (Equiv.prodCongr (ex s) (Equiv.refl U)).symm | |
| (Equiv.prodCongr (ey s) (Equiv.refl U)).symm | |
| (Equiv.refl (Z Γ Unit)).symm | |
| (Tensor.product (labelFiberTensor lx ly T s) (Tensor.dotPairing U)))) r := by | |
| have hf := separatedTensor_fiber_directSum_rankAtMost T lx ly hlabels h | |
| have hp := hf.pullback | |
| (Tensor.directSumCoordinateEquiv | |
| (fun s => Equiv.prodCongr (ex s) (Equiv.refl U))).symm | |
| (Tensor.directSumCoordinateEquiv | |
| (fun s => Equiv.prodCongr (ey s) (Equiv.refl U))).symm | |
| (Tensor.directSumCoordinateEquiv (fun _ : S => Equiv.refl (Z Γ Unit))).symm | |
| rw [Tensor.dependentDirectSum_reindex] at hp | |
| exact hp | |
| theorem separatedTensor_localModels_identity {A B C : Type*} | |
| (T : Tensor β X Y Z) (lx : X β S) (ly : Y β S) | |
| (fx : S β A β X) (fy : S β B β Y) (fz : S β C β Z) | |
| (hfx : β s a, lx (fx s a) = s) (hfy : β s b, ly (fy s b) = s) | |
| (hlabels : β x y z, T x y z β 0 β lx x = ly y) : | |
| Tensor.pullback | |
| (fun x : S Γ (A Γ U) => (fx x.1 x.2.1, x.2.2)) | |
| (fun y : S Γ (B Γ U) => (fy y.1 y.2.1, y.2.2)) | |
| (fun z : S Γ (C Γ Unit) => (fz z.1 z.2.1, z.1)) | |
| (separatedTensor lx T) = | |
| Tensor.directSum (fun s => Tensor.product | |
| (Tensor.pullback (fx s) (fy s) (fz s) T) (Tensor.dotPairing U)) := by | |
| funext x y z | |
| rcases x with β¨s, a, uβ© | |
| rcases y with β¨t, b, vβ© | |
| rcases z with β¨w, c, qβ© | |
| by_cases ht : t = s | |
| Β· subst t | |
| by_cases hw : w = s | |
| Β· subst w | |
| simp [Tensor.pullback, separatedTensor, Tensor.directSum, | |
| Tensor.product, Tensor.dotPairing, hfx, mul_ite] | |
| Β· simp [Tensor.pullback, separatedTensor, Tensor.directSum, | |
| hfx, Ne.symm hw] | |
| Β· have hzero : T (fx s a) (fy t b) (fz w c) = 0 := by | |
| by_contra hzero | |
| have hxy := hlabels (fx s a) (fy t b) (fz w c) hzero | |
| exact ht ((hfy t b).symm.trans (hxy.symm.trans (hfx s a))) | |
| simp [Tensor.pullback, separatedTensor, Tensor.directSum, | |
| Ne.symm ht, hzero] | |
| theorem separatedTensor_localModels_rankAtMost {A B C : Type*} | |
| (T : Tensor β X Y Z) (lx : X β S) (ly : Y β S) | |
| (fx : S β A β X) (fy : S β B β Y) (fz : S β C β Z) | |
| (hfx : β s a, lx (fx s a) = s) (hfy : β s b, ly (fy s b) = s) | |
| (hlabels : β x y z, T x y z β 0 β lx x = ly y) | |
| {r : β} (h : Tensor.RankAtMost (separatedTensor (U := U) lx T) r) : | |
| Tensor.RankAtMost (Tensor.directSum (fun s => Tensor.product | |
| (Tensor.pullback (fx s) (fy s) (fz s) T) (Tensor.dotPairing U))) r := by | |
| rw [β separatedTensor_localModels_identity T lx ly fx fy fz hfx hfy hlabels] | |
| exact h.pullback _ _ _ | |
| theorem separatedTensor_localModels_borderRankAtMost {A B C : Type*} | |
| [Fintype X] [Fintype Y] [Fintype Z] [Fintype S] [Fintype U] | |
| [Fintype A] [Fintype B] [Fintype C] | |
| (T : Tensor β X Y Z) (lx : X β S) (ly : Y β S) | |
| (fx : S β A β X) (fy : S β B β Y) (fz : S β C β Z) | |
| (hfx : β s a, lx (fx s a) = s) (hfy : β s b, ly (fy s b) = s) | |
| (hlabels : β x y z, T x y z β 0 β lx x = ly y) | |
| {r : β} (h : Tensor.BorderRankAtMost (separatedTensor (U := U) lx T) r) : | |
| Tensor.BorderRankAtMost (Tensor.directSum (fun s => Tensor.product | |
| (Tensor.pullback (fx s) (fy s) (fz s) T) (Tensor.dotPairing U))) r := by | |
| classical | |
| rw [β separatedTensor_localModels_identity T lx ly fx fy fz hfx hfy hlabels] | |
| rw [Tensor.pullback_eq_restrict] | |
| exact h.restrict _ _ _ | |
| theorem separatedTensor_scalar_identity | |
| (T : Tensor β X Y Z) (lx : X β S) (ly : Y β S) | |
| (sx : S β X) (sy : S β Y) (sz : S β Z) | |
| (hsx : β s, lx (sx s) = s) (hsy : β s, ly (sy s) = s) | |
| (hlabels : β x y z, T x y z β 0 β lx x = ly y) | |
| (hscalar : β s, T (sx s) (sy s) (sz s) = 1) : | |
| Tensor.pullback | |
| (fun x : S Γ U => (sx x.1, x.2)) | |
| (fun y : S Γ U => (sy y.1, y.2)) | |
| (fun z : S Γ Unit => (sz z.1, z.1)) (separatedTensor lx T) = | |
| Tensor.directSum (fun _ : S => Tensor.dotPairing U) := by | |
| have hmodels := separatedTensor_localModels_identity (U := U) T lx ly | |
| (fun s (_ : Unit) => sx s) (fun s (_ : Unit) => sy s) (fun s (_ : Unit) => sz s) | |
| (fun s _ => hsx s) (fun s _ => hsy s) hlabels | |
| have h := congrArg (Tensor.pullback | |
| (fun x : S Γ U => (x.1, ((), x.2))) | |
| (fun y : S Γ U => (y.1, ((), y.2))) | |
| (fun z : S Γ Unit => (z.1, ((), z.2)))) hmodels | |
| funext x y z | |
| have hpoint := congrFun (congrFun (congrFun h x) y) z | |
| simpa only [Tensor.pullback, Tensor.directSum, Tensor.product, hscalar, one_mul] | |
| using hpoint | |
| theorem separatedTensor_scalar_rankAtMost | |
| (T : Tensor β X Y Z) (lx : X β S) (ly : Y β S) | |
| (sx : S β X) (sy : S β Y) (sz : S β Z) | |
| (hsx : β s, lx (sx s) = s) (hsy : β s, ly (sy s) = s) | |
| (hlabels : β x y z, T x y z β 0 β lx x = ly y) | |
| (hscalar : β s, T (sx s) (sy s) (sz s) = 1) | |
| {r : β} (h : Tensor.RankAtMost (separatedTensor (U := U) lx T) r) : | |
| Tensor.RankAtMost (Tensor.directSum (fun _ : S => Tensor.dotPairing (K := β) U)) r := by | |
| rw [β separatedTensor_scalar_identity T lx ly sx sy sz hsx hsy hlabels hscalar] | |
| exact h.pullback _ _ _ | |
| theorem separatedTensor_scalar_borderRankAtMost | |
| [Fintype X] [Fintype Y] [Fintype Z] [Fintype S] [Fintype U] | |
| (T : Tensor β X Y Z) (lx : X β S) (ly : Y β S) | |
| (sx : S β X) (sy : S β Y) (sz : S β Z) | |
| (hsx : β s, lx (sx s) = s) (hsy : β s, ly (sy s) = s) | |
| (hlabels : β x y z, T x y z β 0 β lx x = ly y) | |
| (hscalar : β s, T (sx s) (sy s) (sz s) = 1) | |
| {r : β} (h : Tensor.BorderRankAtMost (separatedTensor (U := U) lx T) r) : | |
| Tensor.BorderRankAtMost (Tensor.directSum (fun _ : S => Tensor.dotPairing U)) r := by | |
| classical | |
| rw [β separatedTensor_scalar_identity T lx ly sx sy sz hsx hsy hlabels hscalar] | |
| rw [Tensor.pullback_eq_restrict] | |
| exact h.restrict _ _ _ | |
| end MatrixMultiplication.Foundation | |
| end MatrixAllFields | |
| end OAI | |