Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

The money supply of a chain state: the total value of the UTXO set, the issued subsidy, and the value-range invariant

Definition
BitcoinSupply

by pitimespi · Oct 28, 2026 · Mathlib 0df444a (Lean v4.33.1)

21-millionbitcoinbitcoin-mainnetconsensusformal-verificationinflationsupplyutxo

Four names over the block mission's BitcoinBlockV2 and the subsidy mission's BitcoinSubsidy; nothing is re-transcribed.

totalValue u — the sum of nValue over the coins of a ledger uuu (an association list of outpoints and coins), as an integer.

ValuesInRange u — every coin of uuu has 0 ≤ nValue ≤ MAX_MONEY (the MoneyRange of consensus/amount.h).

issued n — BitcoinSubsidy.issuedBelow n as an integer: the sum of GetBlockSubsidy over heights 0,…,n−10, \dots, n-10,…,n−1, i.e. the subsidy a chain of nnn blocks has issued.

genesisSubsidy — GetBlockSubsidy 0 as an integer, the fifty bitcoin of the genesis coinbase, which the source never adds to the UTXO set (ConnectBlock's genesis shortcut; CMainParams).

Formalization Note. The chain state, the ledger, updateCoins, validate and Reachable are the block mission's; coreSubsidy and issuedBelow are the subsidy mission's. Only Std is imported.

Definition code
import Definitions.Def_BitcoinBlockV2
import Definitions.Def_BitcoinSubsidy

/-!
# The money supply as a chain invariant

`GetBlockSubsidy` bounds what each coinbase may create; `CheckTxInputs` requires every other
transaction to spend at least what it creates. Together they bound the total value of the UTXO
set of every chain state reachable from the genesis by the subsidy issued so far. This file names
the quantities the theorems speak about; the rules themselves are those of the block mission
(`BitcoinBlockV2`) and the subsidy mission (`BitcoinSubsidy`).
-/

namespace BitcoinSupply

open BitcoinBlockV2

/-- The total value of the coins of a ledger. -/
def totalValue : Ledger → Int
  | [] => 0
  | e :: rest => e.2.out.nValue + totalValue rest

/-- Every coin's value lies in `[0, MAX_MONEY]`. -/
def ValuesInRange (u : Ledger) : Prop :=
  ∀ e ∈ u, 0 ≤ e.2.out.nValue ∧ e.2.out.nValue ≤ MAX_MONEY

/-- The subsidy a chain of `n` blocks (heights `0..n-1`) has issued, as `GetBlockSubsidy` sums it. -/
def issued (n : Nat) : Int := (BitcoinSubsidy.issuedBelow n : Int)

/-- The genesis subsidy: its coinbase is not in the UTXO set (`CMainParams`, `ConnectBlock`'s
genesis shortcut), so it is issued but never spendable. -/
def genesisSubsidy : Int := (BitcoinSubsidy.coreSubsidy 0 : Int)

end BitcoinSupply
Source
Bitcoin Core a773e1e33b349dc819b5a0edc1c7a4839dc73b48: GetBlockSubsidy, ConnectBlock (the coinbase bound), UpdateCoins, src/validation.cpp: https://github.com/bitcoin/bitcoin/blob/a773e1e33b349dc819b5a0edc1c7a4839dc73b48/src/validation.cpp; CheckTxInputs (consensus/tx_verify.cpp); CheckTransaction (consensus/tx_check.cpp); AddCoin, SpendCoin (coins.cpp); MAX_MONEY (consensus/amount.h)
Read-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: Def_BitcoinSupply.lean (namespace BitcoinSupply)

Throughout, a ledger is a finite list of pairs (k,c)(k, c)(k,c) where kkk is an outpoint (a pair of a byte list k.hashk.\mathrm{hash}k.hash and a natural number k.nk.nk.n) and ccc is a coin: a triple (c.out, c.height, c.isCoinbase)(c.\mathrm{out},\ c.\mathrm{height},\ c.\mathrm{isCoinbase})(c.out, c.height, c.isCoinbase) with c.outc.\mathrm{out}c.out an output (an integer value c.out.nValue∈Zc.\mathrm{out}.\mathrm{nValue} \in \mathbb{Z}c.out.nValue∈Z and a byte-list script), c.height∈Nc.\mathrm{height} \in \mathbb{N}c.height∈N, and c.isCoinbasec.\mathrm{isCoinbase}c.isCoinbase a boolean. The type places no restriction on the list: keys may repeat, values may be negative or arbitrarily large, and the list may be empty.

The constant MAX_MONEY\mathrm{MAX\_MONEY}MAX_MONEY used in this file is the integer 2,100,000,000,000,0002{,}100{,}000{,}000{,}000{,}0002,100,000,000,000,000 (the block mission's integer constant, not the subsidy mission's natural-number constant; the two are numerically equal).


totalValue : Ledger → ℤ

For a ledger u=[(k1,c1),…,(km,cm)]u = [(k_1,c_1), \dots, (k_m,c_m)]u=[(k1​,c1​),…,(km​,cm​)],

totalValue(u)  =  ∑j=1mcj.out.nValue,\mathrm{totalValue}(u) \;=\; \sum_{j=1}^{m} c_j.\mathrm{out}.\mathrm{nValue},totalValue(u)=j=1∑m​cj​.out.nValue,

an integer. The empty ledger has total value 000. Every entry of the list contributes, including entries whose key coincides with an earlier entry's key (no de-duplication is performed), entries whose value is negative, and entries whose script is unspendable; the coin's height and coinbase flag play no role.


ValuesInRange : Ledger → Prop

For a ledger uuu, ValuesInRange(u)\mathrm{ValuesInRange}(u)ValuesInRange(u) is the proposition

∀ (k,c)∈u:0≤c.out.nValue  ∧  c.out.nValue≤2,100,000,000,000,000.\forall\, (k, c) \in u:\quad 0 \le c.\mathrm{out}.\mathrm{nValue} \;\wedge\; c.\mathrm{out}.\mathrm{nValue} \le 2{,}100{,}000{,}000{,}000{,}000 .∀(k,c)∈u:0≤c.out.nValue∧c.out.nValue≤2,100,000,000,000,000.

Both bounds are non-strict. It is vacuously true for the empty ledger. It says nothing about the sum of the values, about repeated keys, or about any field other than the value.


issued : ℕ → ℤ

For n∈Nn \in \mathbb{N}n∈N, issued(n)\mathrm{issued}(n)issued(n) is the natural number issuedBelow(n)\mathrm{issuedBelow}(n)issuedBelow(n) of the subsidy mission, cast to an integer, where

issuedBelow(0)=0,issuedBelow(n+1)=issuedBelow(n)+coreSubsidy(n),\mathrm{issuedBelow}(0) = 0,\qquad \mathrm{issuedBelow}(n+1) = \mathrm{issuedBelow}(n) + \mathrm{coreSubsidy}(n),issuedBelow(0)=0,issuedBelow(n+1)=issuedBelow(n)+coreSubsidy(n),

so that

issued(n)  =  ∑h=0n−1coreSubsidy(h).\mathrm{issued}(n) \;=\; \sum_{h=0}^{n-1} \mathrm{coreSubsidy}(h) .issued(n)=h=0∑n−1​coreSubsidy(h).

Here, for a height h∈Nh \in \mathbb{N}h∈N, with q=⌊h/210,000⌋q = \lfloor h / 210{,}000 \rfloorq=⌊h/210,000⌋,

coreSubsidy(h)  =  {0if q≥64,⌊5,000,000,0002 q⌋otherwise\mathrm{coreSubsidy}(h) \;=\; \begin{cases} 0 & \text{if } q \ge 64,\\[2pt] \left\lfloor \dfrac{5{,}000{,}000{,}000}{2^{\,q}} \right\rfloor & \text{otherwise} \end{cases}coreSubsidy(h)=⎩⎨⎧​0⌊2q5,000,000,000​⌋​if q≥64,otherwise​

(the right shift of the natural number 50⋅10850 \cdot 10^{8}50⋅108 by qqq bits). Note that for q≥33q \ge 33q≥33 the shifted value is already 000, so the q≥64q \ge 64q≥64 branch does not change any value. In particular issued(0)=0\mathrm{issued}(0) = 0issued(0)=0, issued(1)=5,000,000,000\mathrm{issued}(1) = 5{,}000{,}000{,}000issued(1)=5,000,000,000, and issued\mathrm{issued}issued is non-decreasing in nnn and eventually constant. The argument nnn is a count of blocks, not a largest height: the sum runs over heights 0,…,n−10, \dots, n-10,…,n−1.


genesisSubsidy : ℤ

The constant genesisSubsidy=coreSubsidy(0)\mathrm{genesisSubsidy} = \mathrm{coreSubsidy}(0)genesisSubsidy=coreSubsidy(0) cast to an integer, i.e.

genesisSubsidy=5,000,000,000.\mathrm{genesisSubsidy} = 5{,}000{,}000{,}000 .genesisSubsidy=5,000,000,000.

It is a bare numeric constant; nothing in this definition refers to the genesis block, its coinbase, or any ledger.

Human review
  • Endorsed by Shuze Chen · Oct 29, 2026

    Confirmed by the moderator at approval.

  • Endorsed by pitimespi · Oct 29, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me