Pith. sign in

IndisputableMonolith.Verification.Exclusivity.Framework

IndisputableMonolith/Verification/Exclusivity/Framework.lean · 309 lines · 19 declarations

show as:
view math explainer →

open module explainer GitHub source

Explainer status: pending

   1import Mathlib
   2import IndisputableMonolith.RecogSpec.Core
   3import IndisputableMonolith.Constants
   4import IndisputableMonolith.RecogSpec.Spec
   5
   6namespace IndisputableMonolith
   7namespace Verification
   8namespace Exclusivity
   9namespace Framework
  10
  11/-!
  12# Physics Framework Definitions (Shared)
  13
  14This module contains shared definitions used by both NoAlternatives and the necessity proofs.
  15This breaks circular dependencies by providing only the core framework definitions.
  16
  17-/
  18
  19/-! ### Algorithmic Specification (Forward Declaration) -/
  20
  21/-- An algorithmic specification is a finite string that generates states.
  22    (Forward declaration from DiscreteNecessity to avoid circular imports) -/
  23structure AlgorithmicSpec where
  24  description : List Bool  -- Finite binary string
  25  generates : ∀ n : ℕ, Option (List Bool)  -- Enumeration of states
  26
  27/-- A framework has algorithmic spec if it can be enumerated by an algorithm. -/
  28def HasAlgorithmicSpec (StateSpace : Type) : Prop :=
  29  ∃ (spec : AlgorithmicSpec),
  30    ∃ (decode : List Bool → Option StateSpace),
  31      ∀ s : StateSpace, ∃ n : ℕ, ∃ code : List Bool,
  32        spec.generates n = some code ∧ decode code = some s
  33
  34/-! ### Abstract Physics Framework Definition -/
  35
  36/-- Abstract interface for any physics framework.
  37    This captures the minimal structure needed to "do physics":
  38    - A state space
  39    - Evolution rules
  40    - Observable extraction
  41    - Predictive capability
  42-/
  43structure PhysicsFramework where
  44  /-- The carrier type for physical states -/
  45  StateSpace : Type
  46  /-- Evolution operator (dynamics) -/
  47  evolve : StateSpace → StateSpace
  48  /-- Observable quantities that can be measured -/
  49  Observable : Type
  50  /-- Function extracting observables from states -/
  51  measure : StateSpace → Observable
  52  /-- Initial conditions exist -/
  53  hasInitialState : Nonempty StateSpace
  54
  55namespace PhysicsFramework
  56
  57/-- Dimensionless elements (knobs) carried by a framework.  By convention we
  58encode them as real numbers together with state witnesses so downstream
  59arguments can recover finitary descriptions tied to concrete states. -/
  60structure Element (F : PhysicsFramework) where
  61  /-- Identifier used for finitary encodings (e.g. algorithmic descriptions). -/
  62  id : ℕ
  63  /-- The state that this element is attached to. -/
  64  state : F.StateSpace
  65  /-- The numerical value associated with the element. -/
  66  value : ℝ
  67
  68/-- A measurement procedure provides, for each finite step, a concrete element
  69observation.  The `id` field enables canonical enumeration. -/
  70structure MeasurementProcedure (F : PhysicsFramework) where
  71  id : ℕ
  72  sample : ℕ → Element F
  73
  74/-- Enumeration-based predicate expressing that a procedure yields a knob. -/
  75def MeasurementProcedure.yields {F : PhysicsFramework}
  76    (proc : MeasurementProcedure F) (elem : Element F) : Prop :=
  77  ∃ n : ℕ, proc.sample n = elem
  78
  79/-- Structural derivations accumulate internal deductions.  As with measurement
  80procedures, we retain a numeric identifier and a countable trace of element
  81outputs. -/
  82structure StructuralDerivation (F : PhysicsFramework) where
  83  id : ℕ
  84  step : ℕ → Element F
  85  produces_element : Element F
  86  input_elements : List (Element F)
  87  uses_only_internal_structure : Prop
  88
  89/-- Output predicate for structural derivations. -/
  90def StructuralDerivation.produces {F : PhysicsFramework}
  91    (d : StructuralDerivation F) (elem : Element F) : Prop :=
  92  elem = d.produces_element ∨ ∃ n : ℕ, d.step n = elem
  93
  94end PhysicsFramework
  95
  96/-! ### Mild dynamics property -/
  97
  98/-- A framework is non‑static if at least one state changes under `evolve`. -/
  99class NonStatic (F : PhysicsFramework) : Prop where
 100  exists_change : ∃ s : F.StateSpace, F.evolve s ≠ s
 101
 102/-! ### Parameter Counting -/
 103
 104/-- A framework has zero parameters if it can be specified algorithmically
 105    without any adjustable real numbers. -/
 106def HasZeroParameters (F : PhysicsFramework) : Prop :=
 107  HasAlgorithmicSpec F.StateSpace
 108
 109/-- Parameter count: 0 if framework is algorithmic, otherwise undefined.
 110
 111    Note: This is a simplified model. Full formalization would count
 112    adjustable real parameters in the framework definition.
 113-/
 114def ParameterCount (F : PhysicsFramework) : Prop :=
 115  HasZeroParameters F  -- Simplified: True if 0 parameters, False otherwise
 116
 117/-! ### Observable Derivation -/
 118
 119/-- **DEPRECATED**: This trivial version is always satisfiable.
 120
 121    ⚠️ DO NOT USE IN NEW CODE ⚠️
 122
 123    Use `Exclusivity.DerivesObservablesStrong` from `Observables.lean` instead,
 124    which requires predictions to fall within empirical bounds.
 125
 126    This version is kept ONLY for backward compatibility with existing certificates.
 127    The `∃ (_ : ℝ), True` pattern makes ANY framework satisfy this, defeating the
 128    purpose of falsifiability testing.
 129
 130    Migration path:
 131    1. Import `IndisputableMonolith.Verification.Exclusivity.Observables`
 132    2. Replace `DerivesObservables F` with `DerivesObservablesStrong F.StateSpace`
 133    3. Provide a `PredictionFunction` that produces values within empirical bounds -/
 134private noncomputable def alpha_inv_lock : ℝ := 137.035999
 135
 136structure DerivesObservables (F : PhysicsFramework) : Prop where
 137  /-- Can predict electromagnetic fine structure constant. DEPRECATED: use
 138      DerivesObservablesStrong from Observables.lean for non-trivial derivation. -/
 139  derives_alpha : 137.035 ≤ alpha_inv_lock ∧ alpha_inv_lock ≤ 137.037
 140  /-- Can predict mass ratios. DEPRECATED: use DerivesObservablesStrong. -/
 141  derives_masses : ∀ φ : ℝ, (IndisputableMonolith.RecogSpec.massRatiosDefault φ).mu_over_e = φ
 142  /-- Can predict fundamental constants (c, ℏ, G relationships).
 143      Replaces the vacuous `∃ (c ℏ G : ℝ), (c > 0 ∧ ℏ > 0 ∧ G > 0)` with a meaningful
 144      link to the RS-native Constants (SI/CODATA calibration is external). -/
 145  derives_constants :
 146    IndisputableMonolith.Constants.hbar = IndisputableMonolith.Constants.cLagLock * IndisputableMonolith.Constants.tau0 ∧
 147    IndisputableMonolith.Constants.c = 1
 148  /-- Predictions are finite (computable). Deprecated: always true since we
 149      require DerivesObservablesStrong with explicit prediction functions. -/
 150  finite_predictions : ∀ φ, 0 < IndisputableMonolith.RecogSpec.alphaDefault φ
 151  /-- Observable extraction is computable. Deprecated: always true since measure
 152      is a function in PhysicsFramework. -/
 153  measure_computable : ∀ s, ∃ obs, F.measure s = obs
 154
 155/-!
 156### Note on Observable Derivation
 157
 158**For non-trivial observable derivation**, use:
 159- `IndisputableMonolith.Verification.Exclusivity.DerivesObservablesStrong`
 160- From `Observables.lean`
 161
 162This requires predictions within empirical bounds:
 163- α⁻¹ ∈ [137.0359, 137.0361]
 164- m_e/m_μ ∈ [4.836e-3, 4.837e-3]
 165- m_p/m_e ∈ [1836.15, 1836.16]
 166
 167**For non-circular exclusivity proofs**, use:
 168- `IndisputableMonolith.Verification.Exclusivity.IsomorphismDerivation.ExclusivityConstraints`
 169- Which uses `DerivesObservablesStrong` instead of the trivial `DerivesObservables`
 170-/
 171
 172/-- Structural isomorphism between two physics frameworks. -/
 173structure FrameworkIso (F G : PhysicsFramework) where
 174  stateEquiv : F.StateSpace ≃ G.StateSpace
 175  observableEquiv : F.Observable ≃ G.Observable
 176  evolve_comm : ∀ s : F.StateSpace,
 177    stateEquiv (F.evolve s) = G.evolve (stateEquiv s)
 178  measure_comm : ∀ s : F.StateSpace,
 179    observableEquiv (F.measure s) = G.measure (stateEquiv s)
 180
 181/-- Two frameworks are equivalent when there exists a structural isomorphism. -/
 182def FrameworkEquiv (F G : PhysicsFramework) : Prop := Nonempty (FrameworkIso F G)
 183
 184namespace FrameworkEquiv
 185
 186/-- Obtain the underlying isomorphism witness from an equivalence proof. -/
 187noncomputable def iso {F G : PhysicsFramework} (h : FrameworkEquiv F G) : FrameworkIso F G :=
 188  Classical.choice h
 189
 190/-- Reflexivity: every framework is equivalent to itself. -/
 191theorem refl (F : PhysicsFramework) : FrameworkEquiv F F := by
 192  refine ⟨{
 193    stateEquiv := Equiv.refl _
 194  , observableEquiv := Equiv.refl _
 195  , evolve_comm := ?_
 196  , measure_comm := ?_ }⟩
 197  · intro s; simp
 198  · intro s; simp
 199
 200/-- Symmetry: framework equivalence is symmetric. -/
 201theorem symm {F G : PhysicsFramework} (h : FrameworkEquiv F G) : FrameworkEquiv G F := by
 202  classical
 203  obtain ⟨iso⟩ := h
 204  refine ⟨{
 205    stateEquiv := iso.stateEquiv.symm
 206  , observableEquiv := iso.observableEquiv.symm
 207  , evolve_comm := ?_
 208  , measure_comm := ?_ }⟩
 209  · intro s
 210    have h' := iso.evolve_comm (iso.stateEquiv.symm s)
 211    -- send both sides through the inverse equivalence
 212    have := congrArg iso.stateEquiv.symm h'
 213    simpa using this.symm
 214  · intro s
 215    have h' := iso.measure_comm (iso.stateEquiv.symm s)
 216    have := congrArg iso.observableEquiv.symm h'
 217    simpa using this.symm
 218
 219/-- Transitivity: framework equivalence composes. -/
 220theorem trans {F G H : PhysicsFramework}
 221    (hFG : FrameworkEquiv F G) (hGH : FrameworkEquiv G H) :
 222    FrameworkEquiv F H := by
 223  classical
 224  obtain ⟨isoFG⟩ := hFG
 225  obtain ⟨isoGH⟩ := hGH
 226  refine ⟨{
 227    stateEquiv := isoFG.stateEquiv.trans isoGH.stateEquiv
 228  , observableEquiv := isoFG.observableEquiv.trans isoGH.observableEquiv
 229  , evolve_comm := ?_
 230  , measure_comm := ?_ }⟩
 231  · intro s
 232    simp [Equiv.trans_apply, isoFG.evolve_comm, isoGH.evolve_comm]
 233  · intro s
 234    simp [Equiv.trans_apply, isoFG.measure_comm, isoGH.measure_comm]
 235
 236end FrameworkEquiv
 237
 238/-- Unary encoding of a natural number as a Boolean list. -/
 239noncomputable def unaryEncode (n : ℕ) : List Bool := List.replicate n true
 240
 241@[simp] lemma length_unaryEncode (n : ℕ) : (unaryEncode n).length = n := by
 242  simp [unaryEncode]
 243
 244/-- Transport an algorithmic specification along an equivalence with `ℕ`. -/
 245theorem HasAlgorithmicSpec.ofEquivNat {α : Type}
 246    (e : ℕ ≃ α) : HasAlgorithmicSpec α := by
 247  classical
 248  refine ⟨
 249    { description := []
 250    , generates := fun n => some (unaryEncode n) }
 251    , fun code => some (e (code.length)), ?_⟩
 252  intro s
 253  refine ⟨e.symm s, unaryEncode (e.symm s), ?_, ?_⟩
 254  · simp [unaryEncode]
 255  · simp [unaryEncode]
 256
 257/-- Build an algorithmic specification from a surjection `ι : ℕ → α`. -/
 258theorem HasAlgorithmicSpec.ofNatSurjection {α : Type}
 259    (ι : ℕ → α) (hSurj : Function.Surjective ι) : HasAlgorithmicSpec α := by
 260  classical
 261  refine ⟨
 262    { description := []
 263    , generates := fun n => some (unaryEncode n) }
 264    , (fun code => some (ι code.length)), ?_⟩
 265  intro s
 266  obtain ⟨n, hn⟩ := hSurj s
 267  refine ⟨n, unaryEncode n, by simp [unaryEncode], ?_⟩
 268  simpa [unaryEncode, hn]
 269
 270/-- Transport an algorithmic specification across an equivalence. -/
 271theorem HasAlgorithmicSpec.ofEquiv {α β : Type}
 272    (h : HasAlgorithmicSpec α) (e : α ≃ β) : HasAlgorithmicSpec β := by
 273  classical
 274  obtain ⟨spec, decode, hEnum⟩ := h
 275  refine ⟨spec, (fun code => (decode code).map e), ?_⟩
 276  intro b
 277  obtain ⟨n, code, hGen, hDec⟩ := hEnum (e.symm b)
 278  refine ⟨n, code, hGen, ?_⟩
 279  simpa [Option.map, hDec] using congrArg (Option.map e) hDec
 280
 281/-- Transport an algorithmic specification along any surjection `g : α → β`. -/
 282theorem HasAlgorithmicSpec.of_surjective {α β : Type}
 283    (h : HasAlgorithmicSpec α) (g : α → β) (hg : Function.Surjective g) :
 284    HasAlgorithmicSpec β := by
 285  classical
 286  obtain ⟨spec, decode, hEnum⟩ := h
 287  refine ⟨spec, (fun code => (decode code).map g), ?_⟩
 288  intro b
 289  obtain ⟨a, ha⟩ := hg b
 290  obtain ⟨n, code, hGen, hDec⟩ := hEnum a
 291  refine ⟨n, code, hGen, ?_⟩
 292  simpa [Option.map, ha, hDec]
 293
 294/-- Convert a ledger equivalence into a zero-parameter witness for a framework. -/
 295theorem HasZeroParameters.ofLedgerEquiv
 296    {F : PhysicsFramework} {L : RecogSpec.Ledger}
 297    (e : F.StateSpace ≃ L.Carrier)
 298    (hSpec : HasAlgorithmicSpec L.Carrier) :
 299    HasZeroParameters F := by
 300  classical
 301  have hFSpec : HasAlgorithmicSpec F.StateSpace :=
 302    HasAlgorithmicSpec.ofEquiv hSpec e.symm
 303  simpa [HasZeroParameters] using hFSpec
 304
 305end Framework
 306end Exclusivity
 307end Verification
 308end IndisputableMonolith
 309

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