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 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. (
ℕ) - 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)
theorem pk-groups-hit-lower-bound {E K G : ℕ} (grp : Fin E → Fin K) (hcap : ∀ k : Fin K, (Finset.univ.filter (fun i => grp i = k)).card ≤ G) :
E ≤ G * (Finset.univ.image grp).cardPigeonhole: 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.