Where the BIP30 scan runs, an accepted block's outputs are fresh
ProvedBitcoinUniqueness.scan_freshnessFor a reachable state, an accepted block (not hashing to the genesis hash) and ScanRuns S b: FreshOutputs S.utxo b. From the acceptance theorem: the ledger predicate's BIP30 clause.
import Definitions.Def_BitcoinUniqueness import Definitions.Def_BitcoinSer open BitcoinUniqueness BitcoinSer BitcoinBlockV2
theorem BitcoinUniqueness.scan_freshness (S : ChainState) (b : BitcoinSer.Block) (now : Int) (S' : ChainState)
(undo : BlockUndo) (hR : BitcoinBlockV2.Reachable S) (h : BitcoinBlockV2.validate S b now = .accept S' undo)
(hscan : BitcoinUniqueness.ScanRuns S b) (hg : BitcoinSer.headerHash b.header ≠ BitcoinSer.genesisHash) :
BitcoinUniqueness.FreshOutputs S.utxo b := 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: BitcoinUniqueness.scan_freshness
Statement. For every chain state , block , integer (the clock reading, named now), chain state , and undo list (a list of lists of coins), if
- ,
- ,
- , and
- , where is the fixed 32-byte genesis block hash (beginning ),
then holds.
Formally:
What the conclusion says
for a ledger (association list of outpoint–coin pairs) is
where is the double-SHA-256 of the witness-stripped serialization of and returns the coin of the first pair of whose key equals , or if there is none. The ledger in the conclusion is that of (the state before the block), not of .
What ScanRuns says
is, by definition, with and (double-SHA-256 of the serialized header), which unfolds to
where holds iff or for two fixed 32-byte constants, and holds iff has an element at zero-based position (i.e. ) whose header hash equals a fixed 32-byte constant . The block enters only through .
What the acceptance hypothesis says
asserts that the four stages below all succeed and that and are exactly the state and undo list they produce. Write , (the next height), for the last element of (the fixed genesis header if the list is empty), (truncated subtraction, so when ), and for the first transaction of (the fixed genesis coinbase transaction if is empty). A transaction "is a coinbase" iff it has exactly one input and that input's previous outpoint is .
-
Header stage. passes the proof-of-work test of the imported proof-of-work development (its double-SHA-256 hash, read as a little-endian 256-bit number, against the 32-bit field ); equals the header hash of (otherwise the outcome is "missing previous", not accept); the 32-bit value of equals the required work computed from by the imported difficulty rule; the median time past of at is strictly less than ; (otherwise the outcome is "future time", not accept); and it is not the case that ( and ), nor ( and ), nor ( and ).
-
Context-free block stage. The proof-of-work test again; the Merkle root computed from the txids of equals and the Merkle computation reports no mutation; is non-empty; and ; is a coinbase and no other transaction of is; every transaction has non-empty inputs and outputs, witness-stripped size times 4 at most , every output value in with running totals in that range, pairwise distinct previous outpoints, and (for a coinbase) a first-input scriptSig of length between and inclusive, or (for a non-coinbase) no null previous outpoint; and of the legacy signature-operation counts is at most .
-
Contextual stage. Every transaction of is final at height against a cutoff (the median time past of if , else ); if then is a prefix of the scriptSig of the first input of (the first input being the default input with empty scriptSig if has no inputs) — this byte string is literally the same expression as ; the witness-malleation check passes with the expectation flag set iff ; and the block weight ( stripped size full size) is at most .
-
Connect stage. Let . If equals the fixed genesis block hash (32 bytes beginning ), the stage succeeds immediately with ledger and empty undo list, performing no further check. Otherwise: if (see the ScanRuns unfolding) and it is not the case that for every and every the ledger has no entry keyed , the stage fails; otherwise the transactions are processed in order through the imported per-transaction loop (input lookup and maturity, fee range, sequence locks, sigop budget, full script verification, ledger update), which must succeed, and finally the output value of must be at most the accumulated fees plus the subsidy at height .
On success, where is the ledger produced by stage 4, and is the undo list produced by stage 4. In particular .
What reachability says
is the least predicate such that (i) the initial state (one header, empty ledger) is reachable, and (ii) whenever is reachable and for some block , integer and undo list , then is reachable. So means arises from the initial state by a finite sequence of accepted validations, each with its own arbitrary clock reading.
Edge cases and scope
- The conclusion is vacuous for a block with no transactions or for transactions with no outputs; stage 2 of validation requires non-empty and every transaction to have outputs, so under the hypotheses these do not occur, but the conclusion itself does not say so.
- , and appear only inside the acceptance hypothesis; the conclusion does not mention them.
- The hypothesis excludes exactly the case in which stage 4 of validation takes its genesis shortcut (which performs no ledger check at all).
- Under and the non-genesis hypothesis, stage 4 of validation fails unless the Boolean form of the same quantified condition as the conclusion holds on ; the read-back records this as the structure of the definitions, not as an assessment.
- The conclusion says nothing about duplicate txids within , nor about the ledger after connection, nor about any outpoint that does not create.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.