magic_rectangle_sos_term1
Let A be an ℝ-algebra and let D, C, B : Fin 3 → A satisfy B j ^ 2 = 1 for all j, and every D and C commuting with every B. Setting X j = D j + C j, Z j = X j * B j, and S = ∑ j : Fin 3, X j * B j, then for any q : ℝ, ∑ j : Fin 3, (Z j - q • 1) ^ 2 = (∑ j : Fin 3, X j ^ 2) - (2 * q) • S + (3 * q ^ 2) • 1.
Statement
theorem magic_rectangle_sos_term1 {A : Type*} [Ring A] [Algebra ℝ A] (D C B : Fin 3 → A) (hB_sq : ∀ j, B j ^ 2 = 1) (hDB_comm : ∀ j k, D j * B k = B k * D j) (hCB_comm : ∀ j k, C j * B k = B k * C j) (q : ℝ) : let X := fun j => D j + C j let Z := fun j => X j * B j let S := ∑ j : Fin 3, X j * B j ∑ j : Fin 3, (Z j - q • (1 : A)) ^ 2 = (∑ j : Fin 3, X j ^ 2) - (2 * q) • S + (3 * q ^ 2) • (1 : A)
- Source
- step towards magic_rectangle_algebraic_sos_identity
- Verified
- 18 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Used by 1
- magic_rectangle_algebraic_sos_identityLet A be an ℝ-algebra and let D, C, B : Fin 3 → A satisfy D j ^ 2 = C j ^ 2 = B j ^ 2 = 1 for all j, D 0 * D 1 * D 2 = 1, C 0 * C 1 * C 2…
The proof, explained
The proof evaluates the sum of squares ∑ j : Fin 3, (Z j - q • 1) ^ 2 term by term. Because each B j commutes with X j = D j + C j and squares to 1, each squared term Z j ^ 2 = (X j * B j) ^ 2 simplifies to X j ^ 2, which allows expanding each (Z j - q • 1) ^ 2 as X j ^ 2 - (2 * q) • Z j + (q ^ 2) • 1. Summing over the three indices of Fin 3 and regrouping via ℝ-module linearity yields the desired identity.
The goal is rephrased in terms of X j = D j + C j and Z j = X j * B j, with S represented as ∑ j, Z j.
Unfolds the definitions of X, Z, and S, establishing that the identity to prove is ∑ j : Fin 3, (Z j - q • 1) ^ 2 = (∑ j, X j ^ 2) - (2 * q) • (∑ j, Z j) + (3 * q ^ 2) • 1.
dsimp let X := fun j => D j + C j let Z := fun j => X j * B j change ∑ j : Fin 3, (Z j - q • (1 : A)) ^ 2 = (∑ j : Fin 3, X j ^ 2) - (2 * q) • (∑ j : Fin 3, Z j) + (3 * q ^ 2) • (1 : A)
For each j : Fin 3, B j and X j commute: B j * X j = X j * B j.
Expanding X j = D j + C j and distributing multiplication, this follows directly from the commutation hypotheses D j * B j = B j * D j and C j * B j = B j * C j.
uses
mul_add,add_mulhave hcomm (j : Fin 3) : B j * X j = X j * B j := by dsimp [X] simp only [mul_add, add_mul, ← hDB_comm j j, ← hCB_comm j j]
For each j : Fin 3, Z j ^ 2 = X j ^ 2.
Since Z j = X j * B j, the square expands to (X j * B j) * (X j * B j) = X j * (B j * X j) * B j. Applying commutativity B j * X j = X j * B j allows reassociating the product to (X j * X j) * (B j * B j). The assumption B j ^ 2 = 1 then simplifies this to X j * X j.
uses
pow_two,mul_onehave hz (j : Fin 3) : Z j * Z j = X j * X j := by dsimp [Z] calc (X j * B j) * (X j * B j) = X j * (B j * X j) * B j := by noncomm_ring _ = X j * (X j * B j) * B j := by rw [hcomm] _ = (X j * X j) * (B j * B j) := by noncomm_ring _ = X j * X j := by have hb : B j * B j = 1 := by simpa [pow_two] using hB_sq j rw [hb, mul_one]
For each j : Fin 3, (Z j - q • 1) ^ 2 = X j ^ 2 - (2 * q) • Z j + (q ^ 2) • 1.
Expanding (Z j - q • 1) ^ 2 into a product and applying distributivity along with the module scalar action rules produces Z j ^ 2 - q • Z j - q • Z j + q ^ 2 • 1. Substituting Z j ^ 2 = X j ^ 2 and combining the cross-terms via ℝ-module arithmetic yields the quadratic expression.
uses
pow_two,sub_mul,mul_sub,smul_mul_assoc,mul_smul_comm,one_mul,mul_one,smul_smulhave hone (j : Fin 3) : (Z j - q • (1 : A)) ^ 2 = X j ^ 2 - (2 * q) • Z j + (q ^ 2) • (1 : A) := by rw [pow_two, pow_two, ← hz j] simp only [sub_mul, mul_sub, smul_mul_assoc, mul_smul_comm, one_mul, mul_one, smul_smul] module
The total sum ∑ j : Fin 3, (Z j - q • 1) ^ 2 equals ∑ j : Fin 3, (X j ^ 2 - (2 * q) • Z j + (q ^ 2) • 1).
By term-by-term congruence of finite sums, each summand (Z j - q • 1) ^ 2 is replaced by its expanded form proved in the previous step.
uses
Finset.sum_congrcalc (∑ j : Fin 3, (Z j - q • (1 : A)) ^ 2) = ∑ j : Fin 3, (X j ^ 2 - (2 * q) • Z j + (q ^ 2) • (1 : A)) := by apply Finset.sum_congr rfl intro j hj exact hone j
∑ j : Fin 3, (X j ^ 2 - (2 * q) • Z j + (q ^ 2) • 1) = (∑ j : Fin 3, X j ^ 2) - (2 * q) • (∑ j : Fin 3, Z j) + (3 * q ^ 2) • 1.
Unfolding the sum over Fin 3 into the explicit three-term sum for indices 0, 1, 2 and distributing scalar multiplication over addition, the terms are rearranged by ℝ-module linearity: the X j ^ 2 terms form the first sum, the -(2 * q) • Z j terms factor into -(2 * q) • ∑ Z j, and the three constant terms (q ^ 2) • 1 sum to (3 * q ^ 2) • 1.
uses
Fin.sum_univ_three,smul_add_ = (∑ j : Fin 3, X j ^ 2) - (2 * q) • (∑ j : Fin 3, Z j) + (3 * q ^ 2) • (1 : A) := by simp only [Fin.sum_univ_three, smul_add] module
add_mul- Right distributivity of multiplication over addition: (a + b) * c = a * c + b * c
Fin.sum_univ_three- Expansion of a sum over Fin 3 into the three-term sum f 0 + f 1 + f 2
Finset.sum_congr- Congruence for finite sums: two sums over the same set are equal if their summands are pointwise equal
mul_one- Right identity for multiplication: a * 1 = a
mul_add- Left distributivity of multiplication over addition: a * (b + c) = a * b + a * c
mul_sub- Left distributivity of multiplication over subtraction: a * (b - c) = a * b - a * c
mul_smul_comm- Commutativity of multiplication on the right with scalar multiplication: x * (s • y) = s • (x * y)
one_mul- Left identity for multiplication: 1 * a = a
pow_two- Definition of the square of an element: a ^ 2 = a * a
smul_mul_assoc- Associativity of scalar multiplication with ring multiplication: (r • x) * y = r • (x * y)
smul_add- Distributivity of scalar multiplication over addition: a • (b₁ + b₂) = a • b₁ + a • b₂
smul_smul- Composition of scalar multiplications: a₁ • (a₂ • b) = (a₁ * a₂) • b
sub_mul- Right distributivity of multiplication over subtraction: (a - b) * c = a * c - b * c
- The proof uses `noncomm_ring` to handle associativity and bracket rearranging in non-commutative rings, and `module` to handle scalar arithmetic and linear combinations over ℝ in the algebra A.
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.
/-- Expansion of the first sum of squares T1 in the Magic Rectangle SOS identity. -/theorem magic_rectangle_sos_term1 {A : Type*} [Ring A] [Algebra ℝ A] (D C B : Fin 3 → A) (hB_sq : ∀ j, B j ^ 2 = 1) (hDB_comm : ∀ j k, D j * B k = B k * D j) (hCB_comm : ∀ j k, C j * B k = B k * C j) (q : ℝ) : let X := fun j => D j + C j let Z := fun j => X j * B j let S := ∑ j : Fin 3, X j * B j ∑ j : Fin 3, (Z j - q • (1 : A)) ^ 2 = (∑ j : Fin 3, X j ^ 2) - (2 * q) • S + (3 * q ^ 2) • (1 : A) := by dsimp let X := fun j => D j + C j let Z := fun j => X j * B j change ∑ j : Fin 3, (Z j - q • (1 : A)) ^ 2 = (∑ j : Fin 3, X j ^ 2) - (2 * q) • (∑ j : Fin 3, Z j) + (3 * q ^ 2) • (1 : A) have hcomm (j : Fin 3) : B j * X j = X j * B j := by dsimp [X] simp only [mul_add, add_mul, ← hDB_comm j j, ← hCB_comm j j] have hz (j : Fin 3) : Z j * Z j = X j * X j := by dsimp [Z] calc (X j * B j) * (X j * B j) = X j * (B j * X j) * B j := by noncomm_ring _ = X j * (X j * B j) * B j := by rw [hcomm] _ = (X j * X j) * (B j * B j) := by noncomm_ring _ = X j * X j := by have hb : B j * B j = 1 := by simpa [pow_two] using hB_sq j rw [hb, mul_one] have hone (j : Fin 3) : (Z j - q • (1 : A)) ^ 2 = X j ^ 2 - (2 * q) • Z j + (q ^ 2) • (1 : A) := by rw [pow_two, pow_two, ← hz j] simp only [sub_mul, mul_sub, smul_mul_assoc, mul_smul_comm, one_mul, mul_one, smul_smul] module calc (∑ j : Fin 3, (Z j - q • (1 : A)) ^ 2) = ∑ j : Fin 3, (X j ^ 2 - (2 * q) • Z j + (q ^ 2) • (1 : A)) := by apply Finset.sum_congr rfl intro j hj exact hone j _ = (∑ j : Fin 3, X j ^ 2) - (2 * q) • (∑ j : Fin 3, Z j) + (3 * q ^ 2) • (1 : A) := by simp only [Fin.sum_univ_three, smul_add] module