Foundations of Reinforcement Learning IV: Reinforcement Learning Basics and the UCB-VI AlgorithmTextbook
Motivation
Reinforcement learning (RL) formalizes sequential decision-making under uncertainty: an agent repeatedly observes a state, takes an action, receives a reward, and transitions to a new state, with the goal of maximizing cumulative reward over an unknown environment. It underlies applications from game-playing agents to robotics and adaptive medical treatment. What separates RL from the bandit and contextual bandit problems of earlier chapters in this series is state: the environment carries information forward across time steps, so a good action now can pay off many steps later, and a poor exploration strategy can take exponentially long to discover it. This mission formalizes the foundational results of finite-horizon episodic RL — the Markov Decision Process (MDP) model, the Bellman-optimality principle that makes dynamic programming possible, and the analytical toolkit (the performance-difference and Bellman-residual-decomposition lemmas) used throughout the field's regret analyses — culminating in a polynomial regret guarantee for UCB-VI, the canonical optimism-based algorithm for tabular RL introduced by Azar, Osband, and Munos (Minimax Regret Bounds for Reinforcement Learning, ICML 2017, arXiv:1703.05449).
Setting
A finite-horizon episodic Markov Decision Process consists of a finite state space , a finite action space , a horizon , per-layer transition kernels and reward distributions , and an initial state distribution . An episode unrolls for : the learner selects an action under a randomized non-stationary policy (each ), receives reward , and transitions to . The value of is , and the state-action and state value functions , are the analogous reward-to-go quantities from layer onward. In the online RL problem, is unknown, the learner interacts with it for episodes, and the goal is to minimize the regret against the best policy .
Formalization targets
Goal — Theorem 1 (UCB-VI regret)
for the UCB-VI algorithm run with the explicit bonus , under Assumption 6 (deterministic, known, -bounded rewards). This is the weakest stable form of the guarantee: it fixes only the shape of the bound (polynomial in , logarithmic in ), leaving the exact leading constant — which the book itself does not pin down on this page — outside the formal claim.
Reaching it rests on three structural facts, each formalized as a milestone in attack order:
- Proposition 25 (Bellman optimality): existence of a single deterministic policy simultaneously optimal at every state, computable by backward induction — the reason dynamic programming solves planning at all.
- Lemma 13 (Performance difference) and Lemma 14 (Bellman residual decomposition): two "credit assignment" identities decomposing a value gap (between two policies, or one policy under two models) into a sum of per-layer, on-roll-in terms.
- Lemma 15 (Error decomposition for optimistic policies): the fact that a greedy policy driven by any optimistic value estimate suffers sub-optimality controlled additively — not exponentially — by that estimate's own Bellman residuals, evaluated on-policy.
Significance
The result itself. Theorem 1 is the chapter's headline result: the first guarantee, in this development, that a learning algorithm — one that does not know the environment's transitions in advance — can achieve regret growing only polynomially in the size of the state space, the action space, and the horizon, and only as in the number of episodes. The chapter's own "combination lock" example (Figure 8) shows this is not automatic: naive exploration strategies (such as -greedy, which suffices for ordinary bandits) incur regret exponential in the horizon on some MDPs with as few as states. UCB-VI's guarantee is the sample-complexity foundation on which essentially every subsequent result on tabular, linear, and general function-approximation RL in the book is built.
Formalizing it. No part of this chapter's mathematical content already has a
faithful counterpart on the platform (see Difficulty, below, and Formalization
scope). This mission contributes: (i) a from-scratch Lean formalization of the
finite-horizon episodic MDP model and its value functions, faithful to the book's
/-indexing and reward-distribution conventions; (ii) faithful statements
(drafted with sorry, not yet proved) of Proposition 25 and Lemmas 13–15; and (iii) a
faithful statement of Theorem 1 itself, including a from-scratch construction of the
finite -episode adaptive interaction process needed to make sense of a
high-probability regret guarantee. Proving these — Proposition 25 by backward
induction, Lemmas 13–15 by telescoping, and Theorem 1 by combining Lemma 15's
optimism bound with a concentration argument bounding the estimation-error and
martingale terms of Eqs. (5.30)–(5.33) (omitted here; see Difficulty) — is open work
for solvers.
Difficulty
The obvious approach to Theorem 1 — bound the regret episode-by-episode using only the fact that is close to in some fixed sense — fails because 's error is itself random (it depends on the transitions observed so far) and compounds across layers of dynamic programming. Lemma 15 defuses the compounding: it shows the sub-optimality gap is additive in the per-layer Bellman residuals rather than multiplicative, provided is optimistic. Making optimistic with high probability, in turn, requires a concentration argument for the empirical transition estimates (an application of Freedman's or the Azuma–Hoeffding inequality, not included among this mission's milestones) and a union bound over all — accounting for the inside the bonus's logarithm. The final regret sum further requires bounding by a pigeonhole/potential-function argument over the visitation counts, which is where the scaling — rather than a naive — originates. None of this concentration or counting machinery is included in the current milestones; a solver attempting Theorem 1 needs it as prerequisite lemmas.
Formalization scope
MDP and value functions. States and actions are finite types (Fintype); layers
are represented -indexed throughout the Lean development (the book's layer is
h - 1), with the terminal convention V _ _ H _ = 0 matching .
Since every value/expectation formula in this chapter uses the reward distribution
only through its mean, EpisodicMDP.R records that
mean directly — equivalent, by linearity of expectation, to carrying the full
distribution, and changing no theorem's content. Transition kernels and policies are
represented as plain real-valued functions (S → A → ℝ-style) rather than as
Mathlib's PMF, with IsPolicy/the EpisodicMDP structure's own proof fields
asserting the probability-distribution properties (nonnegativity, summing to )
where the book requires membership in or a well-formed kernel;
this keeps every expectation a finite Finset.sum, needing no measure theory. The
optimal value functions Qstar/Vstar are defined as literal suprema over the
entire (uncountable, since ) policy type — not via a recursive
shortcut — which is what rules out the trivializing formalization of Proposition 25:
defining Vstar by the very recursion the proposition asserts would make the
proposition a tautology, whereas here it is a genuine claim about a supremum over an
enormous space of competitor policies.
UCB-VI and Theorem 1. Because , , , and are all finite, the -episode
adaptive interaction (in which round 's policy is a function of the realized
history of the first episodes) is modeled as a finite probability space: the
outcome type Fin T → Trajectory S A H is a Fintype, "probability" is a finite sum
over it, and "with probability " is a plain inequality between two real
numbers — no MeasureTheory is used anywhere in this mission. The universal constant
in Theorem 1 is existentially quantified (∃ C > 0, …) rather than given as a
literal numeral, since its value is not pinned down by the book on this page and this
mission does not carry out the (non-milestoned) concentration argument that would
derive it; this is the convention adopted throughout for the book's own ""
notation. The empirical-transition estimator inside is defined to be when
(no data yet collected for that pair) — a boundary case Eq. (5.25)
does not address, resolved here by convention rather than proof.
Prior art. The platform's existing BanditAlgorithm.UCRL2Algorithm mission
formalizes UCRL2 for the average-reward, infinite-horizon MDP setting with a
diameter parameter, and its Bellman-optimality statement is the average-cost
optimality equation — genuinely different from this chapter's finite-horizon
episodic Bellman recursion, even though both go by the name "Bellman optimality."
No reference item was reused; every definition and theorem in this mission is
drafted from scratch. Both missions bound regret via optimism over a confidence set
of models, but for different objectives (average reward vs. finite-horizon
cumulative reward) and different MDP classes.
Reusable infrastructure and open contributions. EpisodicMDP, Policy,
V/Q/Qstar/Vstar, and stateDist/stateExp are reusable by any future mission
on finite-horizon episodic RL in this book's later chapters. Contributions welcome:
proofs of the four milestone lemmas (by backward induction and telescoping,
respectively); the concentration lemmas underlying Theorem 1's optimism guarantee
(Eqs. (5.30)–(5.33) of the source, not milestoned here); and the final regret proof
combining them.
Selected references
- Foster, D. J. and Rakhlin, A., Foundations of Reinforcement Learning and Interactive Decision Making, 2023. arXiv:2312.16730v1
- Azar, M. G., Osband, I., and Munos, R., Minimax Regret Bounds for Reinforcement Learning, ICML 2017. arXiv:1703.05449
- Jaksch, T., Ortner, R., and Auer, P., Near-optimal Regret Bounds for Reinforcement Learning, JMLR 11 (2010).