Provedunbiased-attentionrandomized-algorithmssoftmaxgradient-hardness
Gradient gadget: with u = c = indicator of value-1 keys, Σ π_j (u_j − o) c_j = o(1 − o)
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 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
- π, u range over Fin n → ℝ: the statement must hold for every choice. (
(π u : Fin n → ℝ)) - ∑Summation
- Add up π(j) for every j. (
∑ j, π j) - =Equality
- ∑ j, π(j) and 1 are the same. (
∑ j, π j = 1) - ∀For all
- The statement after the comma holds for every j. (
∀ j, u j * u j = u j) - πPi
- The ratio of a circle's circumference to its diameter, ≈ 3.14159. (
π) - ·Multiplication
- u(j) times u(j). (
u j * u j) - RReal numbers
- The real numbers: every point on the number line. (
ℝ) - -Subtraction
- u(j) minus ∑ i, π(i) · u(i). On ℕ, Lean's subtraction stops at 0: 2 − 5 = 0. (
u j - ∑ i, π i * u i)
theorem ua-gradient-gadget-identity {n : ℕ} (π u : Fin n → ℝ) (hπ : ∑ j, π j = 1) (hu : ∀ j, u j * u j = u j) :
∑ j, π j * (u j - ∑ i, π i * u i) * u j = (∑ i, π i * u i) * (1 - ∑ i, π i * u i)The query-gradient coordinate along a key coordinate c (with zero query weight, so scores are unchanged), under upstream gradient 1 and 0/1 values, is the Bernoulli variance o(1−o) of the row output. All quantities are at natural scale (|values|, |coordinates| ≤ 1). Part of 'Unbiased randomized attention: cost x variance thresholds', round 7 (gradient hardness via isolation).
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
- 16 lines of Lean
Sign in to see the proofThe proof, its signed report and its history.