"In mathematical physics, a pseudo-Riemannian manifold, also called a semi-Riemannian manifold, is a differentiable manifold with a metric tensor that is everywhere nondegenerate. This is a generalization of a Riemannian manifold in which the requirement of positive-definiteness is relaxed" [Wikipedia, Pseudo-Riemannian manifold]. "Every tangent space of a pseudo-Riemannian manifold is a pseudo-Euclidean vector space. A special case used in general relativity is a four-dimensional Lorentzian manifold for modeling spacetime, where tangent vectors can be classified as timelike, null, and spacelike."
The article fixes the data precisely: "A metric tensor is a non-degenerate, smooth, symmetric, bilinear map that assigns a real number to pairs of tangent vectors at each tangent space of the manifold" — with symmetry and bilinearity — and "That g is non-degenerate means there is no non-zero X in TpM such that g(X,Y) = 0 for all Y in TpM." The signature mechanism is the article's deepest point, and it invokes a classical theorem to work: "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."
No manifold machinery: the mission works on plain coordinate spaces of arbitrary dimension — the tangent spaces themselves, "pseudo-Euclidean vector spaces" in the source's sense.
Spc n = Fin n → ℝ, plain real n-tuples; the metric is a field of matrices g : Spc n → Matrix (Fin n) (Fin n) ℝ.IsSmooth): every component is (ContDiff ℝ ∞ in Mathlib).IsSymmetric): at every point — the source's .HasSignature g s): a fixed signature vector s (entries , IsSignVec) such that at every point there is an invertible matrix B withThis one piece of carried data encodes the two defining requirements of the source — nondegeneracy everywhere, and "the non-degeneracy condition together with continuity implies that p and q remain unchanged throughout the manifold (assuming it is connected)" — and is the concrete stand-in for the local coordinate freedom of the manifold setting.
IsPseudoRiemannian g s): smooth ∧ symmetric ∧ signature witness.pair g x u v = Σᵢⱼ uᵢ g(x)ᵢⱼ vⱼ) — the value , bilinear in and symmetric at x when g is symmetric.IsNondegenerateAt g x): the article's condition verbatim — no nonzero u with for all v.negCount s): the number of negative entries of the signature diagonal — the q of the signature.x ↦ etaM (signature diagonal ) on Spc 4 — "Minkowski space R^{n-1,1} with the flat Minkowski metric is the local model of a Lorentzian manifold".witness_implies_invertible (milestone). A signature witness makes the metric matrix invertible: from with invertible and a signature vector, IsUnit (g x).det follows — . The algebraic core of "everywhere nondegenerate".nondegenerate_of_invertible (milestone). The article's nondegeneracy condition follows from invertibility of the metric matrix: the only u pairing to zero with every v is u = 0 (test against , giving ). Together with item 1 this shows the witness really carries the source's nondegeneracy.minkowski_pseudo_riemannian (milestone). The model space exists: the constant Minkowski metric on Spc 4 is pseudo-Riemannian with signature vector minkDiag — symmetric, smooth (constant), witnessed by the identity congruence. This is the Lorentzian spacetime of "a principal premise of general relativity", the article's local model of a Lorentzian manifold.all_plus_positive_definite (milestone). The Riemannian special case is exactly recovered: a metric congruent to the all-plus identity has a positive definite pairing (, with equality only at ) — the requirement the source's definition relaxes, shown equivalent to the all-plus signature.sylvester_law_of_inertia (goal). The theorem the article invokes for the signature, in diagonal normal form: if a symmetric matrix is invertibly congruent to two signature diagonals, and , then negCount s = negCount s' — the number of negative (equivalently positive) entries is independent of the chosen orthogonal basis. This is what makes the signature of the metric well defined, and hence what makes "the signature of a pseudo-Riemannian metric" meaningful at all.The pseudo-Riemannian manifold is the common roof of Riemannian geometry and relativistic spacetime: the article places Lorentzian manifolds — "after Riemannian manifolds, … the most important subclass" — as the setting of general relativity, with the timelike/null/spacelike classification emerging from the indefinite signature. Formalizing the skeleton pins down the three claims that make the theory coherent: that the carried signature witness really forces nondegeneracy (items 1–2), that both the Lorentzian model space and the Riemannian special case satisfy the definition (items 3–4), and that the signature itself is an invariant of the metric rather than an artifact of the basis — Sylvester's law of inertia (item 5), the theorem on which the article's signature formalism rests.
Items 1–3 are accessible: determinant algebra with and det_diagonal; a one-line testing argument for nondegeneracy; and the unfolding of the Minkowski example (diagonal matrix, constant maps, identity congruence). Item 4 is the most instructive milestone: from one reads , and the pairing becomes a squared norm . The goal is a genuine classical theorem — Sylvester's law of inertia is not in Mathlib, so it must be proved: the standard route is a dimension count (a negative-definite subspace of dimension negCount s and a positive-semidefinite subspace of dimension n − negCount s' must intersect nontrivially, forcing a vector that is both negative and nonnegative under the form — a contradiction when negCount s > negCount s', then symmetry in the two witnesses). It is the heaviest item by design; everything else is elementary.
In scope: metric tensors as smooth symmetric matrix fields of constant signature on Spc n; nondegeneracy in the article's sense and its equivalence-face from invertibility; the Minkowski model space R^{1,3}; the Riemannian all-plus special case; Sylvester's law of inertia in the diagonal form, i.e. well-definedness of the signature .
Out of scope, disclosed: differentiable manifolds, coordinate patches and tangent bundles (the framework is a single global coordinate space — the tangent-space/bilinear-form content is what is captured); the Levi-Civita connection and curvature tensor (the "fundamental theorem of Riemannian geometry" the article notes survives the generalization); geodesics, completeness and the Hopf-Rinow failure (Clifton-Pohl torus); topological obstructions to realizing signatures; submanifold inheritance; and the causal classification timelike/null/spacelike, which the platform's Special Relativity and World Lines missions already formalize for the Lorentzian case.
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 PseudoRiemannianSylvester'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.
No open leaves. Every sub-goal is proved or awaiting decomposition.