AFTD Auto-Formalizing Theoretical Domains

real_symmetric_commuting_pair_orthogonal_diagonalization

theoremverified

Commuting real symmetric square matrices have a common real orthogonal eigenbasis.

Statement

theorem real_symmetric_commuting_pair_orthogonal_diagonalization :
  ∀ (n : ℕ) (R S : Matrix (Fin n) (Fin n) ℝ),
    R.transpose = R → S.transpose = S → R*S = S*R →
    ∃ (O : Matrix (Fin n) (Fin n) ℝ) (r s : Fin n → ℝ),
      O.transpose * O = 1 ∧ O * O.transpose = 1 ∧
      R = O * Matrix.diagonal r * O.transpose ∧
      S = O * Matrix.diagonal s * O.transpose
Source
Linear-algebra helper for the rank-four source in OP-693.
Verified
12 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 2
  • IsSymmetricA symmetric bilinear function.
  • VThe ambient space $V = \mathbb{F}_p^n \times \mathbb{F}_p^n$ of pairs of coordinate vectors.
Used by 3

The proof, explained

The proof converts the pair of commuting real symmetric matrices R and S into commuting self-adjoint linear operators A and B on the Euclidean space ℝⁿ. By the spectral theorem for commuting self-adjoint operators, ℝⁿ decomposes into an internal direct sum of pairwise orthogonal joint eigenspaces. Choosing an orthonormal basis within each joint eigenspace and assembling them produces a global orthonormal basis E of ℝⁿ consisting of simultaneous eigenvectors. The matrix O whose columns are the vectors of E is orthogonal and satisfies the intertwining equations R * O = O * diag(r) and S * O = O * diag(s), from which multiplying by Oᵀ on the right yields the simultaneous orthogonal diagonalizations R = O * diag(r) * Oᵀ and S = O * diag(s) * Oᵀ.

  1. The matrices R and S define symmetric (self-adjoint) linear operators A and B on Euclidean space ℝⁿ.

    For real matrices, the conjugate transpose is identical to the ordinary transpose. Since Rᵀ = R and Sᵀ = S, the matrices are Hermitian, which guarantees that their associated linear maps on Euclidean space are symmetric operators.

    lines 11–19

    uses Matrix.isSymmetric_toEuclideanLin_iff.mpr, Matrix.conjTranspose_eq_transpose_of_trivial

      classical
      let A := R.toEuclideanLin
      let B := S.toEuclideanLin
      have hA : A.IsSymmetric := by
        apply Matrix.isSymmetric_toEuclideanLin_iff.mpr
        simpa [Matrix.IsHermitian, Matrix.conjTranspose_eq_transpose_of_trivial] using hR
      have hB : B.IsSymmetric := by
        apply Matrix.isSymmetric_toEuclideanLin_iff.mpr
        simpa [Matrix.IsHermitian, Matrix.conjTranspose_eq_transpose_of_trivial] using hS
  2. The linear operators A and B commute: A * B = B * A.

    By linear map extensionality, it suffices to check that (A * B) x = (B * A) x for every vector x. In coordinates, evaluating this composition corresponds to matrix-vector multiplication R *ᵥ (S *ᵥ x) = (R * S) *ᵥ x. The hypothesis R * S = S * R then yields (S * R) *ᵥ x = S *ᵥ (R *ᵥ x), establishing commutativity.

    lines 20–25

    uses LinearMap.ext, WithLp.ofLp_injective, Module.End.mul_apply, Matrix.ofLp_toEuclideanLin_apply, Matrix.mulVec_mulVec

      have hAB : Commute A B := by
        apply LinearMap.ext
        intro x
        apply WithLp.ofLp_injective 2
        simp only [Module.End.mul_apply, A, B, Matrix.ofLp_toEuclideanLin_apply]
        rw [Matrix.mulVec_mulVec, Matrix.mulVec_mulVec, hRS]
  3. Euclidean space ℝⁿ decomposes as an internal direct sum of the mutually orthogonal joint eigenspaces of A and B.

    For each pair of real eigenvalues (μ, λ), the joint eigenspace V is the intersection of the eigenspace of A for λ and that of B for μ. Because A and B are commuting self-adjoint operators on a finite-dimensional real inner product space, their joint eigenspaces are mutually orthogonal and span the entire space as an internal direct sum.

    lines 26–30

      let V : ℝ × ℝ → Submodule ℝ (EuclideanSpace ℝ (Fin n)) := fun i =>
        Module.End.eigenspace A i.2 ⊓ Module.End.eigenspace B i.1
      have hV : DirectSum.IsInternal V := hA.directSum_isInternal_of_commute hB hAB
      have hVo : OrthogonalFamily ℝ (fun i => V i) (fun i => (V i).subtypeₗᵢ) :=
        hA.orthogonalFamily_eigenspace_inf_eigenspace hB
  4. There is an orthonormal basis E = (Eⱼ) of ℝⁿ indexed by Fin n together with eigenvalue sequences r, s : Fin n → ℝ.

    We take the standard orthonormal basis of each joint eigenspace V(i) and collect them into a basis C of the full space. Because the subspaces form an orthogonal direct sum, C is orthonormal. Since ℝⁿ has finite dimension n, the index type is finite of size n, allowing us to reindex C to an orthonormal basis E indexed by Fin n, where r and s assign each basis vector its respective eigenvalues under A and B.

    lines 31–43

    uses DirectSum.IsInternal.collectedBasis_orthonormal, Module.Finite.finite_basis, Fintype.ofFinite

      let vf : ∀ i : ℝ × ℝ, Module.Basis (Fin (Module.finrank ℝ (V i))) ℝ (V i) :=
        fun i => (stdOrthonormalBasis ℝ (V i)).toBasis
      let C := hV.collectedBasis vf
      have hCo : Orthonormal ℝ C := DirectSum.IsInternal.collectedBasis_orthonormal hVo hV
        (fun i => (stdOrthonormalBasis ℝ (V i)).orthonormal)
      letI : Finite (Σ i : ℝ × ℝ, Fin (Module.finrank ℝ (V i))) :=
        Module.Finite.finite_basis C
      letI : Fintype (Σ i : ℝ × ℝ, Fin (Module.finrank ℝ (V i))) := Fintype.ofFinite _
      let D := C.toOrthonormalBasis hCo
      let e := C.indexEquiv (EuclideanSpace.basisFun (Fin n) ℝ).toBasis
      let E := D.reindex e
      let r : Fin n → ℝ := fun j => ((e.symm j).1).2
      let s : Fin n → ℝ := fun j => ((e.symm j).1).1
  5. Each basis vector Eⱼ is a simultaneous eigenvector: A(Eⱼ) = rⱼ • Eⱼ and B(Eⱼ) = sⱼ • Eⱼ.

    By definition of the collected basis, Eⱼ belongs to the joint eigenspace associated with its index. Membership in this intersection of eigenspaces means that A(Eⱼ) = rⱼ • Eⱼ and B(Eⱼ) = sⱼ • Eⱼ.

    lines 44–48

    uses OrthonormalBasis.coe_reindex

      have heig (j : Fin n) : A (E j) = r j • E j ∧ B (E j) = s j • E j := by
        have hh := hV.collectedBasis_mem vf (e.symm j)
        have hh' : E j ∈ V (e.symm j).1 := by
          simpa [E, D, C, OrthonormalBasis.coe_reindex] using hh
        exact ⟨Module.End.mem_eigenspace_iff.mp hh'.1, Module.End.mem_eigenspace_iff.mp hh'.2⟩
  6. The matrix O whose columns are the basis vectors Eⱼ is orthogonal: Oᵀ * O = 1 and O * Oᵀ = 1.

    The coordinate matrix expressing an orthonormal basis in terms of the standard orthonormal basis is an element of the orthogonal group O(n). Consequently, its transpose is both its left and right inverse.

    lines 49–56

    uses Matrix.mem_orthogonalGroup_iff', Matrix.mem_orthogonalGroup_iff

      let O : Matrix (Fin n) (Fin n) ℝ := fun i j => (E j).ofLp i
      have hO : O ∈ Matrix.orthogonalGroup (Fin n) ℝ := by
        have hh := (EuclideanSpace.basisFun (Fin n) ℝ).toMatrix_orthonormalBasis_mem_orthogonal E
        convert hh using 1
        ext i j
        simp [O, Module.Basis.toMatrix_apply, EuclideanSpace.basisFun_repr]
      have hOtO : O.transpose*O=1 := (Matrix.mem_orthogonalGroup_iff' _ _).mp hO
      have hOOt : O*O.transpose=1 := (Matrix.mem_orthogonalGroup_iff _ _).mp hO
  7. The matrices satisfy the intertwining relations R * O = O * diag(r) and S * O = O * diag(s).

    Entrywise, column j of R * O represents the matrix-vector product R *ᵥ Eⱼ, which is A(Eⱼ). Since A(Eⱼ) = rⱼ • Eⱼ, column j of R * O equals rⱼ times column j of O, which matches column j of O * diag(r). The exact same reasoning applies to S with eigenvalue sequence s.

    lines 57–66

    uses Matrix.mul_diagonal, congrArg, Matrix.mul_apply, Matrix.ofLp_toEuclideanLin_apply

      have hRO : R*O=O*Matrix.diagonal r := by
        ext i j
        rw [Matrix.mul_diagonal]
        have hh := congrArg (fun x : EuclideanSpace ℝ (Fin n) => x.ofLp i) (heig j).1
        simpa [A, O, Matrix.mul_apply, Matrix.ofLp_toEuclideanLin_apply, Matrix.mulVec, dotProduct, mul_comm] using hh
      have hSO : S*O=O*Matrix.diagonal s := by
        ext i j
        rw [Matrix.mul_diagonal]
        have hh := congrArg (fun x : EuclideanSpace ℝ (Fin n) => x.ofLp i) (heig j).2
        simpa [B, O, Matrix.mul_apply, Matrix.ofLp_toEuclideanLin_apply, Matrix.mulVec, dotProduct, mul_comm] using hh
  8. The matrices are simultaneously orthogonally diagonalized: R = O * diag(r) * Oᵀ and S = O * diag(s) * Oᵀ.

    Multiplying R on the right by O * Oᵀ = 1 and associating terms gives R = (R * O) * Oᵀ. Replacing R * O with O * diag(r) yields R = O * diag(r) * Oᵀ. Repeating the same steps for S yields S = O * diag(s) * Oᵀ, completing the lemma.

    lines 67–75

    uses mul_one, Matrix.mul_assoc

      refine ⟨O,r,s,hOtO,hOOt,?_,?_⟩
      · calc
          R = R * (O*O.transpose) := by rw [hOOt, mul_one]
          _ = (R*O)*O.transpose := by rw [Matrix.mul_assoc]
          _ = (O*Matrix.diagonal r)*O.transpose := by rw [hRO]
      · calc
          S = S * (O*O.transpose) := by rw [hOOt, mul_one]
          _ = (S*O)*O.transpose := by rw [Matrix.mul_assoc]
          _ = (O*Matrix.diagonal s)*O.transpose := by rw [hSO]
  9. Commuting real symmetric square matrices have a common real orthogonal eigenbasis.

    The theorem is established directly by applying the helper lemma in767_diagonalproof_real_commuting_diagonal proved above.

    line 84

    uses in767_diagonalproof_real_commuting_diagonal

      exact in767_diagonalproof_real_commuting_diagonal
Matrix.isSymmetric_toEuclideanLin_iff.mpr
A matrix with real entries whose conjugate transpose equals itself (i.e. a Hermitian matrix, which over ℝ is simply a symmetric matrix) induces a symmetric linear map on Euclidean space.
Matrix.conjTranspose_eq_transpose_of_trivial
For matrices with entries in a type with trivial star operation (such as ℝ), the conjugate transpose equals the transpose.
LinearMap.ext
Two linear maps are equal if and only if they agree on all vectors.
WithLp.ofLp_injective
The canonical projection from an Lp space (here Euclidean space) to the underlying function type is injective.
Module.End.mul_apply
Evaluating a product (composition) of endomorphisms on an input vector satisfies (f * g)(x) = f(g(x)).
Matrix.ofLp_toEuclideanLin_apply
Evaluating the linear map induced by a matrix M on a vector v corresponds to the matrix-vector multiplication M v.
Matrix.mulVec_mulVec
Matrix-vector multiplication is associative: M (N v) = (M N) v.
DirectSum.IsInternal.collectedBasis_orthonormal
Combining orthonormal bases of the component subspaces in an orthogonal internal direct sum yields an orthonormal basis of the entire space.
Module.Finite.finite_basis
Any basis of a finite module over a nontrivial ring has a finite index set.
Fintype.ofFinite
Constructs a Fintype instance from a proof of finiteness.
OrthonormalBasis.coe_reindex
Reindexing an orthonormal basis by an equivalence of index sets composes the basis indexing function with the inverse equivalence.
Matrix.mem_orthogonalGroup_iff'
A square matrix A belongs to the orthogonal group if and only if Aᵀ * A = 1.
Matrix.mem_orthogonalGroup_iff
A square matrix A belongs to the orthogonal group if and only if A * Aᵀ = 1.
Matrix.mul_diagonal
The (i, j)-th entry of the product of a matrix M with a diagonal matrix diag(d) is M i j * d j.
congrArg
Applying a function to equal arguments yields equal values: if a = b, then f(a) = f(b).
Matrix.mul_apply
The (i, j)-th entry of a matrix product M * N is the dot product of the i-th row of M with the j-th column of N.
mul_one
Multiplying by 1 on the right leaves an element unchanged: a * 1 = a.
Matrix.mul_assoc
Matrix multiplication is associative: (L * M) * N = L * (M * N).
in767_diagonalproof_real_commuting_diagonal
Commuting real symmetric square matrices admit a common real orthogonal diagonalization.

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

open Matrixopen scoped BigOperators Matrixset_option backward.isDefEq.respectTransparency falseprivate lemma in767_diagonalproof_real_commuting_diagonal (n : ℕ) (R S : Matrix (Fin n) (Fin n) ℝ)    (hR : R.transpose=R) (hS : S.transpose=S) (hRS : R*S=S*R) :    ∃ (O : Matrix (Fin n) (Fin n) ℝ) (r s : Fin n → ℝ),      O.transpose * O = 1 ∧ O * O.transpose = 1 ∧      R = O * Matrix.diagonal r * O.transpose ∧      S = O * Matrix.diagonal s * O.transpose := by  classical  let A := R.toEuclideanLin  let B := S.toEuclideanLin  have hA : A.IsSymmetric := by    apply Matrix.isSymmetric_toEuclideanLin_iff.mpr    simpa [Matrix.IsHermitian, Matrix.conjTranspose_eq_transpose_of_trivial] using hR  have hB : B.IsSymmetric := by    apply Matrix.isSymmetric_toEuclideanLin_iff.mpr    simpa [Matrix.IsHermitian, Matrix.conjTranspose_eq_transpose_of_trivial] using hS  have hAB : Commute A B := by    apply LinearMap.ext    intro x    apply WithLp.ofLp_injective 2    simp only [Module.End.mul_apply, A, B, Matrix.ofLp_toEuclideanLin_apply]    rw [Matrix.mulVec_mulVec, Matrix.mulVec_mulVec, hRS]  let V : ℝ × ℝ → Submodule ℝ (EuclideanSpace ℝ (Fin n)) := fun i =>    Module.End.eigenspace A i.2 ⊓ Module.End.eigenspace B i.1  have hV : DirectSum.IsInternal V := hA.directSum_isInternal_of_commute hB hAB  have hVo : OrthogonalFamily ℝ (fun i => V i) (fun i => (V i).subtypeₗᵢ) :=    hA.orthogonalFamily_eigenspace_inf_eigenspace hB  let vf : ∀ i : ℝ × ℝ, Module.Basis (Fin (Module.finrank ℝ (V i))) ℝ (V i) :=    fun i => (stdOrthonormalBasis ℝ (V i)).toBasis  let C := hV.collectedBasis vf  have hCo : Orthonormal ℝ C := DirectSum.IsInternal.collectedBasis_orthonormal hVo hV    (fun i => (stdOrthonormalBasis ℝ (V i)).orthonormal)  letI : Finite (Σ i : ℝ × ℝ, Fin (Module.finrank ℝ (V i))) :=    Module.Finite.finite_basis C  letI : Fintype (Σ i : ℝ × ℝ, Fin (Module.finrank ℝ (V i))) := Fintype.ofFinite _  let D := C.toOrthonormalBasis hCo  let e := C.indexEquiv (EuclideanSpace.basisFun (Fin n) ℝ).toBasis  let E := D.reindex e  let r : Fin n → ℝ := fun j => ((e.symm j).1).2  let s : Fin n → ℝ := fun j => ((e.symm j).1).1  have heig (j : Fin n) : A (E j) = r j • E j ∧ B (E j) = s j • E j := by    have hh := hV.collectedBasis_mem vf (e.symm j)    have hh' : E j ∈ V (e.symm j).1 := by      simpa [E, D, C, OrthonormalBasis.coe_reindex] using hh    exact ⟨Module.End.mem_eigenspace_iff.mp hh'.1, Module.End.mem_eigenspace_iff.mp hh'.2⟩  let O : Matrix (Fin n) (Fin n) ℝ := fun i j => (E j).ofLp i  have hO : O ∈ Matrix.orthogonalGroup (Fin n) ℝ := by    have hh := (EuclideanSpace.basisFun (Fin n) ℝ).toMatrix_orthonormalBasis_mem_orthogonal E    convert hh using 1    ext i j    simp [O, Module.Basis.toMatrix_apply, EuclideanSpace.basisFun_repr]  have hOtO : O.transpose*O=1 := (Matrix.mem_orthogonalGroup_iff' _ _).mp hO  have hOOt : O*O.transpose=1 := (Matrix.mem_orthogonalGroup_iff _ _).mp hO  have hRO : R*O=O*Matrix.diagonal r := by    ext i j    rw [Matrix.mul_diagonal]    have hh := congrArg (fun x : EuclideanSpace ℝ (Fin n) => x.ofLp i) (heig j).1    simpa [A, O, Matrix.mul_apply, Matrix.ofLp_toEuclideanLin_apply, Matrix.mulVec, dotProduct, mul_comm] using hh  have hSO : S*O=O*Matrix.diagonal s := by    ext i j    rw [Matrix.mul_diagonal]    have hh := congrArg (fun x : EuclideanSpace ℝ (Fin n) => x.ofLp i) (heig j).2    simpa [B, O, Matrix.mul_apply, Matrix.ofLp_toEuclideanLin_apply, Matrix.mulVec, dotProduct, mul_comm] using hh  refine ⟨O,r,s,hOtO,hOOt,?_,?_⟩  · calc      R = R * (O*O.transpose) := by rw [hOOt, mul_one]      _ = (R*O)*O.transpose := by rw [Matrix.mul_assoc]      _ = (O*Matrix.diagonal r)*O.transpose := by rw [hRO]  · calc      S = S * (O*O.transpose) := by rw [hOOt, mul_one]      _ = (S*O)*O.transpose := by rw [Matrix.mul_assoc]      _ = (O*Matrix.diagonal s)*O.transpose := by rw [hSO]theorem real_symmetric_commuting_pair_orthogonal_diagonalization :  ∀ (n : ℕ) (R S : Matrix (Fin n) (Fin n) ℝ),    R.transpose = R → S.transpose = S → R*S = S*R →    ∃ (O : Matrix (Fin n) (Fin n) ℝ) (r s : Fin n → ℝ),      O.transpose * O = 1 ∧ O * O.transpose = 1 ∧      R = O * Matrix.diagonal r * O.transpose ∧      S = O * Matrix.diagonal s * O.transpose := by  exact in767_diagonalproof_real_commuting_diagonal
See it in the graphDiscuss this resultChallenge it