matrix3_trace_gram_column_factorization
For a cyclic trace decomposition over a field whose first-factor matrix ranks sum to 27+d, there are 3-by-d matrices L_t and M_s such that a_t b_s c_t a_s equals the diagonal term (a_s if t=s, zero otherwise) plus L_t times the transpose of M_s. Every column of L_t is in the column space of a_t, and every column of M_s is in the column space of the transpose of a_s.
Statement
set_option backward.isDefEq.respectTransparency false in theorem matrix3_trace_gram_column_factorization {K : Type*} [Field K] {r d : ℕ} (a b c : Fin r → Matrix (Fin 3) (Fin 3) K) (h : ∀ i j j' k k' i' : Fin 3, ∑ s, a s i j * b s j' k * c s k' i' = if j = j' ∧ k = k' ∧ i = i' then 1 else 0) (hd : ∑ s, (a s).rank = 27 + d) : ∃ L M : Fin r → Matrix (Fin 3) (Fin d) K, (∀ t s, a t * b s * c t * a s = (if t = s then a s else 0) + L t * (M s)ᵀ) ∧ (∀ t q, (L t).col q ∈ LinearMap.range (a t).mulVecLin) ∧ (∀ s q, (M s).col q ∈ LinearMap.range (a s)ᵀ.mulVecLin)
- Formalizes
- arXiv:2610.11823v3, Section 4.2, equation (4.2), including both column-space restrictions. This formalization works over every field; the minus sign outside characteristic two is absorbed into L. The split-map proof and the extension of coefficient maps are written here, with no external rank bounds or computation certificates assumed.
- Verified
- 25 Oct 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 1
- matrix3_trace_split_reconstructionThe cyclic trace coefficient identities reconstruct every 27-coordinate vector through the first-factor column ranges. This is the…
The proof, explained
The Gram map X maps an r-tuple of vectors in the column spaces of the matrices a_s to the tensor ∑_s x(s)_i b_s(j, k). Surjectivity of X onto the 27-dimensional space of 3×3×3 tensors follows from an explicit preimage construction using c, which by rank-nullity implies that ker X has dimension d = ∑_s rank(a_s) - 27. Projecting the canonical column vectors of a_s into ker X and expanding them in a chosen basis decomposes the trace product a_t b_s c_t a_s into the diagonal term plus a rank-d correction L_t (M_s)^T, where the columns of L_t and M_s lie in the column spaces of a_t and a_s^T, respectively.
The Gram map matrix3_gram_map is linear in addition and scalar multiplication automation
The map evaluates an r-tuple of vectors x on a triple of indices p by summing x(s)_{p_1} * b_s(p_2, p_3) over s. Additivity follows by distributing multiplication over addition (add_mul) and splitting the sum (Finset.sum_add_distrib). Compatibility with scalar multiplication follows by factoring out scalars (Finset.mul_sum) and associativity (mul_assoc).
uses
add_mul,Finset.sum_add_distrib,Finset.mul_sum,mul_assocmap_add' x y := by ext p simp [add_mul, Finset.sum_add_distrib] map_smul' c x := by ext p simp [Finset.mul_sum, mul_assoc]
The map matrix3_gram_preimage provides a right inverse to matrix3_gram_map
Evaluating matrix3_gram_map on matrix3_gram_preimage a c z recovers z pointwise, which is proved by matrix3_trace_split_reconstruction using the trace decomposition hypothesis h.
uses
matrix3_trace_split_reconstructionmatrix3_gram_map a b (matrix3_gram_preimage a c z) = z := by ext p exact matrix3_trace_split_reconstruction a b c h z p
The kernel of the Gram map X is d-dimensional, and we choose a basis B indexed by Fin d
The Gram map X = matrix3_gram_map a b has domain ∏_s range(a_s), whose dimension is ∑_s rank(a_s) = 27 + d by Module.finrank_pi_fintype and Matrix.rank. Since X has a right inverse, X is surjective, so its range has full dimension 27 (finrank_top). By the rank-nullity theorem (LinearMap.finrank_range_add_finrank_ker), the kernel of X has dimension (27 + d) - 27 = d. We pick a basis B for ker X indexed by Fin d using Module.finBasis and finCongr.
uses
matrix3_gram_reconstruction,Module.finrank_pi_fintype,Matrix.rank,finrank_top,LinearMap.finrank_range_add_finrank_ker,Module.finBasis,finCongrclassical let X := matrix3_gram_map a b letI : Module.Free K (LinearMap.ker X) := @Module.Free.of_divisionRing K (LinearMap.ker X) (inferInstance : DivisionRing K) (inferInstance : AddCommGroup (LinearMap.ker X)) (inferInstance : Module K (LinearMap.ker X)) have hsur : Function.Surjective X := fun z => ⟨matrix3_gram_preimage a c z, matrix3_gram_reconstruction a b c h z⟩ have hdimE : Module.finrank K (matrix3_gram_space a) = 27 + d := by simpa [matrix3_gram_space, Module.finrank_pi_fintype, Matrix.rank] using hd have hdimR : Module.finrank K (LinearMap.range X) = 27 := by rw [LinearMap.range_eq_top.mpr hsur, finrank_top] norm_num [Module.finrank_pi] have hdimN : Module.finrank K (LinearMap.ker X) = d := by have he := LinearMap.finrank_range_add_finrank_ker X rw [hdimR, hdimE] at he omega let B : Module.Basis (Fin d) K (LinearMap.ker X) := (Module.finBasis K (LinearMap.ker X)).reindex (finCongr hdimN)
The projection P(x) = x - preimage(X(x)) lands in the kernel of X, and we define canonical column vectors z(s, j)
For any x in the Gram space, X(P(x)) = X(x) - X(preimage(X(x))) = 0 by matrix3_gram_reconstruction, map_sub, and sub_self, so P(x) ∈ ker X by LinearMap.mem_ker. The j-th column of a_s is a vector v(s, j) in the range of a_s, and z(s, j) embeds v(s, j) at coordinate s and zero elsewhere using Pi.single.
uses
LinearMap.mem_ker,map_sub,matrix3_gram_reconstruction,sub_self,Pi.singlelet P (x : matrix3_gram_space a) : LinearMap.ker X := ⟨x - matrix3_gram_preimage a c (X x), by rw [LinearMap.mem_ker, map_sub] change X x - matrix3_gram_map a b (matrix3_gram_preimage a c (X x)) = 0 rw [matrix3_gram_reconstruction a b c h, sub_self]⟩ let v (s : Fin r) (j : Fin 3) : LinearMap.range (a s).mulVecLin := ⟨(a s).col j, ⟨Pi.single j 1, by simp⟩⟩ let z (s : Fin r) (j : Fin 3) : matrix3_gram_space a := Pi.single s (v s j)
The projection and coordinate map on each factor s extends to a linear map G_s from K^3 to K^d
We package the preimage operation as a linear map Y (checking linearity with Subtype.ext, map_add, mul_add, Finset.sum_add_distrib, map_smul, Finset.mul_sum, mul_assoc, mul_left_comm) and obtain P as a linear map PN(x) = x - Y(X(x)) into ker X (using smul_sub). Composing PN with the inclusion S_s of the s-th component (Pi.single_add, Pi.single_smul) and the basis coordinate isomorphism gives a linear map D_s : range(a_s) → K^d. We extend D_s from the subspace range(a_s) to all of K^3 as G_s using LinearMap.exists_extend.
uses
Subtype.ext,map_add,mul_add,Finset.sum_add_distrib,map_smul,Finset.mul_sum,mul_assoc,mul_left_comm,smul_sub,Pi.single_add,Pi.single_smul,LinearMap.exists_extendlet Y : (Fin 3 × Fin 3 × Fin 3 → K) →ₗ[K] matrix3_gram_space a := { toFun := matrix3_gram_preimage a c map_add' := by intro x y funext s apply Subtype.ext change (a s).mulVecLin (fun j => ∑ k, ∑ i, c s k i * (x + y) (i,j,k)) = (a s).mulVecLin (fun j => ∑ k, ∑ i, c s k i * x (i,j,k)) + (a s).mulVecLin (fun j => ∑ k, ∑ i, c s k i * y (i,j,k)) rw [← map_add] congr 1 ext j simp only [Pi.add_apply, mul_add, Finset.sum_add_distrib] map_smul' := by intro u x funext s apply Subtype.ext change (a s).mulVecLin (fun j => ∑ k, ∑ i, c s k i * (u • x) (i,j,k)) = u • (a s).mulVecLin (fun j => ∑ k, ∑ i, c s k i * x (i,j,k)) rw [← map_smul] congr 1 ext j simp [Finset.mul_sum, mul_assoc, mul_left_comm] } let PN : matrix3_gram_space a →ₗ[K] LinearMap.ker X := { toFun := P map_add' := by intro x y apply Subtype.ext change x + y - Y (X (x + y)) = (x - Y (X x)) + (y - Y (X y)) rw [map_add, map_add] abel map_smul' := by intro u x apply Subtype.ext change u • x - Y (X (u • x)) = u • (x - Y (X x)) simp only [map_smul, smul_sub] } let S (s : Fin r) : LinearMap.range (a s).mulVecLin →ₗ[K] matrix3_gram_space a := { toFun := fun v => (Pi.single s v : matrix3_gram_space a) map_add' := by intros; simp [Pi.single_add] map_smul' := by intros; simp [Pi.single_smul] } let D (s : Fin r) : LinearMap.range (a s).mulVecLin →ₗ[K] (Fin d → K) := B.equivFun.toLinearMap.comp (PN.comp (S s)) choose G hG using fun s => (D s).exists_extend
The matrices L and M are defined such that the entries of M_s are the basis coordinates of P(z(s, j))
We define L_t(i, q) = -(B_q(t))_i and M_s = (G_s a_s)^T. Then M_s(j, q) = (G_s(a_s col j))_q by LinearMap.toMatrix'_mulVec, Module.Basis.equivFun_apply, congrArg, and congrFun. Since G_s extends D_s, this equals the q-th coordinate of P(z(s, j)) in basis B.
uses
congrArg,Module.Basis.equivFun_apply,congrFun,LinearMap.toMatrix'_mulVeclet L : Fin r → Matrix (Fin 3) (Fin d) K := fun t i q => -((B q).val t).val i let M : Fin r → Matrix (Fin 3) (Fin d) K := fun s => ((G s).toMatrix' * a s)ᵀ have hM (s : Fin r) (j : Fin 3) (q : Fin d) : M s j q = B.repr (P (z s j)) q := by have he := congrArg (fun f : LinearMap.range (a s).mulVecLin →ₗ[K] (Fin d → K) => f (v s j) q) (hG s) change (G s) ((a s).col j) q = B.equivFun (P (z s j)) q at he rw [Module.Basis.equivFun_apply] at he change ((G s).toMatrix' * a s) q j = _ calc _ = ((G s).toMatrix' *ᵥ (a s).col j) q := rfl _ = (G s) ((a s).col j) q := congrFun ((G s).toMatrix'_mulVec _) q _ = _ := he
The trace product a_t b_s c_t a_s equals the diagonal term plus L_t (M_s)^T
Fixing indices t, s, i, j, evaluating X(z(s, j)) collapses the sum over factors to the single term at index s (Finset.sum_eq_single, Pi.single_eq_of_ne). Evaluating the preimage at this tensor gives the entry (a_t b_s c_t a_s)_{i, j} by explicit expansion over Fin 3 (Fin.sum_univ_three). Expanding P(z(s, j)) in the basis B gives coordinates M_s(j, q) (Submodule.coe_sum, Finset.sum_apply). Since P(z(s, j)) = z(s, j) - preimage(X(z(s, j))), evaluating at component t and row i yields (a_t b_s c_t a_s)_{i, j} = (if t = s then a_s else 0)_{i, j} + ∑_q L_t(i, q) M_s(j, q) using neg_mul, Finset.sum_neg_distrib, and mul_comm.
uses
Finset.sum_eq_single,Pi.single_eq_of_ne,Submodule.coe_sum,Finset.sum_apply,Fin.sum_univ_three,neg_mul,Finset.sum_neg_distrib,mul_commrefine ⟨L, M, ?_, ?_, ?_⟩ · intro t s ext i j have hsimp (p : Fin 3 × Fin 3 × Fin 3) : (X (z s j)) p = a s p.1 j * b s p.2.1 p.2.2 := by change (∑ q, ((Pi.single s (v s j) : matrix3_gram_space a) q).val p.1 * b q p.2.1 p.2.2) = _ rw [Finset.sum_eq_single s] · simp [v] · intro q _ hqs simp [Pi.single_eq_of_ne hqs] · simp have he := congrArg (fun x : LinearMap.ker X => (x.val t).val i) (B.sum_repr (P (z s j))) simp only [Submodule.coe_sum, Finset.sum_apply, Submodule.coe_smul, Pi.smul_apply, smul_eq_mul] at he change (∑ q, B.repr (P (z s j)) q * ((B q).val t).val i) = ((z s j) t).val i - (matrix3_gram_preimage a c (X (z s j)) t).val i at he simp_rw [← hM s j] at he have hexpand : (a t * b s * c t * a s) i j = (matrix3_gram_preimage a c (X (z s j)) t).val i := by simp only [matrix3_gram_preimage, mulVecLin_apply, mulVec, dotProduct, hsimp] simp only [Matrix.mul_apply, Fin.sum_univ_three] ring have hz : ((z s j) t).val i = ((if t = s then a s else 0) : Matrix (Fin 3) (Fin 3) K) i j := by by_cases hts : t = s · subst t; simp [z, v] · simp [z, v, hts] rw [← hexpand, hz] at he change (a t * b s * c t * a s) i j = ((if t = s then a s else 0) : Matrix (Fin 3) (Fin 3) K) i j + ∑ q, L t i q * M s j q simp only [L, neg_mul, Finset.sum_neg_distrib] simp_rw [mul_comm (M s j _)] at he linear_combination he
Every column of L_t lies in the column space of a_t
Column q of L_t is -B_q(t). Because B_q belongs to the kernel of X, its t-th component B_q(t) lies in LinearMap.range(a_t.mulVecLin). Since a subspace is closed under negation, -B_q(t) also belongs to this range.
uses
LinearMap.range· intro t q change -((B q).val t).val ∈ LinearMap.range (a t).mulVecLin exact (LinearMap.range (a t).mulVecLin).neg_mem ((B q).val t).property
Every column of M_s lies in the column space of a_s^T
Since M_s = (G_s a_s)^T, column q of M_s at row j is ∑_i a_s(i, j) (G_s)_{q, i}. Thus the q-th row of the matrix of G_s serves as the preimage vector under (a_s)^T, showing that column q of M_s lies in the range of (a_s)^T, using commutativity of multiplication (mul_comm).
uses
mul_comm· intro s q refine ⟨fun i => (G s).toMatrix' q i, ?_⟩ ext j change (∑ i, a s i j * (G s).toMatrix' q i) = ∑ i, (G s).toMatrix' q i * a s i j exact Finset.sum_congr rfl (fun i _ => mul_comm _ _)
add_mul- Right distributivity of multiplication over addition: (a + b) * c = a * c + b * c
Finset.sum_add_distrib- Distributivity of a finite sum over addition: the sum of a sum equals the sum of the sums
Finset.mul_sum- Distributivity of multiplication over a finite sum: a * ∑ i, f i = ∑ i, a * f i
mul_assoc- Associativity of multiplication: (a * b) * c = a * (b * c)
matrix3_trace_split_reconstruction- Reconstruction identity for the cyclic trace decomposition: evaluating the Gram map on the preimage of z reconstructs z
matrix3_gram_reconstruction- The Gram map evaluated on the preimage of z recovers z
Module.finrank_pi_fintype- The dimension of a finite product of vector spaces is the sum of their individual dimensions
Matrix.rank- The rank of a matrix is the dimension of the range of its associated linear map
finrank_top- The dimension of the top submodule of a vector space equals the dimension of the space
LinearMap.finrank_range_add_finrank_ker- The rank-nullity theorem: the dimension of the range plus the dimension of the kernel equals the dimension of the domain
Module.finBasis- Every finite-dimensional free module over a field has a standard basis indexed by Fin (finrank K V)
finCongr- An equality of natural numbers n = m induces an equivalence between Fin n and Fin m
LinearMap.mem_ker- A vector belongs to the kernel of a linear map if and only if the map sends it to zero
map_sub- A linear map preserves subtraction: f (x - y) = f x - f y
sub_self- Subtracting any element of an additive group from itself yields zero
Pi.single- The indicator function that takes a given value at one index and zero elsewhere
Subtype.ext- Two subtype elements are equal if their underlying values are equal
map_add- A linear map preserves addition: f (x + y) = f x + f y
mul_add- Left distributivity of multiplication over addition: a * (b + c) = a * b + a * c
map_smul- A linear map preserves scalar multiplication: f (c • x) = c • f x
mul_left_comm- In a commutative semigroup, a * (b * c) = b * (a * c)
smul_sub- Scalar multiplication distributes over subtraction: c • (x - y) = c • x - c • y
Pi.single_add- The single-coordinate embedding preserves addition
Pi.single_smul- The single-coordinate embedding preserves scalar multiplication
LinearMap.exists_extend- Any linear map defined on a subspace of a vector space over a division ring can be extended to the ambient space
LinearMap.toMatrix'_mulVec- Applying the matrix representation of a linear map via matrix-vector multiplication equals evaluating the map
Module.Basis.equivFun_apply- The coordinate representation equivalence for a basis evaluates to the coordinate representation function
congrArg- Applying a function to equal arguments yields equal results
congrFun- Equal functions applied to the same argument yield equal results
Finset.sum_eq_single- A finite sum whose terms all vanish except at one index reduces to that single term
Pi.single_eq_of_ne- The single-coordinate indicator function evaluates to zero at any index distinct from its support
Submodule.coe_sum- Coercion of a finite sum in a submodule to the ambient space equals the sum of the coerced terms
Finset.sum_apply- Evaluating a finite sum of functions at a point equals the sum of their individual values at that point
Fin.sum_univ_three- A sum over Fin 3 equals the sum of the terms at indices 0, 1, and 2
neg_mul- Multiplication distributes over negation: (-a) * b = -(a * b)
Finset.sum_neg_distrib- A finite sum of negated elements equals the negation of the sum
mul_comm- Multiplication in a commutative magma is commutative: a * b = b * a
LinearMap.range- The range of a linear map as a submodule
Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.
Lean source view module on GitHub
Choose a tactic — a marked line — to see the goals Lean had before and after it, as in Lean’s infoview. Step with ← → or j k.
open Matrix Finsetnoncomputable sectionvariable {K : Type*} [Field K] {r : ℕ}private abbrev matrix3_gram_space (a : Fin r → Matrix (Fin 3) (Fin 3) K) := ∀ s, LinearMap.range (a s).mulVecLinprivate def matrix3_gram_map (a b : Fin r → Matrix (Fin 3) (Fin 3) K) : matrix3_gram_space a →ₗ[K] (Fin 3 × Fin 3 × Fin 3 → K) where toFun x p := ∑ s, (x s).val p.1 * b s p.2.1 p.2.2 map_add' x y := by ext p simp [add_mul, Finset.sum_add_distrib] map_smul' c x := by ext p simp [Finset.mul_sum, mul_assoc]private def matrix3_gram_preimage (a c : Fin r → Matrix (Fin 3) (Fin 3) K) (z : Fin 3 × Fin 3 × Fin 3 → K) : matrix3_gram_space a := fun s => ⟨(a s).mulVecLin (fun j => ∑ k, ∑ i, c s k i * z (i,j,k)), ⟨_, rfl⟩⟩private theorem matrix3_gram_reconstruction (a b c : Fin r → Matrix (Fin 3) (Fin 3) K) (h : ∀ i j j' k k' i' : Fin 3, ∑ s, a s i j * b s j' k * c s k' i' = if j = j' ∧ k = k' ∧ i = i' then 1 else 0) (z : Fin 3 × Fin 3 × Fin 3 → K) : matrix3_gram_map a b (matrix3_gram_preimage a c z) = z := by ext p exact matrix3_trace_split_reconstruction a b c h z pendset_option backward.isDefEq.respectTransparency false intheorem matrix3_trace_gram_column_factorization {K : Type*} [Field K] {r d : ℕ} (a b c : Fin r → Matrix (Fin 3) (Fin 3) K) (h : ∀ i j j' k k' i' : Fin 3, ∑ s, a s i j * b s j' k * c s k' i' = if j = j' ∧ k = k' ∧ i = i' then 1 else 0) (hd : ∑ s, (a s).rank = 27 + d) : ∃ L M : Fin r → Matrix (Fin 3) (Fin d) K, (∀ t s, a t * b s * c t * a s = (if t = s then a s else 0) + L t * (M s)ᵀ) ∧ (∀ t q, (L t).col q ∈ LinearMap.range (a t).mulVecLin) ∧ (∀ s q, (M s).col q ∈ LinearMap.range (a s)ᵀ.mulVecLin) := by classical let X := matrix3_gram_map a b letI : Module.Free K (LinearMap.ker X) := @Module.Free.of_divisionRing K (LinearMap.ker X) (inferInstance : DivisionRing K) (inferInstance : AddCommGroup (LinearMap.ker X)) (inferInstance : Module K (LinearMap.ker X)) have hsur : Function.Surjective X := fun z => ⟨matrix3_gram_preimage a c z, matrix3_gram_reconstruction a b c h z⟩ have hdimE : Module.finrank K (matrix3_gram_space a) = 27 + d := by simpa [matrix3_gram_space, Module.finrank_pi_fintype, Matrix.rank] using hd have hdimR : Module.finrank K (LinearMap.range X) = 27 := by rw [LinearMap.range_eq_top.mpr hsur, finrank_top] norm_num [Module.finrank_pi] have hdimN : Module.finrank K (LinearMap.ker X) = d := by have he := LinearMap.finrank_range_add_finrank_ker X rw [hdimR, hdimE] at he omega let B : Module.Basis (Fin d) K (LinearMap.ker X) := (Module.finBasis K (LinearMap.ker X)).reindex (finCongr hdimN) let P (x : matrix3_gram_space a) : LinearMap.ker X := ⟨x - matrix3_gram_preimage a c (X x), by rw [LinearMap.mem_ker, map_sub] change X x - matrix3_gram_map a b (matrix3_gram_preimage a c (X x)) = 0 rw [matrix3_gram_reconstruction a b c h, sub_self]⟩ let v (s : Fin r) (j : Fin 3) : LinearMap.range (a s).mulVecLin := ⟨(a s).col j, ⟨Pi.single j 1, by simp⟩⟩ let z (s : Fin r) (j : Fin 3) : matrix3_gram_space a := Pi.single s (v s j) let Y : (Fin 3 × Fin 3 × Fin 3 → K) →ₗ[K] matrix3_gram_space a := { toFun := matrix3_gram_preimage a c map_add' := by intro x y funext s apply Subtype.ext change (a s).mulVecLin (fun j => ∑ k, ∑ i, c s k i * (x + y) (i,j,k)) = (a s).mulVecLin (fun j => ∑ k, ∑ i, c s k i * x (i,j,k)) + (a s).mulVecLin (fun j => ∑ k, ∑ i, c s k i * y (i,j,k)) rw [← map_add] congr 1 ext j simp only [Pi.add_apply, mul_add, Finset.sum_add_distrib] map_smul' := by intro u x funext s apply Subtype.ext change (a s).mulVecLin (fun j => ∑ k, ∑ i, c s k i * (u • x) (i,j,k)) = u • (a s).mulVecLin (fun j => ∑ k, ∑ i, c s k i * x (i,j,k)) rw [← map_smul] congr 1 ext j simp [Finset.mul_sum, mul_assoc, mul_left_comm] } let PN : matrix3_gram_space a →ₗ[K] LinearMap.ker X := { toFun := P map_add' := by intro x y apply Subtype.ext change x + y - Y (X (x + y)) = (x - Y (X x)) + (y - Y (X y)) rw [map_add, map_add] abel map_smul' := by intro u x apply Subtype.ext change u • x - Y (X (u • x)) = u • (x - Y (X x)) simp only [map_smul, smul_sub] } let S (s : Fin r) : LinearMap.range (a s).mulVecLin →ₗ[K] matrix3_gram_space a := { toFun := fun v => (Pi.single s v : matrix3_gram_space a) map_add' := by intros; simp [Pi.single_add] map_smul' := by intros; simp [Pi.single_smul] } let D (s : Fin r) : LinearMap.range (a s).mulVecLin →ₗ[K] (Fin d → K) := B.equivFun.toLinearMap.comp (PN.comp (S s)) choose G hG using fun s => (D s).exists_extend let L : Fin r → Matrix (Fin 3) (Fin d) K := fun t i q => -((B q).val t).val i let M : Fin r → Matrix (Fin 3) (Fin d) K := fun s => ((G s).toMatrix' * a s)ᵀ have hM (s : Fin r) (j : Fin 3) (q : Fin d) : M s j q = B.repr (P (z s j)) q := by have he := congrArg (fun f : LinearMap.range (a s).mulVecLin →ₗ[K] (Fin d → K) => f (v s j) q) (hG s) change (G s) ((a s).col j) q = B.equivFun (P (z s j)) q at he rw [Module.Basis.equivFun_apply] at he change ((G s).toMatrix' * a s) q j = _ calc _ = ((G s).toMatrix' *ᵥ (a s).col j) q := rfl _ = (G s) ((a s).col j) q := congrFun ((G s).toMatrix'_mulVec _) q _ = _ := he refine ⟨L, M, ?_, ?_, ?_⟩ · intro t s ext i j have hsimp (p : Fin 3 × Fin 3 × Fin 3) : (X (z s j)) p = a s p.1 j * b s p.2.1 p.2.2 := by change (∑ q, ((Pi.single s (v s j) : matrix3_gram_space a) q).val p.1 * b q p.2.1 p.2.2) = _ rw [Finset.sum_eq_single s] · simp [v] · intro q _ hqs simp [Pi.single_eq_of_ne hqs] · simp have he := congrArg (fun x : LinearMap.ker X => (x.val t).val i) (B.sum_repr (P (z s j))) simp only [Submodule.coe_sum, Finset.sum_apply, Submodule.coe_smul, Pi.smul_apply, smul_eq_mul] at he change (∑ q, B.repr (P (z s j)) q * ((B q).val t).val i) = ((z s j) t).val i - (matrix3_gram_preimage a c (X (z s j)) t).val i at he simp_rw [← hM s j] at he have hexpand : (a t * b s * c t * a s) i j = (matrix3_gram_preimage a c (X (z s j)) t).val i := by simp only [matrix3_gram_preimage, mulVecLin_apply, mulVec, dotProduct, hsimp] simp only [Matrix.mul_apply, Fin.sum_univ_three] ring have hz : ((z s j) t).val i = ((if t = s then a s else 0) : Matrix (Fin 3) (Fin 3) K) i j := by by_cases hts : t = s · subst t; simp [z, v] · simp [z, v, hts] rw [← hexpand, hz] at he change (a t * b s * c t * a s) i j = ((if t = s then a s else 0) : Matrix (Fin 3) (Fin 3) K) i j + ∑ q, L t i q * M s j q simp only [L, neg_mul, Finset.sum_neg_distrib] simp_rw [mul_comm (M s j _)] at he linear_combination he · intro t q change -((B q).val t).val ∈ LinearMap.range (a t).mulVecLin exact (LinearMap.range (a t).mulVecLin).neg_mem ((B q).val t).property · intro s q refine ⟨fun i => (G s).toMatrix' q i, ?_⟩ ext j change (∑ i, a s i j * (G s).toMatrix' q i) = ∑ i, (G s).toMatrix' q i * a s i j exact Finset.sum_congr rfl (fun i _ => mul_comm _ _)