Reachable states are well formed
ProvedBitcoinBlock.reachable_wellFormedEvery state reachable from the genesis has the genesis header first, pairwise distinct ledger keys, and only spendable coins created at heights between 1 and the tip.
Deprecated. Superseded by BitcoinBlockV2.reachable_wellFormed (revision 2 of the block mission): the p2shSigOpCount of this revision counted every push of scriptSig instead of only the redeem script, over-counting P2SH sigops; the V2 declarations carry the corrected definition.
import Definitions.Def_BitcoinBlock
theorem BitcoinBlock.reachable_wellFormed (S : ChainState) (h : BitcoinBlock.Reachable S) :
BitcoinBlock.WellFormed S := 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: BitcoinBlock.reachable_wellFormed
Binders and hypotheses
- : a chain state .
- Hypothesis : , the least predicate closed under: (genesis) ; (step) for any , block , clock , state and undo list , if and then .
Conclusion
i.e. the conjunction of:
- the head of exists and equals (version , prevBlock 32 zero bytes, merkleRoot the txid of the genesis coinbase, time , bits , nonce );
- : the list of outpoint keys of the ledger has no duplicates;
- for every entry of : , (natural subtraction), and is not unspendable (it does not start with byte and its length is at most ).
The step rule, unfolded
means: the header of passes proof of work, builds on the tip hash of , has the required bits, a time above the tip's median-time-past and at most , and a non-outdated version; and hold; and with . In , if the block's header hash is the genesis hash the ledger is returned unchanged; otherwise results from the transaction loop at height , which spends inputs and adds spendable outputs (unspendable scripts are never stored; an added entry replaces any entry with the same key) at that height, after BIP30 (when checked), input, fee, BIP68, sigop, script and coinbase-bound checks.
Edge cases silently included
The initial state has an empty ledger, so clauses 2 and 3 are vacuous there; the genesis-hashed shortcut adds a header without touching the ledger; clause 3 compares to which is for an empty list (unreachable under but the predicate itself is defined for it); the undo lists and clocks in the derivation are existentially hidden in the hypothesis.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.