Bandits.UCB.pullCount_le_of_ucbIndex_le
From the authors
If the means of the best arm and of arm b lie in their confidence intervals and the UCB index
of b is at least that of the best arm, then the number of pulls of b is at most
8 * c * log (n + 1) / gap ν b ^ 2.
-
Ω : Type u_1
-
K : ℕNeZero K -
c : ℝ -
ν : ProbabilityTheory.Kernel (Fin K) ℝA kernel from a measurable spaceαto another measurable spaceβis a measurable functionκ : α → Measure β. -
A : ℕ → Ω → Fin K -
R : ℕ → Ω → ℝ -
n : ℕ -
ω : Ω -
b : Fin K
-
hc : 0 ≤ c -
h_best : ∫ (x : ℝ), id x ∂ν (bestArm ν) ≤ Learning.empMean A R (bestArm ν) n ω + ucbWidth A c (bestArm ν) n ω -
h_arm : Learning.empMean A R b n ω - ucbWidth A c b n ω ≤ ∫ (x : ℝ), id x ∂ν b -
h_le : Learning.empMean A R (bestArm ν) n ω + ucbWidth A c (bestArm ν) n ω ≤ Learning.empMean A R b n ω + ucbWidth A c b n ω -
h_gap_pos : 0 < gap ν b -
h_pull_pos : 0 < Learning.pullCount A b n ω
↑(Learning.pullCount A b n ω) ≤ 8 * c * Real.log (↑n + 1) / gap ν b ^ 2NeZero : {R : Type u_1} → [Zero R] → R → PropA type-class version of `n ≠ 0`.
Nat : TypeThe natural numbers, starting at zero. This type is special-cased by both the kernel and the compiler, and overridden with an efficient implementation. Both use a fast arbitrary-precision arithmetic library (usually [GMP](https://gmplib.org/)); at runtime, `Nat` values that are sufficiently small are unboxed.
Real : TypeThe type `ℝ` of real numbers constructed as equivalence classes of Cauchy sequences of rational numbers.
ProbabilityTheory.Kernel : (α : Type u_1) → (β : Type u_2) → [MeasurableSpace α] → [MeasurableSpace β] → Type (max u_1 u_2)A kernel from a measurable space `α` to another measurable space `β` is a measurable function `κ : α → Measure β`. The measurable space structure on `MeasureTheory.Measure β` is given by `MeasureTheory.Measure.instMeasurableSpace`. A map `κ : α → MeasureTheory.Measure β` is measurable iff `∀ s : Set β, MeasurableSet s → Measurable (fun a ↦ κ a s)`.
Fin : ℕ → TypeNatural numbers less than some upper bound. In particular, a `Fin n` is a natural number `i` with the constraint that `i < n`. It is the canonical type with `n` elements.
LE.le : {α : Type u} → [self : LE α] → α → α → PropThe less-equal relation: `x ≤ y` Conventions for notations in identifiers: * The recommended spelling of `≤` in identifiers is `le`.
MeasureTheory.integral : {α : Type u_6} →
{G : Type u_7} →
[inst : NormedAddCommGroup G] → [NormedSpace ℝ G] → {x : MeasurableSpace α} → MeasureTheory.Measure α → (α → G) → GThe Bochner integral
id : {α : Sort u} → α → αThe identity function. `id` takes an implicit argument `α : Sort u` (a type in any universe), and an argument `a : α`, and returns `a`. Although this may look like a useless function, one application of the identity function is to explicitly put a type on an expression. If `e` has type `T`, and `T'` is definitionally equal to `T`, then `@id T' e` typechecks, and Lean knows that this expression has type `T'` rather than `T`. This can make a difference for typeclass inference, since `T` and `T'` may have different typeclass instances on them. `show T' from e` is sugar for an `@id T' e` expression.
Bandits.bestArm : {𝓐 : Type u_2} → {m𝓐 : MeasurableSpace 𝓐} → [Fintype 𝓐] → [Nonempty 𝓐] → ProbabilityTheory.Kernel 𝓐 ℝ → 𝓐action with the highest mean.Go to its page
Learning.empMean : {𝓐 : Type u_2} → {Ω : Type u_4} → [DecidableEq 𝓐] → (ℕ → Ω → 𝓐) → (ℕ → Ω → ℝ) → 𝓐 → ℕ → Ω → ℝEmpirical mean reward obtained when pulling action `a` up to time `t` (exclusive).Go to its page
HAdd.hAdd : {α : Type u} → {β : Type v} → {γ : outParam (Type w)} → [self : HAdd α β γ] → α → β → γ`a + b` computes the sum of `a` and `b`. The meaning of this notation is type-dependent. Conventions for notations in identifiers: * The recommended spelling of `+` in identifiers is `add`.
Bandits.UCB.ucbWidth : {K : ℕ} → {Ω : Type u_1} → (ℕ → Ω → Fin K) → ℝ → Fin K → ℕ → Ω → ℝThe exploration bonus of the UCB algorithm, which corresponds to the width of a confidence interval.Go to its page
HSub.hSub : {α : Type u} → {β : Type v} → {γ : outParam (Type w)} → [self : HSub α β γ] → α → β → γ`a - b` computes the difference of `a` and `b`. The meaning of this notation is type-dependent. * For natural numbers, this operator saturates at 0: `a - b = 0` when `a ≤ b`. Conventions for notations in identifiers: * The recommended spelling of `-` in identifiers is `sub` (when used as a binary operator).
LT.lt : {α : Type u} → [self : LT α] → α → α → PropThe less-than relation: `x < y` Conventions for notations in identifiers: * The recommended spelling of `<` in identifiers is `lt`.
Bandits.gap : {𝓐 : Type u_2} → {m𝓐 : MeasurableSpace 𝓐} → ProbabilityTheory.Kernel 𝓐 ℝ → 𝓐 → ℝGap of an action `a`: difference between the highest mean of the actions and the mean of `a`.Go to its page
Learning.pullCount : {𝓐 : Type u_2} → {Ω : Type u_4} → [DecidableEq 𝓐] → (ℕ → Ω → 𝓐) → 𝓐 → ℕ → Ω → ℕNumber of times action `a` was chosen up to time `t` (excluding `t`).Go to its page
HMul.hMul : {α : Type u} → {β : Type v} → {γ : outParam (Type w)} → [self : HMul α β γ] → α → β → γ`a * b` computes the product of `a` and `b`. The meaning of this notation is type-dependent. Conventions for notations in identifiers: * The recommended spelling of `*` in identifiers is `mul`.
Real.log : ℝ → ℝThe real logarithm function, equal to the inverse of the exponential for `x > 0`, to `log |x|` for `x < 0`, and to `0` for `0`. We use this unconventional extension to `(-∞, 0]` as it gives the formula `log (x * y) = log x + log y` for all nonzero `x` and `y`, and the derivative of `log` is `1/x` away from `0`.
HDiv.hDiv : {α : Type u} → {β : Type v} → {γ : outParam (Type w)} → [self : HDiv α β γ] → α → β → γ`a / b` computes the result of dividing `a` by `b`. The meaning of this notation is type-dependent. * For most types like `Nat`, `Int`, `Rat`, `Real`, `a / 0` is defined to be `0`. * For `Nat`, `a / b` rounds downwards. * For `Int`, `a / b` rounds downwards if `b` is positive or upwards if `b` is negative. It is implemented as `Int.ediv`, the unique function satisfying `a % b + b * (a / b) = a` and `0 ≤ a % b < natAbs b` for `b ≠ 0`. Other rounding conventions are available using the functions `Int.fdiv` (floor rounding) and `Int.tdiv` (truncation rounding). * For `Float`, `a / 0` follows the IEEE 754 semantics for division, usually resulting in `inf` or `nan`. Conventions for notations in identifiers: * The recommended spelling of `/` in identifiers is `div`.
HPow.hPow : {α : Type u} → {β : Type v} → {γ : outParam (Type w)} → [self : HPow α β γ] → α → β → γ`a ^ b` computes `a` to the power of `b`. The meaning of this notation is type-dependent. Conventions for notations in identifiers: * The recommended spelling of `^` in identifiers is `pow`.
Code
lemma pullCount_le_of_ucbIndex_le (hc : 0 ≤ c) {b : Fin K}
(h_best : (ν (bestArm ν))[id] ≤ empMean A R (bestArm ν) n ω + ucbWidth A c (bestArm ν) n ω)
(h_arm : empMean A R b n ω - ucbWidth A c b n ω ≤ (ν b)[id])
(h_le : empMean A R (bestArm ν) n ω + ucbWidth A c (bestArm ν) n ω ≤
empMean A R b n ω + ucbWidth A c b n ω)
(h_gap_pos : 0 < gap ν b) (h_pull_pos : 0 < pullCount A b n ω) :
pullCount A b n ω ≤ 8 * c * log (n + 1) / gap ν b ^ 2Proof
by
have h_gap_le := gap_le_two_mul_ucbWidth h_best h_arm h_le
rw [ucbWidth] at h_gap_le
have h2 : (gap ν b) ^ 2 ≤ (2 * √(2 * c * log (n + 1) / pullCount A b n ω)) ^ 2 := by
gcongr
rw [mul_pow, sq_sqrt] at h2
· have : (2 : ℝ) ^ 2 = 4 := by norm_num
rw [this] at h2
field_simp at h2 ⊢
grind
· have : 0 ≤ log (n + 1) := by simp [log_nonneg]
positivityNew in v4.34.0-rc2-90-gdde3322 (2026-09-16), and its meaning has not changed since.
Self-contained, with its dependencies inlined and proofs replaced by sorry: download the raw file · open it in the Lean web editor.
Dependency graph
Audit surface: 6 project declarations, 99 external constants
✓ Proved: no sorry anywhere in its closure
This is the tool's own reading of one build's recorded axioms, and it is not robust against an author who wants it to pass. Checking meant to be relied on should go through Comparator, which replays the proof through the kernel from an export against an explicit list of permitted axioms.