Reinforcement Learning: An Introduction XII: The Policy Gradient TheoremTextbook
Motivation
Policy gradient methods learn a parameterized policy directly, by stochastic gradient ascent on a scalar performance measure , instead of deriving the policy from learned action values. They are how reinforcement learning handles continuous action spaces, stochastic optimal policies and prior knowledge built into the policy's form, and they underlie REINFORCE (Williams, 1992) and the actor–critic family. Every such method needs an estimate of . The difficulty is that depends on in two ways: through the action choices in each state, and through the distribution of states those choices produce. The second effect depends on the unknown environment dynamics.
The policy gradient theorem (Sutton, McAllester, Singh and Mansour, 2000; Marbach and Tsitsiklis, 2001) gives as an expectation over the on-policy state distribution that involves no derivative of that distribution. Chapter 13 of Sutton and Barto's Reinforcement Learning: An Introduction (2nd ed., 2018) states it as Eq. (13.5), proves it in a box for the episodic case (p. 325) and in a second box for the continuing case (pp. 334–335), and builds REINFORCE, REINFORCE with baseline and actor–critic methods on it. This mission formalizes that chapter's theorem and the identities around it, in the book's own model.
Setting
A finite episodic MDP has a finite set of nonterminal states, a terminal state, a finite action set , a finite reward set and dynamics : for each nonterminal and action , a probability distribution over next state and reward . The terminal state is absorbing and pays nothing. Write and for the expected reward.
A differentiable policy parameterization assigns to every and state a distribution over actions, with differentiable. Under the nonterminal states form a substochastic chain with matrix ; . Episodes terminate when for all .
There is no discounting (, p. 324). The state value is the expected total reward from , with ; the action value is the expected total reward after taking in . The episode starts in a fixed state , and the performance is (13.4). The expected number of visits to in an episode is , and the on-policy distribution is (9.3).
In the continuing case there is no terminal state, is the average reward per step (13.15), is the steady-state distribution, and , are differential values, defined from the return (13.17).
Formalization targets
Goal: the policy gradient theorem, episodic case (13.5)
If episodes terminate under , then is differentiable at and
with . The book writes and names the constant, the average length of an episode, in words (p. 326). The goal states it.
Milestones
- Exercises 3.18–3.19 with : and .
- The recursion , including the differentiability of .
- The unrolled gradient for every .
- The theorem with a baseline (13.10): , hence may be replaced by .
- The log form behind REINFORCE: where , , and hence , the exact form of .
- Exercise 13.3, (13.9): for the linear soft-max, .
- Exercise 13.4: the eligibility vectors of the Gaussian policy (13.19)–(13.20).
- The continuing case: under ergodicity, with differential .
Significance
The theorem turns into a quantity that can be sampled by following the policy: weighting states by is what visiting them under does, and the log form makes the action sum an expectation over . REINFORCE (13.8), REINFORCE with baseline (13.11) and one-step and eligibility-trace actor–critic methods all rest on it, and so does their claim that the expected update is in the direction of the performance gradient (p. 329). The baseline identity is why a learned state value can reduce variance without introducing bias.
The results are proved, in the book and in the literature. What this mission adds is a machine-checked version in the book's model: random episode lengths with , vector parameters , four-argument dynamics, and values defined from expected returns. The platform already has a proved finite-horizon policy gradient theorem (policy_gradient_finite_horizon, with a baseline and log-form companion) for a fixed horizon , a scalar parameter and an expected-reward kernel; it does not cover the book's statement. The mission also makes explicit two points the text leaves informal: that episodes terminate, and what exact constant hides behind "".
Difficulty
The book's proof is a formal manipulation: differentiate the Bellman equation, substitute it into itself, and "unroll" infinitely often. Two steps are not justified on the page. First, it presupposes that exists; with the value is an infinite series whose convergence depends on through termination, so differentiability of at has to be established, and termination is assumed only at . Second, "repeated unrolling" is a limit: after unrollings a remainder is left over, and it vanishes only because . Differentiating the series for term by term is not an alternative shortcut without a uniform bound on the derivatives of .
In the continuing case the corresponding obstacle is the differentiability of the steady-state distribution and of the differential values, which the book's proof uses without comment; here they are part of what is to be proved, from ergodicity at alone.
Formalization scope
- Model. is
Option S, withnonethe single terminal state (several terminal states can be merged, all having value 0). One action type for all states. lives inEuclideanSpace ℝ (Fin d), and is Mathlib'sgradient; conclusions areHasGradientAt, so differentiability is asserted, not assumed. - Values from returns. , , are series in powers of ; Bellman equations are theorems (milestone 1). The continuing-case average reward and steady-state distribution are the limits of (13.15), and the differential values are the series of (13.17).
- Implicit hypotheses made explicit. Termination under is a hypothesis of every episodic result that involves values; the continuing case assumes the book's ergodicity (the limit of exists and does not depend on ) at . The positivity of is assumed where a logarithm is differentiated.
- "∝". The episodic goal states the exact equality with the constant and proves it is at least 1. A formalization of the form "" is ruled out: it holds with and loses the book's constant.
- Fixed start state. is a fixed state, as in the book (p. 324); no start distribution.
- Not included. Convergence of REINFORCE or actor–critic under stochastic-approximation conditions (p. 329) rests on unstated conditions and is not an item. The baseline is a deterministic function of the state, not the random variable the book also allows.
Reusable infrastructure: the episodic value layer (substochastic chains, expected visits, termination) is needed by any undiscounted episodic RL result; the soft-max and Gaussian eligibility computations are needed by every policy-gradient algorithm. Proofs of any milestone, and general lemmas on the differentiability of values and stationary distributions of parameterized finite Markov chains, are welcome.
Selected references
- R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018, ISBN 9780262039246, Chapter 13. http://incompleteideas.net/book/the-book-2nd.html
- R. S. Sutton, D. McAllester, S. Singh and Y. Mansour, Policy Gradient Methods for Reinforcement Learning with Function Approximation, NeurIPS 12, 2000. https://proceedings.neurips.cc/paper/1999/hash/464d828b85b0bed98e80ade0a5c43b0f-Abstract.html
- P. Marbach and J. N. Tsitsiklis, Simulation-Based Optimization of Markov Reward Processes, IEEE Transactions on Automatic Control 46(2), 2001. https://doi.org/10.1109/9.905687
- R. J. Williams, Simple Statistical Gradient-Following Algorithms for Connectionist Reinforcement Learning, Machine Learning 8, 1992. https://doi.org/10.1007/BF00992696