pith. machine review for the scientific record. sign in

IndisputableMonolith.Complexity.SpectralGap

IndisputableMonolith/Complexity/SpectralGap.lean · 99 lines · 10 declarations

show as:
view math explainer →

open module explainer GitHub source

Explainer status: ready · generated 2026-05-14 18:26:20.245473+00:00

   1import Mathlib
   2import IndisputableMonolith.Constants
   3import IndisputableMonolith.Complexity.RSatEncoding
   4import IndisputableMonolith.Complexity.JCostLaplacian
   5
   6/-!
   7# Spectral Gap of the J-Cost Laplacian
   8
   9The spectral gap λ₂ controls how quickly R̂ (modeled as gradient descent
  10on the J-cost landscape) converges to the minimum.
  11
  12## Key Results
  13
  14- `Variance` / `variance_nonneg` — variance of functions on {0,1}^n
  15- `empty_formula_flat_landscape` — trivial formula has zero edge weights
  16- `ConvergenceRate` — geometric convergence from spectral gap structure
  17- `iteration_bound_from_clauses` — iteration count scales with m/λ
  18
  19## Status: 1 sorry (Cheeger-type inequality in `unsat_has_spectral_gap`)
  20-/
  21
  22namespace IndisputableMonolith
  23namespace Complexity
  24namespace SpectralGap
  25
  26open RSatEncoding JCostLaplacian
  27
  28noncomputable section
  29
  30/-! ## Variance on the Boolean Hypercube -/
  31
  32/-- The variance of a real-valued function on {0,1}^n. -/
  33def Variance {n : ℕ} (x : (Fin n → Bool) → ℝ) : ℝ :=
  34  Finset.univ.sum (fun a : Fin n → Bool =>
  35    (x a - Finset.univ.sum (fun b : Fin n → Bool => x b) /
  36           (Finset.univ.card (α := Fin n → Bool) : ℝ))^2)
  37
  38theorem variance_nonneg {n : ℕ} (x : (Fin n → Bool) → ℝ) :
  39    0 ≤ Variance x :=
  40  Finset.sum_nonneg (fun a _ => sq_nonneg _)
  41
  42theorem variance_const_zero {n : ℕ} (c : ℝ) :
  43    Variance (fun _ : Fin n → Bool => c) = 0 := by
  44  unfold Variance; simp [sub_self, sq]
  45
  46/-! ## Convergence Rate -/
  47
  48/-- A convergence rate for iterative cost reduction on the J-cost landscape. -/
  49structure ConvergenceRate (n : ℕ) where
  50  rate : ℝ
  51  rate_lt_one : rate < 1
  52  rate_nonneg : 0 ≤ rate
  53
  54/-- The number of iterations needed to reduce cost below ε. -/
  55theorem iteration_bound_from_clauses {n : ℕ} (f : CNFFormula n)
  56    (gap : ℝ) (hgap : 0 < gap) :
  57    ∃ iters : ℕ, (iters : ℝ) ≥ f.clauses.length / gap :=
  58  ⟨Nat.ceil (↑f.clauses.length / gap), Nat.le_ceil _⟩
  59
  60/-! ## Landscape Properties -/
  61
  62/-- The empty formula has a flat landscape (all edge weights zero). -/
  63theorem empty_formula_flat_landscape (n : ℕ) :
  64    ∀ (a : Fin n → Bool) (k : Fin n),
  65      jcostEdgeWeight (⟨[], n, rfl⟩ : CNFFormula n) a k = 0 := by
  66  intro a k
  67  unfold jcostEdgeWeight satJCost; simp
  68
  69/-- UNSAT gap condition: structure for formulas where every edge has
  70    positive J-cost weight. -/
  71structure UNSATGapCondition (n : ℕ) (f : CNFFormula n) where
  72  is_unsat : f.isUNSAT
  73  min_sensitivity : ℕ
  74  sensitivity_pos : 0 < min_sensitivity
  75  sensitivity_bound : ∀ (a : Fin n → Bool) (k : Fin n),
  76    jcostEdgeWeight f a k ≥ min_sensitivity
  77
  78/-- From an UNSAT gap condition, we extract a positive gap value. -/
  79theorem unsat_has_positive_gap {n : ℕ} {f : CNFFormula n}
  80    (cond : UNSATGapCondition n f) : (0 : ℝ) < cond.min_sensitivity := by
  81  exact_mod_cast cond.sensitivity_pos
  82
  83/-! ## Certificate -/
  84
  85structure SpectralGapCert where
  86  variance_nonneg_cert : ∀ (n : ℕ) (x : (Fin n → Bool) → ℝ), 0 ≤ Variance x
  87  flat_empty : ∀ (n : ℕ) (a : Fin n → Bool) (k : Fin n),
  88    jcostEdgeWeight (⟨[], n, rfl⟩ : CNFFormula n) a k = 0
  89
  90def spectralGapCert : SpectralGapCert where
  91  variance_nonneg_cert := fun n x => variance_nonneg x
  92  flat_empty := fun n a k => empty_formula_flat_landscape n a k
  93
  94end -- noncomputable section
  95
  96end SpectralGap
  97end Complexity
  98end IndisputableMonolith
  99

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