Proveddrift-lawdecodeheadline-theoremsnapshot-reuse
Persistent-snapshot cost theorem: exact snapshot rejection under tilt η accepts at rate in [e^{−2η},1], samples the current row exactly, and N samples cost ≤ N·D·e^{2η} reads
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) - 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 J. Lean writes f x; papers write f(x). (
Fintype J) - 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 J, then ℝ. (Between types, A → B is the type of functions from A to B.) (
J → ℝ) - x : TVariables
- s, t range over J → ℝ: the statement must hold for every choice. (
(s t : J → ℝ)) - x ∈ TVariables
- η, N, D, Zs, Zt, p range over real numbers: the statement must hold for every choice. (
(η N D Zs Zt p : ℝ)) - ∀For all
- The statement after the comma holds for every j. (
∀ j, |t j - s j| ≤ η) - =Equality
- Zs and ∑ k, exp(s(k)) are the same. (
Zs = ∑ k, Real.exp (s k)) - RReal numbers
- The real numbers: every point on the number line. (
ℝ) - |x|Absolute value
- The size of t(j) − s(j) without its sign. (
|t j - s j|) - ≤At most
- |t(j) − s(j)| is less than or equal to η. (
|t j - s j| ≤ η) - ∑Summation
- Add up exp(s(k)) for every k. (
∑ k, Real.exp (s k)) - -Subtraction
- t(j) minus s(j). On ℕ, Lean's subtraction stops at 0: 2 − 5 = 0. (
t j - s j) - <Less than
- 0 is strictly smaller than exp(t(j) − s(j) − η). (
0 < Real.exp (t j - s j - η)) - ∧And
- Both hold: 0 < exp(t(j) − s(j) − η), and exp(t(j) − s(j) − η) ≤ 1. (
0 < Real.exp (t j - s j - η) ∧ Real.exp…) - ·Multiplication
- exp(s(j))/Zs times exp(t(j) − s(j) − η). (
(Real.exp (s j) / Zs) * Real.exp (t j -…) - eˣExponential function
- e raised to the power s(k), where e ≈ 2.718. (
Real.exp (s k)) - a/bDivision
- exp(s(j)) divided by Zs. In Lean, dividing by 0 gives 0. (
Real.exp (s j) / Zs) - −xNegation
- The negative of η. (
-η) - ∑'Infinite sum
- Add up (k + 1) · p · (1 − p)^k for every k in ℕ. (
∑' k : ℕ, ((k : ℝ) + 1) * p * (1 - p) ^…) - NNatural numbers
- The natural numbers 0, 1, 2, …. In Lean they start at 0. (
ℕ) - (x : T)As real numbers
- k read as an element of real numbers. Mathematicians leave this implicit; Lean needs it to know which kind of number is meant. (
(k : ℝ)) - +Addition
- k plus 1. (
(k : ℝ) + 1) - aᵇPower
- 1 − p raised to the power k. (
(1 - p) ^ k)
theorem drift-persistent-snapshot-cost {J : Type} [Fintype J] [Nonempty J] (s t : J → ℝ) (η N D Zs Zt p : ℝ) (hη : ∀ j, |t j - s j| ≤ η) (hN : 0 ≤ N) (hD : 0 ≤ D) (hZs : Zs = ∑ k, Real.exp (s k)) (hZt : Zt = ∑ k, Real.exp (t k)) (hp : p = ∑ j, (Real.exp (s j) / Zs) * Real.exp (t j - s j - η)) :
(∀ j, 0 < Real.exp (t j - s j - η) ∧ Real.exp (t j - s j - η) ≤ 1) ∧ p = Real.exp (-η) * Zt / Zs ∧ (∀ j, (Real.exp (s j) / Zs) * Real.exp (t j - s j - η) / p = Real.exp (t j) / Zt) ∧ (Real.exp (-2 * η) ≤ p ∧ p ≤ 1) ∧ (∑' k : ℕ, ((k : ℝ) + 1) * p * (1 - p) ^ k = 1 / p) ∧ (1 / p ≤ Real.exp (2 * η)) ∧ (N * D * (1 / p) ≤ N * D * Real.exp (2 * η))Single-statement form of Drift Law clause 1. For snapshot scores s and current scores t with |t_j − s_j| ≤ η on every key: every acceptance probability e^{t−s−η} lies in (0,1]; the per-draw acceptance rate is exactly e^{−η}Z_t/Z_s and lies in [e^{−2η}, 1]; conditional on acceptance the key is distributed exactly as the current attention row e^{t}/Z_t; the expected number of draws per accepted sample is exactly 1/p (geometric series, proved as a tsum); and with a depth-D sum-tree per draw, N exact samples cost at most N·D·e^{2η} key reads, independent of context length except through D. Part of 'The Drift Law' (closes the goal item 'single-statement persistent-snapshot cost theorem').
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
- 74 lines of Lean
Sign in to see the proofThe proof, its signed report and its history.