LeanMachineLearning

Bandits.TS.integral_regret_leπŸ”—

Theorem

If Thompson sampling has the correct prior over environments and every environment has K actions, each of which has a corresponding reward between l and u that is sub-Gaussian with variance proxy Οƒ2 after its mean is subtracted, then the Bayesian regret at time n is at most (2 * K + 1) * (u - l) + 8 * √(Οƒ2 * K * n * Real.log n).

πŸ”—theorem
Bandits.TS.integral_regret_le.{u_1, u_2} {K : β„•} [Nonempty (Fin K)] {l u Οƒ2 : ℝ} {Ξ© : Type u_1} [MeasurableSpace Ξ©] {𝓔 : Type u_2} [MeasurableSpace 𝓔] [StandardBorelSpace 𝓔] [Nonempty 𝓔] {Q : MeasureTheory.Measure 𝓔} [MeasureTheory.IsProbabilityMeasure Q] {ΞΊ : ProbabilityTheory.Kernel (𝓔 Γ— Fin K) ℝ} [ProbabilityTheory.IsMarkovKernel ΞΊ] {E : Ξ© β†’ 𝓔} {A : β„• β†’ Ξ© β†’ Fin K} {R : β„• β†’ Ξ© β†’ ℝ} {P : MeasureTheory.Measure Ξ©} [MeasureTheory.IsProbabilityMeasure P] (hK : 0 < K) (h : Learning.IsBayesAlgEnvSeq Q ΞΊ (tsAlgorithm hK Q ΞΊ) E A R P) (hlu : l ≀ u) (hm : βˆ€ (e : 𝓔) (a : Fin K), ∫ (x : ℝ), id x βˆ‚ΞΊ (e, a) ∈ Set.Icc l u) (hΟƒ2 : 0 < Οƒ2) (hs : βˆ€ (e : 𝓔) (a : Fin K), ProbabilityTheory.HasSubgaussianMGF (fun x => x - ∫ (x : ℝ), id x βˆ‚ΞΊ (e, a)) βŸ¨Οƒ2, β‹―βŸ© (ΞΊ (e, a))) (n : β„•) : ∫ (x : Ξ©), Learning.IsBayesAlgEnvSeq.regret ΞΊ E A n x βˆ‚P ≀ (2 * ↑K + 1) * (u - l) + 8 * √(Οƒ2 * ↑K * ↑n * Real.log ↑n)
Bandits.TS.integral_regret_le.{u_1, u_2} {K : β„•} [Nonempty (Fin K)] {l u Οƒ2 : ℝ} {Ξ© : Type u_1} [MeasurableSpace Ξ©] {𝓔 : Type u_2} [MeasurableSpace 𝓔] [StandardBorelSpace 𝓔] [Nonempty 𝓔] {Q : MeasureTheory.Measure 𝓔} [MeasureTheory.IsProbabilityMeasure Q] {ΞΊ : ProbabilityTheory.Kernel (𝓔 Γ— Fin K) ℝ} [ProbabilityTheory.IsMarkovKernel ΞΊ] {E : Ξ© β†’ 𝓔} {A : β„• β†’ Ξ© β†’ Fin K} {R : β„• β†’ Ξ© β†’ ℝ} {P : MeasureTheory.Measure Ξ©} [MeasureTheory.IsProbabilityMeasure P] (hK : 0 < K) (h : Learning.IsBayesAlgEnvSeq Q ΞΊ (tsAlgorithm hK Q ΞΊ) E A R P) (hlu : l ≀ u) (hm : βˆ€ (e : 𝓔) (a : Fin K), ∫ (x : ℝ), id x βˆ‚ΞΊ (e, a) ∈ Set.Icc l u) (hΟƒ2 : 0 < Οƒ2) (hs : βˆ€ (e : 𝓔) (a : Fin K), ProbabilityTheory.HasSubgaussianMGF (fun x => x - ∫ (x : ℝ), id x βˆ‚ΞΊ (e, a)) βŸ¨Οƒ2, β‹―βŸ© (ΞΊ (e, a))) (n : β„•) : ∫ (x : Ξ©), Learning.IsBayesAlgEnvSeq.regret ΞΊ E A n x βˆ‚P ≀ (2 * ↑K + 1) * (u - l) + 8 * √(Οƒ2 * ↑K * ↑n * Real.log ↑n)

Code

theorem integral_regret_le (hK : 0 < K) (h : IsBayesAlgEnvSeq Q ΞΊ (tsAlgorithm hK Q ΞΊ) E A R P)
    (hlu : l ≀ u) (hm : βˆ€ e a, (ΞΊ (e, a))[id] ∈ (Set.Icc l u)) (hΟƒ2 : 0 < Οƒ2)
    (hs : βˆ€ e a, HasSubgaussianMGF (fun x ↦ x - (ΞΊ (e, a))[id]) βŸ¨Οƒ2, hΟƒ2.le⟩ (ΞΊ (e, a))) (n : β„•) :
    P[IsBayesAlgEnvSeq.regret ΞΊ E A n]
      ≀ (2 * K + 1) * (u - l) + 8 * √(Οƒ2 * K * n * Real.log n)
Proof
by
  by_cases hn : n = 0
  Β· simp [hn, IsBayesAlgEnvSeq.regret, Bandits.regret]
    nlinarith
  have hΞ΄ : (0 : ℝ) < 1 / n ^ 2 := by positivity
  calc P[IsBayesAlgEnvSeq.regret ΞΊ E A n]
      = _ :=
        integral_regret_eq_add hK h hm n
    _ ≀ _ :=
        add_le_add
          (integral_sum_range_actionMean_bestAction_sub_ucb_bestAction_le h hlu hm hσ2 hs hδ n)
          (integral_sum_range_ucb_action_sub_actionMean_action_le h hlu hm hσ2 hs hδ n)
    _ = K * (u - l) + (K + 1) * (u - l) * ((n - 1) / n)
          + 4 * √((2 : ℝ) ^ 2 * (Οƒ2 * K * n * Real.log n)) := by
        field_simp
        rw [Real.log_pow]
        ring_nf
    _ = K * (u - l) + (K + 1) * (u - l) * ((n - 1) / n) + 8 * √(Οƒ2 * K * n * Real.log n) := by
        rw [Real.sqrt_mul (by positivity), Real.sqrt_sq (by norm_num)]
        ring
    _ ≀ K * (u - l) + (K + 1) * (u - l) * 1 + 8 * √(Οƒ2 * K * n * Real.log n) := by -- loose
        have : 0 ≀ u - l := sub_nonneg.2 hlu
        gcongr
        rw [div_le_one (by positivity)]
        linarith
    _ = _ := by
        ring

Actions: Source Β· Open Issue

Meaning last changed in v4.34.0-rc2-1-g439785b (2026-08-23), the 4th 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: 23 project declarations, 126 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.