proofs
Provedgrouped-query-attentiondecodehead-packingsampleability-law

Exact-head packing, lower bound: E heads that must stay exact, in KV groups of size ≤ G, hit at least E/G groups

For all E,K,G∈N\htmlData{mx=1}{E, K, G \in \htmlData{mx=0}{\mathbb{N}}} and grp:Fin⁡ E→Fin⁡ K\htmlData{mx=7}{\mathit{grp} : \htmlData{mx=2}{\htmlData{mx=0}{\operatorname{Fin}}\,\htmlData{mx=1}{E}} \mathrel{\htmlData{mx=6}{\to}} \htmlData{mx=5}{\htmlData{mx=3}{\operatorname{Fin}}\,\htmlData{mx=4}{K}}}, if ∀k:Fin⁡ K, ∣filter⁡(i↦grp(i)=k)∣≤G\htmlData{mx=22}{\forall k : \htmlData{mx=21}{\htmlData{mx=19}{\operatorname{Fin}}\,\htmlData{mx=20}{K}},\ \htmlData{mx=16}{\lvert \htmlData{mx=15}{\htmlData{mx=8}{\operatorname{filter}}(\htmlData{mx=14}{i \mapsto \htmlData{mx=11}{\htmlData{mx=9}{\mathit{grp}}(\htmlData{mx=10}{i})} \mathrel{\htmlData{mx=13}{=}} \htmlData{mx=12}{k}})} \rvert} \mathrel{\htmlData{mx=18}{\leq}} \htmlData{mx=17}{G}}, then

E≤G⋅∣image⁡(grp)∣\htmlData{mx=0}{E} \mathrel{\htmlData{mx=10}{\leq}} \htmlData{mx=9}{\htmlData{mx=1}{G} \cdot \htmlData{mx=8}{\lvert \htmlData{mx=7}{\htmlData{mx=5}{\operatorname{image}}(\htmlData{mx=6}{\mathit{grp}})} \rvert}}
What the notation means · or point at any symbol
NNatural numbers
The natural numbers 0, 1, 2, …. In Lean they start at 0. (ℕ)
x ∈ TVariables
E, K, G range over natural numbers: the statement must hold for every choice. ((E K G : ℕ))
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 E. Lean writes f x; papers write f(x). (Fin E)
⟹Implies
If Fin(E), then Fin(K). (Between types, A → B is the type of functions from A to B.) (Fin E → Fin K)
∀For all
The statement after the comma holds for every k. (∀ k : Fin K, (Finset.univ.filter (fun i…)
·Multiplication
G times card(image(grp)). (G * (Finset.univ.image grp).card)
image
Finset.univ.image: a definition from the library, not special notation. Its name is its meaning; open it in Lean to see how it is defined. (Finset.univ.image)
|s|Cardinality
The number of elements of filter(i ↦ grp(i) = k). ((Finset.univ.filter (fun i => grp i = k…)
≤At most
card(filter(i ↦ grp(i) = k)) is less than or equal to G. ((Finset.univ.filter (fun i => grp i = k…)
filter
Finset.univ.filter: a definition from the library, not special notation. Its name is its meaning; open it in Lean to see how it is defined. (Finset.univ.filter)
x ↦ f(x)Function (λ-abstraction)
The function sending i to grp(i) = k. Lean writes fun x => …; papers write x ↦ …. (fun i => grp i = k)
=Equality
grp(i) and k are the same. (grp i = k)

Pigeonhole: under grouped-query attention a KV group's whole cache is read if any of its query heads must stay exact, so the number of fully-read groups is at least ⌈E/G⌉ per layer. Part of 'The Sampleability Law' / 'The Drift Law' (GQA exact-head packing: minimising KV groups that must be read in full).

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

More proved statements