What the Lean code literally says, in plain math · claude-fable-5-1 (independent sub-agent, blind: Lean code + auditor instructions only)
Read-back: BitcoinReplacement.paysForRBF_iff
Setting (unfolded from the preamble). All declarations live in a namespace BitcoinReplacement. A transaction t is a pair of natural numbers (fee(t),vsize(t)) together with a proof that vsize(t)>0; fee(t) may be 0. Two transactions are equal exactly when their fees and virtual sizes agree. A fee rate r is a pair of natural numbers (rfee,rsize) together with a proof that rsize>0; rfee may be 0, and nothing identifies (1,2) with (2,4). For a fee rate r and a natural number v,
getFeer(v)=⌊rsizerfee⋅v+(rsize−1)⌋,
computed with natural-number (rounding-down) division; since rsize≥1 the inner subtraction rsize−1 is exact, and the value equals ⌈rfeev/rsize⌉. In particular getFeer(0)=0, and getFeer(v)=0 for every v whenever rfee=0.
A replacement R consists of a transaction R.new, a multiset of transactions R.evicted, a multiset of transactions R.direct, and a proof that R.direct≤R.evicted as multisets (every transaction value occurs in R.direct at most as many times as it occurs in R.evicted). Either multiset may be empty, R.new may itself occur in R.evicted, and no other relation between the three components is imposed. For a multiset s of transactions, totalFee(s)=∑u∈sfee(u), summed with multiplicity, so totalFee(∅)=0.
R is valid at rate r (written Valid(r,R)) when all three of the following hold:
- (PaysMoreThanConflicts(R)) for every transaction value u occurring in R.direct, fee(u)⋅vsize(R.new)<fee(R.new)⋅vsize(u) (a strict cross-multiplied comparison in N; vacuously true when R.direct is empty; nothing is required of elements of R.evicted that do not occur in R.direct);
- (PaysForRBF(r,R), first conjunct) totalFee(R.evicted)≤fee(R.new);
- (PaysForRBF(r,R), second conjunct) getFeer(vsize(R.new))≤fee(R.new)−˙totalFee(R.evicted), where −˙ is truncated natural-number subtraction (it returns 0 when the subtrahend exceeds the minuend; under item 2 it coincides with ordinary subtraction).
Statement. For every fee rate r and every replacement R (with no validity or other hypothesis), the following two conditions are equivalent:
- Left side: PaysForRBF(r,R), i.e. the conjunction
totalFee(R.evicted)≤fee(R.new)andgetFeer(vsize(R.new))≤fee(R.new)−˙totalFee(R.evicted),
where −˙ is truncated natural-number subtraction;
- Right side: the single natural-number inequality
totalFee(R.evicted)+getFeer(vsize(R.new))≤fee(R.new).
Edge cases and scope. The condition PaysMoreThanConflicts(R) (the strict fee-rate comparison against R.direct) plays no role on either side; R.direct is not mentioned. If R.evicted is empty then totalFee(R.evicted)=0 and both sides reduce to getFeer(vsize(R.new))≤fee(R.new). If rfee=0 then getFeer(⋅)=0 and both sides reduce to totalFee(R.evicted)≤fee(R.new). The equivalence is a biconditional, in both directions.
Confirmed by the moderator at approval.