An accepted post-BIP34 block's coinbase starts with its height push
ProvedBitcoinUniqueness.coinbase_height_prefixFor a reachable state at next height and an accepted block: heightScript S.nextHeight is a prefix of coinbaseScriptSig b. From the acceptance theorem's contextual clause (ContextualCheckBlock's bad-cb-height).
import Definitions.Def_BitcoinUniqueness import Definitions.Def_BitcoinSer import Definitions.Def_BitcoinHeader open BitcoinUniqueness BitcoinSer BitcoinBlockV2
theorem BitcoinUniqueness.coinbase_height_prefix (S : ChainState) (b : BitcoinSer.Block) (now : Int) (S' : ChainState)
(undo : BlockUndo) (hR : BitcoinBlockV2.Reachable S) (h : BitcoinBlockV2.validate S b now = .accept S' undo)
(h34 : BitcoinHeader.BIP34Height ≤ S.nextHeight) :
(BitcoinBlockV2.heightScript S.nextHeight).isPrefixOf (BitcoinUniqueness.coinbaseScriptSig b) = true := 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.coinbase_height_prefix
Statement. For every chain state , block , integer (clock reading), chain state , and undo list , if
- ,
- , and
- (the constant is at most the next height of ),
then the byte string is a prefix (initial segment, possibly the whole string) of the byte string .
Formally, with :
where means for some byte string .
What coinbaseScriptSig says
is the scriptSig (a byte string) of the first input of the first transaction of , with two fallbacks: if is empty, the fixed genesis coinbase transaction stands in for the first transaction (its scriptSig is a fixed 77-byte string); if that transaction has no inputs, a default input with empty scriptSig stands in, giving the empty string.
What heightScript says
For a natural number , is the byte string
where, for (so is positive and takes its non-negative branch): is the little-endian base-256 digit string of with no trailing zero byte (the "magnitude"), followed by an extra byte if and only if the top bit () of the magnitude's last byte is set; and , for a byte string , is (one length byte then the data) when , is when , is when , and is otherwise. For the magnitude has between 1 and 4 bytes, so has between 1 and 5 bytes and is one length byte (value 1 to 5) followed by those bytes.
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 height in the conclusion is , the length of the header list of the state before is connected; it is not read from and is not (which is one larger).
- Under the header list is non-empty, so and the conditional BIP34 clause of validation stage 3 is in force; that clause compares against the very same byte-string expression that defines . The read-back records this as the structure of the definitions.
- Stage 2 of validation requires to be non-empty with a coinbase first transaction (exactly one input), so under the hypotheses neither fallback of (genesis coinbase, default input) is exercised; the conclusion itself does not say so.
- No upper bound on is assumed here (unlike the sibling statements); is defined for every natural number.
- , and appear only in the acceptance hypothesis.
- The statement asserts a prefix relation only: the coinbase scriptSig may contain arbitrary further bytes after the height push, and nothing is claimed about its length beyond what stage 2 requires (between 2 and 100 bytes).
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.