Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

The ByRatio comparison is the comparison of exact fractions

Proved
BitcoinReplacement.feeRateQ_lt_iff

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

bip125bitcoinfee-marketformal-verificationmathlibmempoolpinningpolicyrbf

For transactions a,ba, ba,b: a.fee/a.vsize<b.fee/b.vsizea.\text{fee}/a.\text{vsize} < b.\text{fee}/b.\text{vsize}a.fee/a.vsize<b.fee/b.vsize in Q\mathbb{Q}Q iff FeeRate.lt a.feeRate b.feeRate.

Preamble
import Definitions.Def_BitcoinReplacement
Formal statement
theorem BitcoinReplacement.feeRateQ_lt_iff (a b : BitcoinReplacement.Tx) :
    a.feeRateQ < b.feeRateQ ↔ BitcoinReplacement.FeeRate.lt a.feeRate b.feeRate := 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.feeRateQ_lt_iff

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. A fee rate is a pair of natural numbers (fee,size)(\mathrm{fee}, \mathrm{size})(fee,size) with a proof that size>0\mathrm{size} > 0size>0. The fee rate attached to a transaction ttt, feeRate⁡(t)\operatorname{feeRate}(t)feeRate(t), is the pair (fee⁡(t),vsize⁡(t))(\operatorname{fee}(t), \operatorname{vsize}(t))(fee(t),vsize(t)). For fee rates a=(afee,asize)a = (a_{\mathrm{fee}}, a_{\mathrm{size}})a=(afee​,asize​) and b=(bfee,bsize)b = (b_{\mathrm{fee}}, b_{\mathrm{size}})b=(bfee​,bsize​), the relation lt⁡(a,b)\operatorname{lt}(a, b)lt(a,b) is defined as the natural-number inequality afee⋅bsize<bfee⋅asizea_{\mathrm{fee}}\cdot b_{\mathrm{size}} < b_{\mathrm{fee}}\cdot a_{\mathrm{size}}afee​⋅bsize​<bfee​⋅asize​. For a transaction uuu, feeRateQ⁡(u)=fee⁡(u)/vsize⁡(u)∈Q\operatorname{feeRateQ}(u) = \operatorname{fee}(u)/\operatorname{vsize}(u) \in \mathbb{Q}feeRateQ(u)=fee(u)/vsize(u)∈Q is the exact rational quotient (well defined since vsize⁡(u)>0\operatorname{vsize}(u) > 0vsize(u)>0).

Statement. For every pair of transactions aaa and bbb (no further hypotheses), the following are equivalent:

fee⁡(a)vsize⁡(a)  <  fee⁡(b)vsize⁡(b)in Q⟺fee⁡(a)⋅vsize⁡(b)  <  fee⁡(b)⋅vsize⁡(a)in N.\frac{\operatorname{fee}(a)}{\operatorname{vsize}(a)} \;<\; \frac{\operatorname{fee}(b)}{\operatorname{vsize}(b)} \quad\text{in } \mathbb{Q} \qquad\Longleftrightarrow\qquad \operatorname{fee}(a)\cdot\operatorname{vsize}(b) \;<\; \operatorname{fee}(b)\cdot\operatorname{vsize}(a) \quad\text{in } \mathbb{N}.vsize(a)fee(a)​<vsize(b)fee(b)​in Q⟺fee(a)⋅vsize(b)<fee(b)⋅vsize(a)in N.

The left side is the strict order on rational numbers; the right side is lt⁡(feeRate⁡(a),feeRate⁡(b))\operatorname{lt}(\operatorname{feeRate}(a), \operatorname{feeRate}(b))lt(feeRate(a),feeRate(b)), a strict cross-multiplied comparison of natural numbers with no rounding.

Edge cases. Both sides are comparisons of a transaction with another arbitrary transaction, including a=ba = ba=b (both sides then false) and the case fee⁡(a)=0\operatorname{fee}(a) = 0fee(a)=0 (left side holds iff fee⁡(b)>0\operatorname{fee}(b) > 0fee(b)>0, and likewise on the right since vsize⁡(a)>0\operatorname{vsize}(a) > 0vsize(a)>0). No fee rate parameter rrr and no replacement appears in this statement.

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