proofs
Provedquery-cover-lawdecode-attentionsoftmaxkv-cache

Rejection from a stale attention snapshot is exact: propose j ~ softmax(s₀), accept w.p. e^{s_t(j)−s₀(j)−M} ⇒ j ~ softmax(s_t) exactly

For all n∈N\htmlData{mx=1}{n \in \htmlData{mx=0}{\mathbb{N}}}, s0,st:Fin⁡ n→R\htmlData{mx=5}{s_{0}, \mathit{st} : \htmlData{mx=2}{\htmlData{mx=0}{\operatorname{Fin}}\,\htmlData{mx=1}{n}} \mathrel{\htmlData{mx=4}{\to}} \htmlData{mx=3}{\mathbb{R}}}, M∈R\htmlData{mx=1}{M \in \htmlData{mx=0}{\mathbb{R}}} and j∈Fin⁡ n\htmlData{mx=3}{j \in \htmlData{mx=2}{\htmlData{mx=0}{\operatorname{Fin}}\,\htmlData{mx=1}{n}}}, if 0<n0 \mathrel{\htmlData{mx=1}{<}} \htmlData{mx=0}{n}, then

es0(j)∑kes0(k)⋅est(j)−s0(j)−M∑ies0(i)∑kes0(k)⋅est(i)−s0(i)−M=est(j)∑kest(k)\begin{aligned} & \htmlData{mx=44}{\frac{\htmlData{mx=21}{\htmlData{mx=10}{\frac{\htmlData{mx=4}{e^{\htmlData{mx=3}{\htmlData{mx=1}{s_{0}}(\htmlData{mx=2}{j})}}}}{\htmlData{mx=9}{\sum_{k} \htmlData{mx=8}{e^{\htmlData{mx=7}{\htmlData{mx=5}{s_{0}}(\htmlData{mx=6}{k})}}}}}} \cdot \htmlData{mx=20}{e^{\htmlData{mx=19}{\htmlData{mx=17}{\htmlData{mx=13}{\htmlData{mx=11}{\mathit{st}}(\htmlData{mx=12}{j})} - \htmlData{mx=16}{\htmlData{mx=14}{s_{0}}(\htmlData{mx=15}{j})}} - \htmlData{mx=18}{M}}}}}}{\htmlData{mx=43}{\sum_{i} \htmlData{mx=42}{\htmlData{mx=31}{\frac{\htmlData{mx=25}{e^{\htmlData{mx=24}{\htmlData{mx=22}{s_{0}}(\htmlData{mx=23}{i})}}}}{\htmlData{mx=30}{\sum_{k} \htmlData{mx=29}{e^{\htmlData{mx=28}{\htmlData{mx=26}{s_{0}}(\htmlData{mx=27}{k})}}}}}} \cdot \htmlData{mx=41}{e^{\htmlData{mx=40}{\htmlData{mx=38}{\htmlData{mx=34}{\htmlData{mx=32}{\mathit{st}}(\htmlData{mx=33}{i})} - \htmlData{mx=37}{\htmlData{mx=35}{s_{0}}(\htmlData{mx=36}{i})}} - \htmlData{mx=39}{M}}}}}}}} \\ & \quad \htmlData{mx=0}{=} \htmlData{mx=54}{\frac{\htmlData{mx=48}{e^{\htmlData{mx=47}{\htmlData{mx=45}{\mathit{st}}(\htmlData{mx=46}{j})}}}}{\htmlData{mx=53}{\sum_{k} \htmlData{mx=52}{e^{\htmlData{mx=51}{\htmlData{mx=49}{\mathit{st}}(\htmlData{mx=50}{k})}}}}}} \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. (ℕ)
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 n. Lean writes f x; papers write f(x). (Fin n)
⟹Implies
If Fin(n), then ℝ. (Between types, A → B is the type of functions from A to B.) (Fin n → ℝ)
x : TVariables
s0, st range over Fin n → ℝ: the statement must hold for every choice. ((s0 st : Fin n → ℝ))
<Less than
0 is strictly smaller than n. (0 < n)
·Multiplication
exp(s0(j))/(∑ k, exp(s0(k))) times exp(st(j) − s0(j) − M). ((Real.exp (s0 j) / ∑ k, Real.exp (s0 k)…)
=Equality
exp(s0(j))/(∑ k, exp(s0(k))) · exp(st(j) − s0(j) − M)/(∑ i… and exp(st(j))/(∑ k, exp(st(k))) are the same. ((Real.exp (s0 j) / ∑ k, Real.exp (s0 k)…)
eˣExponential function
e raised to the power s0(j), where e ≈ 2.718. (Real.exp (s0 j))
a/bDivision
exp(s0(j)) divided by ∑ k, exp(s0(k)). In Lean, dividing by 0 gives 0. (Real.exp (s0 j) / ∑ k, Real.exp (s0 k))
RReal numbers
The real numbers: every point on the number line. (ℝ)
∑Summation
Add up exp(s0(k)) for every k. (∑ k, Real.exp (s0 k))
-Subtraction
st(j) minus s0(j). On ℕ, Lean's subtraction stops at 0: 2 − 5 = 0. (st j - s0 j)

KV-cache keys are fixed during decoding, so the current attention row is an exponential tilt of any stale snapshot. Accepted keys are exact samples from the current row: the estimate is unbiased with variance ≤ F²/N, with no SNIS ratio bias and no MLMC debiasing. Part of 'The Query-Cover Law: decode attention cost is set by where the queries go, not by how long the context is'.

How it was proved

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

More proved statements