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_total
Statement. For every finite list c of FeeFracs (implicit) with SizesPos(c) — every chunk has strictly positive size — and every rational x (implicit) with
diagramSize(c)≤x,
(the integer total size regarded as a rational), we have
diagram(c,x)=diagramFee(c)=i∑fee(ci)
(the integer total fee regarded as a rational).
Binders and edge cases. Fees are arbitrary integers. The condition x≥diagramSize(c) includes x equal to the total size. For the empty list, diagramSize=diagramFee=0; the claim is then that diagram([],x)=0 for all rational x≥0. Nothing is asserted for x<diagramSize(c).
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.
Confirmed by the moderator at approval.