An accepted block raises the UTXO total by at most its subsidy
ProvedBitcoinSupply.block_supplyFor a reachable state and validate S b now = accept S' undo: totalValue S'.utxo ≤ totalValue S.utxo + GetBlockSubsidy (S.nextHeight). The fees the coinbase collects were already in the ledger; only the subsidy is new value. Proved through the acceptance theorem and ApplySpec: the loop bound totalValue (applyTxs) + totalFees ≤ totalValue + valueOut coinbase and the coinbase bound valueOut coinbase ≤ totalFees + subsidy.
import Definitions.Def_BitcoinSupply import Definitions.Def_BitcoinSer import Definitions.Def_BitcoinSubsidy open BitcoinSupply BitcoinBlockV2
theorem BitcoinSupply.block_supply (S : ChainState) (b : BitcoinSer.Block) (now : Int) (S' : ChainState)
(undo : BlockUndo) (hR : BitcoinBlockV2.Reachable S) (hv : BitcoinBlockV2.validate S b now = .accept S' undo) :
BitcoinSupply.totalValue S'.utxo ≤
BitcoinSupply.totalValue S.utxo + (BitcoinSubsidy.coreSubsidy S.nextHeight : Int) := 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: BitcoinSupply.block_supply
Statement
For every chain state , every block (a header and a list of transactions), every integer ("now"), every chain state and every undo datum (a list of lists of coins), if
- holds (expanded below), and
- (the validation procedure expanded below accepts on top of with clock , producing exactly the state and undo data ),
then
where counts every list entry, is the number of headers in (the height at which is connected), and is the subsidy mission's function defined below, cast to an integer. The inequality is non-strict and compares integers.
The conclusion is stated with directly, not with the file's or constants, and it bounds the total after the block in terms of the total before it plus the subsidy at the connecting height; the fees of the block do not appear in the conclusion.
Chain states and what "reachable" means
A chain state is a pair: a list of block headers and a ledger . A ledger is a finite list of pairs with an outpoint (a byte list and a natural number ) and a coin , whose output carries an integer value and a byte-list script. Nothing in the type forbids repeated keys in a ledger. is the length of ; is that length minus one (natural-number subtraction, so for an empty list); the tip is the last header (the fixed genesis header if the list is empty).
Other notation used below:
- : the coin of the first entry of ledger with key , if any; is true iff one exists; is that coin, or a dummy coin of value when absent.
- : has exactly one input and its outpoint is null (hash 32 zero bytes, index ).
- (integer sum).
- : double SHA-256 of the witness-stripped serialization of . A script is unspendable iff it is non-empty with first byte , or longer than bytes.
- : if is not a coinbase, first delete from , for each input in order, every entry whose key equals that input's outpoint; then for each output of (index ): if its script is unspendable, nothing; otherwise delete every entry with key and prepend .
- (integer). " is in money range" means .
- for , with : if , else (already once ).
is the least predicate on chain states such that
- the initial state is reachable: its header list holds the single fixed mainnet genesis header and its ledger is empty (the genesis coinbase output is not in it);
- if is reachable and there exist a block (a header plus a list of transactions ), an integer (the "local clock", unconstrained — any integer may be chosen for each step), a state and undo data with , then is reachable.
holds exactly when steps (a)–(d) below all succeed; then with the ledger produced in step (d), so .
(a) Header acceptance. The header's compact target decodes to a valid target and the header's double-SHA-256 hash, read as a little-endian number, is ; equals the hash of the tip of ; equals the difficulty requires (the PoW mission's next-work rule applied to the tip and the first header of its 2016-block period); , the median-time-past of the tip computed from the header times of ; ; and the version is not outdated (not version once height is active after the tip height, nor for , nor for ).
(b) Context-free block check. The same proof-of-work test; is non-empty; the Merkle root over the txids equals the header's Merkle root and is not flagged mutated; and (witness-stripped serialized size of ) ; the first transaction is a coinbase and every later transaction is not; every transaction passes the transaction check: non-empty inputs and non-empty outputs; (its witness-stripped size) ; every output value lies in and every prefix sum of the output values is in money range (hence ); the inputs' outpoints are pairwise distinct; a coinbase's first input scriptSig has length in , and a non-coinbase has no null input outpoint; finally (the block's legacy sigop count) .
(c) Contextual block check. With : every transaction is final at height against a cutoff time (the tip's median time past if CSV is active after the tip height, else the header's time); if the BIP34 height-in-coinbase rule is active, the first transaction's first input scriptSig begins with the push of ; the witness-commitment/malleation test for the segwit activation status passes; the block weight is .
(d) Connect. Let and let be the hash of .
-
If equals the fixed mainnet genesis hash, the result is : the ledger is unchanged and the transactions of are not applied, although the header is still appended.
-
Otherwise, if the BIP30 scan applies to (it applies unless is one of the two listed repeat blocks or the BIP34 activation header is present in with the expected hash, and always applies from height ), then for every transaction of and every index , no entry of has key . Then the transactions of are processed in order by a loop whose state is (ledger , fees , sigop cost, undo list), starting from :
- if is a coinbase, and the undo list are unchanged;
- otherwise, on the current ledger : every input outpoint must have an entry in ; scanning the inputs in order, the coin found for each must not be (flagged coinbase with , natural-number subtraction truncated at ), its value must be in money range and the running sum of coin values must be in money range; the total input value must satisfy with in money range; then must be in money range, the BIP68 sequence-lock rule must hold, the undo list gains the coins spent, and becomes ;
- in either case the accumulated sigop cost (including this transaction's) must be , a non-coinbase must have every input script verify under the block's script flags, and the ledger becomes .
After the loop, with final fees and ledger , it is required that
where is the first transaction of ; the result is then .
Edge cases the statement includes
- appears only in hypothesis 2 (it is whatever the validation produced); the conclusion does not mention it.
- is any integer; hypothesis 2 fixes it only through the check .
- If 's header hashes to the genesis hash and the block passes (a)–(c), step (d) returns the unchanged ledger, so and the claim reduces to .
- For the subsidy term is and the claim is .
- The theorem does not assert that is reachable (though it is, by the step rule) and does not assert anything about individual values of .
- Coinbase outputs with unspendable scripts count toward in the coinbase bound of step (d) but are never added to the ledger.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.