CheckTxInputs returns the fee, in range, with all inputs present
ProvedBitcoinUtxo.checkTxInputs_someFor every view , transaction , spend height and amount with :
and every input outpoint of is present in . The fee returned through txfee is exactly the difference of input and output values, and the input loop guarantees that every input it summed exists.
import Definitions.Def_BitcoinUtxo open BitcoinUtxo
theorem BitcoinUtxo.checkTxInputs_some {T : Type} [DecidableEq T] (u : UtxoSet T) (tx : Tx T) (h : Nat) (fee : Int)
(hfee : checkTxInputs u tx h = some fee) :
fee = valueIn u tx.vin - valueOut tx ∧ 0 ≤ fee ∧ fee ≤ MAX_MONEY ∧
∀ op ∈ tx.vin, haveCoin u op = true := 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.checkTxInputs_some.
Let be any type with decidable equality. A UTXO set over is a finite ordered list of pairs (outpoint, coin), where an outpoint is with , , and a coin is a record with an output (an integer and a Boolean ), a height and a Boolean . Write for the coin of the first entry of with outpoint (or "none"), and for the Boolean " is not none". A transaction has fields , (a list of outpoints), (a list of outputs) and a Boolean . Let and . Set
(both sums over the lists with multiplicity; for empty lists).
The function , for a spend height , returns an optional integer as follows.
- If is false, i.e. and some has : none.
- Otherwise run the input loop over with accumulator : at step , if none, fail; if some and and (truncated natural subtraction, so this holds in particular whenever ), fail; else set and fail if is false or is false. If any step fails: none. Otherwise (which equals , since every is some coin).
- Let . If : none. Else let ; if is false: none; else some .
The theorem states: for every type with decidable equality, every UTXO set over , every transaction over , every height and every integer , if , then all four of the following hold:
- (exact integer equality);
- ;
- ;
- for every outpoint occurring in , .
There is no hypothesis that the outpoints of are distinct, none that has no duplicates (a repeated input contributes its coin's value once per occurrence both in the loop and in ), and no hypothesis on : a coinbase-flagged transaction is covered too, and for it conclusion 4 still follows because the input loop itself requires every to be present. If is empty, conclusion 4 is vacuous and . The conclusion does not mention the maturity test or the individual coin-value range tests, though the hypothesis entails them.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.