Attention Compute Law, one statement: proposals from side information cost ≥ (Σ_j √E[π_j²|T])², attained by r ∝ √E[π²|T]; uniform optimal when exchangeable; next-step form for adaptive schemes
For all , , , , , , and , if , , , , , , and (given , , and ), then
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
- I, J, H range over Type: the statement must hold for every choice. (
(I J H : 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 I. Lean writes f x; papers write f(x). (
Fintype I) - Nonempty
- Nonempty: a definition from the library, not special notation. Its name is its meaning; open it in Lean to see how it is defined. (
Nonempty) - ⟹Implies
- If I, then ℝ. (Between types, A → B is the type of functions from A to B.) (
I → ℝ) - ∀For all
- The statement after the comma holds for every i. (
∀ i, 0 ≤ lam i) - ∑Summation
- Add up r(j) for every j. (
∑ j, r j) - =Equality
- ∑ j, r(j) and 1 are the same. (
∑ j, r j = 1) - aᵇPower
- ∑ j, √(∑ i, lam(i) · a(i, j)) raised to the power 2. (
(∑ j, Real.sqrt (∑ i, lam i * a i j)) ^…) - RReal numbers
- The real numbers: every point on the number line. (
ℝ) - ≤At most
- 0 is less than or equal to lam(i). (
0 ≤ lam i) - <Less than
- 0 is strictly smaller than r(j). (
0 < r j) - √Square root
- The non-negative number whose square is ∑ i, lam(i) · a(i, j). (
Real.sqrt (∑ i, lam i * a i j)) - ·Multiplication
- lam(i) times a(i, j). (
lam i * a i j) - a/bDivision
- a(i, j) divided by r(j). In Lean, dividing by 0 gives 0. (
a i j / r j) - ∧And
- Both hold: (∀ j, (∑ i, lam(i) · a(i, j)) = Abar) → card(J) · (∑ j, ∑ …, and (∑ h, P(h) · (∑ j, √(∑ i, lamH(h, i) · a(i, j)))^2) ≤ (∑ h…. (
((∀ j, ∑ i, lam i * a i j = Abar) → (Fi…) - (x : T)As real numbers
- card(J) read as an element of real numbers. Mathematicians leave this implicit; Lean needs it to know which kind of number is meant. (
(Fintype.card J : ℝ)) - 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)
theorem attention-compute-law-first-principles {I J H : Type} [Fintype I] [Fintype J] [Nonempty J] [Fintype H] (lam : I → ℝ) (a : I → J → ℝ) (r : J → ℝ) (Abar : ℝ) (P : H → ℝ) (lamH : H → I → ℝ) (rH : H → J → ℝ) (hlam : ∀ i, 0 ≤ lam i) (ha : ∀ i j, 0 ≤ a i j) (hr : ∀ j, 0 < r j) (hrs : ∑ j, r j = 1) (hP : ∀ h, 0 ≤ P h) (hlamH : ∀ h i, 0 ≤ lamH h i) (hrH : ∀ h j, 0 < rH h j) (hrHs : ∀ h, ∑ j, rH h j = 1) :
((∑ j, Real.sqrt (∑ i, lam i * a i j)) ^ 2 ≤ ∑ i, lam i * ∑ j, a i j / r j) ∧ ((∀ j, 0 < ∑ i, lam i * a i j) → ∑ i, lam i * ∑ j, a i j / (Real.sqrt (∑ i, lam i * a i j) / ∑ k, Real.sqrt (∑ i, lam i * a i k)) = (∑ j, Real.sqrt (∑ i, lam i * a i j)) ^ 2) ∧ ((∀ j, ∑ i, lam i * a i j = Abar) → (Fintype.card J : ℝ) * ∑ j, ∑ i, lam i * a i j ≤ ∑ i, lam i * ∑ j, a i j / r j) ∧ (∑ h, P h * (∑ j, Real.sqrt (∑ i, lamH h i * a i j)) ^ 2 ≤ ∑ h, P h * ∑ i, lamH h i * ∑ j, a i j / rH h j)The strongest provable single statement of the Attention Compute Law. For a row drawn from a finite prior (weights λ over rows, which is the posterior given the side information T a method has) and nonnegative per-key weights a (a = π² for the cost factor; a = π²‖v−g‖² for a residual estimator): (i) every proposal r has expected second-moment factor Σ_i λ_i Σ_j a_ij/r_j ≥ (Σ_j √(Σ_i λ_i a_ij))²; (ii) r_j ∝ √(Σ_i λ_i a_ij) attains it; (iii) if Σ_i λ_i a_ij is the same for every key (exchangeable prior, i.e. nothing is known about where the mass sits) then every proposal costs ≥ |J|·Σ_j E[a_j], which uniform sampling attains, so blind sampling is optimal and costs n·E[Σπ²] = n·E[e^{−H₂}]; (iv) for an adaptive scheme whose proposal after history h is r_h, the expected next-draw cost is ≥ Σ_h P(h)(Σ_j √(Σ_i λ_{h,i} a_ij))². Models: non-adaptive proposals with side information, and the next step of adaptive ones; blind adaptive samplers are covered separately by ua-adaptive-sampling-threshold-explicit. Not claimed: coverage of algorithms outside the proposal model, or the cost of building the optimal proposal. Conjoins vcl-bayes-optimal-proposal, vcl-blind-sampling-optimal-under-exchangeability and vcl-sequential-form.
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
- 95 lines of Lean