Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Every evicted transaction paid strictly less than its replacement

Proved
BitcoinReplacement.fee_strictly_increases

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

bip125bitcoinfee-marketformal-verificationmathlibmempoolpinningpolicyrbf

For a rate with positive numerator, a valid replacement RRR and any t∈t \int∈ R.evicted: t.fee < R.new.fee. With a zero incremental relay fee the inequality can be an equality, hence the hypothesis.

Preamble
import Definitions.Def_BitcoinReplacement
Formal statement
theorem BitcoinReplacement.fee_strictly_increases (rate : BitcoinReplacement.FeeRate)
    (hr : 0 < rate.fee) (R : BitcoinReplacement.Replacement)
    (hR : BitcoinReplacement.Valid rate R) (t : BitcoinReplacement.Tx) (ht : t ∈ R.evicted) :
    t.fee < R.new.fee := by sorry
Source
Bitcoin Core a773e1e33b349dc819b5a0edc1c7a4839dc73b48: PaysForRBF (src/policy/rbf.cpp: https://github.com/bitcoin/bitcoin/blob/a773e1e33b349dc819b5a0edc1c7a4839dc73b48/src/policy/rbf.cpp), CFeeRate::GetFee = FeePerVSize::EvaluateFeeUp (policy/feerate.cpp, util/feefrac.h), DEFAULT_INCREMENTAL_RELAY_FEE (policy/policy.h); PaysMoreThanConflicts as last present in policy/rbf.cpp at v29.0; BIP125
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: BitcoinReplacement.fee_strictly_increases

Setting (unfolded from the preamble). All declarations live in a namespace BitcoinReplacement. A transaction ttt is a pair of natural numbers (fee⁡(t),vsize⁡(t))(\operatorname{fee}(t), \operatorname{vsize}(t))(fee(t),vsize(t)) together with a proof that vsize⁡(t)>0\operatorname{vsize}(t) > 0vsize(t)>0; fee⁡(t)\operatorname{fee}(t)fee(t) may be 000. Two transactions are equal exactly when their fees and virtual sizes agree. A fee rate rrr is a pair of natural numbers (rfee,rsize)(r_{\mathrm{fee}}, r_{\mathrm{size}})(rfee​,rsize​) together with a proof that rsize>0r_{\mathrm{size}} > 0rsize​>0; rfeer_{\mathrm{fee}}rfee​ may be 000, and nothing identifies (1,2)(1,2)(1,2) with (2,4)(2,4)(2,4). For a fee rate rrr and a natural number vvv,

getFee⁡r(v)  =  ⌊rfee⋅v+(rsize−1)rsize⌋,\operatorname{getFee}_r(v) \;=\; \left\lfloor \frac{r_{\mathrm{fee}}\cdot v + (r_{\mathrm{size}} - 1)}{r_{\mathrm{size}}} \right\rfloor ,getFeer​(v)=⌊rsize​rfee​⋅v+(rsize​−1)​⌋,

computed with natural-number (rounding-down) division; since rsize≥1r_{\mathrm{size}} \ge 1rsize​≥1 the inner subtraction rsize−1r_{\mathrm{size}}-1rsize​−1 is exact, and the value equals ⌈rfee v/rsize⌉\lceil r_{\mathrm{fee}}\, v / r_{\mathrm{size}}\rceil⌈rfee​v/rsize​⌉. In particular getFee⁡r(0)=0\operatorname{getFee}_r(0) = 0getFeer​(0)=0, and getFee⁡r(v)=0\operatorname{getFee}_r(v) = 0getFeer​(v)=0 for every vvv whenever rfee=0r_{\mathrm{fee}} = 0rfee​=0.

A replacement RRR consists of a transaction R.newR.\mathrm{new}R.new, a multiset of transactions R.evictedR.\mathrm{evicted}R.evicted, a multiset of transactions R.directR.\mathrm{direct}R.direct, and a proof that R.direct≤R.evictedR.\mathrm{direct} \le R.\mathrm{evicted}R.direct≤R.evicted as multisets (every transaction value occurs in R.directR.\mathrm{direct}R.direct at most as many times as it occurs in R.evictedR.\mathrm{evicted}R.evicted). Either multiset may be empty, R.newR.\mathrm{new}R.new may itself occur in R.evictedR.\mathrm{evicted}R.evicted, and no other relation between the three components is imposed. For a multiset sss of transactions, totalFee⁡(s)=∑u∈sfee⁡(u)\operatorname{totalFee}(s) = \sum_{u \in s} \operatorname{fee}(u)totalFee(s)=∑u∈s​fee(u), summed with multiplicity, so totalFee⁡(∅)=0\operatorname{totalFee}(\varnothing) = 0totalFee(∅)=0.

RRR is valid at rate rrr (written Valid⁡(r,R)\operatorname{Valid}(r,R)Valid(r,R)) when all three of the following hold:

  1. (PaysMoreThanConflicts⁡(R)\operatorname{PaysMoreThanConflicts}(R)PaysMoreThanConflicts(R)) for every transaction value uuu occurring in R.directR.\mathrm{direct}R.direct, fee⁡(u)⋅vsize⁡(R.new)<fee⁡(R.new)⋅vsize⁡(u)\operatorname{fee}(u)\cdot\operatorname{vsize}(R.\mathrm{new}) < \operatorname{fee}(R.\mathrm{new})\cdot\operatorname{vsize}(u)fee(u)⋅vsize(R.new)<fee(R.new)⋅vsize(u) (a strict cross-multiplied comparison in N\mathbb{N}N; vacuously true when R.directR.\mathrm{direct}R.direct is empty; nothing is required of elements of R.evictedR.\mathrm{evicted}R.evicted that do not occur in R.directR.\mathrm{direct}R.direct);
  2. (PaysForRBF⁡(r,R)\operatorname{PaysForRBF}(r,R)PaysForRBF(r,R), first conjunct) totalFee⁡(R.evicted)≤fee⁡(R.new)\operatorname{totalFee}(R.\mathrm{evicted}) \le \operatorname{fee}(R.\mathrm{new})totalFee(R.evicted)≤fee(R.new);
  3. (PaysForRBF⁡(r,R)\operatorname{PaysForRBF}(r,R)PaysForRBF(r,R), second conjunct) getFee⁡r(vsize⁡(R.new))≤fee⁡(R.new)−˙totalFee⁡(R.evicted)\operatorname{getFee}_r(\operatorname{vsize}(R.\mathrm{new})) \le \operatorname{fee}(R.\mathrm{new}) \mathbin{\dot-} \operatorname{totalFee}(R.\mathrm{evicted})getFeer​(vsize(R.new))≤fee(R.new)−˙​totalFee(R.evicted), where −˙\dot-−˙​ is truncated natural-number subtraction (it returns 000 when the subtrahend exceeds the minuend; under item 2 it coincides with ordinary subtraction).

Statement. For every fee rate rrr such that 0<rfee0 < r_{\mathrm{fee}}0<rfee​ (the numerator of the rate is positive), every replacement RRR such that Valid⁡(r,R)\operatorname{Valid}(r, R)Valid(r,R) holds (all three conditions above), and every transaction ttt that occurs in the multiset R.evictedR.\mathrm{evicted}R.evicted, the following strict inequality of natural numbers holds:

fee⁡(t)  <  fee⁡(R.new).\operatorname{fee}(t) \;<\; \operatorname{fee}(R.\mathrm{new}).fee(t)<fee(R.new).

Edge cases and scope. The membership hypothesis is t∈R.evictedt \in R.\mathrm{evicted}t∈R.evicted (the larger multiset), so the conclusion covers every evicted transaction, whether or not it occurs in R.directR.\mathrm{direct}R.direct. If R.evictedR.\mathrm{evicted}R.evicted is empty the statement is vacuous. The hypothesis 0<rfee0 < r_{\mathrm{fee}}0<rfee​ constrains only the numerator; rsizer_{\mathrm{size}}rsize​ may be arbitrarily large, so the ratio rfee/rsizer_{\mathrm{fee}}/r_{\mathrm{size}}rfee​/rsize​ may be arbitrarily small but is nonzero, and consequently getFee⁡r(v)≥1\operatorname{getFee}_r(v) \ge 1getFeer​(v)≥1 for every v≥1v \ge 1v≥1. Nothing is asserted about virtual sizes or fee rates of ttt versus R.newR.\mathrm{new}R.new, only about raw fees.

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