theorem
proved
parity_oneBitDiff_of_post
show as:
view math explainer →
open explainer
Generate a durable explainer page for this declaration.
open lean source
IndisputableMonolith.LedgerPostingAdjacency on GitHub at line 133.
browse module
All declarations in this module, on Recognition.
explainer page
depends on
-
step -
LedgerState -
LedgerState -
LedgerState -
coordAtomicStep_oneBitDiff -
LedgerState -
parity -
phiVec -
phiVec_coordAtomicStep_of_post -
post -
Side -
and -
OneBitDiff -
LedgerState -
L -
L
used by
formal source
130
131/-! ## Main theorem: posting ⇒ parity adjacency -/
132
133theorem parity_oneBitDiff_of_post {d : Nat} (L : LedgerState d) (k : Fin d) (side : Side) :
134 OneBitDiff (parity d L) (parity d (post L k side)) := by
135 -- reduce to the coord-atomic step lemma and reuse `coordAtomicStep_oneBitDiff`
136 have hstep := phiVec_coordAtomicStep_of_post (d := d) L k side
137 simpa [parity] using (coordAtomicStep_oneBitDiff (d := d) (x := phiVec (d := d) L)
138 (y := phiVec (d := d) (post L k side)) hstep)
139
140/-! ## Posting-step relation (ledger constraint ⇒ adjacency) -/
141
142/-- One atomic posting step between ledger states. -/
143def PostingStep {d : Nat} (L L' : LedgerState d) : Prop :=
144 ∃ k : Fin d, ∃ side : Side, L' = post L k side
145
146theorem postingStep_oneBitDiff {d : Nat} {L L' : LedgerState d} (h : PostingStep (d := d) L L') :
147 OneBitDiff (parity d L) (parity d L') := by
148 rcases h with ⟨k, side, rfl⟩
149 simpa using parity_oneBitDiff_of_post (d := d) L k side
150
151/-! ## Optional deepening: a cost/legality predicate that implies `PostingStep` -/
152
153/-- L1 cost of a ledger transition, measured as total absolute change in debit+credit counts. -/
154noncomputable def ledgerL1Cost {d : Nat} (L L' : LedgerState d) : Nat :=
155 (∑ i : Fin d, Int.natAbs (L'.debit i - L.debit i)) +
156 (∑ i : Fin d, Int.natAbs (L'.credit i - L.credit i))
157
158/-- Monotone-posting constraint: debit/credit counts never decrease. -/
159def MonotoneLedger {d : Nat} (L L' : LedgerState d) : Prop :=
160 (∀ i : Fin d, L.debit i ≤ L'.debit i) ∧ (∀ i : Fin d, L.credit i ≤ L'.credit i)
161
162/-- A small “legality” predicate: monotone ledger counts + unit L1 step. -/
163def LegalAtomicTick {d : Nat} (L L' : LedgerState d) : Prop :=