theorem
proved
empty_balanced
show as:
view math explainer →
open explainer
Read the cached plain-language explainer.
open lean source
IndisputableMonolith.Algebra.LedgerAlgebra on GitHub at line 97.
browse module
All declarations in this module, on Recognition.
explainer page
depends on
formal source
94 computeBalance page.events = 0
95
96/-- The empty page is balanced. -/
97theorem empty_balanced : IsBalanced ⟨[], 0⟩ := by
98 simp [IsBalanced, computeBalance]
99
100/-- **PROVED: Adding a paired event preserves balance.** -/
101theorem paired_preserves_balance (page : LedgerPage)
102 (h : IsBalanced page) (e : LedgerEvent) :
103 IsBalanced ⟨page.events ++ [e, e.conj], 0⟩ := by
104 rcases page with ⟨events, bal⟩
105 simp [IsBalanced, computeBalance, List.foldl_append, LedgerEvent.conj] at h ⊢
106 omega
107
108/-! ## §3. The Eight-Window Constraint -/
109
110/-- A **window** is a contiguous block of 8 events. -/
111structure Window8 where
112 /-- The 8 events in this window -/
113 events : Fin 8 → LedgerEvent
114
115/-- The sum over a window. -/
116def Window8.sum (w : Window8) : ℤ :=
117 (Finset.univ.sum fun i => (w.events i).flow)
118
119/-- A window is **neutral** if its sum is zero. -/
120def Window8.isNeutral (w : Window8) : Prop := w.sum = 0
121
122/-- **Construction: A neutral window from 4 paired events.** -/
123def neutralWindow (e₁ e₂ e₃ e₄ : LedgerEvent) : Window8 where
124 events := fun i =>
125 match i with
126 | ⟨0, _⟩ => e₁
127 | ⟨1, _⟩ => e₁.conj