AFTD Auto-Formalizing Theoretical Domains

matrix_trace_vecMulVec_mul_vecMulVec

theoremverified

For any finite type r and vectors u, v : r → ℝ, the trace of the product of outer products vecMulVec u u and vecMulVec v v equals the square of their dot product (u ⬝ᵥ v)^2.

Statement

theorem matrix_trace_vecMulVec_mul_vecMulVec {r : Type*} [Fintype r] (u v : r → ℝ) : Matrix.trace (Matrix.vecMulVec u u * Matrix.vecMulVec v v) = (u ⬝ᵥ v) ^ 2
Source
arXiv:2610.04498 Lemma 2.1 proof -- Rank-sensitive vertex bounds for semidefinite lifts
Verified
26 Oct 2026
Axioms
Classical.choiceQuot.soundpropext
Used by 1

Read back from the Lean

For any finite type $r$ and any vectors $u, v : r \to \mathbb{R}$, the trace of the matrix product $(\mathrm{vecMulVec}(u, u) \cdot \mathrm{vecMulVec}(v, v))$ equals the square of the dot product of $u$ and $v$, $(u \cdot_v v)^2$.

Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.

The proof, explained

The trace of the product of two rank-one outer products (u uᵀ)(v vᵀ) is computed by first contracting the product into a single outer product u ((u ⬝ᵥ v) • v)ᵀ. Taking the trace evaluates this to the dot product u ⬝ᵥ ((u ⬝ᵥ v) • v). Factoring out the scalar u ⬝ᵥ v leaves (u ⬝ᵥ v)², which matches the right-hand side by basic ring arithmetic.

  1. The trace of the product of outer products reduces to (u ⬝ᵥ v) • (u ⬝ᵥ v).

    Rewriting with Matrix.vecMulVec_mul_vecMulVec contracts the matrix product (u uᵀ)(v vᵀ) into the single outer product of u with (u ⬝ᵥ v) • v. Applying Matrix.trace_vecMulVec then turns the trace of this outer product into the dot product u ⬝ᵥ ((u ⬝ᵥ v) • v). Finally, dotProduct_smul pulls the scalar u ⬝ᵥ v out of the right argument, leaving (u ⬝ᵥ v) • (u ⬝ᵥ v).

    line 3

    uses Matrix.vecMulVec_mul_vecMulVec, Matrix.trace_vecMulVec, dotProduct_smul

      rw [Matrix.vecMulVec_mul_vecMulVec, Matrix.trace_vecMulVec, dotProduct_smul]
  2. (u ⬝ᵥ v) • (u ⬝ᵥ v) = (u ⬝ᵥ v)^2 automation

    On the real numbers, scalar multiplication coincides with ordinary multiplication, so the expression is simply x * x = x^2, which is solved by polynomial ring arithmetic.

    line 4

      ring
Matrix.vecMulVec_mul_vecMulVec
The product of two outer products (u vᵀ) and (w xᵀ) is the outer product of u with (v ⬝ᵥ w) • x.
Matrix.trace_vecMulVec
The trace of the outer product a bᵀ equals the dot product a ⬝ᵥ b.
dotProduct_smul
A scalar factor in the second argument of a dot product pulls out: v ⬝ᵥ (x • w) = x • (v ⬝ᵥ w).

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

/-- The trace of the product of outer products (u uᵀ) and (v vᵀ) equals the square of the dot product u ⬝ᵥ v. -/theorem matrix_trace_vecMulVec_mul_vecMulVec {r : Type*} [Fintype r] (u v : r → ℝ) : Matrix.trace (Matrix.vecMulVec u u * Matrix.vecMulVec v v) = (u ⬝ᵥ v) ^ 2 := by  rw [Matrix.vecMulVec_mul_vecMulVec, Matrix.trace_vecMulVec, dotProduct_smul]  ring
See it in the graphDiscuss this resultChallenge it