Buckets:
cfahlgren1/math / lean /OAI /LinearAlgebra /MatrixMultiplication /AuxiliarySeparation /Sector /Degeneration.lean
| import OAI.LinearAlgebra.MatrixMultiplication.AuxiliarySeparation.Convolution.Basic | |
| import OAI.LinearAlgebra.MatrixMultiplication.AuxiliarySeparation.Sector.Weights | |
| import OAI.LinearAlgebra.MatrixMultiplication.AuxiliarySeparation.Polynomial.Interpolation | |
| namespace OAI | |
| /-! | |
| # The actual three-sector polynomial degeneration | |
| The interval weights of `SectorWeights` act by diagonal local maps on the | |
| coefficient tensor `C(a, 3h+a-1)`. Shifting every third-leg weight by one makes | |
| the local maps polynomial. Their restriction is exactly `X * retained + | |
| X^2 * erased`, so the existing polynomial-restriction degeneration interface | |
| applies with leading order one and local degree bounds `(0,1,1)`. | |
| -/ | |
| noncomputable section | |
| open scoped BigOperators Classical | |
| namespace MatrixMultiplication.AuxiliarySeparation.Sector | |
| open MatrixMultiplication.Foundation | |
| open Polynomial | |
| abbrev YIndex (a h : ℕ) := Fin (sourceWidth a h) | |
| abbrev ZIndex (a h : ℕ) := Fin (a + sourceWidth a h - 1) | |
| /-- The source coefficient tensor, with its actual shared first-input space. -/ | |
| def source (a h : ℕ) : Tensor ℂ (Fin a) (YIndex a h) (ZIndex a h) := | |
| convolution a (sourceWidth a h) | |
| theorem source_ne_zero_iff {a h : ℕ} (i : Fin a) (j : YIndex a h) | |
| (k : ZIndex a h) : | |
| source a h i j k ≠ 0 ↔ Support a h i.val j.val k.val := by | |
| simp only [source, convolution_ne_zero_iff, Support] | |
| constructor | |
| · intro heq | |
| exact ⟨i.isLt, j.isLt, heq.symm⟩ | |
| · intro hs | |
| exact hs.2.2.symm | |
| /-- The weight-zero part in the original coordinate spaces. -/ | |
| def retained (a h : ℕ) : Tensor ℂ (Fin a) (YIndex a h) (ZIndex a h) := | |
| fun i j k => if totalWeight a h i.val j.val k.val = 0 then source a h i j k else 0 | |
| /-- The positive-weight part, all of whose supported terms have weight one. -/ | |
| def erased (a h : ℕ) : Tensor ℂ (Fin a) (YIndex a h) (ZIndex a h) := | |
| fun i j k => if totalWeight a h i.val j.val k.val = 1 then source a h i j k else 0 | |
| /-- The left retained branch, still in the common ambient coordinate spaces. -/ | |
| def leftTensor (a h : ℕ) : Tensor ℂ (Fin a) (YIndex a h) (ZIndex a h) := | |
| fun i j k => if LeftBranch a h i.val j.val k.val then 1 else 0 | |
| /-- The middle retained branch; its first leg is the actual shared first leg. -/ | |
| def middleTensor (a h : ℕ) : Tensor ℂ (Fin a) (YIndex a h) (ZIndex a h) := | |
| fun i j k => if MiddleBranch a h i.val j.val k.val then 1 else 0 | |
| /-- The right retained branch in the original coordinate spaces. -/ | |
| def rightTensor (a h : ℕ) : Tensor ℂ (Fin a) (YIndex a h) (ZIndex a h) := | |
| fun i j k => if RightBranch a h i.val j.val k.val then 1 else 0 | |
| /-- The retained tensor is exactly the sum of the three stated branches, | |
| with coefficient one on each and the original first-leg coordinates shared. -/ | |
| theorem retained_eq_three_branches (a h : ℕ) : | |
| retained a h = leftTensor a h + middleTensor a h + rightTensor a h := by | |
| funext i j k | |
| by_cases hs : Support a h i.val j.val k.val | |
| · have hsource : source a h i j k = 1 := by | |
| exact (convolution_eq_one_iff i j k).mpr hs.2.2.symm | |
| have hw := retained_support_iff hs | |
| have hlm := leftBranch_not_middleBranch (a := a) (h := h) | |
| (i := i.val) (j := j.val) (k := k.val) | |
| have hlr := leftBranch_not_rightBranch (a := a) (h := h) | |
| (i := i.val) (j := j.val) (k := k.val) | |
| have hmr := middleBranch_not_rightBranch (a := a) (h := h) | |
| (i := i.val) (j := j.val) (k := k.val) | |
| by_cases hl : LeftBranch a h i.val j.val k.val <;> | |
| by_cases hm : MiddleBranch a h i.val j.val k.val <;> | |
| by_cases hr : RightBranch a h i.val j.val k.val | |
| all_goals simp_all [retained, leftTensor, middleTensor, rightTensor] | |
| · have hsource : source a h i j k = 0 := by | |
| by_contra hz | |
| exact hs ((source_ne_zero_iff i j k).mp hz) | |
| have hl : ¬ LeftBranch a h i.val j.val k.val := fun hb => hs hb.support | |
| have hm : ¬ MiddleBranch a h i.val j.val k.val := fun hb => hs hb.support | |
| have hr : ¬ RightBranch a h i.val j.val k.val := fun hb => hs hb.support | |
| simp [retained, leftTensor, middleTensor, rightTensor, hsource, hl, hm, hr] | |
| /-- Every source term belongs either to the retained tensor or the erased one. -/ | |
| theorem source_eq_retained_add_erased (a h : ℕ) : | |
| source a h = retained a h + erased a h := by | |
| funext i j k | |
| by_cases hs : source a h i j k = 0 | |
| · simp [retained, erased, hs] | |
| · rcases totalWeight_eq_zero_or_one ((source_ne_zero_iff i j k).mp hs) with hw | hw | |
| all_goals simp [retained, erased, hw] | |
| /-- The normalized polynomial family appearing in the unshifted weights. -/ | |
| def normalizedPolynomial (a h : ℕ) : | |
| Tensor (Polynomial ℂ) (Fin a) (YIndex a h) (ZIndex a h) := | |
| fun i j k => C (retained a h i j k) + X * C (erased a h i j k) | |
| /-- The first local map fixes the common input basis. -/ | |
| def leftMap (a : ℕ) (output input : Fin a) : Polynomial ℂ := | |
| if input = output then 1 else 0 | |
| /-- The second local map assigns weight one to the middle interval. -/ | |
| def middleMap (a h : ℕ) (output input : YIndex a h) : Polynomial ℂ := | |
| if input = output then (if MiddleY a h output.val then X else 1) else 0 | |
| /-- Shift the third-leg weights by one, giving weight zero to the middle | |
| interval and weight one to the two outer intervals. -/ | |
| def rightMap (a h : ℕ) (output input : ZIndex a h) : Polynomial ℂ := | |
| if input = output then (if MiddleZ a h output.val then 1 else X) else 0 | |
| /-- One simultaneous polynomial restriction of the whole source tensor. -/ | |
| def polynomial (a h : ℕ) : | |
| Tensor (Polynomial ℂ) (Fin a) (YIndex a h) (ZIndex a h) := | |
| Tensor.restrict (leftMap a) (middleMap a h) (rightMap a h) | |
| (fun i j k => C (source a h i j k)) | |
| theorem polynomial_apply (a h : ℕ) (i : Fin a) (j : YIndex a h) | |
| (k : ZIndex a h) : | |
| polynomial a h i j k = | |
| (if MiddleY a h j.val then X else 1) * | |
| (if MiddleZ a h k.val then 1 else X) * C (source a h i j k) := by | |
| simp [polynomial, Tensor.restrict, leftMap, middleMap, rightMap, ite_mul, mul_ite] | |
| /-- The shifted polynomial restriction has precisely two possible degrees. -/ | |
| theorem polynomial_identity (a h : ℕ) (i : Fin a) (j : YIndex a h) | |
| (k : ZIndex a h) : | |
| polynomial a h i j k = | |
| X * C (retained a h i j k) + X ^ 2 * C (erased a h i j k) := by | |
| by_cases hs : source a h i j k = 0 | |
| · simp [polynomial_apply, retained, erased, hs] | |
| · have hsupport := (source_ne_zero_iff i j k).mp hs | |
| have hmiddle := middleY_of_middleZ hsupport | |
| by_cases hy : MiddleY a h j.val <;> by_cases hz : MiddleZ a h k.val | |
| all_goals | |
| simp_all [polynomial_apply, retained, erased, totalWeight, firstWeight, | |
| secondWeight, thirdWeight, pow_two] | |
| theorem polynomial_eq_X_mul_normalized (a h : ℕ) (i : Fin a) (j : YIndex a h) | |
| (k : ZIndex a h) : | |
| polynomial a h i j k = X * normalizedPolynomial a h i j k := by | |
| rw [polynomial_identity, normalizedPolynomial] | |
| ring | |
| theorem polynomial_coeff (a h : ℕ) (i : Fin a) (j : YIndex a h) | |
| (k : ZIndex a h) (n : ℕ) : | |
| (polynomial a h i j k).coeff n = | |
| (if n = 1 then retained a h i j k else 0) + | |
| (if n = 2 then erased a h i j k else 0) := by | |
| rw [polynomial_identity, Polynomial.coeff_add, | |
| mul_comm X (C (retained a h i j k)), | |
| mul_comm (X ^ 2) (C (erased a h i j k)), | |
| Polynomial.coeff_C_mul_X, Polynomial.coeff_C_mul_X_pow] | |
| theorem leftMap_degree (a : ℕ) (output input : Fin a) : | |
| (leftMap a output input).degree ≤ 0 := by | |
| by_cases heq : input = output <;> simp [leftMap, heq] | |
| theorem middleMap_degree (a h : ℕ) (output input : YIndex a h) : | |
| (middleMap a h output input).degree ≤ 1 := by | |
| by_cases heq : input = output <;> by_cases hy : MiddleY a h output.val <;> | |
| simp [middleMap, heq, hy] | |
| theorem rightMap_degree (a h : ℕ) (output input : ZIndex a h) : | |
| (rightMap a h output input).degree ≤ 1 := by | |
| by_cases heq : input = output <;> by_cases hz : MiddleZ a h output.val <;> | |
| simp [rightMap, heq, hz] | |
| /-- The three-sector construction is an actual polynomial restriction | |
| degeneration in the existing tensor API, with leading order one. -/ | |
| def restriction (a h : ℕ) : | |
| Tensor.PolynomialRestrictionDegeneration (source a h) (retained a h) 1 0 1 1 where | |
| leftMap := leftMap a | |
| middleMap := middleMap a h | |
| rightMap := rightMap a h | |
| left_degree := leftMap_degree a | |
| middle_degree := middleMap_degree a h | |
| right_degree := rightMap_degree a h | |
| vanishes := by | |
| intro i j k n hn | |
| change (polynomial a h i j k).coeff n = 0 | |
| rw [polynomial_coeff] | |
| have hn0 : n = 0 := by omega | |
| simp [hn0] | |
| leading := by | |
| intro i j k | |
| change (polynomial a h i j k).coeff 1 = retained a h i j k | |
| simp [polynomial_coeff] | |
| @[simp] theorem restriction_basePolynomial (a h : ℕ) : | |
| (restriction a h).basePolynomial = polynomial a h := rfl | |
| /-- Evaluation of the normalized family has exactly the paper's form. -/ | |
| theorem normalizedPolynomial_eval (a h : ℕ) (t : ℂ) (i : Fin a) | |
| (j : YIndex a h) (k : ZIndex a h) : | |
| (normalizedPolynomial a h i j k).eval t = | |
| retained a h i j k + t * erased a h i j k := by | |
| simp only [normalizedPolynomial, Polynomial.eval_add, Polynomial.eval_mul, | |
| Polynomial.eval_C, Polynomial.eval_X] | |
| /-- At nonzero parameters, the unshifted normalized polynomial is still an | |
| ordinary restriction: divide the first local map by the parameter. -/ | |
| theorem normalizedPolynomial_eval_restriction (a h : ℕ) (t : ℂ) (ht : t ≠ 0) : | |
| (fun i j k => (normalizedPolynomial a h i j k).eval t) = | |
| Tensor.restrict | |
| (fun output input => if input = output then t⁻¹ else 0) | |
| (fun output input => (middleMap a h output input).eval t) | |
| (fun output input => (rightMap a h output input).eval t) | |
| (source a h) := by | |
| funext i j k | |
| have hev := congrArg (fun p : Polynomial ℂ => p.eval t) | |
| (polynomial_eq_X_mul_normalized a h i j k) | |
| simp only [Polynomial.eval_mul, Polynomial.eval_X] at hev | |
| have hscaled : | |
| Tensor.restrict | |
| (fun output input => if input = output then t⁻¹ else 0) | |
| (fun output input => (middleMap a h output input).eval t) | |
| (fun output input => (rightMap a h output input).eval t) | |
| (source a h) i j k = t⁻¹ * (polynomial a h i j k).eval t := by | |
| rw [polynomial_apply] | |
| simp only [middleMap, rightMap, apply_ite, Polynomial.eval_zero, | |
| Polynomial.eval_one, Polynomial.eval_X, Polynomial.eval_mul, Polynomial.eval_C] | |
| simp [Tensor.restrict, ite_mul, mul_ite, mul_assoc] | |
| rw [hscaled, hev, ← mul_assoc, inv_mul_cancel₀ ht, one_mul] | |
| /-- Existing interpolation gives a rank bound with only linear overhead after | |
| tensor powering. -/ | |
| theorem retained_power_rankAtMost (a h r n : ℕ) | |
| (hsource : Tensor.RankAtMost (source a h) r) : | |
| Tensor.RankAtMost (Tensor.power (retained a h) n) ((2 * n + 1) * r ^ n) := by | |
| simpa using restrictionDegeneration_power_rankAtMost (restriction a h) hsource n | |
| end MatrixMultiplication.AuxiliarySeparation.Sector | |
| end | |
| end OAI | |
Xet Storage Details
- Size:
- 10.9 kB
- Xet hash:
- 5a8623675528fda3e0fbd37d80484052413c1d77747543c9607358883792a711
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.