LeanMachineLearning exposition

Bandits.ClippedUCB.ucb_succ_eq_ucb'๐Ÿ”—

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.

Minimal Lean file

ucb_succ_eq_ucb'๐Ÿ”—

LemmaBandits.ClippedUCB.ucb_succ_eq_ucb'

No docstring.

๐Ÿ”—theorem
Bandits.ClippedUCB.ucb_succ_eq_ucb'.{u_1} {K : โ„•} {l u ฯƒ2 ฮด : โ„} {ฮฉ : Type u_1} {A : โ„• โ†’ ฮฉ โ†’ Fin K} {R : โ„• โ†’ ฮฉ โ†’ โ„} {a : Fin K} {n : โ„•} {ฯ‰ : ฮฉ} : ucb A R l u ฯƒ2 ฮด a (n + 1) ฯ‰ = ucb' n (Learning.history A R n ฯ‰) l u ฯƒ2 ฮด a
Bandits.ClippedUCB.ucb_succ_eq_ucb'.{u_1} {K : โ„•} {l u ฯƒ2 ฮด : โ„} {ฮฉ : Type u_1} {A : โ„• โ†’ ฮฉ โ†’ Fin K} {R : โ„• โ†’ ฮฉ โ†’ โ„} {a : Fin K} {n : โ„•} {ฯ‰ : ฮฉ} : ucb A R l u ฯƒ2 ฮด a (n + 1) ฯ‰ = ucb' n (Learning.history A R n ฯ‰) l u ฯƒ2 ฮด a

Code

lemma ucb_succ_eq_ucb' {a : Fin K} {n : โ„•} {ฯ‰ : ฮฉ} :
    ucb A R l u ฯƒ2 ฮด a (n + 1) ฯ‰ = ucb' n (history A R n ฯ‰) l u ฯƒ2 ฮด a
Type uses (3)
Body uses (6)
Used by (1)

Actions: Source ยท Open Issue

Proof
by
  have hp : pullCount A a (n + 1) ฯ‰ = pullCount' n (history A R n ฯ‰) a :=
    pullCount_add_one_eq_pullCount'
  have he : empMean A R a (n + 1) ฯ‰ = empMean' n (history A R n ฯ‰) a :=
    empMean_add_one_eq_empMean'
  rw [ucb, ucb', hp, he]

Dependency graph

Type dependencies (3)

ucb๐Ÿ”—

DefinitionBandits.ClippedUCB.ucb

Clipped upper confidence bound used in the regret analysis of Thompson sampling.

๐Ÿ”—def
Bandits.ClippedUCB.ucb.{u_1} {K : โ„•} {ฮฉ : Type u_1} (A : โ„• โ†’ ฮฉ โ†’ Fin K) (R : โ„• โ†’ ฮฉ โ†’ โ„) (l u ฯƒ2 ฮด : โ„) (a : Fin K) (n : โ„•) (ฯ‰ : ฮฉ) : โ„
Bandits.ClippedUCB.ucb.{u_1} {K : โ„•} {ฮฉ : Type u_1} (A : โ„• โ†’ ฮฉ โ†’ Fin K) (R : โ„• โ†’ ฮฉ โ†’ โ„) (l u ฯƒ2 ฮด : โ„) (a : Fin K) (n : โ„•) (ฯ‰ : ฮฉ) : โ„

Code

noncomputable
def ucb (A : โ„• โ†’ ฮฉ โ†’ Fin K) (R : โ„• โ†’ ฮฉ โ†’ โ„) (l u ฯƒ2 ฮด : โ„) (a : Fin K) (n : โ„•) (ฯ‰ : ฮฉ) : โ„ :=
  if pullCount A a n ฯ‰ = 0 then u
  else max l (min u (empMean A R a n ฯ‰ + โˆš(2 * ฯƒ2 * Real.log (1 / ฮด) / (pullCount A a n ฯ‰))))
Body uses (2)
Used by (12)

Actions: Source ยท Open Issue

ucb'๐Ÿ”—

DefinitionBandits.ClippedUCB.ucb'

Clipped upper confidence bound (history-based version).

๐Ÿ”—def
Bandits.ClippedUCB.ucb' {K : โ„•} (n : โ„•) (h : โ†ฅ(Finset.Iic n) โ†’ Fin K ร— โ„) (l u ฯƒ2 ฮด : โ„) (a : Fin K) : โ„
Bandits.ClippedUCB.ucb' {K : โ„•} (n : โ„•) (h : โ†ฅ(Finset.Iic n) โ†’ Fin K ร— โ„) (l u ฯƒ2 ฮด : โ„) (a : Fin K) : โ„

Code

noncomputable
def ucb' (n : โ„•) (h : Iic n โ†’ Fin K ร— โ„) (l u ฯƒ2 ฮด : โ„) (a : Fin K) : โ„ :=
  if pullCount' n h a = 0 then u
  else max l (min u (empMean' n h a + โˆš(2 * ฯƒ2 * Real.log (1 / ฮด) / (pullCount' n h a))))
Body uses (2)
Used by (3)

Actions: Source ยท Open Issue

history๐Ÿ”—

DefinitionLearning.history

History of the algorithm-environment sequence up to time n.

๐Ÿ”—def
Learning.history.{u_1, u_2, u_3} {๐“ : Type u_1} {๐“จ : Type u_2} {ฮฉ : Type u_3} (A : โ„• โ†’ ฮฉ โ†’ ๐“) (Y : โ„• โ†’ ฮฉ โ†’ ๐“จ) (n : โ„•) (ฯ‰ : ฮฉ) : โ†ฅ(Finset.Iic n) โ†’ ๐“ ร— ๐“จ
Learning.history.{u_1, u_2, u_3} {๐“ : Type u_1} {๐“จ : Type u_2} {ฮฉ : Type u_3} (A : โ„• โ†’ ฮฉ โ†’ ๐“) (Y : โ„• โ†’ ฮฉ โ†’ ๐“จ) (n : โ„•) (ฯ‰ : ฮฉ) : โ†ฅ(Finset.Iic n) โ†’ ๐“ ร— ๐“จ

Code

def history (A : โ„• โ†’ ฮฉ โ†’ ๐“) (Y : โ„• โ†’ ฮฉ โ†’ ๐“จ) (n : โ„•) (ฯ‰ : ฮฉ) : Iic n โ†’ ๐“ ร— ๐“จ :=
  fun i โ†ฆ (A i ฯ‰, Y i ฯ‰)
Used by (72)

Actions: Source ยท Open Issue

All dependencies, transitively (6)

pullCount๐Ÿ”—

DefinitionLearning.pullCount

Number of times action a was chosen up to time t (excluding t).

๐Ÿ”—def
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))
Used by (146)

Actions: Source ยท Open Issue

sumRewards๐Ÿ”—

DefinitionLearning.sumRewards

Sum of rewards obtained when pulling action a up to time t (exclusive).

๐Ÿ”—def
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

empMean๐Ÿ”—

DefinitionLearning.empMean

Empirical mean reward obtained when pulling action a up to time t (exclusive).

๐Ÿ”—def
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)
Used by (34)

Actions: Source ยท Open Issue

pullCount'๐Ÿ”—

DefinitionLearning.pullCount'

Number of pulls of arm a up to (and including) time n. This is the number of entries in h in which the arm is a.

๐Ÿ”—def
Learning.pullCount'.{u_1, u_2} {๐“ : Type u_1} {R : Type u_2} [DecidableEq ๐“] (n : โ„•) (h : โ†ฅ(Finset.Iic n) โ†’ ๐“ ร— R) (a : ๐“) : โ„•
Learning.pullCount'.{u_1, u_2} {๐“ : Type u_1} {R : Type u_2} [DecidableEq ๐“] (n : โ„•) (h : โ†ฅ(Finset.Iic n) โ†’ ๐“ ร— R) (a : ๐“) : โ„•

Code

noncomputable
def pullCount' (n : โ„•) (h : Iic n โ†’ ๐“ ร— R) (a : ๐“) := #{s | (h s).1 = a}
Used by (29)

Actions: Source ยท Open Issue

sumRewards'๐Ÿ”—

DefinitionLearning.sumRewards'

Sum of rewards of arm a up to (and including) time n.

๐Ÿ”—def
Learning.sumRewards'.{u_1} {๐“ : Type u_1} [DecidableEq ๐“] (n : โ„•) (h : โ†ฅ(Finset.Iic n) โ†’ ๐“ ร— โ„) (a : ๐“) : โ„
Learning.sumRewards'.{u_1} {๐“ : Type u_1} [DecidableEq ๐“] (n : โ„•) (h : โ†ฅ(Finset.Iic n) โ†’ ๐“ ร— โ„) (a : ๐“) : โ„

Code

noncomputable
def sumRewards' (n : โ„•) (h : Iic n โ†’ ๐“ ร— โ„) (a : ๐“) :=
  โˆ‘ s, if (h s).1 = a then (h s).2 else 0
Used by (9)

Actions: Source ยท Open Issue

empMean'๐Ÿ”—

DefinitionLearning.empMean'

Empirical mean of arm a at time n.

๐Ÿ”—def
Learning.empMean'.{u_1} {๐“ : Type u_1} [DecidableEq ๐“] (n : โ„•) (h : โ†ฅ(Finset.Iic n) โ†’ ๐“ ร— โ„) (a : ๐“) : โ„
Learning.empMean'.{u_1} {๐“ : Type u_1} [DecidableEq ๐“] (n : โ„•) (h : โ†ฅ(Finset.Iic n) โ†’ ๐“ ร— โ„) (a : ๐“) : โ„

Code

noncomputable
def empMean' (n : โ„•) (h : Iic n โ†’ ๐“ ร— โ„) (a : ๐“) :=
  (sumRewards' n h a) / (pullCount' n h a)
Body uses (2)
Used by (18)

Actions: Source ยท Open Issue