8. CMDPs, Duality & Lagrangian Methods

Constrained MDPs, occupancy measures, zero duality gap, primal-dual algorithms, PID Lagrangians, risk and state augmentation

Before you start

This module assumes:

A route through this module

First build the core calculation: the constrained problem, occupancy measures, the Lagrangian, the updates. Try the Easy practice as you go, then the Medium applications. Then read the controller interpretation, tail-risk constraints and state augmentation. The RLHF section is an application comparison after the main constrained-MDP argument.

The Hard practice checks proofs and assumptions. The original longer exercises remain for a deeper pass. If a calculation stalls, follow its prerequisite review link and return after practising that skill.

Background — check the skills used next

Can you sum a discounted constant, distinguish a probability from a cumulative return, and explain the sign of a Lagrange multiplier?

Show hint

Use the geometric series, then the convention “maximize reward, constrain cost from above”.

Show worked check

With discount $1/2$, a constant cost $1$ gives total cost $1+1/2+1/4+\cdots=2$, not $1$. A normalized occupancy is a probability distribution; cumulative cost therefore has an extra factor $1/(1-\gamma)$. For an upper cost budget, $L=J_r-\lambda(J_c-d)$ with $\lambda\ge0$: a violation lowers the policy’s penalized reward. Review geometric series, discounted returns, and duality if any step is unfamiliar.

Book contents · Apply this chapter to a real decision · Glossary

Contents
1. Constrained MDPs 2. Occupancy Measures and the LP View 3. Lagrangian Relaxation and the Zero Duality Gap 4. Primal-Dual Algorithms and Their Convergence 5. The Multiplier as a Controller: PID Lagrangians 6. Risk-Sensitive Constraints: CVaR and Beyond 7. Almost-Sure Constraints via State Augmentation 8. Adjacent: Safe RLHF Walkthrough: Dual Ascent on a Two-Action CMDP Interactive: Multiplier Dynamics (Plain vs PID) Application lab & chapter review Exercises Graded practice: Easy → Medium → Hard Key Papers Flashcards

1. Constrained MDPs

Module 7 encoded safety as a set to stay in and asked how large a penalty makes the safe set attractive (Module 7). The constrained-RL tradition of Module 1 takes the other road: keep the reward and the safety signal as separate quantities, bound the expected cumulative safety cost by a budget, and let the algorithm find the trade-off.

First, Paternain et al., NeurIPS 2019 point out that a hand-tuned weight $w$ on a penalty has no transparent relation to the constraint value the final policy will achieve, so tuning $w$ can be as hard as solving the problem.

Second, and stronger, Calvo-Fullana et al., IEEE TAC 2024 exhibit constrained problems that no fixed weighted combination of rewards solves (see Sections 3 and 7 below). A budget is also what an engineer can specify: "at most 25 hazard contacts per episode" is a requirement, "weight 0.37 on hazard contacts" is not.

Background used in the definition: policies (stochastic or deterministic, stationary or history-dependent) and discounted returns are in Primer E, value functions, $Q$-functions and advantages in Primer E, expectations over random trajectories in Primer C, and $\sup$ versus $\max$ over infinite sets in Primer B.

Definition — Constrained Markov decision process (Altman 1999)
A CMDP is a tuple $(\mathcal S, \mathcal A, P, \mu, r, \{c_i\}_{i=1}^m, \{d_i\}_{i=1}^m, \gamma)$: states $s\in\mathcal S$, actions $a\in\mathcal A$, transition kernel $P(s'\mid s,a)$, initial distribution $\mu$, a reward $r:\mathcal S\times\mathcal A\to\mathbb R$, $m$ cost functions $c_i:\mathcal S\times\mathcal A\to\mathbb R$ with budgets $d_i\in\mathbb R$, and a discount $\gamma\in(0,1)$. For a (possibly history-dependent) policy $\pi$ define the discounted return and cost returns $$J_r(\pi) := \mathbb E^{\pi}_{\mu}\Big[\sum_{t=0}^{\infty}\gamma^t r(s_t,a_t)\Big],\qquad J_{c_i}(\pi) := \mathbb E^{\pi}_{\mu}\Big[\sum_{t=0}^{\infty}\gamma^t c_i(s_t,a_t)\Big].$$ The CMDP problem is $$P^\star := \max_{\pi}\ J_r(\pi)\quad\text{s.t.}\quad J_{c_i}(\pi)\le d_i,\ \ i=1,\dots,m. \qquad\text{(CMDP)}$$ A policy is feasible if it satisfies all constraints; $\pi^\star$ denotes an optimal (feasible, return-maximising) policy. For finite CMDPs the maximum is attained (by the occupancy LP of Section 2). In general state and action spaces read $\max$ as $\sup$, which need not be attained even with bounded rewards and Slater's condition (one state, actions $a\in[0,1]$, $r(a)=a$ for $a\lt1$ and $r(1)=0$, zero cost). Wherever $\pi^\star$, a Lagrangian maximiser $\pi_\lambda$ or an exact inner maximiser appears, attainment is assumed. Cost value functions $V_c^\pi, Q_c^\pi, A_c^\pi$ are defined exactly like $V^\pi,Q^\pi,A^\pi$ with $c$ in place of $r$.

We stick to one convention throughout the section: maximise reward, costs bounded from above, $\lambda\ge 0$ the Lagrange multiplier of a cost constraint, $\rho_\pi$ the occupancy measure. The literature does not. The table translates the papers cited on this page; the translation rule is that a "utility" constraint $V_g(\pi)\ge b$ is the cost constraint with $c=-g$ and $d=-b$, with the multiplier unchanged.

PaperObjectiveConstraintNotation to translate
Altman 1999minimise cost $C_\alpha(\beta,u)$$D^k_\alpha(\beta,u)\le V_k$discount $\alpha$, initial law $\beta$, policy $u$, occupation measure $f_\alpha(\beta,u)$ normalised to a probability, so that his costs $C_\alpha=\langle f_\alpha,c\rangle$ carry the factor $(1-\alpha)$; $K$ constraints
Paternain et al. 2019, Ding et al. 2020/2023maximise $V_0(\pi)$ or $V_r^\pi(\rho)$$V_i(\pi)\ge c_i$, $V_g^\pi(\rho)\ge b$"utility" constraints; $\rho$ is the initial distribution in Ding et al., not the occupancy measure; Ding et al. 2023 call the utility $u$ and set $g:=u-(1-\gamma)b$, so their constraint reads $V_g^\pi(\rho)\ge0$
Montenegro et al. 2024 (C-PG)minimise $J_0(\upsilon)$$J_i(\upsilon)\le b_i$cost-minimisation with the Lagrangian $J_0+\langle\lambda,J-b\rangle$ maximised over $\lambda$
Stooke et al. 2020, Ray et al. 2019maximise $J(\pi_\theta)$$J_C(\pi_\theta)\le d$our convention
Sootla et al. 2022 (Sauté)minimise task costsafety budget $d-\sum_t\gamma_l^t l(s_t,a_t)\ge 0$two discounts: $\gamma_c$ (task) and $\gamma_l$ (safety)
Chow et al. 2018minimise cost $V^\theta(x^0)$$\mathrm{CVaR}_\alpha(\text{cum.\ constraint cost})\le\beta$ (CVaR: Primer C)$\alpha\to 1$ is the extreme tail (Section 6)

Discounted, average, episodic. The discounted formulation above is the default in deep safe RL. Altman also treats the total-cost problem (for transient or absorbing models, or under uniform Lyapunov conditions; his Chs. 7–9) and the expected-average-cost problem ($\lim_T \frac1T\mathbb E\sum_{t\lt T}c$; for finite MDPs under a unichain assumption, his Ch. 4), which is the setting of Calvo-Fullana et al.; finite-horizon episodic tasks (Safety Gym: $T_{\rm ep}=1000$, $d=25$) are the undiscounted case $\gamma=1$ with a terminal time. The occupancy, LP and duality results of Sections 2–3 have counterparts in these settings, but only under such extra assumptions (a finite horizon also needs time-indexed occupancy measures and non-stationary policies), and the convergence rates of Section 4 are proved for the discounted case; we write the discounted case throughout. Some authors normalise returns by $(1-\gamma)$ so that they live in $[0,1]$ when rewards do; we do not, and we say so wherever a factor $(1-\gamma)$ appears. The three criteria are compared in Primer E; the Markov-chain terms used here are explained in the box below.

Background — Absorbing, transient and unichain models; a drift bound for total costs

A state is absorbing if, once reached, it is never left, whatever the action. A state is transient if its expected number of visits is finite; a recurrent class is a closed group of communicating states that the chain keeps revisiting. A model is unichain if every stationary policy induces a single recurrent class, possibly with transient states; this makes long-run averages independent of where the chain starts. Example: a "working" state that eventually moves to an absorbing "finished" state has finite total cost if only working costs money, but absorption with probability one does not by itself bound the expected finishing time. That is why the total-cost problem needs more than bounded one-step costs.

Fact (a drift bound). Take a countable MDP with an absorbing set $A$, reached at the random time $T_A$, and zero costs after absorption. Suppose functions $W\ge0$ and $w\ge0$ satisfy, for every $s\notin A$ and every action $a$, $\ \mathbb E[W(s_{t+1})\mid s_t=s,a_t=a]\le W(s)-w(s)$, and that $\mathbb E_\mu W(s_0)\lt\infty$ and $|c(s,a)|\le Kw(s)$. Then every policy, history-dependent or not, has $\mathbb E^\pi_\mu\sum_{t\lt T_A}w(s_t)\le\mathbb E_\mu W(s_0)$, so its expected total cost is at most $K\,\mathbb E_\mu W(s_0)$ in absolute value; if $w\ge1$ outside $A$ this also bounds $\mathbb E\,T_A$. Proof sketch: $W$ is an account that loses at least $w(s_t)$ per step in expectation. Summing the drift inequality up to time $n$ telescopes to $\mathbb E\sum_{t\lt\min(n,T_A)}w(s_t)\le\mathbb E W(s_0)-\mathbb E W(s_{\min(n,T_A)})\le\mathbb E W(s_0)$, and $n\to\infty$ is allowed because the terms are nonnegative. Because the inequality holds for every action, the bound holds for every policy. Altman's "uniform Lyapunov" conditions for the total-cost problem are drift conditions of this probabilistic kind (Altman 1999, Chs. 7–9), not the deterministic stability tests of Primer D. None of this is needed for the discounted derivations on this page.

Why the optimal policy is usually stochastic

An unconstrained discounted MDP with finitely many states and actions always has a deterministic optimal stationary policy (in general spaces an optimum need not even exist; see the definition above). A CMDP typically does not. Consider two states that alternate deterministically, $s_1\to s_2\to s_1\to\cdots$, whatever the action (two recurring phases of a task), $\mu=\delta_{s_1}$ (the point mass: start in $s_1$ with probability one; Primer C), $\gamma=\tfrac12$. In both states the agent chooses fast (reward 1) or slow (reward 0). Being fast costs $1$ in $s_1$ and $2$ in $s_2$ (the second phase is riskier), budget $d=1.2$. Write $p_1=\pi(\text{fast}\mid s_1)$, $p_2=\pi(\text{fast}\mid s_2)$. The discounted time spent in $s_1$ is $\sum_k\gamma^{2k}=\tfrac{1}{1-\gamma^2}=\tfrac43$ and in $s_2$ it is $\tfrac{\gamma}{1-\gamma^2}=\tfrac23$, so

$$J_r = \tfrac43 p_1+\tfrac23 p_2,\qquad J_c=\tfrac43 p_1+\tfrac43 p_2 .$$

The four deterministic policies give $(J_c,J_r)\in\{(0,0),\ (\tfrac43,\tfrac43),\ (\tfrac43,\tfrac23),\ (\tfrac83,2)\}$; only $(\text{slow},\text{slow})$ is feasible, with $J_r=0$. Randomising in $s_1$ with $p_1=0.9$, $p_2=0$ gives $J_c=1.2$ and $J_r=1.2$. The set of achievable $(J_c,J_r)$ pairs is the convex hull of the deterministic points, i.e. all their weighted averages (Primer B; Section 2 explains why), and the constrained optimum sits where the budget line cuts its upper boundary:

0 1 2 3 0 1 2 J_c (discounted cost) J_r (discounted return) (slow, slow) (slow, fast) (fast, fast) (fast, slow) optimum (1.2, 1.2) J_c = d = 1.2 feasible
Achievable (cost, return) pairs of the two-state example: a parallelogram spanned by the four deterministic policies. Feasible pairs lie left of the budget line; the optimum $(1.2,1.2)$ is a proper mixture and randomises in exactly one state.
Key insight
The budget is spent where it buys the most return per unit cost ($s_1$: ratio $1$; $s_2$: ratio $\tfrac12$), and the last unit is spent fractionally. This is exactly how a linear program allocates a resource, and Section 2 makes the analogy literal. Altman's Theorem 3.8 quantifies it: with $m$ constraints (his $K$) some optimal stationary policy uses at most $m$ randomisations in total (a state whose support holds $j+1$ actions counts as $j$), hence randomises in at most $m$ states. Two consequences run through the whole page. (i) Because finite unconstrained MDPs have deterministic optima, a CMDP whose optimum must randomise cannot be the unique optimum of any fixed-weight penalised MDP: this is the primal-recovery problem of Section 3. (ii) Stationary policies in $s$ alone suffice for expected cumulative constraints, but in general not for almost-sure or risk constraints (Sections 6–7), where an optimal policy may have to depend on an augmented state.
Notation clash
Module 9 writes $d^\pi$ for the discounted state-visitation distribution in the CPO bound; here $d_i$ is a cost budget and the state marginal of the occupancy measure is written $\rho_\pi(s)$. The multiplier $\lambda$ of this page is a nonnegative scalar (or vector); the diagonal multiplier $T=\mathrm{diag}(\lambda_i)\succeq 0$ of the LipSDP modules is a different object that happens to share the letter.

2. Occupancy Measures and the LP View

The CMDP problem is non-convex in the policy: $J_r(\pi)$ is a nonlinear function of the numbers $\pi(a\mid s)$ because they multiply along trajectories. The classical cure (Altman, Ch. 3) is to change variables to the occupancy measure, in which all returns become linear.

Background — Interchanging infinite sums, expectations, and integrals

For nonnegative random variables $X_t$, Tonelli's rule gives $\mathbb E\sum_tX_t=\sum_t\mathbb E X_t$, allowing $+\infty$. For signed $X_t$, the same equality holds if $\mathbb E\sum_t|X_t|\lt\infty$ (absolute integrability). Here $|r_t|\le B$ implies $\sum_t\gamma^t|r_t|\le B/(1-\gamma)$, so the exchange is justified. For example, with $B=2$ and $\gamma=1/2$ the absolute sum is at most $4$. A finite bound prevents an undefined subtraction of two infinite sums.

Definition — Occupancy measure
For a policy $\pi$ and initial law $\mu$, the (normalised, discounted) occupancy measure is $$\rho_\pi(s,a) := (1-\gamma)\sum_{t=0}^{\infty}\gamma^t\,\mathbb P^{\pi}_{\mu}(s_t=s,\ a_t=a),\qquad \rho_\pi(s):=\sum_a\rho_\pi(s,a).$$ It is a probability measure on $\mathcal S\times\mathcal A$ (the weights $(1-\gamma)\gamma^t$ sum to one), and every discounted return is an expectation under it: $$J_r(\pi)=\frac{1}{1-\gamma}\sum_{s,a}\rho_\pi(s,a)\,r(s,a)=\frac{\langle\rho_\pi,r\rangle}{1-\gamma},\qquad J_{c_i}(\pi)=\frac{\langle\rho_\pi,c_i\rangle}{1-\gamma}.$$ Altman writes $f_\alpha(\beta,u;x,a)=(1-\alpha)\sum_{t\ge1}\alpha^{t-1}P^u_\beta(X_t=x,A_t=a)$ for the same object (time starts at 1 there).

The point is that $\rho_\pi$ is characterised by linear equations. Conservation of probability flow says: discounted mass at $s$ equals what starts there plus what flows in from the previous step.

Derivation — The Bellman-flow constraints

Step 1 (Markov property). Conditioning on the state-action pair at time $t$, $$\mathbb P(s_{t+1}=s)=\sum_{s',a'}\mathbb P(s_t=s',a_t=a')\,P(s\mid s',a').$$ This uses only that the next state depends on the past through $(s_t,a_t)$; the policy can be history-dependent.

Step 2 (discount and sum). Multiply by $\gamma^{t+1}$ and sum over $t\ge0$; on the left the index shifts to $t\ge1$: $$\sum_{t\ge1}\gamma^t\,\mathbb P(s_t=s)=\gamma\sum_{s',a'}P(s\mid s',a')\sum_{t\ge0}\gamma^t\,\mathbb P(s_t=s',a_t=a').$$ Interchanging the two sums is legitimate because all terms are nonnegative.

Step 3 (add the start). The missing $t=0$ term on the left is $\mathbb P(s_0=s)=\mu(s)$, so $$\sum_{t\ge0}\gamma^t\,\mathbb P(s_t=s)=\mu(s)+\gamma\sum_{s',a'}P(s\mid s',a')\sum_{t\ge0}\gamma^t\,\mathbb P(s_t=s',a_t=a').$$

Step 4 (normalise). Multiply by $(1-\gamma)$ and recognise the definition of $\rho_\pi$ on both sides: $$\boxed{\ \rho_\pi(s)=(1-\gamma)\,\mu(s)+\gamma\sum_{s',a'}\rho_\pi(s',a')\,P(s\mid s',a')\quad\forall s\ }$$ Summing over $s$ gives total mass $M=(1-\gamma)+\gamma M$, i.e. $M=1$: the flow equations already encode normalisation.

Theorem — Occupancy measures form a polytope; stationary policies are complete (Altman 1999, Thms 3.1–3.3)
Let $\mathcal Q(\mu)$ be the set of $\rho\ge0$ on $\mathcal S\times\mathcal A$ satisfying the flow constraints. For a finite CMDP:
  1. $\rho_\pi\in\mathcal Q(\mu)$ for every policy $\pi$, history-dependent or not.
  2. Conversely every $\rho\in\mathcal Q(\mu)$ is the occupancy measure of the stationary policy $$\pi_\rho(a\mid s):=\frac{\rho(s,a)}{\sum_{a'}\rho(s,a')}\qquad(\text{arbitrary where the denominator vanishes}).$$
  3. $\mathcal Q(\mu)$ is a closed convex polytope (a bounded set cut out by finitely many linear equalities and inequalities; Primer B) whose vertices are occupancy measures of deterministic policies.
In words: nothing is lost by restricting to stationary stochastic policies, and the set of things a policy can achieve is convex.
Proof sketch — Why every flow-feasible $\rho$ comes from the policy $\pi_\rho$

Take $\rho\in\mathcal Q(\mu)$ and let $w=\pi_\rho$. Insert $\rho(s',a')=\rho(s')\,w(a'\mid s')$ into the flow equation: $$\rho(s)=(1-\gamma)\mu(s)+\gamma\sum_{s'}\rho(s')\underbrace{\sum_{a'}w(a'\mid s')P(s\mid s',a')}_{=:P_w(s\mid s')}.$$ In row-vector form $\rho^\top(I-\gamma P_w)=(1-\gamma)\mu^\top$. The stochastic matrix $P_w$ has spectral radius $1$, so with $\gamma\lt1$ the matrix $I-\gamma P_w$ is invertible and the state marginal is uniquely determined by $w$: $\rho^\top=(1-\gamma)\mu^\top(I-\gamma P_w)^{-1}$. But by part 1 the occupancy measure of $w$ itself satisfies the same equation, hence has the same marginal, $\rho_w(s)=\rho(s)$. Finally $\rho_w(s,a)=\rho_w(s)\,w(a\mid s)=\rho(s)\,w(a\mid s)=\rho(s,a)$. Part 3 follows because $\mathcal Q(\mu)$ is cut out by finitely many linear (in)equalities, and a standard extreme-point argument identifies its vertices with deterministic policies (Altman, Cor. 10.1).

Why $I-\gamma P_w$ is invertible. Index rows by the current state, $(P_w)_{s',s}=P_w(s\mid s')$. Every row is a probability vector, so $P_w\mathbf1=\mathbf1$ and $1$ is an eigenvalue. Each entry of $P_wv$ is an average of entries of $v$, so $\|P_wv\|_\infty\le\|v\|_\infty$ with $\|v\|_\infty=\max_s|v(s)|$ (Primer A); applied to an eigenvector, $P_wv=zv$, this gives $|z|\le1$. So the spectral radius of $P_w$ is $1$, every eigenvalue of $\gamma P_w$ has modulus at most $\gamma\lt1$, $1$ is not one of them, and $I-\gamma P_w$ is invertible.

Key equation — The occupancy LP
$$\begin{aligned} \max_{\rho\ \ge\ 0}\quad & \frac{1}{1-\gamma}\langle\rho,r\rangle\\ \text{s.t.}\quad & \frac{1}{1-\gamma}\langle\rho,c_i\rangle\le d_i,\qquad i=1,\dots,m,\\ & \sum_a\rho(s,a)-\gamma\sum_{s',a'}\rho(s',a')P(s\mid s',a')=(1-\gamma)\mu(s)\qquad\forall s. \end{aligned}$$ Its optimal value is $P^\star$ and an optimal $\rho^\star$ yields the optimal policy $\pi_{\rho^\star}$ (Altman, Thm 3.3). The map $\rho\mapsto(J_r,J_{c_1},\dots,J_{c_m})$ is linear, so the set of achievable (return, cost) vectors is a linear image of a polytope: convex, exactly the parallelogram of Section 1.
Fact — Basic optimal solutions of a linear program, and the support bound

Let $A$ be a finite real matrix of rank $r$. If the LP $\max q^Tx$ subject to $Ax=b$, $x\ge0$ is feasible and has a finite optimum, it has an optimal solution with at most $r$ positive entries. A solution whose positive columns are linearly independent is called basic. An inequality becomes an equality row by adding a nonnegative slack variable: the budget row $\langle\rho,c_i\rangle\le(1-\gamma)d_i$ becomes $\langle\rho,c_i\rangle+u_i=(1-\gamma)d_i$ with unused budget $u_i\ge0$.

Intuition: more than $r$ positive columns are dependent, so a small motion in a null direction preserves $Ax=b$ and positivity. At an optimum such a two-sided motion cannot improve the objective, so one can move until a positive entry reaches zero without changing the value. Repeat. In the occupancy LP there are at most $|\mathcal S|+m$ independent rows; subtracting one occupied action per visited state leaves at most $m$ extra actions. The next paragraph handles unvisited states.

The LP fact is standard; Altman 1999, Thm 3.8 applies it to CMDPs.

Three consequences that we will use. Randomisation count: the LP has $|\mathcal S|+m$ constraints besides $\rho\ge0$, so it has a basic optimal solution with at most $|\mathcal S|+m$ nonzero entries (slacks of the budget rows included). If every state is visited, each state uses at least one of them, which leaves at most $m$ extra entries, i.e. at most $m$ randomisations — Altman's bound with his $K=m$. If some states are never visited, their flow rows vanish on the support of $\rho$ (a zero-occupancy state receives no flow), so the same count runs over the visited states only and the conclusion is unchanged (Altman's proof removes those states); at unvisited states any deterministic action will do. Convex image: the zero-duality-gap proof of Section 3 rests on the convexity of $\mathcal Q(\mu)$, plus Slater's condition for continuity at the nominal budget. LP duality: the dual of this LP is the Lagrangian dual of the CMDP, and the dual variable of the budget row is the Lagrange multiplier $\lambda_i$.

Derivation — The dual LP and why its multiplier is the Lagrange multiplier

Attach a free multiplier to each flow equality (we scale it as $V(s)/(1-\gamma)$ so that $V$ ends up with the units of a value function) and $\lambda_i\ge0$ to each budget row. The LP Lagrangian is $$\mathcal L(\rho,V,\lambda)=\frac{\langle\rho,r\rangle}{1-\gamma}+\sum_s\frac{V(s)}{1-\gamma}\Big[(1-\gamma)\mu(s)+\gamma\sum_{s',a'}\rho(s',a')P(s\mid s',a')-\sum_a\rho(s,a)\Big]+\sum_i\lambda_i\Big[d_i-\frac{\langle\rho,c_i\rangle}{1-\gamma}\Big].$$ Collect the coefficient of each $\rho(s,a)$ (rename summation indices in the transition term): $$\mathcal L=\langle\mu,V\rangle+\langle\lambda,d\rangle+\frac{1}{1-\gamma}\sum_{s,a}\rho(s,a)\Big[r(s,a)-\sum_i\lambda_ic_i(s,a)+\gamma\sum_{s'}P(s'\mid s,a)V(s')-V(s)\Big].$$ Maximise over $\rho\ge0$. The sup is $+\infty$ unless every bracket is $\le0$, in which case it is attained at $\rho=0$ and equals the constant. Hence the dual LP is $$\min_{V,\ \lambda\ge0}\ \langle\mu,V\rangle+\sum_i\lambda_id_i\quad\text{s.t.}\quad V(s)\ \ge\ r(s,a)-\sum_i\lambda_ic_i(s,a)+\gamma\sum_{s'}P(s'\mid s,a)V(s')\ \ \forall(s,a).$$ Read the constraint. It says $V\ge\mathcal T_\lambda V$ at every state, where $(\mathcal T_\lambda V)(s)=\max_a\big[r_\lambda(s,a)+\gamma\sum_{s'}P(s'\mid s,a)V(s')\big]$ is the Bellman optimality operator (Primer E) of the penalised reward $r_\lambda:=r-\sum_i\lambda_ic_i$. $\mathcal T_\lambda$ is monotone ($V\ge W$ implies $\mathcal T_\lambda V\ge\mathcal T_\lambda W$) and a $\gamma$-contraction, so applying it repeatedly to $V\ge\mathcal T_\lambda V$ gives $V\ge\mathcal T_\lambda V\ge\mathcal T_\lambda^2V\ge\cdots\to V^\star_\lambda$, and $V=V^\star_\lambda$ is itself feasible. With $\mu\ge0$ the inner minimisation therefore picks $V=V_\lambda^\star$, the optimal value of the penalised MDP (other minimisers can differ from it only at states with $\mu(s)=0$), and with $V^\star_\lambda(\mu):=\sum_s\mu(s)V^\star_\lambda(s)$ the dual LP collapses to $$\min_{\lambda\ge0}\Big[V^\star_\lambda(\mu)+\langle\lambda,d\rangle\Big]=\min_{\lambda\ge0}\max_\pi\Big[J_r(\pi)-\sum_i\lambda_i\big(J_{c_i}(\pi)-d_i\big)\Big],$$ which is the Lagrangian dual problem of Section 3. LP strong duality (a feasible LP with bounded value has no gap, and its dual optimum is attained) then gives $P^\star=D^\star$ for every feasible finite CMDP, with no Slater condition: this is the content of Altman's Theorem 3.6, which he proves by a minimax argument on the compact (closed and bounded, Primer 0) set of occupation measures. Paternain et al. reprove the zero gap for compact, continuous state and action spaces, where finite-dimensional LP duality is not available; their argument rests on the concavity of the perturbation function together with Slater's condition, and that is the content of the next section.

Connection to Module 2
The pattern "dual variable of a resource row = shadow price of the resource" is the LP instance of the KKT/duality material in Module 2. Here it says $\lambda_i^\star=\partial P^\star/\partial d_i$ wherever $P^\star$ is differentiable in the budget: the multiplier is the marginal return one would gain by relaxing the $i$-th safety budget by one unit. That is also why the multipliers of a well-posed safety constraint are moderate numbers, while a constraint that is nearly impossible to meet can require a large $\lambda^\star$. A small margin permits a large multiplier but does not force one: if relaxing a budget does not improve the optimum, its multiplier is zero however tight the constraint. Section 3 bounds $\lambda^\star$ through Slater's margin.

3. Lagrangian Relaxation and the Zero Duality Gap

Deep RL cannot manipulate occupancy measures directly: it has a parametrised policy $\pi_\theta$ and a gradient estimator (Primer E). The Lagrangian route keeps the policy as the variable and moves the constraint into the objective with a price $\lambda$.

Definition — Lagrangian, dual function, dual problem
$$L(\pi,\lambda):=J_r(\pi)-\sum_{i=1}^m\lambda_i\big(J_{c_i}(\pi)-d_i\big),\qquad D(\lambda):=\max_{\pi}L(\pi,\lambda),\qquad D^\star:=\min_{\lambda\in\mathbb R^m_+}D(\lambda).$$ We write the dual function with a capital $D$, as in Module 2, so that $d$ always denotes a budget (Paternain et al. write $d(\lambda)$). For fixed $\lambda$, maximising $L$ is an ordinary MDP with the penalised reward $r_\lambda=r-\sum_i\lambda_ic_i$ (plus the constant $\langle\lambda,d\rangle$): any RL algorithm can attack it. We call a maximiser $\pi_\lambda$ (one exists for finite CMDPs; in general spaces the $\max$ is a $\sup$, and a maximiser is assumed wherever one is used, as in Section 1); the set of all maximisers is $\Pi(\lambda)$. Slater's condition asks for a strictly feasible policy: $\bar\pi$ with $J_{c_i}(\bar\pi)\le d_i-\xi$ for some margin $\xi\gt0$ and all $i$.

Weak duality is two lines. For any feasible $\pi$ and any $\lambda\ge0$, every term $\lambda_i(J_{c_i}(\pi)-d_i)$ is $\le0$, so $L(\pi,\lambda)\ge J_r(\pi)$; taking the max over $\pi$ on the left and over feasible $\pi$ on the right gives $D(\lambda)\ge P^\star$ for every $\lambda\ge0$, hence $D^\star\ge P^\star$. Convexity is one line: $D$ is a pointwise maximum of functions $\lambda\mapsto L(\pi,\lambda)$ that are affine in $\lambda$, hence convex (Exercise 8.2 does the cost-minimisation mirror image, where the dual function is concave and the dual problem is a maximisation). So the dual problem is a convex program in $m$ variables. The question is whether its value is the CMDP value.

Theorem — Zero duality gap for CMDPs (Paternain, Chamon, Calvo-Fullana, Ribeiro, NeurIPS 2019, Thm 1)
Assumptions. (A1) The discounted model of Section 1 ($\gamma\in(0,1)$, finitely many constraints) with compact state and action sets $\mathcal S\subset\mathbb R^n$, $\mathcal A\subset\mathbb R^k$ (finite sets included), a Markov transition density, bounded reward and costs, and the maximisation over all randomised policies. (A2) Slater's condition holds.
Statement. Then strong duality holds: $P^\star=D^\star$ (the proof below also shows that the dual minimum is attained).
In words. Although the CMDP is non-convex in $\pi$ (and infinite-dimensional for continuous spaces), the price $\lambda^\star$ that solves the convex dual problem is exact: penalising the costs with $\lambda^\star$ yields a Lagrangian whose maximum equals the constrained optimum. (A1) is what makes the returns finite and lets sums and integrals be exchanged; (A2) rules out constraints that are only just attainable, for which the multiplier can be unbounded and, in general (non-finite) spaces, the dual value could sit strictly above $P^\star$; for finite CMDPs the LP argument of Section 2 closes the gap even without Slater. "All randomised policies" matters: the proof mixes two policies, which a neural policy family need not allow, so the parametrised case below needs its own theorem.
Derivation — Proof of the zero duality gap via the perturbation function

Define the perturbation function $P(\xi):=\sup_\pi J_r(\pi)$ s.t. $J_{c_i}(\pi)\le d_i+\xi_i$ for $\xi\in\mathbb R^m$ (a maximum in the finite case), with $P(\xi)=-\infty$ when no policy is feasible. Then $P(0)=P^\star$, and $P$ is nondecreasing in each $\xi_i$ (looser budgets cannot hurt). The proof has three steps: express the dual function through $P$, show $P$ is concave, invoke Fenchel–Moreau.

Step 1: the dual function is the conjugate of $P$ (conjugates: Primer B). We claim $D(\lambda)=\sup_{\xi}\{P(\xi)-\langle\lambda,\xi\rangle\}$ for $\lambda\ge0$. ($\le$): for any $\pi$ put $\xi:=J_c(\pi)-d$; then $\pi$ is feasible for $P(\xi)$, so $J_r(\pi)\le P(\xi)$ and $L(\pi,\lambda)=J_r(\pi)-\langle\lambda,\xi\rangle\le P(\xi)-\langle\lambda,\xi\rangle$; maximise over $\pi$. ($\ge$): for any $\xi$ and any $\pi$ feasible for $P(\xi)$ we have $J_c(\pi)-d\le\xi$ componentwise, so with $\lambda\ge0$, $L(\pi,\lambda)\ge J_r(\pi)-\langle\lambda,\xi\rangle$; maximise over such $\pi$ to get $D(\lambda)\ge P(\xi)-\langle\lambda,\xi\rangle$. (Restricting to $\lambda\ge0$ loses nothing: if $\lambda_i\lt0$, sending $\xi_i\to\infty$ makes the sup $+\infty$ because $P$ is nondecreasing.)

Step 2: $P$ is concave. Take $\xi^1,\xi^2$ with $P$ finite, a mixing weight $\kappa\in(0,1)$ and a tolerance $\varepsilon'\gt0$. Pick policies $\pi_1,\pi_2$, feasible for the two perturbations, with $J_r(\pi_j)\ge P(\xi^j)-\varepsilon'$, and let $\rho_1,\rho_2\in\mathcal Q(\mu)$ be their occupancy measures. (In the finite case the occupancy LP attains the maxima and $\varepsilon'=0$ is allowed. Paternain et al. assume attainment in general, citing compactness of the set of occupation measures; compactness alone does not make a merely bounded reward attain its supremum, which is why we argue with near-maximisers.) Convexity of the set of occupancy measures gives a policy $\pi_\kappa$ with $\rho_{\pi_\kappa}=\kappa\rho_1+(1-\kappa)\rho_2$ (Section 2, part 2 of the theorem, in the finite case; for compact spaces Paternain et al. cite Borkar's convexity result for occupation measures). Returns are linear in $\rho$, so $$J_r(\pi_\kappa)=\kappa J_r(\pi_1)+(1-\kappa)J_r(\pi_2)\ge\kappa P(\xi^1)+(1-\kappa)P(\xi^2)-\varepsilon',\qquad J_{c_i}(\pi_\kappa)=\kappa J_{c_i}(\pi_1)+(1-\kappa)J_{c_i}(\pi_2)\le d_i+\kappa\xi_i^1+(1-\kappa)\xi^2_i .$$ Thus $\pi_\kappa$ is feasible for the perturbation $\kappa\xi^1+(1-\kappa)\xi^2$ and $P(\kappa\xi^1+(1-\kappa)\xi^2)\ge J_r(\pi_\kappa)\ge\kappa P(\xi^1)+(1-\kappa)P(\xi^2)-\varepsilon'$. As $\varepsilon'\gt0$ was arbitrary, this is concavity. Note that nothing about convexity in $\pi$ was needed: the mixture happens in occupancy space, where a mixture is again realisable. (If history-dependent policies are allowed, as in our definition of Section 1, the mixture is even more direct: draw $B\in\{1,2\}$ once at time zero with probabilities $\kappa$ and $1-\kappa$, remember it and follow $\pi_B$; conditioning on $B$ gives exactly the two displayed identities, with no occupancy-measure theorem.)

Fact — Supporting slopes of a concave function (Fenchel–Moreau)

Let $F:\mathbb R^m\to\mathbb R\cup\{-\infty\}$ be concave and proper: finite somewhere (the value $-\infty$ is allowed; here it marks infeasible budgets). Put $D_F(q):=\sup_x\{F(x)-q^\top x\}$.

(i) If $F$ is also upper semicontinuous, $\limsup_{x_n\to x}F(x_n)\le F(x)$ at every $x$ (no downward jump at a point: $F(x)=1$ for $x\ne0$, $F(0)=0$ fails at $0$), then $F(x)=\inf_q\{D_F(q)+q^\top x\}$ for every $x$.

(ii) If $F$ is finite on a neighbourhood of $0$, it is continuous there and has a finite supergradient $q$ at $0$: $F(x)\le F(0)+q^\top x$ for all $x$. Then $D_F(q)=F(0)$, so the infimum in (i) at $x=0$ is attained at this $q$. If $F$ is nondecreasing in each coordinate, $q\ge0$: put $x=te_i$, $t\gt0$, into the supporting inequality.

Intuition: every affine function $x\mapsto D_F(q)+q^\top x$ lies above the concave graph; (i) says their lower envelope recovers $F$, and (ii) says that at an interior point one of them actually touches it.

Step 3: Fenchel–Moreau. By Step 1, $D^\star=\min_{\lambda\ge0}\sup_\xi\{P(\xi)-\langle\lambda,\xi\rangle\}$ is the value at $\xi=0$ of the biconjugate of $P$, the smallest concave upper-semicontinuous function above $P$. For a proper concave $P$ the biconjugate is its upper-semicontinuous hull and therefore agrees with $P$ at every point where $P$ is upper semicontinuous (Fenchel–Moreau; Paternain et al. package this step as their Proposition 1, citing Rockafellar's Convex Analysis, Cor. 30.2.2). $P$ is proper because (A1) bounds it above by $\sup|r|/(1-\gamma)$, and Slater's condition says $P$ is finite on a neighbourhood of $0$ (any $\xi$ with $\xi_i\gt-\xi_{\rm Slater}$ keeps $\bar\pi$ feasible); a concave function is continuous on the interior of its domain (the points with a whole small ball around them inside the set where it is finite; Primer 0). Hence $D^\star=P(0)=P^\star$. Part (ii) of the box gives more: Slater makes $P$ finite near $0$, so $P$ has a supergradient $q\ge0$ at $0$ ($P$ is nondecreasing), and $D(q)=\sup_\xi\{P(\xi)-\langle q,\xi\rangle\}=P(0)$. The dual minimum is attained, at $\lambda^\star=q$.

Geometric reading. The dual problem finds the best affine majorant $\xi\mapsto D(\lambda)+\langle\lambda,\xi\rangle$ of $P$ and evaluates it at $0$. If $P$ had a dent at $0$ (non-concave), the best majorant would sit above $P(0)$: a duality gap. Concavity removes the dent, and $\lambda^\star$ is a supergradient of $P$ at $0$: the shadow price of the budgets.

Lemma — Slater's margin bounds the multiplier (Ding et al., journal version, Lemma 3, there for one constraint)
If $\bar\pi$ is feasible with margin $\xi$, every dual optimum satisfies $\|\lambda^\star\|_1\le\big(P^\star-J_r(\bar\pi)\big)/\xi$, where $\|\lambda\|_1=\sum_i|\lambda_i|$ (Primer A).
Proof. $D^\star=D(\lambda^\star)\ge L(\bar\pi,\lambda^\star)=J_r(\bar\pi)+\sum_i\lambda^\star_i\big(d_i-J_{c_i}(\bar\pi)\big)\ge J_r(\bar\pi)+\xi\|\lambda^\star\|_1$, and $D^\star=P^\star$. $\square$
This bound is what every primal-dual rate in Section 4 hides inside its constants: the projection interval $\Lambda=[0,2/((1-\gamma)\xi)]$ of NPG-PD is exactly twice this bound for rewards in $[0,1]$.

Parametrised policies: almost no price to pay

With a neural policy $\pi_\theta$ the maximisation in $D(\lambda)$ runs over $\theta$, and the dual value $D^\star_\theta$ can differ from $P^\star$. Paternain et al. bound the difference in terms of how expressive the class is.

Theorem — Duality gap of an $\epsilon$-universal parametrisation (Paternain et al. 2019, Def. 1 and Thm 2)
A parametrisation is $\epsilon$-universal if for every policy $\pi$ there is $\theta$ with $\max_{s}\int_{\mathcal A}|\pi(a\mid s)-\pi_\theta(a\mid s)|\,da\le\epsilon$ (an $L^1$, i.e. twice-total-variation, distance uniformly over states; for finite $\mathcal A$ the integral is a sum, and in general one asks $2\sup_s\mathrm{TV}(\pi(\cdot\mid s),\pi_\theta(\cdot\mid s))\le\epsilon$, which also covers policies without densities; total variation: Primer C). Suppose $|r|\le B_{r_0}$, $|c_i|\le B_c$ with $B_c=\max_i B_{c_i}$, put $\Delta_\epsilon:=\epsilon/(1-\gamma)^2$ (the return error of an $\epsilon$-approximation with our unnormalised returns; see the caveat below), and let $\lambda^\star_\epsilon$ be the dual solution of the tightened problem with budgets $d_i-B_c\Delta_\epsilon$. Under the assumptions of the zero-gap theorem, $$P^\star\ \ge\ D^\star_\theta\ \ge\ P^\star-\big(B_{r_0}+\|\lambda^\star_\epsilon\|_1B_c\big)\,\Delta_\epsilon,\qquad \Delta_\epsilon=\frac{\epsilon}{(1-\gamma)^2}.$$ The bound is informative when the tightened problem is still strictly feasible. A Slater margin $\xi\gt B_c\Delta_\epsilon$ is a sufficient certificate of this, but not a necessary one, because another policy may have a larger margin. If the tightened problem is infeasible, its dual value is $-\infty$, $\lambda^\star_\epsilon$ has "infinite norm" in the paper's words, and the bound holds only vacuously, as the paper remarks. If the margin test merely fails, nothing follows from it: feasibility of the tightened problem and the size of $\lambda^\star_\epsilon$ must be checked separately (a feasible tightened problem can have finite dual optima even without a Slater point, as every feasible finite CMDP does by LP duality).
Proof idea. Lemma 1 of the paper shows that the occupancy measures of $\pi$ and of its $\epsilon$-approximation differ by at most $\epsilon/(1-\gamma)$ in $L^1$ (the per-step error $\epsilon$ compounds geometrically); since $J=\langle\rho,r\rangle/(1-\gamma)$, their returns differ by at most $B\Delta_\epsilon$. For every $\lambda$, replacing a Lagrangian maximiser by its $\epsilon$-approximation therefore loses at most $(B_{r_0}+\|\lambda\|_1B_c)\Delta_\epsilon$: $D_\theta(\lambda)\ge D(\lambda)-(B_{r_0}+\|\lambda\|_1B_c)\Delta_\epsilon$, with $D_\theta$ the dual function of the parametrised problem. The $\lambda$-dependent part of the loss is exactly what turns $D$ into the dual function of the tightened problem (budgets $d_i-B_c\Delta_\epsilon$), $D_{\rm tight}(\lambda)=D(\lambda)-B_c\Delta_\epsilon\|\lambda\|_1$ for $\lambda\ge0$. Minimising over $\lambda\ge0$ and using weak duality $D(\lambda)\ge P^\star$ at the last step, $$D^\star_\theta\ \ge\ \min_{\lambda\ge0}D_{\rm tight}(\lambda)-B_{r_0}\Delta_\epsilon=D(\lambda^\star_\epsilon)-\big(B_{r_0}+B_c\|\lambda^\star_\epsilon\|_1\big)\Delta_\epsilon\ \ge\ P^\star-\big(B_{r_0}+B_c\|\lambda^\star_\epsilon\|_1\big)\Delta_\epsilon .$$ The upper bound $D^\star_\theta\le D^\star=P^\star$ holds because the $\pi_\theta$ form a subset of all policies, so $D_\theta\le D$ pointwise. (Primal reading: an $\epsilon$-approximation of an optimal policy of the tightened problem is feasible for the original one.)
Caveat (verified against the paper)
Three things are easy to misquote. (i) The multiplier in the bound is the dual solution of the tightened problem, not of the original one; the two can differ a lot when the original constraint is nearly tight. (ii) The paper's Eq. (14) prints the parametrised dual function with a $\min$ over $\theta$; it must be a $\max$, as the surrounding text and the proofs confirm. (iii) The paper states the bound, and the tightening (perturbation $B_r\epsilon/(1-\gamma)$ in its utility convention), with $\epsilon/(1-\gamma)$. That is the right scale for returns normalised by $(1-\gamma)$, but the paper's value functions $V_i$ are unnormalised and its Eq. (35) drops the factor $1/(1-\gamma)$ between occupancy measures and returns; in the unnormalised convention of this page both become $\epsilon/(1-\gamma)^2$, as stated above. The message to retain: the gap is linear in $\epsilon$ and scales with the size of the multipliers.

Primal recovery: the right price is not the right policy

Zero duality gap means the values agree. It does not mean that a maximiser of $L(\cdot,\lambda^\star)$ solves the CMDP. The precise relation is one inclusion.

Lemma — Optimal policies are Lagrangian maximisers, not conversely (Calvo-Fullana et al. 2024, Prop. 1)
Under zero duality gap, $\Pi^\star\subseteq\Pi(\lambda^\star)$, and every $\pi^\star\in\Pi^\star$ satisfies complementary slackness $\lambda_i^\star\big(J_{c_i}(\pi^\star)-d_i\big)=0$.
Proof. For $\pi^\star\in\Pi^\star$, feasibility and $\lambda^\star\ge0$ give $L(\pi^\star,\lambda^\star)\ge J_r(\pi^\star)=P^\star=D^\star=D(\lambda^\star)=\max_\pi L(\pi,\lambda^\star)$, so $\pi^\star$ attains the max, and the first inequality must be an equality, which forces each slack term to vanish. $\square$

The inclusion can be extremely loose. In the monitoring problem of Calvo-Fullana et al. (average reward; three states $R_0,R_1,R_2$; from $R_0$ the agent moves to $R_1$ or $R_2$, from $R_i$ it stays or returns to $R_0$; reward $\mathbf 1(s=R_0)$; constraints "spend at least a fraction $c=\tfrac13$ of the time in $R_1$ and in $R_2$", i.e. utility constraints $V_i\ge c$ in the paper's convention, costs $-\mathbf 1(s=R_i)$ with budget $-c$ in ours), an optimal policy flips a fair coin in every state and attains $P^\star=\tfrac13$ (the optimum is not unique: every policy whose long-run fractions are $(\tfrac13,\tfrac13,\tfrac13)$ is optimal). The dual optimum is $\lambda^\star=(1,1)$, and there the penalised reward is $\mathbf 1(R_0)+\mathbf 1(R_1)+\mathbf 1(R_2)-\tfrac23\equiv\tfrac13$: every policy maximises the Lagrangian, including "stay in $R_1$ forever", which violates the $R_2$ constraint. For any $\lambda\ne(1,1)$ no maximiser is optimal: with $\lambda_1\ne\lambda_2$ every maximiser abandons one region entirely ($V_1=0$ or $V_2=0$: infeasible), with $\lambda_1=\lambda_2\lt1$ the maximisers return to $R_0$ at once ($V_1+V_2=\tfrac12$: infeasible), and with $\lambda_1=\lambda_2\gt1$ every maximiser has $V_0=0$, hence zero return. The stationary maximisers enter a region and never leave (feasible in expectation only if the probability $q$ of entering $R_1$ lies in $[\tfrac13,\tfrac23]$, and even then every single trajectory starves one region). A history-dependent maximiser can instead shuttle between $R_1$ and $R_2$ in ever longer blocks, which meets both visit constraints on every trajectory but still earns zero return. So no fixed weighted reward identifies the solution; the multiplier is exact and useless at the same time (Exercise 8.6). The structural reason was stated in Section 1: finite penalised MDPs have deterministic optima, CMDPs often do not, so whenever the CMDP optimum must randomise, $\Pi(\lambda^\star)$ must contain several policies and the algorithm has to select among them.

Why it matters
Every practical Lagrangian method fights this in one of three ways. Averaging: the running average of the primal iterates of a dual subgradient method, taken in occupancy space, approaches an optimal mixed policy; one realises it by a mixture policy that draws one iterate at random per episode, or by the stationary policy of the averaged occupancy measure (Section 2). Averaging the action probabilities $\pi_k(a\mid s)$ themselves does not in general produce the averaged returns. (Draw $K$ uniformly from $\{0,\dots,T-1\}$ once per episode and follow $\pi_K$: conditioning on $K$ gives $\mathbb E\,J_r(\pi_K)=\frac1T\sum_kJ_r(\pi_k)$, and likewise for costs and occupancy measures. Redrawing $K$ at every step is a different policy with a different trajectory distribution. In the walkthrough's one-state example the returns are linear in $p$, so there the two coincide.) The walkthrough shows the mechanism, and NPG-PD's rate bounds exactly such averages of values. Regularisation: entropy (Primer E) on the policy plus a quadratic term on the multiplier give RPG-PD a unique regularised saddle point, and a ridge on the multiplier alone gives C-PG a unique, proportional dual best response; either way the last iterate itself, not an average, approaches a slightly biased solution (Section 4). Augmentation: make the policy a function of $\lambda$ and let the multiplier dynamics run at execution time, so the trajectory time-shares between the maximisers (Section 7). Module 9's trust-region methods (CPO) sidestep the issue differently: they solve a small local constrained problem at every update, recomputing its multipliers from scratch, instead of carrying a global CMDP multiplier from one update to the next.

From chance constraints to CMDP constraints with a safety guarantee

The constraints of a CMDP are expectations, while a safety requirement is usually "the trajectory stays in the safe set with probability at least $1-\delta$". Paternain, Calvo-Fullana, Chamon, Ribeiro, IEEE TAC 2023 show how to choose the budget so that the CMDP relaxation implies the chance constraint; the tool is the union bound over time steps (Primer C).

Theorem — Safe policies from a CMDP relaxation (Paternain et al. 2023, Def. 1 and Thm 1)
A policy is $(1-\delta)$-safe for $S_0\subseteq\mathcal S$ if $\mathbb P\big(\bigcap_{t\ge0}\{s_t\in S_0\}\mid\pi\big)\ge1-\delta$. Replace the chance constraint by the expected discounted occupation time $U_i(\theta):=\sum_t\gamma^t\,\mathbb P(s_t\in S_i\mid\pi_\theta)\ge c_i$, a utility constraint of the CMDP type (indicator reward $\mathbf 1(s\in S_i)$; in the paper's notation, kept here, $c_i$ is a threshold, not a cost function). For $\gamma=1$ and a finite horizon $T$, choosing $$c_i=(T+1)\Big(1-\frac{\delta_i}{T+1}\Big)=T+1-\delta_i$$ makes every feasible policy $(1-\delta_i)$-safe for $S_i$ up to time $T$. The slack is computed from $\delta_i$ and $T$ alone: no hyperparameter. (Discounted case, their Theorem 2: $c_i=\big(1-\delta_i\gamma^{T_i}(1-\gamma)\big)/(1-\gamma)$ makes every feasible policy $(1-\delta_i)$-safe until a chosen time $T_i$, so the safety horizon is traded against the slack.)
Derivation — The union bound behind the slack $T+1-\delta$

Let $E_t=\{s_t\in S_i\}$. The complement of "safe at all times" is the union of the per-step failures, so by Boole's inequality $$\mathbb P\Big(\bigcap_{t=0}^{T}E_t\Big)=1-\mathbb P\Big(\bigcup_{t=0}^{T}E_t^c\Big)\ \ge\ 1-\sum_{t=0}^{T}\mathbb P(E_t^c)=1-\sum_{t=0}^{T}\big(1-\mathbb P(E_t)\big)=1-(T+1)+U_i(\theta).$$ Feasibility $U_i(\theta)\ge T+1-\delta_i$ makes the right-hand side at least $1-\delta_i$. $\square$ The price of the relaxation is visible: the expected number of safe steps must be within $\delta_i$ of the maximum $T+1$, i.e. the per-step failure probabilities must be tiny on average. The survey of Wachi, Shen, Sui, IJCAI 2024 states the same fact in general: an expected-cumulative constraint on indicator costs is a conservative approximation of a joint chance constraint, by Boole.

Discounted case. Let $F=\sum_{t\ge0}\gamma^t\,\mathbb P(s_t\notin S_i)=\frac1{1-\gamma}-U_i(\theta)$. The threshold $c_i=\frac1{1-\gamma}-\delta_i\gamma^{T_i}$ of Theorem 2 gives $F\le\delta_i\gamma^{T_i}$. For $t\le T_i$ we have $\gamma^{t-T_i}\ge1$, so $\sum_{t=0}^{T_i}\mathbb P(s_t\notin S_i)\le\gamma^{-T_i}F\le\delta_i$, and the same union bound gives safety up to time $T_i$, not beyond.

4. Primal-Dual Algorithms and Their Convergence

The dual problem is convex and $m$-dimensional, so we would like to run (sub)gradient descent on $D(\lambda)$. The only obstacle is evaluating $D(\lambda)$, which is itself an RL problem. Danskin's theorem tells us what the gradient is once that RL problem is solved.

Key equation — The dual gradient is the constraint violation
If $\pi_\lambda\in\Pi(\lambda)$ is any maximiser of $L(\cdot,\lambda)$, then the vector with entries $$g_i(\lambda)=-\big(J_{c_i}(\pi_\lambda)-d_i\big)=d_i-J_{c_i}(\pi_\lambda)$$ is a subgradient of $D$ at $\lambda$. It is a gradient when the maximiser is unique and Danskin's compactness and continuity hypotheses hold (Module 2), as they do for finite CMDPs in occupancy form; uniqueness alone is not enough in a general policy space. Proof. For any $\lambda'$, $D(\lambda')\ge L(\pi_\lambda,\lambda')=L(\pi_\lambda,\lambda)+\sum_i(\lambda_i-\lambda'_i)\big(J_{c_i}(\pi_\lambda)-d_i\big)=D(\lambda)+\langle g(\lambda),\lambda'-\lambda\rangle$, which is the subgradient inequality. $\square$ Projected subgradient descent on $D$ is therefore $$\lambda_{k+1}=\Big[\lambda_k+\eta\big(J_c(\pi_{\lambda_k})-d\big)\Big]_+ :$$ here $[x]_+=\max(x,0)$ entrywise is the projection onto $\lambda\ge0$ (Primer B). Raise the price of a constraint while it is violated, lower it (down to zero) while it is slack. This is the update in every Lagrangian safe-RL method, and Section 5 will read it as a controller.
Algorithm 1: Dual descent for constrained RL (Paternain et al. 2019, Alg. 1; our sign convention)
  1. Initialise $\theta_0$, $\lambda_0=0$, step $\eta$.
  2. For $k=0,1,\dots$:
  3. $\theta_{k+1}\approx\operatorname*{arg\,max}_\theta L(\theta,\lambda_k)$ with any RL algorithm on the reward $r-\sum_i\lambda_{k,i}c_i$. // inner loop, run to (approximate) convergence
  4. $\lambda_{k+1}=\big[\lambda_k+\eta\,(J_c(\theta_{k+1})-d)\big]_+$. // in practice a Monte-Carlo estimate of $J_c$ (Primer C); the theorem below assumes the exact value

Paternain et al. prove (their Theorem 3) that if the inner RL step returns a local maximiser whose Lagrangian value is within $\delta$ of the global one (their Assumption 1), then under Slater's condition for the parametrised problem and $\epsilon$-universality the dual iterates reach a neighbourhood of the optimum in at most $K\le\|\lambda_0-\lambda_\theta^\star\|^2/(2\eta\varepsilon)$ dual steps, with $P^\star-(B_{r_0}+\|\lambda^\star_\epsilon\|_1B_c)\Delta_\epsilon\le D_\theta(\lambda_K)\le P^\star+\eta B/2+\delta+\varepsilon$. Here $D_\theta$ is the dual function of the parametrised problem and $\lambda^\star_\theta$ its minimiser; the lower bound is the previous theorem, with the same tightened-problem multiplier $\lambda^\star_\epsilon$ and the same $\Delta_\epsilon=\epsilon/(1-\gamma)^2$ (the paper's statement prints $\epsilon/(1-\gamma)$ and calls the multiplier the solution of the unperturbed dual, but its proof, Eq. (46), inherits Theorem 2's tightened-problem multiplier); and $B=\sum_i\big(B_{c_i}/(1-\gamma)+d_i\big)^2$ is the paper's $\sum_i(B_{r_i}/(1-\gamma)-c_i)^2$ translated to cost budgets, a valid bound on $\|J_c-d\|_2^2$ when every $d_i\ge0$ (in general use $|d_i|$). The three error sources are visible: parametrisation ($\epsilon$), inner-loop inaccuracy ($\delta$) and the fixed dual step ($\eta$). Running the inner loop to convergence is expensive, which motivates interleaving the two updates.

Derivation — Where the terms $\eta B/2$ and $\delta$ come from

Write $g_k=d-J_c(\theta_k)$ for the inner solution $\theta_k$ used at step $k$, and assume, as the theorem does, exact values and $\|g_k\|_2^2\le B$. (1) The $\delta$-accurate inner solve, $L(\theta_k,\lambda_k)\ge D_\theta(\lambda_k)-\delta$, makes $g_k$ a $\delta$-subgradient: for every $\lambda'\ge0$, $D_\theta(\lambda')\ge L(\theta_k,\lambda')=L(\theta_k,\lambda_k)+\langle g_k,\lambda'-\lambda_k\rangle\ge D_\theta(\lambda_k)-\delta+\langle g_k,\lambda'-\lambda_k\rangle$. (2) The update is $\lambda_{k+1}=[\lambda_k-\eta g_k]_+$, and projecting onto $\lambda\ge0$ cannot increase the distance to $\lambda^\star_\theta\ge0$: $$\|\lambda_{k+1}-\lambda^\star_\theta\|^2\le\|\lambda_k-\eta g_k-\lambda^\star_\theta\|^2=\|\lambda_k-\lambda^\star_\theta\|^2-2\eta\langle g_k,\lambda_k-\lambda^\star_\theta\rangle+\eta^2\|g_k\|^2 .$$ (3) Step (1) with $\lambda'=\lambda^\star_\theta$ gives $\langle g_k,\lambda_k-\lambda^\star_\theta\rangle\ge D_\theta(\lambda_k)-D^\star_\theta-\delta$. (4) Insert (3) into (2), sum over $k=0,\dots,T-1$ (the distances telescope, and the last one is $\ge0$) and divide by $2\eta T$: $$\min_{k\lt T}D_\theta(\lambda_k)-D^\star_\theta\ \le\ \frac1T\sum_{k\lt T}\big(D_\theta(\lambda_k)-D^\star_\theta\big)\ \le\ \frac{\|\lambda_0-\lambda^\star_\theta\|^2}{2\eta T}+\frac{\eta B}{2}+\delta .$$ So $T\ge\|\lambda_0-\lambda^\star_\theta\|^2/(2\eta\varepsilon)$ steps bring some iterate within $\varepsilon+\eta B/2+\delta$ of $D^\star_\theta\le P^\star$: the upper bound of the theorem. With Monte-Carlo estimates of $J_c$ the update becomes stochastic and noise terms must be added, and truncating a discounted rollout after $H$ steps (with $|c|\le B_c$) biases each estimate by up to $B_c\gamma^H/(1-\gamma)$.

RCPO: penalised reward and three timescales

Tessler, Mankowitz, Mannor, ICLR 2019 made the interleaved version the deep-RL standard. Two ideas. First, the actor and critic are trained on the penalised per-step reward $\hat r(\lambda,s,a)=r(s,a)-\lambda c(s,a)$, whose discounted value $\hat V^\pi(\lambda,s)=V_R^\pi(s)-\lambda V_{C_\gamma}^\pi(s)$ satisfies a Bellman equation and can be learned by an actor–critic with a temporal-difference (TD) critic (Primer E), even when the actual constraint $J_C$ is a general (e.g. average or non-discounted) functional that has no Bellman structure. Second, $\lambda$ is updated with Monte-Carlo estimates of the original constraint, on the slowest of three timescales.

Algorithm 2: RCPO template (Tessler et al. 2019, Alg. 1)
  1. Input: penalty $c$, constraint $C$, threshold $\alpha$, step sizes $\eta_1(k)\lt\eta_2(k)\lt\eta_3(k)$; init $\theta_0,v_0,\lambda_0=0$.
  2. For each episode $k$: for $t=0,\dots,T-1$: sample $a_t\sim\pi_\theta$, observe $r_t,c_t,s_{t+1}$;
  3. target $\hat R_t=r_t-\lambda_kc_t+\gamma\hat V(\lambda,s_{t+1};v_k)$; // penalised reward, Eq. (10)
  4. critic $v_{k+1}\leftarrow v_k-\eta_3(k)\,\partial(\hat R_t-\hat V(\lambda,s_t;v_k))^2/\partial v$; // fastest
  5. actor $\theta_{k+1}\leftarrow\Gamma_\theta\big[\theta_k+\eta_2(k)\nabla_\theta\hat V(\lambda,s)\big]$; // policy gradient on the penalised value
  6. multiplier $\lambda_{k+1}\leftarrow\Gamma_\lambda\big[\lambda_k+\eta_1(k)\,(J_C^{\pi_\theta}-\alpha)\big]$. // slowest; Monte-Carlo estimate of the true constraint

Reading Algorithm 2: $v$ are the critic parameters, and the critic takes a TD semi-gradient step, i.e. the target $\hat R_t$ is computed with the current critic and held fixed while the squared prediction error is differentiated. $\Gamma_\theta$ projects onto the admissible actor parameters and $\Gamma_\lambda$ onto the multiplier range $[0,\lambda_{\max}]$. Actor and critic are updated after every transition; the multiplier only once per episode, which is what the index $k$ counts.

Background — Robbins–Monro steps and multiple-timescale stochastic approximation

A stochastic-approximation update has the form $x_{k+1}=x_k+\eta_k(h(x_k)+M_{k+1})$: a mean direction $h$ plus noise. With $\mathcal F_k$ denoting everything observed by step $k$, the noise condition is $\mathbb E[M_{k+1}\mid\mathcal F_k]=0$, with controlled conditional variance (see Primer C). The conditions $\sum_k\eta_k=\infty$ and $\sum_k\eta_k^2\lt\infty$ allow continued motion while damping accumulated noise. For example, $(k+1)^{-0.8}$ satisfies both. The associated differential equation is $\dot x=h(x)$; stable equilibria explain what the noisy iterates can track. In multiple timescales, a ratio of steps tending to zero makes one variable effectively frozen while the other relaxes. The schedules alone prove no convergence: stability, bounded iterates and suitable mean/noise regularity are also required.

Theorem — RCPO converges to a feasible fixed point (Tessler et al. 2019, Thms 1–2)
Assumptions. Robbins–Monro steps $\sum_k\eta_i(k)=\infty$, $\sum_k\eta_i(k)^2\lt\infty$ with $\eta_1(k)/\eta_2(k)\to0$ (the multiplier moves on a slower timescale than the policy) and, for the three-timescale actor–critic, $\eta_2(k)/\eta_3(k)\to0$ (the critic faster still); for example $\eta_1=(k+1)^{-0.95}$, $\eta_2=(k+1)^{-0.8}$, $\eta_3=(k+1)^{-0.65}$. Bounded values and the standard stability and bounded-noise conditions of multi-timescale stochastic approximation (Borkar), stated there as assumptions, not derived: noise with zero conditional mean and bounded conditional variance, almost surely bounded iterates, and, with the slower variables frozen, a stable equilibrium of each faster variable's limiting ODE (background box above); that every local minimum of the constraint is a feasible point (their Assumption 2, used with Theorem 1 through their Lemma 1) and, for Theorem 2, that every local minimum of the discounted guiding penalty $J_{C_\gamma}^{\pi_\theta}$ is feasible, $\Theta_\gamma\subseteq\Theta:=\{\theta:J_C^{\pi_\theta}\le\alpha\}$; and an unbounded multiplier range: the feasibility proofs take $\lambda_{\max}=\infty$, or let $\lambda_{\max}\to\infty$ (footnote 4: "When Assumption 2 holds, $\lambda_{\max}$ can be set to $\infty$").
Statement. The iterates $(\theta_k,v_k,\lambda_k)$ converge almost surely (with probability one, Primer C) to a fixed point $(\theta^\star(\lambda^\star,v^\star),v^\star(\lambda^\star),\lambda^\star)$ that is a feasible solution.
In words. Because $\lambda$ is quasi-static from the policy's point of view, the policy tracks a local maximiser of the penalised value; because $\lambda$ keeps growing while the constraint is violated, the only stationary points are feasible ones. There is no claim of optimality: the fixed point is a local optimum of the Lagrangian. And the stability and noise conditions describe an idealised process; nothing guarantees them for a neural actor and critic, so the theorem is not a guarantee for every implementation of Algorithm 2.
Caveat
The feasibility conclusion rests on $\Theta_\gamma\subseteq\Theta$: the discounted penalty used to train the critic must have no local minima outside the feasible set of the real constraint. The paper's own example is a torque constraint, where "zero torque" is a common local minimum of both. For a general constraint this is a genuine assumption, not a technicality: if the guiding penalty has a spurious local minimum, the process can stall at an infeasible point with $\lambda$ growing without bound. In practice $\Gamma_\lambda$ projects onto $[0,\lambda_{\max}]$ to keep $\lambda$ bounded, but then the guarantee is gone as well: a cap below the price that feasibility requires lets the multiplier saturate, and the limit can be infeasible even though a feasible policy exists.

NPG-PD: a dimension-free global rate

Background — Multiplicative weights, KL mirror descent, and regret bounds

Mirror ascent maximises $\langle p,A\rangle-\eta^{-1}\mathrm{KL}(p\|p_{\rm old})$ over action probabilities. With full-support $p_{\rm old}$, differentiating with a multiplier for $\sum_a p_a=1$ gives $A_a-\eta^{-1}(\log(p_a/p_{{\rm old},a})+1)=\text{constant}$, hence $p_a\propto p_{{\rm old},a}e^{\eta A_a}$. For $p_{\rm old}=(1/2,1/2)$, $A=(1,0)$ and $\eta=\log2$, this yields $(2/3,1/3)$. KL geometry keeps a probability vector on its simplex. For $|A_{t,a}|\le G$, the usual potential bound is $\sum_{t\lt T}\langle p-p_t,A_t\rangle\le\mathrm{KL}(p\|p_0)/\eta+\eta G^2T/2$. It comes from bounding each log normaliser and telescoping the KL differences. “Regret” is this total shortfall relative to a fixed comparator $p$; choosing $\eta$ proportional to $T^{-1/2}$ makes regret per step vanish.

Ding, Zhang, Başar, Jovanović, NeurIPS 2020 analyse the single-loop scheme "one natural policy gradient step (Primer E), one projected dual step" for tabular softmax policies with a utility constraint $V_g^\pi(\rho)\ge b$ (Slater margin $\xi$, rewards and utilities in $[0,1]$, $\rho$ the initial distribution). Under softmax, the natural gradient step on the Lagrangian is a multiplicative-weights update with the penalised advantage:

$$\begin{aligned}\pi^{(t+1)}(a\mid s)&\ \propto\ \pi^{(t)}(a\mid s)\exp\Big(\frac{\eta_1}{1-\gamma}A^{(t)}_L(s,a)\Big),\qquad A_L^{(t)}=A_r^{(t)}+\lambda^{(t)}A_g^{(t)},\\ \lambda^{(t+1)}&=\mathcal P_{\Lambda}\Big(\lambda^{(t)}-\eta_2\big(V_g^{(t)}(\rho)-b\big)\Big),\qquad \Lambda=\Big[0,\tfrac{2}{(1-\gamma)\xi}\Big].\end{aligned}$$

The symbol $\propto$ means "proportional to": in each state divide the right-hand side by $Z_t(s)=\sum_b\pi^{(t)}(b\mid s)\exp\big(\eta_1A_L^{(t)}(s,b)/(1-\gamma)\big)$ so that the probabilities sum to one. Equivalently (background box above, with step $\eta_1/(1-\gamma)$), $\pi^{(t+1)}(\cdot\mid s)$ maximises $\sum_ap_aA_L^{(t)}(s,a)-\frac{1-\gamma}{\eta_1}\mathrm{KL}\big(p\,\|\,\pi^{(t)}(\cdot\mid s)\big)$ over probability vectors $p$: follow the penalised advantage, but pay for moving away from the old action distribution.

(In our cost convention: $A_L=A_r-\lambda A_c$ and $\lambda\leftarrow\mathcal P_\Lambda(\lambda+\eta_2(J_c-d))$.) Started from the uniform policy $\theta^{(0)}=0$ with $\lambda^{(0)}=0$ (the initialisation used in the proof) and run with $\eta_1=2\log|\mathcal A|$ and $\eta_2=2(1-\gamma)/\sqrt T$, the iterates satisfy, on average over $t$ (journal version, Ding, Zhang, Duan, Başar, Jovanović, JMLR 26(256), 2025, Theorem 10; the NeurIPS paper's Theorem 1 has the same $O(1/\sqrt T)$ rates but states them with $\eta_2=(1-\gamma)/\sqrt T$ and the constants $4$ and $1/\xi+4\xi$ in place of $7$ and $2/\xi+4\xi$; we quote the journal version)

$$\frac1T\sum_{t\lt T}\big(V_r^\star(\rho)-V_r^{(t)}(\rho)\big)\le\frac{7}{(1-\gamma)^2\sqrt T},\qquad \Big[\frac1T\sum_{t\lt T}\big(b-V_g^{(t)}(\rho)\big)\Big]_+\le\frac{2/\xi+4\xi}{(1-\gamma)^2\sqrt T}.$$
Lemma — Performance difference (Kakade & Langford 2002; used by Ding et al. 2020)

In a finite MDP with $0\lt\gamma\lt1$, bounded reward and initial law $\mu$, let $\pi,\pi'$ be stationary stochastic policies. Define $V_r^\pi(s)=\mathbb E_s^\pi\sum_{t\ge0}\gamma^tr_t$, $Q_r^\pi(s,a)=r(s,a)+\gamma\sum_{s'}P(s'\mid s,a)V_r^\pi(s')$, $A_r^\pi=Q_r^\pi-V_r^\pi$, and $d_\mu^{\pi'}(s)=(1-\gamma)\sum_{t\ge0}\gamma^t\Pr_\mu^{\pi'}(s_t=s)$. Then

$$J_r(\pi')-J_r(\pi)=\frac{1}{1-\gamma}\mathbb E_{s\sim d_\mu^{\pi'},a\sim\pi'}A_r^\pi(s,a).$$

Intuition and proof: along a $\pi'$ trajectory, the conditional mean of $r_t+\gamma V_r^\pi(s_{t+1})-V_r^\pi(s_t)$ is $A_r^\pi(s_t,a_t)$. Multiplying by $\gamma^t$ and summing to $T$ cancels all intermediate values, leaving the reward sum minus $V_r^\pi(s_0)$ plus $\gamma^{T+1}V_r^\pi(s_{T+1})$. Boundedness makes the last term tend to zero. Take expectations over the $\pi'$ trajectory with $s_0\sim\mu$: the telescoped sum has expectation $J_r(\pi')-J_r(\pi)$, while the summands, by their conditional means, give $\mathbb E\sum_t\gamma^tA_r^\pi(s_t,a_t)=\frac1{1-\gamma}\mathbb E_{s\sim d_\mu^{\pi'},a\sim\pi'}A_r^\pi(s,a)$ by the definition of $d_\mu^{\pi'}$. Module 9 builds its trust-region bounds on this identity.

Kakade & Langford, ICML 2002; Ding et al., NeurIPS 2020

No factor $|\mathcal S|$ or $|\mathcal A|$ appears: $O(1/\varepsilon^2)$ iterations (big-O notation: Primer 0) for $\varepsilon$-optimality and $\varepsilon$-violation on average, whatever the size of the tables. The constants do depend on the start. The proof bounds the initial divergence (KL: Primer C) $\mathbb E_{s\sim d^{\pi^\star}_\rho}\mathrm{KL}\big(\pi^\star(\cdot\mid s)\,\|\,\pi^{(0)}(\cdot\mid s)\big)$ by $\log|\mathcal A|$, which holds only for the uniform $\pi^{(0)}$, and it telescopes the dual update from $\lambda^{(0)}=0$. From another start the paper still asserts convergence, but that divergence and $\lambda^{(0)}$ enter the bounds in place of the constants $7$ and $2/\xi+4\xi$. The divergence can be arbitrarily large when $\pi^{(0)}$ nearly excludes an optimal action. The proof combines the performance-difference lemma stated here (see Module 9 for further consequences) with the mirror-descent regret of the multiplicative-weights update and the multiplier bound of Section 3; the projection interval $\Lambda$ is twice the Slater bound on $\lambda^\star$. The result bounds averages over $t$ of the iterates' values, not the value of a policy obtained by averaging parameters or action probabilities; it is realised by drawing one iterate uniformly at random per episode, which is exactly the "averaging" cure of the primal-recovery problem.

Two readings. A bound $C/\sqrt T\le\varepsilon$ requires $T\ge(C/\varepsilon)^2$, which is where $O(1/\varepsilon^2)$ comes from; "dimension-free" refers to this iteration count with exact values and gradients, not to the cost of one iteration, which still grows with the numbers of states and actions. And the violation bound concerns $\big[\frac1T\sum_t\big(b-V_g^{(t)}(\rho)\big)\big]_+$, in which violations at some iterations cancel against slack at others: it is not the average violation $\frac1T\sum_t\big[b-V_g^{(t)}(\rho)\big]_+$ and bounds no single iterate.

Last-iterate convergence: regularise the saddle point

Average-iterate guarantees do not say that the current policy is safe: the iterates can circle the saddle forever (the walkthrough shows a period-two cycle). Ding, Wei, Zhang, Ribeiro, NeurIPS 2023 obtain last-iterate convergence for single-time-scale methods by regularising both players. They write the utility as $u$ with threshold $b$ and absorb the threshold into $g:=u-(1-\gamma)b\in[-1,1]$, so their constraint reads $V_g^\pi(\rho)\ge0$: the $g$ below is NPG-PD's utility shifted by $(1-\gamma)b$. With $\psi_t(s,a)=-\log\pi_t(a\mid s)$, the probability simplex $\Delta(\mathcal A)=\{p:p_a\ge0,\ \sum_ap_a=1\}$ of action distributions (Primer B) and its restricted version $\hat\Delta(\mathcal A)=\{\pi(\cdot\mid s)\in\Delta(\mathcal A):\ \pi(a\mid s)\ge\epsilon_0/|\mathcal A|\ \text{for all } a\}$, $\epsilon_0\in(0,1)$,

$$\begin{aligned}L_\tau(\pi,\lambda)&:=V^\pi_{r+\lambda g}(\rho)+\tau\Big(\mathcal H(\pi)+\tfrac12\lambda^2\Big),\\ \pi_{t+1}(\cdot\mid s)&=\operatorname*{arg\,max}_{\pi(\cdot\mid s)\in\hat\Delta(\mathcal A)}\sum_a\pi(a\mid s)Q^{\pi_t}_{r+\lambda_tg+\tau\psi_t}(s,a)-\tfrac1\eta\mathrm{KL}\big(\pi(\cdot\mid s),\pi_t(\cdot\mid s)\big),\\ \lambda_{t+1}&=\operatorname*{arg\,min}_{\lambda\in\Lambda}\lambda\big(V_g^{\pi_t}(\rho)+\tau\lambda_t\big)+\tfrac{1}{2\eta}(\lambda-\lambda_t)^2 .\end{aligned}$$

Here $\mathcal H(\pi)=\mathbb E_\rho^\pi\sum_{k\ge0}\gamma^k\big[-\log\pi(a_k\mid s_k)\big]$ is the discounted entropy of the policy, large when action probabilities are spread out. The shift is harmless: $\sum_{k\ge0}\gamma^k(1-\gamma)b=b$, so $V_g^\pi(\rho)=V_u^\pi(\rho)-b$ and $V_g^\pi(\rho)\ge0$ is exactly $V_u^\pi(\rho)\ge b$. The term $+\tfrac\tau2\lambda^2$ penalises the minimising multiplier player for large multipliers. The policy line is the KL-proximal (multiplicative-weights) step of the background box, restricted to $\hat\Delta(\mathcal A)$; the multiplier line is a projected gradient step, $\lambda_{t+1}=\mathcal P_\Lambda\big(\lambda_t-\eta(V_g^{\pi_t}(\rho)+\tau\lambda_t)\big)$, since $\partial_\lambda L_\tau=V_g^\pi(\rho)+\tau\lambda$.

Theorem — RPG-PD converges linearly to a neighbourhood of the regularised saddle point, and its last iterate is nearly optimal (Ding et al. 2023, Thm 2 and Cor. 3)
Assumptions. Finite state and action sets with tabular policies (one action distribution per state), $r\in[0,1]$, the shifted utility $g\in[-1,1]$ and one constraint $V_g^\pi(\rho)\ge0$ with a strictly feasible policy, $V_g^{\bar\pi}(\rho)\ge\xi\gt0$ (their Assumption 1); exact values $Q$ and $V$; $\tau\gt0$, $\epsilon_0\in(0,1)$, $\Lambda=[0,1/((1-\gamma)\xi)]$, an initial point $(\pi_1,\lambda_1)\in\hat\Delta(\mathcal A)\times\Lambda$, the two updates above, and a stepsize $0\lt\eta\le1/C_{\tau,\xi,\epsilon_0}$, where $$C_{\tau,\xi,\epsilon_0}=\frac{1+\frac{1}{(1-\gamma)\xi}+\tau\log|\mathcal A|}{1-\gamma}-\tau\log\frac{\epsilon_0}{|\mathcal A|},\qquad C'_{\tau,\xi}=\frac{1+\tau/\xi}{1-\gamma}.$$ The proof also needs the regularised saddle point inside $\hat\Delta(\mathcal A)$ (see the caveat below).
Statement. Let $\mathrm{KL}_t(\rho)=\frac{1}{1-\gamma}\sum_sd_\rho^{\pi^\star_\tau}(s)\,\mathrm{KL}\big(\pi^\star_\tau(\cdot\mid s)\,\|\,\pi_t(\cdot\mid s)\big)$, the per-state divergences weighted by the normalised visitation distribution of the saddle policy: nonnegative, but not symmetric, and blind to states that $\pi^\star_\tau$ never visits. With $\Phi_t=\mathrm{KL}_t(\rho)+\tfrac12(\lambda_\tau^\star-\lambda_t)^2$ measuring the distance to the unique regularised saddle point $(\pi^\star_\tau,\lambda^\star_\tau)$, $$\Phi_{t+1}\le e^{-\eta\tau t}\,\Phi_1+\frac{\eta}{\tau}\max\big(C_{\tau,\xi,\epsilon_0}^2,(C'_{\tau,\xi})^2\big).$$ The first term decays linearly at rate $\eta\tau$; the second does not decay: the iterates reach a neighbourhood of $(\pi^\star_\tau,\lambda^\star_\tau)$ whose size scales with $\eta/\tau+\eta\tau(1+\log^2\epsilon_0)$ (the paper's remark after Thm 2), and only a small step makes it small. Choosing $\eta=\Theta(\varepsilon^4)$, $\tau=\Theta(\varepsilon^2)$, $\epsilon_0=\varepsilon$, the last policy iterate is $\varepsilon$-optimal and $\varepsilon$-feasible for the original CMDP after $\Omega\big(\varepsilon^{-6}\log^2(1/\varepsilon)\big)$ iterations (Cor. 3; here $\Omega(\cdot)$ means: at every $t$ beyond a problem-dependent constant times $\varepsilon^{-6}\log^2(1/\varepsilon)$. It is a sufficient budget, not a lower bound).
In words. The entropy and quadratic terms "convexify" the game (the paper's word; the value function itself stays non-concave in $\pi$), so the regularised problem has a unique saddle point (their App. C.1), and the KL-mirror-descent/gradient play contracts towards it at rate $\eta\tau$ up to the $O(\eta/\tau)$ residual. The regularised saddle point is within $O(\tau)$ of an optimal constrained policy (a sandwich property, Eq. (5) of the paper), but the last iterate is close to it only in KL, which Pinsker's inequality turns into a $\sqrt{\Phi_t}$ error in value; the corollary's choice $\tau=\Theta(\varepsilon^2)$, $\eta=\Theta(\varepsilon^4)$ makes both errors $O(\varepsilon)$ and costs the $\varepsilon^{-6}$. The companion method OPG-PD (optimistic gradients, no regularisation) converges linearly in the last iterate to the optimal sets under an extra assumption that the optimal state-visitation distribution is unique.
Theorem — Linear last-iterate convergence of OPG-PD (Ding et al. 2023, Thm 6)

Use the same finite, discounted, one-constraint model with $r\in[0,1]$, $g\in[-1,1]$, Slater margin $\xi\gt0$, and $\Lambda=[0,1/((1-\gamma)\xi)]$. Assume exact values, full support of the initial distribution, $\rho_{\min}=\min_s\rho(s)\gt0$, and that all optimal policies have the same normalised state occupancy $d^\star$. Let $\Pi^\star$ and $\Lambda^\star$ be the sets of optimal policies and optimal multipliers. Put $Q_t=Q_{r+\lambda_tg}^{\pi_t}$ and $G_t=V_g^{\pi_t}(\rho)$. With Euclidean projections, OPG-PD uses the following two stages (policy projections are performed separately in each state):

$$\begin{aligned}\pi_t&=\mathcal P_\Delta(\hat\pi_t+\eta Q_{t-1}),&\lambda_t&=\mathcal P_\Lambda(\hat\lambda_t-\eta G_{t-1}),\\ \hat\pi_{t+1}&=\mathcal P_\Delta(\hat\pi_t+\eta Q_t),&\hat\lambda_{t+1}&=\mathcal P_\Lambda(\hat\lambda_t-\eta G_t).\end{aligned}$$

Start with equal predicted and base iterates in the policy simplex and $\Lambda$. Define the distribution-mismatch coefficient $\kappa_\rho=\sup_\pi\max_s d_\rho^\pi(s)/\rho(s)$. If $0\lt\eta\le\min\{1/(4\sqrt\iota),(1-\gamma)^3/(4|\mathcal A|),(1-\gamma)^3/(2\kappa_\rho)\}$, where $\iota$ is an explicit polynomial in $\kappa_\rho$, $\sqrt{|\mathcal A|}$, $1/(1-\gamma)$ and $1/\xi$ (their Eq. (28)), there exist finite $C_0$ and $q\in(0,1)$, depending on the model and initial point, such that the squared distance of $(\hat\pi_t,\hat\lambda_t)$ to $\Pi^\star\times\Lambda^\star$ is at most $C_0q^t$. Here policy distance uses weights $d^\star(s)/(2(1-\gamma))$ and dual distance weight $1/2$; distance to a set means the infimum of those weighted squared distances over its elements.

Intuition: the old gradient predicts an intermediate point; its freshly evaluated gradient corrects the move from the same base. Full initial support prevents invisible states, and the common optimal occupancy lets the proof use one set of weights. This is a theorem for these updates, not for arbitrary extrapolation rules.

Ding et al., NeurIPS 2023, Thm 6

Caveat — the saddle point must lie in the restricted simplex
The paper defines $(\pi^\star_\tau,\lambda^\star_\tau)$ as the saddle point of $L_\tau$ over all policies (its Eq. (4)), but the iterates never leave $\hat\Delta(\mathcal A)$, and the proof of Theorem 2 applies the mirror-descent inequality (its Lemma 27) with comparator $\pi^\star_\tau(\cdot\mid s)$, which that lemma requires to lie in $\hat\Delta(\mathcal A)$. Nothing guarantees this. Take one state, two actions with rewards $1$ and $0$, an inactive constraint and $\tau=0.1$: the regularised optimum gives the worse action probability $1/(1+e^{10})\approx4.5\cdot10^{-5}$, while with $\epsilon_0=0.2$ every iterate gives it at least $0.1$. So $\mathrm{KL}_t(s)$ stays above $0.1$ for every $t$, whereas the residual $\frac\eta\tau\max(\cdot)$ of the bound vanishes as $\eta\to0$. Read the theorem either with $\pi^\star_\tau\in\hat\Delta(\mathcal A)$ as an extra assumption, or with $(\pi^\star_\tau,\lambda^\star_\tau)$ redefined as the saddle point of $L_\tau$ over $\hat\Delta(\mathcal A)\times\Lambda$; the restricted problem then needs its own saddle point and its own Slater margin. Mixing any policy with the uniform one, with weight $\epsilon_0$, lands in $\hat\Delta(\mathcal A)$ and moves every value by $O(\epsilon_0/(1-\gamma)^2)$. Applied to the Slater policy, this leaves a margin of at least $\xi-O(\epsilon_0/(1-\gamma)^2)$, positive for small $\epsilon_0$, and the constants must then use this smaller margin; applied to an optimal policy, it bounds the bias of the restriction relative to the original CMDP, which the corollary's choice $\epsilon_0=\varepsilon$ keeps at $O(\varepsilon)$, the order of its other error terms.

Montenegro, Mussi, Papini, Metelli, NeurIPS 2024 (C-PG) extend the regularised idea to general parametrisations, including action-based exploration (a stochastic policy randomises each action, as so far) and parameter-based exploration (a deterministic policy whose parameters are drawn at random once per episode), in the cost-minimisation convention $\min_\upsilon J_0(\upsilon)$ s.t. $J_i(\upsilon)\le b_i$. Only the dual is regularised, by a ridge term:

$$\begin{aligned}L_\omega(\upsilon,\lambda)&=J_0(\upsilon)+\langle\lambda,J(\upsilon)-b\rangle-\frac\omega2\|\lambda\|_2^2,\qquad \lambda^\star(\upsilon)=\frac1\omega\big(J(\upsilon)-b\big)_+,\\ H_\omega(\upsilon)&:=\max_{\lambda\ge0}L_\omega(\upsilon,\lambda)=J_0(\upsilon)+\frac{1}{2\omega}\big\|(J(\upsilon)-b)_+\big\|_2^2 .\end{aligned}$$

Where the closed form comes from: with $\Delta_i=J_i(\upsilon)-b_i$ the maximisation over $\lambda\ge0$ splits into scalar problems $\max_{\lambda_i\ge0}\{\lambda_i\Delta_i-\tfrac\omega2\lambda_i^2\}$, concave parabolas with vertex at $\lambda_i=\Delta_i/\omega$. If $\Delta_i\gt0$ the vertex is feasible and the value is $\Delta_i^2/(2\omega)$; if $\Delta_i\le0$ the best feasible point is $\lambda_i=0$ with value $0$. So $\lambda_i^\star=(\Delta_i)_+/\omega$ and the maximum is $(\Delta_i)_+^2/(2\omega)$; summing over $i$ gives $H_\omega$.

Definition — Weak $\psi$-gradient domination (Montenegro et al. 2024, Assumption 3.2)

Fix a parameter domain $\mathcal V$ and a multiplier domain $\Lambda$. Assume $L_0(\cdot,\lambda)$ is differentiable and bounded below for every $\lambda\in\Lambda$, and there are constants $\psi\in[1,2]$, $\alpha_1\gt0$, $\beta_1\ge0$ such that, for every $(\upsilon,\lambda)$ in these domains,

$$\|\nabla_\upsilon L_0(\upsilon,\lambda)\|_2^\psi\ge\alpha_1\big[L_0(\upsilon,\lambda)-\inf_{v\in\mathcal V}L_0(v,\lambda)\big]-\beta_1.$$

Then a point with gradient norm at most $e$ has fixed-multiplier suboptimality at most $(e^\psi+\beta_1)/\alpha_1$. This follows by rearranging the inequality. The case $\psi=2$, $\beta_1=0$ is the Polyak–Łojasiewicz condition. Intuition: a nearly flat landscape must already have nearly optimal value. Smoothness only limits how quickly a gradient changes; it does not rule out a bad flat point. For example $f(x)=x^2$ has $|f'(x)|^2=4f(x)$, so it satisfies PL with $\alpha_1=4$.

Theorem — Convergence of the C-PG potential (Montenegro et al. 2024, Thm 3.2)

Assume $\mathcal V$ is the policy-parameter domain with well-defined Euclidean projection; the objective and constraints are differentiable, bounded expected costs, $0\le J_i,b_i\le J_{\max}$; and an unregularised saddle $(\upsilon_0^\star,\lambda_0^\star)$ exists. Set $\omega\gt0$, $\Lambda=\{\lambda\ge0:\|\lambda\|_2\le\sqrt m J_{\max}/\omega\}$, so the proportional best response lies in $\Lambda$ (and, for $\omega$ small enough, so does the unregularised multiplier $\lambda_0^\star$, which the bias lemmas behind Theorem 3.1 compare against). Require the preceding weak-domination inequality uniformly on $\mathcal V\times\Lambda$. Require finite constants $L_1,L_2,L_3$ bounding, respectively, the Lipschitz changes of $J(\upsilon)$, of $\nabla_\upsilon L_0$ in $\upsilon$, and of $\nabla_\upsilon L_0$ in $\lambda$. Gradient estimates must be conditionally unbiased for the regularised gradients, with conditional mean-square errors bounded by $V_\upsilon,V_\lambda$. For the stated dependence on $\omega$, take $L_2=O(\omega^{-1})$, $L_1,L_3=O(1)$, $V_\upsilon=O(\omega^{-2})$, $V_\lambda=O(1)$.

$$\begin{aligned}\upsilon_{k+1}&=\mathcal P_{\mathcal V}(\upsilon_k-\zeta_\upsilon\widehat\nabla_\upsilon L_\omega(\upsilon_k,\lambda_k)),\\ \lambda_{k+1}&=\mathcal P_\Lambda(\lambda_k+\zeta_\lambda\widehat\nabla_\lambda L_\omega(\upsilon_{k+1},\lambda_k)),\\ a_k&=\mathbb E[H_\omega(\upsilon_k)-\inf_vH_\omega(v)],\\ b_k&=\mathbb E[H_\omega(\upsilon_k)-L_\omega(\upsilon_k,\lambda_k)],\qquad\mathcal P_k=a_k+\chi b_k.\end{aligned}$$

For a suitable fixed $\chi\in(0,1/5)$ and sufficiently small target $\varepsilon$ and $\omega$, there are constant learning rates giving $\mathcal P_K\le\varepsilon+\beta_1/\alpha_1$ with the rates stated in the following paragraph. The exact-gradient choices have $\zeta_\lambda=1/\omega$, $\zeta_\upsilon=O(\omega)$; the estimated-gradient choices have $\zeta_\lambda=O(\omega\varepsilon^{2/\psi})$, $\zeta_\upsilon=O(\omega^3\varepsilon^{2/\psi})$, with sufficiently small theorem-dependent constants (the proof gives them explicitly; they are not free prefactors).

Intuition: $a_k$ measures the gap of the penalised policy and $b_k$ measures the multiplier's failure to attain its best response. Both are nonnegative, so controlling their weighted sum controls both players. Domination removes bad stationary values, regularity controls each step, and the variance bounds control sampling error. The floor $\beta_1/\alpha_1$ remains even with arbitrarily many iterations.

Montenegro et al., NeurIPS 2024, Thms 3.1–3.2

The closed form is worth a second look: maximising over the regularised multiplier turns the Lagrangian into a quadratic penalty on the violation, and the multiplier that goes with it is proportional to the violation rather than an integral of it. Their Theorem 3.1 quantifies the bias of the ridge: if the potential $\mathcal P_k$ that drives the analysis is below $\varepsilon$, then $\mathbb E[J_0(\upsilon_k)-J_0(\upsilon_0^\star)]\le\varepsilon+\frac\omega2\|\lambda_0^\star\|_2^2$ and $\mathbb E[(J_i(\upsilon_k)-b_i)_+]\le4\varepsilon+\omega\|\lambda^\star_0\|_2$, where $\lambda_0^\star$ is the unregularised multiplier; Theorem 3.2 gives last-iterate iteration complexities for driving the potential down to $\mathcal P_K\le\varepsilon+\beta_1/\alpha_1$: $O(\omega^{-1}\log\varepsilon^{-1})$ (exact gradients, Polyak–Łojasiewicz-type domination $\psi=2$), $O(\omega^{-1}\varepsilon^{-(2/\psi-1)})$ (exact gradients, $\psi\in[1,2)$), and $O(\omega^{-3}\varepsilon^{-4/\psi+1})$ with estimated gradients, under weak $\psi$-gradient domination of the Lagrangian, smoothness and bounded gradient variance (smoothness and stochastic gradients: Primer B; the existence of a saddle point enters Theorem 3.1). Here $\alpha_1\gt0$, $\beta_1\ge0$ are the constants of the weak gradient-domination assumption: $\beta_1=0$ for tabular softmax ($\psi=1$) or direct ($\psi=2$) parametrisations, while for general parametrisations $\beta_1$ carries a compatible-function-approximation bias, and the floor $\beta_1/\alpha_1$ does not shrink with more iterations; Theorem 3.1 then applies with $\varepsilon+\beta_1/\alpha_1$ in place of $\varepsilon$. When $\beta_1=0$, setting $\omega=O(\varepsilon)$ balances bias and rate. Alternatively one tightens the budget to $b_i'=b_i-\delta$ (the paper's route to "zero constraint violation"), which needs the tightened problem to remain feasible and $\delta\ge4\varepsilon+\omega\|\lambda^\star_0\|$ with $\lambda^\star_0$ now the multiplier of the tightened problem. Because $\mathbb E[J_i-b_i']\le\mathbb E[(J_i-b_i')_+]\le\delta$, what this buys is $\mathbb E[J_i(\upsilon_k)]\le b_i$: feasibility in expectation over the algorithm's randomness. With exact gradients the iterate is deterministic and is itself feasible. With estimated gradients individual runs can still violate $b_i$: $J_i-b_i'\in\{0,2\delta\}$ with equal probability satisfies the bound and violates $b_i$ half the time.

Off-policy: conservative cost critics

Off-policy actor-critics (SAC-Lagrangian; off-policy learning from a replay buffer: Primer E) estimate $J_c$ from a replay buffer through a learned $Q_c$, and a cost critic that underestimates makes $\lambda$ collapse to zero while the true cost exceeds the budget. Wu et al., ICLR 2024 (CAL) replace $Q_c$ by an upper confidence bound over an ensemble of $E$ cost critics, $\hat Q_c^{\rm UCB}=\frac1E\sum_i\hat Q_c^i+k\cdot\mathrm{Std}_i(\hat Q_c^i)$, so that the constraint seen by the dual update is pessimistic, and they rectify the actor gradient with an augmented-Lagrangian term (a Lagrangian plus a quadratic penalty on the violation; penalties: Primer B): the multiplier that multiplies $\nabla_a\hat Q_c^{\rm UCB}$ in the actor update is $\tilde\lambda=\max\{0,\lambda-c_{\rm pen}\,(d-\mathbb E[\hat Q_c^{\rm UCB}])\}$, a proportional correction of the same kind as C-PG's closed form, which convexifies the objective near the constraint boundary (their Proposition 1 is a Platt–Barr energy argument in continuous time; see Section 5). The benefit is empirical: on Safety Gym and velocity-constrained MuJoCo tasks CAL reaches the asymptotic performance of state-of-the-art on-policy methods with far fewer samples while markedly reducing constraint violations during training (plus a real-world auto-bidding study).

Here $E$ is the number of critics, $k\gt0$ a chosen uncertainty weight and $\mathrm{Std}_i$ the standard deviation of their $E$ predictions, a measure of disagreement. Without a calibration theorem, “mean plus $k$ standard deviations” is a conservative heuristic, not a $1-\delta$ confidence bound of the kind proved in Module 3. In $\tilde\lambda$, $c_{\rm pen}\gt0$ is CAL's penalty coefficient (their $c$), not a cost function.

What is proved

MethodPolicy class, loopsGuaranteeAssumptions that carry the proof
Dual descent (Paternain et al. 2019, Thm 3)$\epsilon$-universal $\pi_\theta$; inner RL loop to $\delta$-accuracy, outer dual step$K\le\|\lambda_0-\lambda_\theta^\star\|^2/(2\eta\varepsilon)$ dual steps to a $[\,-O(\epsilon/(1-\gamma)^2),\ \eta B/2+\delta+\varepsilon\,]$ neighbourhood of $P^\star$ (unnormalised returns; the paper prints $\epsilon/(1-\gamma)$)bounded rewards, Slater for the parametrised problem, inner maximiser within $\delta$ of the global one
RCPO (Tessler et al. 2019, Thm 2)parametrised actor-critic; three timescalesa.s. convergence to a feasible fixed point (local)Robbins–Monro steps with $\eta_1/\eta_2\to0$; local minima of the discounted penalty are feasible; uncapped multiplier ($\lambda_{\max}=\infty$)
NPG-PD (Ding et al. 2020; JMLR Thm 10)tabular softmax; single loopaverage-iterate gap $\le7/((1-\gamma)^2\sqrt T)$, violation $\le(2/\xi+4\xi)/((1-\gamma)^2\sqrt T)$Slater margin $\xi$, exact gradients, rewards in $[0,1]$, uniform $\pi^{(0)}$ and $\lambda^{(0)}=0$ (for these constants); extensions with function-approximation error terms
RPG-PD (Ding et al. 2023, Thm 2, Cor. 3)tabular softmax; single time scale, entropy + quadratic dual regularisationlinear rate to an $O(\eta/\tau)$ neighbourhood, provided the regularised saddle lies in $\hat\Delta(\mathcal A)$ (see the caveat); last iterate $\varepsilon$-optimal and $\varepsilon$-feasible after $\Omega(\varepsilon^{-6}\log^2\varepsilon^{-1})$feasibility with margin, $\eta\le1/C_{\tau,\xi,\epsilon_0}$, $\tau=\Theta(\varepsilon^2)$, $\epsilon_0=\varepsilon$ (restriction bias $O(\epsilon_0/(1-\gamma)^2)$)
OPG-PD (Ding et al. 2023, Thm 6)tabular; optimistic gradientslinear last-iterate convergence to $\Pi^\star\times\Lambda^\star$, problem-dependent rateunique optimal state-visitation distribution, $\rho_{\min}\gt0$
C-PG (Montenegro et al. 2024, Thms 3.1–3.2)general parametrisations, action- or parameter-based; ridge on the duallast iterate: gap $\le\varepsilon+\frac\omega2\|\lambda_0^\star\|^2$, violation $\le4\varepsilon+\omega\|\lambda_0^\star\|$ once $\mathcal P_K\le\varepsilon$; $O(\omega^{-1}\log\varepsilon^{-1})$ to $O(\omega^{-3}\varepsilon^{-4/\psi+1})$ iterations reach $\mathcal P_K\le\varepsilon+\beta_1/\alpha_1$saddle point exists, weak $\psi$-gradient domination (error floor $\beta_1/\alpha_1$), smoothness, bounded variance
A-CRL (Calvo-Fullana et al. 2024, Thm 1)average reward; policy conditioned on $\lambda$; dual dynamics at executiontrajectories feasible a.s.; average reward $\ge P^\star-\eta_\lambda B^2/2$strictly feasible policy, $\|r(s,a)-c\|_2\le B$ (see Section 7), unbiased epoch estimates
CAL (Wu et al. 2024)off-policy SAC; UCB cost ensemble + augmented Lagrangianenergy decreases near a local optimum (continuous-time Prop. 1); otherwise empiricallarge penalty $c$; heuristic outside the neighbourhood
Pitfall — Theory versus benchmark
None of the rates above says anything about constraint satisfaction during training, which is what safe exploration needs. The Safety Gym report (Ray, Achiam, Amodei 2019) introduced the training cost rate $\rho_c$ (all costs incurred during training divided by the number of environment steps) as the regret-like metric for this. With $T_{\rm ep}=1000$ and $d=25$, $\rho_c\le d/T_{\rm ep}=0.025$ says that the average training episode met the budget, the report's "approximate constraint satisfaction throughout training"; individual episodes and intermediate policies may still violate it, and the report itself notes that oscillating costs can have the same $\rho_c$ as steady ones. Its Table 1 (18 environments, $d=25$, three seeds; return / violation / cost rate normalised by unconstrained PPO) reads PPO-Lagrangian $0.24/0.026/0.245$, TRPO-Lagrangian $0.331/0.018/0.265$, CPO $0.784/0.593/0.646$: the plain Lagrangian methods, with no convergence theory of their own, satisfied the constraints far more reliably than CPO, whose per-iteration guarantee (Module 9) is undone by approximation errors; the report says this "contradicts the result from Achiam et al. [2017]" (its CPO also omits the learned failure predictor that the original paper used for cost shaping). Lagrangian methods pay with return and with oscillations, which is the subject of Section 5 and of Module 9's benchmark section.

5. The Multiplier as a Controller: PID Lagrangians

Look again at the dual step $\lambda_{k+1}=(\lambda_k+K_I(J_{C,k}-d))_+$. The multiplier is a running sum of the constraint violation: it is an integral controller (PID control: Primer D) acting on the error $e_k=J_{C,k}-d$, with the RL algorithm as the plant. Stooke, Achiam, Abbeel, ICML 2020 make this reading explicit and draw the obvious conclusion: integral-only controllers overshoot and oscillate, and the standard remedy is to add proportional and derivative action.

Key equation — Constrained RL as a feedback loop (Stooke et al. 2020, Eqs. 18–22)
$$\theta_{k+1}=F(\theta_k,\lambda_k),\qquad y_k=J_C(\pi_{\theta_k}),\qquad \lambda_k=h(y_0,\dots,y_k,d),$$ where $F$ is the (unknown, nonlinear) policy update and $h$ the multiplier rule. For a first-order Lagrangian step the plant is control-affine, i.e. affine in the input $\lambda$ (Primer D), $F(\theta,\lambda)=f(\theta)+g(\theta)\lambda$ with $f(\theta)=\theta+\eta\nabla_\theta J$ and $g(\theta)=-\eta\nabla_\theta J_C$. The Lagrangian rule $h$: $\lambda_{k+1}=(\lambda_k+K_I(J_C-d))_+$ is integral control with gain $K_I$.

Timing convention. For the matrix below and the explorer the order is: measure $e_k$, update $I_k=I_{k-1}+e_k$, form $\lambda_k=K_Pe_k+K_II_k$, then update the policy to obtain $e_{k+1}$. With integral action alone, $\lambda_k=\lambda_{k-1}+K_Ie_k$. This is the same indexing convention used by the simulation. Updating the policy with the old multiplier instead produces a different state matrix.

Derivation — Why the integral-only loop oscillates, and what P and D do

(a) Continuous time, Stooke et al.'s argument (after Platt & Barr). For $\min f(x)$ s.t. $g(x)=0$ the basic differential multiplier method is $\dot x=-\nabla f-\lambda\nabla g$, $\dot\lambda=\alpha g(x)$. Differentiating the first equation (chain rule and Hessians: Primer B) and substituting the second gives a forced oscillator $$\ddot x+A\dot x+\alpha\,g(x)\nabla g=0,\qquad A=\nabla^2f+\lambda\nabla^2g:$$ the only damping is the curvature of the Lagrangian; the multiplier update contributes no damping of its own (Platt and Barr: a positive-definite $A$ dissipates energy; the theorem below makes this precise for a linear constraint). Adding a proportional term, $\dot\lambda=\alpha g+\beta\dot g$ (here $\alpha,\beta$ and, below, $\gamma$ are the paper's gains, not a CVaR level, a budget or the discount), changes the damping matrix to $A+\beta\nabla g\nabla g^\top$: a positive semidefinite increase ($v^\top\nabla g\nabla g^\top v=(\nabla g^\top v)^2\ge0$; Primer A), which can damp oscillations but need not shorten settling time. A derivative term $\dot\lambda=\alpha g+\gamma\ddot g$ multiplies the dynamics by $B^{-1}$ with $B=I+\gamma\nabla g\nabla g^\top$, weakening both damping and forcing and adding a curvature-dependent drag: it acts predictively but "may be prone to instability".

Differentiate term by term: $\ddot x=-\nabla^2f\,\dot x-\dot\lambda\nabla g-\lambda\nabla^2g\,\dot x$. Substituting $\dot\lambda=\alpha g$ gives the displayed equation. With proportional action, $\dot g=\nabla g^\top\dot x$, so the extra term is $-\beta\nabla g\nabla g^\top\dot x$. Its quadratic form is $\beta(\nabla g^\top v)^2\ge0$, explaining the added damping term.

Theorem — The multiplier dynamics converge for a linear constraint (energy argument after Platt & Barr)

Let $f:\mathbb R^n\to\mathbb R$ be twice continuously differentiable with $\nabla^2f(x)\succeq\ell I$, $\ell\gt0$, for every $x$. Let $g(x)=b^\top x-d$ with $b\ne0$, and let $\alpha\gt0$. For the equality-constrained dynamics $\dot x=-\nabla f(x)-\lambda b$, $\dot\lambda=\alpha(b^\top x-d)$, with an unrestricted real multiplier, every solution converges to the unique constrained minimiser and its unique multiplier $(x^\star,\lambda^\star)$.

Intuition and proof: strong convexity makes the affine constrained optimum exist and be unique, with $\nabla f(x^\star)+\lambda^\star b=0$. The nonnegative energy $E=\|x-x^\star\|^2/2+(\lambda-\lambda^\star)^2/(2\alpha)$ has derivative $\dot E=-(x-x^\star)^\top (\nabla f(x)-\nabla f(x^\star))\le-\ell\|x-x^\star\|^2$ (use $\nabla f(x^\star)=-\lambda^\star b$, $b^\top x^\star=d$, and the mean value theorem). Its bounded level sets bound the whole trajectory. The only trajectory that can stay in $\dot E=0$ is the equilibrium, because $b\ne0$. LaSalle's invariance principle (a bounded trajectory approaches the largest invariant set inside $\{\dot E=0\}$) therefore gives convergence. This special case shows the energy reasoning; a nonlinear inequality constraint, a projected multiplier or a nonconvex neural objective needs its own hypotheses.

Stooke et al., ICML 2020, multiplier dynamics

Since $\ddot g=\nabla g^\top\ddot x+\dot x^\top\nabla^2g\dot x$, substituting $\dot\lambda=\alpha g+\gamma\ddot g$ yields $(I+\gamma\nabla g\nabla g^\top )\ddot x+A\dot x+\alpha g\nabla g+\gamma(\dot x^\top\nabla^2g\dot x)\nabla g=0$. The final term depends on the curvature of $g$ and need not have a damping sign. This is why derivative action has no unconditional stability guarantee.

Background — Complex eigenvalues, polar form and oscillation periods

Complex numbers add a unit $i$ with $i^2=-1$. For $z=x+iy$ the conjugate is $\bar z=x-iy$ and the modulus $|z|=\sqrt{x^2+y^2}$, so $z\bar z=|z|^2$. The non-real eigenvalues of a real matrix come in conjugate pairs $z,\bar z$. Euler's formula $e^{i\vartheta}=\cos\vartheta+i\sin\vartheta$ writes any nonzero $z$ in polar form $z=re^{i\vartheta}$ with $r=|z|$, so a pair is $re^{\pm i\vartheta}$. In $x_{k+1}=Mx_k$ each such mode is multiplied by $r$ and rotated by the angle $\vartheta$ at every step: the modulus controls growth or decay, the angle the oscillation, with nominal period $2\pi/\vartheta$ iterations (exact repetition only when $\vartheta/2\pi$ is rational). For $r\lt1$ the envelope halves after $n$ steps with $r^n=\tfrac12$, i.e. $n=\log2/\log(1/r)$. Example: $z=0.8i=0.8e^{i\pi/2}$ turns a quarter-turn and shrinks by $0.8$ per step, so its period is $4$ and its envelope halves every $\log2/\log1.25\approx3.1$ steps.

(b) A discrete linear model of the loop (ours). Near the active constraint linearise (linear discrete-time systems and their modes: Primer D): along the direction of $\nabla J_C$ let $J_C(\theta)\approx d+b\,(\theta-\bar\theta)$ with constant $\nabla_\theta J=g_r$ and $\nabla_\theta J_C=b$. The policy step $\theta_{k+1}=\theta_k+\eta(g_r-\lambda_kb)$ is stationary at $\lambda^\star=g_r/b$, and the error $e_k=J_{C,k}-d$ obeys $$e_{k+1}=e_k-c\,(\lambda_k-\lambda^\star),\qquad c:=\eta b^2 .$$ With Algorithm 3 below (no derivative term, projections inactive) the multiplier is $\lambda_k=K_Pe_k+K_II_k$, $I_k=I_{k-1}+e_k$. Writing $\delta_k=I_k-\lambda^\star/K_I$ the state $x_k=(e_k,\delta_{k-1})$ evolves linearly, $x_{k+1}=Mx_k$ with $$M=\begin{bmatrix}1-c(K_P+K_I)&-cK_I\\ 1&1\end{bmatrix},\qquad \operatorname{tr}M=2-c(K_P+K_I),\qquad \det M=1-cK_P .$$ For $K_P=0$ we get $\det M=1$: whenever the eigenvalues are complex ($0\lt cK_I\lt4$) they lie on the unit circle, $z=e^{\pm i\vartheta}$ with $\cos\vartheta=1-cK_I/2$. The violation and the multiplier oscillate without decay with nominal period $2\pi/\vartheta\approx2\pi/\sqrt{cK_I}$; larger $K_I$ shortens the period but never damps, and $cK_I\ge4$ is not asymptotically stable (at equality the repeated root is $-1$). For $K_P\gt0$, as long as the eigenvalues stay complex, i.e. $(\operatorname{tr}M)^2\lt4\det M$, their modulus is $\sqrt{\det M}=\sqrt{1-cK_P}\lt1$: the envelope decays geometrically. For larger gains they become real, possibly negative (a sign-alternating transient), and only the Jury conditions decide: stability holds iff $0\lt cK_P\lt2$, $cK_I\gt0$ and $c(2K_P+K_I)\lt4$ (Exercise 8.4). The derivative term feeds back the increment $e_k-e_{k-1}$ (one more state in the model) and, being projected to $(\cdot)_+$, only resists increases of the cost: it damps a rising cost, and hence overshoot of the limit from below, without impeding decreases.

For $z^2-tz+q$, both roots lie strictly inside the unit disk exactly when $1-q>0$, $1-t+q>0$, and $1+t+q>0$. Here $t=2-c(K_P+K_I)$ and $q=1-cK_P$, giving $cK_P>0$, $cK_I>0$, and $4-c(2K_P+K_I)>0$. These imply $cK_P\lt 2$. Equality describes a stability boundary, not asymptotic stability.

(c) Curvature. The model takes $\nabla_\theta J$ and $\nabla_\theta J_C$ constant. If they vary, linearising the policy step at the optimum adds the curvature of the Lagrangian $L=J-\lambda^\star J_C$ along the direction: $e_{k+1}=a\,e_k-c(\lambda_k-\lambda^\star)$ with $a=1+\eta\,\partial^2_\theta L$, so the $(1,1)$ entry of $M$ becomes $a-c(K_P+K_I)$, $\operatorname{tr}M=1+a-c(K_P+K_I)$ and $\det M=a-cK_P$. A Lagrangian that is concave along the direction ($a\lt1$) adds damping, the discrete counterpart of Platt and Barr's damping matrix $A$ in (a); a convex one ($a\gt1$) removes it. Then even the integral-only loop is unstable ($\det M=a\gt1$ for $K_P=0$, so $|z|=\sqrt a$ when the eigenvalues are complex), and proportional action must supply $cK_P\gt a-1$ before the envelope can decay. The explorer below is of this second kind.

Algorithm 3: PID-controlled Lagrange multiplier (Stooke et al. 2020, Alg. 2)
  1. Choose $K_P,K_I,K_D\ge0$; $I\leftarrow0$; $J_{C,\rm prev}\leftarrow0$.
  2. At each iteration $k$: receive the cost estimate $J_C$;
  3. $\Delta\leftarrow J_C-d$; $\ \partial\leftarrow(J_C-J_{C,\rm prev})_+$; $\ I\leftarrow(I+\Delta)_+$;
  4. $\lambda\leftarrow(K_P\Delta+K_II+K_D\partial)_+$; $\ J_{C,\rm prev}\leftarrow J_C$. // $K_P=K_D=0$ recovers the Lagrangian method

The policy is then updated with the Lagrangian gradient. Stooke et al. rescale it as $\nabla_\theta L=\frac{1}{1+\lambda}\big(\nabla_\theta\hat J-\lambda\nabla_\theta\hat J_C\big)$, a convex combination of the reward and cost gradients that keeps the step size bounded when $\lambda$ is large; since $\operatorname*{arg\,max}_\theta(J-\lambda J_C)=\operatorname*{arg\,max}_\theta\frac{1}{1+\lambda}(J-\lambda J_C)$, it does not change the fixed points. With $u=\lambda/(1+\lambda)\in[0,1]$ this reads $\nabla_\theta L=(1-u)\nabla_\theta J-u\nabla_\theta J_C$. Their constraint-controlled PPO (CPPO-PID) uses separate value and cost-value critics, because a rapidly moving $\lambda$ would make a single critic for $r-\lambda c$ chase a moving target.

Common mistake — reward-scale invariance is a different mechanism
The $\frac{1}{1+\lambda}$ rescaling is often credited with making the method invariant to the scale of the reward. It is not: scaling the rewards by a factor $\rho$ (the paper's symbol, unrelated to the occupancy measure $\rho_\pi$) scales $\lambda^\star$ by $\rho$ and, as the paper observes, changes the learning dynamics as if the controller gains had been divided by $\rho$. Invariance comes from Section 7 of the paper, which inserts a factor $\beta_k$ in front of the cost gradient, $$\nabla_\theta L=(1-u_k)\nabla_\theta J(\pi_{\theta_k})-u_k\,\beta_k\nabla_\theta J_C(\pi_{\theta_k}),\qquad \beta_{\nabla,k}=\frac{\|\nabla_\theta J(\pi_{\theta_k})\|}{\|\nabla_\theta J_C(\pi_{\theta_k})\|},$$ so that at $\lambda=1$ reward and cost contribute gradients of equal norm (the ratio needs $\nabla_\theta J_C\ne0$; flooring the denominator at a small constant keeps it defined, at the price of exact invariance near vanishing cost gradients) and $\lambda^\star\approx1$ becomes the natural scale; the paper reports nearly identical learning curves across two orders of magnitude of reward scale with $\beta_\nabla$, and visibly different ones with $\beta=1$.

Results. On Safety Gym tasks (cost limits from 25 to 200 depending on the experiment, e.g. 50 in DoggoGoal2 and 50–200 in DoggoButton1) the paper shows that with the integral-only rule the episodic cost oscillates around the limit with a period and amplitude that shrink as $K_I$ grows (a fast $K_I$ removes the oscillation but costs return), that proportional control damps these oscillations across a range of $K_I$ while keeping return high, and that derivative control reduces cost overshoot in the reported experiments and slows cost increases inside the feasible region, which the Lagrangian method cannot do. CPPO-PID is a standard baseline in SafePO/OmniSafe and its multiplier rule is reused inside SafeDreamer's planner (Module 9). The explorer below reproduces the phenomenon on a one-parameter policy: watch the plain multiplier ring and the PID multiplier settle. Its cost curve is concave, so the Lagrangian is slightly convex in the policy parameter (case $a\gt1$ of (c)): the integral-only loop is even weakly unstable, and its oscillation can grow until clipping changes the motion; a periodic limiting orbit is not implied by the local model.

Connection to Module 9 and Module 10
The same loop appears whenever a scalar "price" is set from a measured constraint: the ReLU penalty of P3O (a large fixed price $\kappa$, switched on by a measured violation and grown during training) and the implied multiplier $1/(t\,|\hat J_c-d|)$ of IPO's log barrier (Module 9), the augmented-Lagrangian rectification of CAL and the regularised dual of C-PG (Section 4), which we saw is literally a proportional law $\lambda=(J-b)_+/\omega$. A safety filter (Module 10) is the opposite design choice: it enforces the constraint at every step by a per-step optimisation rather than by a slowly adapted price.

6. Risk-Sensitive Constraints: CVaR and Beyond

An expected-cost budget allows rare catastrophes as long as the average is fine. Risk-constrained RL replaces the expectation of the cumulative cost $Z$ by a tail statistic. The two classical ones are the value-at-risk $\mathrm{VaR}_\alpha(Z)=\min\{z:F_Z(z)\ge\alpha\}$ (a chance constraint in disguise) and the conditional value-at-risk, which also counts how bad the tail is.

Definition — CVaR, Rockafellar–Uryasev form (as used by Chow et al. 2018, Eq. 1)
$$\mathrm{CVaR}_\alpha(Z)=\min_{\nu\in\mathbb R}\Big\{\nu+\frac{1}{1-\alpha}\,\mathbb E\big[(Z-\nu)_+\big]\Big\},\qquad \alpha\in(0,1),$$ one minimiser being $\nu^\star=\mathrm{VaR}_\alpha(Z)$. For an atomless integrable distribution $\mathrm{CVaR}_\alpha(Z)=\mathbb E[Z\mid Z\ge\mathrm{VaR}_\alpha(Z)]$: the mean of the worst $(1-\alpha)$ fraction of outcomes. $\alpha\to1$ is the extreme tail (risk-averse), $\alpha\to0$ recovers the mean. The formula is convex in $\nu$ and jointly convex in $(Z,\nu)$, which is what makes it tractable.
Caveat — two readings of $\alpha$ in the literature
Chow et al.'s prose says CVaR "is equal to the average of the worst-case $\alpha$-fraction of losses", but their formula, with the factor $1/(1-\alpha)$, averages the worst $(1-\alpha)$ fraction; the formula is the one their algorithms use. WCSAC flips the convention altogether: there $\alpha$ is the tail fraction, $\mathrm{CVaR}_\alpha=\mathbb E[C\mid C\ge F_C^{-1}(1-\alpha)]$, so $\alpha\to0$ is risk-averse and $\alpha=1$ is risk-neutral. Always check which fraction a paper's $\alpha$ denotes before comparing numbers.

Chow, Ghavamzadeh, Janson, Pavone, JMLR 2018 pose the CVaR-constrained MDP (cost minimisation: $\min_\theta V^\theta(x^0)$ s.t. $\mathrm{CVaR}_\alpha(\text{cumulative constraint cost})\le\beta$) and use the Rockafellar–Uryasev form to turn it into a joint problem in $(\theta,\nu)$ with an expectation constraint, since $\mathrm{CVaR}_\alpha\le\beta$ iff some $\nu$ has $H_\alpha(Z,\nu):=\nu+\frac{1}{1-\alpha}\mathbb E[(Z-\nu)_+]\le\beta$. The new constraint is convex in $\nu$ but not smooth (the kink of $(\cdot)_+$; for a cost with atoms $H_\alpha$ is piecewise linear in $\nu$), which is why the $\nu$-derivative below is a subgradient. The Lagrangian and its (sub)gradients (their Eqs. 5, 7–9) are

$$\begin{aligned}&\max_{\lambda\ge0}\min_{\theta,\nu}\ L(\nu,\theta,\lambda)=V^\theta(x^0)+\lambda\big(H_\alpha(Z^\theta,\nu)-\beta\big),\\ &\nabla_\theta L=\nabla_\theta V^\theta+\frac{\lambda}{1-\alpha}\nabla_\theta\mathbb E\big[(Z^\theta-\nu)_+\big],\\ &\partial_\nu L\ni\lambda\Big(1-\frac{\mathbb P(Z^\theta\ge\nu)}{1-\alpha}\Big),\qquad \nabla_\lambda L=H_\alpha(Z^\theta,\nu)-\beta .\end{aligned}$$

Why $\ge$ in $\partial_\nu L$: as a function of $\nu$, $(Z-\nu)_+$ has slope $-1$ where $Z>\nu$, slope $0$ where $Z\lt\nu$, and any slope in $[-1,0]$ at $Z=\nu$. Taking expectations, the left and right derivatives of $H_\alpha$ in $\nu$ are $1-\mathbb P(Z\ge\nu)/(1-\alpha)$ and $1-\mathbb P(Z>\nu)/(1-\alpha)$, and $\partial_\nu H_\alpha$ is the interval between them; the displayed element is the left end. They differ only if $Z$ has an atom at $\nu$. $H_\alpha$ is minimal where $0\in\partial_\nu H_\alpha$, i.e. $\mathbb P(Z>\nu)\le1-\alpha\le\mathbb P(Z\ge\nu)$: $\mathrm{VaR}_\alpha(Z)$ is one such $\nu$, not necessarily the only one.

Theorem — The CVaR policy-gradient algorithm converges to a locally optimal policy (Chow et al. 2018, Thm 7)
Assumptions. A finite MDP with bounded task and constraint costs ($|C|\le C_{\max}$, $|D|\le D_{\max}$ in their notation) whose first-hitting time of the target state is almost surely at most a constant $T$ under every stationary policy and initial state (their Assumption 2); a policy $\mu(a\mid x;\theta)$ that is continuously differentiable in $\theta$ with a Lipschitz gradient (Assumption 3); a strictly feasible pair, $H_\alpha(Z^\theta,\nu)\lt\beta$ for some $(\theta,\nu)$ (Assumption 4); Robbins–Monro steps $\zeta_3$ for $\nu$, $\zeta_2$ for $\theta$, $\zeta_1$ for $\lambda$ with $\zeta_1(k)=o(\zeta_2(k))$ and $\zeta_2(k)=o(\zeta_3(k))$, i.e. $\nu$ fastest and $\lambda$ slowest (Assumption 6); projections of $\theta$ onto a compact convex set $\Theta$, of $\nu$ onto $[-\frac{D_{\max}}{1-\gamma},\frac{D_{\max}}{1-\gamma}]$ and of $\lambda$ onto $[0,\lambda_{\max}]$, with $\lambda_{\max}$ doubled whenever $\lambda$ settles at it.
Statement. The policy iterates of the trajectory-based algorithm (their Algorithm 1) converge almost surely to a locally optimal policy $\theta^\star$ of the CVaR-constrained problem.
In words. The proof follows the timescales: $\nu$ tracks its best response for frozen $(\theta,\lambda)$, then $\theta$ for frozen $\lambda$; the limiting ODE is locally asymptotically stable, with the Lagrangian as Lyapunov function, at a local saddle point of $L$, which makes $\theta^\star$ locally optimal. Nothing is claimed about global optimality, and the actor–critic variants need further assumptions (e.g. linearly independent critic features, their Assumption 9).
Chow et al., JMLR 2018, Assumptions 2–6 and Theorem 7

Two structural points. An optimal policy need not be Markov in the state alone: the term $(Z-\nu)_+$ depends on the cost accumulated so far. Chow et al. cite Ott (2010) and Bäuerle and Ott (2011) for a deterministic optimal policy that depends on the history only through the time step, the current state and the accumulated discounted constraint cost. Those results are about minimising CVaR (Bäuerle and Ott minimise the AVaR of the discounted cost), not about the CVaR-constrained problem. For the constrained problem, the same augmented state (together with $\nu$) still gives a Markov description, since for fixed $\nu$ the constraint $H_\alpha\le\beta$ is an expected-cost constraint on the augmented MDP. But, as in every CMDP, the optimum may have to randomise. Take one decision with actions safe (task cost $1$, constraint cost $0$) and risky (task cost $0$, constraint cost $1$), $\alpha=0.5$ and $\beta=0.5$. Choosing risky with probability $p$ gives $\mathrm{CVaR}_{0.5}=\min(2p,1)$, so the optimum $p=\tfrac14$ has task cost $\tfrac34$, while the only feasible deterministic choice (safe) costs $1$. Their actor-critic algorithms work on this augmented MDP whose extra state variable tracks that running cost (compare Section 7), with stochastic policies $\mu(a\mid x,s;\theta)$. And in the policy-gradient algorithm the three variables move on three timescales, $\nu$ fastest, then $\theta$, then $\lambda$ (the actor-critic versions add a fourth, fastest one for the critic), which, under the assumptions of the theorem above, yields almost-sure convergence to a local saddle point of $L$, i.e. a locally optimal policy of the CVaR-constrained problem. The $\nu$ update is a subgradient step on a piecewise-linear function, exactly the kink phenomenon of the walkthrough.

Gaussian shortcut. Yang, Simão, Tindemans, Spaan, AAAI 2021 (WCSAC) keep SAC-Lagrangian but replace the expected-cost constraint by a per-state CVaR of a Gaussian safety critic $C^\pi(s,a)\sim\mathcal N(Q_c^\pi,\Sigma_c^\pi)$, which has the closed form (tail fraction $\alpha$)

$$\Gamma_\pi(s,a,\alpha)=\mathrm{CVaR}_\alpha=Q_c^\pi(s,a)+\alpha^{-1}\varphi\big(\Phi^{-1}(\alpha)\big)\sqrt{\Sigma_c^\pi(s,a)},\qquad \Gamma_\pi(s_t,a_t,\alpha)\le d\ \ \forall t,$$

with $\varphi,\Phi$ the standard normal density and CDF (Primer C), and the multiplier objective $J_s(\kappa)=\mathbb E[\kappa(d-\Gamma_{\pi_\theta})]$. WCSAC write the variance as $V_c^\pi$; we write $\Sigma_c^\pi$ because $V_c^\pi$ is this page's cost value function. The formula is the Gaussian tail mean. For a standard normal $U$, $\varphi'(u)=-u\varphi(u)$, so $\int_z^\infty u\varphi(u)\,du=\varphi(z)$ and $\mathbb E[U\mid U\ge z]=\varphi(z)/(1-\Phi(z))$ (the Mills-ratio identity). For $Z=\mu+\sigma U$ with $\mu=Q_c^\pi(s,a)$ and $\sigma=\sqrt{\Sigma_c^\pi(s,a)}$, the worst $\alpha$ fraction lies above $\mu+\sigma z_\alpha$ with $z_\alpha=\Phi^{-1}(1-\alpha)=-\Phi^{-1}(\alpha)$; since $1-\Phi(z_\alpha)=\alpha$ and $\varphi$ is even, $\mathbb E[Z\mid Z\ge\mu+\sigma z_\alpha]=\mu+\sigma\varphi(\Phi^{-1}(\alpha))/\alpha$, the displayed $\Gamma_\pi$. The formula is exact only when the cumulative cost really is Gaussian, not for every distribution with the same mean and variance; Exercise 8.5 shows how far it can be from the CVaR of a heavy-tailed cost.

Spectral risk. Kim et al., NeurIPS 2024 (SRCPO) constrain a spectral risk measure $R_\sigma(X)=\int_0^1F_X^{-1}(u)\sigma(u)\,du$ with an increasing spectrum $\sigma\ge0$, $\int_0^1\sigma=1$; CVaR is $\sigma(u)=\mathbf 1_{u\ge\alpha}/(1-\alpha)$. The dual form $R_\sigma(X)=\inf_g\{\mathbb E[g(X)]+\int_0^1g^\ast(\sigma(u))\,du\}$ over increasing convex $g$ (for CVaR, $g(x)=(x-\beta)_+/(1-\alpha)$ gives back Rockafellar–Uryasev) turns the risk constraint into an expectation for each fixed $g$.

Theorem — Spectral-risk conjugate representation (as used by Kim et al. 2024)

Let $X$ be a bounded real loss on a probability space, and let $\sigma:[0,1]\to[0,\infty)$ be integrable, nondecreasing and normalised by $\int_0^1\sigma(u)\,du=1$. With $F_X^{-1}(u)=\inf\{x:F_X(x)\ge u\}$ and $g^*(y)=\sup_{x\in\mathbb R}(xy-g(x))$,

$$\int_0^1F_X^{-1}(u)\sigma(u)\,du=\inf_g\left\{\mathbb E g(X)+\int_0^1g^*(\sigma(u))\,du\right\},$$

where the infimum is over finite-valued convex nondecreasing functions $g:\mathbb R\to\mathbb R$, allowing the conjugate integral to be $+\infty$ (such a function cannot lower the infimum). This is a value identity; an attaining $g$ need not be assumed.

Intuition: Fenchel's inequality $xy\le g(x)+g^*(y)$ gives an upper bound for each quantile paired with its weight. Optimising the convex function makes that bound sharp. Larger quantiles receive larger weights, explaining risk aversion. Boundedness of $X$ and integrability of $\sigma$ keep the risk finite. The CVaR substitution below computes the identity explicitly, including distributions with atoms.

Kim et al., NeurIPS 2024

The CVaR case in detail. For $g(x)=k(x-\beta)_+$ with $k=1/(1-\alpha)$, maximise $xy-g(x)$ separately over $x\le\beta$ (slope $y$) and over $x\ge\beta$ (slope $y-k$): $g^*(y)=\beta y$ for $0\le y\le k$ and $g^*(y)=+\infty$ otherwise. The CVaR spectrum takes only the values $0$ and $k$, so $\int_0^1g^*(\sigma(u))\,du=\beta\int_0^1\sigma(u)\,du=\beta$, and the infimum over this family of $g$ is $\inf_\beta\{\beta+\mathbb E[(X-\beta)_+]/(1-\alpha)\}$, exactly the Rockafellar–Uryasev formula.

SRCPO is therefore bilevel: the outer problem optimises the dual variables of the risk measure, the inner problem is a CMDP on the augmented state $(s_t,\{e_{i,t}\},\gamma^t)$ with $e_{i,t+1}=(c_{i,t}+e_{i,t})/\gamma$, and, to the authors' knowledge, it is the first risk-constrained method with a guarantee of convergence to an optimum in the tabular setting (earlier CVaR methods, Chow et al. included, guarantee only local convergence). That guarantee is narrower than "tabular" suggests. The inner theorem (their Thm 5.3) needs finite augmented state and action spaces (the accumulated-cost coordinates included), softmax policies and a strictly feasible policy. The outer theorem (Thm 6.3) needs a finite set of candidate parameters $\beta$ and a softmax sampler. A general spectrum is first replaced by an $M$-step function, which changes the risk by at most $C_{\max}\sigma(1)/((1-\gamma)M)$ (their Lemma 6.1). So the optimum reached is that of this finite, discretised problem; their practical algorithm, which samples $\beta$ from continuous ranges with a truncated-normal sampler, is not covered by the theorems.

The augmented state in detail: $e_{i,0}=0$ and $e_{i,t}=\gamma^{-t}\sum_{j\lt t}\gamma^jc_{i,j}$, the discounted cost accumulated so far, rescaled; then $e_{i,t+1}=(e_{i,t}+c_{i,t})/\gamma$, and the extra coordinate $\gamma^t$ converts back, $\gamma^te_{i,t}=\sum_{j\lt t}\gamma^jc_{i,j}$. The outer parameter vector $\beta$ fixes a finite-dimensional choice of the convex function $g$; it is not a CMDP multiplier. $C_{\max}$ bounds each one-step cost, and the discretisation bound is informative when $\sigma(1)$ is finite. See SRCPO, Sections 5–6.

7. Almost-Sure Constraints via State Augmentation

Under a cumulative constraint that must hold with probability one, how carefully the agent should act depends on how much budget is left, and a stationary policy $\pi(a\mid s)$ cannot see that. Feasibility is not necessarily the obstacle: with nonnegative costs, for instance, a policy that always picks an available zero-cost action is safe on every trajectory. What fails in general is optimality. Stationary policies in the original state need not include an optimal policy, and in Sootla et al.'s ablation the unaugmented policy hedges by leaving budget unused and pays for it in task cost. Tracking the remaining budget restores a Markov description, and Lemma 1 of the Wachi–Shen–Sui survey makes the missing variable explicit. Over a finite horizon $H$, with nonnegative costs (the survey takes $c\in[0,1]$) and budget $d$ (the survey's $\xi$), define the remaining discounted budget $\eta_{h+1}=\gamma_c^{-1}(\eta_h-c(s_h,a_h))$, $\eta_0=d$. Then $\sum_{h\le H}\gamma_c^hc(s_h,a_h)\le d$ iff $c(s_h,a_h)\le\eta_h$ for all $h$, so the single cumulative constraint is equivalent to instantaneous constraints on an augmented state. The closed form is $\eta_h=\gamma_c^{-h}\big(d-\sum_{h'\lt h}\gamma_c^{h'}c_{h'}\big)$: the rescaling by $\gamma_c^{-h}$ is what makes the recursion time-invariant, and $c_h\le\eta_h$ says exactly that the partial sum up to $h$ is within budget. Nonnegativity is what turns "every partial sum within budget" into "the total within budget": with signed costs an early overspend could be repaid later, and the instantaneous constraints would be strictly stronger than the cumulative one.

"With probability one" (almost surely, a.s.) allows exceptional trajectories as long as their total probability is zero; it is not literally a statement about every conceivable trajectory. Because time steps are countable, per-step statements combine: if $\mathbb P(E_t)=1$ for every $t$, then $\mathbb P(\bigcap_tE_t)=1$, since by the union bound the complements have total probability at most $\sum_t\mathbb P(E_t^c)=0$.

Definition — Sauté MDP (Sootla et al., ICML 2022, Def. 3 and Eqs. 7–9)
For a constrained MDP with task cost $c$, discount $\gamma_c$, safety cost $l\ge0$, safety discount $\gamma_l$ and budget $d$, augment the state with the rescaled remaining budget $z_t$ and reshape the task cost: $$z_{t+1}=\frac{z_t-l(s_t,a_t)}{\gamma_l},\quad z_0=d;\qquad \tilde c_n(s,z,a)=\begin{cases}c(s,a)&z\ge0\\ n&z\lt0\end{cases};\qquad \min_\pi\ \mathbb E\sum_t\gamma_c^t\,\tilde c_n(s_t,z_t,a_t).$$ The transitions of $(s,z)$ are Markov, so $\tilde{\mathcal M}_n$ is an ordinary MDP and any RL algorithm can be "sautéed". Theorem 1 (deterministic case): the constrained problem, its Lagrangian form and the reshaped problem with $n=\infty$ have the same optimal policies. Theorem 2 (A1: $\tilde c_n$ bounded, measurable, nonnegative, lower semicontinuous; A2: compact actions; A3: weakly continuous transitions): for every finite $n$ the Bellman equation $V_n^\star(s,z)=\min_a\big(\tilde c_n(s,z,a)+\gamma_c\mathbb E V_n^\star(s',z')\big)$ holds, the optimal policy has the form $a\sim\pi_n^\star(\cdot\mid s,z)$, and $V_n^\star\uparrow V_\infty^\star$ monotonically. Theorem 3: an optimal policy of $\tilde{\mathcal M}_\infty$ with finite cost is optimal for the almost-surely constrained problem $\min\mathbb E J_{\rm task}$ s.t. $z_t\ge0$ a.s. for all $t$ (Def. 4).
Background — What the assumptions of Theorems 2 and 3 mean

They make expected costs well defined and let minimising actions survive the limit $n\to\infty$. Measurable functions are those for which probabilities and integrals such as $\mathbb E\,\tilde c_n(s_t,z_t,a_t)$ are defined. A stochastic kernel assigns a distribution $P(\cdot\mid s,a)$ to every state-action pair, measurably in $(s,a)$; it need not have a density (a deterministic transition is a point mass). Weakly continuous transitions: $\int f(s')\,P(ds'\mid s,a)$ depends continuously on $(s,a)$ for every bounded continuous test function $f$. Compact actions: in $\mathbb R^k$, closed and bounded (Primer 0). A lower semicontinuous cost satisfies $\tilde c_n(y)\le\liminf_{y'\to y}\tilde c_n(y')$: it may jump up but never down at a point. The reshaped cost has exactly such a jump at the budget boundary, $\tilde c_n=c$ at $z=0$ and $n$ for $z\lt0$, which is lower semicontinuous (for continuous $c$) as long as $n\ge c$. For finite state and action sets all these conditions hold automatically. Theorem 3 is the union bound above at work: if $z_t\lt0$ had positive probability at some time $t$, the expected cost in $\tilde{\mathcal M}_\infty$ would be infinite, so a finite-cost optimal policy has $z_t\ge0$ at every $t$ with probability one, hence at all $t$ simultaneously.

Two remarks. The a.s. formulation is much stronger than an expected or CVaR budget, and only makes sense when a policy that never overspends exists; in practice $n$ is finite, and $V_n^\star\uparrow V_\infty^\star$ is a statement about optimal values, not a violation bound for any finite-$n$ policy: a finite penalty can still make a rare or heavily discounted violation worthwhile. And because $d$ enters only as the initial safety state, one policy generalises across budgets by changing $z_0$: in their generalisation experiment (a pendulum-type task, their Fig. 4) a policy trained with budgets sampled from $[5,100]$ met test budgets of 40 and 80 more reliably than one trained at the single budget 60. Their Safety Gym runs, by contrast, test the almost-sure constraint itself, with a few outlier trajectories still violating it.

The multiplier as a state. Calvo-Fullana, Paternain, Chamon, Ribeiro, IEEE TAC 2024 augment with a different summary of the constraint history: the Lagrange multiplier itself. (They use the utility convention of the monitoring problem: rewards $r_i$ with thresholds $c_i$ and constraints $V_i\ge c_i$ on long-run averages, so here $c_i$ is a number, not a cost function.) Training samples $(s,\lambda)$ from $\mathcal S\times\Lambda$ and solves the ordinary MDP with reward $r_\lambda(s,a)=r_0(s,a)+\sum_i\lambda_i(r_i(s,a)-c_i)$ for a policy $\pi_\theta(a\mid s,\lambda)$ (Alg. 1). Execution runs the dual dynamics online (Alg. 2): for epochs of length $T_0$, act with $\pi_\theta(\cdot\mid s_t,\lambda_k)$ and then

$$\lambda_{i,k+1}=\Big[\lambda_{i,k}-\frac{\eta_\lambda}{T_0}\sum_{t=kT_0}^{(k+1)T_0-1}\big(r_i(s_t,a_t)-c_i\big)\Big]_+ .$$
Theorem — State-augmented CRL produces feasible, near-optimal trajectories (Calvo-Fullana et al. 2024, Thm 1; average-reward setting)
Setting. During epoch $k$ the agent acts with $a_t\sim\pi(\lambda_k)$, an exact maximiser of the average-reward Lagrangian for the current multipliers, and the multipliers follow the projected update above with fixed $T_0$ and $\eta_\lambda$. (A learned $\pi_\theta(\cdot\mid s,\lambda)$ only approximates $\pi(\lambda)$ and adds error terms not covered here.)
Assumptions. (A1) a strictly feasible policy with margin $C\gt0$; (A2) $|r_i(s,a)-c_i|\le B$ for all $s,a,i$, as printed; the proof, however, bounds the squared Euclidean norm of the whole vector of epoch-averaged violations by $B^2$, so with $m$ constraints read $B$ as a bound on $\|r(s,a)-c\|_2$, or replace $B^2$ by $mB^2$ below; (A3) the epoch averages are unbiased given the current multipliers, $\mathbb E\big[\frac1{T_0}\sum_{t=kT_0}^{(k+1)T_0-1}r_i(s_t,a_t)\,\big|\,\lambda_k\big]=V_i(\pi(\lambda_k))$ (the proof uses the same for the objective $r_0$). A rollout that starts from an arbitrary state is in general biased for a long-run average; the paper's Appendix II treats that case.
Statement. The state-action sequence satisfies $\liminf_{T}\frac1T\sum_{t\lt T}r_i(s_t,a_t)\ge c_i$ almost surely for every constraint, and $\lim_T\mathbb E\big[\frac1T\sum_{t\lt T}r_0(s_t,a_t)\big]\ge P^\star-\eta_\lambda B^2/2$ (the proof bounds the $\liminf$, which is the safe reading if the limit does not exist).
In words. Nothing is claimed about any single policy $\pi(\lambda_k)$ being optimal; the guarantee is about the trajectory generated by switching among Lagrangian maximisers as the multipliers drift. In the monitoring problem of Section 3 the multiplier $\lambda_i$ records the deficit of time spent in $R_i$ relative to $c$ (their Eq. 16); the executed policy at $R_1$ jumps between "return to $R_0$" ($\lambda_1\lt\max(1,\lambda_2)$) and "stay in $R_1$" ($\lambda_1\gt\max(1,\lambda_2)$; a large $\lambda_1$ alone is not enough, since with $\lambda_2\gt\lambda_1\gt1$ heading for $R_2$ pays more, and at ties the Lagrangian leaves the choice to the policy's tie-breaking), neither of which solves the problem, while the time averages of the switched trajectory meet both fractions (their Fig. 3). The failure of fixed-$\lambda$ methods there is one of recovery, not of representation (Exercise 8.6).

Reading the statement: for a sequence $a_T$, $\liminf_Ta_T=\lim_{N\to\infty}\inf_{T\ge N}a_T$ is its eventual lower envelope (Primer 0). So the constraint part says that, with probability one, for every $\epsilon\gt0$ the running average $\frac1T\sum_{t\lt T}r_i(s_t,a_t)$ falls below $c_i-\epsilon$ only finitely often; deficits at finite times are allowed. The reward part is about an expectation over trajectories, not a bound on each realised average.

Connection to Module 7
Three augmentations, three summary statistics of the constraint history: the running CVaR cost (Chow), the remaining budget (Sauté, Wachi), the multiplier (Calvo-Fullana). The first two turn a trajectory-level constraint into a Markov one; the third turns a recovery problem into a switching rule. All three are the RL counterpart of the "safety as a state variable" idea in Module 7's safe value functions, where the penalty threshold plays the role of the budget.

8. Adjacent: Safe RLHF

Background — Bradley–Terry preference models and logistic losses

The data are prompts $x$ with pairs of responses $(y_w,y_l)$, where a labeller preferred $y_w$. A Bradley–Terry model turns a score difference into a probability, $\mathbb P(y_w\succ y_l\mid x)=\sigma\big(R(y_w,x)-R(y_l,x)\big)$ with the sigmoid $\sigma(z)=1/(1+e^{-z})$: equal scores give $\tfrac12$, a difference of $\log3$ gives $\tfrac34$. Fitting $R$ means minimising the negative log-likelihood $-\log\sigma(\cdot)$ averaged over the labelled pairs, which is small when the model gives the observed preference a high probability. In the cost model the comparison is harmfulness, so $y_w$ is the more harmful response. Pairwise differences do not change if all scores are shifted by a constant, so the second term of $L_C$ anchors the sign: $-\log\sigma(sC)$ is small when a harmful response ($s=+1$) gets $C\gt0$ and a harmless one ($s=-1$) gets $C\lt0$.

Dai et al., ICLR 2024 carry the CMDP template into language-model alignment. Human preferences are collected separately for helpfulness and harmlessness; a reward model $R_\phi(y,x)$ (learned reward models: Primer E) is fitted to the first with the Bradley–Terry loss, and a cost model $C_\psi(y,x)$ to the second with a pairwise term plus a classification term that anchors the sign of the cost: $$L_C(\psi)=-\mathbb E\big[\log\sigma\big(C_\psi(y_w,x)-C_\psi(y_l,x)\big)\big]-\mathbb E\big[\log\sigma(s_wC_\psi(y_w,x))+\log\sigma(s_lC_\psi(y_l,x))\big],$$ where in the harmlessness dataset $y_w$ is the more harmful response of the pair and $s=+1$ marks a harmful, $s=-1$ a harmless response, so that $C_\psi\gt0$ means unsafe and the boundary $C_\psi=0$ is a virtual response that the second term pins down. The fine-tuning problem is then a CMDP with a one-step horizon if the whole response is read as one action (prompt $x$, response $y\sim\pi_\theta(\cdot\mid x)$; PPO itself works token by token, $y=a_{1:T}$): $\max_\theta J_R(\theta)$ s.t. $J_C(\theta)\le0$ with $J_R=\mathbb E[R_\phi(y,x)]$, $J_C=\mathbb E[C_\psi(y,x)]+d$, relaxed to $\min_\theta\max_{\lambda\ge0}[-J_R(\theta)+\lambda J_C(\theta)]$ and solved by alternating PPO steps (Primer E) on $\theta$ with multiplier steps on $\lambda$ (Section 4); the offset $d$ tunes the permitted expected signed cost score.

The offset enforces $\mathbb E[C_\psi]\le-d$. This constrains an average score, not directly $\Pr(C_\psi>0)$. Positive scores can be offset by sufficiently negative ones. Converting this budget to a harmful-output frequency requires additional assumptions about score bounds or calibration. Likewise, convergence results from earlier sections do not transfer automatically to PPO with learned reward and cost models.

The Lagrangian template applies: the multiplier tracks the constraint violation as an integral controller, the trained policy is a Lagrangian maximiser rather than a certified-safe object, and the guarantee is on an expectation over prompts, not on individual outputs. The reported effect over three rounds on Alpaca-7B is a drop of harmful responses on their evaluation set from 53.08% to 2.45% with improved helpfulness, and the method spawned multimodal follow-ups. For the reader of this section the interesting point is the decoupling: one reward model per objective, with the trade-off set by a budget instead of a fixed weight, which is exactly the argument of Section 1 restated for LLMs.

Walkthrough: Dual Ascent on a Two-Action CMDP

The smallest CMDP that shows everything: one state, two actions, one budget. We compute the dual function by hand, recover the mixed optimum from the KKT conditions, and watch a fixed-step dual ascent oscillate around $\lambda^\star$. ("Dual ascent" is the traditional name, from the cost-minimisation convention, in which the dual function is concave and maximised; in this page's convention the very same multiplier update is projected subgradient descent on the convex $D$, as in Section 4.)

Interactive: Multiplier Dynamics (Plain vs PID)

Compare plain and PID multiplier updates on the same toy constrained policy. Change one gain and predict whether the cost settles near the budget, oscillates or overshoots. The plots show a finite simulation; the model and reference-line assumptions are explained below.

Background — Model, reference multiplier and readouts

A one-parameter policy $p\in[0,1]$ with return $J_r(p)=p$ and a nonlinear cost $J_c(p)=2p+0.5\sin(3p)$ is trained by projected gradient ascent on the Lagrangian, $p\leftarrow\mathrm{clip}(p+\eta_\pi(1-\lambda J_c'(p)))$, while the multiplier follows either the plain integral rule or Algorithm 3 with the same $K_I$. The cost fed to the controller is a noisy estimate $\hat J_c=J_c(p)+\sigma\xi$ with seeded Gaussian noise (identical noise for both controllers). Everything is simulated for 300 iterations. The constrained optimum $p^\star$ is found by bisection on $J_c(p^\star)=d$ and $\lambda_{\rm KKT}=1/J_c'(p^\star)$ from stationarity; for $d\ge J_c(1)\approx2.07$, $p^\star=1$ and zero is a valid KKT multiplier; the constraint is strictly slack only for $d\gt J_c(1)$.

Going deeper — why the reference line is a KKT multiplier, not the dual optimum

This explorer is a nonlinear scalar control surrogate, not the unrestricted occupancy-LP CMDP. Denote its equilibrium multiplier by $\lambda_{\rm KKT}=1/J_c'(p^\star)$. Since $J_c''(p)\lt0$ in the interior, $L(p,\lambda)=p-\lambda(J_c(p)-d)$ is convex in $p$ for $\lambda\gt0$ ($\partial_p^2L=-\lambda J_c''(p)\gt0$): the stationary point is a minimum in $p$, not the maximum. At $d=1$, $p^\star\approx0.30285$ and $\lambda_{\rm KKT}\approx0.34219$. Because $L$ is convex in $p$, its maximum over $[0,1]$ sits at an endpoint, so the actual dual function is $D(\lambda)=\lambda d+\max(0,1-\lambda J_c(1))$ (using $J_c(0)=0$). It is minimised at $\lambda=1/J_c(1)\approx0.48296$ with value $d/J_c(1)\approx0.483$ at $d=1$, above $P^\star=p^\star\approx0.303$: a positive duality gap, possible here because this one-parameter family cannot mix policies. The plotted reference $\lambda_{\rm KKT}$ illustrates local feedback regulation around a KKT point, not the dual optimum.

Why bisection: $J_c'(p)=2+1.5\cos(3p)\ge2+1.5\cos3\gt0.5$ on $[0,1]$, so the cost is strictly increasing. For $0\lt d\lt J_c(1)$ the feasible $p$ form an interval $[0,p^\star]$ with $J_c(p^\star)=d$, and maximising the reward $p$ picks its right end. Bisection finds $p^\star$: start with $[0,1]$, evaluate $J_c$ at the midpoint, keep the half in which $J_c-d$ changes sign; each step halves the interval.

Reading the panel. The eigenvalue readout describes the noise-free local P–I model of Section 5(b)–(c) (projections inactive, $K_D=0$): a modulus above one means that small perturbations grow in that model, not that the clipped nonlinear dynamics settle on a periodic orbit; noise, clipping and the one-sided D term can change what you see, so treat an apparent cycle as a simulation observation. The controllers see $\hat J_{c,k}=J_c(p_k)+\sigma\xi_k$ with standard-normal $\xi_k$ from a fixed seed, so both runs get the same draws. The settling readout reports the iteration from which all remaining displayed samples (up to iteration 299) stay within $\max(0.05d,0.02)$ of $J_c(p^\star)$: a finite-run diagnostic, not a guarantee for later iterations or fresh noise. Overshoot is the largest positive $J_c(p_k)-d$ in the run.

If $d>J_c(1)$, the cost constraint is strictly slack at $p=1$, so its KKT multiplier is zero. If $d=J_c(1)$, the cost constraint and the boundary $p=1$ are both active; zero is one valid multiplier choice, but complementary slackness does not uniquely determine it.

Multiplier Dynamics: integral-only versus PID

Linear-model prediction (Section 5(b)–(c)): with loop gain $c=\eta_\pi J_c'(p^\star)^2$ and curvature factor $a=1-\eta_\pi\lambda_{\rm KKT} J_c''(p^\star)$ the local loop matrix is $M=\begin{bmatrix}a-c(K_P+K_I)&-cK_I\\1&1\end{bmatrix}$ with $\det M=a-cK_P$. Here $J_c$ is concave, so the Lagrangian is convex in $p$ and $a\gt1$: the integral-only loop is weakly unstable ($|z|=\sqrt a$ slightly above 1) and its oscillation can grow until clipping changes the motion; a periodic limiting orbit is not implied by the local model. With $K_P\gt0$ complex eigenvalues have modulus $\sqrt{a-cK_P}$, below 1 once $cK_P\gt a-1$. Try $K_P=K_D=0$ to see the two curves coincide, then raise $K_P$; raise $\sigma$ to see how the P and D terms pass estimation noise straight into $\lambda$ (the projected D term only upwards), which is why Stooke et al. smooth the proportional and derivative inputs.

From the mathematics to a real decision

What you will be able to do
  • Translate an operational requirement into an expected discounted cost and identify what that requirement leaves uncontrolled.
  • Solve a constrained choice between policies and interpret a multiplier as a trade-off price.
  • Carry a remaining budget through a trajectory instead of treating every decision as a fresh start.

A delivery robot with two operating modes

Imagine a warehouse robot whose planner chooses a cautious or a fast mode. The following numbers are invented to make the modeling choices visible; they are not measurements from a warehouse. At each decision, cautious mode has expected productivity reward 2 points and probability 0.02 of entering a marked exclusion zone. Fast mode has expected reward 5 points and probability 0.20 of such an entry. The cost is an indicator: 1 for an entry, 0 otherwise. We assume the same distribution is available at every decision and that actions do not change future state distributions. This one-state model is deliberately simpler than a moving robot.

The engineering question is not initially “Which algorithm should we train?” It is “What exactly is the admissible operating behavior?” Suppose a designer sets discount $\gamma=0.9$ and expected discounted cost budget $d=1$. Discounting says that an event ten decisions from now receives weight $0.9^{10}$. That is a mathematical preference, not a physical claim that a late exclusion-zone entry is harmless. If entry must never happen, this cost budget expresses the wrong requirement, whatever optimizer is used.

Worked decision: mix the two modes

Let $p\in[0,1]$ be the probability of choosing fast mode independently at each decision. Its expected one-step reward is $2(1-p)+5p=2+3p$. The expected one-step cost is $0.02(1-p)+0.20p=0.02+0.18p$. Linearity of expectation and the geometric series give

$$J_r(p)=\frac{2+3p}{1-0.9}=20+30p,\qquad J_c(p)=\frac{0.02+0.18p}{1-0.9}=0.2+1.8p.$$

First solve feasibility, before maximizing anything. The inequality $0.2+1.8p\le1$ gives $p\le0.8/1.8=4/9$. Productivity increases with $p$, so the best feasible mixture is $p^\star=4/9$, with $J_r=100/3$ and $J_c=1$. The cost constraint is active: it is the feature that prevents the reward-maximizing choice $p=1$.

Now construct the reward-maximization Lagrangian $L(p,\lambda)=20+30p-\lambda(0.2+1.8p-1)$, with $\lambda\ge0$. Its coefficient of $p$ is $30-1.8\lambda$. At $\lambda^\star=50/3$ that coefficient is zero. Every mixture maximizes this particular inner objective, while the constrained problem selects the feasible one with the greatest reward. This explains why finding an optimal multiplier alone does not necessarily identify a unique policy.

The same number has a useful sensitivity interpretation. For budgets between 0.2 and 2, the optimal reward is $20+(50/3)(d-0.2)$. Increasing the budget by 0.01 increases the attainable discounted reward by $1/6$ point in this model. The interpretation is local to this range and this model. Outside it, the probability limits $0\le p\le1$ change the formula.

A feasible expectation can hide an unacceptable trajectory

Even cautious mode has a positive entry probability. Under independent repetitions, the probability of no entry in the first $T$ decisions is $0.98^T$, which tends to zero. Its discounted cost is only 0.2, yet an entry eventually occurs with probability 1. The independence assumption is needed for this particular product calculation; the general distinction between expected cost and trajectory safety does not depend on it. A physical exclusion zone needs a different model or a safety mechanism such as the filter in Module 10’s application.

Worked trajectory: remember what has already been spent

A second designer specifies a pathwise discounted resource budget rather than an expected entry count. Let the realized resource costs be $c_0=0.4$ and $c_1=0.2$, with initial budget 1 and discount 0.9. The rescaled remaining budget is $z_{t+1}=(z_t-c_t)/0.9$. The units of $z_t$ match the cost at decision $t$, because discounting back to decision zero has been divided out.

$$z_1=\frac{1-0.4}{0.9}=\frac23,\qquad z_2=\frac{2/3-1/5}{9/10}=\frac{14}{27}.$$

Check this against the original accounting. The discounted spend is $0.4+0.9(0.2)=0.58$; the remainder is 0.42, and $0.9^2z_2=0.42$. A proposed next cost 0.6 exceeds $z_2$ and produces total discounted spend $0.58+0.81(0.6)=1.066$. An agent looking only at the current physical state could miss this violation. The augmented state must include the budget when the objective is to respect this trajectory requirement.

This update is bookkeeping, not a complete controller. A policy must still choose an action whose possible costs and successors respect the remaining budget, and there may be no such action. Expected-cost CMDPs, almost-sure budget constraints and robust physical constraints are different design problems. Write the chosen requirement in words beside the equation.

Application exercises

Exercise 8.B1 — Medium: Reprice a tighter operating budget

Keep the two-mode model but reduce $d$ to 0.65. Find the best fast-mode probability, discounted reward and cost. Explain whether the optimal multiplier changes while the constraint remains between the two pure-mode costs.

Show hint

Solve $0.2+1.8p\le0.65$ first. Then inspect the slope of the best reward as a function of the budget.

Show solution

Feasibility gives $p\le0.45/1.8=1/4$. Increasing reward makes $p^\star=1/4$, $J_r=20+30/4=27.5$ and $J_c=0.65$. The interior-range slope is still $30/1.8=50/3$, so the multiplier remains $50/3$. The smaller budget changes the mixture, not this model’s marginal productivity-to-cost ratio. Neither result implies zero entry probability.

Exercise 8.B2 — Hard: Change the discount without changing the meaning by accident

Change $\gamma$ to 0.95 and keep the numerical budget $d=1$. Find the new optimal mixture and reward. What happens if the designer reuses $p=4/9$? State a modeling reason to reconsider the budget when changing the discount.

Show hint

The divisor is now $1-\gamma=0.05$. A constant one-step cost is counted twice as heavily as before.

Show solution

The new cost is $0.4+3.6p$, so $p^\star=0.6/3.6=1/6$. The reward is $(2+3/6)/0.05=50$. Reusing $4/9$ gives cost $0.4+3.6(4/9)=2$, violating the budget. Reward values at different discounts are not directly comparable totals over the same effective horizon. A fixed numerical discounted budget represents a different allowable constant cost when the discount changes; the operational requirement must determine whether that change is intended.

Exercise 8.B3 — Hard: A monitoring variable is part of the decision

Use the trajectory example with $z_2=14/27$. Two actions next have deterministic resource costs 0.5 and 0.6. Which action preserves a nonnegative remaining budget? Compute $z_3$ for the admissible action and verify the accounting at the original time scale.

Show hint

Compare each immediate cost with $z_2$ and multiply the new remainder by $0.9^3$ to check it.

Show solution

Only 0.5 is at most $14/27$. It gives $z_3=(14/27-1/2)/(9/10)=5/243$. Discounted spend becomes $0.4+0.9(0.2)+0.81(0.5)=0.985$, while $0.9^3(5/243)=0.015$. These sum to 1. The check concerns deterministic realized costs here. With uncertain costs, preserving a pathwise budget requires considering every allowed cost realization rather than substituting its expectation.

What to carry into the next chapter

Close the calculations and explain three objects: the feasible policy set, the multiplier, and the trajectory budget. Give an example of a requirement each one does not enforce. Then change one assumption—state dependence, discount or uncertain costs—and identify the first step of the derivation that needs replacing. Module 9 addresses a further problem: even when the target constraint is clear, an approximate update can mispredict its effect.

Exercises

Graded practice

Each level has four problems. Write your steps before opening the answer; use the hint when you need a first move. Close the answer and retry after checking it.

Easy practice

Exercise 8.P1 — Easy: Discounted reward and cost

A policy receives reward $2$ and cost $1/4$ at every time step. Let $\gamma=1/2$ and cost budget $d=3/5$. Compute $J_r,J_c$ and decide feasibility.

Review this topic · Revisit the prerequisite

Show hint
Factor the constant out of $\sum_{t\ge0}(1/2)^t=2$. Compare the total cost with the budget.
Show answer

$J_r=2/(1-1/2)=4$ and $J_c=(1/4)/(1-1/2)=1/2$. Since $1/2\le3/5$, the policy is feasible. The per-step cost is $1/4$, but the constraint is on its discounted cumulative value $1/2$; comparing $1/4$ directly with $d$ would check a different requirement.

Exercise 8.P2 — Easy: A mixed action and its occupancy

In one self-looping state, choose action $R$ with probability $0.3$ and action $S$ otherwise. Rewards are $r(R)=3,r(S)=1$; costs are $c(R)=2,c(S)=0$; $\gamma=1/2$. Find normalized action occupancies, $J_r$ and $J_c$.

Review this topic · Revisit the prerequisite

Show hint
The state is visited at every time, so normalized action occupancies equal the action probabilities.
Show answer

The occupancies are $\rho(R)=0.3$, $\rho(S)=0.7$, summing to $1$. The expected per-step reward is $0.3(3)+0.7(1)=1.6$ and cost is $0.3(2)=0.6$. Dividing by $1-\gamma=0.5$ gives $J_r=3.2$ and $J_c=1.2$. Occupancy normalizes visitation; the discounted return restores the factor $1/(1-\gamma)$.

Exercise 8.P3 — Easy: Evaluate the penalized reward

Use $L=J_r-\lambda(J_c-d)$ with $J_r=8$, $d=4$, $\lambda=1.5$. Evaluate $L$ for $J_c=5$ and for $J_c=3$. Explain the difference.

Review this topic · Revisit the prerequisite

Show hint
Compute the signed constraint residual $J_c-d$ before multiplying.
Show answer

For cost $5$, the residual is $1$, so $L=8-1.5=6.5$. For cost $3$, the residual is $-1$, so $L=8+1.5=9.5$. At this fixed multiplier, violating the budget lowers the policy objective and slack raises it. Neither number alone is the dual optimum: the dual function also maximizes over policies and then minimizes over nonnegative multipliers.

Exercise 8.P4 — Easy: Two projected multiplier updates

Update $\lambda_{k+1}=\max\{0,\lambda_k+0.2(J_{c,k}-2)\}$. Starting from $\lambda_0=0.1$, use costs $J_{c,0}=3$ and $J_{c,1}=0$. Find both updates.

Review this topic · Revisit the prerequisite

Show hint
Apply the update sequentially. Projection removes a negative multiplier.
Show answer

First, $\lambda_1=\max\{0,0.1+0.2(3-2)\}=0.3$. Then $\lambda_2=\max\{0,0.3+0.2(0-2)\}=\max\{0,-0.1\}=0$. Violation increases the penalty; slack reduces it. Projection keeps the multiplier in its permitted domain $\lambda\ge0$.

Medium practice

Exercise 8.P5 — Medium: Verify discounted flow on two states

Start at state $0$, move deterministically to state $1$, and stay there. There is one action and $\gamma=1/2$. Find normalized state occupancies and verify their flow equations. With rewards $r(0)=0,r(1)=2$, find the return.

Review this topic · Revisit the prerequisite

Show hint
State $0$ appears only at time zero; state $1$ appears at every later time.
Show answer

$\rho(0)=(1-\gamma)=1/2$ and $\rho(1)=(1-\gamma)\sum_{t\ge1}\gamma^t=1/2$. State $0$ has flow $\rho(0)=(1-\gamma)\mu(0)+0=1/2$. State $1$ has flow $\rho(1)=0+\gamma(\rho(0)+\rho(1))=1/2$. The normalized expected reward is $0(1/2)+2(1/2)=1$, so $J_r=1/(1-\gamma)=2$. Directly, $2\sum_{t\ge1}(1/2)^t=2$, confirming the normalization.

Exercise 8.P6 — Medium: Solve a small constrained policy problem

One state self-loops. A risky action has reward $4$ and cost $2$; the other has reward $1$ and cost $0$. Choose the risky action with stationary probability $p$. Let $\gamma=1/2,d=1$. Find the feasible range of $p$ and the optimal return.

Review this topic · Revisit the prerequisite

Show hint
Write expected one-step reward and cost as affine functions of $p$, then divide both by $1-\gamma$.
Show answer

The one-step reward is $1+3p$ and cost is $2p$. Thus $J_r=2+6p$ and $J_c=4p$. Feasibility requires $0\le p\le1$ and $4p\le1$, giving $0\le p\le1/4$. Since the return increases with $p$, the optimum is $p=1/4$ with $J_r=7/2=3.5$. Always choosing the safe action gives only $2$; always choosing the risky action violates the budget. Randomization fills the useful gap.

Exercise 8.P7 — Medium: A tail statistic differs from its expectation

A cost $Z$ is $0$ with probability $0.8$ and $10$ with probability $0.2$. Find its expectation, $\mathrm{VaR}_{0.9}$ and upper-tail $\mathrm{CVaR}_{0.9}$, where CVaR averages the worst $10\%$, including fractional mass at a quantile.

Review this topic · Revisit the prerequisite

Show hint
The worst $10\%$ can be taken entirely from the $20\%$ mass at cost $10$.
Show answer

$\mathbb E[Z]=0.8(0)+0.2(10)=2$. The distribution function is $0.8$ at $0$ and $1$ at $10$, so its first value reaching $0.9$ is at $10$: $\mathrm{VaR}_{0.9}=10$. The worst $10\%$ of outcomes all have cost $10$, hence $\mathrm{CVaR}_{0.9}=10$. Counting only half the mass at $10$ is legitimate; the tail definition does not require taking an entire atom.

Exercise 8.P8 — Medium: Track a discounted remaining budget

For $\sum_{t\ge0}\gamma^t c_t\le2$ with $\gamma=1/2$, express remaining budget in current-time units by $z_{t+1}=(z_t-c_t)/\gamma$, $z_0=2$. Take $c_0=1,c_1=1.5$. Compute $z_1,z_2$ and the unused budget in original-time units after these costs.

Review this topic · Revisit the prerequisite

Show hint
Multiply $z_2$ by $\gamma^2$ to convert its units back to time zero.
Show answer

$z_1=(2-1)/(1/2)=2$ and $z_2=(2-1.5)/(1/2)=1$. The original discounted spending is $1+(1/2)(1.5)=1.75$, leaving $0.25$. This matches $\gamma^2 z_2=(1/4)(1)=0.25$. The value $z_1=2$ does not mean the original budget refilled: future costs are measured in different discount units. Including $z_t$ in the state makes that available budget visible to the policy.

Hard practice

Exercise 8.P9 — Hard: Recover the mixed optimum from the dual

For $J_r=2+6p$, $J_c=4p$, $d=1$, $0\le p\le1$, derive $D(\lambda)=\max_p L(p,\lambda)$ and minimize it for $\lambda\ge0$. Why is selecting an arbitrary maximizer of $L$ at the optimal multiplier insufficient?

Review this topic · Revisit the prerequisite

Show hint
The affine function of $p$ attains a maximum at an endpoint, except when its slope is zero.
Show answer

$L=2+6p-\lambda(4p-1)=2+\lambda+(6-4\lambda)p$. Therefore $D(\lambda)=\max\{2+\lambda,8-3\lambda\}$. The second line decreases until it meets the increasing first line: $2+\lambda=8-3\lambda$ gives $\lambda^\ast=1.5$ and $D(\lambda^\ast)=3.5$.

At that multiplier the coefficient of $p$ is zero, so every $p\in[0,1]$ maximizes $L$. Some are infeasible. Among feasible values, the largest reward occurs at $p=1/4$, which has cost $1$ and reward $3.5$. Dual optimality must be combined with primal feasibility and complementary slackness to recover an optimal policy.

Exercise 8.P10 — Hard: Audit an average-violation guarantee

Two successive constraint residuals are $e_1=1,e_2=-1$. Compare $[(e_1+e_2)/2]_+$ with $([e_1]_++[e_2]_+)/2$, where $[x]_+=\max\{x,0\}$. What can a bound on the first quantity establish about the safety of each iterate?

Review this topic · Revisit the prerequisite

Show hint
Apply the positive part before averaging for one expression and after averaging for the other.
Show answer

The signed average is $0$, so its positive part is $0$. The average of positive violations is $(1+0)/2=1/2$. The first quantity allows unsafe iterations to cancel against slack at other iterations; the second counts the violation without that cancellation. Even a zero bound on the signed average does not establish feasibility of every iterate: the first residual is positive. The location of the positive-part operation changes the guarantee.

Exercise 8.P11 — Hard: An expected budget can allow rare failure

A trajectory costs $100$ with probability $0.01$ and $0$ otherwise; call the cost-$100$ outcome a failure. Does it meet expected budget $1$? Find failure probability, $\mathrm{VaR}_{0.95}$ and $\mathrm{CVaR}_{0.95}$. Explain what an expected-cost certificate permits here.

Review this topic · Revisit the prerequisite

Show hint
The worst $5\%$ contains the $1\%$ costly outcomes and $4\%$ of the zero-cost outcomes.
Show answer

The expected cost is $0.01(100)=1$, so the expected budget is met. Failure still has probability $0.01$. Since $\mathbb P(Z\le0)=0.99\ge0.95$, $\mathrm{VaR}_{0.95}=0$. The worst $5\%$ has total weighted cost $0.01(100)+0.04(0)=1$; dividing by $0.05$ gives $\mathrm{CVaR}_{0.95}=20$.

The expected-cost statement is correct but does not exclude rare expensive trajectories. Replacing it by a chance or tail-risk requirement changes the optimization problem and its meaning.

Exercise 8.P12 — Hard: Derive the multiplier sign rather than memorizing it

For reward maximization subject to $J_c\le d$, prove that $D(\lambda)=\sup_\pi[J_r-\lambda(J_c-d)]$ is an upper bound on the feasible optimum for every $\lambda\ge0$. Assuming an exact inner maximizer, derive the projected dual descent update.

Review this topic · Revisit the prerequisite

Show hint
First evaluate the sign of $-\lambda(J_c-d)$ for a feasible policy. Then differentiate the Lagrangian with respect to $\lambda$.
Show answer

For any feasible policy, $J_c-d\le0$, hence $-\lambda(J_c-d)\ge0$ and $L(\pi,\lambda)\ge J_r(\pi)$. Taking the supremum over all policies can only increase this, so $D(\lambda)\ge\sup_{\pi\ {\rm feasible}}J_r(\pi)$. Consequently the tightest such dual bound is obtained by minimizing $D$.

An exact maximizing policy supplies subgradient $d-J_c$ of $D$. A projected descent step is $\lambda^+=[\lambda-\eta(d-J_c)]_+=[\lambda+\eta(J_c-d)]_+$. This explains why an upper-budget violation increases the multiplier even though the dual objective is minimized in this convention.

Original longer exercises

Exercise 8.1 — Derive the occupancy LP

Let $\rho_\pi(s,a)=(1-\gamma)\sum_t\gamma^t\mathbb P^\pi_\mu(s_t=s,a_t=a)$. (a) Show $\sum_{s,a}\rho_\pi(s,a)=1$ and $J_r(\pi)=\langle\rho_\pi,r\rangle/(1-\gamma)$. (b) Derive the flow constraints. (c) Write the CMDP as an LP in $\rho$ and explain why its feasible set is a polytope. (d) Deduce that the set of achievable pairs $(J_r(\pi),J_c(\pi))$ over all policies is convex.

Show answer

(a) $\sum_{s,a}\mathbb P(s_t=s,a_t=a)=1$ for each $t$, so the total mass is $(1-\gamma)\sum_t\gamma^t=1$. Linearity of expectation and the exchange of $\mathbb E$ with the infinite sum, which is allowed because $|r|\le B_r$ gives $\mathbb E\sum_t\gamma^t|r(s_t,a_t)|\le B_r/(1-\gamma)\lt\infty$ (background box of Section 2), give $J_r=\sum_t\gamma^t\sum_{s,a}\mathbb P(s_t=s,a_t=a)r(s,a)=\frac{1}{1-\gamma}\sum_{s,a}\rho_\pi(s,a)r(s,a)$.

(b) Markov property: $\mathbb P(s_{t+1}=s)=\sum_{s',a'}\mathbb P(s_t=s',a_t=a')P(s\mid s',a')$. Multiply by $\gamma^{t+1}$, sum over $t\ge0$, add the $t=0$ term $\mu(s)$ on the left, multiply by $(1-\gamma)$: $\rho_\pi(s)=(1-\gamma)\mu(s)+\gamma\sum_{s',a'}\rho_\pi(s',a')P(s\mid s',a')$.

(c) $\max\frac{1}{1-\gamma}\langle\rho,r\rangle$ s.t. $\frac{1}{1-\gamma}\langle\rho,c_i\rangle\le d_i$, the $|\mathcal S|$ flow equalities, $\rho\ge0$. Finitely many linear equalities and inequalities cut out a polyhedron; it is bounded because every feasible $\rho$ is a probability vector (sum the flow equations), hence a polytope. By Section 2 every point of it is realised by the stationary policy $\pi_\rho$.

(d) $(J_r,J_c)=\frac{1}{1-\gamma}(\langle\rho,r\rangle,\langle\rho,c\rangle)$ is a linear map; the linear image of a convex set is convex, and by the completeness theorem the image over all policies equals the image over $\mathcal Q(\mu)$.

Exercise 8.2 — Convexity of the dual function, in both conventions

(a) Prove that $D(\lambda)=\max_\pi L(\pi,\lambda)$ is convex on $\mathbb R^m_+$ and that $D(\lambda)\ge P^\star$. (b) Altman minimises a cost $C(\pi)$ subject to $D_k(\pi)\le V_k$ and defines $J^\lambda(\pi)=C(\pi)+\langle\lambda,D(\pi)-V\rangle$. Show that his dual function $\tilde D(\lambda)=\min_\pi J^\lambda(\pi)$ is concave, that $\tilde D(\lambda)\le C^\star$, and that his dual problem is a maximisation. (c) Compute $D(\lambda)$ for the walkthrough example ($J_r=p$, $J_c=2p$, $d=1$) and check convexity.

Show answer

(a) For fixed $\pi$, $\lambda\mapsto L(\pi,\lambda)=J_r(\pi)-\langle\lambda,J_c(\pi)-d\rangle$ is affine. For $\lambda^1,\lambda^2$ and a weight $\kappa\in[0,1]$: $D(\kappa\lambda^1+(1-\kappa)\lambda^2)=\max_\pi[\kappa L(\pi,\lambda^1)+(1-\kappa)L(\pi,\lambda^2)]\le\kappa\max_\pi L(\pi,\lambda^1)+(1-\kappa)\max_\pi L(\pi,\lambda^2)$, because a max of a sum is at most the sum of the maxes. Weak duality: for feasible $\pi$ and $\lambda\ge0$ each $\lambda_i(J_{c_i}(\pi)-d_i)\le0$, so $L(\pi,\lambda)\ge J_r(\pi)$; take max over $\pi$ on the left and over feasible $\pi$ on the right.

(b) Same argument with min in place of max: a min of a sum is at least the sum of the mins, so $\tilde D(\kappa\lambda^1+(1-\kappa)\lambda^2)\ge\kappa\tilde D(\lambda^1)+(1-\kappa)\tilde D(\lambda^2)$: concave. For feasible $\pi$, $J^\lambda(\pi)\le C(\pi)$, hence $\tilde D(\lambda)\le C^\star$ and the tightest lower bound is $\max_{\lambda\ge0}\tilde D(\lambda)$: Altman's (3.14), $\sup_\lambda\min_u J^\lambda_\alpha$. The two conventions are mirror images under $r=-C$.

(c) $L(p,\lambda)=p-\lambda(2p-1)=(1-2\lambda)p+\lambda$; $D(\lambda)=\lambda+\max(0,1-2\lambda)$, i.e. $1-\lambda$ for $\lambda\le\frac12$ and $\lambda$ for $\lambda\ge\frac12$: the maximum of two affine functions, convex, with a kink at $\lambda^\star=\frac12$ and $D^\star=\frac12=P^\star$.

Exercise 8.3 — The two-state example by LP reasoning

For the two-state CMDP of Section 1 ($\gamma=\frac12$, $\mu=\delta_{s_1}$, deterministic alternation, fast: reward 1, cost 1 in $s_1$ and 2 in $s_2$; $d=1.2$): (a) write the flow constraints and solve for the state marginals; (b) write the LP in the variables $p_1,p_2$ and solve it; (c) find the multiplier $\lambda^\star$ and verify $D(\lambda^\star)=P^\star$; (d) check Altman's randomisation bound.

Show answer

(a) $\rho(s_1)=(1-\gamma)\cdot1+\gamma\rho(s_2)=\frac12+\frac12\rho(s_2)$ and $\rho(s_2)=\frac12\rho(s_1)$, so $\rho(s_1)=\frac23$, $\rho(s_2)=\frac13$; with $\rho(s_i,\text{fast})=\rho(s_i)p_i$.

(b) $J_r=2\big(\tfrac23p_1+\tfrac13p_2\big)=\tfrac43p_1+\tfrac23p_2$, $J_c=2\big(\tfrac23p_1\cdot1+\tfrac13p_2\cdot2\big)=\tfrac43(p_1+p_2)$. Maximise $\tfrac43p_1+\tfrac23p_2$ s.t. $p_1+p_2\le0.9$, $0\le p_i\le1$. Each unit of budget buys $1$ of return in $s_1$ and $\tfrac12$ in $s_2$, so the LP fills $p_1$ first: $p_1=0.9$, $p_2=0$, $P^\star=1.2$. (The vertex $(0.9,0)$ of the feasible polygon is the optimum; the objective is not parallel to any edge, so it is unique.)

(c) Per state the penalised reward of fast is $1-\lambda$ in $s_1$ and $1-2\lambda$ in $s_2$. Randomising in $s_1$ at the optimum requires indifference there: $\lambda^\star=1$; then $1-2\lambda^\star\lt0$ confirms slow in $s_2$. Directly: $D(\lambda)=\tfrac43\max(0,1-\lambda)+\tfrac23\max(0,1-2\lambda)+1.2\lambda$ equals $2-\tfrac{22}{15}\lambda$ on $[0,\tfrac12]$ (fast preferred in both states), $\tfrac43-\tfrac{2}{15}\lambda$ on $[\tfrac12,1]$ and $1.2\lambda$ beyond: decreasing, decreasing, then increasing, so it is minimised at $\lambda^\star=1$ with $D^\star=1.2=P^\star$.

(d) The LP has $|\mathcal S|+m=3$ constraints besides positivity and 4 variables $\rho(s_i,a)$; a basic solution has at most 3 nonzeros, so at most one state carries two actions. Indeed only $s_1$ randomises.

Exercise 8.4 — Sustained oscillation of dual ascent in the linear model

Assume $K_I\ne0$. In the linear loop of Section 5, $e_{k+1}=e_k-c(\lambda_k-\lambda^\star)$ with $\lambda_k=K_Pe_k+K_II_k$, $I_k=I_{k-1}+e_k$: (a) derive the state matrix $M$ for $x_k=(e_k,\delta_{k-1})$, $\delta_k=I_k-\lambda^\star/K_I$; (b) show that for $K_P=0$ and $0\lt cK_I\lt4$ the eigenvalues have modulus exactly 1, and compute the oscillation period for $c=0.4$, $K_I=0.1$; (c) show that, while the eigenvalues are complex, $K_P\gt0$ gives modulus $\sqrt{1-cK_P}$, check that they are complex for $c=0.4$, $K_I=0.1$, $K_P=0.5$, and find the number of iterations in which the envelope halves; (d) state the stability region.

Show answer

(a) $\lambda_k-\lambda^\star=K_Pe_k+K_I(\delta_{k-1}+e_k)$, so $e_{k+1}=(1-c(K_P+K_I))e_k-cK_I\delta_{k-1}$ and $\delta_k=\delta_{k-1}+e_k$: $M=\begin{bmatrix}1-c(K_P+K_I)&-cK_I\\1&1\end{bmatrix}$, $\operatorname{tr}M=2-c(K_P+K_I)$, $\det M=1-c(K_P+K_I)+cK_I=1-cK_P$.

(b) $K_P=0$: $\det M=1$, so the eigenvalues are $z=\frac{\operatorname{tr}M}{2}\pm\sqrt{(\operatorname{tr}M/2)^2-1}$; for $|\operatorname{tr}M|\lt2$, i.e. $0\lt cK_I\lt4$, they are a complex pair with $|z|^2=\det M=1$: $z=e^{\pm i\vartheta}$, $\cos\vartheta=1-cK_I/2$. Neither growth nor decay: a sustained oscillation. For $c=0.4$, $K_I=0.1$: $\cos\vartheta=0.98$, $\vartheta=\arccos(0.98)\approx0.2003$, period $2\pi/\vartheta\approx31$ iterations.

(c) With $K_P\gt0$ and complex eigenvalues, $|z|^2=z\bar z=\det M$, so $|z|=\sqrt{1-cK_P}$. For $c=0.4$, $K_I=0.1$, $K_P=0.5$: $\operatorname{tr}M=1.76$, $\det M=0.8$, and $(\operatorname{tr}M)^2=3.0976\lt4\det M=3.2$, so the pair is complex with $|z|=\sqrt{0.8}\approx0.894$; the envelope halves after $\ln2/\ln(1/\sqrt{0.8})\approx6.2$ iterations. Proportional action is damping; integral action alone is a pure oscillator.

(d) Jury conditions for a $2\times2$ system: $|\det M|\lt1$ and $|\operatorname{tr}M|\lt1+\det M$, i.e. $0\lt cK_P\lt2$, $cK_I\gt0$ and $c(2K_P+K_I)\lt4$. Note that the loop gain $c=\eta b^2$ multiplies the controller gains: doubling the policy learning rate has the same effect on the multiplier loop as doubling $K_P$ and $K_I$, and scaling the cost (and the budget) by a factor $\kappa\gt0$ scales $b$ by $\kappa$ and hence $c$ by $\kappa^2$: a cost-scale sensitivity of the same kind as the reward-scale sensitivity discussed in Section 5. (With curvature, Section 5(c), $\det M=a-cK_P$ and the same algebra gives the region $a-1\lt cK_P\lt a+1$, $cK_I\gt0$, $c(2K_P+K_I)\lt2(1+a)$.)

Exercise 8.5 — CVaR of a discrete cost and the Gaussian shortcut

An episode's cost is $Z=0$ w.p. $0.9$, $10$ w.p. $0.08$, $100$ w.p. $0.02$. (a) Compute $\mathbb E[Z]$, $\mathrm{VaR}_{0.95}(Z)$ and $\mathrm{CVaR}_{0.95}(Z)$ (tail fraction $5\%$) by averaging the worst $5\%$. (b) Verify with the Rockafellar–Uryasev formula, checking the candidate values $\nu\in\{0,10,100\}$. (c) A WCSAC-style Gaussian critic with the same mean and variance reports $\mathrm{CVaR}$ at tail fraction $\alpha=0.05$ as $\mu+\sigma\varphi(\Phi^{-1}(\alpha))/\alpha$. Compute it and comment.

Show answer

(a) $\mathbb E[Z]=0.8+2=2.8$. $F_Z(0)=0.9\lt0.95\le F_Z(10)=0.98$, so $\mathrm{VaR}_{0.95}=10$. The worst $5\%$ consists of the $2\%$ mass at $100$ and $3\%$ of the mass at $10$: $\mathrm{CVaR}_{0.95}=(0.02\cdot100+0.03\cdot10)/0.05=46$.

(b) $H(\nu)=\nu+20\,\mathbb E[(Z-\nu)_+]$: $H(0)=20\cdot2.8=56$; $H(10)=10+20\cdot0.02\cdot90=46$; $H(100)=100$. $H$ is piecewise linear with kinks at the atoms, so its minimum is at a kink: $\min_\nu H=46$ at $\nu^\star=10=\mathrm{VaR}_{0.95}$, as the theory says.

(c) $\mathbb E[Z^2]=8+200=208$, $\sigma^2=208-2.8^2=200.16$, $\sigma=\sqrt{200.16}\approx14.15$. Write $z_{0.95}=\Phi^{-1}(0.95)$; then $\Phi^{-1}(0.05)=-z_{0.95}\approx-1.645$ and $\varphi(z_{0.95})\approx0.1031$. The true CVaR of this fitted Gaussian law is $2.8+\sqrt{200.16}\,\varphi(z_{0.95})/0.05\approx32$ (it lies strictly between $31.982$ and $31.984$). The Gaussian critic underestimates the actual discrete tail mean ($46$) by about $30\%$: the two-moment fit does not preserve the large tail atom. A certificate using only this Gaussian-CVaR estimate would accept a tail budget of $32$, while the actual policy violates it because its tail CVaR is $46$. This illustrates the Gaussian-critic approximation used by WCSAC at $\alpha=0.05$; a critic with more atoms or the sample-based $\nu$ update of Chow et al. can model the tail beyond two moments, with their estimation errors still to be checked.

Exercise 8.6 — Why the multiplier must be part of the state (monitoring problem)

In the monitoring problem (Section 3: states $R_0,R_1,R_2$; from $R_0$ go to $R_1$ or $R_2$; from $R_i$ stay or return to $R_0$; average reward $\mathbf 1(s=R_0)$; constraints $V_i\ge c=\frac13$ for the fractions of time in $R_1$, $R_2$): (a) show that $\lambda^\star=(1,1)$ is dual optimal and that every policy maximises $L(\cdot,\lambda^\star)$; (b) show that for $\lambda\ne(1,1)$ no Lagrangian maximiser is optimal, and classify the maximisers; (c) describe the trajectory generated by the state-augmented execution and explain why a policy $\pi(a\mid s)$ with a fixed $\lambda$ cannot produce it while $\pi(a\mid s,\lambda)$ with the dual dynamics can; (d) contrast with the Sauté augmentation.

Show answer

(a) Time fractions satisfy $V_0+V_1+V_2=1$. At $\lambda=(1,1)$, $L=V_0+V_1+V_2-\tfrac23=\tfrac13$ for every policy, so $D(1,1)=\tfrac13$. The fair-coin policy is feasible with $V_0=\tfrac13$, so $P^\star\ge\tfrac13$; weak duality gives $P^\star\le D(1,1)=\tfrac13$. Hence $P^\star=D^\star=\tfrac13$, $\lambda^\star=(1,1)$ is optimal, and $\Pi(\lambda^\star)$ is the set of all policies.

(b) Because the agent must leave $R_0$ at every step, the long-run fractions $(V_0,V_1,V_2)$ of any policy satisfy $V_0\le\tfrac12$, and every such point of the simplex is attained (from $R_0$ pick $R_1$ with probability $q$, stay in $R_i$ with probability $a_i$). The achievable set is thus the quadrilateral with vertices $v_1=(0,1,0)$ (stay in $R_1$), $v_2=(0,0,1)$ (stay in $R_2$), $v_3=(\tfrac12,\tfrac12,0)$ (alternate $R_0,R_1$), $v_4=(\tfrac12,0,\tfrac12)$ (alternate $R_0,R_2$). $L=V_0+\lambda_1V_1+\lambda_2V_2-\tfrac{\lambda_1+\lambda_2}{3}$ is linear in the fractions, so it is maximised on a face; up to the constant $-\tfrac{\lambda_1+\lambda_2}{3}$ its values at the four vertices are $\lambda_1,\ \lambda_2,\ \tfrac{1+\lambda_1}{2},\ \tfrac{1+\lambda_2}{2}$. The optimum $(\tfrac13,\tfrac13,\tfrac13)$ lies in the relative interior of the quadrilateral in the plane $V_0+V_1+V_2=1$, so it maximises $L$ only if $L$ is constant on the whole quadrilateral, i.e. $\lambda_1=\lambda_2=1$. For $\lambda_1\gt\lambda_2$, the maximizing face is $v_1$ if $\lambda_1\gt1$, $v_3$ if $\lambda_1\lt1$, and the edge $v_1$–$v_3$ if $\lambda_1=1$; every maximiser has $V_2=0$ and is infeasible. The classification for $\lambda_2\gt\lambda_1$ is symmetric. For $\lambda_1=\lambda_2\lt1$, the maximizing fractions form the edge $v_3$–$v_4$, with $V_0=\tfrac12$ and $V_1+V_2=\tfrac12\lt\tfrac23$, so they are infeasible; representative policies alternate $R_0$ with one region, or mix these alternating modes. For $\lambda_1=\lambda_2\gt1$, the maximizing fractions form the edge $v_1$–$v_2$, with $V_0=0$. One stationary representative enters $R_1$ with probability $q$ and $R_2$ otherwise, then stays in the chosen region. It is feasible in expectation when $q\in[\tfrac13,\tfrac23]$, while each of its trajectories starves one region. These statements classify long-run fractions and give representative policies; maximising an average-reward Lagrangian does not by itself determine each transient action, and a finite initial route followed by the same tail does not change the limiting fractions. A history-dependent maximiser can meet both visit constraints on its single trajectory: stay $n$ steps in $R_1$, then $n$ steps in $R_2$, for $n=1,2,\dots$, passing through $R_0$ once per block. Its $O(\sqrt T)$ visits to $R_0$ yield fractions $(0,\tfrac12,\tfrac12)$. Every policy on this maximizing edge has return $0$, against $P^\star=\tfrac13$. Thus, for every $\lambda\ne(1,1)$, no Lagrangian maximiser is constrained-optimal.

Why every point with $0\lt V_0\le\tfrac12$ is attained: write $a_i=1-b_i$, so $b_i$ is the probability of returning from $R_i$ to $R_0$, and let $q_1=q$, $q_2=1-q$. In the long run the flow from $R_0$ into $R_i$ equals the flow back, $V_0q_i=V_ib_i$. Choosing $q_i=V_i/(1-V_0)$ and $b_i=V_0/(1-V_0)$ (which lies in $(0,1]$ exactly because $0\lt V_0\le\tfrac12$) satisfies both balance equations, and the stationary fractions of this chain are then $(V_0,V_1,V_2)$; a region with $V_i=0$ is never entered. Example: $(\tfrac13,\tfrac13,\tfrac13)$ needs $q=b_1=b_2=\tfrac12$, the fair-coin policy of (a). For stationary policies, points with $V_0=0$ are attained in expectation by randomising once at the start between staying forever in $R_1$ or in $R_2$; single trajectories of that policy have fractions $(0,1,0)$ or $(0,0,1)$. History-dependent policies can also attain mixed fractions on a single trajectory, as the growing-block construction above shows.

The count behind $O(\sqrt T)$: after the blocks of lengths $1,\dots,N$ in both regions the agent has spent $2\sum_{n=1}^Nn=N(N+1)$ steps in $R_1\cup R_2$ and $2N$ steps in $R_0$, so $T\approx N^2$ and the $R_0$ visits number about $2\sqrt T$. A partially finished block has length at most $N+1\approx\sqrt T$, negligible against $T$, so the fractions in $R_1$ and $R_2$ tend to $\tfrac12$ and that in $R_0$ to $0$.

(c) Choose a canonical maximizing mode for each fixed multiplier: at $R_0$ route toward the region with the larger multiplier, choosing $R_1$ at a tie; at $R_i$ stay if $\lambda_i\gt1$ and $\lambda_i\ge\lambda_j$, and otherwise return through $R_0$. Thus equal prices above $1$ keep the current region, while equality at the threshold $1$ selects a returning endpoint of the tied maximizing face. If both multipliers are below $1$, the representative mode alternates $R_0$ with the chosen region. These modes realise the maximizing faces in (b); the face classification alone does not force these particular transient actions for every maximiser. Execute this chosen selector as $\pi(\cdot\mid s,\lambda_k)$ while running the projected epoch update of Section 7. A region's multiplier rises when its epoch visit fraction is below $1/3$ and falls, subject to projection at zero, when that fraction is above $1/3$. Consequently the chosen mode can change as deficits accumulate and are repaid. A concrete per-step instance with step size $1$, initial state $R_0$ and initial multipliers $(0,0)$ enters an exact six-step cycle after five steps; its visit fractions converge to $(\tfrac13,\tfrac13,\tfrac13)$. This directly verified instance does not require an unbiased-epoch assumption. The almost-sure long-run feasibility and expected near-optimality conclusion of Section 7's Theorem 1 applies only under its stated exact-maximiser setting and assumptions A1–A3: strict feasibility, the required bound on the violation vector, and conditional unbiasedness of each epoch estimate. Maximising the long-run Lagrangian does not automatically make a finite epoch started from an arbitrary state unbiased; the paper's Appendix II treats biased epochs under additional conditions. A fixed-$\lambda$ stationary policy has no changing deficit input. For $\lambda\ne(1,1)$ its maximizing fractions are infeasible or have zero return by (b); at $(1,1)$ the Lagrangian leaves all policies tied. Moreover, a state-only policy cannot implement the same deterministic deficit-dependent selector uniformly over histories that reach the same physical state with different multipliers and require different actions. Conditioning on the multiplier supplies that additional history summary. This is a recovery and execution-rule issue: the fair-coin policy is a legitimate optimal stationary Markov policy, so state-only policies can still achieve the optimal visit fractions.

(d) Sauté augments with the remaining budget of a finite, almost-sure constraint, which the policy must respect with probability one. There augmentation is in general needed for representation: an optimal policy may have to condition on how much budget is left, which no policy in $s$ alone can observe. A policy in $s$ alone can still be feasible, for instance by always choosing a zero-cost action when one exists, but typically only at a loss in return. Calvo-Fullana augment with the multiplier of a long-run average constraint; there the augmentation repairs primal recovery.

Key Papers

PaperVenueContributionWhy read it
Altman, Constrained Markov Decision ProcessesBook, Chapman & Hall/CRC 1999Occupation-measure LPs, Lagrangian duality, at most $K$ randomisationsThe reference for Sections 1–2; cost-minimisation convention
Paternain, Chamon, Calvo-Fullana, Ribeiro, Constrained RL Has Zero Duality GapNeurIPS 2019Zero duality gap under Slater; $O(\epsilon/(1-\gamma)^2)$ gap for $\epsilon$-universal policies with unnormalised returns (printed as $\epsilon/(1-\gamma)$, see Section 3); dual descent analysisThe theoretical licence for every Lagrangian method
Calvo-Fullana, Paternain, Chamon, Ribeiro, State Augmented Constrained RLIEEE TAC 69(7), 2024CMDPs that no weighted reward solves; multiplier as state; feasible near-optimal trajectoriesMakes the primal-recovery problem concrete
Tessler, Mankowitz, Mannor, Reward Constrained Policy OptimizationICLR 2019Penalised reward, three timescales, a.s. convergence to a feasible fixed pointTemplate of PPO-/SAC-Lagrangian baselines
Stooke, Achiam, Abbeel, Responsive Safety in RL by PID Lagrangian MethodsICML 2020Multiplier update as integral control; P and D terms; reward-scale invariance via $\beta_\nabla$Explains and fixes the oscillations you will see in practice
Ding, Zhang, Başar, Jovanović, Natural Policy Gradient Primal-Dual Method for CMDPs; journal version (source of the constants quoted in Sections 3–4): Ding, Zhang, Duan, Başar, Jovanović, Convergence and Sample Complexity of Natural Policy Gradient Primal-Dual Methods for Constrained MDPsNeurIPS 2020; journal version JMLR 26(256):1–76, 2025Dimension-free $O(1/\sqrt T)$ average-iterate convergence for softmax NPG-PDFirst global rate; the MWU view of the primal step
Ding, Wei, Zhang, Ribeiro, Last-Iterate Convergent Policy Gradient Primal-Dual MethodsNeurIPS 2023RPG-PD (regularised, linear rate to a neighbourhood of a regularised saddle) and OPG-PD (optimistic)How regularisation stops the cycling
Montenegro, Mussi, Papini, Metelli, Last-Iterate Global Convergence of Policy Gradients for Constrained RLNeurIPS 2024C-PG: ridge-regularised dual, last-iterate rates under weak gradient domination, general parametrisationsThe bias–rate trade-off of dual regularisation made explicit
Chow, Ghavamzadeh, Janson, Pavone, Risk-Constrained RL with Percentile Risk CriteriaJMLR 18(167), 2018CVaR- and chance-constrained MDPs, Lagrangian gradients with the VaR parameter, augmented-state actor-criticThe landmark risk-constrained formulation
Yang, Simão, Tindemans, Spaan, WCSACAAAI 2021Gaussian safety critic with closed-form CVaR constraint in SAC-LagrangianSimplest risk-averse deep baseline; know its Gaussian assumption
Kim et al., Spectral-Risk Safe RL with Convergence GuaranteesNeurIPS 2024Spectral risk constraints via duality; bilevel SRCPO with convergence to an optimum for finite, discretised problems (finite augmented spaces, finitely many $\beta$)Generalises CVaR-constrained RL
Sootla et al., Sauté RLICML 2022Budget-augmented state and reshaped cost; Bellman equation; almost-sure constraintsThe principal state-augmentation approach
Paternain, Calvo-Fullana, Chamon, Ribeiro, Safe Policies for RL via Primal-Dual MethodsIEEE TAC 68(3):1321–1336, 2023Chance constraints relaxed to CMDP constraints with safety-preserving slacksBridges invariance-type safety and the Lagrangian machinery
Dai et al., Safe RLHFICLR 2024 (spotlight)Reward and cost models, Lagrangian PPO for LLM alignmentThe CMDP template in a very different domain
Ray, Achiam, Amodei, Benchmarking Safe Exploration in Deep RLOpenAI report 2019Safety Gym, cost-rate metric, Lagrangian vs CPO comparisonWhy Lagrangian methods are the default baselines

Further reading: García & Fernández, JMLR 2015 (the classic taxonomy: constrained criteria are one of its "modified optimality criterion" branches), Gu et al., IEEE TPAMI 2024 (comprehensive review including a comparison of CMDP sample complexities), Wachi, Shen, Sui, IJCAI 2024 (how the constraint formulations relate), Wu et al., ICLR 2024 (CAL).

Flashcards