Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Theorem 1 — Thompson Sampling has O(ln T/Δ + 1/Δ³) regret on two arms

Proved
AgrawalGoyalTS.TwoArmed.thompson_sampling_two_armed_regret

by mikedeng1 · Oct 4, 2026 · Mathlib 0df444a (Lean v4.33.1)

banditsp2o-batch-pfp1bp2o-gran-per-chapterp2o-plan-paperp2o-v1regretthompson-sampling

Consider the two-armed stochastic bandit problem: arm i∈{1,2}i\in\{1,2\}i∈{1,2} has a fixed reward distribution supported in [0,1][0,1][0,1] with mean μi\mu_iμi​, and arm 1 is the unique optimal arm, μ1>μ2\mu_1>\mu_2μ1​>μ2​. Let Δ=μ1−μ2\Delta=\mu_1-\mu_2Δ=μ1​−μ2​, and let E[R(T)]=E[∑t=1T(μ1−μi(t))]\mathbb E[\mathcal R(T)]=\mathbb E\big[\sum_{t=1}^T(\mu_1-\mu_{i(t)})\big]E[R(T)]=E[∑t=1T​(μ1​−μi(t)​)] be the expected regret in time TTT of Thompson Sampling for general stochastic bandits (Algorithm 2). There is an absolute constant C>0C>0C>0 such that for every such instance and every T≥2T\ge 2T≥2,

E[R(T)]≤C(ln⁡TΔ+1Δ3).\mathbb E[\mathcal R(T)]\le C\Big(\frac{\ln T}{\Delta}+\frac{1}{\Delta^3}\Big).E[R(T)]≤C(ΔlnT​+Δ31​).

This is the first logarithmic finite-time regret bound for Thompson Sampling; its dependence on TTT matches the Lai–Robbins lower bound up to constants.

Formalization Note The paper writes E[R(T)]=O(ln⁡T/Δ+1/Δ3)\mathbb E[\mathcal R(T)]=O(\ln T/\Delta+1/\Delta^3)E[R(T)]=O(lnT/Δ+1/Δ3) in the sense of its footnote 1; we state it with one universal constant CCC, quantified before the reward distributions, the means and TTT, and for every T≥2T\ge 2T≥2. The paper's explicit display on p. 8 (40ln⁡T/Δ+48/Δ3+18Δ40\ln T/\Delta+48/\Delta^3+18\Delta40lnT/Δ+48/Δ3+18Δ) is not the formal claim, because its derivation contains an arithmetic slip. Arm 1 of the paper is Lean arm 0; no condition μ1<1\mu_1<1μ1​<1 or μ2>0\mu_2>0μ2​>0 is assumed.

Preamble
import Mathlib
import Definitions.Def_StochasticBandit
import Definitions.Def_AgrawalGoyalTS_TwoArmed_ThompsonSampling

open MeasureTheory BanditAlgorithm
Formal statement
namespace AgrawalGoyalTS.TwoArmed

/-- Theorem 1 (p. 3): there is an absolute constant `C > 0` such that for every two-armed
stochastic bandit with rewards supported in `[0,1]` and `μ₁ > μ₂` (arm `0` is the paper's arm 1),
and every horizon `T ≥ 2`, Thompson Sampling (Algorithm 2) has expected regret
`E[R(T)] ≤ C (ln T / Δ + 1 / Δ³)`, `Δ = μ₁ - μ₂`. -/
theorem thompson_sampling_two_armed_regret :
    ∃ C : ℝ, 0 < C ∧ ∀ ν : StochasticBandit 2, (∀ i, ν.P i (Set.Icc 0 1) = 1) →
      banditArmMean ν 1 < banditArmMean ν 0 → ∀ T : ℕ, 2 ≤ T →
        tsRegret ν T ≤
          ENNReal.ofReal (C * (Real.log T / (banditArmMean ν 0 - banditArmMean ν 1) +
            1 / (banditArmMean ν 0 - banditArmMean ν 1) ^ 3)) := by sorry

end AgrawalGoyalTS.TwoArmed
Source
Agrawal and Goyal, Analysis of Thompson Sampling for the Multi-armed Bandit Problem, arXiv:1111.1797v3, p. 3, Theorem 1 (O(·) as in footnote 1, p. 4; proof in §3, pp. 6–8)
Human review
  • Endorsed by Shuze Chen · Oct 4, 2026

    Confirmed by the moderator at approval.

  • Endorsed by mikedeng1 · Oct 4, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me