Sylvester's law of inertia: the signature is well defined (goal)
ProvedPseudoRiemannian.sylvester_law_of_inertiaSylvester's law of inertia — the signature is well defined. The goal theorem.
The source: "By Sylvester's law of inertia, the number of each positive, negative and zero values produced in this manner are invariants of the metric tensor, independent of the choice of orthogonal basis. The signature (p, q, r) of the metric tensor gives these numbers … A non-degenerate metric tensor has r = 0 and the signature may be denoted (p, q), where p + q = n."
Let be a symmetric matrix, and suppose it is invertibly congruent to two signature diagonals:
with invertible and taking values .
Conclusion: the two diagonals have the same index:
(the number of entries equal to ; by also the number of entries agrees). In words: the signature of a nondegenerate symmetric bilinear form is an invariant of the form, not of the chosen orthogonal basis — exactly the invariance the article invokes. This is what makes "the signature (p, q) of a pseudo-Riemannian metric" a well-defined notion, and with it the whole signature-based classification of the source (Lorentzian, Riemannian, etc.).
Formalization note. A genuine classical theorem — Mathlib does not have Sylvester's law of inertia, so it must be proved. The standard dimension count: the -coordinates of diag s span a subspace of dimension negCount s on which the form is negative definite ( for ); the non--coordinates of diag s' span a subspace of dimension on which the form is positive semidefinite (). Pulled to the same space (through and ), if the counts differed, so contains a nonzero vector — but on it the form is simultaneously and , a contradiction. Symmetry of enters in the semidefiniteness direction (restricting a symmetric form to a subspace and pulling back along linear maps preserves symmetry); the argument then runs symmetrically to rule out negCount s < negCount s'. Harvest: negCount of a signature diagonal via Finset.univ.filter/cardinality lemmas; the subspace arguments via Mathlib's Subspace/dimension API.
import Mathlib import Definitions.Def_PseudoRiemannian
namespace PseudoRiemannian
open Matrix
open scoped ContDiff
/-- The goal — Sylvester's law of inertia, the theorem the source invokes for
the signature: "By Sylvester's law of inertia, the number of each positive,
negative and zero values produced in this manner are invariants of the metric
tensor, independent of the choice of orthogonal basis. The signature (p, q, r)
of the metric tensor gives these numbers ... A non-degenerate metric tensor has
r = 0 and the signature may be denoted (p, q), where p + q = n."
In the diagonal normal form: if the symmetric matrix `g x` is invertibly
congruent to two signature diagonals, `Bᵀ (g x) B = diag s` and
`Cᵀ (g x) C = diag s'` with `s, s'` taking values `± 1`, then the two diagonals
have the same number of negative entries — `negCount s = negCount s'` — and
likewise the same number of positive entries. The signature `(p, q)` of the
metric (here `(n - negCount s, negCount s)`) is therefore well defined: it does
not depend on the chosen orthogonal basis, only on the metric. -/
theorem sylvester_law_of_inertia {n : ℕ} {g : Spc n → Matrix (Fin n) (Fin n) ℝ}
{x : Spc n} (hsymm : ∀ i j, g x i j = g x j i)
{B C : Matrix (Fin n) (Fin n) ℝ} (hB : IsUnit B.det) (hC : IsUnit C.det)
{s s' : Fin n → ℝ} (h1 : Bᵀ * g x * B = Matrix.diagonal s)
(h2 : Cᵀ * g x * C = Matrix.diagonal s')
(hs : IsSignVec s) (hs' : IsSignVec s') :
negCount s = negCount s' := by
sorry
end PseudoRiemannianRead-back
What the Lean code literally says, in plain math · zai-glm-5-3-flash-vibe-free
The theorem takes a metric field g, a point x : Spc n, the symmetry of the metric matrix at x (hsymm : ∀ i j, g x i j = g x j i), invertible matrices B C (hB : IsUnit B.det, hC : IsUnit C.det), signature vectors s s' (hs : IsSignVec s, hs' : IsSignVec s'), and both congruences: h1 : Bᵀ * g x * B = Matrix.diagonal s, h2 : Cᵀ * g x * C = Matrix.diagonal s'.
Conclusion: negCount s = negCount s' — the two signature diagonals have the same number of -1 entries (componentwise expansion: (Finset.univ.filter fun i => s i < 0).card = (Finset.univ.filter fun i => s' i < 0).card).
This is Sylvester's law of inertia in diagonal normal form — the well-definedness of the signature (p, q) the article's formalism rests on ("By Sylvester's law of inertia, the number of each positive, negative and zero values … are invariants of the metric tensor, independent of the choice of orthogonal basis"). Note what is and is not assumed: symmetry of g x is assumed (it is essential — the theorem is false for nonsymmetric matrices, since only the symmetric part of a bilinear form is seen by the quadratic values); the signature vectors are required to be ± 1-valued (no zeros — the nondegenerate case r = 0 of the source's (p, q, r)). The goal does not assert the analogous statement for the count of +1 entries (it follows by p + q = n, since negCount matching plus equal lengths forces it), nor any canonical form statement beyond the count equality. This is the heaviest item of the mission by design: Mathlib has no Sylvester's law of inertia, and the standard proof is the dimension-counting argument described in the natural-language statement (negative-definite subspace from s vs. positive-semidefinite subspace from s', forced nontrivial intersection, contradiction).
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.