Spending a present coin removes exactly its value
ProvedBitcoinUtxo.totalValue_spendFor every view with pairwise distinct outpoints, outpoint and coin with ,
Distinctness is what makes the removed entry unique.
import Definitions.Def_BitcoinUtxo open BitcoinUtxo
theorem BitcoinUtxo.totalValue_spend {T : Type} [DecidableEq T] (u : UtxoSet T) (op : OutPoint T) (c : Coin)
(hn : keysNodup u) (h : getCoin u op = some c) :
totalValue (spendCoin u op) = totalValue u - c.out.value := 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 of BitcoinUtxo.totalValue_spend.
Let be any type with decidable equality. A UTXO set over is a finite ordered list of pairs , where is an outpoint (a transaction id in together with an index ) and is a coin, i.e. a record consisting of an output (an integer and a Boolean ), a height and a Boolean . Write for the lookup that returns the coin of the first entry of whose outpoint equals , or "none" if there is no such entry. Write for the total value of : the integer sum of over every entry of the list, counting each entry (with multiplicity, even for repeated outpoints) and with no range restriction; . Write for the list obtained from by deleting every entry whose outpoint equals , keeping the others in order (if no entry matches, the list is unchanged). Write for the proposition that the list of outpoints of (first components, in order) contains no duplicates.
The theorem states: for every type with decidable equality, every UTXO set over , every outpoint over and every coin , if
- holds (the outpoints of are pairwise distinct), and
- (the first — hence, under the previous hypothesis, the only — entry of with outpoint carries exactly the coin ),
then
an equality of integers (ordinary subtraction in , no truncation). The conclusion is an exact equality, not an inequality. The hypotheses exclude the case where is absent from (then would be "none"), so is non-empty whenever the hypotheses hold. No constraint is placed on the sign or magnitude of or of any other value in , nor on , or .
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.