Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Lorentzian metrics in a global chart: curvature and energy conditions

Definition
natario_gr_core

by LG · Sep 15, 2026 · Mathlib 0df444a (Lean v4.33.1)

differential-geometrygeneral-relativity

The core of a coordinate framework for four-dimensional Lorentzian geometry. A spacetime is given by the components gijg_{ij}gij​ of a metric in one global chart on R4\mathbb{R}^4R4: a smooth symmetric field which at each point is congruent to diag(−1,1,1,1)\mathrm{diag}(-1,1,1,1)diag(−1,1,1,1), with g00<0g_{00} < 0g00​<0 fixing a time orientation. The file defines the inverse metric, index raising and lowering, the Christoffel symbols of the Levi-Civita connection, the Riemann and Ricci tensors by their classical coordinate formulas, the classification of tangent vectors as timelike, null, causal or future-pointing, and the strong and null energy conditions.

Definition code
import Mathlib

open scoped ContDiff

/-!
# Four-dimensional Lorentzian geometry in a global chart — core objects

Formalization framework for J. Natário, *Mathematical Relativity* (arXiv:2003.02855),
Chapter 4 (Singularity theorems).

A spacetime is modelled by the components of a Lorentzian metric in a single global
chart, so that points and tangent vectors are elements of `Fin 4 → ℝ` and all curvature
quantities are the classical coordinate expressions.
-/

namespace MathematicalRelativity

/-- A spacetime point, and also a tangent vector, in the global chart. -/
abbrev Pt : Type := Fin 4 → ℝ

/-- Partial derivative of `f` in the `i`-th coordinate direction. -/
noncomputable def pd (f : Pt → ℝ) (i : Fin 4) (x : Pt) : ℝ := fderiv ℝ f x (Pi.single i 1)

/-- The Minkowski signature matrix `diag(-1, 1, 1, 1)`. -/
def eta : Matrix (Fin 4) (Fin 4) ℝ := Matrix.diagonal (fun i => if i = 0 then -1 else 1)

/-- A four-dimensional spacetime described in a single global chart: a smooth field of
symmetric bilinear forms which is everywhere congruent to the Minkowski form (signature
`(-,+,+,+)`), time-oriented by requiring the coordinate direction `∂/∂x⁰` to be timelike. -/
structure Spacetime where
  g : Pt → Fin 4 → Fin 4 → ℝ
  smooth : ∀ i j, ContDiff ℝ ∞ (fun x => g x i j)
  symm : ∀ x i j, g x i j = g x j i
  lorentz : ∀ x, ∃ P : Matrix (Fin 4) (Fin 4) ℝ, IsUnit P.det ∧
      P.transpose * (Matrix.of (g x)) * P = eta
  time_orient : ∀ x, g x 0 0 < 0

namespace Spacetime

variable (m : Spacetime)

/-- The metric components at `x`, as a matrix. -/
noncomputable def mat (x : Pt) : Matrix (Fin 4) (Fin 4) ℝ := Matrix.of (m.g x)

/-- The inverse metric `g^{ij}`. -/
noncomputable def ginv (x : Pt) (i j : Fin 4) : ℝ := (m.mat x)⁻¹ i j

/-- The metric pairing `⟪u, v⟫ = g_{ij} u^i v^j` at `x`. -/
def ip (x : Pt) (u v : Pt) : ℝ := ∑ i, ∑ j, m.g x i j * u i * v j

/-- Index lowering: `V_i = g_{ij} V^j`. -/
def lower (x : Pt) (v : Pt) (i : Fin 4) : ℝ := ∑ j, m.g x i j * v j

/-- Index raising: `W^i = g^{ij} W_j`. -/
noncomputable def raise (x : Pt) (w : Fin 4 → ℝ) (i : Fin 4) : ℝ := ∑ j, m.ginv x i j * w j

/-- The Christoffel symbols `Γ^a_{bc}` of the Levi-Civita connection. -/
noncomputable def christoffel (a b c : Fin 4) (x : Pt) : ℝ :=
  (1/2 : ℝ) * ∑ d, m.ginv x a d *
    (pd (fun y => m.g y d c) b x + pd (fun y => m.g y d b) c x - pd (fun y => m.g y b c) d x)

/-- The Riemann curvature tensor `R^a_{bcd}`, normalised so that
`(R(u,v)w)^a = R^a_{bcd} w^b u^c v^d`. -/
noncomputable def riemann (a b c d : Fin 4) (x : Pt) : ℝ :=
  pd (m.christoffel a d b) c x - pd (m.christoffel a c b) d x
    + ∑ e, (m.christoffel a c e x * m.christoffel e d b x
              - m.christoffel a d e x * m.christoffel e c b x)

/-- The Riemann tensor with all indices down, `R_{abcd} = g_{ae} R^e_{bcd}`. -/
noncomputable def riemannLower (a b c d : Fin 4) (x : Pt) : ℝ :=
  ∑ e, m.g x a e * m.riemann e b c d x

/-- The Ricci tensor `R_{bd} = R^a_{bad}`. -/
noncomputable def ricci (b d : Fin 4) (x : Pt) : ℝ := ∑ a, m.riemann a b a d x

/-- The quadratic form `Ric(v, v)`. -/
noncomputable def ricciQuad (x v : Pt) : ℝ := ∑ i, ∑ j, m.ricci i j x * v i * v j

/-- `v` is timelike at `x`. -/
def IsTimelike (x v : Pt) : Prop := m.ip x v v < 0

/-- `v` is null (lightlike) at `x`. -/
def IsNull (x v : Pt) : Prop := m.ip x v v = 0 ∧ v ≠ 0

/-- `v` is causal at `x`. -/
def IsCausalVec (x v : Pt) : Prop := m.ip x v v ≤ 0 ∧ v ≠ 0

/-- `v` is future-pointing: its `x⁰`-component is positive.  For causal vectors this is a
genuine time orientation, because `∂/∂x⁰` is timelike. -/
def IsFuture (v : Pt) : Prop := 0 < v 0

/-- The strong energy condition, equivalently the timelike convergence condition:
`Ric(v, v) ≥ 0` for every timelike vector `v` (Natário, §4.2). -/
def StrongEnergyCondition : Prop := ∀ x v, m.IsTimelike x v → 0 ≤ m.ricciQuad x v

/-- The null energy condition: `Ric(v, v) ≥ 0` for every null vector `v` (Natário, §4.2). -/
def NullEnergyCondition : Prop := ∀ x v, m.IsNull x v → 0 ≤ m.ricciQuad x v

end Spacetime

end MathematicalRelativity
Source
J. Natário, Mathematical Relativity, arXiv:2003.02855, Chapter 4 (Singularity theorems), §§4.1-4.2
Read-back

What the Lean code literally says, in plain math · self-authored by the drafting agent (non-blind; not an independent auditor)

Disclosure — non-blind read-back, not independent testimony. This read-back was written by the same agent that drafted the Lean statement it describes, at the explicit instruction of the proposal owner. It is not the blind testimony of an independent auditor with fresh context, and it cannot serve the usual purpose of a read-back as an outside check on the drafter: any misreading in the formalization is likely to be repeated here. Please treat it as an authored restatement and obtain an independent audit before relying on it.

This bundle fixes Pt=R4\mathrm{Pt} = \mathbb{R}^4Pt=R4 (functions {0,1,2,3}→R\{0,1,2,3\} \to \mathbb{R}{0,1,2,3}→R) as the type of both points and tangent vectors, and defines ∂if(x)\partial_i f(x)∂i​f(x) as the derivative of fff at xxx in the direction of the iii-th standard basis vector, taken as the Fréchet derivative applied to that vector (so it is the junk value 000 wherever fff fails to be differentiable). It fixes the constant matrix η=diag(−1,1,1,1)\eta = \mathrm{diag}(-1,1,1,1)η=diag(−1,1,1,1).

A spacetime is a structure bundling a function ggg assigning to each x∈R4x \in \mathbb{R}^4x∈R4 a square array gij(x)g_{ij}(x)gij​(x) of reals, together with four conditions: every component function x↦gij(x)x \mapsto g_{ij}(x)x↦gij​(x) is C∞C^\inftyC∞; gij(x)=gji(x)g_{ij}(x) = g_{ji}(x)gij​(x)=gji​(x) for all x,i,jx, i, jx,i,j; for every xxx there exists a matrix PPP with det⁡P\det PdetP a unit (i.e. det⁡P≠0\det P \ne 0detP=0) such that Ptg(x)P=ηP^{t} g(x) P = \etaPtg(x)P=η; and g00(x)<0g_{00}(x) < 0g00​(x)<0 for every xxx. Note that the congruence condition is required pointwise with no continuity in xxx of the choice of PPP.

Derived from this data: the matrix g(x)g(x)g(x); the inverse metric gij(x)g^{ij}(x)gij(x), defined as the entries of the inverse of that matrix (with the Lean convention that a non-invertible matrix inverts to 000 — not reachable here, since the congruence condition forces invertibility); the pairing ⟨u,v⟩x=∑i,jgij(x)uivj\langle u, v\rangle_x = \sum_{i,j} g_{ij}(x)u^i v^j⟨u,v⟩x​=∑i,j​gij​(x)uivj; lowering vi=∑jgij(x)vjv_i = \sum_j g_{ij}(x) v^jvi​=∑j​gij​(x)vj; raising wi=∑jgij(x)wjw^i = \sum_j g^{ij}(x) w_jwi=∑j​gij(x)wj​;

Γabc(x)=12∑dgad(x)(∂bgdc(x)+∂cgdb(x)−∂dgbc(x));\Gamma^{a}{}_{bc}(x) = \tfrac12 \sum_d g^{ad}(x)\bigl(\partial_b g_{dc}(x) + \partial_c g_{db}(x) - \partial_d g_{bc}(x)\bigr);Γabc​(x)=21​d∑​gad(x)(∂b​gdc​(x)+∂c​gdb​(x)−∂d​gbc​(x)); Rabcd(x)=∂cΓadb(x)−∂dΓacb(x)+∑e(Γace(x)Γedb(x)−Γade(x)Γecb(x));R^{a}{}_{bcd}(x) = \partial_c \Gamma^{a}{}_{db}(x) - \partial_d \Gamma^{a}{}_{cb}(x) + \sum_e \bigl(\Gamma^{a}{}_{ce}(x)\Gamma^{e}{}_{db}(x) - \Gamma^{a}{}_{de}(x)\Gamma^{e}{}_{cb}(x)\bigr);Rabcd​(x)=∂c​Γadb​(x)−∂d​Γacb​(x)+e∑​(Γace​(x)Γedb​(x)−Γade​(x)Γecb​(x));

the fully lowered tensor Rabcd(x)=∑egae(x)Rebcd(x)R_{abcd}(x) = \sum_e g_{ae}(x) R^{e}{}_{bcd}(x)Rabcd​(x)=∑e​gae​(x)Rebcd​(x); the Ricci tensor Rbd(x)=∑aRabad(x)R_{bd}(x) = \sum_a R^{a}{}_{bad}(x)Rbd​(x)=∑a​Rabad​(x); and the quadratic form Ric(x)(v)=∑i,jRij(x)vivj\mathrm{Ric}(x)(v) = \sum_{i,j} R_{ij}(x) v^i v^jRic(x)(v)=∑i,j​Rij​(x)vivj.

Finally the predicates: vvv is timelike at xxx when ⟨v,v⟩x<0\langle v,v\rangle_x < 0⟨v,v⟩x​<0; null when ⟨v,v⟩x=0\langle v,v\rangle_x = 0⟨v,v⟩x​=0 and v≠0v \ne 0v=0; causal when ⟨v,v⟩x≤0\langle v,v\rangle_x \le 0⟨v,v⟩x​≤0 and v≠0v \ne 0v=0; future-pointing when v0>0v^0 > 0v0>0 (a condition on the vector alone, with no reference to the metric or the point). The strong energy condition asserts Ric(x)(v)≥0\mathrm{Ric}(x)(v) \ge 0Ric(x)(v)≥0 for every point xxx and every vvv timelike at xxx; the null energy condition asserts the same for every vvv null at xxx. Both are conditions on all of R4\mathbb{R}^4R4.

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me