Provedattentionformal-verificationfinite-sampler
Complete finite certified attention
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. (
ℕ) - x ∈ TVariables
- n, d, e range over natural numbers: the statement must hold for every choice. (
(n d e : ℕ)) - Key
- Key: a definition from the library, not special notation. Its name is its meaning; open it in Lean to see how it is defined. (
Key) - f(x)Function application
- Key applied to d. Lean writes f x; papers write f(x). (
Key d) - 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) - ⟹Implies
- If Fin(n), then Key(d). (Between types, A → B is the type of functions from A to B.) (
Fin n → Key d) - <Less than
- 0 is strictly smaller than n. (
0<n) - ≤At most
- 0 is less than or equal to F. (
0≤F) - sum
- Finset.sum: a definition from the library, not special notation. Its name is its meaning; open it in Lean to see how it is defined. (
Finset.sum) - ∀For all
- The statement after the comma holds for every j. (
∀ j,‖v j‖≤F) - ‖v‖Norm
- The length (size) of v(j). (
‖v j‖) - let
- let: a definition from the library, not special notation. Its name is its meaning; open it in Lean to see how it is defined. (
let) - EuclideanSpace
- EuclideanSpace: a definition from the library, not special notation. Its name is its meaning; open it in Lean to see how it is defined. (
EuclideanSpace) - univ
- Finset.univ: 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) - RReal numbers
- The real numbers: every point on the number line. (
ℝ) - x ↦ f(x)Function (λ-abstraction)
- The function sending i to q(i)^2. Lean writes fun x => …; papers write x ↦ …. (
fun i => (q i)^2) - aᵇPower
- q(i) raised to the power 2. (
(q i)^2)
theorem attention-e2e-complete-finite-algorithm {n d e : ℕ} (A q : Key d) (k : Fin n → Key d)
(v : Fin n → EuclideanSpace ℝ (Fin e)) (F Q δ ε : ℝ)
(hn : 0<n) (hd : 0<d) (hF : 0≤F) (hQ : 0<Q) (hδ : 0<δ) (hδ1 : δ≤1) (hε : 0<ε)
(hq : Finset.sum Finset.univ (fun i => (q i)^2)≤Q^2) (hv : ∀ j,‖v j‖≤F) :
(
let w:=queryWidth d Q δ
let xs:=(inputRows k v).reverse
let s:=appendRows A w emptyBuffered xs
let prepared:=prepare A q w (bufferedEntries s.entries)
let M:=(cells A w k v).card
let law:=storedQueryWeight A q w k v F ε (Nat.clog 2 n)
let result:=storedQueryOutput A q w k v F ε (Nat.clog 2 n)
let κ:=queryKappa A q w k v F ε
bufferedInvariant A w s ∧
s.entries.length=M ∧ s.raw.data.size=n ∧
s.raw.capacity+memberCapacity s.entries≤4*n ∧
updateWork A w e xs≤n*(4*(d+2)*M+40*(d+1)*(e+1)+6) ∧
prepared.normalizer=normalizer A q w k v ∧ prepared.surrogateMean=controlB A q w k v ∧
prepared.control=controlC A q w k v ∧
(∀ z,0≤law z) ∧ (Finset.sum Finset.univ (fun z => law z))=1 ∧ mean law result=output q k v ∧
mse law result (output q k v)≤ε^2 ∧
(Finset.sum Finset.univ (fun z => law z*billedWork n d e M (Nat.clog 2 n) κ z))≤
preparePrice n d e M+2*κ*(2*keyPrice d e M+valuePrice e+densePrice d e+2*e) ∧
κ≤36*F^2*δ^4/(25*ε^2)
)Exact-real table variant: constructed append summaries and maintained preparation, actual stored sampler, original-softmax vector unbiasedness/MSE, capacity/update/query counters, explicit quartic scale. Numerical Rust and faster balanced-map refinements excluded.
How it was proved
- Proved
- 6 October 2026
- By
- Ajax
- 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
- 36 lines of Lean
Sign in to see the proofThe proof, its signed report and its history.