proofs
Provedunbiased-attentionrandomized-algorithmssoftmaxdebiasing

Variance of the single-term estimator ≤ its second moment Σ p (D/p)²

For all L∈N\htmlData{mx=1}{L \in \htmlData{mx=0}{\mathbb{N}}} and D,p:N→R\htmlData{mx=3}{D, p : \htmlData{mx=0}{\mathbb{N}} \mathrel{\htmlData{mx=2}{\to}} \htmlData{mx=1}{\mathbb{R}}}:

∑l=0L−1p(l)⋅(D(l)p(l))2−(∑l=0L−1p(l)⋅(D(l)p(l)))2≤∑l=0L−1p(l)⋅(D(l)p(l))2\begin{aligned} & \htmlData{mx=29}{\htmlData{mx=14}{\sum_{l=0}^{\htmlData{mx=1}{L} - 1} \htmlData{mx=13}{\htmlData{mx=4}{\htmlData{mx=2}{p}(\htmlData{mx=3}{l})} \cdot \htmlData{mx=12}{\left(\htmlData{mx=11}{\frac{\htmlData{mx=7}{\htmlData{mx=5}{D}(\htmlData{mx=6}{l})}}{\htmlData{mx=10}{\htmlData{mx=8}{p}(\htmlData{mx=9}{l})}}}\right)^{2}}}} - \htmlData{mx=28}{\left(\htmlData{mx=27}{\sum_{l=0}^{\htmlData{mx=15}{L} - 1} \htmlData{mx=26}{\htmlData{mx=18}{\htmlData{mx=16}{p}(\htmlData{mx=17}{l})} \cdot \left(\htmlData{mx=25}{\frac{\htmlData{mx=21}{\htmlData{mx=19}{D}(\htmlData{mx=20}{l})}}{\htmlData{mx=24}{\htmlData{mx=22}{p}(\htmlData{mx=23}{l})}}}\right)}}\right)^{2}}} \\ & \quad \htmlData{mx=0}{\leq} \htmlData{mx=43}{\sum_{l=0}^{\htmlData{mx=30}{L} - 1} \htmlData{mx=42}{\htmlData{mx=33}{\htmlData{mx=31}{p}(\htmlData{mx=32}{l})} \cdot \htmlData{mx=41}{\left(\htmlData{mx=40}{\frac{\htmlData{mx=36}{\htmlData{mx=34}{D}(\htmlData{mx=35}{l})}}{\htmlData{mx=39}{\htmlData{mx=37}{p}(\htmlData{mx=38}{l})}}}\right)^{2}}}} \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. (ℕ)
⟹Implies
If ℕ, then ℝ. (Between types, A → B is the type of functions from A to B.) (ℕ → ℝ)
x : TVariables
D, p range over ℕ → ℝ: the statement must hold for every choice. ((D p : ℕ → ℝ))
∑Summation
Add up p(l) · (D(l)/p(l))^2 for l = 0, 1, …, L − 1. (∑ l ∈ Finset.range L, p l * (D l / p l)…)
-Subtraction
∑ l, p(l) · (D(l)/p(l))^2 minus (∑ l, p(l) · (D(l)/p(l)))^2. On ℕ, Lean's subtraction stops at 0: 2 − 5 = 0. (∑ l ∈ Finset.range L, p l * (D l / p l)…)
≤At most
(∑ l, p(l) · (D(l)/p(l))^2) − (∑ l, p(l) · (D(l)/p(l)))^2 is less than or equal to ∑ l, p(l) · (D(l)/p(l))^2. (∑ l ∈ Finset.range L, p l * (D l / p l)…)
RReal numbers
The real numbers: every point on the number line. (ℝ)
f(x)Function application
p applied to l. Lean writes f x; papers write f(x). (p l)
·Multiplication
p(l) times (D(l)/p(l))^2. (p l * (D l / p l) ^ 2)
aᵇPower
D(l)/p(l) raised to the power 2. ((D l / p l) ^ 2)
a/bDivision
D(l) divided by p(l). In Lean, dividing by 0 gives 0. (D l / p l)

Var Z = E Z² − (E Z)² ≤ E Z². Combined with the second-moment identity, Var ≤ Σ M_l/p_l. Part of 'Unbiased randomized attention: cost x variance thresholds' (open theory problem).

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