The supply invariant: the UTXO total never exceeds the issued subsidy
ProvedBitcoinSupply.supply_boundFor every chain state reachable from the genesis: totalValue S.utxo + genesisSubsidy ≤ issued S.nextHeight. The spendable supply plus the unspendable genesis subsidy is bounded by what GetBlockSubsidy has issued to the chain's height. No sequence of valid blocks creates value beyond the schedule: this is the invariant whose violation would be an inflation bug (CVE-2018-17144 broke it in Core by double-spending within a block; here duplicate inputs are rejected by CheckTransaction and the proof goes through the distinct-prevout condition).
import Definitions.Def_BitcoinSupply open BitcoinSupply BitcoinBlockV2
theorem BitcoinSupply.supply_bound (S : ChainState) (hR : BitcoinBlockV2.Reachable S) :
BitcoinSupply.totalValue S.utxo + BitcoinSupply.genesisSubsidy ≤ BitcoinSupply.issued S.nextHeight := 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.supply_bound
Statement
For every chain state such that holds (expanded below),
where
- , every list entry counted, an integer;
- is a fixed integer constant;
- is the number of headers in , and the right-hand side is : the natural number with , , cast to an integer (an empty sum, , when has no headers).
The inequality is non-strict and is between integers. Equivalently, .
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
- For the initial state, and , so the claim is , an equality.
- The sum on the right runs over heights , i.e. over every header in including the genesis header; the constant on the left is subtracted from it regardless of what the ledger contains.
- A block whose header hashes to the genesis hash and passes (a)–(c) leaves the ledger unchanged while adding one more term to the right-hand side.
- Nothing in the conclusion bounds individual entries, and nothing requires the keys of to be distinct; all entries are summed.
- Each reachability step existentially quantifies the block, the clock value and the undo data.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.