Buckets:
cfahlgren1/math / lean /OAI /LinearAlgebra /MatrixMultiplication /Tensor /ComplexTensorFlattening.lean
| import OAI.LinearAlgebra.MatrixMultiplication.Tensor.ComplexMatrixTensor | |
| import Mathlib.LinearAlgebra.Matrix.Rank | |
| namespace OAI | |
| /-! Finite coefficient tensors and their algebraic transformations. -/ | |
| noncomputable section | |
| open scoped BigOperators | |
| namespace MatrixMultiplication.Foundation | |
| namespace Tensor | |
| variable {K X Y Z : Type*} [Field K] | |
| theorem RankAtMost.card_le_of_identity {ι : Type*} [Fintype ι] [DecidableEq ι] | |
| {T : Tensor K X Y Z} {r : ℕ} (hT : RankAtMost T r) | |
| (x : ι → X) (y : ι → Y) (z : ι → Z) | |
| (hidentity : ∀ i j, T (x i) (y i) (z j) = if i = j then 1 else 0) : | |
| Fintype.card ι ≤ r := by | |
| rcases hT with ⟨a, b, c, heq⟩ | |
| let L : Matrix ι (Fin r) K := fun i q => a q (x i) * b q (y i) | |
| let R : Matrix (Fin r) ι K := fun q j => c q (z j) | |
| have hmul : L * R = (1 : Matrix ι ι K) := by | |
| funext i j | |
| change (∑ q, (a q (x i) * b q (y i)) * c q (z j)) = if i = j then 1 else 0 | |
| calc | |
| (∑ q, (a q (x i) * b q (y i)) * c q (z j)) = T (x i) (y i) (z j) := | |
| (congrFun (congrFun (congrFun heq (x i)) (y i)) (z j)).symm | |
| _ = _ := hidentity i j | |
| have hle : (1 : Matrix ι ι K).rank ≤ r := by | |
| rw [← hmul] | |
| exact (Matrix.rank_mul_le_left L R).trans (by | |
| simpa only [Fintype.card_fin] using Matrix.rank_le_card_width L) | |
| simpa only [Matrix.rank_one] using hle | |
| theorem directSum_matrixCoefficients_rank_lower | |
| {Label A B C : Type*} [Fintype Label] [Fintype A] [Fintype C] | |
| [DecidableEq Label] [DecidableEq A] [DecidableEq B] [DecidableEq C] | |
| [Nonempty B] {r : ℕ} | |
| (h : RankAtMost (directSum (fun _ : Label => matrixCoefficients (K := K) A B C)) r) : | |
| Fintype.card Label * (Fintype.card C * Fintype.card A) ≤ r := by | |
| classical | |
| let b₀ : B := Classical.choice inferInstance | |
| have hminor : ∀ i j : Label × (C × A), | |
| directSum (fun _ : Label => matrixCoefficients (K := K) A B C) | |
| (i.1, (i.2.2, b₀)) (i.1, (b₀, i.2.1)) j = if i = j then 1 else 0 := by | |
| intro i j | |
| simp only [directSum, matrixCoefficients] | |
| split_ifs <;> simp_all [Prod.ext_iff] | |
| have hlower := h.card_le_of_identity | |
| (fun i : Label × (C × A) => (i.1, (i.2.2, b₀))) | |
| (fun i : Label × (C × A) => (i.1, (b₀, i.2.1))) | |
| (fun i : Label × (C × A) => i) hminor | |
| simpa only [Fintype.card_prod] using hlower | |
| theorem directSum_square_rank_lower (k n r : ℕ) (hn : 0 < n) | |
| (h : RankAtMost (directSum (fun _ : Fin k => | |
| matrixCoefficients (K := K) (Fin n) (Fin n) (Fin n))) r) : | |
| k * n ^ 2 ≤ r := by | |
| let : Nonempty (Fin n) := ⟨⟨0, hn⟩⟩ | |
| simpa only [Fintype.card_fin, pow_two] using directSum_matrixCoefficients_rank_lower h | |
| end Tensor | |
| end MatrixMultiplication.Foundation | |
| end | |
| end OAI | |
Xet Storage Details
- Size:
- 2.73 kB
- Xet hash:
- 0239820aebe13b457dfe26888ee291e8befe4975bb5fe80f79252a3a1a4639e0
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.