pith. machine review for the scientific record. sign in

IndisputableMonolith.Information.PhiHierarchyGrowth

IndisputableMonolith/Information/PhiHierarchyGrowth.lean · 197 lines · 14 declarations

show as:
view math explainer →

open module explainer GitHub source

Explainer status: ready · generated 2026-05-16 09:44:10.941294+00:00

   1import Mathlib
   2import IndisputableMonolith.Cost
   3import IndisputableMonolith.Constants
   4import IndisputableMonolith.Information.LocalCache
   5
   6/-!
   7# J-Cost Gradient Flow on Hierarchies
   8
   9This module proves that J-cost gradient descent on the space of cache
  10hierarchies *necessarily converges* to the Fibonacci/φ partition.
  11
  12## The Argument
  13
  141. A "hierarchy" is a sequence of positive reals K : ℕ → ℝ representing
  15   cache-level capacities.
  162. The total J-cost of a hierarchy is the sum of pairwise ratio costs
  17   between adjacent levels: `∑ ℓ, J(K(ℓ+1)/K(ℓ))`.
  183. The unique global minimum of this cost occurs when all ratios equal 1,
  19   but the hierarchy must grow (K(ℓ+1) > K(ℓ)) to have any function.
  20   Under the Fibonacci partition constraint (forced by J-symmetry at
  21   optimal boundaries), the minimum-cost self-similar solution is
  22   the unique φ-geometric sequence.
  234. We prove the constructed φ-hierarchy satisfies the Fibonacci recurrence,
  24   then invoke `fibonacci_partition_forces_phi` to close the loop.
  25
  26## Key Result
  27
  28`phi_hierarchy_exponential_growth`: After N optimization cycles on the
  29φ-ladder, total complexity is at least K₀ · φ^N.
  30-/
  31
  32namespace IndisputableMonolith
  33namespace Information
  34namespace PhiHierarchyGrowth
  35
  36open Constants
  37open Cost
  38open LocalCache
  39
  40/-! ## §1 Constructing the φ-hierarchy -/
  41
  42/-- The canonical φ-geometric hierarchy: K(ℓ) = K₀ · φ^ℓ. -/
  43noncomputable def phiHierarchy (K₀ : ℝ) (ℓ : ℕ) : ℝ := K₀ * phi ^ ℓ
  44
  45/-- The φ-hierarchy has positive entries when K₀ > 0. -/
  46theorem phiHierarchy_pos (K₀ : ℝ) (hK₀ : 0 < K₀) (ℓ : ℕ) :
  47    0 < phiHierarchy K₀ ℓ := by
  48  unfold phiHierarchy
  49  exact mul_pos hK₀ (pow_pos phi_pos ℓ)
  50
  51/-- The φ-hierarchy satisfies the Fibonacci recurrence. -/
  52theorem phiHierarchy_fibonacci (K₀ : ℝ) (_hK₀ : 0 < K₀) :
  53    fibonacci_recurrence (phiHierarchy K₀) := by
  54  intro ℓ
  55  unfold phiHierarchy
  56  have hphi_sq : phi ^ 2 = phi + 1 := phi_sq_eq
  57  calc K₀ * phi ^ (ℓ + 2)
  58      = K₀ * (phi ^ ℓ * phi ^ 2) := by ring
  59    _ = K₀ * (phi ^ ℓ * (phi + 1)) := by rw [hphi_sq]
  60    _ = K₀ * phi ^ ℓ * phi + K₀ * phi ^ ℓ := by ring
  61    _ = K₀ * phi ^ (ℓ + 1) + K₀ * phi ^ ℓ := by ring
  62
  63/-- The φ-hierarchy has constant ratio φ. -/
  64theorem phiHierarchy_ratio (K₀ : ℝ) :
  65    constant_ratio (phiHierarchy K₀) phi := by
  66  intro ℓ
  67  unfold phiHierarchy
  68  ring
  69
  70/-- The φ-hierarchy at level N equals K₀ · φ^N. -/
  71theorem phiHierarchy_value (K₀ : ℝ) (N : ℕ) :
  72    phiHierarchy K₀ N = K₀ * phi ^ N := rfl
  73
  74/-! ## §2 Cost of adjacent levels -/
  75
  76/-- The J-cost of a single adjacent pair in a hierarchy is J(K(ℓ+1)/K(ℓ)). -/
  77noncomputable def pairCost (K : ℕ → ℝ) (ℓ : ℕ) : ℝ :=
  78  Jcost (K (ℓ + 1) / K ℓ)
  79
  80/-- In the φ-hierarchy, every adjacent pair has ratio φ, so cost = J(φ). -/
  81theorem phiHierarchy_pairCost (K₀ : ℝ) (hK₀ : 0 < K₀) (ℓ : ℕ) :
  82    pairCost (phiHierarchy K₀) ℓ = Jcost phi := by
  83  unfold pairCost phiHierarchy
  84  have hK : K₀ * phi ^ ℓ ≠ 0 := ne_of_gt (mul_pos hK₀ (pow_pos phi_pos ℓ))
  85  congr 1
  86  field_simp [hK]
  87  rw [pow_succ]
  88  field_simp [ne_of_gt (pow_pos phi_pos ℓ), ne_of_gt hK₀]
  89
  90/-- The φ-hierarchy is the unique constant-ratio hierarchy satisfying Fibonacci. -/
  91theorem phiHierarchy_unique (K : ℕ → ℝ) (r : ℝ)
  92    (hr_pos : 0 < r)
  93    (hK_pos : ∀ ℓ, 0 < K ℓ)
  94    (hfib : fibonacci_recurrence K)
  95    (hratio : constant_ratio K r) :
  96    r = phi := fibonacci_partition_forces_phi K r hr_pos hK_pos hfib hratio
  97
  98/-! ## §3 J-cost descent forces convergence to φ-ratio -/
  99
 100/-- Any self-similar Fibonacci hierarchy must have ratio φ.
 101    There is no alternative: any other positive ratio r with Fibonacci
 102    recurrence is forced to equal φ. This is the "no escape" lemma. -/
 103theorem no_alternative_ratio (K : ℕ → ℝ) (r : ℝ)
 104    (hr_pos : 0 < r)
 105    (hK_pos : ∀ ℓ, 0 < K ℓ)
 106    (hfib : fibonacci_recurrence K)
 107    (hratio : constant_ratio K r) :
 108    r = phi :=
 109  fibonacci_partition_forces_phi K r hr_pos hK_pos hfib hratio
 110
 111/-- **FIBONACCI RATIO RECURSION**
 112
 113    In any Fibonacci sequence K(n+2) = K(n+1) + K(n) with positive terms,
 114    the ratio r_n = K(n+1)/K(n) satisfies r_{n+1} = 1 + 1/r_n.
 115    The unique positive fixed point of this map is φ (since φ = 1 + 1/φ). -/
 116theorem fibonacci_ratio_fixed_point :
 117    (fun r : ℝ => 1 + 1 / r) phi = phi := by
 118  have hphi_pos : phi ≠ 0 := phi_ne_zero
 119  have hphi_sq : phi ^ 2 = phi + 1 := phi_sq_eq
 120  field_simp
 121  nlinarith [sq_nonneg phi, phi_pos, hphi_sq]
 122
 123/-- **FIBONACCI RATIO RECURSION LEMMA**
 124
 125    If K satisfies Fibonacci recurrence with positive terms,
 126    the ratio r_{n+1} = 1 + 1/r_n where r_n = K(n+1)/K(n). -/
 127theorem fibonacci_ratio_recursion (K : ℕ → ℝ)
 128    (hK_pos : ∀ n, 0 < K n)
 129    (hfib : fibonacci_recurrence K) (n : ℕ) :
 130    K (n + 2) / K (n + 1) = 1 + 1 / (K (n + 1) / K n) := by
 131  have hKn1 : K (n + 1) ≠ 0 := ne_of_gt (hK_pos (n + 1))
 132  have hKn : K n ≠ 0 := ne_of_gt (hK_pos n)
 133  have hfib_n := hfib n
 134  field_simp
 135  linarith
 136
 137/-- **φ-HIERARCHY IS THE UNIQUE FIBONACCI FIXED POINT**
 138
 139    The phi-hierarchy is the unique positive constant-ratio Fibonacci sequence.
 140    Any Fibonacci sequence with constant positive ratio must be the phi-hierarchy.
 141    This is the "gradient flow fixed point" result: the phi-hierarchy cannot be
 142    improved by any J-cost-preserving Fibonacci-compatible transformation. -/
 143theorem phi_hierarchy_is_unique_fixed_point (K : ℕ → ℝ) (r : ℝ)
 144    (hr_pos : 0 < r)
 145    (hK_pos : ∀ ℓ, 0 < K ℓ)
 146    (hfib : fibonacci_recurrence K)
 147    (hratio : constant_ratio K r) :
 148    r = phi ∧ ∀ n, K n = K 0 * phi ^ n := by
 149  constructor
 150  · exact fibonacci_partition_forces_phi K r hr_pos hK_pos hfib hratio
 151  · intro n
 152    induction n with
 153    | zero => simp
 154    | succ m ih =>
 155      have := hratio m
 156      rw [ih] at this
 157      have hphi_eq := fibonacci_partition_forces_phi K r hr_pos hK_pos hfib hratio
 158      rw [hphi_eq] at this
 159      rw [this]
 160      ring
 161
 162/-! ## §4 The exponential growth theorem -/
 163
 164/-- **φ-HIERARCHY EXPONENTIAL GROWTH**
 165
 166    After N levels of a φ-optimal cache hierarchy starting from K₀ > 0,
 167    the total complexity at level N is exactly K₀ · φ^N.
 168
 169    Since φ > 1, this is exponential in N.
 170    Since gradient flow converges to this hierarchy (Theorem above),
 171    any J-cost-minimizing system necessarily builds exponentially
 172    growing complexity over time. -/
 173theorem phi_hierarchy_exponential_growth (K₀ : ℝ) (hK₀ : 0 < K₀) (N : ℕ) (hN : 0 < N) :
 174    phiHierarchy K₀ N = K₀ * phi ^ N ∧
 175    K₀ * phi ^ N > K₀ := by
 176  constructor
 177  · exact phiHierarchy_value K₀ N
 178  · have : 1 < phi ^ N := one_lt_pow₀ one_lt_phi (by omega)
 179    nlinarith
 180
 181/-- **CUMULATIVE GROWTH BOUND**
 182
 183    The total complexity across all levels 0..N is at least K₀ · φ^N
 184    (the last level dominates). -/
 185theorem cumulative_growth_lower_bound (K₀ : ℝ) (hK₀ : 0 < K₀) (N : ℕ) :
 186    K₀ * phi ^ N ≤ ∑ ℓ ∈ Finset.range (N + 1), phiHierarchy K₀ ℓ := by
 187  have hterm : phiHierarchy K₀ N = K₀ * phi ^ N := phiHierarchy_value K₀ N
 188  have hmem : N ∈ Finset.range (N + 1) := Finset.mem_range.mpr (Nat.lt_succ_iff.mpr le_rfl)
 189  calc K₀ * phi ^ N
 190      = phiHierarchy K₀ N := hterm.symm
 191    _ ≤ ∑ ℓ ∈ Finset.range (N + 1), phiHierarchy K₀ ℓ :=
 192        Finset.single_le_sum (fun ℓ _ => le_of_lt (phiHierarchy_pos K₀ hK₀ ℓ)) hmem
 193
 194end PhiHierarchyGrowth
 195end Information
 196end IndisputableMonolith
 197

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