import proofs.QuantumStateBoundary011g /-! # 011h / S-05 — Observable exposure and frozen-declaration receipt This module is the exact formal boundary for a root-to-record prediction. It does not manufacture an empirical result. A receipt is judged against a `ForwardBinding`: the forward model, the root state and parameter it is evaluated at, and the parameter-origin record. The prediction is *computed* from that binding, never supplied as a free number. The receipt carries a `DeclarationRecord` (forward-model name, parameter record, origins, apparatus, calibration, held-out record, tolerance) and a `freezeId`. A receipt is bound only if its declaration names the binding's model and parameter record and its `freezeId` equals the digest of its declaration. `PASS` means: bound, receipt-complete, and the computed prediction lies within the declared tolerance of the observed value. It does not mean the physics is correct. The digest is a parameter of the decision procedure; collision resistance enters only as an explicit injectivity hypothesis where immutability is stated. The integer carrier is intentionally minimal. A physical instantiation supplies its own units, uncertainty propagation, apparatus model, and independently retained measurement. -/ set_option autoImplicit false namespace ObservableExposure011h open RootFieldLift011a QuantumStateBoundary011g inductive RecordOrigin where | rootCertificate | importedTheory | empiricallyCalibrated | apparatusDeclared | heldOutMeasurement deriving DecidableEq, Repr inductive ReceiptVerdict where | pass | fail | void deriving DecidableEq, Repr def intAbs (z : Int) : Int := if z < 0 then -z else z def WithinTolerance (prediction observed tolerance : Int) : Prop := 0 ≤ tolerance ∧ intAbs (prediction - observed) ≤ tolerance /-- The forward model with the root state and parameter it is evaluated at, and the parameter-origin record it depends on. -/ structure ForwardBinding (State Parameter : Type) where modelName : String model : State → Parameter → Int rootState : State parameter : Parameter parameterRecord : String parameterOrigins : List RecordOrigin def ForwardBinding.prediction {S P : Type} (b : ForwardBinding S P) : Int := b.model b.rootState b.parameter /-- The serializable declaration that a freeze identity is computed over. -/ structure DeclarationRecord where forwardModelName : String parameterRecord : String parameterOrigins : List RecordOrigin apparatusRecord : String calibrationRecord : String heldOutRecord : String tolerance : Int deriving DecidableEq structure Receipt where declaration : DeclarationRecord freezeId : Nat observed : Int def recordComplete (d : DeclarationRecord) : Bool := decide (d.apparatusRecord ≠ "") && decide (d.calibrationRecord ≠ "") && decide (d.heldOutRecord ≠ "") && decide (d.parameterOrigins ≠ []) def isBound {S P : Type} (digest : DeclarationRecord → Nat) (b : ForwardBinding S P) (r : Receipt) : Bool := decide (r.declaration.forwardModelName = b.modelName) && decide (r.declaration.parameterRecord = b.parameterRecord) && decide (r.declaration.parameterOrigins = b.parameterOrigins) && decide (r.freezeId = digest r.declaration) def decideReceipt {S P : Type} (digest : DeclarationRecord → Nat) (b : ForwardBinding S P) (r : Receipt) : ReceiptVerdict := if isBound digest b r && recordComplete r.declaration then if decide (0 ≤ r.declaration.tolerance) && decide (intAbs (b.prediction - r.observed) ≤ r.declaration.tolerance) then .pass else .fail else .void theorem decision_is_exhaustive {S P : Type} (digest : DeclarationRecord → Nat) (b : ForwardBinding S P) (r : Receipt) : decideReceipt digest b r = .pass ∨ decideReceipt digest b r = .fail ∨ decideReceipt digest b r = .void := by cases decideReceipt digest b r <;> simp /-- What `PASS` certifies: bound, complete, prediction within tolerance. -/ def PassMeaning {S P : Type} (digest : DeclarationRecord → Nat) (b : ForwardBinding S P) (r : Receipt) : Prop := r.declaration.forwardModelName = b.modelName ∧ r.declaration.parameterRecord = b.parameterRecord ∧ r.declaration.parameterOrigins = b.parameterOrigins ∧ r.freezeId = digest r.declaration ∧ r.declaration.apparatusRecord ≠ "" ∧ r.declaration.calibrationRecord ≠ "" ∧ r.declaration.heldOutRecord ≠ "" ∧ r.declaration.parameterOrigins ≠ [] ∧ WithinTolerance b.prediction r.observed r.declaration.tolerance theorem pass_means_bound_complete_within_tolerance {S P : Type} (digest : DeclarationRecord → Nat) (b : ForwardBinding S P) (r : Receipt) (h : decideReceipt digest b r = .pass) : PassMeaning digest b r := by unfold decideReceipt at h split at h · rename_i hc split at h · rename_i ht simp only [isBound, recordComplete, Bool.and_eq_true, decide_eq_true_eq] at hc ht obtain ⟨⟨⟨⟨h1, h2⟩, h3⟩, h4⟩, ⟨⟨⟨h5, h6⟩, h7⟩, h8⟩⟩ := hc exact ⟨h1, h2, h3, h4, h5, h6, h7, h8, ht.1, ht.2⟩ · contradiction · contradiction theorem void_marks_unbound_or_incomplete {S P : Type} (digest : DeclarationRecord → Nat) (b : ForwardBinding S P) (r : Receipt) (h : decideReceipt digest b r = .void) : isBound digest b r = false ∨ recordComplete r.declaration = false := by unfold decideReceipt at h split at h · rename_i hc split at h <;> contradiction · rename_i hc by_cases hb : isBound digest b r = true · right simpa [hb] using hc · left simpa using hb /-- A `PASS` is attainable (decision-procedure non-vacuity; not an observable). -/ theorem pass_is_attainable : ∃ (digest : DeclarationRecord → Nat) (b : ForwardBinding Unit Unit) (r : Receipt), decideReceipt digest b r = .pass := by refine ⟨fun _ => 0, ⟨"m", fun _ _ => 7, (), (), "p", [.rootCertificate]⟩, ⟨⟨"m", "p", [.rootCertificate], "a", "c", "h", 0⟩, 0, 7⟩, ?_⟩ decide /-- Freeze identity: with an injective digest, equal freeze identities of bound receipts force equal declarations. -/ theorem freeze_identity_determines_declaration (digest : DeclarationRecord → Nat) (hinj : Function.Injective digest) (r r' : Receipt) (h : r.freezeId = digest r.declaration) (h' : r'.freezeId = digest r'.declaration) (heq : r.freezeId = r'.freezeId) : r.declaration = r'.declaration := hinj (h.symm.trans (heq.trans h')) /-- Editing a frozen declaration without re-freezing voids the receipt. -/ theorem edited_declaration_voids_receipt {S P : Type} (digest : DeclarationRecord → Nat) (hinj : Function.Injective digest) (b : ForwardBinding S P) (r : Receipt) (hfrozen : r.freezeId = digest r.declaration) (d' : DeclarationRecord) (hne : d' ≠ r.declaration) : decideReceipt digest b { r with declaration := d' } = .void := by unfold decideReceipt have hnb : isBound digest b { r with declaration := d' } = false := by simp only [isBound, Bool.and_eq_false_iff, decide_eq_false_iff_not] right intro hid exact hne (hinj (hid.symm.trans hfrozen)) simp [hnb] def ObservableExposureStatement : Prop := CommutatorProfileBoundary ∧ ∀ (State Parameter : Type) (digest : DeclarationRecord → Nat) (b : ForwardBinding State Parameter) (r : Receipt), decideReceipt digest b r = .pass → PassMeaning digest b r theorem observable_exposure_exact : ObservableExposureStatement := by refine ⟨commutator_profile_boundary_exact, ?_⟩ intro State Parameter digest b r h exact pass_means_bound_complete_within_tolerance digest b r h inductive ObservableOffice where | forwardModel | parameterOrigins | uncertaintyPropagation | apparatusModel | calibrationRecord | heldOutMeasurement | frozenDecision deriving DecidableEq, Repr def observableOffices : List ObservableOffice := [.forwardModel, .parameterOrigins, .uncertaintyPropagation, .apparatusModel, .calibrationRecord, .heldOutMeasurement, .frozenDecision] theorem observable_offices_complete : ∀ o : ObservableOffice, o ∈ observableOffices := by intro o; cases o <;> decide /-- S-05's own obligation type: one receipt witness per observable office. -/ inductive S05Obligation where | receiptWitness (office : ObservableOffice) deriving DecidableEq, Repr def S05Obligation.office : S05Obligation → ObservableOffice | .receiptWitness o => o def s05Obligations : List S05Obligation := observableOffices.map S05Obligation.receiptWitness theorem s05_obligations_cover_offices : s05Obligations.map S05Obligation.office = observableOffices := by simp [s05Obligations, Function.comp_def, S05Obligation.office] theorem s05_obligations_complete : ∀ ob : S05Obligation, ob ∈ s05Obligations := by intro ob; cases ob with | receiptWitness o => cases o <;> decide structure S05ObservableRecord where boundary : ObservableExposureStatement offices : List ObservableOffice obligations : List S05Obligation offices_exact : offices = observableOffices obligations_exact : obligations = s05Obligations def s05ObservableRecord : S05ObservableRecord where boundary := observable_exposure_exact offices := observableOffices obligations := s05Obligations offices_exact := rfl obligations_exact := rfl theorem s05_record_carries_every_observable_office : s05ObservableRecord.obligations.map S05Obligation.office = observableOffices := by simpa [s05ObservableRecord] using s05_obligations_cover_offices #print axioms decision_is_exhaustive #print axioms pass_means_bound_complete_within_tolerance #print axioms void_marks_unbound_or_incomplete #print axioms pass_is_attainable #print axioms freeze_identity_determines_declaration #print axioms edited_declaration_voids_receipt #print axioms observable_exposure_exact #print axioms s05_obligations_complete #print axioms s05_record_carries_every_observable_office end ObservableExposure011h