PhysLib physical cosmology
DefinitionPhyslibPhysicalCosmologygeneral-relativityphyslib-exact-spacetimes
Cosmic time, the FLRW background and matter model, and the physical constants and stress-energy used in the Friedmann equations.
Definition code
import Definitions.Def_PhyslibCoordinateGeometry
import Lean.Elab.Command
import Lean.Exception
import Mathlib.Algebra.BigOperators.Group.Finset.Basic
import Mathlib.Algebra.Field.Rat
import Mathlib.Algebra.Field.TransferInstance
import Mathlib.Algebra.Order.Ring.InjSurj
import Mathlib.Algebra.Order.Ring.Rat
import Mathlib.Analysis.Calculus.ContDiff.WithLp
import Mathlib.Analysis.Calculus.Deriv.Inv
import Mathlib.Analysis.Distribution.TemperateGrowth
import Mathlib.Analysis.InnerProductSpace.Calculus
import Mathlib.Analysis.InnerProductSpace.PiL2
import Mathlib.Analysis.SpecialFunctions.Pow.NNReal
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Basic
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Deriv
import Mathlib.Analysis.SpecialFunctions.Trigonometric.DerivHyp
import Mathlib.Data.Matrix.Basic
import Mathlib.Data.Real.Basic
import Mathlib.Geometry.Manifold.ContMDiff.Atlas
import Mathlib.Geometry.Manifold.Instances.Real
import Mathlib.Geometry.Manifold.IsManifold.Basic
import Mathlib.Geometry.Manifold.MFDeriv.NormedSpace
import Mathlib.LinearAlgebra.Matrix.Symmetric
import Mathlib.MeasureTheory.Measure.Haar.InnerProductSpace
import Mathlib.Tactic.NormNum
import Mathlib.Topology.Algebra.Module.Spaces.ContinuousLinearMap
section
/-
Copyright (c) 2025 Joseph Tooby-Smith. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joseph Tooby-Smith
-/
/-!
# Time
`Time` represents instants with a fixed but arbitrary unit and orientation. It is an
affine space over `ℝ`: two instants determine a real-valued elapsed time, and adding
such a duration to an instant produces another instant. There is no distinguished zero.
The field `Time.val` is an implementation coordinate, not a frame-relative time
coordinate. A reference frame chooses its own time origin. Import
`Physlib.SpaceAndTime.Time.InnerProductSpace` to use the inner product space structure with the
implicit origin `Time.mk 0`, including addition of instants, norms, and derivatives.
-/
@[expose] public noncomputable section
open scoped Manifold ContDiff
/-!
# A. The `Time` type
-/
/-- An instant in time with a given unit and orientation, but no distinguished origin. -/
@[ext]
structure Time where
/-- The implementation coordinate associated with an instant. -/
val : ℝ
namespace Time
instance : Nonempty Time := ⟨⟨0⟩⟩
/-!
# B. The affine structure
-/
instance : VAdd ℝ Time where
vadd dt t := ⟨dt + t.val⟩
@[simp]
lemma vadd_val (dt : ℝ) (t : Time) : (dt +ᵥ t).val = dt + t.val := rfl
instance : VSub ℝ Time where
vsub t₁ t₂ := t₁.val - t₂.val
@[simp]
lemma vsub_eq_val (t₁ t₂ : Time) : t₁ -ᵥ t₂ = t₁.val - t₂.val := rfl
instance : AddTorsor ℝ Time where
zero_vadd t := by ext; simp
add_vadd dt₁ dt₂ t := by ext; simp [add_assoc]
vsub_vadd' t₁ t₂ := by ext; simp
vadd_vsub' dt t := by simp
/-!
# C. The metric and manifold structure
-/
instance : MetricSpace Time := metricSpaceOfNormedAddCommGroupOfAddTorsor ℝ Time
end Time
end
section
/-
Copyright (c) 2025 Joseph Tooby-Smith. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joseph Tooby-Smith
-/
/-!
# Time as an inner product space
## i. Overview
In this module we equip the affine type `Time` with a real inner product space structure,
choosing the implicit origin represented by `Time.mk 0`. The units and orientation agree with the
real-valued displacements defined in `Physlib.SpaceAndTime.Time.Basic`.
We note that this is the version of time most often used in undergraduate and
non-mathematical physics.
The choice of units or origin can be made on a case-by-case basis, as
long as they are done consistently. However, since the choice of units and origin is
left implicit, Lean will not catch inconsistencies in the choice of units or origin when
working with `Time`.
For example, for the classical mechanics system corresponding to the harmonic oscillator,
one can take the origin of time to be the time at which the initial conditions are specified,
and the units can be taken as anything as long as the units chosen for time `t` and
the angular frequency `ω` are consistent.
With this choice, `Time` becomes a 1d vector space over `ℝ` with an inner product.
## ii. Key results
- `toRealCLE` : The continuous linear equivalence from `Time` to `ℝ`.
## iii. Table of contents
- A. Instances on Time
- A.1. Natural numbers as elements of `Time`
- A.2. Real numbers as elements of `Time`
- A.3. Time is inhabited
- A.4. The order on `Time`
- A.5. Addition of times
- A.6. Negation of times
- A.7. Subtraction of times
- A.8. Scalar multiplication of time
- A.9. Module on `Time`
- A.10. Norm of time
- A.11. Inner product on `Time`
- A.12. Decidability of `Time`
- A.13. Measurability of `Time`
- B. Basis of `Time`
- C. Maps from `Time` to `ℝ`
## iv. References
* None.
-/
namespace Time
/-!
## A. Instances on Time
-/
/-!
### A.1. Natural numbers as elements of `Time`
-/
/-- The casting of a natural number to an element of `Time`. This corresponds to a choice of
(1) zero point in time, and (2) a choice of metric on time (defining `1`). -/
instance {n : ℕ} : OfNat Time n where
ofNat := ⟨n⟩
@[simp]
lemma ofNat_val {n : ℕ} : val (OfNat.ofNat n : Time) = n := rfl
lemma one_ne_zero : (1 : Time) ≠ (0 : Time) :=
mt (congrArg val) (Nat.cast_injective.ne Nat.one_ne_zero)
@[simp]
lemma zero_val : val 0 = 0 := by exact_mod_cast ofNat_val (n := 0)
@[simp]
lemma one_val : val 1 = 1 := by exact_mod_cast ofNat_val (n := 1)
/-!
### A.2. Real numbers as elements of `Time`
-/
/-!
### A.3. Time is inhabited
-/
/-!
### A.4. The order on `Time`
-/
/-- The choice of an orientation on `Time`. -/
instance : LE Time where
le t1 t2 := t1.val ≤ t2.val
lemma le_def (t1 t2 : Time) :
t1 ≤ t2 ↔ t1.val ≤ t2.val := Iff.rfl
instance : PartialOrder Time where
le_refl t := by simp [le_def]
le_trans t1 t2 t3 := by simp [le_def]; exact le_trans
le_antisymm t1 t2 h1 h2 := by simp_all [le_def]; ext; exact le_antisymm h1 h2
/-!
### A.5. Addition of times
-/
instance : Add Time where
add t1 t2 := ⟨t1.val + t2.val⟩
@[simp]
lemma add_val (t1 t2 : Time) :
(t1 + t2).val = t1.val + t2.val := rfl
/-!
### A.6. Negation of times
-/
instance : Neg Time where
neg t := ⟨-t.val⟩
@[simp]
lemma neg_val (t : Time) :
(-t).val = -t.val := rfl
/-!
### A.7. Subtraction of times
-/
instance : Sub Time where
sub t1 t2 := ⟨t1.val - t2.val⟩
@[simp]
lemma sub_val (t1 t2 : Time) :
(t1 - t2).val = t1.val - t2.val := rfl
/-!
### A.8. Scalar multiplication of time
-/
instance : SMul ℝ Time where
smul k t := ⟨k * t.val⟩
@[simp]
lemma smul_real_val (k : ℝ) (t : Time) :
(k • t).val = k * t.val := rfl
/-!
### A.9. Module on `Time`
-/
instance : AddGroup Time where
add_assoc t1 t2 t3 := by ext; simp [add_assoc]
zero_add t := by ext; simp [zero_add]
add_zero t := by ext; simp [add_zero]
neg_add_cancel t := by ext; simp [neg_add_cancel]
nsmul := nsmulRec
zsmul := zsmulRec
instance : AddCommGroup Time where
add_comm := by intros; ext; simp [add_comm]
instance : Module ℝ Time where
one_smul t := by ext; simp
smul_add k t1 t2 := by ext; simp [mul_add]
smul_zero k := by ext; simp [mul_zero]
add_smul k1 k2 t := by ext; simp [add_mul]
mul_smul k1 k2 t := by ext; simp [mul_assoc]
zero_smul t := by ext; simp
/-!
### A.10. Norm of time
-/
instance : Norm Time where
norm t := ‖t.val‖
lemma norm_eq_val (t : Time) :
‖t‖ = ‖t.val‖ := rfl
lemma dist_eq_val (t1 t2 : Time) :
dist t1 t2 = ‖t1.val - t2.val‖ := rfl
instance : SeminormedAddCommGroup Time where
dist_eq t1 t2 := by
simp [dist_eq_val, norm_eq_val]
rw [abs_eq_iff_mul_self_eq]
ring
instance : NormedAddCommGroup Time where
dist_eq t1 t2 := by
simp [dist_eq_val, norm_eq_val]
rw [abs_eq_iff_mul_self_eq]
ring
instance : NormedSpace ℝ Time where
norm_smul_le k t := by simp [abs_mul, norm]
/-!
### A.11. Inner product on `Time`
-/
open InnerProductSpace
/-!
### A.12. Decidability of `Time`
-/
/-!
### A.13. Measurability of `Time`
-/
/-!
## B. Basis of `Time`
-/
open MeasureTheory
@[simp]
lemma rank_eq_one : Module.rank ℝ Time = 1 :=
rank_eq_one_iff.mpr ⟨1, one_ne_zero, fun v => ⟨v.val, Time.ext (by simp)⟩⟩
instance : FiniteDimensional ℝ Time := Module.finite_of_rank_eq_one rank_eq_one
/-!
## C. Maps from `Time` to `ℝ`
-/
/-- The continuous linear equivalence from `Time` to `ℝ`. -/
noncomputable def toRealCLE : Time ≃L[ℝ] ℝ := LinearEquiv.toContinuousLinearEquiv
{
toFun := Time.val
invFun := fun x => ⟨x⟩
left_inv x := by rfl
right_inv x := by rfl
map_add' := by simp
map_smul' := by simp
}
end Time
end
section
/-
Copyright (c) 2025 Joseph Tooby-Smith. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Nikolai Kashcheev, Zhi Kai Pong, Joseph Tooby-Smith
-/
/-!
# Time Derivatives
## i. Overview
In this module we define and prove basic lemmas about derivatives of functions on `Time`.
## ii. Key results
- `deriv` : The derivative of a function `Time → M` at a given time.
- `manifoldDeriv` : The derivative of a function from `Time` to a manifold.
- `derivVec` : The derivative of a function from `Time` into a torsor, such as `Space d`,
valued in the vector space of displacements of that torsor.
- `hasDerivAt_comp_toRealCLE_symm` : The time derivative as a `HasDerivAt` on `ℝ`, for a curve
reparametrised through the canonical equivalence `toRealCLE.symm : ℝ ≃L[ℝ] Time`.
- `deriv_comp_toRealCLE_of_hasDerivAt` : Its converse, a `HasDerivAt` on `ℝ` read as the time
derivative of the curve pulled back to `Time` through `toRealCLE`.
- `hasDerivAt_mk_of_differentiableAt` and `deriv_eq_of_hasDerivAt` : The same two bridges for a
real-valued curve `f : Time → ℝ`, stated at `t : Time` through the curve `τ ↦ f ⟨τ⟩` on `ℝ`.
- `deriv_comp_neg` and `deriv_deriv_comp_neg` : The first and second time derivatives under the
reversal of time `t ↦ -t`.
## iii. Table of contents
- A. The definition of the derivative
- A.1. Derivatives of functions into vector spaces
- A.2. The derivative through the canonical equivalence with `ℝ`
- A.3. Derivatives of functions into manifolds
- A.4. Derivatives of functions into torsors
- B. Linearlity properties of the derivative
- C. Derivative of constant functions
- D. Smoothness properties and the reversal of time
- E. Derivatives of components
- F. Derivatives of trajectories into `Space`
## iv. References
* None.
-/
namespace Time
variable {M : Type} {d : ℕ} {t : Time}
/-!
## A. The definition of the derivative
-/
/-!
### A.1. Derivatives of functions into vector spaces
-/
/-- Given a function `f : Time → M` the derivative of `f`. -/
noncomputable def deriv [AddCommGroup M] [Module ℝ M] [TopologicalSpace M]
(f : Time → M) : Time → M :=
(fun t => fderiv ℝ f t 1)
@[inherit_doc deriv]
scoped notation "∂ₜ" => deriv
/-!
### A.2. The derivative through the canonical equivalence with `ℝ`
`Time` is identified with `ℝ` by the continuous linear equivalence `toRealCLE`. Precomposing a
curve `w : Time → M` with `toRealCLE.symm : ℝ ≃L[ℝ] Time` gives a curve on `ℝ`, whose Mathlib
derivative (`HasDerivAt`) at `τ` is the time derivative `∂ₜ w` evaluated at `toRealCLE.symm τ`.
This is the bridge through which Mathlib's calculus and ODE theory on `ℝ` applies to curves on
`Time`. Conversely, a `HasDerivAt` on `ℝ` at `toRealCLE t` is the time derivative at `t` of the
curve pulled back to `Time` through `toRealCLE`.
-/
/-!
### A.3. Derivatives of functions into manifolds
-/
/-!
### A.4. Derivatives of functions into torsors
A trajectory in physical space is a curve of points, and its velocity is a displacement per
unit time, that is a vector. For a torsor `P` over a vector space `V`, for example
`Space d` over `EuclideanSpace ℝ (Fin d)`, the derivative of a curve `f : Time → P` is
therefore valued in `V` rather than in `P`. It is defined by differentiating the displacement
curve `s ↦ f s -ᵥ f t`, which is `V`-valued, so that no origin of `P` is ever chosen. The
reference point used to form the displacement is irrelevant, see `derivVec_eq_fderiv_vsub`.
-/
/-!
## B. Linearlity properties of the derivative
-/
/-!
## C. Derivative of constant functions
-/
/-!
## D. Smoothness properties and the reversal of time
-/
open MeasureTheory ContDiff InnerProductSpace Time
/-!
## E. Derivatives of components
-/
/-!
## F. Derivatives of trajectories into `Space`
For a trajectory `f : Time → Space d` of points in space, the torsor derivative `∂ₜᵥ f` is
valued in the displacement space `EuclideanSpace ℝ (Fin d)`. Componentwise it agrees with the
time derivatives of the coordinates, and under the identification of `Space d` with its
displacement space given by the (arbitrary) zero point it recovers the vector space derivative
`∂ₜ f`. The latter bridges `∂ₜᵥ` to the existing `∂ₜ` API.
Note that `Space d` carries two `AddTorsor` instances: the intended one over
`EuclideanSpace ℝ (Fin d)`, and one over itself coming from the module structure on `Space d`.
Instance resolution selects the former, so `∂ₜᵥ` of a trajectory in `Space d` is valued in
`EuclideanSpace ℝ (Fin d)` as intended.
-/
end Time
end
section
/-
Copyright (c) 2024 Joseph Tooby-Smith. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Samyak Rai, Joseph Tooby-Smith
-/
/-!
# The Speed of Light
The speed of light in a vacuum, in the format of `Physlib/Units/Constants.lean`.
## i. Overview
The speed of light has the dimension `L T⁻¹`, and its value in SI units is exact. Section F adds
the instance of one and the speed of light as a dimensioned quantity.
## ii. Key results
- `SpeedOfLight` : The speed of light in a chosen but arbitrary system of units.
- `speedOfLight` : The speed of light in our world, `299792458 m s⁻¹`.
- `SpeedOfLight.toWithDim` : The speed of light as a quantity with the dimension of
length over time.
- `SpeedOfLight.toWithDim_scaleUnit` : The map `toWithDim` commutes with changes of units.
## iii. Table of contents
- A. The type
- B. Instances
- C. Positivity
- D. The dimension
- E. The value in our world
- F. Specific to the speed of light
- F.1. The instance of one
- F.2. As a dimensioned quantity
## iv. References
* The defining value of the speed of light. [ref: bipm_si_brochure_2019]
-/
open scoped NNReal
/-!
## A. The type
-/
/-- The speed of light in a vacuum, in a chosen but arbitrary system of units. -/
structure SpeedOfLight where
/-- The underlying value of the speed of light. -/
val : ℝ
pos : 0 < val
namespace SpeedOfLight
/-!
## B. Instances
-/
instance : Coe SpeedOfLight ℝ := ⟨SpeedOfLight.val⟩
/-!
## C. Positivity
-/
@[simp]
lemma val_ne_zero (c : SpeedOfLight) : (c : ℝ) ≠ 0 := ne_of_gt c.pos
/-!
## D. The dimension
-/
end SpeedOfLight
/-!
## E. The value in our world
-/
namespace SpeedOfLight
/-!
## F. Specific to the speed of light
### F.1. The instance of one
We define the instance of one for `SpeedOfLight` to be the speed of light equal to `1`.
This is useful when we are working in units where the speed of light is equal to one.
-/
/-!
### F.2. As a dimensioned quantity
-/
end SpeedOfLight
end
section
/-
Copyright (c) 2025 Joseph Tooby-Smith. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Luis Gabriel C. Bariuan, Joseph Tooby-Smith
-/
/-!
# The Friedmann-Lemaître-Robertson-Walker metric
The spatial geometry of an FLRW model and its curvature parameter, the structures `FLRW` and
`CosmicFluid`, the density and pressure of the cosmological constant as a fluid and the cosmic
fluid with the cosmological constant folded in, the tangent-line bound for an FLRW model whose
scale factor decelerates and the resulting lower bound on its interval of time, the first- and
second-order Friedmann equations, the proposition `FLRW.FriedmannSolution` that a model and a
fluid solve them, and the Hubble and deceleration parameters.
-/
open Filter
open scoped Topology
namespace Cosmology
/-- The inductive type with three constructors:
- `Spherical (k : ℝ)`
- `Flat`
- `Saddle (k : ℝ)`
-/
inductive SpatialGeometry : Type where
| Spherical (k : ℝ) (h : k < 0)
| Flat
| Saddle (k : ℝ) (h : k > 0)
namespace SpatialGeometry
/-- For `s` corresponding to
- `Spherical k`, `S s r = k * sin (r / k)`
- `Flat`, `S s r = r`,
- `Saddle k`, `S s r = k * sinh (r / k)`.
-/
noncomputable def S (s : SpatialGeometry) : ℝ → ℝ :=
fun r =>
match s with
| SpatialGeometry.Spherical k _ => k * Real.sin (r / k)
| SpatialGeometry.Flat => r
| SpatialGeometry.Saddle k _ => k * Real.sinh (r / k)
/-- The curvature parameter of the spatial geometry, the constant `k` of the first-order
Friedmann equation `FLRW.FriedmannEquation.FirstOrderFriedmann`:
- `1 / k ^ 2` for `Spherical k`, whose profile `S` is that of a sphere of radius `|k|`,
- `0` for `Flat`,
- `-1 / k ^ 2` for `Saddle k`, whose profile `S` is that of a hyperbolic space of curvature
radius `|k|`.
-/
noncomputable def curvature : SpatialGeometry → ℝ
| Spherical k _ => 1 / k ^ 2
| Flat => 0
| Saddle k _ => -1 / k ^ 2
end SpatialGeometry
open Time in
/-- An FLRW model: the scale factor `a` of the Friedmann-Lemaître-Robertson-Walker metric on an
open interval `I` of cosmic time, positive and twice differentiable on `I`, together with the
geometry of the spatial slices. The values of `a` outside `I` carry no meaning. The interval
lets a model begin at a Big Bang, as the Milne model `FLRW.milne` does on
`I = {t | 0 < t.val}`. -/
structure FLRW where
/-- The interval of cosmic time on which the model is defined. -/
I : Set Time
/-- The interval `I` is open. -/
isOpen_I : IsOpen I
/-- The set `I` is an interval. -/
ordConnected_I : I.OrdConnected
/-- The scale factor as a function of cosmic time. -/
a : Time → ℝ
/-- The scale factor is positive on `I`. -/
a_pos : ∀ t ∈ I, 0 < a t
/-- The scale factor is differentiable on `I`. -/
differentiableOn_a : DifferentiableOn ℝ a I
/-- The time derivative of the scale factor is differentiable on `I`. -/
differentiableOn_deriv_a : DifferentiableOn ℝ (∂ₜ a) I
/-- The geometry of the spatial slices. -/
geometry : SpatialGeometry
/-- The cosmic fluid filling an FLRW model, described by its total energy density `ρ` and its
pressure `p`, both functions of cosmic time, as in the first- and second-order Friedmann
equations `FLRW.FriedmannEquation.FirstOrderFriedmann` and
`FLRW.FriedmannEquation.SecondOrderFriedmann`. -/
structure CosmicFluid where
/-- The total energy density as a function of cosmic time. -/
ρ : Time → ℝ
/-- The pressure as a function of cosmic time. -/
p : Time → ℝ
namespace FLRW
section
open Time
variable (U : FLRW)
end
/-!
## The interval and the tangent-line bound for a decelerating model
These statements hold for any FLRW model; they do not use the Friedmann equations.
-/
section
open Time
end
namespace FriedmannEquation
open Time
/--
The first-order Friedmann equation.
- `a : Time → ℝ` is the FLRW scale factor as a function of cosmic time `t`.
- `ρ : Time → ℝ` is the total energy density as a function of cosmic time `t`.
- `k : ℝ` is the spatial curvature parameter.
- `Λ : ℝ` is the cosmological constant.
- `G : ℝ` is Newton's constant.
- `c : SpeedOfLight` is the speed of light; take `c = 1` for units in which it is one.
Note: We will leave `c` explicit for generality and accounting purposes.
At time `t` the equation reads:
`(a'(t) / a(t))^2 = (8πG/3) ρ(t) − k c^2 / a(t)^2 + Λ c^2 / 3`.
-/
def FirstOrderFriedmann (a ρ : Time → ℝ) (k Λ G : ℝ) (c : SpeedOfLight) (t : Time) : Prop :=
((∂ₜ a t / a t)^2
= ((8 * Real.pi * G) / 3) * ρ t - k * (c : ℝ) ^ 2 / (a t)^2 + Λ * (c : ℝ) ^ 2 / 3)
/--
The second-order Friedmann equation.
Note: Other sources may call this the Raychaudhuri equation.
We choose not to use that terminology to avoid the Raychaudhuri equation
related to describing congruences of geodesics in general relativity.
- `a : Time → ℝ` is the FLRW scale factor as a function of cosmic time `t`.
- `ρ : Time → ℝ` is the total energy density as a function of cosmic time `t`.
- `p : Time → ℝ` is the pressure. It is related to `ρ` via `p = w * ρ `
- `w` is the equation of state. We will introduce this later.
- `Λ : ℝ` is the cosmological constant.
- `G : ℝ` is Newton's constant.
- `c : SpeedOfLight` is the speed of light; take `c = 1` for units in which it is one.
Note: We will leave `c` explicit for generality and accounting purposes.
At time `t` the equation reads:
`(a''(t) / a (t)) = - (4πG/3) * (ρ(t) + 3 * p(t) / c^2) + Λ * c^2 / 3`.
-/
def SecondOrderFriedmann (a ρ p : Time → ℝ) (Λ G : ℝ) (c : SpeedOfLight) (t : Time) : Prop :=
∂ₜ (∂ₜ a) t / a t
= - (4 * Real.pi * G / 3) * (ρ t + 3 * p t / (c : ℝ) ^ 2) + Λ * (c : ℝ) ^ 2 / 3
end FriedmannEquation
end FLRW
namespace FLRW
open FriedmannEquation
end FLRW
end Cosmology
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
-/
/-!
# The Newtonian gravitational constant
Newton's gravitational constant `G`, in the format of `Physlib/Units/Constants.lean`, together with
geometric and natural unit systems in which `c = G = k_B = 1`.
## i. Overview
Newton's universal gravitational constant `G` has dimension `L³ M⁻¹ T⁻²` (`L𝓭 * L𝓭 * L𝓭 * M𝓭⁻¹ *
T𝓭⁻¹ * T𝓭⁻¹`) and CODATA 2022 recommended SI value `6.67430 × 10⁻¹¹ m³ kg⁻¹ s⁻²`. Because the
dimensions of `c` (`L T⁻¹`), `G` (`L³ M⁻¹ T⁻²`), and `k_B` (`M L² T⁻² Θ⁻¹`) are linearly
independent in the `(L, T, M, Θ)` base space, `exists_units_c_G_kB_eq_one` parallels
`Physlib.Units.Constants.exists_units_constants_eq_one` by constructing systems of units in which
`c`, `G`, and `k_B` simultaneously take the numerical value `1`.
## ii. Key results
- `GravitationalConstant` : Newton's gravitational constant in a chosen but arbitrary system of
units.
- `gravitationalConstantDimension`, `GravitationalConstant.instHasDim` : The dimension
`L³ M⁻¹ T⁻²` of Newton's gravitational constant.
- `gravitationalConstant`, `gravitationalConstant_in_SI` : The gravitational constant in our world,
`6.67430 × 10⁻¹¹ m³ kg⁻¹ s⁻²` (CODATA 2022).
- `GravitationalConstant.toWithDim`, `GravitationalConstant.toWithDim_scaleUnit` : The
gravitational constant as a dimensioned quantity and unit-scaling equivariance.
- `exists_units_c_G_kB_eq_one` : Existence of a system of units `u : LTMCTUnitChoices` in which
`(speedOfLight u).val = 1`, `(gravitationalConstant u).val = 1`, and
`(boltzmannConstant u).val = 1`.
## iii. Table of contents
- A. The type
- B. Instances
- C. Positivity
- D. The dimension
- E. Specific to the gravitational constant
- E.1. The instance of one
- E.2. As a dimensioned quantity
- F. The value in our world
- G. Natural and geometric unit systems
## iv. References
* International Bureau of Weights and Measures (BIPM), *The International System of Units (SI
Brochure)*, 9th ed. (2019), Sec. 2.2
(https://www.bipm.org/documents/d/guest/si-brochure-9-en-pdf). [ref: bipm_si_brochure_2019]
* P. J. Mohr, D. B. Newell, B. N. Taylor, and E. Tiesinga, *CODATA Recommended Values of the
Fundamental Physical Constants: 2022*, *Reviews of Modern Physics* 97(2), 025002 (2025),
"Newtonian constant of gravitation" entry (https://physics.nist.gov/cgi-bin/cuu/Value?bg).
[ref: CODATA2022]
* R. M. Wald, *General Relativity* (1984), App. F. [ref: wald_1984_general_relativity]
-/
open scoped NNReal
/-!
## A. The type
Following `Physlib/Units/Constants.lean`, `GravitationalConstant` packages a positive real value
representing Newton's constant in an arbitrary choice of units.
-/
/-- Newton's universal gravitational constant `G`, in a chosen but arbitrary system of units. -/
structure GravitationalConstant where
/-- The underlying numerical value of the gravitational constant. -/
val : ℝ
/-- Positivity of the gravitational constant in any valid unit system. -/
pos : 0 < val
namespace GravitationalConstant
/-!
## B. Instances
This section registers `PositiveRealUnitCore` and the real coercion so `GravitationalConstant`
transforms automatically under changes of `LTMCTUnitChoices`.
-/
instance : Coe GravitationalConstant ℝ := ⟨GravitationalConstant.val⟩
/-!
## C. Positivity
Basic positivity, nonnegativity, and nonvanishing lemmas for the numerical value of the
gravitational constant in any unit system.
-/
/-!
## D. The dimension
Newton's constant carries the mechanical dimension `L³ M⁻¹ T⁻²`, matching `G M / r²` having the
dimension of acceleration.
-/
/-!
## E. Specific to the gravitational constant
### E.1. The instance of one
We define the instance of one for `GravitationalConstant` to be the gravitational constant equal to
`1`, corresponding to geometric or Planck units.
-/
/-!
### E.2. As a dimensioned quantity
Embedding `GravitationalConstant` into `WithDim` relates unit scaling directly to the dimensional
scale factor of `L³ M⁻¹ T⁻²`.
-/
end GravitationalConstant
/-!
## F. The value in our world
The SI value is fixed from the CODATA 2022 recommended value `6.67430 × 10⁻¹¹ m³ kg⁻¹ s⁻²`.
-/
/-!
## G. Natural and geometric unit systems
Rescaling the SI length, mass, and temperature units simultaneously sets `c = 1`, `G = 1`, and
`k_B = 1` in `LTMCTUnitChoices`.
-/
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
-/
/-!
# Comoving perfect-fluid stress-energy
Perfect-fluid stress-energy tensor for a comoving observer in four dimensions.
## i. Overview
For a comoving observer `u = (-1, 0, 0, 0)`, mass density `ρ`, pressure `p`, and speed of light
`c`, the perfect-fluid stress-energy tensor is `T_{ij} = (ρ c² + p) u_i u_j + p g_{ij}`.
## ii. Key results
- `perfectFluidStressEnergy` : comoving perfect-fluid stress-energy tensor.
## iii. Table of contents
- A. Comoving perfect-fluid stress-energy
## iv. References
* R. M. Wald, *General Relativity* (1984), Ch. 4 (Sec. 4.3). [ref: wald_1984_general_relativity]
* S. M. Carroll, *Lecture Notes on General Relativity* (1997), Ch. 4 (Sec. 4.3)
(https://arxiv.org/pdf/gr-qc/9712019#page=112). [ref: Carroll1997]
-/
namespace GeneralRelativity
/-!
## A. Comoving perfect-fluid stress-energy
The comoving four-velocity has only a time component, so the fluid stress-energy is diagonal in
the observer frame up to the spatial metric term.
-/
/-- Comoving perfect-fluid stress-energy tensor `T_{ij} = (ρ c² + p) u_i u_j + p g_{ij}` for a
comoving observer `u = (-1, 0, 0, 0)` with speed of light `c`, mass density `ρ`, and pressure
`p`. -/
def perfectFluidStressEnergy (c : SpeedOfLight) (ρ p : ℝ) (g : Tensor2 4) : Tensor2 4 :=
Matrix.of fun i j => (ρ * (c : ℝ) ^ 2 + p) * (if i = 0 ∧ j = 0 then 1 else 0) + p * g i j
end GeneralRelativity
end
Source