Sylvester's law of inertia (existence of a diagonal ±1/0 form)
ProvedFamousTheorems.sylvester_law_of_inertiaSylvester's law of inertia (existence part). Every quadratic form on a finite-dimensional real vector space of dimension is equivalent to a diagonal form
This is the normal form behind the signature of a real quadratic form, which classifies real quadratic forms up to equivalence. It is used throughout geometry and analysis, from the classification of conics and quadrics to the Morse lemma and the index of critical points.
Formalization note. Mathlib's QuadraticForm.equivalent_one_zero_neg_one_weighted_sum_squared. QuadraticMap.Equivalent means there is a linear isometry equivalence between the two forms, and QuadraticMap.weightedSumSquares ℝ w is on Fin n → ℝ. Only the existence of the diagonal form is stated. The invariance of the numbers of , and entries (the uniqueness half of the law) is not part of this statement.
import Mathlib
namespace FamousTheorems
theorem sylvester_law_of_inertia {M : Type*} [AddCommGroup M] [Module ℝ M] [FiniteDimensional ℝ M] (Q : QuadraticForm ℝ M) :
∃ w : Fin (Module.finrank ℝ M) → ℝ,
(∀ i, w i = -1 ∨ w i = 0 ∨ w i = 1) ∧ QuadraticMap.Equivalent Q (QuadraticMap.weightedSumSquares ℝ w) := by sorry
end FamousTheorems