pith. machine review for the scientific record. sign in

IndisputableMonolith.RSBridge.GapFunctionForcing

IndisputableMonolith/RSBridge/GapFunctionForcing.lean · 233 lines · 13 declarations

show as:
view math explainer →

open module explainer GitHub source

Explainer status: ready · generated 2026-05-13 12:08:23.123841+00:00

   1import Mathlib
   2import IndisputableMonolith.Constants
   3import IndisputableMonolith.RSBridge.Anchor
   4
   5/-!
   6# Gap Function Forcing (Three-Point Calibration)
   7
   8Within the affine-log candidate family
   9
  10  `g(x) = a · log(1 + x / b) + c`,
  11
  12three normalization conditions uniquely fix all parameters:
  13
  141. `g(0) = 0` forces `c = 0`
  152. `g(-1) = -2` with `b > 1` forces `b = φ`
  163. `g(1) = 1` forces `a = 1 / log(φ)`
  17
  18Together this collapses the family to the canonical gap function
  19
  20  `gap(Z) = log(1 + Z/φ) / log(φ) = log_φ(1 + Z/φ)`.
  21
  22## Scope of Uniqueness
  23
  24The uniqueness proved here is within the affine-log family `a·log(1+x/b)+c`.
  25That this family is the correct bridge from multiplicative J-costs to additive
  26φ-ladder shifts is a structural postulate motivated by the logarithmic nature
  27of the cost-to-rung conversion, not a theorem derived from T0–T8.
  28-/
  29
  30namespace IndisputableMonolith
  31namespace RSBridge
  32namespace GapFunctionForcing
  33
  34open Real Constants
  35
  36noncomputable section
  37
  38/-- Affine-log candidate family on reals. -/
  39def gapAffineLogR (a b c x : ℝ) : ℝ :=
  40  a * Real.log (1 + x / b) + c
  41
  42/-- Integer specialization. -/
  43def gapAffineLog (a b c : ℝ) (Z : ℤ) : ℝ :=
  44  gapAffineLogR a b c (Z : ℝ)
  45
  46/-- `φ = 1 + 1/φ` (golden ratio identity). -/
  47lemma phi_eq_one_add_inv_phi : phi = 1 + (1 : ℝ) / phi := by
  48  have hne : phi ≠ 0 := phi_ne_zero
  49  calc
  50    phi = phi ^ 2 / phi := by field_simp [hne]
  51    _ = (phi + 1) / phi := by simp [phi_sq_eq]
  52    _ = 1 + (1 : ℝ) / phi := by field_simp [hne]
  53
  54lemma one_add_inv_phi_eq_phi : 1 + (1 : ℝ) / phi = phi :=
  55  phi_eq_one_add_inv_phi.symm
  56
  57lemma log_one_add_inv_phi_eq_log_phi : Real.log (1 + phi⁻¹) = Real.log phi := by
  58  have hshift : (1 + phi⁻¹ : ℝ) = phi := by
  59    simpa [one_div] using one_add_inv_phi_eq_phi
  60  simp [hshift]
  61
  62/-! ## Step 1: g(0) = 0 forces c = 0 -/
  63
  64lemma zero_normalization_forces_offset
  65    {a c : ℝ}
  66    (h0 : gapAffineLogR a phi c 0 = 0) :
  67    c = 0 := by
  68  simpa [gapAffineLogR] using h0
  69
  70/-! ## Step 2: g(1) = 1 forces a = 1/log(φ) (given c = 0 and b = φ) -/
  71
  72lemma unit_step_forces_log_scale
  73    {a c : ℝ}
  74    (h0 : gapAffineLogR a phi c 0 = 0)
  75    (h1 : gapAffineLogR a phi c 1 = 1) :
  76    a = 1 / Real.log phi := by
  77  have hc : c = 0 := zero_normalization_forces_offset h0
  78  have hlog_ne : Real.log phi ≠ 0 := ne_of_gt (Real.log_pos one_lt_phi)
  79  have hmul_raw : a * Real.log (1 + phi⁻¹) = 1 := by
  80    simpa [gapAffineLogR, hc] using h1
  81  have hmul : a * Real.log phi = 1 := by
  82    calc
  83      a * Real.log phi = a * Real.log (1 + phi⁻¹) := by
  84        rw [log_one_add_inv_phi_eq_log_phi]
  85      _ = 1 := hmul_raw
  86  exact (eq_div_iff hlog_ne).2 hmul
  87
  88/-! ## Step 3: g(-1) = -2 forces b = φ (the key theorem)
  89
  90This is the paper's Theorem 4.2: setting u = 1/b, the condition
  91`(1 - u)(1 + u)^2 = 1` expands to `u^2 + u - 1 = 0`, giving u = 1/φ. -/
  92
  93theorem minus_one_step_forces_phi_shift
  94    {a b c : ℝ}
  95    (hb : 1 < b)
  96    (h0 : gapAffineLogR a b c 0 = 0)
  97    (h1 : gapAffineLogR a b c 1 = 1)
  98    (hneg1 : gapAffineLogR a b c (-1) = -2) :
  99    b = phi := by
 100  have hb_pos : 0 < b := lt_trans zero_lt_one hb
 101  have hb_ne : b ≠ 0 := ne_of_gt hb_pos
 102  have hplus_pos : 0 < 1 + (1 : ℝ) / b := by
 103    have hinv_pos : 0 < (1 : ℝ) / b := one_div_pos.mpr hb_pos
 104    linarith
 105  have hinv_lt_one : (1 : ℝ) / b < 1 := by
 106    simpa using (one_div_lt_one_div_of_lt (by norm_num : (0 : ℝ) < 1) hb)
 107  have hminus_pos : 0 < 1 - (1 : ℝ) / b := by linarith
 108  have hminus_ne : (1 - (1 : ℝ) / b) ≠ 0 := ne_of_gt hminus_pos
 109  have hc : c = 0 := by simpa [gapAffineLogR] using h0
 110  have h1' : a * Real.log (1 + (1 : ℝ) / b) = 1 := by
 111    simpa [gapAffineLogR, hc] using h1
 112  have hneg1_raw : a * Real.log (1 + (-1 : ℝ) / b) = -2 := by
 113    simpa [gapAffineLogR, hc] using hneg1
 114  have hneg1' : a * Real.log (1 - (1 : ℝ) / b) = -2 := by
 115    simpa [sub_eq_add_neg, div_eq_mul_inv, mul_assoc] using hneg1_raw
 116  have ha_ne : a ≠ 0 := by
 117    intro ha; simp [ha] at h1'
 118  have hscaled : a * (-2 * Real.log (1 + (1 : ℝ) / b)) = -2 := by
 119    calc
 120      a * (-2 * Real.log (1 + (1 : ℝ) / b))
 121          = (-2) * (a * Real.log (1 + (1 : ℝ) / b)) := by ring
 122      _ = (-2) * 1 := by rw [h1']
 123      _ = -2 := by ring
 124  have hlog_rel :
 125      Real.log (1 - (1 : ℝ) / b) = -2 * Real.log (1 + (1 : ℝ) / b) := by
 126    apply (mul_left_cancel₀ ha_ne)
 127    calc
 128      a * Real.log (1 - (1 : ℝ) / b) = -2 := hneg1'
 129      _ = a * (-2 * Real.log (1 + (1 : ℝ) / b)) := hscaled.symm
 130  have hlog_pow :
 131      Real.log ((1 + (1 : ℝ) / b) ^ (2 : ℝ)) =
 132        2 * Real.log (1 + (1 : ℝ) / b) := by
 133    exact Real.log_rpow hplus_pos (2 : ℝ)
 134  have hlog_sum :
 135      Real.log (1 - (1 : ℝ) / b) +
 136        Real.log ((1 + (1 : ℝ) / b) ^ (2 : ℝ)) = 0 := by
 137    linarith [hlog_rel, hlog_pow]
 138  have hpow_ne : ((1 + (1 : ℝ) / b) ^ (2 : ℝ)) ≠ 0 := by
 139    exact ne_of_gt (Real.rpow_pos_of_pos hplus_pos (2 : ℝ))
 140  have hlog_prod :
 141      Real.log ((1 - (1 : ℝ) / b) * ((1 + (1 : ℝ) / b) ^ (2 : ℝ))) = 0 := by
 142    calc
 143      Real.log ((1 - (1 : ℝ) / b) * ((1 + (1 : ℝ) / b) ^ (2 : ℝ)))
 144          = Real.log (1 - (1 : ℝ) / b) + Real.log ((1 + (1 : ℝ) / b) ^ (2 : ℝ)) := by
 145              simpa using (Real.log_mul hminus_ne hpow_ne)
 146      _ = 0 := hlog_sum
 147  have hprod_pos : 0 < (1 - (1 : ℝ) / b) * ((1 + (1 : ℝ) / b) ^ (2 : ℝ)) := by
 148    exact mul_pos hminus_pos (Real.rpow_pos_of_pos hplus_pos (2 : ℝ))
 149  have hprod_eq_one : (1 - (1 : ℝ) / b) * ((1 + (1 : ℝ) / b) ^ (2 : ℝ)) = 1 := by
 150    exact Real.eq_one_of_pos_of_log_eq_zero hprod_pos hlog_prod
 151  have hpoly : b ^ 2 - b - 1 = 0 := by
 152    have htmp : (1 - (1 : ℝ) / b) * (1 + (1 : ℝ) / b) ^ 2 = 1 := by
 153      simpa [Real.rpow_two] using hprod_eq_one
 154    field_simp [hb_ne] at htmp
 155    nlinarith [htmp]
 156  have hphi_poly : phi ^ 2 - phi - 1 = 0 := by linarith [phi_sq_eq]
 157  have hfactor : (b - phi) * (b + phi - 1) = 0 := by
 158    nlinarith [hpoly, hphi_poly]
 159  rcases mul_eq_zero.mp hfactor with hroot | hother
 160  · linarith
 161  · exact False.elim ((ne_of_gt (by linarith [hb, one_lt_phi] : 0 < b + phi - 1)) hother)
 162
 163/-! ## Main Theorems -/
 164
 165/-- Three-point calibration forces all affine-log parameters. -/
 166theorem affine_log_parameters_forced
 167    {a b c : ℝ}
 168    (hb : 1 < b)
 169    (h0 : gapAffineLogR a b c 0 = 0)
 170    (h1 : gapAffineLogR a b c 1 = 1)
 171    (hneg1 : gapAffineLogR a b c (-1) = -2) :
 172    b = phi ∧ a = 1 / Real.log phi ∧ c = 0 := by
 173  have hbphi : b = phi := minus_one_step_forces_phi_shift hb h0 h1 hneg1
 174  have h0phi : gapAffineLogR a phi c 0 = 0 := by simpa [hbphi] using h0
 175  have h1phi : gapAffineLogR a phi c 1 = 1 := by simpa [hbphi] using h1
 176  exact ⟨hbphi, unit_step_forces_log_scale h0phi h1phi,
 177         zero_normalization_forces_offset h0phi⟩
 178
 179/-- Under the normalizations, the affine-log family equals the canonical gap. -/
 180theorem affine_log_collapses_to_gap
 181    {a c : ℝ}
 182    (h0 : gapAffineLogR a phi c 0 = 0)
 183    (h1 : gapAffineLogR a phi c 1 = 1) :
 184    ∀ Z : ℤ, gapAffineLog a phi c Z = RSBridge.gap Z := by
 185  have hc : c = 0 := zero_normalization_forces_offset h0
 186  have ha : a = 1 / Real.log phi := unit_step_forces_log_scale h0 h1
 187  intro Z
 188  unfold gapAffineLog gapAffineLogR RSBridge.gap
 189  calc
 190    a * Real.log (1 + (Z : ℝ) / phi) + c
 191        = (1 / Real.log phi) * Real.log (1 + (Z : ℝ) / phi) := by
 192            simp [ha, hc]
 193    _ = Real.log (1 + (Z : ℝ) / phi) / Real.log phi := by
 194          simp [div_eq_mul_inv, mul_comm]
 195
 196/-- Three-point calibration gives direct collapse to the canonical gap. -/
 197theorem three_point_forces_canonical_gap
 198    {a b c : ℝ}
 199    (hb : 1 < b)
 200    (h0 : gapAffineLogR a b c 0 = 0)
 201    (h1 : gapAffineLogR a b c 1 = 1)
 202    (hneg1 : gapAffineLogR a b c (-1) = -2) :
 203    ∀ Z : ℤ, gapAffineLog a b c Z = RSBridge.gap Z := by
 204  have hbphi : b = phi := minus_one_step_forces_phi_shift hb h0 h1 hneg1
 205  have h0phi : gapAffineLogR a phi c 0 = 0 := by simpa [hbphi] using h0
 206  have h1phi : gapAffineLogR a phi c 1 = 1 := by simpa [hbphi] using h1
 207  intro Z
 208  simpa [hbphi] using affine_log_collapses_to_gap h0phi h1phi Z
 209
 210/-- Certificate structure for the three-point closure. -/
 211structure ThreePointClosure (a b c : ℝ) where
 212  shift_forced : b = phi
 213  scale_forced : a = 1 / Real.log phi
 214  offset_forced : c = 0
 215  collapses_to_gap : ∀ Z : ℤ, gapAffineLog a b c Z = RSBridge.gap Z
 216
 217/-- Build the closure certificate from calibration data. -/
 218theorem three_point_closure
 219    {a b c : ℝ}
 220    (hb : 1 < b)
 221    (h0 : gapAffineLogR a b c 0 = 0)
 222    (h1 : gapAffineLogR a b c 1 = 1)
 223    (hneg1 : gapAffineLogR a b c (-1) = -2) :
 224    ThreePointClosure a b c := by
 225  have hparams := affine_log_parameters_forced hb h0 h1 hneg1
 226  exact ⟨hparams.1, hparams.2.1, hparams.2.2,
 227         three_point_forces_canonical_gap hb h0 h1 hneg1⟩
 228
 229end
 230end GapFunctionForcing
 231end RSBridge
 232end IndisputableMonolith
 233

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