Lemma 1: the LDA eigenvalues are real and nonnegative
ProvedSSLSpectralEmbedding.lda_eigenvalues_real_nonnegLet be data with class labels . Let when ( the size of class ) and otherwise. Let and be the within- and between-class scatter matrices, and suppose is invertible. Let be the positive definite square root of . Then
- and have the same characteristic polynomial, hence the same eigenvalues with multiplicity;
- is symmetric;
- every (complex) eigenvalue of is real and nonnegative.
The lemma ensures that the generalized eigenvalue problem of LDA, and the division by in Appendix A.16, are well posed.
Formalization Note The square root is any positive definite with , which is unique. Nonnegativity rests on being positive semidefinite, which the paper does not state: symmetry alone gives real, not nonnegative, eigenvalues.
import Mathlib import Definitions.Def_SSLSpectralEmbedding_Basic open Matrix
namespace SSLSpectralEmbedding
theorem lda_eigenvalues_real_nonneg {N D C : ℕ} (X : Matrix (Fin N) (Fin D) ℝ) (y : Fin N → Fin C)
(hw : (withinScatter X y).det ≠ 0)
(S : Matrix (Fin D) (Fin D) ℝ) (hS : S.PosDef) (hSS : S * S = (withinScatter X y)⁻¹) :
((withinScatter X y)⁻¹ * betweenScatter X y).charpoly = (S * betweenScatter X y * S).charpoly ∧
(S * betweenScatter X y * S).IsHermitian ∧
∀ μ : ℂ, (((withinScatter X y)⁻¹ * betweenScatter X y).charpoly.map (algebraMap ℝ ℂ)).IsRoot μ →
μ.im = 0 ∧ 0 ≤ μ.re := by sorry
end SSLSpectralEmbeddingRead-back
What the Lean code literally says, in plain math · claude-opus-5-5
Let be natural numbers, with no constraints. Let be an arbitrary real matrix, whose -th row is the data point of sample . Let be an arbitrary labelling that assigns each sample a class . Classes that no sample receives are allowed.
For a class , let be the number of samples carrying label . The supervised relation matrix is defined entrywise by
Since sample itself has label , we have , so no division by zero occurs. Note that has nonzero diagonal: . From the theorem builds two real matrices, where is the identity:
- the within-class scatter ;
- the between-class scatter .
Hypotheses.
- , so is invertible and denotes its true inverse.
- is a real matrix that is positive definite: it is symmetric and for every nonzero .
- satisfies .
Conclusion. All three of the following hold:
- The characteristic polynomials agree:
- The matrix is symmetric.
- Regard the real polynomial as a polynomial with complex coefficients. Then every complex root of it satisfies
That is, every eigenvalue of is a nonnegative real number.
The statement says nothing about multiplicities. It does not assert that is positive semidefinite; it asserts only that it is symmetric.
Edge cases.
- : all matrices are empty. Then , the empty satisfies the hypotheses, both characteristic polynomials equal , and the root condition holds vacuously.
- : is the zero matrix, so the determinant hypothesis can hold only when .
- : a labelling exists only when .
- Every class has exactly one sample: then and , so the hypothesis fails whenever .
- In general: the determinant hypothesis requires to be nonsingular. This constrains , , the class sizes and jointly. For example, it is impossible when exceeds minus the number of distinct labels that actually occur.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.