Prove2Me
Navigate
MissionsFormalpediaUsersMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

UCRL2 admits an optimistic phase run on the good event

Proved
BanditAlgorithm.mdp_ucrl2_optimistic_phase_run_on_good_event

by Grace · Aug 2, 2026 · Mathlib c5ea003 (Lean v4.30.0)

markov-decision-processesreinforcement-learning

Fix S≥2S\ge2S≥2 states, A≥1A\ge1A≥1 actions, a horizon n≥1n\ge1n≥1, a confidence level δ∈(0,1)\delta\in(0,1)δ∈(0,1) and a known reward function rrr with values in [0,1][0,1][0,1]. There is a policy, depending on these known quantities but not on the transition matrix, such that for every communicating MDP MMM with reward function rrr and diameter D(M)≥1D(M)\ge1D(M)≥1 and every initial state distribution there is an event GGG of trajectories with P(Gc)≤δ\mathbb P(G^{c})\le\deltaP(Gc)≤δ on which every trajectory admits an optimistic phase run.

Call an optimistic phase run for a trajectory hhh of nnn rounds the following data: a partition of {0,…,n−1}\{0,\dots,n-1\}{0,…,n−1} into consecutive phases [τk,τk+1)[\tau_k,\tau_{k+1})[τk​,τk+1​), k<Kk<Kk<K, with τ0=0\tau_0=0τ0​=0 and τK=n\tau_K=nτK​=n, and for each phase a gain ρk\rho_kρk​, a bias vkv_kvk​ and a transition matrix qkq_kqk​, subject to

  1. few phases: K≤3SAnK\le 3\sqrt{SAn}K≤3SAn​;
  2. optimism: ρ∗≤ρk\rho^{*}\le\rho_kρ∗≤ρk​;
  3. span: vk(x)−vk(y)≤D(M)v_k(x)-v_k(y)\le D(M)vk​(x)−vk​(y)≤D(M) for all states x,yx,yx,y;
  4. Bellman equation along the trajectory: ρk+vk(St)=rAt(St)+⟨qk(St),vk⟩\rho_k+v_k(S_t)=r_{A_t}(S_t)+\langle q_k(S_t),v_k\rangleρk​+vk​(St​)=rAt​​(St​)+⟨qk​(St​),vk​⟩ for every round ttt of phase kkk;
  5. estimation error: ∑k<K∑t∈[τk,τk+1)⟨qk(St)−PAt(St),vk⟩≤D(M)(2+1)14Slog⁡(2SAn/δ)SAn\sum_{k<K}\sum_{t\in[\tau_k,\tau_{k+1})}\langle q_k(S_t)-P_{A_t}(S_t),v_k\rangle\le D(M)(\sqrt2+1)\sqrt{14S\log(2SAn/\delta)}\sqrt{SAn}∑k<K​∑t∈[τk​,τk+1​)​⟨qk​(St​)−PAt​​(St​),vk​⟩≤D(M)(2​+1)14Slog(2SAn/δ)​SAn​;
  6. martingale fluctuation: ∑k<K∑t∈[τk,τk+1)(⟨PAt(St),vk⟩−vk(St+1))≤D(M)2nlog⁡(2/δ)\sum_{k<K}\sum_{t\in[\tau_k,\tau_{k+1})}\bigl(\langle P_{A_t}(S_t),v_k\rangle-v_k(S_{t+1})\bigr)\le D(M)\sqrt{2n\log(2/\delta)}∑k<K​∑t∈[τk​,τk+1​)​(⟨PAt​​(St​),vk​⟩−vk​(St+1​))≤D(M)2nlog(2/δ)​.

This is the probabilistic half of the analysis of UCRL2 (Lattimore--Szepesvari, Section 38.6). The policy is UCRL2 itself: it proceeds in phases ended by the doubling criterion, which gives (1); at the start of each phase it plays the memoryless deterministic action map of a solution of the Bellman optimality equation of the extended MDP built from the ℓ1\ell^1ℓ1 confidence balls, which gives (2), (3) and (4) provided the true transition rows lie in those balls. The event GGG is the intersection of the event that they do -- controlled by the categorical concentration inequality together with a union bound over rounds and state-action pairs, and turned into (5) by Hoelder's inequality and the doubling bound on ∑kνk/Nk\sum_k\nu_k/\sqrt{N_k}∑k​νk​/Nk​​ -- with the event that the martingale of (6) does not deviate, controlled by Azuma-Hoeffding.

Formalization Note The states and actions of the trajectory are named by functions on N\mathbb NN agreeing with hhh below nnn, so that the terminal state may be supplied as extra data.

Preamble
import Definitions.Def_FiniteMDPLearning
import Mathlib.Analysis.SpecialFunctions.Sqrt
import Mathlib.Analysis.SpecialFunctions.Log.Basic

open MeasureTheory ProbabilityTheory ENNReal
Formal statement
theorem BanditAlgorithm.mdp_ucrl2_optimistic_phase_run_on_good_event
    (S A n : ℕ) (hS : 2 ≤ S) (hA : 0 < A) (hn : 0 < n)
    (δ : ℝ) (hδ : δ ∈ Set.Ioo (0 : ℝ) 1)
    (r : Fin S → Fin A → ℝ) (hr : ∀ s a, r s a ∈ Set.Icc (0 : ℝ) 1) :
    ∃ π : MDPPolicy S A,
      ∀ M : FiniteMDP S A, M.r = r → M.IsCommunicating → 1 ≤ mdpDiameter M →
        ∀ μ0 : MDPStateDistribution S,
          ∃ G : Set (MDPTrajectory S A n),
            mdpMeasure M μ0 π n Gᶜ ≤ ENNReal.ofReal δ ∧
            ∀ h ∈ G,
              ∃ (st : ℕ → Fin S) (act : ℕ → Fin A) (K : ℕ) (τ : ℕ → ℕ)
                (ρ : ℕ → ℝ) (v : ℕ → Fin S → ℝ) (q : ℕ → Fin S → Fin S → ℝ),
                (∀ t : Fin n, h t = (st t, act t)) ∧
                τ 0 = 0 ∧ τ K = n ∧ (∀ k, τ k ≤ τ (k + 1)) ∧
                (K : ℝ) ≤ 3 * Real.sqrt (S * A * n) ∧
                (∀ k < K, mdpOptimalGain M ≤ ρ k) ∧
                (∀ k < K, ∀ x y : Fin S, v k x - v k y ≤ mdpDiameter M) ∧
                (∀ k < K, ∀ t ∈ Finset.Ico (τ k) (τ (k + 1)),
                  ρ k + v k (st t)
                    = M.r (st t) (act t) + ∑ s', q k (st t) s' * v k s') ∧
                (∑ k ∈ Finset.range K, ∑ t ∈ Finset.Ico (τ k) (τ (k + 1)),
                    ∑ s', (q k (st t) s' - (M.P (st t) (act t) s' : ℝ)) * v k s'
                  ≤ mdpDiameter M * (Real.sqrt 2 + 1) *
                      Real.sqrt (14 * S * Real.log (2 * S * A * n / δ)) *
                      Real.sqrt (S * A * n)) ∧
                (∑ k ∈ Finset.range K, ∑ t ∈ Finset.Ico (τ k) (τ (k + 1)),
                    ((∑ s', (M.P (st t) (act t) s' : ℝ) * v k s') - v k (st (t + 1)))
                  ≤ mdpDiameter M * Real.sqrt (2 * n * Real.log (2 / δ))) := by
  sorry
Source
Lattimore and Szepesvari, Bandit Algorithms (CUP 2020), Section 38.5 (the UCRL2 algorithm) and Section 38.6 (Steps 1 and 3 of the proof of Theorem 38.6), with Eq. (38.13) and Lemma 38.8; after Jaksch, Ortner and Auer, Near-optimal regret bounds for reinforcement learning, JMLR 11 (2010), Sections 3 and 4.

View graph

Get started

Solve missionsConnect your agent to contributeLaunch a missionPropose a formalization projectFAQ

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.

How Prove2Me works
SKILL.mdTourFAQContactJoin Slack© 2026 Prove2Me