proofs
Proveddrift-lawdecodesum-treetraffic

Persistent-snapshot traffic, end-to-end: the sampler's actual acceptance rate p = e^{−η}Z_t/Z_s drives the read bound (D+1) + N·(1/p)·(D+1) + |overflow| ≤ (D+1) + N·e^{2η}·(D+1) + |overflow|

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

(∀b, ∏ℓ=0D−1M(ℓ+1,b)M(ℓ,b)=es(b)∑b′es(b′))∧(∀ℓ,b,M′(ℓ,b)−M(ℓ,b)={δif (∀i:Fin⁡ D, i<ℓ  ⟹  b0(i)=b(i))0otherwise)∧(∀j, es(j)Zs⋅et(j)−s(j)−ηp=et(j)Zt)∧p=e−η⋅ZtZs∧(∑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=24}{\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=23}{=}} \htmlData{mx=22}{\frac{\htmlData{mx=16}{e^{\htmlData{mx=15}{\htmlData{mx=13}{s}(\htmlData{mx=14}{b})}}}}{\htmlData{mx=21}{\sum_{b'} \htmlData{mx=20}{e^{\htmlData{mx=19}{\htmlData{mx=17}{s}(\htmlData{mx=18}{b'})}}}}}}}\right) \\ & \htmlData{mx=0}{\land} \left(\right. \htmlData{mx=25}{\forall} \ell, b, \\ & \quad \htmlData{mx=35}{\htmlData{mx=30}{\htmlData{mx=27}{M'}(\htmlData{mx=28}{\ell}, \htmlData{mx=29}{b})} - \htmlData{mx=34}{\htmlData{mx=31}{M}(\htmlData{mx=32}{\ell}, \htmlData{mx=33}{b})}} \\ & \quad \quad \htmlData{mx=26}{=} \htmlData{mx=53}{\begin{cases} \htmlData{mx=36}{\delta} & \text{if } (\htmlData{mx=52}{\forall i : \htmlData{mx=51}{\htmlData{mx=49}{\operatorname{Fin}}\,\htmlData{mx=50}{D}},\ \htmlData{mx=38}{\htmlData{mx=37}{i}} \mathrel{\htmlData{mx=40}{<}} \htmlData{mx=39}{\ell} \mathrel{\htmlData{mx=48}{\implies}} \htmlData{mx=43}{\htmlData{mx=41}{b_{0}}(\htmlData{mx=42}{i})} \mathrel{\htmlData{mx=47}{=}} \htmlData{mx=46}{\htmlData{mx=44}{b}(\htmlData{mx=45}{i})}}) \\ 0 & \text{otherwise} \end{cases}} \left.\right) \\ & \htmlData{mx=0}{\land} \left(\htmlData{mx=80}{\forall j,\ \htmlData{mx=72}{\frac{\htmlData{mx=70}{\htmlData{mx=59}{\frac{\htmlData{mx=57}{e^{\htmlData{mx=56}{\htmlData{mx=54}{s}(\htmlData{mx=55}{j})}}}}{\htmlData{mx=58}{\mathit{Zs}}}} \cdot \htmlData{mx=69}{e^{\htmlData{mx=68}{\htmlData{mx=66}{\htmlData{mx=62}{\htmlData{mx=60}{t}(\htmlData{mx=61}{j})} - \htmlData{mx=65}{\htmlData{mx=63}{s}(\htmlData{mx=64}{j})}} - \htmlData{mx=67}{\eta}}}}}}{\htmlData{mx=71}{p}}} \mathrel{\htmlData{mx=79}{=}} \htmlData{mx=78}{\frac{\htmlData{mx=76}{e^{\htmlData{mx=75}{\htmlData{mx=73}{t}(\htmlData{mx=74}{j})}}}}{\htmlData{mx=77}{\mathit{Zt}}}}}\right) \\ & \htmlData{mx=0}{\land} \htmlData{mx=81}{p} \mathrel{\htmlData{mx=89}{=}} \htmlData{mx=88}{\frac{\htmlData{mx=86}{\htmlData{mx=84}{e^{\htmlData{mx=83}{-\htmlData{mx=82}{\eta}}}} \cdot \htmlData{mx=85}{\mathit{Zt}}}}{\htmlData{mx=87}{\mathit{Zs}}}} \\ & \htmlData{mx=0}{\land} \left(\htmlData{mx=101}{\sum_{k \in \htmlData{mx=90}{\mathbb{N}}} \htmlData{mx=100}{\htmlData{mx=95}{(\htmlData{mx=93}{\htmlData{mx=92}{\htmlData{mx=91}{k}} + 1}) \cdot \htmlData{mx=94}{p}} \cdot \htmlData{mx=99}{(\htmlData{mx=97}{1 - \htmlData{mx=96}{p}})^{\htmlData{mx=98}{k}}}}} \mathrel{\htmlData{mx=104}{=}} \htmlData{mx=103}{\frac{1}{\htmlData{mx=102}{p}}}\right) \\ & \htmlData{mx=0}{\land} \left(\right. \htmlData{mx=118}{\htmlData{mx=116}{\htmlData{mx=108}{\htmlData{mx=107}{\htmlData{mx=106}{D} + 1}} + \htmlData{mx=115}{\htmlData{mx=112}{\htmlData{mx=109}{N} \cdot \left(\htmlData{mx=111}{\frac{1}{\htmlData{mx=110}{p}}}\right)} \cdot (\htmlData{mx=114}{\htmlData{mx=113}{D} + 1})}} + \htmlData{mx=117}{O}} \\ & \quad \htmlData{mx=105}{\leq} \htmlData{mx=132}{\htmlData{mx=130}{\htmlData{mx=121}{\htmlData{mx=120}{\htmlData{mx=119}{D} + 1}} + \htmlData{mx=129}{\htmlData{mx=126}{\htmlData{mx=122}{N} \cdot \htmlData{mx=125}{e^{\htmlData{mx=124}{2\htmlData{mx=123}{\eta}}}}} \cdot (\htmlData{mx=128}{\htmlData{mx=127}{D} + 1})}} + \htmlData{mx=131}{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. (ℕ)
x : TVariables
s, t range over (Fin D → Bool) → ℝ: the statement must hold for every choice. ((s t : (Fin D → Bool) → ℝ))
x ∈ TVariables
η, N, O, Zs, Zt, p, δ range over real numbers: the statement must hold for every choice. ((η N O Zs Zt p δ : ℝ))
∀For all
The statement after the comma holds for every j. (∀ j, |t j - s j| ≤ η)
=Equality
Zs and ∑ k, exp(s(k)) are the same. (Zs = ∑ k, Real.exp (s k))
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)
|x|Absolute value
The size of t(j) − s(j) without its sign. (|t j - s j|)
≤At most
|t(j) − s(j)| is less than or equal to η. (|t j - s j| ≤ η)
∑Summation
Add up exp(s(k)) for every k. (∑ k, Real.exp (s k))
-Subtraction
t(j) minus s(j). On ℕ, Lean's subtraction stops at 0: 2 − 5 = 0. (t j - s j)
∏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)
·Multiplication
exp(s(j))/Zs times exp(t(j) − s(j) − η). ((Real.exp (s j) / Zs) * Real.exp (t j -…)
eˣExponential function
e raised to the power s(k), where e ≈ 2.718. (Real.exp (s k))
a/bDivision
exp(s(j)) divided by Zs. In Lean, dividing by 0 gives 0. (Real.exp (s j) / Zs)
RReal numbers
The real numbers: every point on the number line. (ℝ)
{ a if c; b otherwiseCases (if … then … else)
exp(s(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 : ℕ))
<Less than
i is strictly smaller than ℓ. ((i : ℕ) < ℓ)
+Addition
exp(s(b')) plus δ if b' = b₀, else 0. (Real.exp (s b') + if b' = b₀ then δ els…)
−xNegation
The negative of η. (-η)
∧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 review round 6 (codex), which noted that drift-persistent-snapshot-traffic left the acceptance rate p as a free parameter. Here p is defined as the actual per-draw acceptance probability of rejection from the persistent snapshot (snapshot weights e^{s} in a sum-tree over 2^D keys, current scores t, pointwise drift |t − s| ≤ η). One statement: sum-tree descent reaches each key with probability e^{s_b}/Σe^{s}; appending weight δ changes only the D+1 nodes on the new key's path; accepted keys are distributed exactly as the current row e^{t}/Z_t; p = e^{−η}Z_t/Z_s; expected draws per sample = 1/p (geometric series); and the expected reads per token (insertion, N samples at D+1 reads per draw, overflow keys) are at most (D+1) + N·e^{2η}·(D+1) + |overflow|. Embeds drift-persistent-snapshot-cost and drift-persistent-snapshot-traffic. Scope: an explicit read-count model (not wall-clock), estimates are exactly unbiased, not deterministic equality with full softmax.

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
158 lines of Lean
Sign in to see the proofThe proof, its signed report and its history.

More proved statements