Provedunbiased-attentionrandomized-algorithmssoftmaxeasy-side
Approximate-score proposal: |s − ŝ| ≤ η ⇒ Σ π²/r ≤ e^{2η} (π = softmax s, r = softmax ŝ)
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) - ⟹Implies
- If Fin(n), then ℝ. (Between types, A → B is the type of functions from A to B.) (
Fin n → ℝ) - x : TVariables
- s, t range over Fin n → ℝ: the statement must hold for every choice. (
(s t : Fin n → ℝ)) - ∀For all
- The statement after the comma holds for every j. (
∀ j, |s j - t j| ≤ η) - |x|Absolute value
- The size of s(j) − t(j) without its sign. (
|s j - t j|) - ≤At most
- |s(j) − t(j)| is less than or equal to η. (
|s j - t j| ≤ η) - aᵇPower
- exp(s(j))/(∑ k, exp(s(k))) raised to the power 2. (
(Real.exp (s j) / ∑ k, Real.exp (s k)) …) - -Subtraction
- s(j) minus t(j). On ℕ, Lean's subtraction stops at 0: 2 − 5 = 0. (
s j - t j) - eˣExponential function
- e raised to the power s(j), where e ≈ 2.718. (
Real.exp (s j)) - a/bDivision
- exp(s(j)) divided by ∑ k, exp(s(k)). In Lean, dividing by 0 gives 0. (
Real.exp (s j) / ∑ k, Real.exp (s k)) - RReal numbers
- The real numbers: every point on the number line. (
ℝ) - ∑Summation
- Add up exp(s(k)) for every k. (
∑ k, Real.exp (s k)) - ·Multiplication
- 2 times η. (
2 * η)
theorem ua-approximate-score-proposal {n : ℕ} (s t : Fin n → ℝ) (η : ℝ) (hη : ∀ j, |s j - t j| ≤ η) :
∑ j, (Real.exp (s j) / ∑ k, Real.exp (s k)) ^ 2 / (Real.exp (t j) / ∑ k, Real.exp (t k)) ≤ Real.exp (2 * η)If any cheap stage (low-precision or sketched dot products, a cache, a data structure) yields scores within η of the true ones, importance sampling from softmax(ŝ) has 1 + χ² ≤ e^{2η}: the sample count for constant MSE depends only on η, not on n or the score range. All of the hardness lives in producing the proposal. Part of 'Unbiased randomized attention: cost x variance thresholds', round 5 (approximate-score proposals and the sampling lower bound).
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
- 44 lines of Lean
Sign in to see the proofThe proof, its signed report and its history.