AFTD Auto-Formalizing Theoretical Domains

matrix_rank_one_sandwich_identity

theoremverified

For vectors u, v and a square matrix W over a commutative ring, (u v^T) W (u v^T) = (v · (W u)) • (u v^T).

Statement

theorem matrix_rank_one_sandwich_identity {n : Type*} [Fintype n] [DecidableEq n] {R : Type*} [CommRing R] (u v : n → R) (W : Matrix n n R) : Matrix.vecMulVec u v * W * Matrix.vecMulVec u v = (v ⬝ᵥ (Matrix.mulVec W u)) • Matrix.vecMulVec u v
Source
arXiv:2611.06562 Appendix A
Verified
06 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Used by 1

Read back from the Lean

Let $n$ be a finite type with decidable equality, and let $R$ be a commutative ring. For any vectors $u, v : n \to R$ and any $n \times n$ matrix $W$ with entries in $R$, the matrix product $(\text{vecMulVec}(u, v) \cdot W) \cdot \text{vecMulVec}(u, v)$ (the outer product $u v^T$ multiplied by $W$ and then by $u v^T$) equals the outer product $\text{vecMulVec}(u, v)$ scaled by the dot product $v \cdot (W u)$.

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 identity is proved by rewriting the expression step by step using standard matrix and outer-product identities. Associativity first groups the action of W onto the right outer product, turning it into (W u) vᵀ. Multiplying the two outer products evaluates the inner product v · (W u) as a scalar factor, which is then pulled out to the front.

  1. (u vᵀ) W (u vᵀ) = (v · (W u)) • (u vᵀ)

    The identity follows from four successive rewrites: 1. Reassociate the product as (u vᵀ) (W (u vᵀ)) using Matrix.mul_assoc. 2. Simplify W (u vᵀ) to (W u) vᵀ via Matrix.mul_vecMulVec. 3. Compute the product of outer products (u vᵀ) ((W u) vᵀ) as u ((v · (W u)) • v)ᵀ using Matrix.vecMulVec_mul_vecMulVec. 4. Factor the scalar (v · (W u)) out of the outer product via Matrix.vecMulVec_smul to obtain the right-hand side.

    line 3

    uses Matrix.mul_assoc, Matrix.mul_vecMulVec, Matrix.vecMulVec_mul_vecMulVec, Matrix.vecMulVec_smul

      rw [Matrix.mul_assoc, Matrix.mul_vecMulVec, Matrix.vecMulVec_mul_vecMulVec, Matrix.vecMulVec_smul]
Matrix.mul_assoc
Matrix multiplication is associative: (L * M) * N = L * (M * N).
Matrix.mul_vecMulVec
Multiplying a matrix by an outer product satisfies M * (x yᵀ) = (M x) yᵀ.
Matrix.vecMulVec_mul_vecMulVec
The product of two rank-one outer products satisfies (u vᵀ) * (w xᵀ) = u ((v · w) • x)ᵀ.
Matrix.vecMulVec_smul
Scalar multiplication in the right factor of an outer product pulls out: u (r • v)ᵀ = r • (u vᵀ).

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

/-- Rank-one sandwich identity: (u v^T) W (u v^T) = (v . W u) (u v^T). -/theorem matrix_rank_one_sandwich_identity {n : Type*} [Fintype n] [DecidableEq n] {R : Type*} [CommRing R] (u v : n → R) (W : Matrix n n R) : Matrix.vecMulVec u v * W * Matrix.vecMulVec u v = (v ⬝ᵥ (Matrix.mulVec W u)) • Matrix.vecMulVec u v := by  rw [Matrix.mul_assoc, Matrix.mul_vecMulVec, Matrix.vecMulVec_mul_vecMulVec, Matrix.vecMulVec_smul]
See it in the graphDiscuss this resultChallenge it