proofs
Provedtwo-precision-attentionenergyquantizationlaw

Quantized-score error: entrywise |q − q̂| ≤ ε_q, |k − k̂| ≤ ε_k ⇒ |⟨q,k⟩ − ⟨q̂,k̂⟩| ≤ d(ε_q K∞ + Q∞ ε_k)

For all d∈N\htmlData{mx=1}{d \in \htmlData{mx=0}{\mathbb{N}}}, q,qh,k,kh:Fin⁡ d→R\htmlData{mx=5}{q, \mathit{qh}, k, \mathit{kh} : \htmlData{mx=2}{\htmlData{mx=0}{\operatorname{Fin}}\,\htmlData{mx=1}{d}} \mathrel{\htmlData{mx=4}{\to}} \htmlData{mx=3}{\mathbb{R}}} and eq,ek,Kinf,Qinf∈R\htmlData{mx=1}{\mathit{eq}, \mathit{ek}, \mathit{Kinf}, \mathit{Qinf} \in \htmlData{mx=0}{\mathbb{R}}}, if ∀i, ∣q(i)−qh(i)∣≤eq\htmlData{mx=10}{\forall i,\ \htmlData{mx=7}{\left\lvert \htmlData{mx=6}{\htmlData{mx=2}{\htmlData{mx=0}{q}(\htmlData{mx=1}{i})} - \htmlData{mx=5}{\htmlData{mx=3}{\mathit{qh}}(\htmlData{mx=4}{i})}} \right\rvert} \mathrel{\htmlData{mx=9}{\leq}} \htmlData{mx=8}{\mathit{eq}}}, ∀i, ∣k(i)−kh(i)∣≤ek\htmlData{mx=10}{\forall i,\ \htmlData{mx=7}{\left\lvert \htmlData{mx=6}{\htmlData{mx=2}{\htmlData{mx=0}{k}(\htmlData{mx=1}{i})} - \htmlData{mx=5}{\htmlData{mx=3}{\mathit{kh}}(\htmlData{mx=4}{i})}} \right\rvert} \mathrel{\htmlData{mx=9}{\leq}} \htmlData{mx=8}{\mathit{ek}}}, ∀i, ∣k(i)∣≤Kinf\htmlData{mx=6}{\forall i,\ \htmlData{mx=3}{\left\lvert \htmlData{mx=2}{\htmlData{mx=0}{k}(\htmlData{mx=1}{i})} \right\rvert} \mathrel{\htmlData{mx=5}{\leq}} \htmlData{mx=4}{\mathit{Kinf}}} and ∀i, ∣qh(i)∣≤Qinf\htmlData{mx=6}{\forall i,\ \htmlData{mx=3}{\left\lvert \htmlData{mx=2}{\htmlData{mx=0}{\mathit{qh}}(\htmlData{mx=1}{i})} \right\rvert} \mathrel{\htmlData{mx=5}{\leq}} \htmlData{mx=4}{\mathit{Qinf}}}, then

∣∑iq(i)⋅k(i)−∑iqh(i)⋅kh(i)∣≤d⋅(eq⋅Kinf+Qinf⋅ek)\begin{aligned} & \htmlData{mx=18}{\left\lvert \htmlData{mx=17}{\htmlData{mx=8}{\sum_{i} \htmlData{mx=7}{\htmlData{mx=3}{\htmlData{mx=1}{q}(\htmlData{mx=2}{i})} \cdot \htmlData{mx=6}{\htmlData{mx=4}{k}(\htmlData{mx=5}{i})}}} - \htmlData{mx=16}{\sum_{i} \htmlData{mx=15}{\htmlData{mx=11}{\htmlData{mx=9}{\mathit{qh}}(\htmlData{mx=10}{i})} \cdot \htmlData{mx=14}{\htmlData{mx=12}{\mathit{kh}}(\htmlData{mx=13}{i})}}}} \right\rvert} \\ & \quad \htmlData{mx=0}{\leq} \htmlData{mx=27}{\htmlData{mx=19}{d} \cdot (\htmlData{mx=26}{\htmlData{mx=22}{\htmlData{mx=20}{\mathit{eq}} \cdot \htmlData{mx=21}{\mathit{Kinf}}} + \htmlData{mx=25}{\htmlData{mx=23}{\mathit{Qinf}} \cdot \htmlData{mx=24}{\mathit{ek}}}})} \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 d. Lean writes f x; papers write f(x). (Fin d)
⟹Implies
If Fin(d), then ℝ. (Between types, A → B is the type of functions from A to B.) (Fin d → ℝ)
x : TVariables
q, qh, k, kh range over Fin d → ℝ: the statement must hold for every choice. ((q qh k kh : Fin d → ℝ))
x ∈ TVariables
eq, ek, Kinf, Qinf range over real numbers: the statement must hold for every choice. ((eq ek Kinf Qinf : ℝ))
∀For all
The statement after the comma holds for every i. (∀ i, |q i - qh i| ≤ eq)
∑Summation
Add up q(i) · k(i) for every i. (∑ i, q i * k i)
|x|Absolute value
The size of q(i) − qh(i) without its sign. (|q i - qh i|)
≤At most
|q(i) − qh(i)| is less than or equal to eq. (|q i - qh i| ≤ eq)
-Subtraction
q(i) minus qh(i). On ℕ, Lean's subtraction stops at 0: 2 − 5 = 0. (q i - qh i)
·Multiplication
q(i) times k(i). (q i * k i)
RReal numbers
The real numbers: every point on the number line. (ℝ)
+Addition
eq · Kinf plus Qinf · ek. (eq * Kinf + Qinf * ek)

A deterministic, computable tilt bound for low-precision QKᵀ used as a rejection proposal. Viable for INT8 (η ≈ Q∞K∞); too loose for INT4 at d = 64, where SNIS + MLMC must be used instead. Part of 'Two-Precision Exact Attention: low-precision scores as a proposal, full-precision softmax as the exact target'.

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

More proved statements