proofs
Provedsampleability-lawgrouped-query-attentiondecode

GQA sharing penalty, upper: for H probability rows, (Σ_j √(Σ_h π_hj²))² ≤ |H|², so sharing never costs more gathers than separate sampling

For all H,J∈Type⁡\htmlData{mx=1}{H, J \in \htmlData{mx=0}{\operatorname{Type}}} and π:H→J→R\htmlData{mx=5}{\pi : \htmlData{mx=0}{H} \mathrel{\htmlData{mx=4}{\to}} \htmlData{mx=1}{J} \mathrel{\htmlData{mx=3}{\to}} \htmlData{mx=2}{\mathbb{R}}}, if ∀h,j, 0≤π(h,j)\htmlData{mx=5}{\forall h, j,\ 0 \mathrel{\htmlData{mx=4}{\leq}} \htmlData{mx=3}{\htmlData{mx=0}{\pi}(\htmlData{mx=1}{h}, \htmlData{mx=2}{j})}} and ∀h, ∑jπ(h,j)=1\htmlData{mx=6}{\forall h,\ \htmlData{mx=4}{\sum_{j} \htmlData{mx=3}{\htmlData{mx=0}{\pi}(\htmlData{mx=1}{h}, \htmlData{mx=2}{j})}} \mathrel{\htmlData{mx=5}{=}} 1} (given Fintype⁡ H\htmlData{mx=2}{\htmlData{mx=0}{\operatorname{Fintype}}\,\htmlData{mx=1}{H}} and Fintype⁡ J\htmlData{mx=2}{\htmlData{mx=0}{\operatorname{Fintype}}\,\htmlData{mx=1}{J}}), then

(∑j∑hπ(h,j)2)2≤card⁡(H)2\htmlData{mx=8}{\left(\htmlData{mx=7}{\sum_{j} \htmlData{mx=6}{\sqrt{\htmlData{mx=5}{\sum_{h} \htmlData{mx=4}{\htmlData{mx=3}{\htmlData{mx=0}{\pi}(\htmlData{mx=1}{h}, \htmlData{mx=2}{j})}^{2}}}}}}\right)^{2}} \mathrel{\htmlData{mx=14}{\leq}} \htmlData{mx=13}{\htmlData{mx=12}{\htmlData{mx=11}{\htmlData{mx=9}{\operatorname{card}}(\htmlData{mx=10}{H})}}^{2}}
What the notation means · or point at any symbol
Type
Type: a definition from the library, not special notation. Its name is its meaning; open it in Lean to see how it is defined. (Type)
x ∈ TVariables
H, J range over Type: the statement must hold for every choice. ((H J : Type))
Fintype
Fintype: a definition from the library, not special notation. Its name is its meaning; open it in Lean to see how it is defined. (Fintype)
f(x)Function application
Fintype applied to H. Lean writes f x; papers write f(x). (Fintype H)
∀For all
The statement after the comma holds for every h, j. (∀ h j, 0 ≤ π h j)
⟹Implies
If J, then ℝ. (Between types, A → B is the type of functions from A to B.) (J → ℝ)
∑Summation
Add up π(h, j) for every j. (∑ j, π h j)
=Equality
∑ j, π(h, j) and 1 are the same. (∑ j, π h j = 1)
√Square root
The non-negative number whose square is ∑ h, π(h, j)^2. (Real.sqrt (∑ h, π h j ^ 2))
≤At most
0 is less than or equal to π(h, j). (0 ≤ π h j)
RReal numbers
The real numbers: every point on the number line. (ℝ)
πPi
The ratio of a circle's circumference to its diameter, ≈ 3.14159. (π)
aᵇPower
π(h, j) raised to the power 2. (π h j ^ 2)
(x : T)As real numbers
card(H) read as an element of real numbers. Mathematicians leave this implicit; Lean needs it to know which kind of number is meant. ((Fintype.card H : ℝ))
card
Fintype.card: a definition from the library, not special notation. Its name is its meaning; open it in Lean to see how it is defined. (Fintype.card)

√(Σ_h x²) ≤ Σ_h x for x ≥ 0 gives A ≤ |H|, so ρ = A²/|H| ≤ |H|. Consequence: at per-head accuracy ε a KV group needs ρF²/ε² shared key gathers against |H|F²/ε² for separate exact sampling; sharing saves the factor |H|/ρ ∈ [1, |H|] of decode KV traffic, maximal when the group's heads attend alike. Part of 'The Sampleability Law' (GQA decode-traffic extension).

How it was proved

Proved
5 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
22 lines of Lean
Sign in to see the proofThe proof, its signed report and its history.

More proved statements