proofs
Proveddrift-lawdecodeheadline-theoremsingle-statement

Drift Law, one statement: norm-tier certificate |t−s| ≤ ‖q_t−q_s‖κ off O; exact envelope sampling, draws ≤ e^{2δκ}; stratified IS factor ≤ cosh²(δκ); tree reads ≤ (D+1)(1+Ne^{2δκ})+|O|

For all J∈Type⁡\htmlData{mx=1}{J \in \htmlData{mx=0}{\operatorname{Type}}}, d∈N\htmlData{mx=1}{d \in \htmlData{mx=0}{\mathbb{N}}}, k:J→Fin⁡ d→R\htmlData{mx=7}{k : \htmlData{mx=0}{J} \mathrel{\htmlData{mx=6}{\to}} \htmlData{mx=3}{\htmlData{mx=1}{\operatorname{Fin}}\,\htmlData{mx=2}{d}} \mathrel{\htmlData{mx=5}{\to}} \htmlData{mx=4}{\mathbb{R}}}, qs,qt:Fin⁡ d→R\htmlData{mx=5}{\mathit{qs}, \mathit{qt} : \htmlData{mx=2}{\htmlData{mx=0}{\operatorname{Fin}}\,\htmlData{mx=1}{d}} \mathrel{\htmlData{mx=4}{\to}} \htmlData{mx=3}{\mathbb{R}}}, O∈Finset⁡ J\htmlData{mx=3}{O \in \htmlData{mx=2}{\htmlData{mx=0}{\operatorname{Finset}}\,\htmlData{mx=1}{J}}}, κ,δ∈R\htmlData{mx=1}{\kappa, \delta \in \htmlData{mx=0}{\mathbb{R}}}, s,t:J→R\htmlData{mx=3}{s, t : \htmlData{mx=0}{J} \mathrel{\htmlData{mx=2}{\to}} \htmlData{mx=1}{\mathbb{R}}}, m:J→R\htmlData{mx=3}{m : \htmlData{mx=0}{J} \mathrel{\htmlData{mx=2}{\to}} \htmlData{mx=1}{\mathbb{R}}}, M,Zt,p∈R\htmlData{mx=1}{M, \mathit{Zt}, p \in \htmlData{mx=0}{\mathbb{R}}} and N,D∈R\htmlData{mx=1}{N, D \in \htmlData{mx=0}{\mathbb{R}}}, if 0≤κ0 \mathrel{\htmlData{mx=1}{\leq}} \htmlData{mx=0}{\kappa}, ∀j, j∉O  ⟹  ∑ik(j,i)2≤κ2\htmlData{mx=13}{\forall j,\ \htmlData{mx=0}{j} \mathrel{\htmlData{mx=2}{\notin}} \htmlData{mx=1}{O} \mathrel{\htmlData{mx=12}{\implies}} \htmlData{mx=8}{\sum_{i} \htmlData{mx=7}{\htmlData{mx=6}{\htmlData{mx=3}{k}(\htmlData{mx=4}{j}, \htmlData{mx=5}{i})}^{2}}} \mathrel{\htmlData{mx=11}{\leq}} \htmlData{mx=10}{\htmlData{mx=9}{\kappa}^{2}}}, δ=∑i(qt(i)−qs(i))2\htmlData{mx=0}{\delta} \mathrel{\htmlData{mx=11}{=}} \htmlData{mx=10}{\sqrt{\htmlData{mx=9}{\sum_{i} \htmlData{mx=8}{(\htmlData{mx=7}{\htmlData{mx=3}{\htmlData{mx=1}{\mathit{qt}}(\htmlData{mx=2}{i})} - \htmlData{mx=6}{\htmlData{mx=4}{\mathit{qs}}(\htmlData{mx=5}{i})}})^{2}}}}}, ∀j, s(j)=∑iqs(i)⋅k(j,i)\htmlData{mx=13}{\forall j,\ \htmlData{mx=2}{\htmlData{mx=0}{s}(\htmlData{mx=1}{j})} \mathrel{\htmlData{mx=12}{=}} \htmlData{mx=11}{\sum_{i} \htmlData{mx=10}{\htmlData{mx=5}{\htmlData{mx=3}{\mathit{qs}}(\htmlData{mx=4}{i})} \cdot \htmlData{mx=9}{\htmlData{mx=6}{k}(\htmlData{mx=7}{j}, \htmlData{mx=8}{i})}}}}, ∀j, t(j)=∑iqt(i)⋅k(j,i)\htmlData{mx=13}{\forall j,\ \htmlData{mx=2}{\htmlData{mx=0}{t}(\htmlData{mx=1}{j})} \mathrel{\htmlData{mx=12}{=}} \htmlData{mx=11}{\sum_{i} \htmlData{mx=10}{\htmlData{mx=5}{\htmlData{mx=3}{\mathit{qt}}(\htmlData{mx=4}{i})} \cdot \htmlData{mx=9}{\htmlData{mx=6}{k}(\htmlData{mx=7}{j}, \htmlData{mx=8}{i})}}}}, ∀j, m(j)={et(j)if j∈Oeδ⋅κ⋅es(j)otherwise\htmlData{mx=21}{\forall j,\ \htmlData{mx=2}{\htmlData{mx=0}{m}(\htmlData{mx=1}{j})} \mathrel{\htmlData{mx=20}{=}} \htmlData{mx=19}{\begin{cases} \htmlData{mx=6}{e^{\htmlData{mx=5}{\htmlData{mx=3}{t}(\htmlData{mx=4}{j})}}} & \text{if } \htmlData{mx=7}{j} \mathrel{\htmlData{mx=9}{\in}} \htmlData{mx=8}{O} \\ \htmlData{mx=18}{\htmlData{mx=13}{e^{\htmlData{mx=12}{\htmlData{mx=10}{\delta} \cdot \htmlData{mx=11}{\kappa}}}} \cdot \htmlData{mx=17}{e^{\htmlData{mx=16}{\htmlData{mx=14}{s}(\htmlData{mx=15}{j})}}}} & \text{otherwise} \end{cases}}}, M=∑jm(j)\htmlData{mx=0}{M} \mathrel{\htmlData{mx=5}{=}} \htmlData{mx=4}{\sum_{j} \htmlData{mx=3}{\htmlData{mx=1}{m}(\htmlData{mx=2}{j})}}, Zt=∑jet(j)\htmlData{mx=0}{\mathit{Zt}} \mathrel{\htmlData{mx=6}{=}} \htmlData{mx=5}{\sum_{j} \htmlData{mx=4}{e^{\htmlData{mx=3}{\htmlData{mx=1}{t}(\htmlData{mx=2}{j})}}}}, p=∑jm(j)M⋅(et(j)m(j))\htmlData{mx=0}{p} \mathrel{\htmlData{mx=16}{=}} \htmlData{mx=15}{\sum_{j} \htmlData{mx=14}{\htmlData{mx=5}{\frac{\htmlData{mx=3}{\htmlData{mx=1}{m}(\htmlData{mx=2}{j})}}{\htmlData{mx=4}{M}}} \cdot \left(\htmlData{mx=13}{\frac{\htmlData{mx=9}{e^{\htmlData{mx=8}{\htmlData{mx=6}{t}(\htmlData{mx=7}{j})}}}}{\htmlData{mx=12}{\htmlData{mx=10}{m}(\htmlData{mx=11}{j})}}}\right)}}, 0≤N0 \mathrel{\htmlData{mx=1}{\leq}} \htmlData{mx=0}{N}, 0≤D0 \mathrel{\htmlData{mx=1}{\leq}} \htmlData{mx=0}{D} and ∃j, j∉O\htmlData{mx=3}{\exists j,\ \htmlData{mx=0}{j} \mathrel{\htmlData{mx=2}{\notin}} \htmlData{mx=1}{O}} (given Fintype⁡ J\htmlData{mx=2}{\htmlData{mx=0}{\operatorname{Fintype}}\,\htmlData{mx=1}{J}}, Nonempty⁡ J\htmlData{mx=2}{\htmlData{mx=0}{\operatorname{Nonempty}}\,\htmlData{mx=1}{J}} and DecidableEq⁡ J\htmlData{mx=2}{\htmlData{mx=0}{\operatorname{DecidableEq}}\,\htmlData{mx=1}{J}}), then

((∀j, j∉O  ⟹  ∣t(j)−s(j)∣≤δ⋅κ)∧(∀j, 0<m(j)∧et(j)≤m(j))∧p=ZtM∧(∀j, m(j)M⋅(et(j)m(j))p=et(j)Zt)∧(∑n∈N(n+1)⋅p⋅(1−p)n=MZt)∧MZt≤e2δ⋅κ)∧((∑j∈filter⁡(j↦j∉O)e2t(j)−s(j))⋅(∑j∈filter⁡(j↦j∉O)es(j))≤cosh⁡(δ⋅κ)2⋅(∑j∈filter⁡(j↦j∉O)et(j))2)∧(D+1+N⋅(MZt)⋅(D+1)+card⁡≤(D+1)⋅(1+N⋅e2δ⋅κ)+card⁡)\begin{aligned} & \left(\right. (\htmlData{mx=18}{\forall j,\ \htmlData{mx=2}{j} \mathrel{\htmlData{mx=4}{\notin}} \htmlData{mx=3}{O} \mathrel{\htmlData{mx=17}{\implies}} \htmlData{mx=12}{\left\lvert \htmlData{mx=11}{\htmlData{mx=7}{\htmlData{mx=5}{t}(\htmlData{mx=6}{j})} - \htmlData{mx=10}{\htmlData{mx=8}{s}(\htmlData{mx=9}{j})}} \right\rvert} \mathrel{\htmlData{mx=16}{\leq}} \htmlData{mx=15}{\htmlData{mx=13}{\delta} \cdot \htmlData{mx=14}{\kappa}}}) \\ & \htmlData{mx=1}{\land} (\htmlData{mx=32}{\forall j,\ 0 \mathrel{\htmlData{mx=22}{<}} \htmlData{mx=21}{\htmlData{mx=19}{m}(\htmlData{mx=20}{j})} \mathbin{\htmlData{mx=31}{\land}} \htmlData{mx=26}{e^{\htmlData{mx=25}{\htmlData{mx=23}{t}(\htmlData{mx=24}{j})}}} \mathrel{\htmlData{mx=30}{\leq}} \htmlData{mx=29}{\htmlData{mx=27}{m}(\htmlData{mx=28}{j})}}) \\ & \htmlData{mx=1}{\land} \htmlData{mx=33}{p} \mathrel{\htmlData{mx=37}{=}} \htmlData{mx=36}{\frac{\htmlData{mx=34}{\mathit{Zt}}}{\htmlData{mx=35}{M}}} \\ & \htmlData{mx=1}{\land} \left(\htmlData{mx=61}{\forall j,\ \htmlData{mx=53}{\frac{\htmlData{mx=51}{\htmlData{mx=42}{\frac{\htmlData{mx=40}{\htmlData{mx=38}{m}(\htmlData{mx=39}{j})}}{\htmlData{mx=41}{M}}} \cdot \left(\htmlData{mx=50}{\frac{\htmlData{mx=46}{e^{\htmlData{mx=45}{\htmlData{mx=43}{t}(\htmlData{mx=44}{j})}}}}{\htmlData{mx=49}{\htmlData{mx=47}{m}(\htmlData{mx=48}{j})}}}\right)}}{\htmlData{mx=52}{p}}} \mathrel{\htmlData{mx=60}{=}} \htmlData{mx=59}{\frac{\htmlData{mx=57}{e^{\htmlData{mx=56}{\htmlData{mx=54}{t}(\htmlData{mx=55}{j})}}}}{\htmlData{mx=58}{\mathit{Zt}}}}}\right) \\ & \htmlData{mx=1}{\land} \left(\htmlData{mx=73}{\sum_{n \in \htmlData{mx=62}{\mathbb{N}}} \htmlData{mx=72}{\htmlData{mx=67}{(\htmlData{mx=65}{\htmlData{mx=64}{\htmlData{mx=63}{n}} + 1}) \cdot \htmlData{mx=66}{p}} \cdot \htmlData{mx=71}{(\htmlData{mx=69}{1 - \htmlData{mx=68}{p}})^{\htmlData{mx=70}{n}}}}} \mathrel{\htmlData{mx=77}{=}} \htmlData{mx=76}{\frac{\htmlData{mx=74}{M}}{\htmlData{mx=75}{\mathit{Zt}}}}\right) \\ & \htmlData{mx=1}{\land} \htmlData{mx=80}{\frac{\htmlData{mx=78}{M}}{\htmlData{mx=79}{\mathit{Zt}}}} \mathrel{\htmlData{mx=86}{\leq}} \htmlData{mx=85}{e^{\htmlData{mx=84}{\htmlData{mx=82}{2\htmlData{mx=81}{\delta}} \cdot \htmlData{mx=83}{\kappa}}}} \left.\right) \\ & \htmlData{mx=0}{\land} \left(\right. \htmlData{mx=115}{\left(\htmlData{mx=103}{\sum_{j \in \htmlData{mx=93}{\htmlData{mx=88}{\operatorname{filter}}(\htmlData{mx=92}{j \mapsto \htmlData{mx=89}{j} \mathrel{\htmlData{mx=91}{\notin}} \htmlData{mx=90}{O}})}} \htmlData{mx=102}{e^{\htmlData{mx=101}{\htmlData{mx=97}{2\htmlData{mx=96}{\htmlData{mx=94}{t}(\htmlData{mx=95}{j})}} - \htmlData{mx=100}{\htmlData{mx=98}{s}(\htmlData{mx=99}{j})}}}}}\right) \cdot \left(\htmlData{mx=114}{\sum_{j \in \htmlData{mx=109}{\htmlData{mx=104}{\operatorname{filter}}(\htmlData{mx=108}{j \mapsto \htmlData{mx=105}{j} \mathrel{\htmlData{mx=107}{\notin}} \htmlData{mx=106}{O}})}} \htmlData{mx=113}{e^{\htmlData{mx=112}{\htmlData{mx=110}{s}(\htmlData{mx=111}{j})}}}}\right)} \\ & \quad \htmlData{mx=87}{\leq} \htmlData{mx=133}{\htmlData{mx=120}{\htmlData{mx=119}{\cosh (\htmlData{mx=118}{\htmlData{mx=116}{\delta} \cdot \htmlData{mx=117}{\kappa}})}^{2}} \cdot \htmlData{mx=132}{\left(\htmlData{mx=131}{\sum_{j \in \htmlData{mx=126}{\htmlData{mx=121}{\operatorname{filter}}(\htmlData{mx=125}{j \mapsto \htmlData{mx=122}{j} \mathrel{\htmlData{mx=124}{\notin}} \htmlData{mx=123}{O}})}} \htmlData{mx=130}{e^{\htmlData{mx=129}{\htmlData{mx=127}{t}(\htmlData{mx=128}{j})}}}}\right)^{2}}} \left.\right) \\ & \htmlData{mx=0}{\land} \left(\right. \htmlData{mx=148}{\htmlData{mx=145}{\htmlData{mx=136}{\htmlData{mx=135}{D} + 1} + \htmlData{mx=144}{\htmlData{mx=141}{\htmlData{mx=137}{N} \cdot \left(\htmlData{mx=140}{\frac{\htmlData{mx=138}{M}}{\htmlData{mx=139}{\mathit{Zt}}}}\right)} \cdot (\htmlData{mx=143}{\htmlData{mx=142}{D} + 1})}} + \htmlData{mx=147}{\htmlData{mx=146}{\operatorname{card}}}} \\ & \quad \htmlData{mx=134}{\leq} \htmlData{mx=162}{\htmlData{mx=159}{(\htmlData{mx=150}{\htmlData{mx=149}{D} + 1}) \cdot (\htmlData{mx=158}{1 + \htmlData{mx=157}{\htmlData{mx=151}{N} \cdot \htmlData{mx=156}{e^{\htmlData{mx=155}{\htmlData{mx=153}{2\htmlData{mx=152}{\delta}} \cdot \htmlData{mx=154}{\kappa}}}}}})} + \htmlData{mx=161}{\htmlData{mx=160}{\operatorname{card}}}} \left.\right) \end{aligned}
What the notation means · or point at any symbol
Type
Type: a definition from the library, not special notation. Its name is its meaning; open it in Lean to see how it is defined. (Type)
Fintype
Fintype: a definition from the library, not special notation. Its name is its meaning; open it in Lean to see how it is defined. (Fintype)
f(x)Function application
Fintype applied to J. Lean writes f x; papers write f(x). (Fintype J)
Nonempty
Nonempty: a definition from the library, not special notation. Its name is its meaning; open it in Lean to see how it is defined. (Nonempty)
DecidableEq
DecidableEq: a definition from the library, not special notation. Its name is its meaning; open it in Lean to see how it is defined. (DecidableEq)
NNatural numbers
The natural numbers 0, 1, 2, …. In Lean they start at 0. (ℕ)
x : TVariables
qs, qt range over Fin d → ℝ: the statement must hold for every choice. ((qs qt : Fin d → ℝ))
Finset
Finset: a definition from the library, not special notation. Its name is its meaning; open it in Lean to see how it is defined. (Finset)
x ∈ TVariables
κ, δ range over real numbers: the statement must hold for every choice. ((κ δ : ℝ))
≤At most
0 is less than or equal to κ. (0 ≤ κ)
∀For all
The statement after the comma holds for every j. (∀ j, j ∉ O → ∑ i, k j i ^ 2 ≤ κ ^ 2)
=Equality
δ and √(∑ i, (qt(i) − qs(i))^2) are the same. (δ = Real.sqrt (∑ i, (qt i - qs i) ^ 2))
∃There exists
At least one j makes the statement after the comma true. (∃ j, j ∉ O)
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)
⟹Implies
If Fin(d), then ℝ. (Between types, A → B is the type of functions from A to B.) (Fin d → ℝ)
√Square root
The non-negative number whose square is ∑ i, (qt(i) − qs(i))^2. (Real.sqrt (∑ i, (qt i - qs i) ^ 2))
∉Not an element of
j is not a member of O. (j ∉ O)
a/bDivision
m(j) divided by M. In Lean, dividing by 0 gives 0. (m j / M)
{ a if c; b otherwiseCases (if … then … else)
exp(t(j)) when j ∈ O, and exp(δ · κ) · exp(s(j)) otherwise. (if j ∈ O then Real.exp (t j) else Real.…)
RReal numbers
The real numbers: every point on the number line. (ℝ)
∑Summation
Add up k(j, i)^2 for every i. (∑ i, k j i ^ 2)
∈Element of
j is a member of O. (j ∈ O)
|x|Absolute value
The size of t(j) − s(j) without its sign. (|t j - s j|)
·Multiplication
qs(i) times k(j, i). (qs i * k j i)
aᵇPower
k(j, i) raised to the power 2. (k j i ^ 2)
-Subtraction
qt(i) minus qs(i). On ℕ, Lean's subtraction stops at 0: 2 − 5 = 0. (qt i - qs i)
eˣExponential function
e raised to the power t(j), where e ≈ 2.718. (Real.exp (t j))
<Less than
0 is strictly smaller than m(j). (0 < m j)
∧And
Both hold: 0 < m(j), and exp(t(j)) ≤ m(j). (0 < m j ∧ Real.exp (t j) ≤ m j)
∑'Infinite sum
Add up (n + 1) · p · (1 − p)^n for every n in ℕ. (∑' n : ℕ, ((n : ℝ) + 1) * p * (1 - p) ^…)
(x : T)As real numbers
n read as an element of real numbers. Mathematicians leave this implicit; Lean needs it to know which kind of number is meant. ((n : ℝ))
+Addition
n plus 1. ((n : ℝ) + 1)
filter
Finset.univ.filter: a definition from the library, not special notation. Its name is its meaning; open it in Lean to see how it is defined. (Finset.univ.filter)
x ↦ f(x)Function (λ-abstraction)
The function sending j to j ∉ O. Lean writes fun x => …; papers write x ↦ …. (fun j => j ∉ O)
coshHyperbolic cosine
(eˣ + e⁻ˣ)/2 at δ · κ. (Real.cosh (δ * κ))
card
O.card: a definition from the library, not special notation. Its name is its meaning; open it in Lean to see how it is defined. (O.card)

The strongest provable single statement of the Drift Law for decode reuse. Keys k_j, snapshot query q_s, current query q_t, δ = ‖q_t − q_s‖, exceptional set O containing every key of norm > κ. Then: (i) every key outside O drifts by at most δκ in score; (ii) the envelope m = e^{t} on O and e^{δκ}e^{s} off O dominates the current weights, rejection from m/M accepts with probability Z_t/M, accepted keys follow the current row exactly, the expected draws per accepted sample are M/Z_t (geometric series) and M/Z_t ≤ e^{2δκ}; (iii) importance sampling from the stale snapshot on the complement of O has second-moment factor (Σ_{∉O} e^{2t−s})(Σ_{∉O} e^{s}) ≤ cosh²(δκ)(Σ_{∉O} e^{t})²; (iv) for N samples from a depth-D sum-tree with one insertion per token, expected tree reads (D+1) + N(M/Z_t)(D+1) + |O| ≤ (D+1)(1 + N e^{2δκ}) + |O|, independent of the context length apart from D and |O|. Read-count model only: tree construction, path reweighting for O, key/value vector reads and the refresh schedule are charged in prose, not here. Conjoins drift-norm-tiered-exact-decode and drift-stratified-oscillation-bound.

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

More proved statements