Bandits.UCB.pullCount_le_add_three
No docstring.
-
Ω : 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 : ℕ → Ω → ℝ -
a : Fin K -
n : ℕ -
C : ℕ -
ω : Ω
Learning.pullCount A a n ω ≤
C + 1 +
∑ s ∈ Finset.range n,
{s |
A s ω = a ∧
C < Learning.pullCount A a s ω ∧
∫ (x : ℝ), id x ∂ν (bestArm ν) ≤
Learning.empMean A R (bestArm ν) s ω + ucbWidth A c (bestArm ν) s ω ∧
Learning.empMean A R (A s ω) s ω - ucbWidth A c (A s ω) s ω ≤
∫ (x : ℝ), id x ∂ν (A s ω)}.indicator
1 s +
∑ s ∈ Finset.range n,
{s |
C < Learning.pullCount A a s ω ∧
Learning.empMean A R (bestArm ν) s ω + ucbWidth A c (bestArm ν) s ω <
∫ (x : ℝ), id x ∂ν (bestArm ν)}.indicator
1 s +
∑ s ∈ Finset.range n,
{s |
C < Learning.pullCount A a s ω ∧
∫ (x : ℝ), id x ∂ν a < Learning.empMean A R a s ω - ucbWidth A c a s ω}.indicator
1 sNeZero : {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`.
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
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`.
Finset.range : ℕ → Finset ℕ`range n` is the set of natural numbers less than `n`.
Set.ofPred : {α : Type u} → (α → Prop) → Set αTurn a predicate `p : α → Prop` into a set, also written as `{x | p x}`Eq : {α : Sort u_1} → α → α → PropThe equality relation. It has one introduction rule, `Eq.refl`.
We use `a = b` as notation for `Eq a b`.
A fundamental property of equality is that it is an equivalence relation.
```
variable (α : Type) (a b c d : α)
variable (hab : a = b) (hcb : c = b) (hcd : c = d)
example : a = d :=
Eq.trans (Eq.trans hab (Eq.symm hcb)) hcd
```
Equality is much more than an equivalence relation, however. It has the important property that every assertion
respects the equivalence, in the sense that we can substitute equal expressions without changing the truth value.
That is, given `h1 : a = b` and `h2 : p a`, we can construct a proof for `p b` using substitution: `Eq.subst h1 h2`.
Example:
```
example (α : Type) (a b : α) (p : α → Prop)
(h1 : a = b) (h2 : p a) : p b :=
Eq.subst h1 h2
example (α : Type) (a b : α) (p : α → Prop)
(h1 : a = b) (h2 : p a) : p b :=
h1 ▸ h2
```
The triangle in the second presentation is a macro built on top of `Eq.subst` and `Eq.symm`, and you can enter it by typing `\t`.
For more information: [Equality](https://lean-lang.org/theorem_proving_in_lean4/quantifiers_and_equality.html#equality)
Conventions for notations in identifiers:
* The recommended spelling of `=` in identifiers is `eq`.And : Prop → Prop → Prop`And a b`, or `a ∧ b`, is the conjunction of propositions. It can be constructed and destructed like a pair: if `ha : a` and `hb : b` then `⟨ha, hb⟩ : a ∧ b`, and if `h : a ∧ b` then `h.left : a` and `h.right : b`. Conventions for notations in identifiers: * The recommended spelling of `∧` in identifiers is `and`.
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`.
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
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).
Set.indicator : {α : Type u_1} → {M : Type u_3} → [Zero M] → Set α → (α → M) → α → M`Set.indicator s f a` is `f a` if `a ∈ s`, `0` otherwise.
Code
lemma pullCount_le_add_three (a : Fin K) (n C : ℕ) (ω : Ω) :
pullCount A a n ω ≤ C + 1 +
∑ s ∈ range n, {s | A s ω = a ∧ C < pullCount A a s ω ∧
(ν (bestArm ν))[id] ≤ empMean A R (bestArm ν) s ω + ucbWidth A c (bestArm ν) s ω ∧
empMean A R (A s ω) s ω - ucbWidth A c (A s ω) s ω ≤ (ν (A s ω))[id]}.indicator 1 s +
∑ s ∈ range n,
{s | C < pullCount A a s ω ∧ empMean A R (bestArm ν) s ω + ucbWidth A c (bestArm ν) s ω <
(ν (bestArm ν))[id]}.indicator 1 s +
∑ s ∈ range n,
{s | C < pullCount A a s ω ∧ (ν a)[id] <
empMean A R a s ω - ucbWidth A c a s ω}.indicator 1 sProof
by
refine (pullCount_le_add a n C ω).trans ?_
simp_rw [add_assoc]
gcongr
simp_rw [← add_assoc]
let A' := {s | A s ω = a ∧ C < pullCount A a s ω}
let B := {s | A s ω = a ∧ C < pullCount A a s ω ∧
(ν (bestArm ν))[id] ≤ empMean A R (bestArm ν) s ω + ucbWidth A c (bestArm ν) s ω ∧
empMean A R (A s ω) s ω - ucbWidth A c (A s ω) s ω ≤ (ν (A s ω))[id]}
let C' := {s | C < pullCount A a s ω ∧
empMean A R (bestArm ν) s ω + ucbWidth A c (bestArm ν) s ω < (ν (bestArm ν))[id]}
let D := {s | C < pullCount A a s ω ∧ (ν a)[id] < empMean A R a s ω - ucbWidth A c a s ω}
change ∑ s ∈ range n, A'.indicator 1 s ≤
∑ s ∈ range n, B.indicator 1 s + ∑ s ∈ range n, C'.indicator 1 s +
∑ s ∈ range n, D.indicator 1 s
have h_union : A' ⊆ B ∪ C' ∪ D := by simp [A', B, C', D]; grind
calc
(∑ s ∈ range n, A'.indicator 1 s)
_ ≤ (∑ s ∈ range n, (B ∪ C' ∪ D).indicator (fun _ ↦ (1 : ℕ)) s) := by
gcongr with n hn
by_cases h : n ∈ A'
· have : n ∈ B ∪ C' ∪ D := h_union h
simp [h, this]
· simp [h]
_ ≤ ∑ s ∈ range n, (B.indicator 1 s + C'.indicator 1 s + D.indicator 1 s) := by
gcongr with s
simp [Set.indicator_apply]
grind
_ = ∑ s ∈ range n, B.indicator 1 s + ∑ s ∈ range n, C'.indicator 1 s +
∑ s ∈ range n, D.indicator 1 s := by
rw [Finset.sum_add_distrib, Finset.sum_add_distrib]Meaning last changed in v4.34.0-rc2-90-gdde3322 (2026-09-16), the 5th recorded change.
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: 5 project declarations, 96 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.