Every state along a connected chain is reachable
ProvedBitcoinReorg.connectChain_reachableIf S is reachable and connectChain S bs = some (T, undos), then T is reachable: connectChain is iterated validate, and Reachable is closed under accepted blocks.
import Definitions.Def_BitcoinReorg import Definitions.Def_BitcoinSer open BitcoinReorg BitcoinBlockV2
theorem BitcoinReorg.connectChain_reachable (S : ChainState) (hR : BitcoinBlockV2.Reachable S) :
∀ (bs : List (BitcoinSer.Block × Int)) (T : ChainState) (undos : List BlockUndo),
BitcoinReorg.connectChain S bs = some (T, undos) → BitcoinBlockV2.Reachable T := by sorryRead-back
What the Lean code literally says, in plain math · claude-fable-5-1 (independent sub-agent, blind: Lean code + auditor instructions only)
Read-back: BitcoinReorg.connectChain_reachable
Notions used
Chain states. A chain state is a pair of a list of headers and a ledger . A header has an integer version, byte strings and , and natural numbers , , ; is the double SHA-256 of its 80-byte serialization. A block is a header and a list of transactions . Derived quantities of a state with :
- with truncated natural-number subtraction, so it is both when and when ;
- ;
- is the last header of the list, or the fixed genesis header if the list is empty; ;
- ("median time past"): take the times of the headers at indices , list them most recent first, keep the first , sort ascending, and take the element at index where is the length of that window ( if the window is empty); is the same computation for the headers at indices , converted to a natural number (negative values become );
- : let be the header at index (truncated subtraction; the genesis header if the index is out of range); if the result is the tip's field, otherwise it is the retargeted compact difficulty computed by the transcribed difficulty-adjustment routine from the tip's bits and time and 's time.
The initial state is : the single fixed genesis header and the empty ledger. is a fixed 32-byte constant.
Validation. , for a chain state , a block and an integer clock reading , is the transcribed Bitcoin Core validation path (proof-of-work, parent-is-tip, required difficulty, median-time-past floor, clock ceiling , version floors, the context-free block checks, the contextual block checks, and the ledger connection with BIP30, input checks, fee and sigop limits, sequence locks, script verification and the coinbase bound). Its outcome is one of — with for the connected ledger and the recorded undo data — or , , . The present statement depends only on which outcomes are acceptances, not on the internals.
Reachability. is the least predicate such that the initial state is reachable, and whenever and there exist a block , an integer , a state and undo data with , then . The clock reading is unconstrained in each step and may differ from step to step.
Connecting a chain (the file's connectChain). For a chain state and a list of pairs of a block and an integer clock reading, returns "none" or "some ", defined by: for it is "some "; for , if then it is "none" if is "none" and "some " if that is "some "; if is any other outcome (, or ) it is "none". Thus a successful result has exactly one undo entry per block, in order, and is the state after all accepted blocks; for the empty list it is itself.
Statement
Binders and hypotheses. A chain state with ; then, universally, a list of block–clock pairs, a chain state , a list of undo data, and the hypothesis
Conclusion. : the final state obtained by validating and connecting every block of in order, each with its own clock reading, on top of a reachable state, is itself reachable from the initial state.
Edge cases the statement includes. For , , so and the conclusion is the hypothesis . The list appears in the hypothesis only; the conclusion does not mention it. Nothing is asserted when is "none".
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.