PhysLib static spherical metrics and regular coordinate points
DefinitionPhyslibStaticSphericalCoordinatesgeneral-relativityphyslib-exact-spacetimes
Static spherical metric data. A regular point has nonzero radius, nonzero radial metric function, and nonzero sine of the polar angle.
Definition code
import Definitions.Def_PhyslibCoordinateGeometry
import Mathlib.Algebra.BigOperators.Fin
import Mathlib.Algebra.BigOperators.Ring.Finset
import Mathlib.Algebra.Lie.Classical
import Mathlib.Analysis.Calculus.ContDiff.Deriv
import Mathlib.Analysis.Calculus.Deriv.Add
import Mathlib.Analysis.Calculus.Deriv.Basic
import Mathlib.Analysis.Calculus.Deriv.Inv
import Mathlib.Analysis.Calculus.Deriv.Mul
import Mathlib.Analysis.Calculus.Deriv.Pow
import Mathlib.Analysis.Calculus.Deriv.Prod
import Mathlib.Analysis.Calculus.FDeriv.Symmetric
import Mathlib.Analysis.ODE.ExistUnique
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Basic
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Deriv
import Mathlib.Data.Matrix.Basic
import Mathlib.Data.Real.Basic
import Mathlib.Data.Set.Basic
import Mathlib.LinearAlgebra.Matrix.Notation
import Mathlib.LinearAlgebra.Matrix.Symmetric
import Mathlib.Logic.Equiv.Fin.Basic
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.FinCases
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.NoncommRing
import Mathlib.Tactic.NormNum
import Mathlib.Tactic.Positivity
import Mathlib.Tactic.Ring
section
/-
Copyright (c) 2026 Alex Vergara Gil. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Alex Vergara Gil
-/
/-!
# Static spherically symmetric metrics
Static spherically symmetric metric `StaticSphericalMetric`, its diagonal coordinate metric and
inverse in `(t, r, θ, φ)` coordinates, symmetry, two-sided invertibility, and `CoordinateMetric 4`
instance.
## i. Overview
A general static spherically symmetric four-dimensional metric in coordinates `(t, r, θ, φ)` is
parameterized by a single radial metric function `f(r) = S.metricFn r`:
`ds² = -f(r) dt² + f(r)⁻¹ dr² + r² dθ² + r² sin²θ dφ²`.
This module defines `StaticSphericalMetric` in terms of `f` and establishes the nondegeneracy of the
metric on the regular chart `{x | x 1 ≠ 0 ∧ S.metricFn (x 1) ≠ 0 ∧ Real.sin (x 2) ≠ 0}`,
yielding both pointwise `MetricTensor 4` instances and a `CoordinateMetric 4`.
## ii. Key results
- `StaticSphericalMetric` : a static spherically symmetric metric parameterized by its radial metric
function `metricFn`.
- `StaticSphericalMetric.metric`, `StaticSphericalMetric.metricInv`,
`StaticSphericalMetric.metric_symm`, `StaticSphericalMetric.metric_mul_inv`,
`StaticSphericalMetric.metricInv_mul` : coordinate metric, inverse, symmetry, and invertibility.
- `StaticSphericalMetric.metricTensor`, `StaticSphericalMetric.toCoordinateMetric` : certified
`MetricTensor 4` and `CoordinateMetric 4` instances.
## iii. Table of contents
- A. Metric, inverse, and MetricTensor
## iv. References
* R. M. Wald, *General Relativity* (1984), Ch. 6 (Sec. 6.1). [ref: wald_1984_general_relativity]
* C. W. Misner, K. S. Thorne, and J. A. Wheeler, *Gravitation* (1973), Ch. 23 (Sec. 23.2).
[ref: mtw_1973_gravitation]
* B. O'Neill, *Semi-Riemannian Geometry With Applications to Relativity* (1983), Ch. 13.
[ref: oneill_1983_semi_riemannian]
* S. M. Carroll, *Lecture Notes on General Relativity* (1997), Ch. 7
(https://arxiv.org/pdf/gr-qc/9712019#page=168). [ref: Carroll1997]
-/
namespace GeneralRelativity
namespace StaticSpherical
/-!
## A. Metric, inverse, and MetricTensor
On a static spherically symmetric spacetime parameterized by a single radial metric function
`f(r)`, the diagonal metric `diag(-f, f⁻¹, r², r² sin²θ)` is nondegenerate everywhere away from the
origin (`r = 0`), Killing horizons (`f = 0`), and polar coordinate axis (`sin θ = 0`).
-/
/-- A static spherically symmetric four-dimensional metric determined by a single radial metric
function `f(r)` in coordinates `(t, r, θ, φ)`: the restricted ansatz `g_tt = -f(r)`,
`g_rr = f(r)⁻¹`, `g_{θθ} = r²`, `g_{φφ} = r² sin²θ`, which automatically satisfies
`g_tt g_rr = -1`. Metrics without this pairing of the `tt` and `rr` components are not
representable. -/
structure StaticSphericalMetric where
/-- The radial metric function `f(r)` entering `g_tt = -f(r)` and `g_rr = f(r)⁻¹`. -/
metricFn : ℝ → ℝ
namespace StaticSphericalMetric
/-- A regular chart point of a static spherically symmetric metric: `r ≠ 0`, `f(r) ≠ 0`, and
`sin θ ≠ 0`, so the metric and its inverse are both defined. -/
structure RegularPoint (S : StaticSphericalMetric) where
/-- Coordinate point `(t, r, θ, φ)`. -/
x : Fin 4 → ℝ
/-- The radial coordinate is nonzero. -/
hr : x 1 ≠ 0
/-- The metric function is nonzero at the radius. -/
hf : S.metricFn (x 1) ≠ 0
/-- The polar angle is away from the axis. -/
hsin : Real.sin (x 2) ≠ 0
/-- General static spherically symmetric metric `diag(-f(r), f(r)⁻¹, r², r² sin²θ)` in
coordinates `(t, r, θ, φ)`. -/
noncomputable def metric (S : StaticSphericalMetric) (x : Fin 4 → ℝ) : Tensor2 4 :=
Matrix.of fun i j =>
if i = j then
if i = 0 then -(S.metricFn (x 1))
else if i = 1 then (S.metricFn (x 1))⁻¹
else if i = 2 then (x 1) ^ 2
else (x 1) ^ 2 * Real.sin (x 2) ^ 2
else 0
/-- Inverse of the general static spherically symmetric metric. -/
noncomputable def metricInv (S : StaticSphericalMetric) (x : Fin 4 → ℝ) : Tensor2 4 :=
Matrix.of fun i j =>
if i = j then
if i = 0 then -(S.metricFn (x 1))⁻¹
else if i = 1 then S.metricFn (x 1)
else if i = 2 then ((x 1) ^ 2)⁻¹
else ((x 1) ^ 2 * Real.sin (x 2) ^ 2)⁻¹
else 0
/-- Symmetry of the static spherically symmetric metric tensor. -/
lemma metric_symm (S : StaticSphericalMetric) (x : Fin 4 → ℝ) : IsSymm (S.metric x) := by
ext i j
fin_cases i <;> fin_cases j <;> simp [Matrix.transpose_apply, metric]
/-- Left inverse identity `g⁻¹ * g = 1` on the regular chart `r ≠ 0`, `f(r) ≠ 0`,
`sin θ ≠ 0`. -/
lemma metricInv_mul (S : StaticSphericalMetric) (x : Fin 4 → ℝ) (hr : x 1 ≠ 0)
(hf : S.metricFn (x 1) ≠ 0) (hsin : Real.sin (x 2) ≠ 0) :
S.metricInv x * S.metric x = 1 := by
ext i j
fin_cases i <;> fin_cases j <;>
simp [metric, metricInv, Matrix.mul_apply]
· field_simp [hf]
· field_simp [hf]
· field_simp [hr]
· field_simp [hr, hsin]
/-- Right inverse identity `g * g⁻¹ = 1` on the regular chart `r ≠ 0`, `f(r) ≠ 0`,
`sin θ ≠ 0`. -/
lemma metric_mul_inv (S : StaticSphericalMetric) (x : Fin 4 → ℝ) (hr : x 1 ≠ 0)
(hf : S.metricFn (x 1) ≠ 0) (hsin : Real.sin (x 2) ≠ 0) :
S.metric x * S.metricInv x = 1 :=
mul_eq_one_of_isSymm_of_mul_eq_one (metric_symm S x) (metricInv_mul S x hr hf hsin)
/-- The metric as a `CoordinateMetric 4` on its regular chart where
`r ≠ 0`, `f(r) ≠ 0`, `sin θ ≠ 0`. -/
noncomputable def toCoordinateMetric (S : StaticSphericalMetric) : CoordinateMetric 4 where
g := S.metric
ginv := S.metricInv
domain := {x | x 1 ≠ 0 ∧ S.metricFn (x 1) ≠ 0 ∧ Real.sin (x 2) ≠ 0}
symm := S.metric_symm
inv_left x hx := S.metric_mul_inv x hx.1 hx.2.1 hx.2.2
inv_right x hx := S.metricInv_mul x hx.1 hx.2.1 hx.2.2
end StaticSphericalMetric
end StaticSpherical
end GeneralRelativity
end
section
/-
Copyright (c) 2026 Alex Vergara Gil. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Alex Vergara Gil
-/
/-!
# Static spherically symmetric connection and curvature
Closed-form Levi-Civita connection coefficients `StaticSphericalMetric.christoffel`, their partial
derivatives `StaticSphericalMetric.christoffelDeriv`, and the resulting Riemann, Ricci, scalar,
and Einstein tensors, verified against the coordinate metric.
## i. Overview
Differentiating `ds² = -f(r) dt² + f(r)⁻¹ dr² + r² dθ² + r² sin²θ dφ²` produces only radial and
polar coordinate derivatives of the metric components, since the metric is static (`∂_t g = 0`)
and axisymmetric (`∂_φ g = 0`). Combining these derivatives with `S.metricInv` identifies all 64
coordinate Christoffel symbols with the closed-form table `S.christoffel` and identifies all
256 coordinate partial derivatives `∂_μ Γ^k_{ij}` with `S.christoffelDeriv`.
## ii. Key results
- `christoffelPhiPhiTheta_from_metric` : angular
Levi-Civita connection coefficients of 2-spheres of radius `r`.
- `StaticSphericalMetric.christoffel`, `StaticSphericalMetric.christoffelDeriv` : closed-form
Christoffel and partial-derivative tables.
- `Metric.christoffel_eq`, `Metric.eventually_christoffel_eq`,
`StaticSphericalMetric.pd_christoffel_eq`, `StaticSphericalMetric.pd_christoffel_eq_deriv` :
agreement with `CoordinateMetric.christoffel` and its partial derivatives.
- `StaticSphericalMetric.riemann_eq_data`, `StaticSphericalMetric.ricciTensor`,
`StaticSphericalMetric.ricciScalar`, `StaticSphericalMetric.einsteinTensor` : closed-form
curvature for an arbitrary twice-differentiable radial metric function.
## iii. Table of contents
- A. Angular Christoffel symbols and metric partial derivatives
- B. Second-order Christoffel derivative table
- C. Riemann, Ricci, scalar, and Einstein tensors
## iv. References
* R. M. Wald, *General Relativity* (1984), Ch. 6 (Sec. 6.1). [ref: wald_1984_general_relativity]
* C. W. Misner, K. S. Thorne, and J. A. Wheeler, *Gravitation* (1973), Ch. 23 (Sec. 23.2).
[ref: mtw_1973_gravitation]
* S. M. Carroll, *Lecture Notes on General Relativity* (1997), Ch. 7
(https://arxiv.org/pdf/gr-qc/9712019#page=168). [ref: Carroll1997]
-/
namespace GeneralRelativity
namespace StaticSpherical
namespace StaticSphericalMetric
open GeneralRelativity.CoordinateCurvature
/-!
## A. Angular Christoffel symbols and metric partial derivatives
Because a static spherically symmetric metric is invariant under time translations and rotations,
only radial (`∂_r`) and polar (`∂_θ`) derivatives contribute to the Levi-Civita connection.
-/
/-- Closed-form Levi-Civita Christoffel symbols `Γ^k_{ij}` for a static spherically symmetric
metric in `(t, r, θ, φ)` coordinates. -/
noncomputable def christoffel (S : StaticSphericalMetric) (x : Fin 4 → ℝ)
(k i j : Fin 4) : ℝ :=
if k = 0 then
(if (i = 1 ∧ j = 0) ∨ (i = 0 ∧ j = 1) then
deriv S.metricFn (x 1) / (2 * S.metricFn (x 1))
else 0)
else if k = 1 then
(if i = 0 ∧ j = 0 then S.metricFn (x 1) * deriv S.metricFn (x 1) / 2
else if i = 1 ∧ j = 1 then -(deriv S.metricFn (x 1) / (2 * S.metricFn (x 1)))
else if i = 2 ∧ j = 2 then -(x 1 * S.metricFn (x 1))
else if i = 3 ∧ j = 3 then -(x 1 * Real.sin (x 2) ^ 2 * S.metricFn (x 1))
else 0)
else if k = 2 then
(if (i = 1 ∧ j = 2) ∨ (i = 2 ∧ j = 1) then 1 / x 1
else if i = 3 ∧ j = 3 then -(Real.sin (x 2) * Real.cos (x 2)) else 0)
else
(if (i = 1 ∧ j = 3) ∨ (i = 3 ∧ j = 1) then 1 / x 1
else if (i = 2 ∧ j = 3) ∨ (i = 3 ∧ j = 2) then Real.cos (x 2) / Real.sin (x 2) else 0)
/-!
## B. Second-order Christoffel derivative table
Differentiating each closed-form Christoffel symbol with respect to `(t, r, θ, φ)` isolates the
second radial derivative `f''(r)` that enters the Riemann and Ricci curvature components.
-/
/-- Closed-form partial-derivative table `∂_μ Γ^k_{ij}` for a static spherically symmetric metric
across all 256 index tuples `(μ, k, i, j)`. -/
noncomputable def christoffelDeriv (S : StaticSphericalMetric) (μ : Fin 4) (x : Fin 4 → ℝ)
(k i j : Fin 4) : ℝ :=
if μ = 1 then
(if k = 0 ∧ ((i = 1 ∧ j = 0) ∨ (i = 0 ∧ j = 1)) then
(deriv (deriv S.metricFn) (x 1) * S.metricFn (x 1) - (deriv S.metricFn (x 1)) ^ 2) /
(2 * (S.metricFn (x 1)) ^ 2)
else if k = 1 ∧ i = 0 ∧ j = 0 then
((deriv S.metricFn (x 1)) ^ 2 + S.metricFn (x 1) * deriv (deriv S.metricFn) (x 1)) / 2
else if k = 1 ∧ i = 1 ∧ j = 1 then
-((deriv (deriv S.metricFn) (x 1) * S.metricFn (x 1) - (deriv S.metricFn (x 1)) ^ 2) /
(2 * (S.metricFn (x 1)) ^ 2))
else if k = 1 ∧ i = 2 ∧ j = 2 then
-S.metricFn (x 1) - x 1 * deriv S.metricFn (x 1)
else if k = 1 ∧ i = 3 ∧ j = 3 then
(-S.metricFn (x 1) - x 1 * deriv S.metricFn (x 1)) * Real.sin (x 2) ^ 2
else if (k = 2 ∧ ((i = 1 ∧ j = 2) ∨ (i = 2 ∧ j = 1)))
∨ (k = 3 ∧ ((i = 1 ∧ j = 3) ∨ (i = 3 ∧ j = 1))) then
-1 / (x 1) ^ 2
else 0)
else if μ = 2 then
(if k = 1 ∧ i = 3 ∧ j = 3 then
-(x 1 * (2 * Real.sin (x 2) * Real.cos (x 2)) * S.metricFn (x 1))
else if k = 2 ∧ i = 3 ∧ j = 3 then
Real.sin (x 2) ^ 2 - Real.cos (x 2) ^ 2
else if k = 3 ∧ ((i = 2 ∧ j = 3) ∨ (i = 3 ∧ j = 2)) then
-1 / Real.sin (x 2) ^ 2
else 0)
else 0
/-!
## C. Riemann, Ricci, scalar, and Einstein tensors
Contracting the closed-form Riemann tensor gives a diagonal Ricci tensor, the spherical scalar
curvature `R = -f'' - 4 f'/r + 2 (1 - f) / r²`, and the Einstein tensor governing static
spherically symmetric spacetimes such as Schwarzschild, Kottler, and Reissner–Nordström.
-/
end StaticSphericalMetric
end StaticSpherical
end GeneralRelativity
end
Source