Coordinate curvature tensors and the Einstein field equations
Definitionefe_geometryCurvature in a single coordinate chart of a four-dimensional spacetime, and the Einstein field equations.
A point of spacetime is a quadruple of coordinates , and a -tensor field assigns to each point a real matrix of components. For a metric we write for its components and for the entries of the inverse matrix, and for the partial derivative along the -th coordinate direction (a Fréchet derivative in that direction).
The file defines, by the standard formulas,
the Ricci tensor , the trace of a -tensor with respect to , the scalar curvature , and the Einstein tensor
The Einstein field equations at a point , for cosmological constant , Einstein gravitational constant and stress–energy tensor , are the assertion
Finally the covariant divergence of a -tensor field with respect to the Levi-Civita connection of ,
Sign conventions are those of Misner–Thorne–Wheeler. Two conventions of the ambient formalization should be noted: the matrix inverse returns the zero matrix at a point where the metric is singular, and the derivative operator returns zero where a component function fails to be differentiable, so statements using these definitions carry invertibility and domain hypotheses.
import Mathlib
namespace EinsteinFieldEquations
open Finset
/-- Coordinate space of a four-dimensional spacetime chart: a point is the quadruple of its
coordinates `(x⁰, x¹, x², x³)`. -/
abbrev Coord : Type := Fin 4 → ℝ
/-- The components, in a coordinate chart, of a (0,2)-tensor field on spacetime: to each point
it assigns a `4 × 4` real matrix of components. -/
abbrev Tensor2Field : Type := Coord → Matrix (Fin 4) (Fin 4) ℝ
/-- The partial derivative `∂_k f` of a scalar function of the coordinates. -/
noncomputable def partialD (f : Coord → ℝ) (k : Fin 4) (x : Coord) : ℝ :=
fderiv ℝ f x (Pi.single k 1)
/-- The Christoffel symbols of the second kind of a metric `g`:
`Γᵃ_{bc} = ½ gᵃᵈ (∂_b g_{dc} + ∂_c g_{db} − ∂_d g_{bc})`,
where `gᵃᵈ` are the entries of the inverse matrix of `g x`. -/
noncomputable def christoffel (g : Tensor2Field) (a b c : Fin 4) (x : Coord) : ℝ :=
(1 / 2 : ℝ) * ∑ d : Fin 4, (g x)⁻¹ a d *
(partialD (fun y => g y d c) b x + partialD (fun y => g y d b) c x
- partialD (fun y => g y b c) d x)
/-- The Riemann curvature tensor of `g` in the MTW sign convention:
`Rᵃ_{bcd} = ∂_c Γᵃ_{db} − ∂_d Γᵃ_{cb} + Γᵃ_{ce} Γᵉ_{db} − Γᵃ_{de} Γᵉ_{cb}`. -/
noncomputable def riemann (g : Tensor2Field) (a b c d : Fin 4) (x : Coord) : ℝ :=
partialD (fun y => christoffel g a d b y) c x
- partialD (fun y => christoffel g a c b y) d x
+ ∑ e : Fin 4, (christoffel g a c e x * christoffel g e d b x
- christoffel g a d e x * christoffel g e c b x)
/-- The Ricci curvature tensor, the contraction `R_{bd} = Rᵃ_{bad}` of the Riemann tensor. -/
noncomputable def ricci (g : Tensor2Field) (b d : Fin 4) (x : Coord) : ℝ :=
∑ a : Fin 4, riemann g a b a d x
/-- The trace `gᵃᵇ A_{ab}` of a (0,2)-tensor field `A` with respect to the metric `g`. -/
noncomputable def metricTrace (g : Tensor2Field) (A : Tensor2Field) (x : Coord) : ℝ :=
∑ a : Fin 4, ∑ b : Fin 4, (g x)⁻¹ a b * A x a b
/-- The scalar curvature `R = gᵃᵇ R_{ab}` of `g`. -/
noncomputable def scalarCurvature (g : Tensor2Field) (x : Coord) : ℝ :=
metricTrace g (fun y => Matrix.of fun b d => ricci g b d y) x
/-- The Einstein tensor `G_{ab} = R_{ab} − ½ R g_{ab}`. -/
noncomputable def einsteinTensor (g : Tensor2Field) (a b : Fin 4) (x : Coord) : ℝ :=
ricci g a b x - (1 / 2 : ℝ) * scalarCurvature g x * (g x) a b
/-- The Einstein field equations `G_{ab} + Λ g_{ab} = κ T_{ab}` at the point `x`, for the metric
`g`, cosmological constant `Lam`, Einstein gravitational constant `kappa` and stress–energy
tensor `T`. -/
def SatisfiesEFE (g : Tensor2Field) (Lam kappa : ℝ) (T : Tensor2Field) (x : Coord) : Prop :=
∀ a b : Fin 4, einsteinTensor g a b x + Lam * (g x) a b = kappa * T x a b
/-- The covariant divergence `∇ᵃ A_{ab} = gᵃᶜ (∂_a A_{cb} − Γᵉ_{ac} A_{eb} − Γᵉ_{ab} A_{ce})` of a
(0,2)-tensor field `A` with respect to the Levi-Civita connection of `g`. -/
noncomputable def covDiv (g : Tensor2Field) (A : Tensor2Field) (b : Fin 4) (x : Coord) : ℝ :=
∑ a : Fin 4, ∑ c : Fin 4, (g x)⁻¹ a c *
(partialD (fun y => A y c b) a x
- ∑ e : Fin 4, christoffel g e a c x * A x e b
- ∑ e : Fin 4, christoffel g e a b x * A x c e)
end EinsteinFieldEquations
Read-back
What the Lean code literally says, in plain math · Aristotle (Harmonic)
Provenance note — this read-back is NOT independent testimony. It is non-blind: it was written by the same agent that drafted the Lean statements and the mission, at the explicit instruction of the proposal's owner, and not by an independent auditor kept blind to the intended meaning. The author knew the source material and the intended statement while writing it, so it cannot play the cross-checking role a blind read-back is meant to play, and no reviewer should treat it as independent confirmation that the formalization is faithful.
This file introduces, in a fixed four-dimensional coordinate chart, the objects of Riemannian/Lorentzian curvature and one predicate.
A coordinate point is an element of the set of functions , i.e. a quadruple of real numbers with no positivity, ordering or smoothness restriction. A tensor field is a function assigning to every such a real matrix; no symmetry, invertibility, signature or continuity condition is imposed anywhere in the file, so "metric" below means only "arbitrary matrix-valued function of four real variables".
For a real-valued function of a coordinate point, is defined as the Fréchet derivative of at evaluated on the -th standard basis vector (the quadruple with in slot and elsewhere). Where is not differentiable at this value is by the convention of the underlying derivative operator; nothing in the definition excludes that case.
For a tensor field , let denote the matrix inverse of , which is the zero matrix whenever is singular. The following are then defined for all indices and all points :
Note that the index contracted in the Ricci definition is the first upper index with the third slot, that the trace uses the inverse matrix of at the same point, and that the divergence contracts the derivative index with the first index of while subtracting one connection term for each index of .
Finally, the predicate " satisfies the field equations at with parameters , and source " is defined to mean:
It is a statement about the single point only, involves the real parameters and with no restriction (either may be zero), and refers to only through its value at . Since all derivative and inverse operations are total, every one of these quantities is a well-defined real number for every tensor field and every point, including degenerate ones where the matrix is singular or the components are nowhere differentiable — in such cases the values are the junk values described above rather than being undefined.