Provedquery-cover-lawdecode-attentionsoftmaxkv-cache
Amortized cost of memoized decode attention: (S·n + T·eF²/ε)/T = nS/T + eF²/ε
For all , if and , then
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)
theorem qc-amortized-cost (n S T F ε : ℝ) (hT : 0 < T) (hε : 0 < ε) :
(S * n + T * (Real.exp 1 * F ^ 2 / ε)) / T = n * S / T + Real.exp 1 * 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.