Provedunbiased-attentionrandomized-algorithmssoftmaxaggregate
Pair sampling: global score range ≤ R ⇒ n²·Σ_{ij} π_ij² ≤ e^R
For all , and , if , 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 n. Lean writes f x; papers write f(x). (
Fin n) - ∀For all
- The statement after the comma holds for every i, j, i', j'. (
∀ i j i' j', s i j - s i' j' ≤ R) - (x : T)As real numbers
- n read as an element of real numbers. Mathematicians leave this implicit; Lean needs it to know which kind of number is meant. (
(n : ℝ)) - ·Multiplication
- n times n. (
(n : ℝ) * n) - ⟹Implies
- If Fin(n), then ℝ. (Between types, A → B is the type of functions from A to B.) (
Fin n → ℝ) - -Subtraction
- s(i, j) minus s(i', j'). On ℕ, Lean's subtraction stops at 0: 2 − 5 = 0. (
s i j - s i' j') - ≤At most
- s(i, j) − s(i', j') is less than or equal to R. (
s i j - s i' j' ≤ R) - RReal numbers
- The real numbers: every point on the number line. (
ℝ) - aᵇPower
- exp(s(i, j))/(∑ i', ∑ j', exp(s(i', j'))) raised to the power 2. (
(Real.exp (s i j) / ∑ i', ∑ j', Real.ex…) - eˣExponential function
- e raised to the power s(i, j), where e ≈ 2.718. (
Real.exp (s i j)) - a/bDivision
- exp(s(i, j)) divided by ∑ i', ∑ j', exp(s(i', j')). In Lean, dividing by 0 gives 0. (
Real.exp (s i j) / ∑ i', ∑ j', Real.exp…) - ∑Summation
- Add up exp(s(i', j')) for every j'. (
∑ j', Real.exp (s i' j'))
theorem ua-pair-sampling-chi-square {n : ℕ} (s : Fin n → Fin n → ℝ) (R : ℝ) (hR : ∀ i j i' j', s i j - s i' j' ≤ R) :
((n : ℝ) * n) * ∑ i, ∑ j, (Real.exp (s i j) / ∑ i', ∑ j', Real.exp (s i' j')) ^ 2 ≤ Real.exp RUniform sampling of (query, key) pairs estimates the batch partition function to constant relative error with O(e^R) samples. With the aggregate gadget: the exponent of constant-factor batch partition-function estimation at range a ln n is exactly min(a, 2) (SETH, polylog dimension; candidate), sharpening the Θ(log n) threshold of Charikar–Siminelakis 2019 (Thm 1.2, constant C(δ, α) = O(e^{e^{δ/c(δ)}})) to the exact constant and full curve. Part of 'Unbiased randomized attention: cost x variance thresholds', round 13 (aggregate / batch partition function).
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
- 37 lines of Lean
Sign in to see the proofThe proof, its signed report and its history.