Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

The diagram starts at the origin

Proved
BitcoinFeerateDiagram.diagram_at_zero

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

bitcoincluster-mempoolfeefracfeerate-diagramformal-verificationmathlibmempoolpolicyrbf

For positive chunk sizes: diagram cs 0 = 0.

Preamble
import Definitions.Def_BitcoinFeerateDiagram
open BitcoinFeerateDiagram BitcoinReplacement
Formal statement
theorem BitcoinFeerateDiagram.diagram_at_zero {cs : List FeeFrac} (h : SizesPos cs) :
    diagram cs 0 = 0 := by sorry
Source
Bitcoin Core a773e1e33b349dc819b5a0edc1c7a4839dc73b48: util/feefrac.h (FeeFrac :20, MulFallback :25-30, DivFallback :40-59, Mul/Div :64-82, operator+/- :120-131, EvaluateFee :147-175, ByRatio :217-240), util/overflow.h (CeilDiv :70-74), util/feefrac.cpp (CompareChunks :12-75), policy/rbf.cpp (ImprovesFeerateDiagram :127-140, PaysForRBF :100-125): https://github.com/bitcoin/bitcoin/blob/a773e1e33b349dc819b5a0edc1c7a4839dc73b48/src/util/feefrac.cpp; test vectors from src/test/rbf_tests.cpp (feerate_chunks_utilities) and src/test/feefrac_tests.cpp
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: BitcoinFeerateDiagram.diagram_at_zero

Statement. For every finite list ccc of FeeFracs (implicit argument) satisfying SizesPos(c)\mathrm{SizesPos}(c)SizesPos(c) — every chunk has strictly positive size —

diagram(c,0)=0(in Q).\mathrm{diagram}(c, 0) = 0 \quad (\text{in } \mathbb Q).diagram(c,0)=0(in Q).

Binders and edge cases. Fees are arbitrary integers. The empty list satisfies the hypothesis vacuously and its diagram is 000 everywhere. For a nonempty list with size(c1)>0\mathrm{size}(c_1) > 0size(c1​)>0, the first case of the recursion applies at x=0x = 0x=0, giving fee(c1)⋅0/size(c1)\mathrm{fee}(c_1)\cdot 0/\mathrm{size}(c_1)fee(c1​)⋅0/size(c1​). The hypothesis excludes lists containing a chunk of size 000 or of negative size; for a first chunk of negative size the recursion would take the second branch at x=0x = 0x=0.

Definitions used, unfolded

FeeFrac. A FeeFrac is a pair X=(fee(X),size(X))X = (\mathrm{fee}(X), \mathrm{size}(X))X=(fee(X),size(X)) of two arbitrary integers. Nothing constrains them: either component may be zero or negative, and no machine-word bounds are imposed. Addition and subtraction are componentwise,

X±Y=(fee(X)±fee(Y), size(X)±size(Y)),X \pm Y = \big(\mathrm{fee}(X) \pm \mathrm{fee}(Y),\ \mathrm{size}(X) \pm \mathrm{size}(Y)\big),X±Y=(fee(X)±fee(Y), size(X)±size(Y)),

and the zero FeeFrac is (0,0)(0,0)(0,0). A chunk list is a finite list c=[c1,…,cn]c = [c_1, \dots, c_n]c=[c1​,…,cn​] of FeeFracs; the empty list (n=0n = 0n=0) is allowed.

diagram. For a chunk list ccc and x∈Qx \in \mathbb Qx∈Q, diagram(c,x)∈Q\mathrm{diagram}(c, x) \in \mathbb Qdiagram(c,x)∈Q is defined recursively:

diagram([ ],x)=0,diagram(c1::c′,x)={fee(c1)⋅x/size(c1)if x≤size(c1),fee(c1)+diagram(c′,x−size(c1))if x>size(c1),\mathrm{diagram}([\,], x) = 0, \qquad \mathrm{diagram}(c_1 :: c', x) = \begin{cases} \mathrm{fee}(c_1)\cdot x / \mathrm{size}(c_1) & \text{if } x \le \mathrm{size}(c_1),\\ \mathrm{fee}(c_1) + \mathrm{diagram}\big(c', x - \mathrm{size}(c_1)\big) & \text{if } x > \mathrm{size}(c_1),\end{cases}diagram([],x)=0,diagram(c1​::c′,x)={fee(c1​)⋅x/size(c1​)fee(c1​)+diagram(c′,x−size(c1​))​if x≤size(c1​),if x>size(c1​),​

with rational division (⋅/0=0\cdot/0 = 0⋅/0=0). It is defined for every rational xxx, including negative xxx. For the empty list it is identically 000. When every size is positive, writing Sk=∑i≤ksize(ci)S_k = \sum_{i \le k}\mathrm{size}(c_i)Sk​=∑i≤k​size(ci​) and Fk=∑i≤kfee(ci)F_k = \sum_{i \le k}\mathrm{fee}(c_i)Fk​=∑i≤k​fee(ci​) (with S0=F0=0S_0 = F_0 = 0S0​=F0​=0) for c=[c1,…,cn]c = [c_1,\dots,c_n]c=[c1​,…,cn​], n≥1n \ge 1n≥1, the recursion unfolds to: diagram(c,x)=fee(c1) x/size(c1)\mathrm{diagram}(c,x) = \mathrm{fee}(c_1)\,x/\mathrm{size}(c_1)diagram(c,x)=fee(c1​)x/size(c1​) for all x≤S1x \le S_1x≤S1​ (including negative xxx); Fk−1+fee(ck)(x−Sk−1)/size(ck)F_{k-1} + \mathrm{fee}(c_k)(x - S_{k-1})/\mathrm{size}(c_k)Fk−1​+fee(ck​)(x−Sk−1​)/size(ck​) for Sk−1≤x≤SkS_{k-1} \le x \le S_kSk−1​≤x≤Sk​; and FnF_nFn​ for x≥Snx \ge S_nx≥Sn​ — the piecewise-linear function through (0,0),(S1,F1),…,(Sn,Fn)(0,0), (S_1,F_1), \dots, (S_n,F_n)(0,0),(S1​,F1​),…,(Sn​,Fn​), horizontal to the right. If a size is zero or negative the recursion still evaluates but need not have this shape (e.g. a chunk with size(c1)<0\mathrm{size}(c_1) < 0size(c1​)<0 gives diagram(c,0)=fee(c1)+diagram(c′,−size(c1))\mathrm{diagram}(c, 0) = \mathrm{fee}(c_1) + \mathrm{diagram}(c', -\mathrm{size}(c_1))diagram(c,0)=fee(c1​)+diagram(c′,−size(c1​)); a chunk with size 000 contributes a jump of fee(c1)\mathrm{fee}(c_1)fee(c1​) just after x=0x = 0x=0).

SizesPos. SizesPos(c)\mathrm{SizesPos}(c)SizesPos(c) means size(ci)>0\mathrm{size}(c_i) > 0size(ci​)>0 for every chunk cic_ici​ in ccc (vacuously true for the empty list). It says nothing about fees, which may be zero or negative.

Human review
  • Endorsed by Shuze Chen · Oct 30, 2026

    Confirmed by the moderator at approval.

  • Endorsed by pitimespi · Oct 30, 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