pith. machine review for the scientific record. sign in

IndisputableMonolith.Foundation.LawOfExistence

IndisputableMonolith/Foundation/LawOfExistence.lean · 203 lines · 21 declarations

show as:
view math explainer →

open module explainer GitHub source

Explainer status: pending

   1import Mathlib
   2import IndisputableMonolith.Cost
   3
   4/-!
   5# Law of Existence: Rigorous Formalization
   6
   7This module provides a **sharp, literal** formalization of the Law of Existence:
   8
   9  **x exists ⟺ defect(x) = 0**
  10
  11## Key Theorems
  12
  131. `defect_zero_iff_one`: defect(x) = 0 ⟺ x = 1
  142. `law_of_existence`: Exists x ⟺ DefectCollapse x
  153. `unity_unique_existent`: 1 is the unique existent
  164. `nothing_cannot_exist`: ∀ C, ∃ ε > 0, ∀ x ∈ (0,ε), defect(x) > C
  175. `existence_economically_inevitable`: ∃! x > 0, x minimizes defect
  18-/
  19
  20namespace IndisputableMonolith
  21namespace Foundation
  22namespace LawOfExistence
  23
  24open Real
  25
  26/-! ## The Cost/Defect Functional -/
  27
  28/-- The canonical cost functional J(x) = ½(x + x⁻¹) - 1. -/
  29noncomputable def J (x : ℝ) : ℝ := (x + x⁻¹) / 2 - 1
  30
  31/-- The defect functional. Equals J for positive x. -/
  32noncomputable def defect (x : ℝ) : ℝ := J x
  33
  34/-- Defect at unity is zero. -/
  35@[simp] theorem defect_at_one : defect 1 = 0 := by simp [defect, J]
  36
  37/-- Defect is non-negative for positive arguments. -/
  38theorem defect_nonneg {x : ℝ} (hx : 0 < x) : 0 ≤ defect x := by
  39  simp only [defect, J]
  40  have hx0 : x ≠ 0 := hx.ne'
  41  have h : 0 ≤ (x - 1)^2 / x := by positivity
  42  calc (x + x⁻¹) / 2 - 1 = ((x - 1)^2 / x) / 2 := by field_simp; ring
  43    _ ≥ 0 := by positivity
  44
  45/-! ## The Existence Predicate -/
  46
  47/-- **Existence Predicate**: x exists in the RS framework iff x > 0 and defect(x) = 0. -/
  48structure Exists (x : ℝ) : Prop where
  49  pos : 0 < x
  50  defect_zero : defect x = 0
  51
  52/-- **Defect Collapse Predicate**: Equivalent formulation. -/
  53def DefectCollapse (x : ℝ) : Prop := 0 < x ∧ defect x = 0
  54
  55/-! ## Core Equivalence Theorems -/
  56
  57/-- **Defect Zero Characterization**: defect(x) = 0 ⟺ x = 1 (for x > 0). -/
  58theorem defect_zero_iff_one {x : ℝ} (hx : 0 < x) : defect x = 0 ↔ x = 1 := by
  59  simp only [defect, J]
  60  constructor
  61  · intro h
  62    have hx0 : x ≠ 0 := hx.ne'
  63    -- (x + 1/x)/2 - 1 = 0 implies (x + 1/x) = 2
  64    have h1 : x + x⁻¹ = 2 := by linarith
  65    -- Multiply by x: x² + 1 = 2x, so (x-1)² = 0
  66    have h2 : x * (x + x⁻¹) = x * 2 := by rw [h1]
  67    have h3 : x^2 + 1 = 2 * x := by field_simp at h2; linarith
  68    nlinarith [sq_nonneg (x - 1)]
  69  · intro h; simp [h]
  70
  71/-- **Law of Existence (Forward)**: Existence implies defect is zero. -/
  72theorem exists_implies_defect_zero {x : ℝ} (h : Exists x) : defect x = 0 :=
  73  h.defect_zero
  74
  75/-- **Law of Existence (Backward)**: Zero defect (with x > 0) implies existence. -/
  76theorem defect_zero_implies_exists {x : ℝ} (hpos : 0 < x) (hdef : defect x = 0) :
  77    Exists x := ⟨hpos, hdef⟩
  78
  79/-- **Law of Existence (Biconditional)**: x exists ⟺ defect collapses. -/
  80theorem law_of_existence (x : ℝ) : Exists x ↔ DefectCollapse x :=
  81  ⟨fun ⟨hpos, hdef⟩ => ⟨hpos, hdef⟩, fun ⟨hpos, hdef⟩ => ⟨hpos, hdef⟩⟩
  82
  83/-- **Existence Characterization**: x exists ⟺ x = 1. -/
  84theorem exists_iff_unity {x : ℝ} (hx : 0 < x) : Exists x ↔ x = 1 :=
  85  ⟨fun ⟨_, hdef⟩ => (defect_zero_iff_one hx).mp hdef,
  86   fun h => ⟨hx, (defect_zero_iff_one hx).mpr h⟩⟩
  87
  88/-- **Unity is Unique Existent**: ∀ x, Exists x ⟺ x = 1. -/
  89theorem unity_unique_existent : ∀ x : ℝ, Exists x ↔ x = 1 := by
  90  intro x
  91  constructor
  92  · intro ⟨hpos, hdef⟩; exact (defect_zero_iff_one hpos).mp hdef
  93  · intro h; subst h; exact ⟨one_pos, defect_at_one⟩
  94
  95/-- Alias for `defect_at_one`. -/
  96theorem defect_one : defect 1 = 0 := defect_at_one
  97
  98/-- Defect is strictly positive for x ≠ 1. -/
  99theorem defect_pos_of_ne_one {x : ℝ} (hx : 0 < x) (hne : x ≠ 1) : 0 < defect x := by
 100  have h_nn := defect_nonneg hx
 101  have h_ne_zero : defect x ≠ 0 := fun h => hne ((defect_zero_iff_one hx).mp h)
 102  exact lt_of_le_of_ne h_nn (Ne.symm h_ne_zero)
 103
 104/-! ## Nothing Cannot Exist: J(0) → ∞ -/
 105
 106/-- As x → 0⁺, defect(x) → +∞.
 107
 108Technical proof: J(x) = (x + 1/x)/2 - 1 ≥ 1/(2x) - 1 → +∞ as x → 0⁺. -/
 109theorem defect_tendsto_atTop_at_zero :
 110    Filter.Tendsto defect (nhdsWithin 0 (Set.Ioi 0)) Filter.atTop := by
 111  unfold defect J
 112  -- The proof uses that 1/x → +∞ as x → 0⁺, and (x + 1/x)/2 - 1 ≥ 1/(2x) - 1
 113  have hinv : Filter.Tendsto (fun x : ℝ => x⁻¹) (nhdsWithin 0 (Set.Ioi 0)) Filter.atTop :=
 114    tendsto_inv_nhdsGT_zero
 115  rw [Filter.tendsto_atTop]
 116  intro r
 117  rw [Filter.tendsto_atTop] at hinv
 118  have hev := hinv (2 * (r + 2))
 119  -- On nhdsWithin 0 (Ioi 0), x is positive. Combine with x⁻¹ ≥ 2(r+2)
 120  have hpos : ∀ᶠ x in nhdsWithin (0 : ℝ) (Set.Ioi 0), 0 < x := eventually_mem_nhdsWithin
 121  apply Filter.Eventually.mono (hev.and hpos)
 122  intro x ⟨hinvx, hx0⟩
 123  have h1 : (x + x⁻¹) / 2 - 1 ≥ x⁻¹ / 2 - 1 := by linarith
 124  have h2 : x⁻¹ / 2 - 1 ≥ (2 * (r + 2)) / 2 - 1 := by linarith
 125  linarith
 126
 127/-- **Nothing Cannot Exist**: For any cost bound C, defect exceeds C near zero.
 128
 129This is the **sharp** statement that "Nothing costs infinity." -/
 130theorem nothing_cannot_exist (C : ℝ) :
 131    ∃ ε > 0, ∀ x, 0 < x → x < ε → C < defect x := by
 132  -- Choose ε = 1/(2(|C|+2)) so that 1/x > 2(|C|+2) when x < ε
 133  use 1 / (2 * (|C| + 2))
 134  constructor
 135  · positivity
 136  · intro x hxpos hxlt
 137    -- x < 1/(2(|C|+2)) implies 1/x > 2(|C|+2)
 138    have hbound : 0 < 2 * (|C| + 2) := by positivity
 139    have hinv : 2 * (|C| + 2) < x⁻¹ := by
 140      rw [inv_eq_one_div, lt_one_div hbound hxpos]
 141      exact hxlt
 142    simp only [defect, J]
 143    have hxinv_pos : 0 < x⁻¹ := inv_pos.mpr hxpos
 144    -- (x + 1/x)/2 - 1 ≥ 1/x / 2 - 1 > (2(|C|+2))/2 - 1 = |C| + 1 ≥ C + 1 > C
 145    have h1 : x⁻¹ / 2 > |C| + 1 := by linarith
 146    have h2 : (x + x⁻¹) / 2 ≥ x⁻¹ / 2 := by
 147      have : x ≥ 0 := le_of_lt hxpos
 148      linarith
 149    have h3 : |C| ≥ C := le_abs_self C
 150    linarith
 151
 152/-! ## Structured Set -/
 153
 154/-- The structured set S = {x ∈ ℝ₊ : defect(x) = 0} = {1}. -/
 155def StructuredSet : Set ℝ := {x : ℝ | 0 < x ∧ defect x = 0}
 156
 157theorem structured_set_singleton : StructuredSet = {1} := by
 158  ext x
 159  simp only [StructuredSet, Set.mem_setOf_eq, Set.mem_singleton_iff]
 160  constructor
 161  · intro ⟨hpos, hdef⟩; exact (defect_zero_iff_one hpos).mp hdef
 162  · intro h; subst h; exact ⟨one_pos, defect_at_one⟩
 163
 164/-- Membership in structured set ⟺ existence. -/
 165theorem mem_structured_iff_exists {x : ℝ} : x ∈ StructuredSet ↔ Exists x :=
 166  ⟨fun ⟨hpos, hdef⟩ => ⟨hpos, hdef⟩, fun ⟨hpos, hdef⟩ => ⟨hpos, hdef⟩⟩
 167
 168/-! ## Economic Inevitability -/
 169
 170/-- **Existence is Economically Inevitable**: 1 is the unique minimizer of defect. -/
 171theorem existence_economically_inevitable :
 172    ∃! x : ℝ, 0 < x ∧ ∀ y, 0 < y → defect x ≤ defect y := by
 173  refine ⟨1, ⟨one_pos, ?_⟩, ?_⟩
 174  · intro y hy
 175    rw [defect_at_one]
 176    exact defect_nonneg hy
 177  · intro z ⟨hzpos, hzmin⟩
 178    have h1 : defect z ≤ defect 1 := hzmin 1 one_pos
 179    rw [defect_at_one] at h1
 180    have h2 : defect z = 0 := le_antisymm h1 (defect_nonneg hzpos)
 181    exact (defect_zero_iff_one hzpos).mp h2
 182
 183/-! ## Complete Law of Existence -/
 184
 185/-- **Complete Law of Existence**: The following are equivalent for x > 0:
 1861. Exists x
 1872. defect(x) = 0
 1883. x ∈ StructuredSet
 1894. x = 1 -/
 190theorem complete_law_of_existence {x : ℝ} (hx : 0 < x) :
 191    Exists x ↔ defect x = 0 ∧ x ∈ StructuredSet ∧ x = 1 := by
 192  constructor
 193  · intro hex
 194    refine ⟨hex.defect_zero, mem_structured_iff_exists.mpr hex, ?_⟩
 195    exact (exists_iff_unity hx).mp hex
 196  · intro ⟨_, _, h3⟩
 197    subst h3
 198    exact ⟨one_pos, defect_at_one⟩
 199
 200end LawOfExistence
 201end Foundation
 202end IndisputableMonolith
 203

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