proofs
Provedunbiased-attentionrandomized-algorithmssoftmaxproposal

Importance sampling of the attention numerator is unbiased: Σ r_j·(w_j v_j / r_j) = Σ w_j v_j

For all n∈N\htmlData{mx=1}{n \in \htmlData{mx=0}{\mathbb{N}}} and w,v,r:Fin⁡ n→R\htmlData{mx=5}{w, v, r : \htmlData{mx=2}{\htmlData{mx=0}{\operatorname{Fin}}\,\htmlData{mx=1}{n}} \mathrel{\htmlData{mx=4}{\to}} \htmlData{mx=3}{\mathbb{R}}}, if ∀j, r(j)≠0\htmlData{mx=4}{\forall j,\ \htmlData{mx=2}{\htmlData{mx=0}{r}(\htmlData{mx=1}{j})} \mathrel{\htmlData{mx=3}{\neq}} 0}, then

∑jr(j)⋅(w(j)⋅v(j)r(j))=∑jw(j)⋅v(j)\htmlData{mx=15}{\sum_{j} \htmlData{mx=14}{\htmlData{mx=2}{\htmlData{mx=0}{r}(\htmlData{mx=1}{j})} \cdot \left(\htmlData{mx=13}{\frac{\htmlData{mx=9}{\htmlData{mx=5}{\htmlData{mx=3}{w}(\htmlData{mx=4}{j})} \cdot \htmlData{mx=8}{\htmlData{mx=6}{v}(\htmlData{mx=7}{j})}}}{\htmlData{mx=12}{\htmlData{mx=10}{r}(\htmlData{mx=11}{j})}}}\right)}} \mathrel{\htmlData{mx=24}{=}} \htmlData{mx=23}{\sum_{j} \htmlData{mx=22}{\htmlData{mx=18}{\htmlData{mx=16}{w}(\htmlData{mx=17}{j})} \cdot \htmlData{mx=21}{\htmlData{mx=19}{v}(\htmlData{mx=20}{j})}}}
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)
⟹Implies
If Fin(n), then ℝ. (Between types, A → B is the type of functions from A to B.) (Fin n → ℝ)
x : TVariables
w, v, r range over Fin n → ℝ: the statement must hold for every choice. ((w v r : Fin n → ℝ))
∀For all
The statement after the comma holds for every j. (∀ j, r j ≠ 0)
∑Summation
Add up r(j) · (w(j) · v(j)/r(j)) for every j. (∑ j, r j * (w j * v j / r j))
=Equality
∑ j, r(j) · (w(j) · v(j)/r(j)) and ∑ j, w(j) · v(j) are the same. (∑ j, r j * (w j * v j / r j) = ∑ j, w j…)
≠Not equal
r(j) and 0 are different. (r j ≠ 0)
RReal numbers
The real numbers: every point on the number line. (ℝ)
·Multiplication
w(j) times v(j). (w j * v j)
a/bDivision
w(j) · v(j) divided by r(j). In Lean, dividing by 0 gives 0. (w j * v j / r j)

Sampling key j with probability r_j and returning w_j v_j / r_j is unbiased for the unnormalized attention numerator, for any proposal with full support. 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
11 lines of Lean
Sign in to see the proofThe proof, its signed report and its history.

More proved statements