The spendable supply is always below MAX_MONEY
ProvedBitcoinSupply.supply_lt_maxMoneyFor every reachable chain state : totalValue S.utxo < MAX_MONEY (= 21,000,000 × 10^8 satoshi). From the supply invariant and the subsidy mission's issuance_bound.
import Definitions.Def_BitcoinSupply open BitcoinSupply BitcoinBlockV2
theorem BitcoinSupply.supply_lt_maxMoney (S : ChainState) (hR : BitcoinBlockV2.Reachable S) :
BitcoinSupply.totalValue S.utxo < MAX_MONEY := 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_lt_maxMoney
Statement
For every chain state such that holds (expanded below),
where is the integer sum of the values of all entries of the ledger, and the right-hand side is the block mission's integer constant (the subsidy mission's natural-number constant has the same numerical value, but it is the block mission's integer constant that is named here, since only that namespace is opened).
The inequality is strict (, not ). No lower bound on the total is asserted by this theorem.
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 the ledger is empty, so the claim is .
- Entries with repeated keys, if a reachable ledger had any, would all be counted in the sum.
- The conclusion concerns only the sum; individual entries are not bounded by this statement.
- Each reachability step existentially quantifies the block, the clock value (any integer) and the undo data; a block whose header hashes to the genesis hash and passes (a)–(c) leaves the ledger unchanged.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.