pith. machine review for the scientific record. sign in

IndisputableMonolith.Relativity.Fields.Scalar

IndisputableMonolith/Relativity/Fields/Scalar.lean · 101 lines · 19 declarations

show as:
view math explainer →

open module explainer GitHub source

Explainer status: pending

   1import Mathlib
   2import IndisputableMonolith.Relativity.Geometry
   3
   4namespace IndisputableMonolith
   5namespace Relativity
   6namespace Fields
   7
   8open Geometry
   9
  10/-- A scalar field assigns a real value to each spacetime point. -/
  11structure ScalarField where
  12  ψ : (Fin 4 → ℝ) → ℝ
  13
  14/-- Evaluate scalar field at a point. -/
  15noncomputable def eval (φ : ScalarField) (x : Fin 4 → ℝ) : ℝ := φ.ψ x
  16
  17/-- Constant scalar field. -/
  18def constant (c : ℝ) : ScalarField := { ψ := fun _ => c }
  19
  20theorem constant_eval (c : ℝ) (x : Fin 4 → ℝ) :
  21  eval (constant c) x = c := rfl
  22
  23/-- Zero scalar field. -/
  24def zero : ScalarField := constant 0
  25
  26theorem zero_eval (x : Fin 4 → ℝ) : eval zero x = 0 := rfl
  27
  28/-- Scalar field addition. -/
  29def add (φ₁ φ₂ : ScalarField) : ScalarField :=
  30  { ψ := fun x => φ₁.ψ x + φ₂.ψ x }
  31
  32/-- Scalar multiplication. -/
  33def smul (c : ℝ) (φ : ScalarField) : ScalarField :=
  34  { ψ := fun x => c * φ.ψ x }
  35
  36theorem add_comm (φ₁ φ₂ : ScalarField) :
  37  ∀ x, eval (add φ₁ φ₂) x = eval (add φ₂ φ₁) x := by
  38  intro x
  39  simp [eval, add]
  40  ring
  41
  42theorem smul_zero (φ : ScalarField) :
  43  ∀ x, eval (smul 0 φ) x = 0 := by
  44  intro x
  45  simp [eval, smul]
  46
  47/-- Directional derivative of scalar field in direction μ. -/
  48noncomputable def directional_deriv (φ : ScalarField) (μ : Fin 4) (x : Fin 4 → ℝ) : ℝ :=
  49  let h := (0.001 : ℝ)
  50  let x_plus := fun ν => if ν = μ then x ν + h else x ν
  51  (φ.ψ x_plus - φ.ψ x) / h
  52
  53/-- Directional derivative is linear in the field. -/
  54theorem deriv_add (φ₁ φ₂ : ScalarField) (μ : Fin 4) (x : Fin 4 → ℝ) :
  55  directional_deriv (add φ₁ φ₂) μ x =
  56    directional_deriv φ₁ μ x + directional_deriv φ₂ μ x := by
  57  simp [directional_deriv, add]
  58  ring
  59
  60theorem deriv_smul (c : ℝ) (φ : ScalarField) (μ : Fin 4) (x : Fin 4 → ℝ) :
  61  directional_deriv (smul c φ) μ x = c * directional_deriv φ μ x := by
  62  simp only [directional_deriv, smul]
  63  ring
  64
  65/-- Derivative of constant field is zero. -/
  66theorem deriv_constant (c : ℝ) (μ : Fin 4) (x : Fin 4 → ℝ) :
  67  directional_deriv (constant c) μ x = 0 := by
  68  simp only [directional_deriv, constant]
  69  norm_num
  70
  71/-- Gradient: collection of all directional derivatives ∂_μ ψ. -/
  72noncomputable def gradient (φ : ScalarField) (x : Fin 4 → ℝ) : Fin 4 → ℝ :=
  73  fun μ => directional_deriv φ μ x
  74
  75/-- Squared gradient g^{μν} (∂_μ ψ)(∂_ν ψ) with inverse metric. -/
  76noncomputable def gradient_squared (φ : ScalarField) (g : MetricTensor) (x : Fin 4 → ℝ) : ℝ :=
  77  Finset.sum (Finset.univ : Finset (Fin 4)) (fun μ =>
  78    Finset.sum (Finset.univ : Finset (Fin 4)) (fun ν =>
  79      (inverse_metric g) x (fun i => if (i : ℕ) = 0 then μ else ν) (fun _ => 0) *
  80      (gradient φ x μ) * (gradient φ x ν)))
  81
  82/-- Gradient squared for Minkowski metric. -/
  83theorem gradient_squared_minkowski (φ : ScalarField) (x : Fin 4 → ℝ) :
  84  gradient_squared φ minkowski_tensor x =
  85    -(gradient φ x 0)^2 + (gradient φ x 1)^2 + (gradient φ x 2)^2 + (gradient φ x 3)^2 := by
  86  unfold gradient_squared
  87  apply gradient_squared_minkowski_sum
  88
  89/-- Field squared. -/
  90noncomputable def field_squared (φ : ScalarField) (x : Fin 4 → ℝ) : ℝ :=
  91  (φ.ψ x) ^ 2
  92
  93theorem field_squared_nonneg (φ : ScalarField) (x : Fin 4 → ℝ) :
  94  field_squared φ x ≥ 0 := by
  95  simp [field_squared]
  96  exact sq_nonneg _
  97
  98end Fields
  99end Relativity
 100end IndisputableMonolith
 101

source mirrored from github.com/jonwashburn/shape-of-logic