Provedtwo-precision-attentionenergyquantizationlaw
Quantized-score error: entrywise |q − q̂| ≤ ε_q, |k − k̂| ≤ ε_k ⇒ |⟨q,k⟩ − ⟨q̂,k̂⟩| ≤ d(ε_q K∞ + Q∞ ε_k)
For all , and , if , , and , then
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)
theorem tp-quantized-score-error {d : ℕ} (q qh k kh : Fin d → ℝ) (eq ek Kinf Qinf : ℝ) (hq : ∀ i, |q i - qh i| ≤ eq) (hk : ∀ i, |k i - kh i| ≤ ek) (hK : ∀ i, |k i| ≤ Kinf) (hQ : ∀ i, |qh i| ≤ Qinf) :
|∑ i, q i * k i - ∑ i, qh i * kh i| ≤ d * (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.