7. Viability & Safe Value Functions
Viability kernels, learnable safety measures, the penalty threshold theorem, entropy regularisation and uncertainty-aware safe RL
This module assumes:
- States, trajectories, feedback, and well-defined dynamics (Primer D)
- MDPs, policies, discounted returns, and geometric sums (Primer E)
- Value functions and Bellman equations (Primer E)
- Value iteration and contraction arguments (Primer E)
- Suprema, infima, and sets of optimizers (Primer B)
- Constrained optimization, Lagrangians, and duality (Module 2)
- Entropy and KL divergence (Primer C)
- GP posterior means, variances, and uncertainty (Module 3)
- Forward invariance and safe sets (Primer D)
- Dynamic programming, terminal sets, and tube MPC (Primer D)
Core reading. Compute a small viability kernel and count viable actions before reading the discounted penalty setup. Then study the strict safety conditions and threshold assumptions, the threshold walkthrough, and the gridworld.
Practice route. Try the three readiness checks. If a skill is rusty, use its exact review link, then return. Work through Easy P1–P4, Medium P5–P8, and Hard P9–P12; each has a separate hint and a full worked solution. Reattempt a missed problem later without opening the answer.
Optional research reading. The continuous-time boundary/continuity discussion, entropy-regularized theorems, recent learned-model filters, and research connections are extensions. Begin the entropy section after reviewing entropy in Primer C; distinguish the finite deterministic theorem from continuous-action experiments.
Try these before opening the answer. The review links lead to earlier material.
- If every action from a nonfailed state reaches failure next, is that state viable? Review transition models.
- What is $\sum_{t=0}^{\infty}(1/2)^t$? Review geometric series.
- If safe and unsafe actions tie for maximum return, are all maximizing actions safe? Review argmax and ties.
Show readiness answers
The state is unviable: no controller can avoid the next failure. The geometric sum is $1/(1-1/2)=2$. At a tie an unsafe maximizer still exists, so a theorem about all optimal actions being safe needs a strict separation.
Book contents · Apply this chapter to a real decision · Glossary
Modules 4–6 kept a learner safe by never evaluating a parameter whose safety was not certified. This module changes the object of study: which states are safe, and what it takes for an optimal controller to respect that. The central question, posed by Massiani, Heim, Solowjow and Trimpe, is one every RL practitioner answers by reflex when writing a reward function: how large must the failure penalty be? The answer is a theorem with an exponential in it.
1. Failure Sets, Viable Sets and the Viability Kernel
Start with three states. Let $A$ have an action that stays at $A$ and another that moves to $B$. Every action at $B$ reaches failed state $F$ one step later. Then $A$ is viable by choosing its self-loop forever, while $B$ is already doomed although it has not yet failed. The viable action at $A$ is the self-loop; going to $B$ leaves the kernel. The rest of this page asks how to learn such distinctions and how to choose penalties so that reward maximization respects them.
Safety in this module is a state constraint: there is a set of failure states that the system must never visit. The difficulty is that "not failed yet" is not the same as "safe". A car sliding on ice towards a wall has not crashed, but no input can prevent the crash any more. Viability theory (Aubin, Viability Theory, 1991/2009) names the states from which failure can still be avoided forever; that set, and not the complement of the failure set, is the right notion of a safe set.
Set notation used below (Primer 0): $X\setminus Y$ is the set of points of $X$ that are not in $Y$; $X\times U$ is the set of all pairs $(x,u)$ (for $X=\{0,1\}$ and $U=\{-1,1\}$ it has four elements); $\exists$ reads "there exists" and $\forall$ "for every"; an intersection $\bigcap_{x\in X_V}\mathcal U_{\mathrm{safe}}(x)$ keeps the elements that belong to every set $\mathcal U_{\mathrm{safe}}(x)$. The order of quantifiers matters: $\exists u\ \forall t$ asks for one controller that works for the entire trajectory, whereas $\forall t\ \exists u$ would allow a different controller for each horizon $t$.
A measure assigns a size to sets. The counting measure gives a finite set its number of elements, so integrating against it is summing: $\int g\,d\mu=\sum_i g(i)$. The Lebesgue measure gives intervals their length and boxes their volume, so integrating against it is the ordinary integral, e.g. $\int_0^1 2t\,dt=1$; a single point (or any finite set) has Lebesgue measure zero. A point mass $\delta_{t_f}$ instead gives the single point $t_f$ mass $1$, so $\int g\,d\delta_{t_f}=g(t_f)$. Measurable sets and functions are those for which these sizes and integrals are defined (a function $g$ is measurable if every set $\{x:g(x)>b\}$ is measurable; continuous functions are); in this module the word is a technical regularity assumption that can be read as "nice enough to integrate". Two consequences are used later: in a continuous action space a viable state whose only viable input is a single point has viable-action volume zero (Section 2), and a one-time failure charge is a point mass in time, not an integral of a bounded rate (Section 3).
A closed set contains the limits of all convergent sequences of its points. So for a cart that must not hit a wall at position $L$ (Exercise 7.1), the closed failure set $X_F=\{x : x_1\ge L\}$ contains the wall itself: touching it counts as failure. For a set $Y$, the boundary $\partial Y$ consists of the points that can be approached both from inside $Y$ and from outside it, and the interior is $\mathrm{Int}\,Y=Y\setminus\partial Y$. In $\mathbb{R}^n$ a set is compact iff it is closed and bounded, and a continuous real function on a nonempty compact set attains its minimum and maximum; both facts are used in Sections 2 and 4.
Here $f^{-1}(X_V)$ is a preimage: all pairs whose successor lies in $X_V$. It does not require $f$ to be invertible. The slice $Q_V[x]$ fixes the state and lists its viable inputs. Projecting $Q_V$ onto the state space means retaining the first coordinate of every pair; this differs from the nearest-action optimization called a projection in Section 2.
Computing the kernel on a finite space
On a finite state-input space the kernel is a greatest fixed point and can be computed by a decreasing iteration. This is what the explorer below runs, and it is also the algorithm behind shield synthesis (Section 7).
- $X^0 \leftarrow X \setminus X_F$ // optimistic start: every state that has not failed yet
- repeat
- $X^{k+1} \leftarrow \{x \in X^k : \exists u \in U,\ f(x,u) \in X^k\}$ // keep the states that can stay one more step
- until $X^{k+1} = X^k$
- return $X_V = X^k$ and $Q_V = \{(x,u) : x \in X_V,\ f(x,u) \in X_V\}$
Why it works. By induction (Primer 0), $X^k$ is the set of states from which failure can be avoided for $k$ steps. The sequence is decreasing, so on a finite space it stabilises after at most $|X|$ iterations, and the limit is the largest set $Y \subseteq X \setminus X_F$ with the invariance property $\forall x \in Y\ \exists u : f(x,u) \in Y$, which is precisely $X_V$. On a continuous state space Hamilton–Jacobi reachability (see Primer D) approximates this object on a grid: $X_U$ is the unavoidable-failure backward-reachable tube of $X_F$, and $X_V$ is its complement (Bansal, Chen, Herbert & Tomlin, CDC 2017; Module 10).
Induction. $X^0=X\setminus X_F$ is the set of states that survive $0$ further transitions (they have not failed). If $X^k$ is exactly the set of states that can survive $k$ further transitions, then a state survives $k+1$ transitions iff it has not failed and some first input leads into $X^k$, which is the update rule; so $X^{k+1}$ is exactly the set of states that can survive $k+1$ transitions.
Termination and the limit. Every iteration that changes the set deletes at least one state, so on a finite space the loop stops after at most $|X|$ rounds, at a fixed point $X^\ast$ (a set that the update leaves unchanged). Every state of $X^\ast$ has an input leading back into $X^\ast$; choosing such an input at each state of $X^\ast$ gives a feedback controller that never leaves $X^\ast\subseteq X\setminus X_F$, so $X^\ast\subseteq X_V$. Conversely, a viable state survives any number of transitions, so it lies in every $X^k$ and hence in $X^\ast$. Thus $X^\ast=X_V$.
Tiny example. Single-input transitions $a\to a$, $b\to c$, $c\to F$ with $F$ failed: $X^0=\{a,b,c\}$, $X^1=\{a,b\}$ ($c$ can only fail), $X^2=\{a\}$ ($b$ can only reach $c$), $X^3=X^2$. So $X_V=\{a\}$.
The tube meant here is the unavoidable-failure tube: $\{x:\forall u\in\mathcal U,\ \exists t<\infty,\ \varphi_x^u(t)\in X_F\}$. It is not the set from which some controller can reach failure. For example, a shelf state can be driven off the edge, but remains viable because another controller can keep it safe.
Take $\ell(x)=\operatorname{dist}(x,X_F)-\operatorname{dist}(x,X\setminus X_F)$, where $\operatorname{dist}(x,S)=\inf_{y\in S}\|x-y\|_2$. Thus $\ell$ is positive outside failure, negative in its interior and zero on the boundary (for a nonempty closed failure set with nonempty complement). Then $V_{\mathrm{BRT}}>0$ certifies a trajectory with a positive safety margin, and $V_{\mathrm{BRT}}<0$ rules out safety. The zero level requires additional conventions and assumptions. For example, under $\dot x=-x$ with failure $x\le0$, every $x>0$ is safe but $\inf_{t\ge0}x e^{-t}=0$; the failed state $x=0$ also has value zero. So neither $\{V_{\mathrm{BRT}}\ge0\}$ (which contains the failed state $0$) nor $\{V_{\mathrm{BRT}}\gt0\}$ (which is empty) equals $X_V=\{x\gt0\}$: identifying a level set of this infinite-horizon value with $X_V$ needs extra conventions.
Here $s_a^+=f(s,a)$ is the successor under action $a$. Let $BV$ denote the right-hand side as a function of $s$. A maximum and a minimum each change by at most the largest change in their arguments, and the term $(1-\gamma)\ell(s)$ does not depend on $V$, so $|BV(s)-BW(s)|\le\gamma\max_a|V(s_a^+)-W(s_a^+)|$ and therefore $\|BV-BW\|_\infty\le\gamma\|V-W\|_\infty$, with $\|V-W\|_\infty=\max_s|V(s)-W(s)|$ on a finite state space. This contraction property is what makes value iteration converge (and, with the usual step-size conditions, Q-learning).
Massiani et al. (Section VI-A) use a piecewise-affine model that we will reuse for the threshold theorem. A robot drives on a shelf of length $L$ at speed $\pm v$ or stands still: $X = [-L, L]$, $U = \{-v, 0, v\}$,
On $[0, L)$ the robot controls its motion. If it crosses the ledge at $x = 0$ it falls at constant speed $L/T_f$ and breaks on the ground at $x = -L$, where the trajectory stops. Hence $X_V = [0, L]$ (the robot can stand still anywhere on the shelf, and at the wall $x = L$ it is stuck, $\dot x = 0$) and $X_U = [-L, 0)$: the paper writes $(-L, 0)$ for the doomed but not yet failed part, and the failure state $-L$ belongs to $X_U$ as well. Every unviable trajectory reaches $X_F$ within time $T_f$, exactly the uniform time-to-failure bound that Assumption 1 in Section 4 asks for. Note the discontinuity of $f$ at $x = 0$: the fall is not a Lipschitz continuation (see Primer B) of the driving dynamics. Section 4 explains why this is not an accident.
For this toy model we use the intended event-driven trajectory convention: commanding zero at the ledge keeps the robot there, while commanding motion over the ledge initiates the constant-speed fall. This convention is part of the model. The discontinuous differential equation alone does not establish uniqueness at the ledge, so the usual Lipschitz existence-and-uniqueness result cannot be applied there.
The CoRL 2019 paper introduces its objects on a five-state grid world: a hovering spaceship pulled towards the ground by a gravity that is stronger near the ground; it can fire two levels of thrust or let itself fall. With failure set $S_F = \{5\}$ (the crash), the viability kernel is $S_V = \{1, 2, 3\}$. Two details are worth remembering. State $3$ is viable but can no longer reach the other viable states: avoiding failure does not require ergodicity (see Module 6). State $4$ is neither in $S_V$ nor in $S_F$: it has not failed yet but cannot avoid failing, the "sliding on ice" situation. Finally, from state $3$ exactly one action keeps the ship alive, which is what the safety measure of the next section quantifies as $\Lambda(3) = 1$.
2. A Learnable Safety Measure
A binary label "viable / unviable" hides how close to failure a state is. Heim, von Rohr, Trimpe & Badri-Spröwitz, CoRL 2019 propose a graded notion: count the viable actions. This section uses their notation, $s' = T(s, a)$ with $q = (s, a) \in Q = S \times A$.
Learning the measure from samples, and why failures are informative
The goal is a large, conservative estimate $\hat Q_V \subseteq Q_V$ (see Module 4) obtained model-free. The agent picks an action $a$ in state $s$ and receives the tuple $(s', \mathrm{failed})$. Two kinds of samples arrive: a failure is the only direct observation of the ground truth, $\Lambda_Q(q) = 0$; a success only yields the current estimate $\hat\Lambda(s')$ of the next state's measure, which is itself computed from $\hat\Lambda_Q$. The learning signal therefore flows from failures outwards.
Proof idea (Heim et al., CoRL 2019, App. A): from an unviable state every trajectory fails without revisiting a state, so within at most $|S|$ steps. Pairs that fail in one step are set to $0$ by their first update and stay there; after that, pairs whose successor only has such actions copy $\hat\Lambda(s')=0$, and so on backwards along every doomed chain. Exhaustive updates make each stage happen eventually. The GP algorithm below uses a probability-thresholded estimate and does not inherit this theorem.
Why the two conditions. Non-failure samples only ever copy estimates and failures only ever lower them, so a viable pair that is wrongly assigned $0$ can be repaired only through a successor state whose estimate is still positive; once the zeros close a loop they are permanent. Optimism is needed so that errors are only ever in the direction that failures can fix, and it has to hold pair by pair: the invariant $Q_V \subseteq \hat Q_V$ survives every update (a viable pair's successor $s' \in S_V$ keeps at least its $\Lambda(s') \ge 1$ viable actions positive), and together with the theorem it forces $\hat Q_V = Q_V$, hence $\hat\Lambda = \Lambda$. The state-wise $\hat\Lambda \ge \Lambda$ does not suffice: take one viable state $s$ with a safe self-loop $a_1$ and a failing action $a_2$, initialised $\hat\Lambda_Q(s,a_1) = 0$, $\hat\Lambda_Q(s,a_2) = 1$, so that $\hat\Lambda(s) = 1 = \Lambda(s)$; if $a_2$ is sampled first, $\hat\Lambda(s)$ drops to $0$ and the self-loop copies $0$ forever. Infinite sampling is what lets every unviable pair eventually be observed as a failure, directly or through the chain $\hat\Lambda_Q(q) = \hat\Lambda(T(q))$. Both are the usual conditions of model-free learning and both are impractical, since optimistic starts encourage visits to the failure set. The practical algorithm trades the guarantee for confidence bounds.
For $\sigma(q)>0$, the Gaussian-model probability is $1-\Phi((\lambda-\mu(q))/\sigma(q))$, where $\Phi$ is the standard normal CDF. This calculation is exact within the Gaussian model; its interpretation as true viability probability is approximate. Assume $\lambda_{\mathrm{caut}}\ge0$. Then the event $\{\hat\Lambda_Q>\lambda_{\mathrm{caut}}\}$ is contained in $\{\hat\Lambda_Q>0\}$, so for $q\in\hat Q_{\mathrm{caut}}$: $P[\hat\Lambda_Q(q)>0]\ge P[\hat\Lambda_Q(q)>\lambda_{\mathrm{caut}}]>\gamma_{\mathrm{caut}}\ge\gamma_{\mathrm{opt}}$, i.e. $q\in\hat Q_{\mathrm{opt}}$. (With $\lambda_{\mathrm{caut}}\lt0$ the first inclusion fails and the containment can fail.)
If $\sigma(q)=0$, the model is a point mass at $\mu(q)$ and the strict exceedance probability is $\mathbf1\{\mu(q)>\lambda\}$.
- Input: initial GP estimate $\hat\Lambda_Q$, thresholds $\gamma_{\mathrm{caut}}, \gamma_{\mathrm{opt}}, \lambda_{\mathrm{caut}}$, initial state $s_0$, budget $n$
- while $i \lt n$:
- compute $\hat\Lambda$, $\hat Q_{\mathrm{opt}}$, $\hat Q_{\mathrm{caut}}$ from $\hat\Lambda_Q$; $A_{\mathrm{caut}} \leftarrow \{a : (s_i, a) \in \hat Q_{\mathrm{caut}}\}$
- if $A_{\mathrm{caut}} = \emptyset$: $a_i \leftarrow \arg\max_a P[\hat\Lambda_Q(s_i,a) \gt 0 \mid \mathcal{D}]$ // take the safest action: the most probably viable one. The paper writes $P[(s_i,a) \in \hat Q_{\mathrm{caut}}]$, which is $0$ for every $a$ once the set is thresholded; the authors' code (vibly) maximises this unthresholded probability, plus a little noise to break ties
- else: $a_i \leftarrow \arg\max_{a \in A_{\mathrm{caut}}} \sigma^2(s_i, a)$ // explore where the GP is most uncertain
- $(s_{i+1}, \mathrm{failed}) \leftarrow T(s_i, a_i)$
- if failed: add $((s_i, a_i), 0)$ to $\mathcal{D}$, refit, reset $s_{i+1}$ to a random state of $\hat Q_{\mathrm{caut}}$
- else: compute $\hat\Lambda(s_{i+1})$ from $\hat Q_{\mathrm{opt}}$, add $((s_i, a_i), \hat\Lambda(s_{i+1}))$ to $\mathcal{D}$, refit
"A random state of $\hat Q_{\mathrm{caut}}$" means a state of its projection onto the state space, $\{s:\exists a,\ (s,a)\in\hat Q_{\mathrm{caut}}\}$. The rule presupposes that this set is nonempty and that the experiment can be reset to a chosen state; otherwise an externally supplied reset state is needed.
Results reported. On a continuous version of the hovership with a deliberately poor prior mean, the estimate is close to the ground truth after 250 samples with an 8% failure rate; the confidence thresholds are raised linearly over the run as a heuristic. On a spring-loaded inverted pendulum (SLIP) running model, controlled once per step at the apex, a conservative prior converges to a nearly maximal conservative approximation of $Q_V$ with an 8% failure rate after 500 samples. Where the measure has a non-smooth edge (an infeasibility constraint) the GP's smoothness assumption is violated and more failures are sampled; at smooth borders the shrinking measure lets the border be inferred with few or no failures.
Exploration requirements: constraints need not be accurate everywhere
If the goal is not to know $Q_V$ but to make a given nominal policy $\pi$ safe, much less has to be learned. Massiani, Heim & Trimpe, L4DC 2021 define the constrained policy as the projection of $\pi$ onto a constraint set $K \subset Q$ (projections: Primer B),
with the paper's default cost $J(s,a) = \|a - \pi(s)\|_2^2$ (see Primer A), where $\mathrm{OPT}(K)(s)$ denotes the set of minimisers, and ask which closed sets $K$ produce the same policy as the true viable set, $\mathrm{OPT}(K) = \mathrm{OPT}(Q_V)$ on $S_V$. For this quadratic distance cost, nonempty closed action slices guarantee attainment (see Primer 0); for $\mathrm{OPT}(Q_V)$ itself the paper assumes that the dynamics generate a closed viable set.
Why: pick any feasible $a_0$ in the slice; actions with $\|a-\pi(s)\|_2\gt\|a_0-\pi(s)\|_2$ cannot be optimal, so the minimisation can be restricted to the slice intersected with a closed ball around $\pi(s)$, a compact set on which the continuous $J$ attains its minimum. For a general cost, attainment must be assumed separately (e.g. continuity plus compact slices). In the critical-set formula below, $J(s,\mathrm{OPT}(Q_V)(s))$ is shorthand for the common optimal cost $\min_{a\in Q_V[s]}J(s,a)$, not $J$ evaluated at a set.
In words: an admissible constraint must contain the optimal viable policy and exclude the critical set, and may otherwise contain unviable pairs that are never tempting. Two consequences follow. First, greed is good: following $\pi_{\hat K}(s) = \mathrm{OPT}(\hat K)(s)$ when feasible (and $\pi$ otherwise) aims exploration at $Q_{\mathrm{crit}}$ by itself, and the paper concludes that it keeps visiting $Q_{\mathrm{crit}}$ until the learner has excluded it, so the exploration requirement is fulfilled by the greedy on-policy strategy, with no off-policy exploration. That is an argument, not a theorem (Theorem 6 is a static statement about sets): the greedy policy only probes the critical pairs at states its trajectories actually reach, so a viable region they never enter is never explored, and each probed pair must then really be removed by the learner's update. In the experiments the coverage comes from starting every episode (at most 10 steps) in a random state of the projection of $\hat K$. Second, this is why failures are informative here too: as long as $\hat K$ contains $\mathrm{OPT}(Q_V)$, an unviable action that the greedy policy picks at a viable state costs at most $J(s, \mathrm{OPT}(Q_V)(s))$, so it is by definition a critical pair, and the failures it causes teach exactly what must be excluded. In their experiment with the affine nominal policy $a = 0.7 - 0.3 s$ on the hovership and the GP learner of Heim et al., 20 episodes (196 samples) gave a safe policy $\pi_{\hat K}$ over nearly the whole viability kernel.
3. Penalising Failure: The Setup
Back to control notation. The reward $r : X \times U \to \mathbb{R}$ is measurable and bounded. For a controller $u$ and initial state $x$ the return is
with the discount time constant $\tau \gt 0$; in discrete time the integral is a sum and $e^{-t/\tau} = \gamma^t$ with $\gamma = e^{-1/\tau}$. The smaller $\tau$, the shorter the agent's inner time horizon, although large delayed rewards can still matter. Because $r$ is bounded the return is finite for every $u$ and $x$. The (unconstrained) value function is $v(x) = \sup_{u \in \mathcal{U}} G(x,u)$ and satisfies the dynamic-programming identity (see Primer D), for all $t$,
The $\delta t$ bookkeeping is what produces the extra term in the discrete-time theorems. In discrete time the integral up to $t$ is the sum $\sum_{k=0}^{t}\gamma^k r(x_k,u_k)$, which already contains the reward at step $t$, so the "rest of the trajectory" starts one step later, at $x_{t+1}$, with weight $\gamma^{t+1}$; in continuous time the split point itself carries no reward and the continuation starts at $t$.
The only rule about point masses used below is $\int g(t)\,\delta_{t_f}(dt)=g(t_f)$: a unit mass in time samples the integrand at the event time. (The spatial comparison is a side remark: near a simple crossing $x(t)-x_F\approx\dot x(t_f)(t-t_f)$, and the substitution $s=\dot x(t_f)(t-t_f)$ turns $\int\delta(x(t)-x_F)\,dt$ into $\int\delta(s)\,ds/|\dot x(t_f)|=1/|\dot x(t_f)|$, a charge that would depend on the crossing speed instead of being one fixed penalty.)
Proof. With the sink convention the trajectory is in $X_F$ at exactly one instant, its time-to-failure $t_f \in \mathbb{T} \cup \{\infty\}$, so with this convention the integral evaluates to $\rho(x,u) = e^{-t_f/\tau}$ (and to $0$ if $t_f = \infty$). By definition $u$ is safe for $x$ iff the trajectory never enters $X_F$, i.e. iff $t_f = \infty$. $\square$
The discount inside $\rho$ is not needed for the lemma; it is there so that $\rho$ can be combined linearly with the return $G$, which has the same discount.Proposition 1. If $V_p$ is an SVF, then $V_p(x) = V(x)$ for all $x \in X_V$.
Proof. Let $u^\star$ be an optimal controller of $V_p$ at $x \in X_V$. It is safe, so $\rho(x,u^\star) = 0$ and $V_p(x) = G(x,u^\star)$. Because it is also optimal for (C) among safe controllers, $G(x,u^\star) = \sup_{\mathcal{U}_{\mathrm{safe}}} G(x,\cdot) = V(x)$. $\square$
Three reward constants will control everything that follows. For discrete time, with $Q_V$ and $Q_U$ from Section 1,
$R_{Q_U}$ is the best one-step reward obtainable on a transition that leaves the kernel (or happens outside it), $R_{Q_V}$ the worst one-step reward of a viable transition, and $R_{X_U}$ the best reward rate available while doomed. In every example of this module the failure states carry zero reward; since $X_F \subset X_U$, this makes both suprema at least $0$. Only the sign of $R_{X_U}$ matters for the theory (Section 4).
4. Safe Value Functions: The Theorems
The main result has two layers. First, a condition on the value function itself that guarantees safety: unviable states must look worse than every viable state. Second, a guarantee that a large enough failure penalty always enforces that condition, with an explicit (if conservative) formula for "large enough".
Source: Massiani et al., TAC 2023, Theorem 1; the continuation hypothesis is made explicit here.
In words. No state outside the kernel may be worth more than the worst state inside it. In discrete time the transition that leaves the kernel earns a one-step reward of at most $R_{Q_U}$, while the safe alternative at the same state earns at least $R_{Q_V}$; these two one-step rewards are collected before the discounted continuation, hence the extra terms and the factor $\gamma$ in (Zb). The condition is called "zeroth-order" because it compares values, not derivatives, of $V_p$ at different states.
Why each ingredient matters. The supremum on the left ranges over the whole unviability kernel, failure states included (but not the post-failure sink, which is bookkeeping and not a state of $X$), because an unsafe controller can wander anywhere in $X_U$ before failing. The infimum on the right is over the constrained value $V$, not $V_p$: the safe alternative we compare against must itself be safe. The inequality is strict so that unsafe actions are strictly suboptimal, which is what "all maximisers are safe" needs; with equality some optimal controller could be indifferent and fail.
Step 1 (Lemma 3 of the paper). The following are equivalent: (i) for every $x \in X_V$, every maximiser of $u \mapsto (G - p\rho)(x,u)$ lies in $\mathcal{U}_{\mathrm{safe}}(x)$; (ii) for every $x \in X_V$ and every unsafe $u_F \notin \mathcal{U}_{\mathrm{safe}}(x)$, $V(x) \gt (G - p\rho)(x, u_F)$. Indeed, (i) implies that the maximum of $G - p\rho$ is attained on safe controllers, where $\rho = 0$, so it equals $\max_{\mathcal{U}_{\mathrm{safe}}} G = V(x)$, and any unsafe $u_F$ is strictly below it. Conversely, weak duality gives $\max_{\mathcal{U}} (G - p\rho) \ge \max_{\mathcal{U}_{\mathrm{safe}}} G = V(x)$, so under (ii) no unsafe controller can be a maximiser. Statement (i) is exactly "$V_p$ is safe" together with Proposition 1's optimality, so it suffices to show that (Z) implies (ii).
Step 2 (exit time). Fix $x \in X_V$ and an unsafe $u_F$. Let $T = \sup\{t : \varphi^{u_F}_x(t) \in X_V\}$, the last time the unsafe trajectory is still viable; $T$ is finite because $u_F$ fails from $x$, and it can be $0$ (on the shelf, start at the ledge $x = 0$ and drive left). Write the return of $u_F$ with the dynamic-programming identity split at $T + \epsilon$, for a small $\epsilon \gt 0$, and share the prefix only up to $s_\epsilon = \max\{0, T - \epsilon\}$ so that no negative times appear (continuous time; the discrete case is written out separately in Step 4, with $\epsilon = 0$):
Since $y_\epsilon$ is unviable, $(G - p\rho)(y_\epsilon, u_F) \le \sup_{X_U} V_p$. This is where $\sup_{X_U} V_p$ enters.
Step 3 (a safe competitor). Let $u$ follow $u_F$ up to time $s_\epsilon$, while the state is still viable, and then switch to a safe backup $b \in \mathcal{U}_{\mathrm{safe}}$. Then $u$ is safe from $x$, so its state at time $T+\epsilon+\delta t$ is viable. The dynamic-programming identity for $V$ at time $T+\epsilon$ (the continuation hypothesis of the theorem) replaces the rest of $u$'s return by the best safe continuation from that state, which is worth at least $\inf_{X_V} V$: $$V(x) \ \ge\ \int_0^{s_\epsilon} e^{-t/\tau} r\, dt + \int_{s_\epsilon}^{T+\epsilon} e^{-t/\tau} r\big(\varphi^{u}_x, \hat u_x\big)\, dt + e^{-(T+\epsilon+\delta t)/\tau}\, \inf_{X_V} V .$$ Only this continuation value enters, never the return of $b$ itself. (The switch happens at a fixed time, which a time- or history-dependent controller implements with a clock. The paper instead pastes $u_F$ on the visited prefix and $b$ elsewhere into one feedback law and argues that this law is safe; applying the identity to it is exactly the continuation hypothesis for stationary feedback.) The shared part is identical in both expressions and cancels.
Step 4 (let $\epsilon \to 0$). In continuous time the middle integrals run over intervals of length at most $2\epsilon$ with a bounded integrand, so they vanish as $\epsilon \to 0$, while the shared part tends to $A = \int_0^T e^{-t/\tau} r\big(\varphi^{u_F}_x(t), u_F(\varphi^{u_F}_x(t))\big)\,dt$ ($A = 0$ if $T = 0$). Multiplying by $e^{T/\tau}$ and writing $I_0 = e^{T/\tau}A$ (the paper's notation), the two bounds become $e^{T/\tau} V(x) \ge \inf_{X_V} V + I_0$ and $e^{T/\tau}(G - p\rho)(x,u_F) \le \sup_{X_U} V_p + I_0$ with the same $I_0$. Subtracting, $V(x) - (G - p\rho)(x,u_F) \ge e^{-T/\tau}\big(\inf_{X_V} V - \sup_{X_U} V_p\big) \gt 0$ by (Za). If the trajectory jumps from $X_V$ directly into $X_F$, split at $T$ instead of $T + \epsilon$, with the same inequalities. In discrete time take $\epsilon = 0$, $\delta t = 1$, and split the sums without overlap. With the shared part $A = \sum_{t=0}^{T-1} \gamma^t r(x_t, u_F(x_t))$, the unsafe return is $A + \gamma^T r(x_T, u_F(x_T)) + \gamma^{T+1} (G - p\rho)(x_{T+1}, u_F) \le A + \gamma^T R_{Q_U} + \gamma^{T+1} \sup_{X_U} V_p$, because the exit pair lies in $Q_U$ and $x_{T+1} \in X_U$ (possibly a failure state). The safe competitor of Step 3, now switching at $x_T$, plays a viable input $b(x_T)$ at the exit state and then the best safe continuation (dynamic programming for $V$ again), so $(x_T, b(x_T)) \in Q_V$ and $V(x) \ge A + \gamma^T R_{Q_V} + \gamma^{T+1} \inf_{X_V} V$. After dividing by $\gamma^T$, (Zb) says precisely that the second bound exceeds the first. $\square$
The linear inverted pendulum model keeps the centre of mass at a fixed height above a point foot; its horizontal offset $y$ from the foot obeys $\ddot y=\omega^2y$ with $\omega\gt0$, so the capture point $y+\dot y/\omega$, where the foot must be placed to come to rest, moves away from the foot exponentially between steps. The $N$-step capture region is the set of states from which the model can come to rest in at most $N$ steps; with maximal step length $\ell_{\max}$ and minimal step duration $\Delta t'_s\gt0$ (in the model's nondimensional time), its border is the displayed $d_N$, the largest capture-point distance from which $N$ steps suffice. With $q=e^{-\Delta t'_s}\in(0,1)$ the geometric sum is $d_N=\ell_{\max}q(1-q^N)/(1-q)$; for $q=1/2$ and $\ell_{\max}=1$ this gives $d_1,d_2,d_3=1/2,\,3/4,\,7/8$, increasing to $d_\infty=1$. States just inside $d_\infty$ need arbitrarily many steps to stop, and states just outside take arbitrarily many steps to fall: an unbounded time-to-failure, exactly what Assumption 1 excludes.
Proof. For the same input, Grönwall's inequality (Primer D) gives $\|x_u(t)-y_u(t)\|\le e^{L_ft}\|x-y\|$. Split the integral at a time $T$: the parts up to $T$ differ by at most $T\,\omega(e^{L_fT}\|x-y\|)$, the tails by at most $2M\tau e^{-T/\tau}$. Choose $T$ to make the tail small, then $\|x-y\|$ small; the bound does not depend on the input, so it survives the supremum. $\square$ The penalised problem (P) is outside these assumptions (the failure penalty is an event charge and $X_F$ stops trajectories), which is why the paper's Remark 3 is a warning about typical Lipschitz models rather than a theorem about $V_p$.
The penalty should be big enough
Proof. (i): the supremum over $\mathcal{U}$ preserves the pointwise inequality $G - p_2 \rho \le G - p_1 \rho$ for $p_2 \ge p_1$, since $\rho \ge 0$. (ii): for $x \in X_U$, $V_p(x) \le \sup_u G(x,u) - p \inf_u \rho(x,u)$ because the supremum of a difference is at most the difference of supremum and infimum. Every trajectory from $x$ fails by time $T_f$ and collects nothing afterwards, so $G(x,u) \le R_{X_U} \int_0^{T_f} e^{-t/\tau} dt = R_{X_U}\tau(1 - e^{-T_f/\tau})$ (continuous) or $R_{X_U} \sum_{t=0}^{T_f} \gamma^t$ (discrete, reward collected at times $0, \dots, T_f$); and $\rho(x,u) = e^{-t_f/\tau} \ge e^{-T_f/\tau}$. The walkthrough below goes through every step. $\square$
The point of Lemma 2 is (ii): the supremum of $V_p$ on the unviability kernel can be pushed arbitrarily low by increasing $p$, while $\inf_{X_V} V$ does not depend on $p$ at all. So (Z) can always be enforced.
The paper writes $p^\star \in \mathbb{R}_+$, but the two expressions can be negative (Exercise 7.4(c), and the explorer with a large goal reward). Then every $p \ge 0$ is certified, $p = 0$ included; if a nonnegative threshold is wanted, take $\max\{0, p^\star\}$.
(Zb) reads $R_{Q_U} + \gamma \sup_{X_U} V_p \lt R_{Q_V} + \gamma \inf_{X_V} V$. A sufficient condition is obtained by replacing $\sup_{X_U} V_p$ with its upper bound from Lemma 2(ii):
Collect the $p$ term on the right (it appears as $-\gamma^{T_f+1} p$ on the left):
Divide by $\gamma^{T_f+1} \gt 0$ and factor $\gamma^{-T_f}$:
Sanity check at $T_f = 0$ (failure immediately after leaving the kernel, as in the paper's Fig. 1): $p^\star = R_{X_U} + (R_{Q_U} - R_{Q_V})/\gamma - \inf_{X_V} V$, which both readings of (18b) give. Sanity check against continuous time: with $\gamma = e^{-1/\tau}$, $\gamma^{-T_f} = e^{T_f/\tau}$ is the same exponential factor as in (18a).
Reading the formula
Four things are now established: the threshold is finite; all maximisers of (P) for $p \gt p^\star$ are safe; they are also optimal for (C); and $p^\star$ depends explicitly on the time-to-failure, the reward and the discount. For $p \gt p^\star$ the penalised and the constrained problem are equivalent. The dependence has two parts.
- The exponential. $e^{T_f/\tau} = \gamma^{-T_f}$ is the inverse of the discount that the penalty suffers before it arrives: a penalty paid $T_f$ steps after the mistake is only worth $\gamma^{T_f} p$ at the moment the decision is made, so it must be inflated by $\gamma^{-T_f}$ to have any effect. If the agent is short-sighted, $\tau \ll T_f$, the required penalty is astronomically large. The paper's phrase: the ratio $T_f/\tau$ measures how the time-scale of failure compares to the agent's inner horizon.
- The bracket. $R_{X_U}\tau - \inf_{X_V} V$ (continuous time) is how attractive the doomed region can look: the best reward rate available while failing, integrated over the horizon $\tau$, minus the worst value that safety can guarantee. Positive rewards outside $X_V$ raise $R_{X_U}$ and $R_{Q_U}$; negative rewards inside $X_V$ lower $\inf_{X_V} V$ and $R_{Q_V}$; both raise $p^\star$.
A fixed penalty (as in (P)), a Lagrange multiplier (Section 7) and an augmented Lagrangian are three different tools. The augmented Lagrangian combines an adaptive multiplier with an extra penalty on constraint violation: for a constraint $c(z)\le0$ in a reward-maximisation problem, one simple form maximises $J(z)-\lambda c(z)-\tfrac{\beta}{2}[c(z)]_+^2$ over $z$ (with $[q]_+=\max\{q,0\}$ and a penalty weight $\beta\gt0$) and then updates $\lambda$ from the observed violation. Because the multiplier absorbs most of the work, $\beta$ can stay moderate. For $c(z)=z-1$ the extra charge is $\beta/2$ at $z=2$ and vanishes at the feasible $z=1$. The SVF theorem says nothing about the convergence or safety of such a scheme; it concerns one fixed $p$.
Take the shelf of Section 1 with the reward $r(x) = -1$ on $[0, L)$, $+1$ on $(-L, 0)$ (falling feels great) and $0$ at $\pm L$, plus the penalty $p$ at $x = -L$. At the wall $x = L$ the robot cannot move, so $V_p(L) = 0$. From $x \in [0, L)$ the optimal control is either to drive to $x = L$ and rest there, or to drive to the ledge and fall. Driving right from $x$ takes time $(L-x)/v$ at reward $-1$, so the value of the safe option is $\tau\big(e^{(x-L)/(v\tau)} - 1\big)$. Driving left takes time $x/v$ at reward $-1$, then the fall lasts $T_f$ at reward $+1$, then the penalty arrives, discounted by $e^{-(T_f + x/v)/\tau}$:
(Taken literally at $x = L$ the second argument would describe an impossible manoeuvre, which is why the wall is treated separately.) On $X_U = [-L, 0)$ the robot is falling: $V_p(x) = \tau\big(1 - e^{-\frac{T_f}{\tau}(1 + \frac{x}{L})}\big) - p\, e^{-\frac{T_f}{\tau}(1 + \frac{x}{L})}$, which equals $-p$ at the failure state $x = -L$. Every optimal controller stays on the shelf forever iff the first argument of the max strictly wins at $x = 0$ (with a tie, a falling controller is optimal too), i.e.
Where this comes from. Put $a=x/v$. The falling return is $-\int_0^a e^{-t/\tau}dt+\int_a^{a+T_f}e^{-t/\tau}dt-p\, e^{-(a+T_f)/\tau}=-\tau(1-e^{-a/\tau})+\tau e^{-a/\tau}(1-e^{-T_f/\tau})-p\,e^{-(a+T_f)/\tau}$, which is the second candidate above. With its value at the ledge $F_0=\tau(1-e^{-T_f/\tau})-p\, e^{-T_f/\tau}$ it reads $-\tau+e^{-x/(v\tau)}(\tau+F_0)$, while the safe value is $-\tau+\tau e^{(x-L)/(v\tau)}$. Multiplying the comparison by $e^{x/(v\tau)}\gt0$, staying on the shelf is strictly better iff $\tau e^{(2x-L)/(v\tau)}\gt\tau+F_0$. The left side increases with $x$, so $x=0$ is the hardest case, and at $x=0$ this is the displayed condition.
Now evaluate Theorem 2: $R_{X_U} = \sup_{[-L,0)} r = 1$ and $\inf_{X_V} V = V(0) = -\tau\big(1 - e^{-L/(v\tau)}\big)$ (the constrained optimum from the ledge is to drive all the way to $L$), so $p^\star = \big(\tau + \tau(1 - e^{-L/(v\tau)})\big)e^{T_f/\tau} - \tau$, which is exactly the threshold just derived (the paper's eq. (29)). On this example the bound of Theorem 2 is tight; in general it is only an upper bound on the minimum penalty, which is the point the explorer makes. With $L = 1$, $v = 0.2$, $\tau = 1$, $T_f = 1$: $p^\star = (2 - e^{-5})\,e - 1 \approx 4.42$; with $T_f = 2$ it is already $\approx 13.7$.
Recovering the kernel and a barrier function from an SVF
For this paragraph write continuous-time control-affine dynamics as $\dot x=f_0(x)+g(x)u$ (drift $f_0$, input matrix $g$; the notation table's $f(x)+g(x)u$, renamed to avoid a clash with the transition map $f$). A $C^1$ function $h$ describes a candidate safe set $C=\{x:h(x)\ge0\}$. The Lie derivatives $L_{f_0}h=\nabla h^\top f_0$ and $L_gh=\nabla h^\top g$ are the directional derivatives of $h$ along the drift and along the input directions, so by the chain rule (Primer B) $\dot h=L_{f_0}h(x)+L_gh(x)\,u$. A control barrier condition asks for inputs in $K_{\mathrm{cbf}}(x)=\{u\in U:L_{f_0}h(x)+L_gh(x)\,u\ge-\kappa(h(x))\}$, where $\kappa$ is an extended class-$\mathcal K$ function (continuous, strictly increasing, $\kappa(0)=0$; Primer D). Example: $\dot x=u$, $h(x)=x$, $\kappa(h)=h$ gives $u\ge-x$; then $\tfrac{d}{dt}(e^tx)=e^t(x+u)\ge0$, so $x(t)\ge e^{-t}x(0)\ge0$ whenever $x(0)\ge0$. In general, if $f_0$, $g$ are locally Lipschitz, $\nabla h\ne0$ where $h=0$, and a locally Lipschitz feedback takes values in $K_{\mathrm{cbf}}(x)$, the comparison lemma turns $\dot h\ge-\kappa(h)$ into $h(x(t))\ge0$ for all $t\ge0$ whenever $h(x(0))\ge0$: $C$ is forward invariant (Module 10 develops this). The theorem below goes the other way, from invariance to a barrier function; what matters in both directions is that $h=0$ exactly on the boundary of the set.
For $\dot x=f_0(x)+g(x)u$ on an open neighborhood $D$ of a nonempty compact $C$, assume $f_0,g$ locally Lipschitz and $h\in C^1(D)$, with $C=\{x\in D:h(x)\ge0\}$, $\partial C=\{h=0\}$, $\operatorname{Int}C=\{h>0\}$, and $\nabla h\ne0$ on $\partial C$. If a locally Lipschitz feedback $k:D\to U$ renders $C$ forward invariant, then there exists an extended class-$\mathcal K_\infty$ function $\kappa$ such that $\sup_{u\in U}[L_{f_0}h+L_gh\,u]\ge-\kappa(h)$ on $C$: $h|_C$ is a CBF. This is the restricted-domain converse of Ames et al., ECC 2019, Theorem 3.
Intuition: invariance forces inward or tangent velocity on the zero boundary. Compactness controls the worst decrease away from that boundary, allowing one comparison function to bound it. The defining-function and nonzero-gradient assumptions make $h=0$ describe the actual boundary; positivity there is not a substitute.
Proposition 3 applies this theorem with $C = X_V$. The definition of $X_V$ supplies the invariance, but the SVF does not supply the defining function. For $\alpha \lt \alpha_{\sup}$ the function $h = V_p|_{X_V} - \alpha$ is strictly positive on $\partial X_V$, so $\{h = 0\} \neq \partial X_V$, and every continuous extension of $h$ stays positive just outside $X_V$. The identity $X_V = \{h \ge 0\}$ holds only because $h$ is defined on $X_V$ alone. There, the CBF inequality $\sup_u [L_{f_0} h + L_g h\,u] \ge -\kappa(h)$ holds trivially, because $h$ is bounded away from $0$ on the compact $X_V$ and a steep extended class-$\mathcal{K}_\infty$ function $\kappa$ absorbs any decrease. At a true boundary point, where $h = 0$, the condition would demand $\dot h \ge 0$; here $h \gt 0$ on $\partial X_V$, so it allows $\dot h \lt 0$ there and need not exclude outward inputs, and the resulting filter need not keep the state in $X_V$. The natural extension $V_p - \alpha$ does have $X_V$ as its 0-superlevel set on all of $X$ (Proposition 2), but it jumps across $\partial X_V$ (see the caveat on (Z)) and is not $C^1$. A CBF that represents the whole kernel therefore needs more than the listed assumptions: a $C^1$ function on a neighbourhood of $X_V$ with $X_V = \{h \ge 0\}$ and $h = 0$ exactly on $\partial X_V$ (for $h = V_p|_{X_V} - \alpha$ this forces $\alpha = \alpha_{\sup}$, with $V$ equal to its minimum on all of $\partial X_V$ and larger inside), plus the regularity of the dynamics that the CBF theorems assume. When such an $h$ exists, note the asymmetry with usual CBF practice: CBFs certify a conservative subset of $X_V$ chosen a priori, whereas here the level set is the whole kernel. Choosing $\alpha \gt \alpha_{\sup}$ selects a strict subset that need not be controlled invariant at all (the paper's Fig. 6 shows such a conservative subset, for which no CBF is guaranteed).
What the numerical examples teach about reward shaping
The paper's second example is a "satellite" $\dot x_1 = x_2$, $\dot x_2 = -g/x_1^2 + \omega^2 x_1 + u$ with $u \in [-1, 1]$, $g = 10$, $\omega = 0.1$, failure set $\{x_1 \le 1\} \cup \{x_1 \ge 15\}$, discretised on a $401 \times 301$ grid with a one-second zero-order hold (the input is held constant over each one-second interval, Primer D; on the resulting finite grid Assumption 1 holds automatically, see below) and solved by value iteration (see Primer E) with $\gamma = 0.6$. Three reward functions for the task "reach the equilibrium $(10, 0)$" illustrate the three ways a reward can interact with $p^\star$.
Why Assumption 1 is automatic on a finite deterministic grid: a non-failure cycle reachable while remaining in $X_U$ would allow a controller to repeat that cycle forever, contradicting unviability. Thus the non-failure part of the unviable transition graph has no cycle, so every path through it visits each state at most once and reaches $X_F$ within $|X_U|$ steps, whatever the inputs: $T_f \le |X_U|$. The argument does not carry over unchanged to stochastic transitions.
| Reward design | Effect on (Z) and $p^\star$ | Satellite example |
|---|---|---|
| Parsimonious: $+1$ at task success (inside $X_V$), $0$ elsewhere | Without penalty the value is $\ge 0$ inside $X_V$ and $0$ outside; any $p \gt 0$ gives an SVF, so the minimum penalty is $0$ (the paper's figure labels it $p^\star = 0$) and $\alpha = 0$ works. The conservative formula (18b) can still be positive, e.g. when a success state has an input that leaves $X_V$, which makes $R_{Q_U} = 1$. Success and failure are conceptually independent. | $p = 1$ is an SVF; threshold range $\alpha \in [-0.0054, 0]$ |
| Degenerate: $r \equiv 0$ | All terms of $p^\star$ vanish; any $p \gt 0$ works and $X_V = \{V_p \ge 0\}$. Value iteration with zero reward and a failure penalty computes the viability kernel: the goal of RL-based reachability (Fisac et al.), reached here with an ordinary discounted, Lagrange-type value. | SVF strictly negative outside $X_V$, kernel recovered with $\alpha = 0$ |
| Benign: positive rewards inside $X_V$ or negative rewards outside | Continuous time: they only raise the right-hand side or lower the left-hand side of (Za), so (18a) never increases and may decrease. Discrete time: the same holds for negative rewards outside $X_V$ and positive rewards on viable pairs, but a positive state reward at a viable state that also has an exit input raises $R_{Q_U}$ too, so (Zb) and the bound (18b) can get worse. Example: $A \to B$ or $F$, $B \to B$, reward $M$ at $A$ and $0$ elsewhere; then $T_f = 0$, $R_{X_U} = R_{Q_V} = \inf_{X_V} V = 0$, $R_{Q_U} = M$, and (18b) gives $p^\star = M/\gamma$, although every $p \gt 0$ is safe. What is preserved is actual safety: adding state-only rewards $\ge 0$ on $X_V$ keeps an SVF an SVF, because at the exit state the safe alternative collects the same bonus. | — |
| Positive rewards outside $X_V$: e.g. $+1$ when $|x_1 - 10| \le 1$ regardless of velocity | Raise $R_{Q_U}$ and $\alpha_{\inf}$; $p^\star$ grows and thresholding gets harder, but with only positive rewards $\alpha = 0$ still recovers $X_V$ for some $p \gt p^\star$. | with $p = 1$ some regions outside $X_V$ still have a higher value than parts of $X_V$ (not an SVF); $p = 111$, two orders of magnitude above the reward, is needed (figure label $p^\star = 110$); threshold range $\alpha \in [-0.004, 0]$ |
| Negative rewards inside $X_V$: e.g. $-1 - u^2$ when $|x_2| \ge 2$, $-u^2$ otherwise | Lower $\inf_{X_V} V$ and $R_{Q_V}$; $p^\star$ grows, and the admissible threshold interval shrinks to a sliver, so $\alpha = 0$ recovers only a conservative subset. | $p = 136$ needed (figure label $p^\star = 135$); threshold range $\alpha \in [-4.54, -4.53]$, and $\alpha = 0$ recovers only a conservative subset of $X_V$ |
This duality statement requires a specified CMDP setting: for example, a feasible finite discounted CMDP with randomized policies has a finite-dimensional occupancy-measure linear program; more general results require their own assumptions, such as bounded rewards and a Slater condition. In this example only, risk is charged at time 1 but the penalty at time 2. Consequently the standard multiplier of the discounted risk is $\lambda=\gamma p$, explaining why the tie occurs at $p=1/\gamma=10$ rather than at multiplier $\lambda=1$.
With a fresh action draw at each visit, failing after $k$ stays has probability $(1-\theta)^k\theta$ and discounted risk $\gamma^{k+1}$. Hence $\bar\rho=\sum_{k\ge0}(1-\theta)^k\theta\gamma^{k+1}=\gamma\theta/[1-\gamma(1-\theta)]$. Setting this equal to $\eta$ gives $\theta=\eta(1-\gamma)/[\gamma(1-\eta)]$, which is $1/11$ for the stated numbers.
For uncertain dynamics $x^+=f(x,u,d)$ with $d\in D$, a robustly viable state admits one causal control strategy that stays safe for every admissible disturbance sequence: $\exists\text{ strategy }\,\forall(d_0,d_1,\ldots)\,\forall t$. Causal, or nonanticipating, means the action may depend on observations already available, not on future disturbances. Here the control is chosen before the current disturbance. The one-step condition is $\exists u\,\forall d:\ f(x,u,d)\in Y$. For $x^+=x+u+d$, $|d|\le0.1$, landing nominally at $0.95$ does not robustly stay in $[-1,1]$ (the disturbance can push it to $1.05$); landing at $0.8$ does for that step. The set of robustly viable states is the discriminating kernel of the safe set; without a control input (every evolution must stay safe) it reduces to the invariance kernel. Different information orders (who moves first, who observes what) define different kernels, so a claim about them must specify the order.
5. Viability of Future Actions and Entropy Regularisation
Practitioners train constrained tasks with SAC (see Primer E), whose target policy is a Boltzmann (softmax) distribution over soft Q-values with full support: no action ever gets zero probability. That breaks the SVF story in an obvious way: a stochastic policy that sometimes picks an unviable action cannot be safe. Massiani, von Rohr, Haverbeck & Trimpe, ECML-PKDD 2025 ask two questions about the entropy-regularised constrained problem: in what sense is it a robust control problem, and can penalties still make it amenable to unconstrained algorithms? The theory is for discrete-time deterministic dynamics $x' = f(x,a)$ on finite state and action spaces, with stochastic policies $\pi(a \mid x)$ and discount $\gamma \in (0,1)$.
Why entropy prefers states with many viable actions
The whole mechanism rests on one elementary inequality. A safe policy at $x \in X_V$ can only put mass on viable actions, and the entropy of a distribution supported on $|Q_V[x]|$ points is at most $\ln|Q_V[x]|$:
where the last equality is the counting-measure safety measure of Section 2. $\bar S$ is the discounted sum of these entropies along trajectories, so an entropy-regularised safe optimiser is drawn away from states with few viable actions. It does not forbid the actions leading there, because a hard exclusion would propagate the same cap backwards to earlier states and cost immediate entropy; it merely lowers their probability, the more so the sooner the constrained states would be reached. The paper's interpretation: the mode of such a policy tends to minimise the long-term proportion of actions that are unavailable because of constraints, and therefore the chance that action noise picks one of them. This is offered as an empirical explanation of the robustness of SAC-style agents; a precise formalisation is explicitly left to future work.
Penalties again, but only $\delta$-safety
The constrained problem involves $Q_V$, which is unknown in a model-free setting. The Lagrangian relaxation of $\pi \in \Pi_V$ is the penalised problem
with $c$ a dynamic indicator and $p \ge 0$. For $\alpha = 0$ this is (P) and Theorem 2 of Section 4 applies. For $\alpha \gt 0$ the softmax gives $\pi^\star_{\alpha,p}(a \mid x) \gt 0$ for every pair, so, as soon as $Q_{\mathrm{crit}} \neq \emptyset$, $\pi^\star_{\alpha,p} \notin \Pi_V$ for every finite penalty. (If $Q_{\mathrm{crit}} = \emptyset$, every action at every viable state is viable and every policy is safe, so there is nothing to enforce.) What survives is approximate safety.
With $m=|A|$ actions, some action has probability at least $1/m$. If every critical action has probability at most $\delta<1/m$, no critical action can be a mode; all modal choices are viable. This proves a sufficient choice $\bar\delta=1/|A|$. By contrast, a stochastic $\delta$-safe policy can still fail: its one-step probability of leaving the kernel is at most $|Q_{\mathrm{crit}}[x]|\delta$, and a union bound over $H$ decisions gives at most $H|A|\delta$, capped at 1. There is no corresponding infinite-horizon safety conclusion.
The proof is short enough to be worth doing in full, and it shows where the temperature enters the required penalty. The core is a two-sided bound on the soft Q-function (Lemma 2 of the paper, a generalisation of Lemma 2 in Section 4).
What the experiments show
On a cliff-walking grid with three cliff cells (failure set), a target column with invariant states, and reward $-1$ for every action outside cliff and target, the constrained "fenced" version offers only three actions next to the cliff, so the entropy cap bites there. Maximising entropy alone drives the mode away from the cliff towards the top corners, even giving up the target when it starts on the left; finite temperatures trade this robustness against reaching the target. With penalties, sufficient $p$ recovers the constrained solution, consistent with Theorem 2, but entropy and penalty compete: for any fixed $p$ a high enough $\alpha$ degrades safety, so the penalty must scale with the temperature (Fig. 3 of the paper: the minimum penalty for a safe mode increases with $\alpha$, from about $9$ at $\alpha = 1$ to about $17$ at $\alpha = 32$; the achievable $\delta$ decreases in $p$, and beyond $p \approx 15$ it is larger at higher $\alpha$, while at small penalties the order is reversed). On two benchmarks (a modified Pendulum-v1 and Hopper-v4, trained with SAC and penalties) the paper evaluates the mode of the learned policy under injected uniform action noise and reports that modes trained at higher temperature avoid failure under larger noise, which is the claimed robustness; it is an empirical finding, not a theorem. Two remarks from the paper are worth keeping: with the plain indicator as dynamic indicator, the minimum penalty scales exponentially with the longest trajectory in $X \setminus (X_V \cup X_C)$, the discrete cousin of $e^{T_f/\tau}$; and while theory says "as high as possible", very large penalties cause numerical instabilities with function approximators.
6. Uncertainty-Aware Safe RL at DSME (UPSi, Dyna-SAuR, CHEQ)
The theory above assumes the dynamics are known and deterministic. The group's recent algorithmic work keeps the viability idea but replaces the model by a learned, uncertainty-aware one, and replaces "stay in $Q_V$" by "stay in the part of $Q_V$ where the model can be trusted". This section is a factual summary; the filter mechanics are treated in Module 10.
UPSi: a predictive safety filter on a probabilistic ensemble
Frauenknecht, Kesper, Mayfrank, Hose & Trimpe, RLC 2026 build a predictive safety filter (MPC background: Primer D; the filter of Wabersich & Zeilinger in Module 10) on the probabilistic-ensemble (PE) neural dynamics model (see Primer E) used by Dyna-style MBRL, for dynamics $s_{t+1} = \mu(s_t,a_t) + L(s_t,a_t)w_t$ with bounded process noise $w_t \in W$. The filter solves, at every step,
where $R_{n|t}$ is the robust reachable set of the plan ($n|t$ reads "predicted $n$ steps ahead from the information at time $t$"; $N$ is the horizon, $j$ counts model-update episodes, and $R_{0|t} = \{s_t\}$), $v_{n|t} = u_{n|t} + K_{n|t}(s - z_{n|t})$ the input with ancillary feedback around the nominal state $z_{n|t}$ ($v_{0|t} = u_{0|t}$; because this input depends on the state, $R_{n|t} \times v_{n|t}$ is shorthand for the graph $\{(s, v_{n|t}(s)) : s \in R_{n|t}\}$, so every state the tube may contain must yield an admissible and certain pair), $T_j$ a robustly positive invariant terminal set (for some control law $\kappa$, every $s \in T_j$ satisfies $\mu(s,\kappa(s)) + L(s,\kappa(s))W \subseteq T_j$, the paper's Definition 2: the robust counterpart of controlled invariance, so the tube can end there and stay safe forever), and the only non-standard ingredient is the certainty constraint $C_j$. (The paper's compact statement (4) indexes the stage constraints from $n = 1$; its full formulation (11) enforces them from $n = 0$, which in particular requires the applied pair $(s_t, u_{0|t})$ to be admissible and certain.) The ensemble members $e = 1, \dots, E$ predict means $\mu_{\theta_e}$ and covariances $\Sigma_{\theta_e}$ (see Primer C); following the group's earlier work these are fused into an aleatoric variance $\bar\Sigma = \big(\tfrac{1}{E}\sum_e \Sigma_{\theta_e}^{-1}\big)^{-1}$, a nominal model $\bar\mu$ and an epistemic variance $\hat\Sigma = \tfrac{1}{E}\sum_e (\mu_{\theta_e} - \bar\mu)(\mu_{\theta_e} - \bar\mu)^\top$ (the spread of the members). The Kalman-gain-like matrix $G = \bar\Sigma(\bar\Sigma + \hat\Sigma)^{-1}$ (a gain matrix, not the return $G$ of Section 3) is the ratio of aleatoric to total predictive variance, and the certain set is
which, with $n_S$ the state dimension, approaches $1$ where epistemic uncertainty is negligible and $0$ under high model uncertainty (eq. 5 of the paper). Reachable sets are over-approximated by ellipsoidal tubes $\mathcal{P}_{n|t} = \{s : (s - z_{n|t})^\top P_{n|t}^{-1}(s - z_{n|t}) \le 1\}$: the centre follows $\bar\mu$, the shape is propagated through the averaged Jacobians with an ancillary feedback $K_{n|t}$, an outer ellipsoid of the Minkowski sum ($A \oplus B = \{a + b : a \in A,\ b \in B\}$; Primer D) with the truncated noise ellipsoid $\epsilon\bar\Sigma$, and an explicit inflation by a Lipschitz bound on the linearisation error. Theorem 1 of the paper (stated precisely below): under Assumptions 2, 3 and 5, $R_{n|t} \subseteq \mathcal{P}_{n|t}$ for all $n$. Assumption 2 (consistent estimator: $\Sigma_{\theta_e} \succeq \Sigma$ inside $C_j$) and Assumption 3 (unbiased inside $C_j$) only hold inside the certain set, which is why certainty must be enforced along the whole predicted tube; this is done by tightening $C_j$ with a Lipschitz margin $g_{n|t} = \ell_G\sqrt{\lambda_{\max}(P_{n|t}) + \lambda_{\max}(K_{n|t}P_{n|t}K_{n|t}^\top)}$. Assumption 4 (the noise estimate improves monotonically and $C_j \subseteq C_{j+1}$) makes the sampled terminal-set expansion valid across episodes; Assumption 5 asks for twice-differentiable nominal dynamics with Lipschitz gradient, noise scale and certainty measure.
Why $\tfrac{1}{n_S}\operatorname{tr}G\in[0,1]$ (Primer A): assume $\bar\Sigma\succ0$, $\hat\Sigma\succeq0$ and write $\Sigma_{\mathrm{tot}}=\bar\Sigma+\hat\Sigma$. Since $0\preceq\bar\Sigma\preceq\Sigma_{\mathrm{tot}}$, the symmetric matrix $\Sigma_{\mathrm{tot}}^{-1/2}\bar\Sigma\,\Sigma_{\mathrm{tot}}^{-1/2}$ lies between $0$ and $I$, so its $n_S$ eigenvalues lie in $[0,1]$; by cyclicity of the trace, $\operatorname{tr}G=\operatorname{tr}(\bar\Sigma\,\Sigma_{\mathrm{tot}}^{-1})=\operatorname{tr}(\Sigma_{\mathrm{tot}}^{-1/2}\bar\Sigma\,\Sigma_{\mathrm{tot}}^{-1/2})$ is their sum. ($G$ itself need not be symmetric, hence the detour; in one dimension $G=\bar\sigma^2/(\bar\sigma^2+\hat\sigma^2)$.) The inverses in the ensemble formulas need positive-definite member covariances or a stated regularisation.
Here $P_{n|t}$ is the shape matrix of the ellipsoid. At $n=0$ it is $0$ and the tube is the single point $s_t$ (for a singular shape read $\mathcal{P}=\{z+P^{1/2}q:\|q\|_2\le1\}$, since the inverse in the formula needs $P\succ0$). The paper's noise set is the ball $W=\{w:\|w\|_2^2\le\epsilon\}$ with $L$ diagonal, so $\epsilon$ is a noise radius (not the explorer's slip probability), and the noise $Lw$ lies in the ellipsoid with shape $\epsilon LL^\top=\epsilon\Sigma\preceq\epsilon\bar\Sigma$ under Assumption 2.
Proof idea. For $s=z_{n|t}+\delta\in\mathcal{P}_{n|t}$ the true successor is $z_{n+1|t}+F_{n|t}\delta+(\text{linearisation error})+L(s,v_{n|t}(s))w$. The first two terms lie in the ellipsoid with shape $F_{n|t}P_{n|t}F_{n|t}^\top$ around the new centre, the noise at the nominal pair lies in the ellipsoid with shape $\epsilon\bar\Sigma$ (previous paragraph), and Assumption 5 bounds the error, together with the change of $L$ across the tube, by $e_{n|t}$. The outer ellipsoid contains the sum of the three sets, and induction from the single point $s_t$ gives the claim for every $n$. The guarantee needs the bounded noise set: an ellipsoid fitted to a Gaussian covariance is only a probability region, which is why the practical variant below loses it.
The paper's error radius is $e_{n|t}=\tfrac12\ell_{\nabla\mu}D_n^2+\ell_L\sqrt{\epsilon}\,D_n$ with $D_n^2=\lambda_{\max}(P_{n|t})+\lambda_{\max}(K_{n|t}P_{n|t}K_{n|t}^\top)$: Taylor's theorem bounds the remainder of $\mu$ by $\tfrac12\ell_{\nabla\mu}$ times the squared distance of $(s,v(s))$ from $(z,u)$, which is at most $D_n^2$ (next paragraph), and $\|(L(s,v(s))-L(z,u))w\|\le\ell_L D_n\sqrt{\epsilon}$. For the outer ellipsoid a crude but valid choice is $P_{n+1}=3(M_1+M_2+M_3)$ with $M_1=F_nP_nF_n^\top$, $M_2=\epsilon\bar\Sigma$, $M_3=e_n^2I$. Indeed, the ellipsoid $\{M^{1/2}q:\|q\|_2\le1\}$ extends $\sqrt{v^\top Mv}$ in the direction of a unit vector $v$, extents add under Minkowski sums, and $\big(\sum_{i=1}^{3}\sqrt{v^\top M_iv}\big)^2\le3\sum_{i=1}^{3}v^\top M_iv$ by Cauchy–Schwarz, so the sum lies inside the ellipsoid with shape $3(M_1+M_2+M_3)$. The paper's update (8) is tighter: it applies the standard outer ellipsoid of the sum of two ellipsoids twice, with trace-based weights. Simply adding the shapes, as one adds covariances, is not enough for worst-case sets: $[-1,1]+[-1,1]=[-2,2]$, whereas adding the two unit shapes gives only $[-\sqrt2,\sqrt2]$.
The certainty margin: write a state of the tube as $s=z+P^{1/2}q$ with $\|q\|_2\le1$. Then $\|s-z\|_2^2=q^\top Pq\le\lambda_{\max}(P)$ and $\|v(s)-u\|_2^2=\|KP^{1/2}q\|_2^2\le\lambda_{\max}(KPK^\top)$, so the pair $(s,v(s))$ lies within distance $\sqrt{\lambda_{\max}(P)+\lambda_{\max}(KPK^\top)}$ of $(z,u)$. A certainty measure with Lipschitz constant $\ell_G$ can therefore drop by at most the margin $g_{n|t}$ above, and requiring the nominal pair to exceed $\xi$ by $g_{n|t}$ certifies the whole tube.
Dyna-SAuR: a hyperplane safety filter learned inside a Dyna loop
Eisele, Frauenknecht, Solowjow & Trimpe, 2026 learn both a control policy and a scalable safety filter from an uncertainty-aware model, with minimal domain knowledge. Their viability notion is finite-horizon and probabilistic (see Primer C): $S_V = \{s : \exists\pi,\ \Pr_\pi[\forall t \le T,\ S_t \in S_S \mid S_0 = s] \ge 1 - \delta\}$ with $S_S$ the non-failure states (unbounded process noise rules out infinite-horizon statements), and it is intersected with a certain set $E = \{(s,a) : H(\hat S_{t+1}) \le \lambda_1\}$ defined by the entropy of the model's predictive distribution, giving a certain viability kernel $S_V(E)$ and the certain viable policies $\Pi_V(E)$. The filter is the projection onto a state-dependent half-space of actions (see Primer B),
with $A = [-1,1]^{n_A}$ ($n_A$ the action dimension), a filter policy $\mu$ with values in the punctured unit ball $\mathcal{U}_h = \{u \in \mathbb{R}^{n_A} : 0 \lt \|u\|_2 \le 1\}$ (the paper's $\mathcal{U}$; renamed here to avoid a clash with the controller set $\mathcal{U}$ of Sections 1–4), and the map $h(u) = (w, b)$, $w = u/\|u\|_2$, $b = (2\|u\|_2 - 1)\|w\|_1$. Theorem 5.1 calls $h$ a bijection onto the hyperplanes that intersect $A$. Precisely, $h$ is a bijection from $\mathcal{U}_h$ onto the oriented pairs $\{(w, b) : \|w\|_2 = 1,\ -\|w\|_1 \lt b \le \|w\|_1\}$, i.e. onto half-spaces $w^\top a \ge b$; the pairs $(w, b)$ and $(-w, -b)$ give the same hyperplane but opposite half-spaces. The endpoint $b = -\|w\|_1$ is missing. Its half-space contains all of $A$ (no filtering), and it would need $u = 0$, which the paper's definition (13) excludes and where $h$ is undefined; the appendix proof uses the closed ball, and puncturing it removes the division by zero at the cost of this endpoint. $\|u\|_2$ near $0$ classifies almost all actions as viable and near $1$ almost none, a minimal search space for $\mu$. The paper motivates the half-space by saying that for control-affine dynamics a state-dependent hyperplane discriminates viable from unviable actions (citing Lavanakul et al.). What Lavanakul et al. show is weaker. For continuous-time control-affine dynamics and a control-invariant set with $C^1$ boundary, the tangency (Nagumo/CBF) condition (see Primer D) is affine in the input, so a state-dependent half-space can serve as a sufficient, possibly conservative, safety constraint that separates certified from uncertified inputs. The exact set of viable actions need not be a half-space, least of all in the discrete-time setting used here: for $x' = 2a$ with $A = [-1, 1]$ and safe states $[-1, 1]$, the viable actions are $[-\tfrac12, \tfrac12]$, which no single half-space intersected with $A$ represents. The hyperplane filter is therefore in general an approximation of the viable actions, at best a conservative (inner) one. The filter policy is trained purely on model rollouts in a "safety filter MDP" with reward $+1$ per step inside the certain safe set, $-1/(1-\gamma_{\mathrm{SF}})$ and termination when leaving it, and a regulariser $c\|\mu(s)\|_2$ in its objective that pushes towards the least restrictive hyperplane; both $\mu$ and $\pi$ are retrained from scratch in each Dyna iteration, and a better model enlarges $E$ and hence makes the filter less conservative. Reported results: control performance matching or exceeding safe-RL baselines on goal-reaching CartPole (constraints on pole angle and cart position) and on par with PPO-Lagrangian on MuJoCo Walker, with accumulated training failures reduced by at least two orders of magnitude compared with the other methods.
Why these endpoints: over the box $A=[-1,1]^{n_A}$, $\max_{a\in A} w^\top a=\sum_i|w_i|=\|w\|_1$ (take each coordinate with the sign of $w_i$) and the minimum is $-\|w\|_1$, so the hyperplane $w^\top a=b$ meets $A$ iff $-\|w\|_1\le b\le\|w\|_1$. The inverse of $h$: for an allowed pair ($\|w\|_2=1$, $-\|w\|_1\lt b\le\|w\|_1$) put $r=(1+b/\|w\|_1)/2\in(0,1]$ and $u=rw$; then $\|u\|_2=r$, $u/\|u\|_2=w$ and $(2\|u\|_2-1)\|w\|_1=b$, so $h(u)=(w,b)$, and $u$ is the only preimage because $h(u)$ fixes both the direction and the norm of $u$.
CHEQ on hardware, and safe RL in uncertain contexts
Cramer, Jäschke & Trimpe, IFAC-PapersOnLine 2025 give the first hardware evaluation of CHEQ, an adaptive hybrid RL method that blends a control prior with an RL action, $a^{\mathrm{ref}}_t = (1 - \lambda^{\mathrm{RL}}_t)a^{\mathrm{prior}}_t + \lambda^{\mathrm{RL}}_t a^{\mathrm{RL}}_t$, where the weight $\lambda^{\mathrm{RL}}_t$ is a clipped linear map of the parametric uncertainty of a critic ensemble (the standard deviation of the ensemble's Q-estimates (see Primer E)): the agent is trusted where its critics agree. Applied to robotic polishing with variable impedance, a task requiring precise force and velocity tracking, CHEQ learned effective polishing directly on hardware in eight hours of training with only five failures. The paper stresses that CHEQ gives no formal safety guarantee: the control prior shapes exploration, and hard limits truncate episodes. (This $\lambda$ is a blending weight, not a Lagrange multiplier.) Finally, Baumann & Schön, T-RO 2024, by a Trimpe alumnus and not co-authored by Trimpe, extend SafeOpt-style safe learning to discrete environmental contexts that cannot be measured (payloads, surfaces): contexts are identified through MMD-based tests on dedicated identification experiments when they cannot be inferred from measurements, and estimated online with frequentist multi-class classification bounds built on conditional mean embeddings, validated on a Furuta pendulum whose weights are classified from camera images.
With the feature map $\phi$ of a kernel (Module 3), a kernel mean embedding represents a distribution $P$ by the feature-space average $m_P=\mathbb E_{X\sim P}[\phi(X)]$. The maximum mean discrepancy is the RKHS distance $\mathrm{MMD}(P,P')=\|m_P-m_{P'}\|$; a two-sample test estimates this distance and compares it with a calibrated threshold. A conditional mean embedding is the corresponding conditional average $m(x)=\mathbb E[\phi(Y)\mid X=x]$. For one-hot encoded class labels, an ordinary conditional feature average is the vector of class probabilities. Classification confidence bounds quantify uncertainty in such estimates; they require a separate statistical theorem and are not supplied by an ensemble's agreement alone.
For two classes with probabilities $(0.7,0.3)$, the mean of their one-hot vectors is exactly $(0.7,0.3)$. A simultaneous confidence statement bounds both estimated coordinates on one event of probability at least $1-\delta$. For a characteristic kernel, zero MMD implies equal distributions; otherwise MMD only tests distinctions visible to the chosen features.
7. Connections: Lagrangians, Reachability, Shields
The penalty is a Lagrange multiplier
Write (C) as the CMDP "maximise $\mathbb{E}_\mu G$ subject to $\mathbb{E}_\mu \rho \le 0$". Because $\rho \ge 0$, this averaged constraint demands safety only from $\mu$-almost every initial state (why: if $\Pr_\mu(\rho\gt0)\gt0$, then some event $\{\rho\ge1/n\}$ has positive probability, because these events increase to $\{\rho\gt0\}$, and then $\mathbb{E}_\mu\rho\ge\tfrac1n\Pr_\mu(\rho\ge1/n)\gt0$; so $\mathbb{E}_\mu\rho=0$ forces $\rho=0$ except on a set of initial states of probability zero, Primer C); the paper's constraint "$\rho(x,u) = 0$ for all $x \in X_V$" (its $(C_\eta)$ with $\eta = 0$) is the pointwise version, and it is the one the SVF theorem speaks about. Form the Lagrangian with multiplier $\lambda \ge 0$:
The penalised problem (P) with $p = \lambda$ is the inner maximisation of the Lagrangian for a fixed multiplier, and the dual function is the expected penalised value (the supremum can be taken inside the expectation because the penalised problem has a controller that is optimal from every initial state at once, as assumed in Section 3). Weak duality, $d(\lambda) \ge$ the constrained optimum, is Lemma 3's inequality (34). Now compare the two theories. Strong duality for CMDPs (Paternain et al., NeurIPS 2019; Module 8) says $\min_\lambda d(\lambda)$ equals the primal optimum and that some maximiser of $\mathcal{L}(\cdot, \lambda^\star)$ is feasible and optimal; it says nothing about the other maximisers, which is the primal recovery problem that motivates state augmentation (Calvo-Fullana et al., TAC 2024; Module 8). The SVF theorem is stronger and narrower: for the 0-risk constraint and every fixed $\lambda \gt p^\star$, every optimal controller of $V_\lambda$ is safe from every viable state and optimal for (C), and every maximiser of the averaged Lagrangian $\mathcal{L}(\cdot,\lambda)$ is safe from $\mu$-almost every initial state and optimal. The dual optimal set therefore contains the whole ray $(p^\star, \infty)$; it can be larger, since $p^\star$ is only sufficient. This is the mechanism behind a familiar observation: the same fixed penalty that works on one task fails on another. In the exact, deterministic setting a fixed multiplier works once it exceeds the task's minimal penalty, which Theorem 2 bounds through the time-to-failure, the reward scale and the discount; for PPO or SAC with function approximation, and with entropy regularisation (Section 5), this is a heuristic reading rather than a guarantee. Projected dual descent on the multiplier, $\lambda \leftarrow [\lambda + \eta_\lambda\,\mathbb{E}_\mu\rho]_+$ with step size $\eta_\lambda$ (RCPO, PPO-Lagrangian, Module 8), can be read as a search for a sufficient penalty: with threshold $0$ and $\rho \ge 0$ the multiplier never decreases and stops moving as soon as the current maximiser is safe from $\mu$-almost every initial state, and a PID-controlled multiplier (PID control: Primer D; Module 8) damps the overshoot of that search. For a risk budget $\eta \gt 0$ the SVF equivalence fails (Example 1) and the multiplier genuinely has to be found.
In our reward-maximization convention, $d(\lambda)=\sup_u\mathbb E[G-\lambda\rho]$ is minimized. An exact maximizing controller $u_\lambda$ gives the subgradient $g_\lambda=-\mathbb E\rho(x,u_\lambda)$. Projected subgradient descent is therefore $\lambda^+=[\lambda-\eta_\lambda g_\lambda]_+=[\lambda+\eta_\lambda\mathbb E\rho]_+$, where $[z]_+=\max\{z,0\}$. The literature often calls the corresponding update dual ascent after changing the optimization sign convention.
A subgradient $g$ at $\lambda$ means $d(z)\ge d(\lambda)+g(z-\lambda)$ for every $z$. Keep the optimizing controller $u_\lambda$ fixed at the new multiplier: $d(z)\ge\mathcal L(u_\lambda,z)=d(\lambda)-(z-\lambda)\mathbb E\rho$. This proves the stated subgradient. For risk $0.2$ and step size $0.5$, the multiplier rises by $0.1$.
Viability is reachability is invariance
Three communities compute the same set. The unviability kernel $X_U$ is the backward-reachable tube of $X_F$ in HJ reachability (Module 10), obtained from the min-over-time value $V_{\mathrm{BRT}}$ and used as a least-restrictive safety filter that intervenes only at $\partial X_V$; SVFs put the same set into a Lagrange-type value via Proposition 2. $X_V$ is the largest controlled-invariant subset of $X \setminus X_F$; CBFs (Module 10) certify invariance of a chosen subset $\{h \ge 0\}$, and Proposition 3 claims that an SVF furnishes a CBF for the whole kernel under regularity, which in fact also needs a $C^1$ defining function vanishing exactly on $\partial X_V$ (Section 4). And a shield (Alshiekh et al., AAAI 2018; Module 10) is synthesised from the winning region $W \subseteq F^g$ of a safety game on a finite abstraction ($F^g$ the safe game states). The paper computes $W$ by standard safety-game solving, i.e. as the greatest fixed point $W = \nu X.\,F^g \cap \mathrm{CPre}(X)$ with $\mathrm{CPre}(X)$ the states from which the system player can force the next state into $X$, which reduces to Algorithm 1 when every action has one successor: $W$ is the viability kernel of the abstraction, a preemptive shield restricts the learner to $Q_V[x]$, and a post-posed shield substitutes an action from $Q_V[x]$ when the learner leaves it. Shielded RL is therefore the "unconstrained MDP on $X_V$ with action set $Q_V[x]$" of Section 3, enforced online rather than through the reward. The HJ, CBF and predictive safety filters surveyed by Wabersich et al., CSM 2023 all override the learner's action so that it stays in (an inner approximation of) $Q_V[x]$, CBF and predictive filters by a minimal projection, HJ filters typically by switching to a safe action at the boundary; Dyna-SAuR's half-space is a learned such approximation.
The symbol $\nu$ means 'take the largest fixed point'. If $\mathrm{Succ}(x,u)$ is the set of successors an adversary may choose after action $u$, define $\mathrm{CPre}(Y)=\{x:\exists u,\ \mathrm{Succ}(x,u)\subseteq Y\}$. Starting with $W_0=F^g$, repeatedly compute $W_{k+1}=F^g\cap\mathrm{CPre}(W_k)$. With one deterministic successor per action this becomes Algorithm 1. A shield on an abstraction certifies the physical system only when the abstract successor sets include all physical successors represented by each abstract state.
Example: if action $a$ has possible successors $\{y,z\}$ and $Y=\{y\}$, that action is not winning: the adversary may select $z$. The quantifiers are one action first, then every possible successor.
| Concept | Safe value functions | HJ reachability | Barrier functions | Shields / filters | CMDPs |
|---|---|---|---|---|---|
| Safe set | $X_V = \{V_p \ge \alpha\}$ when values separate (Prop. 2) | complement of the unavoidable-failure BRT; zero level needs boundary conventions | $\{h \ge 0\}$, a chosen invariant subset | winning region $W$ of the safety game | states where $\rho = 0$ is feasible |
| Safe actions | maximisers of $Q_p(x,\cdot)$, $p \gt p^\star$ | $\arg\max_{u\in U} \min_{d\in D} \nabla V(x)^\top f(x,u,d)$ at the boundary | $K_{\mathrm{cbf}}(x) = \{u : L_{f_0}h + L_gh\,u \ge -\kappa(h)\}$ | $Q_V[x]$ (preemptive) or a substitute (post-posed) | support of the optimal occupancy measure |
| Where the task enters | same value function | separate task controller, filtered | QP objective $\|u - u_{\mathrm{des}}\|^2$ | learner's action, overridden | reward, with the multiplier |
| Type of guarantee | exact, all maximisers, deterministic dynamics | exact / robust to $d \in D$ | exact given a valid $h$ | exact on the abstraction | in expectation, $\rho \le \eta$ |
Reading the table. In the SVF column the safe actions are the maximisers of the one-step look-ahead $Q_p(x,u)=r(x,u)-p\mathbf{1}_{X_F}(x)+\gamma V_p(f(x,u))$ (discrete time, sink convention), not of the state function $V_p$; thresholding $V_p$ itself recovers $X_V$ only under the value separation of Proposition 2. In the HJ column the dynamics carry a disturbance, $f(x,u,d)$ with $d\in D$, and at the boundary the filter picks $\arg\max_{u}\min_{d}\nabla V(x)^\top f(x,u,d)$, the input with the best worst-case rate. In the CMDP column the occupancy support only describes pairs that are actually visited; it certifies nothing at unvisited viable states.
Walkthrough: Deriving the Penalty Threshold p*
The derivation of the continuous-time threshold (18a) in six steps, with the reason for each step. It reproduces Lemma 2(ii) and Theorem 2 of Massiani et al. Keep the shelf example in mind: there the bound turns out to be exact.
Interactive: Penalty vs Safety on a Cliff Gridworld
An $8 \times 5$ cliff world. The bottom row is the cliff (failure set, absorbing, penalty $p$ on entry, then nothing; a cliff cell is itself a state of $X_U$ with value $-p$). Six shaded "slope" cells are unviable: on a slope the agent cannot climb and slides one row down after every move, so from the four slope cells next to the cliff every action fails in one step, and from the two slope cells above them every action fails within two steps (moving down falls at once, any other move slides onto the lower slope), so $T_f = 2$. All other cells are viable; the number in the corner is the safety measure $\Lambda$, the count of viable actions among up, down, left, right, stay. The agent pays a living cost $c$ per step away from the goal G and earns $R_g$ per step at the goal (it can stay there). The explorer runs numerical value iteration for the penalised problem, draws the greedy policy, flags every viable state from which some optimal action leaves the kernel, rolls out the greedy policy from S, and compares three thresholds: an estimate $p_{\min}$ of the first safety threshold, an estimate $p_Z$ of the boundary where the strict zeroth-order condition (Zb) holds, and the formula $p^\star$ of Theorem 2.
The reward is paid at the current state. If an action at time $t$ reaches a cliff cell at time $t+1$, its action value is $r(x_t)-\gamma p$: the failure state has value $-p$ at the next time index. Otherwise it is $r(x_t)+\gamma V_p(x_{t+1})$. Thus 'on entry' means at the arrival state's time, matching the sums in Exercise 7.4.
At each decision, execute the intended action with probability $1-\varepsilon$; with probability $\varepsilon$, draw uniformly from all currently available actions, including the intended one. If there are $m$ actions, the intended action therefore has total probability $1-\varepsilon+\varepsilon/m$, and every other action has probability $\varepsilon/m$. The value calculation averages over these outcomes. The drawn line instead follows nominal successors of selected greedy actions without sampling slip; it is an illustrative intended path.
Values. In-place (Gauss–Seidel) sweeps, at most 20 000, stopped when the largest change in a sweep is below $10^{-9}(1+|p|)$ ($10^{-9}$ for the constrained values). This is a numerical stopping rule, not a certified residual bound. Actions whose Q-values are within $10^{-9}$ of the best count as tied, and a viable state is flagged unsafe if any tied action leaves the kernel. (If the value error is at most $E$, each Q-value is off by at most $\gamma E$, so only gaps above $2\gamma E$ certify the order of two actions.)
Thresholds. The scan evaluates 61 penalties from $10^{-2}$ to $10^3$ (12 per decade) and refines the first passing interval by 14 bisection steps, checking $p=0$ when the first grid point already passes. $p_{\min}$ is the first penalty found at which every optimal action keeps its successor in the kernel; at the boundary itself an unsafe action may still tie, so the boundary need not be safe (Exercise 7.4). $p_Z$ is the analogous boundary of the strict condition (Zb), on the deterministic world. "> 1000" means that no threshold was found in the scanned range. With slip, the test concerns the intended actions only and need not be monotone in $p$, so $p_{\min}$ is then a diagnostic estimate, not a proof of the smallest safe penalty.
Theory quantities ($p^\star$, $p_Z$, $\sup_{X_U} V_p$, the last including the cliff cells' value $-p$) are computed on the deterministic world, which is the setting of the theorem; the empirical threshold and the policy use the slip probability you set. A state counts as unsafe if any optimal action at it leaves the kernel, matching Definition 3 ("all optimal controllers"). With slip no policy avoids the cliff forever (random moves reach it eventually with probability one), so for $\varepsilon \gt 0$ the empirical threshold only asks that every optimal intended action keep its nominal successor in the deterministic kernel. Try: raise $c$ to see the "suicide" failure mode (dying stops the living cost); lower $\gamma$ to watch $p^\star$ grow through $\gamma^{-T_f}$; set $c = 0$ (with $R_g \gt 0$) to see the parsimonious case where any $p \ge 0$ is safe, even though the conservative formula $p^\star$ may stay positive; add slip to see the penalty push the policy away from the edge, a purely robustness-driven effect outside the theorem.
Why no policy survives with slip $\varepsilon\gt0$: from every non-failure cell, at most $H=4$ consecutive downward moves reach the cliff (the grid has four rows above it). Whatever the policy intends, each executed move is "down" with probability at least $\varepsilon/5$ (the slip draws uniformly among at most five actions), so a block of $H$ steps ends in the cliff with probability at least $q=(\varepsilon/5)^4\gt0$, from any state. Surviving $k$ consecutive blocks therefore has probability at most $(1-q)^k\to0$.
Reading the chart: each tick to the right multiplies $p$ by ten. Read the blue, purple and green curves on the left axis and the orange count on the right axis. Curves below the plotting window are clipped at its lower edge. A threshold outside the horizontal plotting range is placed at the nearest edge; consult its numerical readout for its actual value. Zero and negative thresholds cannot be placed on this logarithmic axis.
From the mathematics to a real decision
Learning objectives
- Compute a viability kernel by removing states with no action that preserves future feasibility.
- Distinguish an immediately nonfailed successor from a viable successor.
- Compare a finite failure penalty with the complete discounted safe alternative and treat ties strictly.
A commissioning decision
A simplified enclosure alternates production and cooling. Temperature is restricted to the discrete states $52,54,56,58,60$ degrees Celsius; leaving $[52,60]$ is failure. One step lasts one minute. Action R runs production and increases temperature by 2 degrees. Action C cools by 4 degrees, but a hypothetical interlock makes C unavailable at temperatures of 60 degrees or higher. At low temperatures cooling is allowed to act but causes failure if the result is below 52.
Assume these deterministic transitions are exact, temperature is the complete state, the interlock has no hidden memory, and no disturbance occurs. Failure is absorbing. This intentionally small model isolates future controllability: being inside the permitted temperature range now need not mean some controller can keep the process there forever.
For the reward comparison, a production action normally earns 3 units of output and cooling earns zero. A special rush order gives 25 units for running at 58 degrees. Running at 60 earns the usual 3 units before failure. Use discount $\gamma=0.9$ per minute, a one-time penalty $p$ on the transition into failure, and zero return afterward. Rewards are teaching choices, not throughput estimates.
Worked decision, with its limits
Start from nonfailed states. Let $K_0=\{52,54,56,58,60\}$. At 60, cooling is unavailable and running reaches 62, so 60 has no action remaining in $K_0$. Remove it. At 58, cooling reaches 54, so 58 remains even though running would reach the removed state. At 56, both running to 58 and cooling to 52 remain possible. Temperatures 52 and 54 can run to 54 and 56 respectively.
Repeat until nothing changes. The resulting set $K_1=\{52,54,56,58\}$ is controlled invariant: every member has at least one successor in the same set. Therefore another elimination round changes nothing, and the viability kernel is $K_1$. The viable-action counts in increasing temperature order are $1,1,2,1$. This count reveals flexibility at 56 that the binary viable/nonviable label hides.
Choose the action at 58. Running from 58 reaches 60 without immediate failure, yet destroys the possibility of avoiding failure later. Cooling reaches 54 and permits the perpetual cycle $58\to54\to56\to58$. The safe cycle's discounted return, starting at 58, is
This is the best safe return: at 58 cooling is compulsory, at 54 running is compulsory, and at 56 running returns to 58 sooner than taking the additional cooling detour through 52. The unsafe rush sequence earns $25+0.9(3-p)=27.7-0.9p$. A guessed penalty $p=5$ gives return 23.2, so the reward optimizer prefers the route to inevitable failure despite that substantial penalty.
Safety can instead be enforced by restricting actions to viable successors, which rejects running at 58 directly. A penalty is an alternative only when its magnitude and assumptions actually create strict separation. The safe value depends on the full continuing process, not just the next reward, and a learned approximation to this value introduces additional uncertainty beyond the exact finite model.
A tempting wrong approach
A one-step filter that tests only whether the next temperature belongs to $[52,60]$ accepts running at 58. Its successor is legal but doomed. The appropriate filter checks membership in the viability kernel, which represents continued feasibility. Treating a large failure penalty as an equivalent filter without computing its threshold makes the same future-feasibility mistake in reward form.
Transfer the argument
Exercise 7.B1 — Medium: A looser temperature cap may not help
Raise the upper temperature limit to 62 degrees, adding state 62. The interlock still forbids cooling at 60 and above. Recompute the viability kernel and explain the practical implication.
Review: Controlled invariance and elimination.
Show hint
First remove 62, then inspect 60 again. Kernel computation may need more than one elimination round.
Show worked solution
From 62, running reaches 64 and cooling is unavailable, so remove 62. State 60 then has only its running successor 62, which has just been removed, so remove 60 in the next round. The four original states 52, 54, 56, and 58 still have viable successors. The kernel is unchanged. Relaxing an instantaneous limit can postpone failure without restoring a sustainable action. Changing the interlock or adding cooling capacity addresses a different part of the model.
Exercise 7.B2 — Hard: Recompute the penalty after changing the horizon preference
Change the discount to $\gamma=0.8$ while retaining all rewards. Find the strict penalty threshold above which every optimal action at 58 is safe. Decide whether $p=24$ works and explain what happens at equality.
Review: Strict penalty separation.
Show hint
Recompute the safe cycle and compare it with $25+0.8(3-p)$. The strict inequality excludes unsafe ties.
Show worked solution
The best safe cycle gives $V_s=[0.8(3)+0.8^2(3)]/(1-0.8^3)=4.32/0.488\approx8.852459$. The unsafe return is $27.4-0.8p$. Requiring it to be strictly smaller gives $p\gt(27.4-8.852459)/0.8\approx23.184426$. At $p=24$, unsafe return is 8.2, below the safe value, so the optimal action at 58 is cooling. At equality the unsafe action also maximizes return; a claim about all maximizing policies being safe would fail. The shorter effective reward horizon makes delayed failure less influential and increases the required penalty.
Synthesis and bridge
Viability describes sustainable choices before reward enters. A safe-value or penalty argument can make optimization respect those choices, but it must preserve future feasibility and handle strict separation. The small example also distinguishes a physical constraint from an actuator restriction: either can determine the kernel.
The following constrained-RL chapters return to expected costs and policy optimization. Keep this kernel in mind when reading their budgets. An expected discounted penalty can be a useful design objective while answering a different question from whether failure remains avoidable from the robot's current state.
Exercises
Graded practice — Build the argument yourself
There are 12 new problems: four Easy, four Medium, and four Hard. Start with the level that lets you make progress without opening the solution. Easy problems rebuild individual operations; Medium problems combine them; Hard problems ask for proofs, boundary cases, and the limits of a guarantee. The required concepts are explained on this page or in the linked earlier material.
Easy — Warm up one skill at a time.
Exercise 7.P1 — Easy: Safe now, but doomed next
A deterministic system has states $A,B,F$, failure set $\{F\}$, and transitions: at $A$, “stay” goes to $A$ and “go” to $B$; every action at $B$ goes to $F$; $F$ stays at $F$. Find the viability kernel and identify the actions at $A$ that preserve it.
Review if needed: Primer E: deterministic transition models. Apply here: this module's explanation.
Show hint
A viable state needs at least one action that can be continued safely forever.
Show worked solution
State $A$ is viable because repeatedly choosing “stay” avoids failure forever. State $B$ has not failed at time zero, but every action reaches $F$ at the next step, so it is unviable. State $F$ has already failed. Therefore $X_V=\{A\}$ and $X_U=\{B,F\}$.
Only “stay” at $A$ preserves the kernel. “Go” has a nonfailure immediate successor, but that successor is doomed. Viability checks the existence of an indefinitely safe continuation rather than only whether the next state belongs to the complement of the failure set.
Exercise 7.P2 — Easy: Count viable actions
There are five available actions at state $x$. Their deterministic successors are $v_1,v_1,v_2,d,F$, where $v_1,v_2\in X_V$, $d\in X_U\setminus X_F$, and $F\in X_F$. Find the count-based safety measure $\Lambda(x)$ and the fraction of viable actions.
Review if needed: Primer 0: sets and counting. Apply here: this module's explanation.
Show hint
Count actions leading back into the kernel, including different actions with the same successor.
Show worked solution
Three actions are viable: the two leading to $v_1$ and the one leading to $v_2$. Hence the counting measure is $\Lambda(x)=3$, and the viable fraction is $3/5=0.6$.
The action leading to $d$ is excluded even though failure is not immediate, because no safe continuation exists there. Two actions reaching the same viable state still count as two options under counting measure. On a continuous action space the measure would instead depend on a specified volume measure; a finite action count does not transfer unchanged.
Exercise 7.P3 — Easy: Discount a failure at its arrival time
Rewards are zero and a one-time failure penalty $p=20$ is paid when the state first reaches failure at integer time $t_f=3$. With $\gamma=0.9$, compute the penalized return. Compare with immediate failure at time 0.
Review if needed: Primer 0: powers and discounted sums. Apply here: this module's explanation.
Show hint
The failure cost is multiplied by $\gamma^{t_f}$ under the page's arrival-time convention.
Show worked solution
The delayed penalty contributes $-p\gamma^{t_f}=-20(0.9)^3=-14.58$. Immediate failure contributes $-20$. Both trajectories fail, but discounting makes the later failure look less costly.
This comparison is one reason a sufficient penalty threshold needs a bound on how long a doomed state can postpone failure. If doomed trajectories could delay it arbitrarily while collecting reward, the discounted penalty might become arbitrarily small in present-value terms. Always state the time at which the penalty is charged before computing action values.
Exercise 7.P4 — Easy: A tie does not make every optimizer safe
At a viable state, one safe action has return 0 and one unsafe action has penalized return $1-p$. For which $p\ge0$ are all maximizing actions safe? What happens at equality?
Review if needed: Primer B: argmax and ties. Apply here: this module's explanation.
Show hint
Compare the two returns strictly if every maximizer must be safe.
Show worked solution
All maximizing actions are safe exactly when $0\gt1-p$, or $p\gt1$. For $p\lt1$ the unsafe action is strictly better. At $p=1$, both actions have value 0, so the unsafe action remains a maximizer.
An SVF requires all optimal controllers to be safe. The threshold 1 is the infimum of sufficient penalties, but it is not itself sufficient in this example. Choosing a particular safe tie-breaking rule can select safely at equality; it does not prove the stronger statement about every optimizer.
Medium — Combine definitions and compute a certificate.
Exercise 7.P5 — Medium: Compute a kernel by repeated pruning
The nonfailure states are $A,B,C,D$. Available successors are $A:\{A,B\}$, $B:\{C\}$, $C:\{F\}$, and $D:\{D\}$, with $F$ failed. Starting with all nonfailure states, repeatedly remove states with no action whose successor remains in the current set. List every set until it stops changing.
Review if needed: Primer 0: fixed points of set maps. Apply here: this module's explanation.
Show hint
A state can survive one round because its doomed successor has not yet been removed.
Show worked solution
Start $K_0=\{A,B,C,D\}$. Since every successor of $C$ is failed, the first update removes $C$: $K_1=\{A,B,D\}$. Now $B$ has no successor in $K_1$, giving $K_2=\{A,D\}$. Both remaining states have self-loops, so $K_3=K_2$.
The fixed point is $X_V=\{A,D\}$. The rounds propagate the consequence of failure backward: $B$ looked one-step safe initially but was removed once its continuation was understood. On a finite deterministic graph, any state that survives the fixed point has a successor inside it and hence an indefinitely safe policy.
Exercise 7.P6 — Medium: Solve an exact penalty threshold in a tiny model
At a viable state $A$, action “stay” gives reward 1 and returns to $A$; action “jump” gives reward 4 and reaches failure at the next time. Failure has value $-p$, then zero reward forever. Let $\gamma=1/2$. Find the safe value and the penalties making every optimal action at $A$ safe.
Review if needed: Primer E: Bellman values. Apply here: this module's explanation.
Show hint
The safe self-loop has value $1/(1-\gamma)$. Compare it with $4-\gamma p$.
Show worked solution
The safe value is $1+\gamma+\gamma^2+\cdots=1/(1-1/2)=2$. Jumping immediately has value $4-p/2$. It is strictly worse exactly when $4-p/2\lt2$, giving $p\gt4$.
At $p=4$ jumping and staying tie, so not every optimal action is safe. For $p\lt4$, jumping immediately is optimal: delaying it by $n$ safe steps gives $2+\gamma^n[(4-p/2)-2]$, which is smaller than the immediate jump when the bracket is positive. This checks possible delayed failure rather than comparing only two incomplete policies.
Exercise 7.P7 — Medium: Entropy rewards options, but softmax keeps unsafe mass
A state has three viable actions and one critical action. Compare the entropy of a uniform policy on the three viable actions with a uniform policy on all four actions. Which is safe? If a softmax assigns finite scores to all four, can its critical-action probability be exactly zero?
Review if needed: Primer C: entropy. Apply here: this module's explanation.
Show hint
Uniform entropy on $m$ points is $\log m$; a finite exponential is positive.
Show worked solution
The safe uniform policy has entropy $\log3\approx1.09861$ and zero mass on the critical action. The fully uniform policy has entropy $\log4\approx1.38629$, but chooses the critical action with probability $1/4$ and is unsafe.
A finite-score softmax with positive temperature has probability $e^{q_a/\alpha}/\sum_b e^{q_b/\alpha}\gt0$ for every action. It cannot give the critical action exactly zero mass. An action mask, a constrained support, or a deterministic policy obtained from appropriate modes changes that fact. Entropy can prefer more viable options only after safety of the support has been addressed.
Exercise 7.P8 — Medium: A prediction tube must fit inside the constraint
The true next state is guaranteed to belong to $[z-r,z+r]$. The hard state constraint is $|x|\le1$. Derive a condition on $z$ and $r\ge0$ that certifies all possible next states. Check $(z,r)=(0.7,0.2)$ and $(0.9,0.2)$.
Review if needed: Primer B: bounds over neighborhoods. Apply here: this module's explanation.
Show hint
The largest possible magnitude in that interval is $|z|+r$.
Show worked solution
Every point in the interval is safe exactly when $|z|+r\le1$. Sufficiency follows from $|x|\le|z|+|x-z|\le|z|+r$; necessity follows by taking the endpoint on the same side of zero as $z$.
The first tube has maximum magnitude 0.9 and is certified. The second reaches magnitude 1.1 and fails the test even though its center 0.9 is safe. The premise is that the tube really contains the true successor; an attractive learned mean and a plotted uncertainty interval alone do not establish that premise.
Hard — Explain why the argument works and where it stops.
Exercise 7.P9 — Hard: Prove monotonicity of penalized values
Let $V_p(x)=\sup_u[G(x,u)-p\rho(x,u)]$ with $\rho\ge0$. Prove $V_{p_2}(x)\le V_{p_1}(x)$ when $p_2\ge p_1$. At a viable state, also show $V_p(x)\ge V(x)$, where $V$ optimizes only safe controllers with $\rho=0$.
Review if needed: Primer 0: suprema and inequalities. Apply here: this module's explanation.
Show hint
First compare each controller separately, then take the supremum over the same set.
Show worked solution
For every controller $u$, $G(x,u)-p_2\rho(x,u)\le G(x,u)-p_1\rho(x,u)$ because $(p_2-p_1)\rho\ge0$. Taking suprema over $u$ preserves the inequality, proving monotonicity.
Every safe controller is also available to the unrestricted penalized problem, and for it $G-p\rho=G$. Therefore $V_p(x)\ge\sup_{u\text{ safe}}G(x,u)=V(x)$. When all penalized optimizers are safe and optimal among safe controllers, equality holds. Before that threshold, the unrestricted value can sit strictly above the safe value because an unsafe option is still attractive.
Exercise 7.P10 — Hard: Bound a doomed state and retain the sign assumption
Every trajectory from a doomed state fails by time $T_f=2$. Its reward at times 0 through failure is at most $R=1$, reward is zero afterward, and failure incurs $p=20$ at its arrival time. With $\gamma=0.9$, bound the return uniformly. Why must a nonnegative $R$ be used when extending the reward sum to time 2?
Review if needed: Primer 0: geometric sums. Apply here: this module's explanation.
Show hint
Extend the reward bound to all three times and use $\gamma^{t_f}\ge\gamma^2$.
Show worked solution
Since $t_f\le2$, the reward return is at most $1+0.9+0.81=2.71$. The discounted penalty is at least $20(0.9)^2=16.2$ in magnitude, because earlier failure has a larger discount weight. Thus every return is at most $2.71-16.2=-13.49$, and so is the supremum over controllers.
Extending a sum from the actual failure time to time 2 adds terms $\gamma^tR$. They must be nonnegative for the extension to remain an upper bound. If a true reward supremum were negative, use a nonnegative upper bound such as $\max\{0,R\}$ or analyze the actual stopping time directly.
Exercise 7.P11 — Hard: A Bellman residual controls value error
For a finite discounted MDP, the Bellman operator $B$ is a $\gamma$-contraction in maximum norm. A computed value table $W$ has residual $e=\|BW-W\|_\infty$. Prove $\|W-V^*\|_\infty\le e/(1-\gamma)$ and evaluate for $e=0.002$, $\gamma=0.95$. Does the bound by itself certify that the greedy policy is safe?
Review if needed: Primer E: Bellman operators. Apply here: this module's explanation.
Show hint
Insert $BW$ between $W$ and the fixed point $V^*=BV^*$, then move the contraction term to the left.
Show worked solution
The triangle inequality and contraction give $\|W-V^*\|_\infty\le\|W-BW\|_\infty+\|BW-BV^*\|_\infty\le e+\gamma\|W-V^*\|_\infty$. Subtracting the last term and dividing by $1-\gamma\gt0$ gives the claim.
Numerically the error bound is $0.002/0.05=0.04$. This establishes approximation quality for the modeled penalized problem. Safety also needs a valid model, a penalty that makes the relevant optimum safe, and enough separation between safe and unsafe action values that numerical error cannot reverse their ordering. A small residual alone does not supply those additional facts.
Exercise 7.P12 — Hard: Per-action delta-safety and episode risk
At every viable state there are at most three critical actions, each assigned conditional probability at most $\delta_a=0.002$. Starting in the viability kernel, give an upper bound on the probability of selecting a critical action within the first 50 decisions. State the conditioning needed and whether independence is required.
Review if needed: Primer C: union bounds and conditional probabilities. Apply here: this module's explanation.
Show hint
First sum over critical actions at one decision, then over possible times of the first critical choice.
Show worked solution
Conditional on any safe history, the next critical-action probability is at most $3\delta_a=0.006$. For time $t$, the probability of a first critical action at that time is at most 0.006, since the probability of reaching that safe history is at most 1. Summing over 50 possible first times gives a failure bound $50(0.006)=0.3$ and hence at least 0.7 probability of avoiding critical actions throughout.
No independence is needed. The action-probability bound must hold conditional on every relevant history while the state remains viable. A per-action number 0.002 is neither the total per-step risk nor the whole-episode risk. The bound may be conservative, but it states what the given assumptions suffice to guarantee.
Further practice — Original problems and research connections
The original exercises below retain their numbering. Some compare later methods or ask for longer research derivations; use the graded set above first, and return to a research-connection problem after reading the relevant linked module.
Key Papers
| Paper | Venue | Contribution | Why read it |
|---|---|---|---|
| Massiani, Heim, Solowjow, Trimpe — Safe Value Functions | IEEE TAC 68(5), 2023 | Zeroth-order condition; finite penalty threshold $p^\star$ with its $e^{T_f/\tau}$ scaling; thresholding recovers $X_V$; penalties do not solve bounded-risk CMDPs | The theory behind the "large failure penalty" heuristic. Read Sections II–IV and Appendix A in full. |
| Heim, von Rohr, Trimpe, Badri-Spröwitz — A Learnable Safety Measure | CoRL 2019, PMLR 100 | Safety measure $\Lambda$ = volume of viable actions; $Q_V = \{\Lambda_Q \gt 0\}$ (counting measure); model-free GP learning with optimistic and cautious sets | Introduced the state-action, graded view of viability that the later papers build on. |
| Massiani, Heim, Trimpe — On exploration requirements for learning safety constraints | L4DC 2021, PMLR 144 | Admissible constraints must contain $\mathrm{OPT}(Q_V)$ and exclude the critical set; greedy on-policy exploration targets that set (given state coverage, e.g. random episode starts) | Explains why constraints need not be accurate everywhere and why failures are informative. |
| Massiani, von Rohr, Haverbeck, Trimpe — Viability of Future Actions: Robust Safety in Reinforcement Learning via Entropy Regularization | ECML-PKDD 2025 (LNCS) | Entropy cap $H \le \ln|Q_V[x]|$; temperature controls $S$-robustness; penalties give $\delta$-safety and a safe mode | Extends SVFs to maximum-entropy RL and explains SAC's robustness to action noise. |
| Frauenknecht, Kesper, Mayfrank, Hose, Trimpe — Uncertainty-Aware Predictive Safety Filters for Probabilistic Neural Network Dynamics (UPSi) | RLC 2026 / RLJ | Predictive safety filter on a probabilistic ensemble with ellipsoidal tubes and a certainty constraint (eq. 5); reachable-set over-approximation under Assumptions 2, 3, 5 | Predictive safety filtering with neural models while keeping reachable-set reasoning. |
| Eisele, Frauenknecht, Solowjow, Trimpe — Dyna-Style Safety Augmented Reinforcement Learning: Staying Safe in the Face of Uncertainty (Dyna-SAuR) | arXiv, 2026 | Learned hyperplane safety filter and control policy in a Dyna loop; finite-horizon probabilistic viability intersected with a certain set | About two orders of magnitude fewer training failures on CartPole and Walker. |
| Cramer, Jäschke, Trimpe — CHEQ-ing the Box: Safe Variable Impedance Learning for Robotic Polishing | IFAC-PapersOnLine 59(18):325–330, 2025 | Hardware evaluation of uncertainty-weighted hybrid RL for polishing with variable impedance | A data point for safe exploration on hardware: eight hours, five failures. |
| Baumann, Schön — Safe reinforcement learning in uncertain contexts | IEEE T-RO 40, 2024 | Safe learning with unmeasured discrete contexts via MMD tests and frequentist multi-class classification bounds | Not co-authored by Trimpe; extends SafeOpt-style safe BO guarantees to unmeasured, discrete environment contexts. |
| Fisac, Lugovoy, Rubies-Royo, Ghosh, Tomlin — Bridging Hamilton-Jacobi Safety Analysis and Reinforcement Learning | ICRA 2019 | Discounted min-over-time Bellman backup is a contraction; safe sets learned by Q-learning | The other way to put the viability kernel into a value function; contrast with Lagrange-type SVFs. |
| Bansal, Chen, Herbert, Tomlin — Hamilton-Jacobi Reachability: A Brief Overview and Recent Advances | CDC 2017 | Backward reachable sets and tubes, differential-game formulation, numerical tools | The unviability kernel is the BRT of the failure set. |
| Alshiekh, Bloem, Ehlers, Könighofer, Niekum, Topcu — Safe Reinforcement Learning via Shielding | AAAI 2018 | Shields synthesised from the winning region of a safety game; preemptive and post-posed shields | The winning region is the viability kernel of the abstraction, computed by the same fixed-point iteration. |
| Paternain, Chamon, Calvo-Fullana, Ribeiro — Constrained Reinforcement Learning Has Zero Duality Gap | NeurIPS 2019 | Zero duality gap for CMDPs under Slater's condition | What strong duality gives and does not give; the contrast that makes the SVF theorem interesting. |
| Calvo-Fullana, Paternain, Chamon, Ribeiro — State Augmented Constrained Reinforcement Learning: Overcoming the Limitations of Learning with Rewards | IEEE TAC 69(7), 2024 | Some constrained problems are unsolvable by any weighted reward; multiplier-augmented states fix primal recovery | The bounded-risk side of the story: when a fixed penalty cannot work. |
| Wabersich, Taylor, Choi, Sreenath, Tomlin, Ames, Zeilinger — Data-Driven Safety Filters: Hamilton-Jacobi Reachability, Control Barrier Functions, and Predictive Methods for Uncertain Systems | IEEE CSM 43(5), 2023 | HJ, CBF and predictive filters as approximations of an ideal minimally invasive filter | The filter view of "stay in $Q_V$" that UPSi and Dyna-SAuR instantiate. |