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.replacement_count_bound_min_vsize
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).
A list [R1,…,Rn] of replacements (n≥0) is a chain at rate r from t0 (written IsChain(r,t0,[R1,…,Rn])) when, writing ti=Ri.new for 1≤i≤n, for every i with 1≤i≤n: Ri is valid at rate r, and the transaction value ti−1 occurs in the multiset Ri.evicted. Membership is by value: any element of Ri.evicted with the same fee and virtual size as ti−1 counts; it is not required that ti−1 occur in Ri.direct, nor that Ri.evicted contain nothing else. The empty list is a chain from any t0 at any rate. The chain end chainEnd(t0,[R1,…,Rn]) is tn=Rn.new when n≥1 and is t0 itself when n=0 (it depends only on the last replacement). The chain vsizes chainVsizes([R1,…,Rn]) is the list [vsize(t1),…,vsize(tn)], empty when n=0. Below, tn always denotes chainEnd(t0,[R1,…,Rn]), i.e. it is t0 when n=0.
Statement. For every fee rate r, every transaction t0, every list of replacements [R1,…,Rn] (n≥0) such that IsChain(r,t0,[R1,…,Rn]) holds, and every natural number m such that
m≤vsize(R.new)for every replacement R occurring in the list [R1,…,Rn],
the following inequality of natural numbers holds:
fee(t0)+n⋅getFeer(m)≤fee(tn),
where n is the length of the list and getFeer(m)=⌊(rfeem+rsize−1)/rsize⌋=⌈rfeem/rsize⌉.
Edge cases. The hypothesis on m is a universal statement over the members of the list, so it holds vacuously when n=0, in which case tn=t0 and the claim reads fee(t0)≤fee(t0). The value m=0 always satisfies the hypothesis, and then getFeer(0)=0 and the claim reads fee(t0)≤fee(tn). When rfee=0, getFeer(m)=0 for every m. The relation ≤ is non-strict; the hypothesis m≤vsize(R.new) is also non-strict.
Confirmed by the moderator at approval.