proofs
Provedquery-cover-lawdecode-attentionsoftmaxkv-cache

Amortized cost of memoized decode attention: (S·n + T·eF²/ε)/T = nS/T + eF²/ε

For all n,S,T,F,ε∈R\htmlData{mx=1}{n, S, T, F, \varepsilon \in \htmlData{mx=0}{\mathbb{R}}}, if 0<T0 \mathrel{\htmlData{mx=1}{<}} \htmlData{mx=0}{T} and 0<ε0 \mathrel{\htmlData{mx=1}{<}} \htmlData{mx=0}{\varepsilon}, then

S⋅n+T⋅(e1⋅F2ε)T=n⋅ST+e1⋅F2ε\htmlData{mx=13}{\frac{\htmlData{mx=11}{\htmlData{mx=2}{\htmlData{mx=0}{S} \cdot \htmlData{mx=1}{n}} + \htmlData{mx=10}{\htmlData{mx=3}{T} \cdot \left(\htmlData{mx=9}{\frac{\htmlData{mx=7}{\htmlData{mx=4}{e^{1}} \cdot \htmlData{mx=6}{\htmlData{mx=5}{F}^{2}}}}{\htmlData{mx=8}{\varepsilon}}}\right)}}}{\htmlData{mx=12}{T}}} \mathrel{\htmlData{mx=26}{=}} \htmlData{mx=25}{\htmlData{mx=18}{\frac{\htmlData{mx=16}{\htmlData{mx=14}{n} \cdot \htmlData{mx=15}{S}}}{\htmlData{mx=17}{T}}} + \htmlData{mx=24}{\frac{\htmlData{mx=22}{\htmlData{mx=19}{e^{1}} \cdot \htmlData{mx=21}{\htmlData{mx=20}{F}^{2}}}}{\htmlData{mx=23}{\varepsilon}}}}
What the notation means · or point at any symbol
RReal numbers
The real numbers: every point on the number line. (ℝ)
x ∈ TVariables
n, S, T, F, ε range over real numbers: the statement must hold for every choice. ((n S T F ε : ℝ))
<Less than
0 is strictly smaller than T. (0 < T)
=Equality
(S · n + T · (exp(1) · F^2/ε))/T and n · S/T + exp(1) · F^2/ε are the same. ((S * n + T * (Real.exp 1 * F ^ 2 / ε)) …)
·Multiplication
S times n. (S * n)
+Addition
S · n plus T · (exp(1) · F^2/ε). (S * n + T * (Real.exp 1 * F ^ 2 / ε))
eˣExponential function
e raised to the power 1, where e ≈ 2.718. (Real.exp 1)
a/bDivision
exp(1) · F^2 divided by ε. In Lean, dividing by 0 gives 0. (Real.exp 1 * F ^ 2 / ε)
aᵇPower
F raised to the power 2. (F ^ 2)

S snapshots (one full pass each) plus T tokens at eF²/ε proposals each. The context length n enters only through the snapshot rate S/T, which is the covering number of the query trajectory. 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
10 lines of Lean
Sign in to see the proofThe proof, its signed report and its history.

More proved statements