LeanMachineLearning

Bandits.UCB.expectation_pullCount_le๐Ÿ”—

Lemma

Bound on the expectation of the number of pulls of each arm by the UCB algorithm.

๐Ÿ”—theorem
Bandits.UCB.expectation_pullCount_le.{u_1} {K : โ„•} {hK : 0 < K} {c : โ„} {ฮฝ : ProbabilityTheory.Kernel (Fin K) โ„} [ProbabilityTheory.IsMarkovKernel ฮฝ] {ฮฉ : Type u_1} {mฮฉ : MeasurableSpace ฮฉ} {P : MeasureTheory.Measure ฮฉ} [MeasureTheory.IsProbabilityMeasure P] {A : โ„• โ†’ ฮฉ โ†’ Fin K} {R : โ„• โ†’ ฮฉ โ†’ โ„} {ฯƒ2 : NNReal} (h : Learning.IsAlgEnvSeq A R (ucbAlgorithm hK (c * โ†‘ฯƒ2)) (Learning.stationaryEnv ฮฝ) P) (hฮฝ : โˆ€ (a : Fin K), ProbabilityTheory.HasSubgaussianMGF (fun x => x - โˆซ (x : โ„), id x โˆ‚ฮฝ a) ฯƒ2 (ฮฝ a)) (hฯƒ2 : ฯƒ2 โ‰  0) (hc : 0 < c) (a : Fin K) (h_gap : 0 < gap ฮฝ a) (n : โ„•) : โˆซ (x : ฮฉ), (fun ฯ‰ => โ†‘(Learning.pullCount A a n ฯ‰)) x โˆ‚P โ‰ค 8 * c * โ†‘ฯƒ2 * Real.log (โ†‘n + 1) / gap ฮฝ a ^ 2 + 2 + 2 * ENNReal.toReal (constSum c n)
Bandits.UCB.expectation_pullCount_le.{u_1} {K : โ„•} {hK : 0 < K} {c : โ„} {ฮฝ : ProbabilityTheory.Kernel (Fin K) โ„} [ProbabilityTheory.IsMarkovKernel ฮฝ] {ฮฉ : Type u_1} {mฮฉ : MeasurableSpace ฮฉ} {P : MeasureTheory.Measure ฮฉ} [MeasureTheory.IsProbabilityMeasure P] {A : โ„• โ†’ ฮฉ โ†’ Fin K} {R : โ„• โ†’ ฮฉ โ†’ โ„} {ฯƒ2 : NNReal} (h : Learning.IsAlgEnvSeq A R (ucbAlgorithm hK (c * โ†‘ฯƒ2)) (Learning.stationaryEnv ฮฝ) P) (hฮฝ : โˆ€ (a : Fin K), ProbabilityTheory.HasSubgaussianMGF (fun x => x - โˆซ (x : โ„), id x โˆ‚ฮฝ a) ฯƒ2 (ฮฝ a)) (hฯƒ2 : ฯƒ2 โ‰  0) (hc : 0 < c) (a : Fin K) (h_gap : 0 < gap ฮฝ a) (n : โ„•) : โˆซ (x : ฮฉ), (fun ฯ‰ => โ†‘(Learning.pullCount A a n ฯ‰)) x โˆ‚P โ‰ค 8 * c * โ†‘ฯƒ2 * Real.log (โ†‘n + 1) / gap ฮฝ a ^ 2 + 2 + 2 * ENNReal.toReal (constSum c n)

Code

lemma expectation_pullCount_le
    (h : IsAlgEnvSeq A R (ucbAlgorithm hK (c * ฯƒ2)) (stationaryEnv ฮฝ) P)
    (hฮฝ : โˆ€ a, HasSubgaussianMGF (fun x โ†ฆ x - (ฮฝ a)[id]) ฯƒ2 (ฮฝ a))
    (hฯƒ2 : ฯƒ2 โ‰  0) (hc : 0 < c) (a : Fin K) (h_gap : 0 < gap ฮฝ a) (n : โ„•) :
    P[fun ฯ‰ โ†ฆ (pullCount A a n ฯ‰ : โ„)] โ‰ค
      8 * c * ฯƒ2 * log (n + 1) / gap ฮฝ a ^ 2 + 2 + 2 * (constSum c n).toReal
Proof
by
  have hA := h.measurable_action
  have h := expectation_pullCount_le' h hฮฝ hฯƒ2 hc a h_gap n (hK := hK)
  simp_rw [โ† ENNReal.ofReal_natCast] at h
  rw [โ† ofReal_integral_eq_lintegral_ofReal] at h
  rotate_left
  ยท exact integrable_pullCount hA _ _
  ยท exact ae_of_all _ fun _ โ†ฆ by simp
  simp only
  have : 0 โ‰ค log (n + 1) := log_nonneg (by simp)
  rw [โ† ENNReal.ofReal_toReal (a := 2 * constSum c n), โ† ENNReal.ofReal_one, โ† ENNReal.ofReal_add,
    โ† ENNReal.ofReal_add, ENNReal.ofReal_le_ofReal_iff] at h
  rotate_left
  ยท positivity
  ยท positivity
  ยท simp
  ยท have : constSum c n โ‰  โˆž := (constSum_lt_top c n).ne
    finiteness
  ยท simp
  ยท have : constSum c n โ‰  โˆž := (constSum_lt_top c n).ne
    finiteness
  refine h.trans_eq ?_
  simp only [ENNReal.toReal_mul, ENNReal.toReal_ofNat, add_left_inj]
  ring

Actions: Source ยท Open Issue

Meaning last changed in v4.34.0-rc2-14-gf86702d (2026-08-25), 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: 20 project declarations, 146 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.