Markov Decision Processes — From Bandits to Reinforcement Learning

Markov decision processes as bandits whose actions also move a state. Covers the setup (states, actions, transitions, deterministic rewards), histories and policies (memoryless, deterministic, Markov), traps, strong connectivity and the diameter; the average-reward criterion, with gain, stationary transition matrix, differential value function as a Cesàro sum, the Poisson equation, the Bellman optimality equation (existence, optimality of greedy policies, non-uniqueness, span ≤ diameter) and the Bellman operator. Planning with known dynamics uses two linear programs for the optimal gain and an optimal value function, solved in polynomial time by the ellipsoid method with a separation oracle; value and policy iteration are noted. Learning with unknown transitions measures regret nρ* − Σ rewards. UCRL2 combines L1 confidence sets, the extended MDP trick for optimism and doubling phases to get regret O(D S √(An log(nSA/δ))), proved via optimism, Bellman telescoping, Azuma and phase counting. A lower bound of Ω(√(DSAn)) comes from a tree-to-good/bad-state construction reducing MDPs to bandits with about SA arms. Notes cover episodic MDPs, POMDPs, discounting and the vanishing-discount method, traps and maximal end components, unknown rewards, the √(DS) gap, and the reinforcement learning literature.

· 23 min read · 4,535 words

Corresponds to Lattimore & Szepesvári, Chapter 38, the book’s final chapter.

Motivation: actions with long-term consequences

IntuitionBandits plus state

A brewery’s ingredient orders today shape what it can brew next month. A student’s study choices pay off now and in future job prospects. Bandits can’t express this. A Markov decision process adds a state that the learner observes: rewards depend on (state, action), and actions influence the next state. A bandit is an MDP with one state; a contextual bandit is an MDP whose next state ignores the action (Exercise 38.25).

QuestionTool
What is optimal behaviour in a known MDP?gain, Bellman optimality equation
How do we compute it?linear programming (polynomial time); value or policy iteration (practical)
How do we learn it with unknown dynamics?UCRL2: optimism over a confidence set of MDPs
How well can one learn?O~(DSAn)\tilde O(DS\sqrt{An}) upper bound versus Ω(DSAn)\Omega(\sqrt{DSAn}) lower bound

Problem set-up

DefinitionMarkov decision process M=(S,A,P,r,μ)M = (\mathcal S,\mathcal A,P,r,\mu)

  • states S\mathcal S and actions A\mathcal A, of sizes SS and AA (finite MDP if both are finite; take S=[S]\mathcal S = [S]);
  • transitions Pa(s,s′)P_a(s,s'): the probability of moving s→s′s\to s' under action aa, with right-stochastic matrices PaP_a and rows Pa(s)∈P(S)P_a(s)\in\mathcal P(\mathcal S);
  • deterministic rewards ra(s)∈[0,1]r_a(s)\in[0,1], also viewed as vectors in [0,1]S[0,1]^S;
  • initial distribution μ\mu.

Protocol: S1∼μS_1\sim\mu. In each round, observe StS_t, choose AtA_t, receive rAt(St)r_{A_t}(S_t), then St+1∼PAt(St)S_{t+1}\sim P_{A_t}(S_t).

flowchart LR
  O["Observe state S_t"] --> C["Choose action A_t"]
  C --> R["Receive r(A_t, S_t)"]
  R --> T["Next state drawn from P(A_t, S_t)"]
  T --> O

NoteActions are per-state labels

The same action set in every state implies no similarity between Pa(s)P_a(s) and Pa(s′)P_a(s'). State-dependent action sets change nothing. The colours in the book’s figures (solid = “increment”, dashed = “decrement”) are only for human readability.

DefinitionHistories and policies

The history Ht=(S1,A1,…,At−1,St)H_t = (S_1,A_1,\ldots,A_{t-1},S_t) includes the current state; rewards are recomputable. A policy maps histories to (distributions over) actions.

ClassDepends onNotation
Memoryless (stationary)current state only, possibly randomisedΠM\Pi_M, π(a∣s)\pi(a\mid s)
Deterministic memorylesscurrent state, no randomisationΠDM\Pi_{DM}, π:S→A\pi : \mathcal S\to\mathcal A
Markovtime index and current statea sequence of memoryless policies

Under a Markov policy the states form a Markov chain, homogeneous if the policy is memoryless. The infinite interaction exists by Ionescu–Tulcea (Exercise 38.1). Markov policies suffice: for any policy there is a Markov policy with the same state–action marginals, hence the same rewards (Exercise 38.2; Strauch 1966).

Traps and the diameter

WarningTraps make learning hopeless

A trap is a set of states with no escape. A learner discovers that an action leads to a trap only by trying it, so competing with an informed agent is impossible: policies with sublinear regret on all strongly connected MDPs suffer linear regret on MDPs with suboptimal traps (Exercise 38.28). Assume no traps.

DefinitionStrong connectivity and diameter (Def. 38.1)

MM is strongly connected (communicating) if every state can reach every other under some policy with positive probability. The diameter is

D(M)=max⁡s≠s′min⁡π∈ΠDMEπ[min⁡{t≥1:St=s}∣S1=s′]−1D(M) = \max_{s\ne s'}\min_{\pi\in\Pi_{DM}}\mathbb E^\pi\big[\min\{t\ge1 : S_t = s\}\mid S_1 = s'\big] - 1

the worst-case expected travel time between states, using the best policy for each pair.

FactDetail
Different policy per pairthe max is outside the min
Deterministic memoryless sufficestravel times satisfy a shortest-path fixed point (Exercise 38.3)
D<∞D < \inftyiff strongly connected, for finite MDPs (Exercise 38.4)
Lower limitD≥log⁡AS−3D\ge\log_AS - 3: at most AkA^k states are reachable in kk steps (Exercise 38.5)
Meaningsmall DD means mistakes are cheap to recover from

All MDPs below are strongly connected.


Optimal policies and the Bellman optimality equation

DefinitionGain and optimality (average reward)

ρsπ=lim⁡n→∞1n∑t=1nEπ[rAt(St)∣S1=s],ρˉsπ=lim sup⁡n→∞(⋯ ),ρ∗=max⁡ssup⁡πρˉsπ\rho_s^\pi = \lim_{n\to\infty}\frac1n\sum_{t=1}^n\mathbb E^\pi[r_{A_t}(S_t)\mid S_1 = s],\qquad\bar\rho_s^\pi = \limsup_{n\to\infty}(\cdots),\qquad\rho^* = \max_s\sup_\pi\bar\rho_s^\pi

π\pi is optimal if ρπ=ρ∗1\rho^\pi = \rho^*\mathbf 1. Optimal policies exist for strongly connected MDPs, which is far from trivial. Without strong connectivity, the optimal gain is a vector ρs∗\rho^*_s (Note 7).

DefinitionMemoryless-policy quantities

Pπ(s,s′)=∑aπ(a∣s)Pa(s,s′)P_\pi(s,s') = \sum_a\pi(a\mid s)P_a(s,s') and rπ(s)=∑aπ(a∣s)ra(s)r_\pi(s) = \sum_a\pi(a\mid s)r_a(s) (38.1).

  • Stationary transition matrix Pπ∗=lim⁡n1n∑t<nPπtP_\pi^* = \lim_n\frac1n\sum_{t<n}P_\pi^t, which always exists (Exercise 38.7). Then ρπ=Pπ∗rπ\rho^\pi = P_\pi^*r_\pi (38.2).
  • Differential value function (Cesàro sum of excess rewards): vπ=lim⁡n1n∑k=1nvπ(k),vπ(k)=∑t=1kPπt−1(rπ−ρπ)⇒vπ=((I−Pπ+Pπ∗)−1−Pπ∗)rπ(38.3)v_\pi = \lim_n\frac1n\sum_{k=1}^nv_\pi^{(k)},\quad v_\pi^{(k)} = \sum_{t=1}^kP_\pi^{t-1}(r_\pi - \rho^\pi)\quad\Rightarrow\quad v_\pi = \big((I - P_\pi + P_\pi^*)^{-1} - P_\pi^*\big)r_\pi \tag{38.3} vπ(s)−vπ(s′)v_\pi(s) - v_\pi(s') is the long-run advantage of starting in ss rather than s′s'. (I−P+P∗)−1(I - P + P^*)^{-1} is the fundamental matrix, and subtracting P∗P^* gives the deviation matrix.
  • Poisson equation: Pπ∗Pπ=Pπ∗P_\pi^*P_\pi = P_\pi^* gives Pπ∗vπ=0P_\pi^*v_\pi = 0, and ρπ+vπ=rπ+Pπvπ(38.4)\rho^\pi + v_\pi = r_\pi + P_\pi v_\pi \tag{38.4}

NoteWhy Cesàro sums (Notes 9–10)

A Cesàro sum averages the partial sums, which smooths out periodicity: 1−1+1−⋯1 - 1 + 1 - \cdots has Cesàro sum 12\frac12. It is used so that vπv_\pi exists even for periodic chains. The Abel sum lim⁡γ→1(1−γ)∑γnan\lim_{\gamma\to1}(1-\gamma)\sum\gamma^na_n agrees with the Cesàro sum when the latter exists, and is stronger. Approximating average reward by γ\gamma-discounted problems with γ→1\gamma\to1 is the vanishing discount method.

DefinitionSpan, greedy policy, Bellman equation, Bellman operator

  • span(v)=max⁡sv(s)−min⁡sv(s)\mathrm{span}(v) = \max_sv(s) - \min_sv(s).
  • Greedy policy: πv(s)=arg⁡max⁡a(ra(s)+⟨Pa(s),v⟩)\pi_v(s) = \arg\max_a\big(r_a(s) + \langle P_a(s),v\rangle\big), with systematic tie-breaking.
  • Bellman optimality equation: ρ+v(s)=max⁡a(ra(s)+⟨Pa(s),v⟩)∀s(38.5)\rho + v(s) = \max_a\big(r_a(s) + \langle P_a(s),v\rangle\big)\quad\forall s \tag{38.5} SS nonlinear equations in (ρ,v)(\rho,v). The vv-part is an optimal differential value function.
  • Bellman operator: (Tv)(s)=max⁡a(ra(s)+⟨Pa(s),v⟩)(Tv)(s) = \max_a\big(r_a(s) + \langle P_a(s),v\rangle\big), so (38.5) reads ρ1+v=Tv\rho\mathbf 1 + v = Tv.

WarningSolutions are not unique even up to translation (Exercise 38.11)

v+c1v + c\mathbf 1 is always another solution, but there can be more. Two states, “stay” (reward 0) and “go” (reward −1-1): the solutions are exactly ρ=0\rho = 0 with v(1)−1≤v(2)≤v(1)+1v(1) - 1\le v(2)\le v(1) + 1, a whole band. (This breaks a published proof that assumed vv is a limit of value iteration; Bartlett–Tewari 2009.)

TheoremTheorem 38.2 — Bellman equation characterises optimality

  1. A solution (ρ,v)(\rho,v) of (38.5) exists.
  2. Any solution has ρ=ρ∗\rho = \rho^*, and the greedy policy πv\pi_v is optimal.
  3. Hence a deterministic memoryless optimal policy exists.
ProofProof of (2): telescope against the greedy policy

Greedy achieves ρ\rho: with π∗=πv\pi^* = \pi_v, the Bellman equation reads rπ∗=ρ1+v−Pπ∗vr_{\pi^*} = \rho\mathbf 1 + v - P_{\pi^*}v, so 1n∑tPπ∗t−1rπ∗=ρ1+1n(v−Pπ∗nv)→ρ1\frac1n\sum_tP_{\pi^*}^{t-1}r_{\pi^*} = \rho\mathbf 1 + \frac1n(v - P_{\pi^*}^nv)\to\rho\mathbf 1.

Nothing beats ρ\rho: take any Markov policy (πt)(\pi_t) (sufficient by Exercise 38.2) with Pπ(t)=Pπ1⋯PπtP_\pi^{(t)} = P_{\pi_1}\cdots P_{\pi_t}. Greediness gives rπt+Pπtv≤rπ∗+Pπ∗v=ρ1+vr_{\pi_t} + P_{\pi_t}v\le r_{\pi^*} + P_{\pi^*}v = \rho\mathbf 1 + v, so

Pπ(t−1)rπt≤ρ1+Pπ(t−1)v−Pπ(t)vP_\pi^{(t-1)}r_{\pi_t}\le\rho\mathbf 1 + P_\pi^{(t-1)}v - P_\pi^{(t)}v

which telescopes, so ρˉπ≤ρ1\bar\rho^\pi\le\rho\mathbf 1.

Existence (1): discounted problems have fixed points (contraction). Choose a deterministic policy greedy along a sequence γn→1\gamma_n\to1 (finitely many candidates), and pass to the limit with Pγ∗=(1−γ)(I−γP)−1→P∗P^*_\gamma = (1-\gamma)(I - \gamma P)^{-1}\to P^* (Exercises 38.8–38.10).

∎

LemmaLemma 38.3 — Value spans are bounded by the diameter

Any Bellman solution has span(v)≤D(M)\mathrm{span}(v)\le D(M), and more precisely ≤(ρ∗−min⁡s,ara(s))D(M)\le(\rho^* - \min_{s,a}r_a(s))D(M) (Exercise 38.13). Intuition: you can travel from the worst state to the best in about DD steps, losing at most about ρ∗\rho^* per step, so values can’t differ by more.

TheoremDiscounted MDPs (Exercise 38.8)

(Tγv)(s)=max⁡a(ra(s)+γ⟨Pa(s),v⟩)(T_\gamma v)(s) = \max_a\big(r_a(s) + \gamma\langle P_a(s),v\rangle\big) is a γ\gamma-contraction in sup norm. By Banach’s theorem it has a unique fixed point vγ∗v^*_\gamma, the greedy policy π\pi satisfies v=(I−γPπ)−1rπv = (I - \gamma P_\pi)^{-1}r_\pi, and it is γ\gamma-discount optimal. Compare the discounted Gittins setting, a special discounted MDP.


Finding an optimal policy (planning)

TheoremTheorem 38.4 — LP for the optimal gain

min⁡ρ,v ρs.t.ρ+v(s)≥ra(s)+⟨Pa(s),v⟩  ∀s,a(38.6)\min_{\rho,v}\ \rho\quad\text{s.t.}\quad\rho + v(s)\ge r_a(s) + \langle P_a(s),v\rangle\ \ \forall s,a \tag{38.6}

is feasible, and every solution has ρ=ρ∗\rho = \rho^*. However, its vv need not satisfy the Bellman equation, and its greedy policy need not be optimal (Exercise 38.12).

ProofFeasibility from the Bellman solution; optimality by telescoping

(ρ∗,v∗)(\rho^*,v^*) is feasible, so ρ≤ρ∗\rho\le\rho^*. Conversely, with π∗\pi^* optimal and (ρ,v)(\rho,v) feasible, rπ∗≤ρ1+v−Pπ∗vr_{\pi^*}\le\rho\mathbf 1 + v - P_{\pi^*}v. Multiplying by Pπ∗tP_{\pi^*}^t and averaging telescopes to ρ∗≤ρ\rho^*\le\rho.

∎

TheoremTheorem 38.5 — LP for an optimal value function

min⁡v ⟨v,1⟩s.t.ρ∗+v(s)≥ra(s)+⟨Pa(s),v⟩  ∀s,a,v(s~)=0(38.7)\min_v\ \langle v,\mathbf 1\rangle\quad\text{s.t.}\quad\rho^* + v(s)\ge r_a(s) + \langle P_a(s),v\rangle\ \ \forall s,a,\qquad v(\tilde s) = 0 \tag{38.7}

For some state s~\tilde s, every solution satisfies the Bellman equation. (Without the anchor v(s~)=0v(\tilde s) = 0, vv could decrease without bound.)

ProofThe slack vanishes at a recurrent state, then everywhere

Let ε=v+ρ∗1−Tv≥0\varepsilon = v + \rho^*\mathbf 1 - Tv\ge0. With π∗\pi^* optimal, ρ∗1≤ρ∗1−Pπ∗∗ε\rho^*\mathbf 1\le\rho^*\mathbf 1 - P^*_{\pi^*}\varepsilon, so Pπ∗∗ε=0P^*_{\pi^*}\varepsilon = 0. Pick s~\tilde s with Pπ∗∗(s,s~)>0P^*_{\pi^*}(s,\tilde s) > 0 for some ss (a recurrent state), so ε(s~)=0\varepsilon(\tilde s) = 0. Then v−εv - \varepsilon is also feasible, and minimality gives ⟨ε,1⟩≤0\langle\varepsilon,\mathbf 1\rangle\le0, so ε=0\varepsilon = 0. In practice, try each s~\tilde s, or find a recurrent state through the LP dual’s complementary slackness (Note 11).

∎

AlgorithmPolynomial time via the ellipsoid method (§38.3.1)

The ellipsoid method minimises ⟨c,x⟩\langle c,x\rangle over a convex KK in time polynomial in nn and log⁡(R/(δε))\log(R/(\delta\varepsilon)), given (a) a bounding radius RR, (b) a separation oracle, and (c) an inner ball of radius δ\delta.

  • (a) Bounded: add ∥v∥∞≤D\lVert v\rVert_\infty\le D (Lemma 38.3) and 0≤ρ≤10\le\rho\le1, giving R=1+D2SR = \sqrt{1 + D^2S}. Use doubling if DD is unknown.
  • (c) Inner ball: add slack ε\varepsilon to every constraint (38.9). The solution moves by at most ε\varepsilon.
  • (b) Oracle (Algorithm 27): for each ss compute as∗=arg⁡max⁡a(ra(s)+⟨Pa(s),v⟩)a_s^* = \arg\max_a(r_a(s) + \langle P_a(s),v\rangle). If all constraints hold, return “feasible”; otherwise return the violated constraint’s normal (1,es−Pas∗(s))(1, e_s - P_{a_s^*}(s)). Extra half-space constraints combine easily (Exercise 38.15).
  • Approximation is fine (Exercise 38.16): if Bellman holds within ε\varepsilon, then ρ≥ρ∗−ε\rho\ge\rho^* - \varepsilon, and an ε′\varepsilon'-greedy policy is (2ε+ε′)(2\varepsilon + \varepsilon')-optimal.

WarningPolynomial is not practical

The ellipsoid method “should be avoided at all costs” in practice. Use instead:

  • Value iteration: vk+1=Tvk−max⁡svk(s)v_{k+1} = Tv_k - \max_sv_k(s) (renormalised because vkv_k grows like kk; the greedy policy is unchanged).
  • Policy iteration: alternate evaluating vπkv_{\pi_k} and acting greedily (needs a small modification to converge).
  • Other LP methods.

These work well but lack polynomial guarantees under weak assumptions (Bertsekas, vol. 2).


Learning in Markov decision processes

Setting. The rewards rr are known, the transitions PP unknown. Unknown stochastic rewards are an easy extension with optimistic reward estimates (Exercise 38.23).

DefinitionRegret

R^n=nρ∗−∑t=1nrAt(St)\hat R_n = n\rho^* - \sum_{t=1}^nr_{A_t}(S_t)

This compares against the asymptotic gain, which is fine because the best nn-step value satisfies vn∗(s)≤nρ∗+Dv^*_n(s)\le n\rho^* + D (Exercise 38.17).

TheoremTheorem 38.6 — Upper bound (UCRL2)

An efficiently computable policy achieves, on every MDP with SS states, AA actions, rewards in [0,1][0,1] and any initial distribution, with probability 1−δ1-\delta,

R^n<C D(M) SAnlog⁡(nSA/δ)\hat R_n < C\,D(M)\,S\sqrt{An\log(nSA/\delta)}

and E[R^n]≤1+CD(M)S2Anlog⁡n\mathbb E[\hat R_n]\le1 + CD(M)S\sqrt{2An\log n} (38.12).

TheoremTheorem 38.7 — Lower bound

For S≥3S\ge3, A≥2A\ge2, D≥6+2log⁡ASD\ge6 + 2\log_AS and n≥DSAn\ge DSA, every policy has some MDP with diameter at most DD and

E[R^n]≥CDSAn\mathbb E[\hat R_n]\ge C\sqrt{DSAn}

The gap to the upper bound is at least DS\sqrt{DS}.


UCRL2: upper confidence bounds for reinforcement learning

DefinitionConfidence sets for transitions

Empirical transitions P^t,a(s,s′)=∑u≤tI{Su=s,Au=a,Su+1=s′}1∨Tt(s,a)\hat P_{t,a}(s,s') = \frac{\sum_{u\le t}\mathbb I\{S_u = s,A_u = a,S_{u+1} = s'\}}{1\vee T_t(s,a)}. Each state–action pair gets an ℓ1\ell_1 ball:

Ct(s,a)={P∈P(S):∥P−P^t−1,a(s)∥1≤SLt−1(s,a)1∨Tt−1(s,a)}(38.13)\mathcal C_t(s,a) = \Big\{P\in\mathcal P(\mathcal S) : \lVert P - \hat P_{t-1,a}(s)\rVert_1\le\sqrt{\frac{S L_{t-1}(s,a)}{1\vee T_{t-1}(s,a)}}\Big\} \tag{38.13}

with Lt(s,a)=2log⁡4SATt(s,a)(1+Tt(s,a))δL_t(s,a) = 2\log\frac{4SAT_t(s,a)(1 + T_t(s,a))}\delta (and L=1L = 1, i.e. the whole simplex, when unvisited). Lt≤L=2log⁡4SAn(n+1)δL_t\le L = 2\log\frac{4SAn(n+1)}\delta. The full set Ct\mathcal C_t is the product over pairs. The radius is the Bretagnolle–Huber–Carol ℓ1\ell_1 bound for categorical distributions.

AlgorithmUCRL2 (Algorithm 28; Auer, Jaksch, Ortner)

Proceed in phases k=1,2,…k = 1, 2, \ldots. At phase start τk\tau_k:

  1. Optimistic planning: find (ρk,vk,Pk)(\rho_k,v_k,P_k) with Pk∈CτkP_k\in\mathcal C_{\tau_k} solving the Bellman equation in the most optimistic plausible MDP: ρk+vk(s)=max⁡a(ra(s)+⟨Pk,a(s),vk⟩),ρk=max⁡smax⁡π∈ΠDMmax⁡P∈Cτkρsπ(P)(38.16)\rho_k + v_k(s) = \max_a\big(r_a(s) + \langle P_{k,a}(s),v_k\rangle\big),\qquad\rho_k = \max_s\max_{\pi\in\Pi_{DM}}\max_{P\in\mathcal C_{\tau_k}}\rho_s^\pi(P) \tag{38.16}
  2. Act: play πk\pi_k, greedy with respect to vkv_k.
  3. Doubling: end the phase when the visit count of the current state–action pair reaches twice its value at phase start.

ImportantWhy phases are necessary (Exercise 38.19)

Re-planning every round can make an optimistic learner dither. On a two-state MDP where both states pay 12\frac12 for staying and switching pays 0, infinite-horizon optimism keeps believing the other state is slightly better and alternates, paying linear regret. Long-term plans should be followed for a while. Doubling phases also mean only O(SAlog⁡n)O(SA\log n) re-plans.

The extended MDP

DefinitionOptimism as planning in a bigger MDP

The extended MDP M~k\tilde M_k has the same states, enlarged actions A~s={(a,P):a∈A, P∈Cτk(s,a)}\tilde{\mathcal A}_s = \{(a,P) : a\in\mathcal A,\ P\in\mathcal C_{\tau_k}(s,a)\}, reward ra(s)r_a(s), and transition PP. The agent chooses both an action and a plausible transition law. Its optimal policy is exactly the optimistic policy in (38.16). (The idea first appeared in MBIE; Strehl–Littman 2008.)

TheoremProperties of the extended MDP

  • Strongly connected: every confidence ball contains a transition with P(s,s′)>0P(s,s') > 0 for any s′s', so (38.16) has constant-gain solutions (Exercise 38.20).
  • Finite in effect: each ℓ1\ell_1 ball is a convex polytope, and restricting to its finitely many vertices doesn’t change the optimum.
  • Diameter at most D(M)D(M) on the good event: the true PP is among the choices, so span(vk)≤D(v_k)\le D (Lemma 38.3). It is also at most n\sqrt n always, since a 1∧1/n1\wedge1/\sqrt n jump probability is always plausible, which bounds the LP’s radius.

AlgorithmThe inner optimisation is a sort (§38.5.2)

The oracle needs, for each (s,a)(s,a), max⁡P∈C(s,a)⟨P,v⟩\max_{P\in\mathcal C(s,a)}\langle P,v\rangle: maximise a linear function over ℓ1\ell_1-ball ∩ simplex. Sort states by vv, put as much mass as the ℓ1\ell_1 budget allows on the highest-value state, and take the excess mass from the lowest-value states. Total cost O(S(A+log⁡S))O(S(A + \log S)) per oracle call. Combined with Algorithm 27 and the ellipsoid method, the optimistic policy is polynomial-time computable. (The original UCRL papers used extended value iteration, which is practical but not polynomial.)


Proof of the upper bound

ProofStep 1: Failure event and optimism

Let EkE_k be the rounds of phase kk (KK phases) and FF the event that P∉CτkP\notin\mathcal C_{\tau_k} for some kk. By the categorical ℓ1\ell_1 concentration with a union bound over pairs and sample counts (the Markov property makes the samples effectively independent), P(F)≤δ/2\mathbb P(F)\le\delta/2 (Lemma 38.8, Exercise 38.21). On FcF^c the truth is plausible, so ρ∗≤ρk\rho^*\le\rho_k (optimism) and

R^n≤∑k=1KR~k,R~k=∑t∈Ek(ρk−rAt(St))\hat R_n\le\sum_{k=1}^K\tilde R_k,\qquad\tilde R_k = \sum_{t\in E_k}\big(\rho_k - r_{A_t}(S_t)\big)

∎

ProofStep 2: Regret within a phase via the Bellman equation

On FcF^c, shift vkv_k so that ∥vk∥∞≤12span(vk)≤D2\lVert v_k\rVert_\infty\le\frac12\mathrm{span}(v_k)\le\frac D2. For t∈Ekt\in E_k the Bellman equation in MkM_k gives ρk−rAt(St)=−vk(St)+⟨Pk,At(St),vk⟩\rho_k - r_{A_t}(S_t) = -v_k(S_t) + \langle P_{k,A_t}(S_t),v_k\rangle. Split the optimistic transition into the true one plus an error:

R~k≤∑t∈Ek(⟨PAt(St),vk⟩−vk(St))⏟(A)+D2∑t∈Ek∥Pk,At(St)−PAt(St)∥1⏟(B)(38.20)\tilde R_k\le\underbrace{\sum_{t\in E_k}\big(\langle P_{A_t}(S_t),v_k\rangle - v_k(S_t)\big)}_{(A)} + \underbrace{\frac D2\sum_{t\in E_k}\lVert P_{k,A_t}(S_t) - P_{A_t}(S_t)\rVert_1}_{(B)} \tag{38.20}

  • (A) telescopes plus a martingale: inserting vk(St+1)v_k(S_{t+1}) gives (A)≤D+∑t∈Ek(Et[vk(St+1)]−vk(St+1))(A)\le D + \sum_{t\in E_k}(\mathbb E_t[v_k(S_{t+1})] - v_k(S_{t+1})), using span(vk)≤D(v_k)\le D for the boundary terms.
  • (B) confidence widths: both PkP_k and PP lie in the ℓ1\ell_1 ball, so (B)≤DLS2∑s,aT(k)(s,a)1∨Tτk−1(s,a)(B)\le\frac{D\sqrt{LS}}2\sum_{s,a}\frac{T^{(k)}(s,a)}{\sqrt{1\vee T_{\tau_k-1}(s,a)}}.

∎

ProofStep 3: Sum over phases
  • Martingale: ∑t(Et[vKt(St+1)]−vKt(St+1))≤Dnlog⁡(2/δ)/2\sum_t(\mathbb E_t[v_{K_t}(S_{t+1})] - v_{K_t}(S_{t+1}))\le D\sqrt{n\log(2/\delta)/2} with probability 1−δ/21 - \delta/2, by Hoeffding–Azuma with a random range.
  • Widths: doubling makes ∑kT(k)1∨Tτk−1≤(2+1)Tn(s,a)\sum_k\frac{T^{(k)}}{\sqrt{1\vee T_{\tau_k-1}}}\le(\sqrt2 + 1)\sqrt{T_n(s,a)} (Exercise 38.22, the discrete version of ∫f′/f=2f\int f'/\sqrt f = 2\sqrt f). Then by Cauchy–Schwarz, ∑s,aTn(s,a)≤SAn\sum_{s,a}\sqrt{T_n(s,a)}\le\sqrt{SAn}.
  • Number of phases: each pair’s count can double at most 1+log⁡2Tn(s,a)1 + \log_2T_n(s,a) times, so K≤SA(1+log⁡2nSA)K\le SA(1 + \log_2\frac n{SA}), contributing KDKD.

Total: R^n≲DSAlog⁡nSA+Dnlog⁡1δ+DLSSAn=O(DSAnlog⁡(nSA/δ))\hat R_n\lesssim DSA\log\frac n{SA} + D\sqrt{n\log\frac1\delta} + D\sqrt{LS}\sqrt{SAn} = O(DS\sqrt{An\log(nSA/\delta)}).

∎

IntuitionWhere DD and SS come from

  • DD is the scale of value differences, because a transition error of ℓ1\ell_1 size ϵ\epsilon moves the value by up to ϵ⋅span(v)≈ϵD\epsilon\cdot\mathrm{span}(v)\approx\epsilon D.
  • One S\sqrt S comes from the ℓ1\ell_1 radius of an SS-dimensional distribution. The other S\sqrt S comes from Cauchy–Schwarz over SASA pairs, giving SA\sqrt{SA}.

Note 16: removing the spurious S\sqrt S means bounding ⟨P^−P,vk⟩\langle\hat P - P,v_k\rangle directly, but vkv_k depends on P^\hat P. This dependence is “pernicious” and has spoiled several attempts.


Proof of the lower bound

DefinitionThe hard MDP

  • A tree of S−2S-2 states with branching factor at most AA and deterministic transitions, rooted at s∘s_\circ, with leaves s1,…,sLs_1, \ldots, s_L.
  • Two absorbing-ish states sgs_g (reward 1) and sbs_b (reward 0). Each stays put with probability 1−δ1 - \delta and returns to the root with probability δ=4/D\delta = 4/D.
  • From leaf sis_i, action aa goes to sgs_g with probability 12+ε(a,i)\frac12 + \varepsilon(a,i), else to sbs_b. Here ε≡0\varepsilon\equiv0 except for one leaf–action pair, which has ε=Δ\varepsilon = \Delta.

The diameter is at most DD regardless of Δ\Delta (Claim 38.9).

IntuitionAn MDP that is secretly a bandit

Each visit to the root lets the learner pick one of k=LA=Ω(SA)k = LA = \Omega(SA) leaf–action “meta-arms”, each a Bernoulli(12+ε)(\frac12 + \varepsilon) coin for entering the good state. Rewards then accrue for about DD rounds. So there are about n/Dn/D decisions with stakes of about DD each, and the regret is about Dk⋅n/D=nDSAD\sqrt{k\cdot n/D} = \sqrt{nDSA}.

ProofProof of Theorem 38.7 (Assouad-style, as in Exercise 15.2)

Step 1: Setup. M0M_0 has no special pair, and MjM_j makes pair jj special. Stop at τ\tau, when the root has been visited about n/Dn/D times. Let TjT_j count plays of pair jj before τ\tau, and Tσ=∑jTjT_\sigma = \sum_jT_j. Claims: DE0[Tσ]/n∈[c1,c2]DE_0[T_\sigma]/n\in[c_1,c_2] (Claim 38.10), and the regret in MjM_j is Rnj≥c3ΔD Ej[Tσ−Tj]R_{nj}\ge c_3\Delta D\,E_j[T_\sigma - T_j] (Claim 38.11; Exercise 38.24).

Step 2: Divergence. M0M_0 and MjM_j differ only at pair jj, so by the stopped chain rule, D(P0,Pj)=E0[Tj] d(12,12+Δ)≤4Δ2E0[Tj]D(\mathbb P_0,\mathbb P_j) = E_0[T_j]\,d(\frac12,\frac12 + \Delta)\le4\Delta^2E_0[T_j] for Δ≤14\Delta\le\frac14 (38.22–38.23; Exercise 38.30).

Step 3: Pinsker and summing over jj. Since 0≤Tσ−Tj≤n/D0\le T_\sigma - T_j\le n/D, Ej[Tσ−Tj]≥E0[Tσ−Tj]−nΔD2E0[Tj]E_j[T_\sigma - T_j]\ge E_0[T_\sigma - T_j] - \frac{n\Delta}D\sqrt{2E_0[T_j]}. Summing over jj with Cauchy–Schwarz, ∑jEj[Tσ−Tj]≥c1n(k−1)D−nΔD2c2nkD≥c1n(k−1)2D\sum_jE_j[T_\sigma - T_j]\ge\frac{c_1n(k-1)}D - \frac{n\Delta}D\sqrt{\frac{2c_2nk}D}\ge\frac{c_1n(k-1)}{2D} for Δ≈c1(k−1)2D2c2nk\Delta\approx\frac{c_1(k-1)}2\sqrt{\frac D{2c_2nk}}.

Step 4: some jj has Ej[Tσ−Tj]≳n/DE_j[T_\sigma - T_j]\gtrsim n/D. Then Rnj≳DΔ⋅nD≈DSAnR_{nj}\gtrsim D\Delta\cdot\frac nD\approx\sqrt{DSAn}.

∎


Notes

WarningLarge MDPs are hard (Notes 1–2)

Real MDPs have millions or billions of states, so DSAnDS\sqrt{An} can be vacuous, and the lower bound says that without structural assumptions learning is genuinely hard. Choosing the state is a trade-off. It must be observable and Markov; enlarging it (the full history always works) improves fidelity but slows learning.

DefinitionVariants (Notes 3–8)

  • Random rewards: a joint kernel over (next state, reward), with mean reward ra(s)r_a(s).
  • Episodic MDPs: an absorbing state is reached almost surely. Average reward is meaningless there, so maximise total (possibly discounted) reward. Finite-horizon: absorption after a fixed number of steps.
  • POMDPs: only observations of the state are seen. They can be converted to MDPs on histories or belief states (posteriors over the hidden state), but computing optimal policies is hard in general (Papadimitriou–Tsitsiklis 1987). Compare the Bayesian bandit posterior-as-state view.
  • Terminology: agent / decision maker / controller; environment / plant; stochastic optimal control (control theory, average cost) versus multistage stochastic programming (operations research, episodic).
  • Finer criteria: bias optimality (gain optimal and vπ∗≥vπv_{\pi^*}\ge v_\pi), Blackwell optimality, nn-discount optimality.

WarningUCRL2 is brittle (Notes 13–14)

  • Unreachable high-reward state: a single unreachable state whose reward exceeds ρ∗\rho^* forces linear regret, because the optimistic MDP keeps trying to reach it (Exercise 38.27). SCAL (Fruit et al. 2018) fixes this by working with the reachable sub-MDP.
  • Traps, redefined (Exercise 38.29): the maximal end components (MECs) form a directed acyclic graph, and its sinks are closed, strongly connected sub-MDPs. Reasonable policies can’t control which sink they fall into, so regret should restart once trapped: Rn′=E[τ+∑t≥τr−nρ∗(MI)]R'_n = \mathbb E[\tau + \sum_{t\ge\tau}r - n\rho^*(M_I)], with the target O(D(MI)∣CI∣Anlog⁡n)O(D(M_I)\lvert C_I\rvert\sqrt{An\log n}). This definition still ignores how fast the learner gets trapped.

ExampleContextual bandits as MDPs (Exercise 38.25)

If Pa(s)=pP_a(s) = p for all s,as, a, the next state ignores the action: a contextual bandit. The optimal policy is per-state greedy with gain ∑sp(s)max⁡ara(s)\sum_sp(s)\max_ar_a(s). The diameter is D=max⁡s1/p(s)D = \max_s1/p(s) (geometric hitting times). One UCB per state gives O(SAn)O(\sqrt{SAn}), as in one bandit per context. UCRL2’s DSAnDS\sqrt{An} is loose here: its bound pays for planning that this problem doesn’t need. (Worked here.)

ExampleRiverSwim (Exercise 38.26)

States 1,…,S1, \ldots, S. “Left” drifts back deterministically, with reward 0.050.05 in state 1. “Right” swims against a current: up with probability 0.3, stay 0.6, down 0.1 (state 1: up 0.3, stay 0.7), with reward 1 in state SS (stay 0.9). Always swimming right gives a birth–death chain with up/down ratio 3, so π(s)∝3s−1\pi(s)\propto3^{s-1} and

ρ∗=2⋅3S−13S−1≈23(S=5: ≈0.67)\rho^* = \frac{2\cdot3^{S-1}}{3^S - 1}\approx\frac23\quad(S = 5:\ \approx0.67)

far above 0.050.05. ε-greedy with empirical models stays near the bank: the reward is too far away to stumble upon. UCRL2 deliberately explores upstream because it is optimistic about unvisited states. (Gain worked here.)

RemarkHistory and the wider literature

  • Foundations: Bellman (1954; his autobiography mentions encountering Thompson’s bandit paper); Puterman (OR view); Bertsekas (control view); Ross; Kallenberg’s notes; Arapostathis et al. on average-reward theory. RL: Sutton–Barto; Bertsekas–Tsitsiklis; Szepesvári (2010).
  • Regret: UCRL/UCRL2 (Auer et al. 2009; Jaksch et al. 2010). PSRL, i.e. Thompson sampling for RL (Strens 2000; Osband et al. 2013). Agrawal–Jia (2017) attempted to improve the SS dependence, but the proof has unpatched holes. Episodic: O~(HSAn)\tilde O(\sqrt{HSAn}) via Bernstein/Freedman bonuses and backward induction (Azar et al. 2017), with large lower-order terms. Logarithmic instance-dependent bounds: Tewari–Bartlett (flawed constants), Auer–Ortner; asymptotically optimal constants with known supports (Burnetas–Katehakis 1997).
  • Structured MDPs: LQR with O(n)O(\sqrt n) regret (Abbasi-Yadkori–Szepesvári 2011); Lipschitz MDPs with O(n(2d+1)/(2d+2))O(n^{(2d+1)/(2d+2)}) (Ortner–Ryabko). Optimistic algorithms are often computationally intractable here, which Thompson sampling may fix.
  • PAC-MDP (discounted): R-max, MBIE, delayed Q-learning, MorMax, UCRLγ.
  • Adversarial rewards with stochastic transitions: Even-Dar et al. (2004); Neu et al. (2014). Fully adversarial: Abbasi-Yadkori et al. (2013).

Quick reference

ObjectStatementNote
MDP(S,A,P,r,μ)(\mathcal S,\mathcal A,P,r,\mu)bandit = one state
Diametermax⁡s≠s′min⁡πE[hit time]−1\max_{s\ne s'}\min_\pi\mathbb E[\text{hit time}] - 1finite iff strongly connected; ≥log⁡AS−3\ge\log_AS - 3
Gainρπ=Pπ∗rπ\rho^\pi = P^*_\pi r_\piaverage reward
Valuevπ=((I−Pπ+Pπ∗)−1−Pπ∗)rπv_\pi = ((I - P_\pi + P_\pi^*)^{-1} - P_\pi^*)r_\piCesàro sum
Poissonρπ+vπ=rπ+Pπvπ\rho^\pi + v_\pi = r_\pi + P_\pi v_\pi
Bellmanρ+v=Tv\rho + v = Tv, (Tv)(s)=max⁡ara(s)+⟨Pa(s),v⟩(Tv)(s) = \max_a r_a(s) + \langle P_a(s),v\ranglenon-unique solutions
Optimalitygreedy w.r.t. any solution is optimal; deterministic memoryless suffices
Spanspan(v)≤D\mathrm{span}(v)\le D
DiscountedTγT_\gamma is a γ\gamma-contractionvanishing discount gives average reward
LPmin⁡ρ\min\rho s.t. ρ+v≥ra+Pav\rho + v\ge r_a + P_av; then min⁡⟨v,1⟩\min\langle v,\mathbf 1\rangle with v(s~)=0v(\tilde s) = 0ellipsoid + oracle
Practicevalue / policy iterationno polynomial guarantee
Regretnρ∗−∑rAt(St)n\rho^* - \sum r_{A_t}(S_t)vn∗≤nρ∗+Dv_n^*\le n\rho^* + D
Confidence setℓ1\ell_1 ball, radius SL/T\sqrt{SL/T}categorical concentration
Extended MDPchoose (action, plausible PP)strongly connected; sort-based inner max
UCRL2optimistic plan, doubling phasesO(DSAnlog⁡(nSA/δ))O(DS\sqrt{An\log(nSA/\delta)})
Lower boundtree → good/bad states ≈ bandit with SASA armsΩ(DSAn)\Omega(\sqrt{DSAn})
GapDS\sqrt{DS}vkv_k dependent on P^\hat P

Facts to keep to hand

  • MDPs are bandits with consequences. The state carries the effect of past actions. Without traps (strong connectivity, finite diameter), average-reward optimality is constant across states and is achieved by a deterministic memoryless policy greedy with respect to any solution of the Bellman optimality equation.
  • Planning is linear programming. The optimal gain and value function solve two LPs, polynomial-time via the ellipsoid method with a greedy separation oracle and the span ≤ diameter bound. In practice, value and policy iteration are used.
  • Learning is optimism over MDPs. UCRL2 builds ℓ1\ell_1 confidence balls on transitions, plans in the extended MDP where the agent also picks the most favourable plausible dynamics, and commits to that plan until some visit count doubles. Its regret is about DSAnDS\sqrt{An}: diameter from value spans, SS from ℓ1\ell_1 widths and Cauchy–Schwarz.
  • The lower bound is a disguised bandit. About SASA meta-arms, each decision worth about DD rounds, give DSAn\sqrt{DSAn}. Closing the DS\sqrt{DS} gap is open and delicate, because the optimistic value function depends on the empirical model it would be paired with.

References

  • Lattimore & Szepesvári, Bandit Algorithms — Chapter 38
  • Jaksch, Ortner & Auer, “Near-optimal regret bounds for reinforcement learning” (2010)
  • Puterman, Markov Decision Processes (2009); Bertsekas, Dynamic Programming and Optimal Control (2012)
  • Sutton & Barto, Reinforcement Learning: An Introduction (2018)

← All notes