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).

Types
  • Ξ© : Type u_1MeasurableSpace Ξ©A measurable space is a space equipped with a Οƒ-algebra.
  • 𝓔 : Type u_2MeasurableSpace 𝓔StandardBorelSpace 𝓔A standard Borel space is a measurable space arising as the Borel sets of some Polish topology.Nonempty 𝓔
Given
  • K : β„•Nonempty (Fin K)
  • l : ℝ
  • u : ℝ
  • Οƒ2 : ℝ
  • Q : MeasureTheory.Measure 𝓔A measure is defined to be an outer measure that is countably additive on measurable sets, with the additional assumption that the outer measure is the canonical extension of the restricted measure.MeasureTheory.IsProbabilityMeasure QA measure ΞΌ is called a probability measure if ΞΌ univ = 1.
  • ΞΊ : ProbabilityTheory.Kernel (𝓔 Γ— Fin K) ℝA kernel from a measurable space Ξ± to another measurable space Ξ² is a measurable function ΞΊ : Ξ± β†’ Measure Ξ².ProbabilityTheory.IsMarkovKernel ΞΊA kernel is a Markov kernel if every measure in its image is a probability measure.
  • E : Ξ© β†’ 𝓔
  • A : β„• β†’ Ξ© β†’ Fin K
  • R : β„• β†’ Ξ© β†’ ℝ
  • P : MeasureTheory.Measure Ξ©MeasureTheory.IsProbabilityMeasure P
  • n : β„•
Assuming
Then
∫ (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-39-gb743f31 (2026-09-08), 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: 25 project declarations, 140 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.