Bandits.UCB.pullCount_le_add_three
This page has the declaration's own card below, then its dependency graph, then a card for each dependency (type dependencies first, then the rest of the transitive closure). For a theorem, the graph and the dependency cards only follow its statement's dependencies (its proof is replaced by sorry, so what it proves doesn't depend on how); for everything else, both the type and the body/value are followed, since their content is part of what later declarations build on.
pullCount_le_add_three๐
Bandits.UCB.pullCount_le_add_threeNo docstring.
Bandits.UCB.pullCount_le_add_three.{u_1} {K : โ} {c : โ} {ฮฝ : ProbabilityTheory.Kernel (Fin K) โ} {ฮฉ : Type u_1} {A : โ โ ฮฉ โ Fin K} {R : โ โ ฮฉ โ โ} [Nonempty (Fin K)] (a : Fin K) (n C : โ) (ฯ : ฮฉ) : Learning.pullCount A a n ฯ โค C + 1 + โ s โ Finset.range n, Set.indicator {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 ฯ)} 1 s + โ s โ Finset.range n, Set.indicator {s | C < Learning.pullCount A a s ฯ โง Learning.empMean A R (bestArm ฮฝ) s ฯ + ucbWidth A c (bestArm ฮฝ) s ฯ < โซ (x : โ), id x โฮฝ (bestArm ฮฝ)} 1 s + โ s โ Finset.range n, Set.indicator {s | C < Learning.pullCount A a s ฯ โง โซ (x : โ), id x โฮฝ a < Learning.empMean A R a s ฯ - ucbWidth A c a s ฯ} 1 sBandits.UCB.pullCount_le_add_three.{u_1} {K : โ} {c : โ} {ฮฝ : ProbabilityTheory.Kernel (Fin K) โ} {ฮฉ : Type u_1} {A : โ โ ฮฉ โ Fin K} {R : โ โ ฮฉ โ โ} [Nonempty (Fin K)] (a : Fin K) (n C : โ) (ฯ : ฮฉ) : Learning.pullCount A a n ฯ โค C + 1 + โ s โ Finset.range n, Set.indicator {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 ฯ)} 1 s + โ s โ Finset.range n, Set.indicator {s | C < Learning.pullCount A a s ฯ โง Learning.empMean A R (bestArm ฮฝ) s ฯ + ucbWidth A c (bestArm ฮฝ) s ฯ < โซ (x : โ), id x โฮฝ (bestArm ฮฝ)} 1 s + โ s โ Finset.range n, Set.indicator {s | C < Learning.pullCount A a s ฯ โง โซ (x : โ), id x โฮฝ a < Learning.empMean A R a s ฯ - ucbWidth A c a s ฯ} 1 s
Code
lemma pullCount_le_add_three [Nonempty (Fin K)] (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 sBody uses (1)
Used by (1)
Actions: Source ยท Open Issue
Proof
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]Dependency graph
Type dependencies (4)
pullCount๐
Learning.pullCount
Number of times action a was chosen up to time t (excluding t).
Learning.pullCount.{u_1, u_3} {๐ : Type u_1} {ฮฉ : Type u_3} [DecidableEq ๐] (A : โ โ ฮฉ โ ๐) (a : ๐) (t : โ) (ฯ : ฮฉ) : โLearning.pullCount.{u_1, u_3} {๐ : Type u_1} {ฮฉ : Type u_3} [DecidableEq ๐] (A : โ โ ฮฉ โ ๐) (a : ๐) (t : โ) (ฯ : ฮฉ) : โ
Code
noncomputable def pullCount (A : โ โ ฮฉ โ ๐) (a : ๐) (t : โ) (ฯ : ฮฉ) : โ := #(filter (fun s โฆ A s ฯ = a) (range t))
Actions: Source ยท Open Issue
bestArm๐
Bandits.bestArmaction with the highest mean.
Bandits.bestArm.{u_1} {๐ : Type u_1} {m๐ : MeasurableSpace ๐} [Fintype ๐] [Nonempty ๐] (ฮฝ : ProbabilityTheory.Kernel ๐ โ) : ๐Bandits.bestArm.{u_1} {๐ : Type u_1} {m๐ : MeasurableSpace ๐} [Fintype ๐] [Nonempty ๐] (ฮฝ : ProbabilityTheory.Kernel ๐ โ) : ๐
Code
noncomputable def bestArm (ฮฝ : Kernel ๐ โ) : ๐ := (exists_max_image univ (fun a โฆ (ฮฝ a)[id]) (univ_nonempty_iff.mpr inferInstance)).choose
Used by (18)
Actions: Source ยท Open Issue
empMean๐
Learning.empMean
Empirical mean reward obtained when pulling action a up to time t (exclusive).
Learning.empMean.{u_1, u_3} {๐ : Type u_1} {ฮฉ : Type u_3} [DecidableEq ๐] (A : โ โ ฮฉ โ ๐) (R' : โ โ ฮฉ โ โ) (a : ๐) (t : โ) (ฯ : ฮฉ) : โLearning.empMean.{u_1, u_3} {๐ : Type u_1} {ฮฉ : Type u_3} [DecidableEq ๐] (A : โ โ ฮฉ โ ๐) (R' : โ โ ฮฉ โ โ) (a : ๐) (t : โ) (ฯ : ฮฉ) : โ
Code
noncomputable def empMean (A : โ โ ฮฉ โ ๐) (R' : โ โ ฮฉ โ โ) (a : ๐) (t : โ) (ฯ : ฮฉ) : โ := sumRewards A R' a t ฯ / pullCount A a t ฯ
Body uses (2)
Actions: Source ยท Open Issue
ucbWidth๐
Bandits.UCB.ucbWidthThe exploration bonus of the UCB algorithm, which corresponds to the width of a confidence interval.
Bandits.UCB.ucbWidth.{u_1} {K : โ} {ฮฉ : Type u_1} (A : โ โ ฮฉ โ Fin K) (c : โ) (a : Fin K) (n : โ) (ฯ : ฮฉ) : โBandits.UCB.ucbWidth.{u_1} {K : โ} {ฮฉ : Type u_1} (A : โ โ ฮฉ โ Fin K) (c : โ) (a : Fin K) (n : โ) (ฯ : ฮฉ) : โ
Code
noncomputable def ucbWidth (A : โ โ ฮฉ โ Fin K) (c : โ) (a : Fin K) (n : โ) (ฯ : ฮฉ) : โ := โ(2 * c * log (n + 1) / pullCount A a n ฯ)
Body uses (1)
Used by (16)
Actions: Source ยท Open Issue
All dependencies, transitively (1)
sumRewards๐
Learning.sumRewards
Sum of rewards obtained when pulling action a up to time t (exclusive).
Learning.sumRewards.{u_1, u_3} {๐ : Type u_1} {ฮฉ : Type u_3} [DecidableEq ๐] (A : โ โ ฮฉ โ ๐) (R' : โ โ ฮฉ โ โ) (a : ๐) (t : โ) (ฯ : ฮฉ) : โLearning.sumRewards.{u_1, u_3} {๐ : Type u_1} {ฮฉ : Type u_3} [DecidableEq ๐] (A : โ โ ฮฉ โ ๐) (R' : โ โ ฮฉ โ โ) (a : ๐) (t : โ) (ฯ : ฮฉ) : โ
Code
def sumRewards (A : โ โ ฮฉ โ ๐) (R' : โ โ ฮฉ โ โ) (a : ๐) (t : โ) (ฯ : ฮฉ) : โ := โ s โ range t, if A s ฯ = a then R' s ฯ else 0
Used by (44)
Actions: Source ยท Open Issue