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_concave
Statement. Let c=[c1,…,cn] be any finite list of FeeFracs such that
- SizesPos(c): size(ci)>0 for every i; and
- FeeratesNonIncreasing(c): fee(ci+1)⋅size(ci)≤fee(ci)⋅size(ci+1) for every pair of adjacent chunks.
Let I={x∈Q:0≤x≤diagramSize(c)}, the closed interval of rationals from 0 to the total size diagramSize(c)=∑isize(ci). Then the function x↦diagram(c,x) is concave on I over the scalar field Q, which means:
- I is convex (as a subset of Q), and
- for all x,y∈I and all rationals λ,μ≥0 with λ+μ=1,
λdiagram(c,x)+μdiagram(c,y)≤diagram(c,λx+μy).
Binders and edge cases. Fees are arbitrary integers (zero or negative allowed). Concavity is asserted only on [0,diagramSize(c)], not on the whole half-line x≥0 and not for negative x; only rational points and rational weights are involved. For the empty list, diagramSize=0 and I={0}, so the claim reduces to diagram([],0)≤diagram([],0). For a single chunk the sortedness hypothesis is vacuous. The sortedness hypothesis compares only adjacent chunks, by integer cross-multiplication.
Definitions used, unfolded
FeeFrac. A FeeFrac is a pair 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)),
and the zero FeeFrac is (0,0). A chunk list is a finite list c=[c1,…,cn] of FeeFracs; the empty list (n=0) is allowed.
diagram. For a chunk list c and x∈Q, diagram(c,x)∈Q is defined recursively:
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). It is defined for every rational x, including negative x. For the empty list it is identically 0. When every size is positive, writing Sk=∑i≤ksize(ci) and Fk=∑i≤kfee(ci) (with S0=F0=0) for c=[c1,…,cn], n≥1, the recursion unfolds to: diagram(c,x)=fee(c1)x/size(c1) for all x≤S1 (including negative x); Fk−1+fee(ck)(x−Sk−1)/size(ck) for Sk−1≤x≤Sk; and Fn for x≥Sn — the piecewise-linear function through (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 gives diagram(c,0)=fee(c1)+diagram(c′,−size(c1)); a chunk with size 0 contributes a jump of fee(c1) just after x=0).
diagramFee, diagramSize. For c=[c1,…,cn]: diagramFee(c)=∑i=1nfee(ci)∈Z and diagramSize(c)=∑i=1nsize(ci)∈Z (both 0 for the empty list).
SizesPos. SizesPos(c) means size(ci)>0 for every chunk ci in c (vacuously true for the empty list). It says nothing about fees, which may be zero or negative.
FeeratesNonIncreasing. FeeratesNonIncreasing(c) means: for every pair of adjacent chunks ci,ci+1,
fee(ci+1)⋅size(ci)≤fee(ci)⋅size(ci+1)
(integer cross-multiplication). It holds automatically for lists of length 0 or 1.
Confirmed by the moderator at approval.