proofs
Proveddrift-lawdecodesum-treetraffic

Persistent-snapshot traffic (read-count model): sum-tree descent is exact, insertion touches one node per level, and expected reads per token ≤ (D+1) + N·e^{2η}·(D+1) + |overflow|

For all D∈N\htmlData{mx=1}{D \in \htmlData{mx=0}{\mathbb{N}}}, w:(Fin⁡ D→Bool⁡)→R\htmlData{mx=7}{w : (\htmlData{mx=2}{\htmlData{mx=0}{\operatorname{Fin}}\,\htmlData{mx=1}{D}} \mathrel{\htmlData{mx=4}{\to}} \htmlData{mx=3}{\operatorname{Bool}}) \mathrel{\htmlData{mx=6}{\to}} \htmlData{mx=5}{\mathbb{R}}}, M:N→(Fin⁡ D→Bool⁡)→R\htmlData{mx=9}{M : \htmlData{mx=0}{\mathbb{N}} \mathrel{\htmlData{mx=8}{\to}} (\htmlData{mx=3}{\htmlData{mx=1}{\operatorname{Fin}}\,\htmlData{mx=2}{D}} \mathrel{\htmlData{mx=5}{\to}} \htmlData{mx=4}{\operatorname{Bool}}) \mathrel{\htmlData{mx=7}{\to}} \htmlData{mx=6}{\mathbb{R}}}, b0:Fin⁡ D→Bool⁡\htmlData{mx=5}{b_{0} : \htmlData{mx=2}{\htmlData{mx=0}{\operatorname{Fin}}\,\htmlData{mx=1}{D}} \mathrel{\htmlData{mx=4}{\to}} \htmlData{mx=3}{\operatorname{Bool}}}, δ∈R\htmlData{mx=1}{\delta \in \htmlData{mx=0}{\mathbb{R}}}, M′:N→(Fin⁡ D→Bool⁡)→R\htmlData{mx=9}{M' : \htmlData{mx=0}{\mathbb{N}} \mathrel{\htmlData{mx=8}{\to}} (\htmlData{mx=3}{\htmlData{mx=1}{\operatorname{Fin}}\,\htmlData{mx=2}{D}} \mathrel{\htmlData{mx=5}{\to}} \htmlData{mx=4}{\operatorname{Bool}}) \mathrel{\htmlData{mx=7}{\to}} \htmlData{mx=6}{\mathbb{R}}} and p,η,N,O∈R\htmlData{mx=1}{p, \eta, N, O \in \htmlData{mx=0}{\mathbb{R}}}, if ∀b, 0<w(b)\htmlData{mx=4}{\forall b,\ 0 \mathrel{\htmlData{mx=3}{<}} \htmlData{mx=2}{\htmlData{mx=0}{w}(\htmlData{mx=1}{b})}}, ∀ℓ,b, M(ℓ,b)=∑b′:Fin⁡ D→Bool⁡({w(b′)if (∀i:Fin⁡ D, i<ℓ  ⟹  b′(i)=b(i))0otherwise)\htmlData{mx=31}{\forall \ell, b,\ \htmlData{mx=3}{\htmlData{mx=0}{M}(\htmlData{mx=1}{\ell}, \htmlData{mx=2}{b})} \mathrel{\htmlData{mx=30}{=}} \htmlData{mx=29}{\sum_{b' : \htmlData{mx=6}{\htmlData{mx=4}{\operatorname{Fin}}\,\htmlData{mx=5}{D}} \mathrel{\htmlData{mx=8}{\to}} \htmlData{mx=7}{\operatorname{Bool}}} \left(\htmlData{mx=28}{\begin{cases} \htmlData{mx=11}{\htmlData{mx=9}{w}(\htmlData{mx=10}{b'})} & \text{if } (\htmlData{mx=27}{\forall i : \htmlData{mx=26}{\htmlData{mx=24}{\operatorname{Fin}}\,\htmlData{mx=25}{D}},\ \htmlData{mx=13}{\htmlData{mx=12}{i}} \mathrel{\htmlData{mx=15}{<}} \htmlData{mx=14}{\ell} \mathrel{\htmlData{mx=23}{\implies}} \htmlData{mx=18}{\htmlData{mx=16}{b'}(\htmlData{mx=17}{i})} \mathrel{\htmlData{mx=22}{=}} \htmlData{mx=21}{\htmlData{mx=19}{b}(\htmlData{mx=20}{i})}}) \\ 0 & \text{otherwise} \end{cases}}\right)}}, ∀ℓ,b, M′(ℓ,b)=∑b′:Fin⁡ D→Bool⁡({w(b′)+{δif b′=b00otherwiseif (∀i:Fin⁡ D, i<ℓ  ⟹  b′(i)=b(i))0otherwise)\htmlData{mx=37}{\forall \ell, b,\ \htmlData{mx=3}{\htmlData{mx=0}{M'}(\htmlData{mx=1}{\ell}, \htmlData{mx=2}{b})} \mathrel{\htmlData{mx=36}{=}} \htmlData{mx=35}{\sum_{b' : \htmlData{mx=6}{\htmlData{mx=4}{\operatorname{Fin}}\,\htmlData{mx=5}{D}} \mathrel{\htmlData{mx=8}{\to}} \htmlData{mx=7}{\operatorname{Bool}}} \left(\htmlData{mx=34}{\begin{cases} \htmlData{mx=17}{\htmlData{mx=11}{\htmlData{mx=9}{w}(\htmlData{mx=10}{b'})} + \htmlData{mx=16}{\begin{cases} \htmlData{mx=12}{\delta} & \text{if } \htmlData{mx=13}{b'} \mathrel{\htmlData{mx=15}{=}} \htmlData{mx=14}{b_{0}} \\ 0 & \text{otherwise} \end{cases}}} & \text{if } (\htmlData{mx=33}{\forall i : \htmlData{mx=32}{\htmlData{mx=30}{\operatorname{Fin}}\,\htmlData{mx=31}{D}},\ \htmlData{mx=19}{\htmlData{mx=18}{i}} \mathrel{\htmlData{mx=21}{<}} \htmlData{mx=20}{\ell} \mathrel{\htmlData{mx=29}{\implies}} \htmlData{mx=24}{\htmlData{mx=22}{b'}(\htmlData{mx=23}{i})} \mathrel{\htmlData{mx=28}{=}} \htmlData{mx=27}{\htmlData{mx=25}{b}(\htmlData{mx=26}{i})}}) \\ 0 & \text{otherwise} \end{cases}}\right)}}, e−2⋅η≤p\htmlData{mx=3}{e^{\htmlData{mx=2}{\htmlData{mx=0}{-2} \cdot \htmlData{mx=1}{\eta}}}} \mathrel{\htmlData{mx=5}{\leq}} \htmlData{mx=4}{p}, p≤1\htmlData{mx=0}{p} \mathrel{\htmlData{mx=1}{\leq}} 1, 0≤N0 \mathrel{\htmlData{mx=1}{\leq}} \htmlData{mx=0}{N} and 0≤O0 \mathrel{\htmlData{mx=1}{\leq}} \htmlData{mx=0}{O}, then

(∀b, ∏ℓ=0D−1M(ℓ+1,b)M(ℓ,b)=w(b)∑b′w(b′))∧(∀ℓ,b,M′(ℓ,b)−M(ℓ,b)={δif (∀i:Fin⁡ D, i<ℓ  ⟹  b0(i)=b(i))0otherwise)∧(∑k∈N(k+1)⋅p⋅(1−p)k=1p)∧(D+1+N⋅(1p)⋅(D+1)+O≤D+1+N⋅e2η⋅(D+1)+O)\begin{aligned} & \left(\htmlData{mx=22}{\forall b,\ \htmlData{mx=12}{\prod_{\ell=0}^{\htmlData{mx=1}{D} - 1} \htmlData{mx=11}{\frac{\htmlData{mx=6}{\htmlData{mx=2}{M}(\htmlData{mx=4}{\htmlData{mx=3}{\ell} + 1}, \htmlData{mx=5}{b})}}{\htmlData{mx=10}{\htmlData{mx=7}{M}(\htmlData{mx=8}{\ell}, \htmlData{mx=9}{b})}}}} \mathrel{\htmlData{mx=21}{=}} \htmlData{mx=20}{\frac{\htmlData{mx=15}{\htmlData{mx=13}{w}(\htmlData{mx=14}{b})}}{\htmlData{mx=19}{\sum_{b'} \htmlData{mx=18}{\htmlData{mx=16}{w}(\htmlData{mx=17}{b'})}}}}}\right) \\ & \htmlData{mx=0}{\land} \left(\right. \htmlData{mx=23}{\forall} \ell, b, \\ & \quad \htmlData{mx=33}{\htmlData{mx=28}{\htmlData{mx=25}{M'}(\htmlData{mx=26}{\ell}, \htmlData{mx=27}{b})} - \htmlData{mx=32}{\htmlData{mx=29}{M}(\htmlData{mx=30}{\ell}, \htmlData{mx=31}{b})}} \\ & \quad \quad \htmlData{mx=24}{=} \htmlData{mx=51}{\begin{cases} \htmlData{mx=34}{\delta} & \text{if } (\htmlData{mx=50}{\forall i : \htmlData{mx=49}{\htmlData{mx=47}{\operatorname{Fin}}\,\htmlData{mx=48}{D}},\ \htmlData{mx=36}{\htmlData{mx=35}{i}} \mathrel{\htmlData{mx=38}{<}} \htmlData{mx=37}{\ell} \mathrel{\htmlData{mx=46}{\implies}} \htmlData{mx=41}{\htmlData{mx=39}{b_{0}}(\htmlData{mx=40}{i})} \mathrel{\htmlData{mx=45}{=}} \htmlData{mx=44}{\htmlData{mx=42}{b}(\htmlData{mx=43}{i})}}) \\ 0 & \text{otherwise} \end{cases}} \left.\right) \\ & \htmlData{mx=0}{\land} \left(\htmlData{mx=63}{\sum_{k \in \htmlData{mx=52}{\mathbb{N}}} \htmlData{mx=62}{\htmlData{mx=57}{(\htmlData{mx=55}{\htmlData{mx=54}{\htmlData{mx=53}{k}} + 1}) \cdot \htmlData{mx=56}{p}} \cdot \htmlData{mx=61}{(\htmlData{mx=59}{1 - \htmlData{mx=58}{p}})^{\htmlData{mx=60}{k}}}}} \mathrel{\htmlData{mx=66}{=}} \htmlData{mx=65}{\frac{1}{\htmlData{mx=64}{p}}}\right) \\ & \htmlData{mx=0}{\land} \left(\right. \htmlData{mx=80}{\htmlData{mx=78}{\htmlData{mx=70}{\htmlData{mx=69}{\htmlData{mx=68}{D} + 1}} + \htmlData{mx=77}{\htmlData{mx=74}{\htmlData{mx=71}{N} \cdot \left(\htmlData{mx=73}{\frac{1}{\htmlData{mx=72}{p}}}\right)} \cdot (\htmlData{mx=76}{\htmlData{mx=75}{D} + 1})}} + \htmlData{mx=79}{O}} \\ & \quad \htmlData{mx=67}{\leq} \htmlData{mx=94}{\htmlData{mx=92}{\htmlData{mx=83}{\htmlData{mx=82}{\htmlData{mx=81}{D} + 1}} + \htmlData{mx=91}{\htmlData{mx=88}{\htmlData{mx=84}{N} \cdot \htmlData{mx=87}{e^{\htmlData{mx=86}{2\htmlData{mx=85}{\eta}}}}} \cdot (\htmlData{mx=90}{\htmlData{mx=89}{D} + 1})}} + \htmlData{mx=93}{O}} \left.\right) \end{aligned}
What the notation means · or point at any symbol
NNatural numbers
The natural numbers 0, 1, 2, …. In Lean they start at 0. (ℕ)
∀For all
The statement after the comma holds for every b. (∀ b, 0 < w b)
x ∈ TVariables
p, η, N, O range over real numbers: the statement must hold for every choice. ((p η N O : ℝ))
eˣExponential function
e raised to the power −2 · η, where e ≈ 2.718. (Real.exp (-2 * η))
≤At most
exp(−2 · η) is less than or equal to p. (Real.exp (-2 * η) ≤ p)
Fin
Fin: a definition from the library, not special notation. Its name is its meaning; open it in Lean to see how it is defined. (Fin)
f(x)Function application
Fin applied to D. Lean writes f x; papers write f(x). (Fin D)
⟹Implies
If Fin(D), then Bool. (Between types, A → B is the type of functions from A to B.) (Fin D → Bool)
<Less than
0 is strictly smaller than w(b). (0 < w b)
∏Product
Multiply together M(ℓ + 1, b)/M(ℓ, b) for ℓ = 0, 1, …, D − 1. (∏ ℓ ∈ Finset.range D, (M (ℓ + 1) b / M …)
Bool
Bool: a definition from the library, not special notation. Its name is its meaning; open it in Lean to see how it is defined. (Bool)
−xNegation
The negative of 2. (-2)
·Multiplication
−2 times η. (-2 * η)
∑Summation
Add up w(b') if ∀ i, i < ℓ → b'(i) = b(i), else 0 for every b' in Fin(D) → Bool. (∑ b' : Fin D → Bool, (if (∀ i : Fin D, …)
RReal numbers
The real numbers: every point on the number line. (ℝ)
a/bDivision
M(ℓ + 1, b) divided by M(ℓ, b). In Lean, dividing by 0 gives 0. (M (ℓ + 1) b / M ℓ b)
{ a if c; b otherwiseCases (if … then … else)
w(b') when ∀ i, i < ℓ → b'(i) = b(i), and 0 otherwise. (if (∀ i : Fin D, (i : ℕ) < ℓ → b' i = b…)
(x : T)As natural numbers
i read as an element of natural numbers. Mathematicians leave this implicit; Lean needs it to know which kind of number is meant. ((i : ℕ))
=Equality
b'(i) and b(i) are the same. (b' i = b i)
-Subtraction
M'(ℓ, b) minus M(ℓ, b). On ℕ, Lean's subtraction stops at 0: 2 − 5 = 0. (M' ℓ b - M ℓ b)
+Addition
w(b') plus δ if b' = b₀, else 0. (w b' + if b' = b₀ then δ else 0)
∧And
Both hold: (∑' k, (k + 1) · p · (1 − p)^k) = 1/p, and D + 1 + N · (1/p) · (D + 1) + O ≤ D + 1 + N · exp(2 · η) ·…. ((∑' k : ℕ, ((k : ℝ) + 1) * p * (1 - p) …)
∑'Infinite sum
Add up (k + 1) · p · (1 − p)^k for every k in ℕ. (∑' k : ℕ, ((k : ℝ) + 1) * p * (1 - p) ^…)
(x : T)As real numbers
k read as an element of real numbers. Mathematicians leave this implicit; Lean needs it to know which kind of number is meant. ((k : ℝ))
aᵇPower
1 − p raised to the power k. ((1 - p) ^ k)

Answers the round-1/3 objection (codex) that no persistent-snapshot cost or traffic law was proven, within an explicit read-count model. Keys are the 2^D leaves of a sum-tree whose node at level ℓ stores the prefix mass M(ℓ, b) of snapshot weights w > 0. (1) Exactness: descending by child/parent mass ratios reaches each key with probability exactly w(b)/Σw (telescoping). (2) Locality: appending weight δ to key b₀ changes M(ℓ, b) by δ exactly on b₀'s path and by 0 elsewhere, so an insertion writes D+1 nodes. (3) Draws: the expected number of draws per accepted rejection sample is exactly 1/p (geometric series), and with acceptance p ≥ e^{−2η} the expected reads per token (one insertion, N samples each costing a D-node descent plus one key read per draw, plus |overflow| keys read exactly) are at most (D+1) + N·e^{2η}·(D+1) + |overflow|, against n reads for exact decode. Scope: a read-count model, not wall-clock; overflow and acceptance as hypotheses (acceptance proven in drift-persistent-snapshot-cost, overflow by the box/residual certificate).

How it was proved

Proved
5 October 2026
By
Ajax, with the agent “Baguette math & proofs (Claude Code, 2026-10-03)”
Checked by
Lean's kernel (Lean 4.33.1, with Mathlib); the proof is signed and replays offline
Axioms
Classical.choice, Quot.sound, propext
Proof
84 lines of Lean
Sign in to see the proofThe proof, its signed report and its history.

More proved statements