7. Viability & Safe Value Functions

Viability kernels, learnable safety measures, the penalty threshold theorem, entropy regularisation and uncertainty-aware safe RL

Before you start

This module assumes:

How to study this module

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.

Readiness check — Three prerequisite skills

Try these before opening the answer. The review links lead to earlier material.

  1. If every action from a nonfailed state reaches failure next, is that state viable? Review transition models.
  2. What is $\sum_{t=0}^{\infty}(1/2)^t$? Review geometric series.
  3. 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

Contents
1. Failure Sets, Viable Sets and the Viability Kernel 2. A Learnable Safety Measure 3. Penalising Failure: The Setup 4. Safe Value Functions: The Theorems 5. Viability of Future Actions and Entropy Regularisation 6. Uncertainty-Aware Safe RL at DSME (UPSi, Dyna-SAuR, CHEQ) 7. Connections: Lagrangians, Reachability, Shields Walkthrough: Deriving the Penalty Threshold p* Interactive: Penalty vs Safety on a Cliff Gridworld Application lab & chapter review Exercises Graded practice: Easy, Medium & Hard Key Papers Flashcards

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

Intuition — A starting example

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.

Notation for this module
Sections 1, 3 and 4 follow Massiani, Heim, Solowjow & Trimpe, TAC 2023: state $x \in X$, input $u \in U$, and a feedback controller (Primer D) is also written $u : X \to U$ (the paper overloads the symbol; the argument makes it clear which is meant). Trajectories are $\varphi^u_x(t)$ (see Primer D), the failure set is $X_F$, the reward $r$, the discount time constant $\tau$ in continuous time or the factor $\gamma = e^{-1/\tau}$ (see Primer E) in discrete time, and $p$ is the penalty. Sections 2 and 5 keep the notation of the papers they present: $s \in S$, $a \in A$, transition map $T$, viable set $Q_V$ (Heim et al.), or $x$, $a$ with a stochastic policy $\pi(a \mid x)$ and failure set $X_C$, the 2025 paper's name for $X_F$. Throughout, $\gamma$ is the discount factor, never the information gain of the GP modules; $\Lambda$ (capital lambda) is the safety measure, not a multiplier. $\lambda$ is the Lagrange multiplier of Section 7 (see Module 2), but inside Sections 2 and 6 it keeps the meaning of the paper being presented (Heim et al.'s level $\lambda$ of the safety measure, an eigenvalue $\lambda_{\max}$ (see Primer A), Dyna-SAuR's entropy threshold $\lambda_1$, CHEQ's blending weight $\lambda^{\mathrm{RL}}_t$). $\alpha$ is the thresholding level of Proposition 2 (with $\alpha_{\inf}$, $\alpha_{\sup}$) and, in Section 5, the entropy temperature (see Primer C); the class-$\mathcal{K}$ function of CBFs (see Primer D) is written $\kappa$ instead (Sections 4 and 7). $\rho$ is the paper's discounted risk, not the occupancy measure $\rho_\pi$ of Module 8 (see Primer E); $\eta$ is the risk threshold of bounded-risk CMDPs, so the dual step size (Module 8's $\eta$) is written $\eta_\lambda$ here; $G$ is the return, except for UPSi's gain matrix in Section 6. And $h$, the SafeOpt threshold in Modules 4–6, appears here only as a barrier function (Proposition 3) and as Dyna-SAuR's hyperplane map. Finally, $c$ is the living cost of the explorer and the exercises, the cost of a dynamic indicator in Section 5 and Dyna-SAuR's regulariser weight in Section 6, and $\mu$ is the initial-state distribution in Sections 3 and 7 but UPSi's nominal dynamics and Dyna-SAuR's filter policy in Section 6; each use is local.

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$.

Setting — deterministic dynamics and trajectories
Continuous time, $\mathbb{T} = \mathbb{R}_+$: $\dot x(t) = f(x(t), u(x(t)))$ with $x \in X \subset \mathbb{R}^n$, $u(x) \in U \subset \mathbb{R}^m$ and $f : X \times U \to \mathbb{R}^n$. Discrete time, $\mathbb{T} = \mathbb{N}$: $x_{t+1} = f(x_t, u(x_t))$, where $f$ may be discontinuous and $X$, $U$ may be finite sets. In both cases $u : X \to U$ is a measurable feedback controller, $\mathcal{U}$ is the set of all such controllers and $\varphi^u_x : \mathbb{T} \to X$ is the trajectory from $x$ under $u$, assumed well defined (and, in continuous time, continuous) for all time. Integrals over $\mathbb{T}$ use the Lebesgue measure in continuous time and the counting measure in discrete time, so that one formula covers both cases.
Background — Measures, integrals against them, and "measurable"

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).

Definition — Failure set and the sink convention
The failure set $X_F \subset X$ is closed (see Primer 0) and absorbing: once the state enters $X_F$ the experiment is over (the robot is broken, the episode is reset). To reconcile this with an infinite time horizon, Massiani et al. (Remark 1) let the system jump instantly to an invariant sink state $\sigma$ with zero reward when it reaches $X_F$, so a trajectory occupies $X_F$ at a single instant and collects nothing afterwards. The paper deliberately does not introduce the sink formally: it is bookkeeping that ends the return (and the risk), not a point of $X$, so it does not enter $X_V$, $X_U$ or the suprema and infima below (see Primer B). (Counting it in $X_U$ would break the theory: its penalised value is $0$ for every $p$, so $\sup_{X_U} V_p$ could never be pushed below $0$.) The failure states themselves do belong to $X_U$, and in every example of this module they carry zero reward; Section 4 explains why that matters.

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.

Definition — Viability kernel, unviability kernel (Massiani et al., Def. 1)
$$X_V = \{\,x \in X : \exists u \in \mathcal{U},\ \forall t \in \mathbb{T},\ \varphi^u_x(t) \notin X_F\,\}, \qquad X_U = X \setminus X_V .$$ In words: $x$ is viable if some controller keeps the trajectory out of the failure set for all time. Trajectories can stay in $X_V$ arbitrarily long, but as soon as they leave it they fail within finite time, which is why the complement $X_U$ is called the unviability kernel. $X_V$ is the largest set that can be made invariant while avoiding $X_F$, i.e. the maximal controlled-invariant subset (see Primer D) of $X \setminus X_F$ in the language of set-invariance theory (Blanchini, Automatica 1999), hence the largest possible safe set.
Definition — Safe controller and viable set
A controller $u$ is safe for the point $x$ if $\varphi^u_x(t) \notin X_F$ for all $t \in \mathbb{T}$; equivalently, by the definition of $X_V$, if $\varphi^u_x(t) \in X_V$ for all $t$. $\mathcal{U}_{\mathrm{safe}}(x)$ is the set of such controllers, and $\mathcal{U}_{\mathrm{safe}} = \bigcap_{x \in X_V} \mathcal{U}_{\mathrm{safe}}(x)$ is the set of controllers that are safe from every viable state. In discrete time the same idea lives in state-input space: the viable set $$Q_V = f^{-1}(X_V) = \{(x,u) : f(x,u) \in X_V\} \subset X_V \times U, \qquad Q_U = (X \times U) \setminus Q_V,$$ is the set of pairs that transition into the kernel (Heim et al. call it the maximal set with this property), and $Q_V[x] = \{u : (x,u) \in Q_V\}$ is its slice at $x$. The kernel is the projection of $Q_V$ onto the state space, and $Q_V[x] \neq \emptyset$ exactly when $x \in X_V$.

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.

Key insight
The viability kernel replaces a dynamic question ("will this trajectory ever fail?") by a static one ("is $(x,u)$ in $Q_V$?"). A policy is safe from every viable state if and only if it maps viable states into $Q_V$: necessary because any pair outside $Q_V$ lands outside $X_V$ and therefore fails in finite time, sufficient because every state in $X_V$ has a pair in $Q_V$ available, so the choice can be repeated forever (Massiani, Heim & Trimpe, L4DC 2021). Every safety filter, shield and safe value function in this section is, at bottom, a way of never leaving $Q_V$.

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).

Algorithm 1: Viability iteration (finite $X \times U$, deterministic $f$)
  1. $X^0 \leftarrow X \setminus X_F$ // optimistic start: every state that has not failed yet
  2. repeat
  3. $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
  4. until $X^{k+1} = X^k$
  5. 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).

Proof — Algorithm 1 returns exactly $X_V$

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.

Connection to Module 10 — reachability values are not Lagrange values
HJ reachability also encodes $X_V$ in a value function, but one of a different type: $V_{\mathrm{BRT}}(x) = \sup_{u} \inf_{t \ge 0} \ell(\varphi^u_x(t))$ with $\ell$ a signed distance to $X_F$ (see Primer A), whose positive level certifies a safety margin; identifying its zero superlevel set with $X_V$ needs additional boundary assumptions. This is a minimum over time along the trajectory, not a discounted integral, so it is not a Lagrange-type value function and does not come with the usual RL machinery. Fisac et al., ICRA 2019 showed that its discounted version $V(s) = (1-\gamma)\ell(s) + \gamma \min\{\ell(s), \max_a V(s^+_a)\}$ is a contraction (see Primer E) and can be learned by Q-learning (see Primer E). Safe value functions, by contrast, keep the standard discounted return and ask when it already encodes the kernel.
Going deeper — the signed distance and why the zero level is delicate

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).

Worked example — The shelf: a one-dimensional kernel with a known time-to-failure

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\}$,

$$\dot x = \begin{cases} u(x), & x \in [0, L), \\ -L/T_f, & x \in (-L, 0), \\ 0, & \text{otherwise}, \end{cases} \qquad X_F = \{-L\}.$$

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.

Worked example — The hovership toy model of Heim et al.

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$.

Definition — Safety measure, Q-safety measure, safe level sets (Heim et al., Defs. 3–5)
The safety measure $\Lambda(s) \in \mathbb{R}_{\ge 0}$ is the volume of the slice of the viable set at $s$, $$\Lambda(s) = \operatorname{vol}\{a \in A : (s,a) \in Q_V\},$$ with the Lebesgue measure on continuous action spaces (assuming measurability) and the counting measure on discrete ones. The Q-safety measure transports it to state-action space through the dynamics, $\Lambda_Q(q) = \Lambda(T(q))$. For a level $\lambda \ge 0$ the safe level sets are $S_\lambda = \{s : \Lambda(s) \gt \lambda\}$ and $Q_\lambda = \{q : \Lambda_Q(q) \gt \lambda\}$. With the counting measure viability means $\Lambda(s) \gt 0$ (a viable state has at least one viable action), so the viable set is recovered as $Q_V = Q_{\lambda = 0}$. With the Lebesgue measure this needs every nonempty slice $\{a : (s,a) \in Q_V\}$ to have positive volume, which the paper assumes tacitly: a viable state whose only viable input is a single point has $\Lambda(s) = 0$.
Intuition
A high $\Lambda(s)$ means many viability-maintaining actions are available: the agent can be sloppy. A low value means the agent must be precise and deliberate, because few actions avoid failure now and in the future. Sampling from $Q_\lambda$ moves the system to a state $s'$ with $\Lambda(s') \gt \lambda$, i.e. with more than $\lambda$ viable actions to choose from, which is useful when disturbances are expected. The paper adds that the margin can then be kept indefinitely; that does not follow from the definitions alone, because a state with $\Lambda(s') \gt \lambda$ need not have any successor with $\Lambda \gt \lambda$ (two viable actions that both lead to a state with a single viable action). An indefinite margin needs the viability kernel of $S_\lambda$, computed like $X_V$ with $S_\lambda$ in place of $X \setminus X_F$. The measure implicitly encodes both the dynamics and the failure set; nothing else about the system needs to be known. Section 5 will show that maximum-entropy RL is drawn to high-$\Lambda$ states on its own.

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.

Theorem — Tabular safety-measure convergence (Heim et al. 2019, Thm. 1)
Let $S$ and $A$ be finite and the transition map $T$ deterministic (discrete time; the setting of the paper's Appendix A, not the GP of the practical algorithm). The estimate of the viable set is $\hat Q_V=\{q:\hat\Lambda_Q(q)\gt0\}$ and the state estimate counts its slice, $\hat\Lambda(s)=\#\{a\in A:\hat\Lambda_Q(s,a)\gt0\}$. Use the tabular update $\hat\Lambda_Q(q) \leftarrow 0$ after a failure and $\hat\Lambda_Q(q) \leftarrow \hat\Lambda(s')$ otherwise. If every pair $q\in Q$ is updated infinitely often (the paper's "infinite random sampling over $Q$"; independent draws that give every pair positive probability achieve this with probability one), then $\hat\Lambda_Q$ converges to the correct value $0$ for all $q \in Q_V^c$ (the unviable and failed pairs). Once this has happened, $\hat Q_V$ is tightly bounded from above and $\hat\Lambda \le \Lambda$; if the estimate was initialised optimistically on the viable pairs, $Q_V \subseteq \hat Q_V$ (i.e. $\hat\Lambda_Q \gt 0$ on $Q_V$, implied by the pointwise $\hat\Lambda_Q \ge \Lambda_Q$), it converges to the true measure. The paper phrases the optimism state-wise, "initially $\hat\Lambda \ge \Lambda$", which is not enough (counterexample below).

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.

Algorithm idea — A GP over $\Lambda_Q$ with an optimistic and a cautious set
Model $\hat\Lambda_Q(q) \mid \mathcal{D} \sim \mathcal{N}(\mu(q), \sigma^2(q))$ with a Gaussian process (Module 3) on $\mathcal{D} = \{(q_i, \hat\Lambda_i(s'_i))\}$ (a practical approximation: the mass below zero is read as the probability of the point being unviable). Then $P[\hat\Lambda_Q \gt \lambda \mid \mathcal{D}] \approx 1 - F_{\hat\Lambda_Q}(\lambda)$ with $F$ the normal CDF (see Primer C), and two thresholded sets drive learning: $$\begin{aligned} \hat Q_{\mathrm{opt}}(\gamma_{\mathrm{opt}}) &= \{q : P[\hat\Lambda_Q \gt 0] \gt \gamma_{\mathrm{opt}}\}, \\ \hat Q_{\mathrm{caut}}(\gamma_{\mathrm{caut}}, \lambda_{\mathrm{caut}}) &= \{q : P[\hat\Lambda_Q \gt \lambda_{\mathrm{caut}}] \gt \gamma_{\mathrm{caut}}\}. \end{aligned}$$ $\hat Q_{\mathrm{opt}}$ is used to compute $\hat\Lambda$ (optimism, needed for convergence); $\hat Q_{\mathrm{caut}}$ is used for active sampling (caution, needed to avoid failures). Choosing $\lambda_{\mathrm{caut}}\ge0$ and $\gamma_{\mathrm{caut}} \ge \gamma_{\mathrm{opt}}$ gives $\hat Q_{\mathrm{caut}} \subseteq \hat Q_{\mathrm{opt}}$, so the agent never purposefully explores outside its current estimate of the viable set. (Here $\gamma_{\mathrm{opt}}$, $\gamma_{\mathrm{caut}} \in [0,1]$ are confidence levels, not discount factors.)
Derivation — the exceedance probability and why the cautious set is inside the optimistic one

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\}$.

Algorithm 2: Learning the safety measure (Heim et al., Alg. 1)
  1. Input: initial GP estimate $\hat\Lambda_Q$, thresholds $\gamma_{\mathrm{caut}}, \gamma_{\mathrm{opt}}, \lambda_{\mathrm{caut}}$, initial state $s_0$, budget $n$
  2. while $i \lt n$:
  3. 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}}\}$
  4. 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
  5. else: $a_i \leftarrow \arg\max_{a \in A_{\mathrm{caut}}} \sigma^2(s_i, a)$ // explore where the GP is most uncertain
  6. $(s_{i+1}, \mathrm{failed}) \leftarrow T(s_i, a_i)$
  7. 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}}$
  8. 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.

Caveat
The Gaussian likelihood is a modelling convenience: $\Lambda_Q$ is non-negative and has an atom at zero (a positive probability of being exactly zero; Primer C), which a normal distribution cannot represent. Once confidence thresholds replace the optimistic-and-exhaustive sampling of Theorem 1, the convergence guarantee is lost; the paper states this explicitly and shows convergence to conservative subsets empirically. The "8% failure rate" is a training statistic, not a bound. Compare with the GP bounds of Module 3, which are rigorous but need an RKHS-norm bound on the target function.

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),

$$\mathrm{OPT}(K) : s \mapsto \operatorname*{arg\,min}_{a \in A}\ J(s,a) \quad \text{s.t. } (s,a) \in K,$$

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.

Definition & Theorem — Critical set and admissible constraints (L4DC 2021, Def. 5 and Thm. 6)
The critical set is the set of unviable pairs at viable states that the projection would prefer over the optimal viable action: $$Q_{\mathrm{crit}} = \{(s,a) \in Q \setminus Q_V : s \in S_V,\ J(s,a) \le J(s, \mathrm{OPT}(Q_V)(s))\}.$$ Theorem 6. Assume $Q_V$ is closed, and let $K$ be closed with $\mathrm{OPT}(Q_V) \subseteq K$ (as a set of state-action pairs). Then $\mathrm{OPT}(K)(s) = \mathrm{OPT}(Q_V)(s)$ for all $s \in S_V$ if, and only if, $K \cap Q_{\mathrm{crit}} = \emptyset$. Such a $K$ is called admissible.

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.

Pitfall — two critical sets
The 2025 entropy paper (Section 5) reuses the name $Q_{\mathrm{crit}}$ for the larger set $Q_U \cap (X_V \times A)$, all unviable actions at viable states, with no reference to a nominal policy. The L4DC critical set is the subset of those that beat $\mathrm{OPT}(Q_V)$ for the cost $J$. Both are "the pairs that must be excluded"; only the reference policy differs.

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

$$G(x,u) = \int_{\mathbb{T}} e^{-t/\tau}\, r\big(\varphi^u_x(t), \hat u_x(t)\big)\, dt, \qquad \hat u_x(t) = u(\varphi^u_x(t)),$$

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$,

$$\begin{gathered} v(x) = \sup_{u \in \mathcal{U}} \left[ \int_0^{t} e^{-s/\tau} r\big(\varphi^u_x(s), \hat u_x(s)\big)\, ds + e^{-(t + \delta t)/\tau}\, v\big(\varphi^u_x(t + \delta t)\big) \right], \\ \delta t = \begin{cases} 1 & \mathbb{T} = \mathbb{N} \\ 0 & \mathbb{T} = \mathbb{R}_+ \end{cases} \end{gathered}$$

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$.

Lemma — The discounted risk (Massiani et al., Lemma 1)
For $x \in X$ and $u \in \mathcal{U}$ define $$\rho(x,u) = \int_{\mathbb{T}} e^{-t/\tau}\, \delta_{X_F}\big(\varphi^u_x(t)\big)\, dt,$$ where $\delta_{X_F}$ is the indicator function of $X_F$ in discrete time and, in the paper's words, "the Dirac distribution" in continuous time. The continuous-time case is a convention about events in time: $\delta_{X_F}(\varphi^u_x(t))\,dt$ stands for the unit point mass $\delta_{t_f}(dt)$ at the failure instant. A spatial Dirac composed with the trajectory would not give this: for a scalar crossing of $x_F$ at speed $\dot x(t_f) \ne 0$, $\int \delta(x(t) - x_F)\,dt = 1/|\dot x(t_f)|$, and a general closed set $X_F$ has no canonical Dirac distribution at all. Then $u$ is safe for $x$ if, and only if, $\rho(x,u) = 0$.

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.
Key equation — The constrained problem (C) and the penalised problem (P)
The task is to maximise the expected return over safe controllers, for an initial distribution $\mu$ supported in $X_V$ (see Primer C): $$\text{(C)} \qquad \sup_{u \in \mathcal{U}_{\mathrm{safe}}} \mathbb{E}_{x \sim \mu}\big[G(x,u)\big], \qquad\qquad V : x \in X_V \mapsto \sup_{u \in \mathcal{U}_{\mathrm{safe}}} G(x,u),$$ where $V$ is the constrained value function, defined on the kernel only. Since constrained optimal control is hard, common practice relaxes the constraint and penalises failure by replacing $r$ with $r - p\,\delta_{X_F}$ for a constant designer-chosen penalty $p \in \mathbb{R}_+$: $$\text{(P)} \qquad V_p : x \in X \mapsto \sup_{u \in \mathcal{U}} \big[G(x,u) - p\,\rho(x,u)\big].$$ The supremum in (P) is assumed to be attained; its maximisers are the optimal controllers of $V_p$. Attainment is meant uniformly: there is a feedback controller that attains $V_p(x)$ at every $x$ at once (the paper's proof starts from "any controller that achieves $V_p$ for all $x$"; on finite deterministic problems dynamic programming supplies a stationary one). Problem 1: under what conditions on $p$ are the solutions of (P) both safe and optimal for (C)?
Definition — Safe value function (Massiani et al., Def. 3) and Proposition 1
$V_p$ is a safe value function (SVF) if all of its optimal controllers are both safe and optimal with respect to (C). Every SVF is a value function in the classical RL sense, so it can be learned with standard algorithms.

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$

Key insight — optimality is decoupled from safety
For an SVF, optimal trajectories that start inside $X_V$ never leave it, so the values on $X_V$ are unaffected by whatever the reward does outside. As long as the reward on $X_V$ is the one of (C), all SVFs coincide on $X_V$ and do not depend on $p$. Modifying the reward only where it affects $X_U$ is therefore a free degree of freedom for enforcing safety. The catch is that $X_V$ is rarely known, so we want conditions under which a plain failure penalty, which the designer can always write down, has this property.

Three reward constants will control everything that follows. For discrete time, with $Q_V$ and $Q_U$ from Section 1,

$$R_{Q_U} = \sup_{Q_U} r, \qquad R_{Q_V} = \inf_{Q_V} r, \qquad R_{X_U} = \sup_{X_U \times U} r .$$

$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).

Connection to Module 8 — the 0-risk CMDP
(C) is a constrained MDP (Module 8) whose running cost is $\delta_{X_F}$ and whose threshold is exactly $0$: Massiani et al. call it the 0-risk CMDP, as opposed to bounded-risk CMDPs with $\rho \le \eta$, $\eta \gt 0$. The constraint $\rho = 0$ can be rewritten as a trajectory constraint, "stay in $X_V$", so (C) is an unconstrained MDP on the state space $X_V$ with state-dependent action set $Q_V[x]$ (Section V-B of the paper). That is why, unlike general CMDPs, it has deterministic optimal controllers that do not depend on $\mu$ (Remark 5), and why value-function tools apply to it at all. The same fact will explain, in Section 4, why penalties work for $\eta = 0$ but not for $\eta \gt 0$.

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".

Theorem — Zeroth-order safety (Massiani et al. 2023, Thm. 1)
Take the setting of Section 3: deterministic dynamics with well-defined trajectories (continuous in continuous time), a measurable and bounded reward, $\tau \gt 0$ (so $0 \lt \gamma \lt 1$), a closed absorbing $X_F$ with the sink convention, a penalty $p \ge 0$, a nonempty $X_V$, and the supremum in (P) attained uniformly. In addition, the constrained value must obey the dynamic-programming identity of Section 3 over safe controllers: after a safe prefix, the rest of the return can be replaced by an arbitrarily near-optimal safe continuation within the admissible controller class. (The paper's proof uses this identity without comment. It holds for time- or history-dependent controllers, which can switch by a clock, and on finite deterministic problems, where (C) is an MDP on $X_V$ with action sets $Q_V[x]$; for stationary feedback in continuous time it is an assumption.) Suppose the zeroth-order condition holds: $$\text{(Za)} \qquad \sup_{X_U} V_p \ \lt\ \inf_{X_V} V \qquad\qquad \text{if } \mathbb{T} = \mathbb{R}_+,$$ $$\text{(Zb)} \qquad R_{Q_U} + \gamma \sup_{X_U} V_p \ \lt\ R_{Q_V} + \gamma \inf_{X_V} V \qquad \text{if } \mathbb{T} = \mathbb{N}.$$ Then $V_p$ is a safe value function: all of its optimal controllers are safe and optimal for (C).

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.

Proof sketch — Theorem 1: splitting the return at the exit time

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$):

$$\begin{aligned} (G - p\rho)(x,u_F) &= \underbrace{\int_0^{s_\epsilon} e^{-t/\tau} r\, dt}_{\text{shared part}} + \int_{s_\epsilon}^{T+\epsilon} e^{-t/\tau} r\, dt + e^{-(T+\epsilon+\delta t)/\tau}\,(G - p\rho)(y_\epsilon, u_F), \\ y_\epsilon &= \varphi^{u_F}_x(T + \delta t + \epsilon) \in X_U . \end{aligned}$$

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$

Caveat — (Z) forces a discontinuous value function
In continuous time, (Za) puts a uniform gap between the values on the two sides of the kernel: $V_p \ge V \ge \inf_{X_V} V$ on $X_V$ (weak duality) and $V_p \le \sup_{X_U} V_p \lt \inf_{X_V} V$ on $X_U$. So $V_p$ cannot be continuous at a point of $\partial X_V$ that is approached both by viable and by unviable states. (On a finite state space, as in the examples and the explorer, this is no obstruction: there every function is continuous.) The paper's Remark 3 states that both (Z) and Assumption 1 below "require non-Lipschitz dynamics", citing Bardi and Capuzzo-Dolcetta's result (stated precisely below this box) that Lipschitz dynamics with uniformly continuous running costs give continuous value functions. Read this as a warning about the typical case, not as a theorem: the failure penalty is a Dirac cost, which that continuity result does not cover, and Exercise 7.1 shows a linear system (a double integrator with a wall and bounded velocity) that satisfies Assumption 1. The mechanism behind the warning is continuous dependence on initial conditions. A doomed state just outside $X_V$ follows the trajectory of a nearby viable state for a long time, so if viable trajectories near $\partial X_V$ stay away from $X_F$ for long, as near a saddle-type boundary, the time-to-failure is unbounded. In the double integrator the viable neighbours brake to rest just short of the wall after a bounded time, which is why $T_f$ stays bounded. The authors argue that such unbounded predicted times-to-failure are a feature of models rather than of reality: a Lipschitz model often predicts an unbounded time-to-failure near $\partial X_V$ that is not observed. Their Appendix B gives two examples. For the linear inverted pendulum model of walking, the border of the $N$-step capture region is $d_N = \ell_{\max} \sum_{i=1}^N (e^{-\Delta t'_s})^i$, with limit $d_\infty = \ell_{\max} e^{-\Delta t'_s}/(1 - e^{-\Delta t'_s})$; the model implies states from which stopping, and conversely falling, takes infinitely many steps, whereas numerical studies of such models, real robots and human walkers indicate that whenever falling can be avoided, a stop is possible within two steps. For landing honeybees, the measured exponential approach implies an infinite time-to-touchdown, yet bees land because they extend their legs. A model that is excellent for control can be poor at bounding the time-to-failure, and Assumption 1 is a statement about the latter.
Background — Capture regions of the linear inverted pendulum

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.

Theorem — Continuity of discounted value functions (Bardi & Capuzzo-Dolcetta 1997; a sufficient version)
Let $U$ be compact, $f:\mathbb R^n\times U\to\mathbb R^n$ continuous and globally Lipschitz in $x$ with a constant $L_f$ independent of $u$, and $\sup_{u\in U}\|f(0,u)\|\lt\infty$ (so solutions exist for all time). Let the reward be bounded, $|r|\le M$, continuous, and uniformly continuous in $x$ uniformly in $u$: $|r(x,u)-r(y,u)|\le\omega(\|x-y\|)$ with $\omega(s)\to0$ as $s\to0$. Over all measurable open-loop inputs $u:[0,\infty)\to U$ define $v(x)=\sup_u\int_0^\infty e^{-t/\tau}r(x_u(t),u(t))\,dt$ with $\tau\gt0$, with no state constraints, stopping set, terminal cost or event penalty. Then $v$ is bounded and uniformly continuous.

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

Assumption 1 — Uniformly bounded time-to-failure
The time-to-failure in $X_U$ is uniformly upper bounded by some $T_f \in \mathbb{T}$: for every $x \in X_U$ and every controller $u$, the trajectory $\varphi^u_x$ enters $X_F$ at a time $t_f(x,u) \le T_f$. $T_f$ is the time-scale of failure of the system; viability theory only says $t_f$ is finite, the assumption asks for a common bound.
Lemma — Influence of the penalty (Massiani et al., Lemma 2)
Under Assumption 1: (i) for every $x \in X$ the map $p \mapsto V_p(x)$ is nonincreasing; (ii) the value function is uniformly upper bounded on $X_U$, $$\begin{aligned} \sup_{X_U} V_p &\le R_{X_U}\, \tau \big(1 - e^{-T_f/\tau}\big) - p\, e^{-T_f/\tau} && (\mathbb{T} = \mathbb{R}_+), \\ \sup_{X_U} V_p &\le R_{X_U}\, \frac{1 - \gamma^{T_f + 1}}{1 - \gamma} - p\, \gamma^{T_f} && (\mathbb{T} = \mathbb{N}), \end{aligned}$$ with $R_{X_U} = \sup_{X_U \times U} r$.

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$

Common mistake — $R_{X_U}$ is never negative
The bound on the reward part uses $R_{X_U} \ge 0$: it upper-bounds $\sum_{t \le t_f} \gamma^t r_t$ by $R_{X_U} \sum_{t \le T_f} \gamma^t$, which only holds if adding the terms between $t_f$ and $T_f$ cannot decrease the right-hand side. The paper does not state this sign condition; it holds in its examples because the failure states themselves carry zero reward ($r(-L) = 0$ on the shelf) and $X_F \subset X_U$. With a living cost $r = -c$ on the whole unviable region, failure states included, it is tempting to plug in $R_{X_U} = -c$; that gives a bound that is false (the agent can fail early and stop paying). Use $R_{X_U} = \max\{0, \sup_{X_U \times U} r\}$. No sign condition is needed for $R_{Q_U}$ and $R_{Q_V}$, which enter (Zb) through a single transition. In the explorer the cliff cells have zero reward, so its $R_{X_U}$ is automatically non-negative.

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.

Theorem — A finite penalty threshold (Massiani et al., Thm. 2)
Under Assumption 1 there exists a finite threshold $p^\star \in \mathbb{R}$ such that for all penalties $p \ge 0$ with $p \gt p^\star$ the penalised value function $V_p$ is safe and the zeroth-order condition (Z) holds, with $$p^\star = \Big(R_{X_U}\,\tau - \inf_{X_V} V\Big)\, e^{T_f/\tau} - R_{X_U}\,\tau \qquad (\mathbb{T} = \mathbb{R}_+),$$ $$p^\star = \frac{1}{\gamma^{T_f}} \left[ R_{X_U}\, \frac{1 - \gamma^{T_f+1}}{1 - \gamma} + \frac{R_{Q_U} - R_{Q_V}}{\gamma} - \inf_{X_V} V \right] \qquad (\mathbb{T} = \mathbb{N}).$$ Proof. Insert the upper bound of Lemma 2(ii) into the left-hand side of (Za) or (Zb) and solve for $p$; the bound then guarantees (Z), and Theorem 1 gives safety. Since $p \mapsto \sup_{X_U} V_p$ is nonincreasing, every $p \gt p^\star$ works as well. $\square$

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\}$.

Caveat — quoting (18b)
The paper prints (18b) with square brackets around the whole sum, all of it multiplied by $1/\gamma^{T_f}$, which is the form above (and (18a) likewise brackets $R_{X_U}\tau - \inf_{X_V} V$). Plain-text copies of the formula (PDF text extraction, some summaries) lose the brackets and seem to attach $\gamma^{-T_f}$ to $\inf_{X_V} V$ only, $R_{X_U}\frac{1-\gamma^{T_f+1}}{1-\gamma} + \frac{R_{Q_U}-R_{Q_V}}{\gamma} - \inf_{X_V} V \cdot \frac{1}{\gamma^{T_f}}$; that reading does not follow from Lemma 2(ii) and (Zb); the two agree when $T_f = 0$ but differ in general. The derivation is three lines, so when in doubt re-derive rather than quote:
Derivation — The discrete-time threshold from Lemma 2(ii) and (Zb)

(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):

$$R_{Q_U} + \gamma \left[ R_{X_U}\frac{1 - \gamma^{T_f+1}}{1 - \gamma} - p\,\gamma^{T_f} \right] \ \lt\ R_{Q_V} + \gamma \inf_{X_V} V .$$

Collect the $p$ term on the right (it appears as $-\gamma^{T_f+1} p$ on the left):

$$\gamma^{T_f+1}\, p \ \gt\ R_{Q_U} - R_{Q_V} + \gamma R_{X_U}\frac{1 - \gamma^{T_f+1}}{1 - \gamma} - \gamma \inf_{X_V} V .$$

Divide by $\gamma^{T_f+1} \gt 0$ and factor $\gamma^{-T_f}$:

$$p \ \gt\ \frac{1}{\gamma^{T_f}} \left[ \frac{R_{Q_U} - R_{Q_V}}{\gamma} + R_{X_U}\frac{1 - \gamma^{T_f+1}}{1 - \gamma} - \inf_{X_V} V \right] = p^\star .$$

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.

Why it matters — "large penalty" is not a free lunch
In theory larger penalties never hurt: the value on $X_V$ is unchanged for $p \gt p^\star$ and the values on $X_U$ just go to $-\infty$. In practice values and policies are approximated numerically (see Primer E), and an arbitrarily large penalty produces an ill-conditioned problem (large penalty targets and small safe rewards have competing numerical scales; see Primer B) and poor exploration, the same issue as in classical penalty methods; augmented-Lagrangian schemes exist precisely to keep the penalty small but sufficient. Two theory-guided remedies follow from the formula. Fail fast: if two unviable states are causally related, penalise the one that occurs first, which shortens $T_f$. Tune the discount with care: a larger $\tau$ propagates the penalty further up a failed trajectory and shrinks $e^{T_f/\tau}$, but if the reward is negative inside $X_V$ a larger $\tau$ also lowers $\inf_{X_V} V$ and can raise $p^\star$ again; on the shelf example $p^\star(\tau)$ is non-monotone (Fig. 2 of the paper). And choose $p$ relative to the reward scale: every term in the bracket is a reward, so doubling all rewards doubles $p^\star$.
Background — Augmented Lagrangians

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$.

Worked example — The shelf solved analytically: the bound is tight

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}$:

$$V_p(x) = \max\left\{ \tau\Big(e^{\frac{x-L}{v\tau}} - 1\Big),\ \ \tau\Big[\big(2 - e^{-T_f/\tau}\big)e^{-\frac{x}{v\tau}} - 1\Big] - p\, e^{-\frac{1}{\tau}\left(T_f + \frac{x}{v}\right)} \right\}, \qquad 0 \le x \lt L .$$

(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.

$$\tau\big(e^{-L/(v\tau)} - 1\big) \ \gt\ \tau\big(1 - e^{-T_f/\tau}\big) - p\, e^{-T_f/\tau} \quad\Longleftrightarrow\quad p \ \gt\ \tau\big(2 - e^{-L/(v\tau)}\big)\, e^{T_f/\tau} - \tau ,$$

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

Proposition — Thresholding and a CBF (Massiani et al., Props. 2 and 3)
Let $V_p$ be an SVF for which (Z) holds, and let $\alpha_{\inf}$, $\alpha_{\sup}$ be the left- and right-hand sides of (Z) for the relevant $\mathbb{T}$. For every $\alpha \in (\alpha_{\inf}, \alpha_{\sup}]$, $$\begin{aligned} X_V &= \{x : V_p(x) \ge \alpha\} && (\mathbb{T} = \mathbb{R}_+), \\ X_V &= \{x : \exists u \in Q_V[x],\ r(x,u) + \gamma V_p(x) \ge \alpha\} && (\mathbb{T} = \mathbb{N}). \end{aligned}$$ (Read literally, the discrete version is satisfied by every $x$ with $Q_V[x] \neq \emptyset$ and presupposes the viable set. The informative reading, which follows from (Zb) by the same argument, thresholds the one-step look-ahead over all inputs: $X_V = \{x : \exists u \in U,\ r(x,u) + \gamma V_p(f(x,u)) \ge \alpha\}$, because on $X_U$ every input gives at most $R_{Q_U} + \gamma \sup_{X_U} V_p = \alpha_{\inf}$ and on $X_V$ some input gives at least $R_{Q_V} + \gamma \inf_{X_V} V = \alpha_{\sup}$. The paper's Remark 4 adds that if moreover $\inf_{X_V} V \gt \sup_{X_U} V_p$, the continuous-time form holds in discrete time too.) If moreover $\mathbb{T} = \mathbb{R}_+$, $V_p|_{X_V}$ is continuously differentiable (its gradient exists and is continuous), $X_V$ is compact and $\partial V_p / \partial x \neq 0$ on $\partial X_V$, the paper concludes (Prop. 3) that $h = V_p|_{X_V} - \alpha$ is a control barrier function of $X_V$ (Module 10). This holds only in a restricted-domain sense that certifies nothing: for $\alpha \lt \alpha_{\sup}$, $h \ge \inf_{X_V} V - \alpha \gt 0$ on all of $X_V$, boundary included (see below).
Background — Control barrier functions and Lie derivatives

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.

Theorem — Converse CBF condition (Ames et al. 2019)

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 designEffect on (Z) and $p^\star$Satellite example
Parsimonious: $+1$ at task success (inside $X_V$), $0$ elsewhereWithout 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 outsideContinuous 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 velocityRaise $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$ otherwiseLower $\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$
Pitfall — penalties do not solve bounded-risk problems
The equivalence of (P) and (C) is specific to the 0-risk constraint. For a bounded-risk CMDP, $\rho \le \eta$ with $\eta \gt 0$, strong duality still holds (Paternain et al., NeurIPS 2019; Altman, 1999), so a penalty $p^\star$ exists for which some maximiser of the penalised problem is feasible and optimal, but not all maximisers are. The paper's Example 1: two states, $X_V = \{x_1\}$, $X_F = \{x_2\}$; $u_1$ stays at $x_1$ with reward $0$; $u_2$ moves to $x_2$, where reward $1$ and cost $1$ are collected at time $1$, and the system then moves to the sink, which pays $-p$ at time $2$; $\gamma = 0.1$, $\eta = 0.01$, stochastic controllers that use $u_2$ with probability $\theta$. Read $\theta$ as a one-shot randomisation (use $u_2$ at time $0$ with probability $\theta$, otherwise $u_1$ forever); that is the reading under which the paper's scalar reduction is exact. The bounded-risk problem is $\max_\theta \gamma\theta$ s.t. $\gamma\theta \le \eta$, solved by $\theta^\star = 0.1$, a stochastic controller. The penalised problem is $\max_\theta \gamma\theta(1 - \gamma p)$: for $p \lt 10$ it always fails, for $p \gt 10$ it never risks anything (suboptimal), and at $p = p^\star = 10$ every $\theta \in [0,1]$ is optimal, so an RL algorithm may return an infeasible or a suboptimal solution. (With a stationary per-step randomisation the returns to $x_1$ add a geometric series, which changes the numbers, $\theta^\star = \eta(1-\gamma)/(\gamma(1-\eta)) = 1/11$, but not the conclusion: the penalised objective is still proportional to $1 - \gamma p$.) Optimal controllers of CMDPs are stochastic in general; unconstrained MDPs only produce stochastic optima through ties. For further methods with $\eta \gt 0$, see the primal-dual machinery in Module 8, or state augmentation (Module 8).

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.

Caveat — what the theory does not cover
The results assume deterministic dynamics (the authors expect an extension through the invariance or discriminating kernel, the robust version of $X_V$; when that kernel is empty, penalising failure is expected to harm optimality and bounded-risk constraints are the right tool), an attained supremum, and exact dynamic programming. With function approximation the values inside and outside $X_V$ are coupled by the approximator, the learned approximation need not satisfy the exact DP identity, and whether a finite penalty still guarantees safety and constrained optimality is stated as an open question. The inputs of the formula, $T_f$ and $\inf_{X_V} V$, are rarely available; the formula is meant as structure, not as a number to look up.
Background — Robust viability and discriminating kernels

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)$.

Setting — Maximum-entropy RL in one box
Return $G(x,\pi) = \sum_t \gamma^t r(X_t, A_t)$ with expectation $\bar G$; discounted cumulative entropy $S(x,\pi) = \sum_t \gamma^t H(\pi(\cdot \mid X_t))$ with expectation $\bar S$. The entropy-regularised objective with temperature $\alpha \ge 0$ is $\max_\pi \bar G(x,\pi) + \alpha \bar S(x,\pi)$ for all $x$. For $\alpha \gt 0$ its optimal soft Q-function $q$ satisfies $$q(x,a) = r(x,a) + \gamma \alpha \ln \sum_{b \in A} \exp\Big(\tfrac{1}{\alpha} q(x', b)\Big), \qquad x' = f(x,a),$$ equivalently $q(x,a) = \max_\pi\big[r(x,a) + \gamma \bar G(x',\pi) + \alpha\gamma \bar S(x',\pi)\big]$, and the optimal policy is the softmax $\pi_{\mathrm{opt}}(a \mid x) = \operatorname{softmax}\big(q(x,\cdot)/\alpha\big)(a)$. Both formulas divide by $\alpha$; at $\alpha = 0$ (their zero-temperature limit) they become the ordinary Bellman equation $q(x,a) = r(x,a) + \gamma \max_b q(x',b)$, and the optimal policies are those supported on $\arg\max_b q(x,b)$. The mode of a policy is the uniform distribution on $\arg\max_a \pi(a \mid x)$. Failure set $X_C$; kernel $X_V = \{x : \exists\pi,\ \forall t \gt 0,\ \Pr[X_t \notin X_C] = 1\}$; viable set $Q_V = \{(x,a) : x \in X_V,\ f(x,a) \in X_V\}$; $Q_U = Q \setminus Q_V$ and $Q_{\mathrm{crit}} = Q_U \cap (X_V \times A)$. $\Pi_V(x)$ are the policies safe from $x$ and $\Pi_V = \bigcap_{x \in X_V} \Pi_V(x)$.
Definition — $\delta$-safety and dynamic indicators (Defs. 2 and 3)
A policy is safe if it is safe from every $x \in X_V$. For $\delta \gt 0$ it is $\delta$-safe if $\max_{Q_{\mathrm{crit}}} \pi \le \delta$: no critical action gets more than $\delta$ probability at any viable state (Remark 1: bounding the total mass on critical actions by $\delta$ instead is equivalent up to the factor $|Q_{\mathrm{crit}}[x]|$). A cost $c : Q \to \mathbb{R}_{\ge 0}$ with discounted risk $\rho(x,\pi) = \sum_t \gamma^t c(X_t, A_t)$ (a random variable) and expected risk $\bar\rho = \mathbb{E}[\rho]$ is a dynamic indicator of $X_C$ if, for all $x \in X_V$, $\bar\rho(x,\pi) \gt 0$ iff $\pi \notin \Pi_V(x)$. The indicator of $X_C$ composed with the dynamics is one (that is Lemma 1 of Section 3); an indicator that fires earlier on doomed trajectories lowers the required penalty.

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]|$:

$$\forall \pi \in \Pi_V, \ \forall x \in X_V: \qquad H\big(\pi(\cdot \mid x)\big) \ \le\ \ln |Q_V[x]| \ =\ \ln \Lambda(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.

Theorem — Temperature controls robustness (Def. 4, Thm. 1, Cor. 1)
Call $\pi_1 \in \Pi_V$ less $S$-robust than $\pi_2 \in \Pi_V$, written $\pi_1 \preceq \pi_2$, if $\bar S(x,\pi_1) \le \bar S(x,\pi_2)$ for all $x \in X_V$. Let $\pi^\star_\alpha$ solve the constrained problem $\max_{\pi \in \Pi_V} \bar G + \alpha \bar S$ (for $\alpha = 0$ this is the unregularised constrained problem) and $\pi^\star_{\mathrm{ent}} = \arg\max_{\pi \in \Pi_V} \bar S$ the maximum-entropy safe policy, with soft Q-functions $Q_\alpha$ and $Q_{\mathrm{ent}}$. Theorem 1: $\max_{Q_V} |\tfrac{1}{\alpha} Q_\alpha - Q_{\mathrm{ent}}| \to 0$ as $\alpha \to \infty$. Corollary 1: the map $\alpha \mapsto \pi^\star_\alpha$ is monotone for $\preceq$ and $\max_{Q_V}|\pi^\star_\alpha - \pi^\star_{\mathrm{ent}}| \to 0$ as $\alpha \to \infty$. In words: raising the temperature makes the safe optimum monotonically more robust and drives it to the policy that maximises future viable options, at the price of task performance.

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

$$\pi^\star_{\alpha,p} = \operatorname*{arg\,max}_{\pi \in \Pi} \ \bar G(x,\pi) + \alpha \bar S(x,\pi) - p\,\bar\rho(x,\pi),$$

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.

Theorem — $\delta$-safety and closeness for large penalties (Massiani et al. 2025, Thm. 2 and Cor. 2)
For any $\delta \gt 0$, $\epsilon \gt 0$ and $\alpha \gt 0$ there exists $p^\star \ge 0$ such that for all $p \gt p^\star$ the optimal policy $\pi^\star_{\alpha,p}$ of the penalised problem is $\delta$-safe and $$\max_{Q_V} \big|\pi^\star_{\alpha,p} - \pi^\star_\alpha\big| \ \lt\ \epsilon .$$ Corollary 2: there is $\bar\delta \in (0,1)$ such that for $\delta \in (0, \bar\delta)$ the policy that follows the mode of $\pi^\star_{\alpha,p}$ is safe. So a sufficiently penalised, entropy-regularised, unconstrained problem, which SAC can attack directly, yields a policy whose mode is exactly safe and whose stochastic version is as close as desired to the robust constrained optimum.

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.

Caveat — finite spaces, continuous practice
Lemma 2 of the paper uses $|A| \lt \infty$ and the finiteness of $Q_{\mathrm{crit}}$ (to get a positive minimum $u_3$), and the whole analysis is for deterministic dynamics. SAC on continuous action spaces is the practical algorithm of the experiments, not an instance of the theorem. The $\delta$-safety notion is per action ($\max_{Q_{\mathrm{crit}}} \pi \le \delta$); the total mass on critical actions can be up to $\delta |Q_{\mathrm{crit}}[x]|$. Finally, the paper formally treats a non-terminal failure set (the agent keeps acting after visiting $X_C$) and states that the results also hold when failure ends the episode (its Remark 2); the entropy sum is why the sink bookkeeping of Section 1 is not used there.

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,

$$\begin{aligned} \min_{u_{0|t},\dots,u_{N-1|t}}\ & \|a_t - u_{0|t}\|_2^2 \\ \text{s.t.}\quad & R_{n|t} \times v_{n|t} \subseteq (\mathbb{S} \times \mathbb{A}) \cap C_j \quad (n = 0,\dots,N-1), \qquad R_{N|t} \subseteq T_j, \end{aligned}$$

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

$$C = \Big\{(s,a) \in \mathbb{S} \times \mathbb{A} : \tfrac{1}{n_S}\operatorname{tr} G(s,a) \ge \xi\Big\}, \qquad \tfrac{1}{n_S}\operatorname{tr} G \in [0,1],$$

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.

Theorem — Tube over-approximation (Frauenknecht et al. 2026, Thm. 1)
Consider $s_{t+1}=\mu(s_t,a_t)+L(s_t,a_t)w_t$ with $w_t\in W=\{w:\|w\|_2^2\le\epsilon\}$ and diagonal $\Sigma=LL^\top$. Assume that on the certain set $C_j$ every ensemble member over-estimates the noise, $\Sigma_{\theta_e}\succeq\Sigma$ (Assumption 2), and the model is unbiased, its mean prediction equals the true mean (Assumption 3); and that $\mu$ is twice continuously differentiable with an $\ell_{\nabla\mu}$-Lipschitz Jacobian, $L$ is $\ell_L$-Lipschitz and the certainty measure $\tfrac{1}{n_S}\operatorname{tr}G$ is $\ell_G$-Lipschitz (Assumption 5). Fix inputs $u_{0|t},\dots,u_{N-1|t}$ and gains $K_{n|t}$, start from $z_{0|t}=s_t$, $P_{0|t}=0$, and propagate the centre by $z_{n+1|t}=\bar\mu(z_{n|t},u_{n|t})$ and the shape by the paper's update: an outer ellipsoid of the Minkowski sum of the linearised image (shape $F_{n|t}P_{n|t}F_{n|t}^\top$, with $F_{n|t}$ the averaged Jacobian of $s\mapsto\bar\mu(s,v_{n|t}(s))$ at $z_{n|t}$), the noise ellipsoid (shape $\epsilon\bar\Sigma$) and a ball whose radius $e_{n|t}$ bounds the linearisation error. Then $R_{n|t}\subseteq\mathcal{P}_{n|t}$ for $n=0,\dots,N$, provided every pair $(s,v_{n|t}(s))$ with $s\in\mathcal{P}_{n|t}$ lies in $C_j$, so that the assumptions apply along the whole tube (the filter enforces this with the tightened certainty constraint). In words: every realisation of the bounded noise keeps the true state inside the tube.

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.

Going deeper — the error radius, and why three ellipsoids fit in one

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.

Caveat
The formal guarantee is for the full formulation; the reported evaluation inside MBPO uses practical simplifications that, as the paper says, break the formal guarantees: a naive Gaussian tube propagation clipped at a probability level, $\ell_G = 0$ (no certainty tightening along the tube), no ancillary controller ($K = 0$), soft constraints with a backup scheme for infeasibility, and a sampled convex approximation of the terminal set. The result there is a substantial reduction of constraint violations compared with an earlier PE-based filter, at return comparable to unfiltered MBPO. As with every learned filter, the guarantee is conditional on the model assumptions inside $C_j$; nothing certifies those assumptions themselves.

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),

$$a_t = \operatorname*{arg\,min}_{a \in A} \|a - \pi(s_t)\|^2 \quad \text{s.t.}\quad w_t^\top a \ge b_t, \qquad (w_t, b_t) = h(\mu(s_t)),$$

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.

Background — Kernel distribution embeddings and tests

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$:

$$\mathcal{L}(u, \lambda) = \mathbb{E}_{x \sim \mu}\big[G(x,u) - \lambda\,\rho(x,u)\big], \qquad d(\lambda) = \sup_{u \in \mathcal{U}} \mathcal{L}(u,\lambda) = \mathbb{E}_{x \sim \mu}\big[V_\lambda(x)\big].$$

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.

Background — Subgradients and multiplier updates

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.

Background — Safety games and sound abstractions

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.

ConceptSafe value functionsHJ reachabilityBarrier functionsShields / filtersCMDPs
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 subsetwinning region $W$ of the safety gamestates where $\rho = 0$ is feasible
Safe actionsmaximisers 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 enterssame value functionseparate task controller, filteredQP objective $\|u - u_{\mathrm{des}}\|^2$learner's action, overriddenreward, with the multiplier
Type of guaranteeexact, all maximisers, deterministic dynamicsexact / robust to $d \in D$exact given a valid $h$exact on the abstractionin 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.

Connection to Modules 4–6
SafeOpt's safe set is a set of controller parameters whose static performance constraint (the threshold condition of Module 4) is certified; viability is a constraint on states along trajectories. GoSafe and GoSafeOpt (Module 6) already bridge the two: a backup policy that is known, under the GP assumptions, to keep the system safe from a visited state is a certified viable controller for that state, and the boundary condition that triggers it acts as a learned shield. Learning the safety measure of Section 2 is the model-free counterpart of GoSafe's learning of "which (parameter, state) pairs are safe".
Open problems
Disturbances (the invariance/discriminating kernel replaces $X_V$; the 0-risk constraint may then be infeasible and bounded risk is the right notion); function approximation (the exact value still satisfies the Bellman equation, but a learned $\hat V$ has a nonzero Bellman residual and couples errors inside and outside $X_V$, so the proof certifies neither $\hat V$ nor its greedy policy without error bounds and action-value margins); estimating $T_f$ and $\inf_{X_V} V$ from data; continuous-time value functions with Lipschitz dynamics, for which higher-order safety conditions would be needed; and the interplay of penalty and temperature in continuous-action maximum-entropy RL, where the finite-space theory of Section 5 does not formally apply.

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.

Fact — Value iteration converges, with a residual bound
On a finite MDP with $0 \lt \gamma \lt 1$ (termination modelled by the absorbing sink), the Bellman backup $(BV)(x)=\max_a\big[r(x,a)+\gamma\sum_y P(y\mid x,a)V(y)\big]$ is a $\gamma$-contraction in the max norm, $\|BV-BW\|_\infty\le\gamma\|V-W\|_\infty$: averaging over slip outcomes and maximising over actions cannot enlarge the largest difference, and discounting shrinks it by $\gamma$ (Primer E). Hence $B$ has a unique fixed point $V^\ast$, iteration converges geometrically, $\|B^kV_0-V^\ast\|_\infty\le\gamma^k\|V_0-V^\ast\|_\infty$, and a table with residual $e=\|BV-V\|_\infty$ is within $e/(1-\gamma)$ of $V^\ast$, because $\|V-V^\ast\|\le\|V-BV\|+\|BV-BV^\ast\|\le e+\gamma\|V-V^\ast\|$. (Example: $e=10^{-6}$ and $\gamma=0.9$ give an error of at most $10^{-5}$.)

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.

Going deeper — what the explorer computes, and how exactly

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.

Penalty vs safety on a cliff gridworld
$T_f$ = 2
$R_{X_U}$ = 0
$R_{Q_U}$ = 0
$R_{Q_V}$ = 0
$\inf_{X_V} V$ = 0
$\sup_{X_U} V_p$ (slip 0) = 0
$p^\star$ (Theorem 2) = 0
$p_Z$ (boundary of (Zb), slip 0) = 0
$p_{\min}$ (empirical; nominal if slip) = 0
$V_p$ at S = 0

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

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

$$V_{\mathrm{safe}}(58)=\frac{0+0.9(3)+0.9^2(3)}{1-0.9^3}=\frac{5.13}{0.271}\approx18.929889.$$

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

Common mistake — Next temperature within bounds

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.

Exercise 7.1 — The viability kernel of a double integrator with a wall

A cart on a rail: $\dot x_1 = x_2$, $\dot x_2 = u$ with $|u| \le u_{\max}$, and a wall at $x_1 = L$, so $X_F = \{x_1 \ge L\}$ (closed). (a) Compute $X_V$ and $X_U$ analytically. (b) Show that Assumption 1 holds with $T_f = v_{\max}/u_{\max}$ if the state space is restricted to $|x_2| \le v_{\max}$, and that it fails without a velocity bound although every unviable state still fails in finite time. (c) Apply inputs with a zero-order hold of duration $\Delta \gt 0$, so that a state-action pair is a state and a constant input. How does the safety measure $\Lambda$ (Lebesgue measure on $u \in [-u_{\max}, u_{\max}]$) behave as a state approaches $\partial X_V$ from inside?

Show answer

(a) If $x_2 \le 0$ and $x_1 \lt L$, the input $u = 0$ keeps $x_1$ non-increasing, so the state is viable. If $x_2 \gt 0$, the position under any admissible input satisfies $\ddot x_1 = u \ge -u_{\max}$, hence $x_1(t) \ge x_1 + x_2 t - \tfrac12 u_{\max} t^2$ for all $t$ up to the first zero of the velocity. The right-hand side is the maximal-braking trajectory; it reaches its maximum $x_1 + x_2^2/(2u_{\max})$ at $t = x_2/u_{\max}$ (where the braked velocity is zero). Case 1: $x_1 + x_2^2/(2u_{\max}) \lt L$. Then maximal braking until rest followed by $u = 0$ never reaches the wall: viable. Case 2: $x_1 + x_2^2/(2u_{\max}) \ge L$. Then every input gives $x_1(x_2/u_{\max}) \ge L$: the state fails by time $x_2/u_{\max}$. Therefore $$\begin{aligned} X_V &= \{x_1 \lt L,\ x_2 \le 0\} \cup \{x_2 \gt 0,\ x_1 + x_2^2/(2u_{\max}) \lt L\}, \\ X_U &= \{x_2 \gt 0,\ x_1 + x_2^2/(2u_{\max}) \ge L\} \cup X_F . \end{aligned}$$ The boundary parabola belongs to $X_U$ because the braked trajectory touches $x_1 = L$ and $X_F$ is closed.

(b) Let $x \in X_U \setminus X_F$, so $x_1 \lt L$, $v = x_2 \gt 0$ and $x_1 + v^2/(2u_{\max}) \ge L$. Every input satisfies $x_1(t) \ge x_1 + vt - \tfrac12 u_{\max}t^2$, so every trajectory reaches the wall no later than the maximal-braking one, which does so at the smaller root $t_{\max} = \big(v - \sqrt{v^2 - 2u_{\max}(L - x_1)}\big)/u_{\max} \le v/u_{\max}$, with equality exactly on the boundary parabola. With $|x_2| \le v_{\max}$ this gives the uniform bound $T_f = v_{\max}/u_{\max}$. Without a velocity bound, $\sup_{X_U} x_2/u_{\max} = \infty$: each unviable state fails in finite time, but there is no common bound, so Assumption 1 fails and Theorem 2 gives no finite $p^\star$; indeed, the reward that a doomed but very fast cart can collect while decelerating is unbounded in duration. This is the mildest way Assumption 1 can fail; the paper's Appendix B describes the more insidious case of Lipschitz models that predict arbitrarily long failures near $\partial X_V$ (infinitely many steps to fall in the linear inverted pendulum model, an infinite time-to-touchdown for landing bees).

To prove failure of a uniform bound, choose $v_k\to\infty$ and $x_{1,k}=L-v_k^2/(2u_{\max})$. These boundary states are unviable, and maximal braking reaches the wall exactly at $t_k=v_k/u_{\max}\to\infty$. For the bounded-velocity statement, it is enough to bound the initial velocity of the states under consideration. If $|x_2|\le v_{\max}$ is instead a hard state constraint, the model must also specify admissible boundary inputs or what happens when that constraint is violated.

(c) It depends on which part of $\partial X_V$ is approached; there is no single boundary limit. The boundary consists of the braking parabola $\{x_2 \gt 0,\ x_1 + x_2^2/(2u_{\max}) = L\}$ and the wall segment $\{x_1 = L,\ x_2 \le 0\}$. Braking parabola. At a state with fixed velocity $x_2 = v \gt 0$ and $x_1 + v^2/(2u_{\max}) = L - \epsilon$, an input $u$ held for $\Delta$ must not push the braked stopping point past $L$. Since the stopping point moves at rate $\partial_t[x_1 + x_2^2/(2u_{\max})] = x_2(1 + u/u_{\max})$, only inputs with $u \le -u_{\max} + O(\epsilon)$ (big-O: Primer 0; derivation below) keep the state viable: the set of viable inputs shrinks to the single point $\{-u_{\max}\}$ as $\epsilon \to 0$ and $\Lambda \to 0$. Wall. At rest at $x_1 = L - \epsilon$, every $u \in [-u_{\max}, 0]$ is safe under the hold, and a positive $u$ is safe iff the successor $(L - \epsilon + u\Delta^2/2,\ u\Delta)$ can still brake in time, i.e. iff $u + u^2/u_{\max} \lt 2\epsilon/\Delta^2$. So $\Lambda \to u_{\max}$, not $0$. Moving away from the wall ($x_2 \lt 0$) even more inputs are admissible (with $u_{\max} = 1$, $\Delta = 0.5$, $x_2 = -0.3$: all of them). At rest far from the wall, $\Lambda = 2u_{\max}$. The measure is a graded margin that tells the agent how precise it has to be. It vanishes where staying viable requires the extreme input (full braking), not merely where the state is close to the failure set.

Let $a=u_{\max}$ and $b=x_1+x_2^2/(2a)$. While $x_2>0$, the chain rule gives $\dot b=x_2+x_2u/a=x_2(1+u/a)$. Write $u=-a+d$, where $d\ge0$. For $t_0=\min\{\Delta,v/(2a)\}>0$, the velocity is at least $v/2$ throughout $[0,t_0]$, so $b(t_0)-b(0)\ge vd t_0/(2a)$. To preserve the initial margin $\epsilon$, necessarily $d<2a\epsilon/(vt_0)$. This is the meaning of $d=O(\epsilon)$: it is bounded by a constant times $\epsilon$ for small $\epsilon$.

Exercise 7.2 — Prove Lemma 2(ii) in discrete time

Under Assumption 1 with $\mathbb{T} = \mathbb{N}$, prove that $\sup_{X_U} V_p \le R_{X_U}\frac{1 - \gamma^{T_f+1}}{1-\gamma} - p\,\gamma^{T_f}$, and state precisely where $R_{X_U} \ge 0$ is used. Then verify the bound on an upper slope cell of the explorer (row 2, zero slip), where $r = -c$ until the fall.

Show answer

Fix $x \in X_U$ and a controller $u$. Let $t_f \le T_f$ be the time at which the trajectory enters $X_F$; the state at time $t_f$ is a failure state (part of $X_U$), and from $t_f + 1$ on the system sits in the zero-reward sink. With the counting measure, $$G(x,u) = \sum_{t=0}^{t_f} \gamma^t r(x_t, u_t) \ \le\ R_{X_U}\sum_{t=0}^{t_f}\gamma^t \ \le\ R_{X_U}\sum_{t=0}^{T_f}\gamma^t = R_{X_U}\,\frac{1 - \gamma^{T_f+1}}{1-\gamma},$$ where the first inequality uses $r \le R_{X_U}$ on $X_U \times U$ (every visited state is unviable) and the second uses $R_{X_U} \ge 0$: extending the sum from $t_f$ to $T_f$ adds terms $\gamma^t R_{X_U} \ge 0$. If $R_{X_U}$ were negative the second inequality would reverse. Next, $\rho(x,u) = \sum_t \gamma^t \mathbf{1}_{X_F}(x_t) = \gamma^{t_f} \ge \gamma^{T_f}$ since $\gamma \lt 1$ and $t_f \le T_f$. Hence $G(x,u) - p\rho(x,u) \le R_{X_U}\frac{1-\gamma^{T_f+1}}{1-\gamma} - p\gamma^{T_f}$ for every $u$, and taking the supremum over $u$ and then over $x \in X_U$ gives the claim. $\square$

Check on the explorer's upper slope cell $(2,3)$ with zero slip. Moving down falls at once (the move and the slide add up to two rows), which is worth $-c - \gamma p$; any other move slides onto a lower slope cell, from which every action falls in one step, which is worth $-c + \gamma(-c - \gamma p) = -c - \gamma c - \gamma^2 p$. Hence $V_p(2,3) = \max\{-c - \gamma p,\ -c - \gamma c - \gamma^2 p\}$, and the slow fall wins iff $c \lt p(1 - \gamma)$. The bound with $T_f = 2$ and $R_{X_U} = \max\{0, -c\} = 0$ reads $V_p \le -p\gamma^2$, and both candidates satisfy it: $-c - \gamma p \le -\gamma^2 p$ because $-c \le 0 \le \gamma p (1 - \gamma)$, and $-c(1+\gamma) - \gamma^2 p \le -\gamma^2 p$. Had we used $R_{X_U} = -c$, the "bound" $-c(1 + \gamma + \gamma^2) - p\gamma^2$ would lie $\gamma^2 c$ below the slow-fall value, hence below $V_p(2,3)$ whenever $c \gt 0$: false.

Exercise 7.3 — Numbers for the shelf: $p^\star$ as a function of $\tau$ and $T_f$

For the shelf example with $L = 1$ and $v = 0.2$ (the values of the paper's Fig. 2), compute $p^\star = \tau(2 - e^{-L/(v\tau)})e^{T_f/\tau} - \tau$ for (a) $\tau = 1$, $T_f = 1$; (b) $\tau = 1$, $T_f = 2$; (c) $T_f = 1$ and $\tau \in \{0.5, 2, 5, 20\}$. Explain the shape of $p^\star(\tau)$.

Show answer

(a) $e^{-5} \approx 0.0067$, so $p^\star = (2 - 0.0067)\,e - 1 \approx 5.418 - 1 = 4.42$. (b) $p^\star = 1.9933 \cdot e^2 - 1 \approx 14.73 - 1 = 13.73$: one extra second of falling roughly triples the required penalty. The exact scaling is $p^\star + \tau \propto e^{T_f/\tau}$, so it is $p^\star + \tau$ that is multiplied by $e^{\Delta T_f/\tau} = e$ ($5.418 \to 14.73$); $p^\star$ itself grows by a factor $3.1$. (c) $\tau = 0.5$: $L/(v\tau) = 10$, $p^\star = 0.5(2 - e^{-10})e^{2} - 0.5 \approx 7.389 - 0.5 = 6.89$. $\tau = 2$: $e^{-2.5} \approx 0.082$, $p^\star = 2(1.918)e^{0.5} - 2 \approx 6.32 - 2 = 4.32$. $\tau = 5$: $e^{-1} \approx 0.368$, $p^\star = 5(1.632)e^{0.2} - 5 \approx 9.97 - 5 = 4.97$. $\tau = 20$: $e^{-0.25} \approx 0.779$, $p^\star = 20(1.221)e^{0.05} - 20 \approx 25.68 - 20 = 5.68$.

So $p^\star(\tau)$ decreases from $6.89$ at $\tau = 0.5$ to a minimum of about $4.24$ near $\tau \approx 1.45$ and then rises again, which is the non-monotone curve of the paper's Fig. 2 (middle). Two effects compete. For small $\tau$ the factor $e^{T_f/\tau}$ dominates: the penalty is discounted away before it reaches the ledge. For large $\tau$ the constrained value at the ledge, $\inf_{X_V} V = -\tau(1 - e^{-L/(v\tau)}) \to -L/v = -5$, keeps decreasing because the reward inside $X_V$ is negative and a far-sighted agent accounts for the whole drive to $x = L$. The rise does not continue forever, though: the bracket $R_{X_U}\tau - \inf_{X_V} V$ grows like $\tau$, but the final $-R_{X_U}\tau$ cancels the linear term. With $a = L/v$ and $b = T_f$, expanding $e^{-a/\tau}$ and $e^{b/\tau}$ gives $p^\star(\tau) = \tau\big[(2 - e^{-a/\tau})e^{b/\tau} - 1\big] = a + b + \big(ab + \tfrac{b^2}{2} - \tfrac{a^2}{2}\big)/\tau + O(\tau^{-2})$, so $p^\star(\tau) \to L/v + T_f = 6$ from below ($5.93$ at $\tau = 100$). The discount time constant cannot be chosen to fight the exponential alone; it is also a task parameter.

Use $2-e^{-a/\tau}=1+a/\tau-a^2/(2\tau^2)+O(\tau^{-3})$ and $e^{b/\tau}=1+b/\tau+b^2/(2\tau^2)+O(\tau^{-3})$. Their product is $1+(a+b)/\tau+(ab+b^2/2-a^2/2)/\tau^2+O(\tau^{-3})$. Subtracting 1 and multiplying by $\tau$ yields the stated expansion. Here $O(\tau^{-2})$ means a remainder whose absolute value is at most a fixed constant times $\tau^{-2}$ for sufficiently large $\tau$.

Exercise 7.4 — A too-small penalty makes cutting the corner optimal

A one-dimensional chain of cells $0, 1, \dots, 6$. Cell $0$ is the cliff ($X_F$, absorbing). Cell $1$ is a slope: every action from it leads to cell $0$. From cells $2$–$5$ the actions L, R, S move left, right or stay. Cell $6$ is the goal, where S stays. Reward: $-c = -1$ per step in cells $1$–$5$, $+1$ per step in cell $6$, penalty $p$ on entering cell $0$ (then zero forever), discount $\gamma = 0.5$. (a) Compute the constrained value $V(2)$ and the value of "jumping" from cell $2$ (L, then fall). For which $p$ is jumping optimal? (b) Compute $p^\star$ from Theorem 2 and compare. (c) Repeat (a) with $\gamma = 0.9$.

Show answer

(a) The safe optimum from cell $2$ walks to the goal: four steps of $-1$ (at times $0$–$3$, in cells $2, 3, 4, 5$), then $+1$ forever from time $4$: $V(2) = -(1 + \gamma + \gamma^2 + \gamma^3) + \gamma^4/(1-\gamma) = -1.875 + 0.125 = -1.75$. Jumping: $-1$ in cell $2$ at time $0$, $-1$ in cell $1$ at time $1$, the penalty at time $2$: $-1 - \gamma - \gamma^2 p = -1.5 - 0.25p$. Jumping is strictly better than walking iff $-1.5 - 0.25p \gt -1.75$, i.e. iff $p \lt 1$, and at $p = 1$ the two tie, so jumping is optimal for all $p \le 1$. All optimal controllers are safe exactly for $p \gt 1$: the true minimum penalty is the infimum $p_{\min} = 1$, which is not itself safe. (From cell $3$ the jump is worth $-1 + \gamma(-1.5 - 0.25p) = -1.75 - 0.125p \lt V(3) = -1.5$ for every $p \ge 0$; only cell $2$ is tempted.) The failure mode is "suicide": dying stops the living cost, which an agent with a short horizon prefers to a long walk.

(b) $T_f = 1$. $X_U = \{0, 1\}$ and the failure cell $0$ has reward $0$, so $R_{X_U} = \max\{0, \sup_{X_U \times U} r\} = 0$. $R_{Q_U} = 0$ for the same reason (the unsafe pair $(2, \mathrm{L})$ and the pairs at cell $1$ have reward $-1$, the pairs at the failure cell $0$ have reward $0$). $R_{Q_V} = -1$. $\inf_{X_V} V = V(2) = -1.75$ (the farthest viable cell). Then $$p^\star = \gamma^{-T_f}\Big[R_{X_U}\tfrac{1-\gamma^{2}}{1-\gamma} + \tfrac{R_{Q_U} - R_{Q_V}}{\gamma} - \inf_{X_V} V\Big] = 2\,[0 + 2 + 1.75] = 7.5 .$$ Sufficient (any $p \gt 7.5$ is safe, indeed any $p \gt 1$ is) but conservative by a factor $7.5$. The slack is transparent: the bound credits the doomed agent with a reward of $0$ instead of the $-1$ it actually collects in cell $1$ ($R_{X_U}$), and the exit transition with $0$ instead of the $-1$ that $(2, \mathrm{L})$ actually earns ($R_{Q_U}$, taken over all of $Q_U$); both gaps are then amplified by the inverse discount factors in (18b). Using the true $\sup_{X_U} V_p = \max\{-p, -1 - p/2\}$ in (Zb) instead of Lemma 2's bound gives the intermediate threshold $p_Z = 5.5$.

Here (Zb) becomes $\tfrac12\max\{-p,-1-p/2\}<-1+\tfrac12(-1.75)=-1.875$, or $\max\{-p,-1-p/2\}<-3.75$. Both branches must lie below $-3.75$: they require $p>3.75$ and $p>5.5$, respectively. Thus (Zb) holds exactly for $p>5.5$, and $p_Z=5.5$ is its infimum, not a penalty at which the strict condition already holds.

(c) With $\gamma = 0.9$: $V(2) = -(1 + 0.9 + 0.81 + 0.729) + 0.9^4/0.1 = -3.439 + 6.561 = 3.12$, while jumping is worth $-1 - 0.9 - 0.81p \lt 0$. No penalty is needed ($p_{\min} = 0$), and the formula agrees: $p^\star = \tfrac{1}{0.9}[0 + \tfrac{1}{0.9} - 3.12] \approx -2.2 \lt 0$, so every $p \ge 0$ is above the threshold. A far-sighted agent sees the goal; a myopic one needs to be threatened.

Exercise 7.5 — The penalty as a Lagrange multiplier

Write (C) as the CMDP $\max_u \mathbb{E}_\mu G(x,u)$ s.t. $\mathbb{E}_\mu \rho(x,u) \le 0$. (a) Show that its dual function is $d(\lambda) = \mathbb{E}_\mu[V_\lambda(x)]$ and that weak duality holds. (b) Using Proposition 1 and Theorem 2, show that $d(\lambda) = P^\star$ (the constrained optimum) for every $\lambda \gt p^\star$, so the duality gap is zero and the dual optimal set contains $(p^\star, \infty)$. (c) Explain what standard strong duality guarantees for $\lambda = \lambda^\star$ that the SVF result does not need, and vice versa. (d) What does the projected dual-descent update $\lambda \leftarrow [\lambda + \eta_\lambda\,\mathbb{E}_\mu\rho(x, u_\lambda)]_+$ with step size $\eta_\lambda \gt 0$ do on this problem if $u_\lambda$ is an exact maximiser of the Lagrangian at each step? Does it terminate?

Show answer

(a) $\mathcal{L}(u,\lambda) = \mathbb{E}_\mu[G - \lambda\rho]$ with $\lambda \ge 0$. Always $\sup_u \mathbb{E}_\mu[G - \lambda\rho] \le \mathbb{E}_\mu[\sup_u (G - \lambda\rho)] = \mathbb{E}_\mu[V_\lambda]$. Equality holds because (P) has a controller that attains $V_\lambda(x)$ at every $x$ simultaneously (the attainment assumption of Section 3; on finite deterministic problems dynamic programming provides a stationary one), and using it from every initial state achieves the right-hand side. So $d(\lambda) = \mathbb{E}_\mu[V_\lambda]$. For any safe $u$, $\rho = 0$ and $\mathcal{L}(u,\lambda) = \mathbb{E}_\mu G$, so $d(\lambda) \ge \sup_{\mathcal{U}_{\mathrm{safe}}} \mathbb{E}_\mu G = P^\star$: weak duality, which is inequality (34) of the paper averaged over $\mu$.

(b) For $\lambda \gt p^\star$, Theorem 2 says $V_\lambda$ is an SVF, and Proposition 1 says $V_\lambda = V$ on $X_V \supseteq \operatorname{supp}\mu$. Hence $d(\lambda) = \mathbb{E}_\mu V = P^\star$. (Here $P^\star = \mathbb{E}_\mu V$ is attained by a controller optimal for (C) from every viable state, Remark 5; a controller that is safe only from $\mu$-almost every initial state cannot do better, since from each state it is safe from its return is at most $V(x)$.) Combined with (a), $\min_\lambda d(\lambda) = P^\star$ and every $\lambda \gt p^\star$ attains it. Since $d$ is nonincreasing in $\lambda$ (Lemma 2(i)), convex, and bounded below by $P^\star$, the dual optimal set is a ray $[\lambda_0, \infty)$ that contains $(p^\star, \infty)$, but $\lambda_0$ can lie far below $p^\star$: in Exercise 7.4 with $\mu = \delta_2$, $d(\lambda) = \max\{-1.75, -1.5 - 0.25\lambda\}$, so $\lambda_0 = 1$ while $p^\star = 7.5$.

All multiplier sets are understood inside $[0,\infty)$, so the guaranteed set is $\{\lambda\ge0:\lambda>p^\star\}$. Because $0\le\rho\le1$, changing $\lambda$ by $h$ changes every controller's penalized return by at most $|h|$; taking suprema gives $|d(\lambda+h)-d(\lambda)|\le|h|$. Thus $d$ is continuous. Once this nonincreasing function reaches its lower bound $P^\star$, it stays there, and its optimal set is a closed ray $[\lambda_0,\infty)$ with $\lambda_0\ge0$.

(c) Strong duality for bounded-risk CMDPs gives a multiplier $\lambda^\star$ and a saddle point: some maximiser of $\mathcal{L}(\cdot,\lambda^\star)$ is primal feasible and optimal, but other maximisers may be infeasible or suboptimal, so the maximiser an RL algorithm returns need not be safe (Example 1: at $p^\star = 10$ every $\theta$ is a maximiser). Paternain et al. prove the zero duality gap under bounded rewards and Slater's condition; Slater is sufficient, not necessary (for finite CMDPs the linear-programming formulation gives strong duality from feasibility alone; Altman, 1999). Slater in fact fails here: $\rho \ge 0$, so the 0-risk constraint has no strictly feasible point. The SVF result does not rest on it; it needs Assumption 1 and $\eta = 0$ instead, and in exchange it gives that all maximisers are feasible and optimal, for all multipliers above $p^\star$, not just at one value.

(d) With threshold $0$ the constraint slack is $\mathbb{E}_\mu\rho \ge 0$, so the update never decreases $\lambda$. It increases $\lambda$ by $\eta_\lambda \mathbb{E}_\mu\rho(x, u_\lambda)$ exactly while the current maximiser fails from a $\mu$-positive set of initial states, and stops as soon as $u_\lambda$ is safe $\mu$-almost surely, which may happen far below $p^\star$ (in Exercise 7.4 with $\mu = \delta_2$: at the first iterate above $1$, or at $1$ itself if ties are broken towards safety, rather than above $7.5$). This dual update is a search for a sufficient penalty, but Theorem 2 only guarantees that a finite stopping point exists, not that the iteration reaches it: an unsafe maximiser can delay leaving $X_V$ (Assumption 1 bounds the time-to-failure only after the exit), so its risk can be arbitrarily small and the increments can shrink without $\lambda$ ever crossing the threshold. On a finite deterministic MDP with $\mu$ of finite support this cannot happen: an unsafe feedback controller fails within $|X|$ steps from any state it fails from (otherwise its trajectory would cycle), so $\mathbb{E}_\mu\rho \ge \gamma^{|X|}\min_{\operatorname{supp}\mu}\mu \gt 0$ while $u_\lambda$ is unsafe, and the search stops after finitely many steps, at the latest once $\lambda \gt p^\star$. The exponential in $p^\star$ still warns that with small step sizes and myopic agents it can take very long. With a positive threshold and sampled, inexact maximisers (any deep RL algorithm) the multiplier and the cost oscillate around the constraint boundary, which is the motivation for the PID multiplier of Module 8.

Exercise 7.6 — The entropy cap and the price of a decade of safety

(a) Prove that for every safe policy $\pi \in \Pi_V$ and every $x \in X_V$, $H(\pi(\cdot \mid x)) \le \ln|Q_V[x]|$. (b) In the notation of the $\delta$-safety walkthrough, take $u_1 - v_1 = 10$, $u_2 = 2$, $u_3 = 1$. Compute the penalty $p_1$ that guarantees $\delta$-safety with $\delta = 10^{-2}$ for $\alpha = 0.5$ and for $\alpha = 2$, and the extra penalty needed to go from $\delta = 10^{-2}$ to $\delta = 10^{-3}$ at each temperature.

Show answer

(a) Let $\pi$ be safe from $x \in X_V$, i.e. $\Pr[X_t \notin X_C] = 1$ for all $t \gt 0$. If $\pi(a \mid x) \gt 0$ for some $a$ with $f(x,a) \notin X_V$, then with probability $\pi(a \mid x) \gt 0$ the next state is unviable and, by definition of $X_V$, reaches $X_C$ in finite time under every policy, contradicting safety. So $\operatorname{supp}\pi(\cdot \mid x) \subseteq Q_V[x]$, and the entropy of a distribution supported on $n$ points is at most $\ln n$ (attained by the uniform distribution, by concavity of $H$ or by Gibbs' inequality against the uniform). Hence $H(\pi(\cdot \mid x)) \le \ln|Q_V[x]|$. $\square$

Let $n=|Q_V[x]|$ and let $u_i=1/n$ be uniform on those viable actions. Nonnegativity of KL divergence gives $0\le D_{\mathrm{KL}}(\pi\|u)=\sum_i\pi_i\ln(\pi_i/(1/n))=\ln n-H(\pi)$. Hence $H(\pi)\le\ln n$, with equality for the uniform distribution.

(b) $p_1 = \frac{u_1 - v_1}{u_3} + \frac{u_2 - \ln\delta}{u_3}\alpha$ with $-\ln 10^{-2} = 4.605$. For $\alpha = 0.5$: $p_1 = 10 + 0.5(2 + 4.605) = 13.30$. For $\alpha = 2$: $p_1 = 10 + 2(6.605) = 23.21$. Going to $\delta = 10^{-3}$ adds $\alpha\ln 10/u_3$: $1.15$ at $\alpha = 0.5$ and $4.61$ at $\alpha = 2$. Each decade of safety costs a penalty increment proportional to the temperature, which is why a fixed penalty is eventually overcome by a high temperature and why the paper recommends scaling $p$ with $\alpha$. Note that these are illustrative constants of a sufficient bound, not values from the paper; on a concrete problem the minimum penalty is typically smaller. The paper's Fig. 3 measures, on its cliff world, the smallest penalty that makes the mode safe, and it too grows with $\alpha$.

Key Papers

PaperVenueContributionWhy read it
Massiani, Heim, Solowjow, Trimpe — Safe Value FunctionsIEEE TAC 68(5), 2023Zeroth-order condition; finite penalty threshold $p^\star$ with its $e^{T_f/\tau}$ scaling; thresholding recovers $X_V$; penalties do not solve bounded-risk CMDPsThe 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 MeasureCoRL 2019, PMLR 100Safety measure $\Lambda$ = volume of viable actions; $Q_V = \{\Lambda_Q \gt 0\}$ (counting measure); model-free GP learning with optimistic and cautious setsIntroduced the state-action, graded view of viability that the later papers build on.
Massiani, Heim, Trimpe — On exploration requirements for learning safety constraintsL4DC 2021, PMLR 144Admissible 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 RegularizationECML-PKDD 2025 (LNCS)Entropy cap $H \le \ln|Q_V[x]|$; temperature controls $S$-robustness; penalties give $\delta$-safety and a safe modeExtends 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 / RLJPredictive safety filter on a probabilistic ensemble with ellipsoidal tubes and a certainty constraint (eq. 5); reachable-set over-approximation under Assumptions 2, 3, 5Predictive 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, 2026Learned hyperplane safety filter and control policy in a Dyna loop; finite-horizon probabilistic viability intersected with a certain setAbout 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 PolishingIFAC-PapersOnLine 59(18):325–330, 2025Hardware evaluation of uncertainty-weighted hybrid RL for polishing with variable impedanceA data point for safe exploration on hardware: eight hours, five failures.
Baumann, Schön — Safe reinforcement learning in uncertain contextsIEEE T-RO 40, 2024Safe learning with unmeasured discrete contexts via MMD tests and frequentist multi-class classification boundsNot 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 LearningICRA 2019Discounted min-over-time Bellman backup is a contraction; safe sets learned by Q-learningThe 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 AdvancesCDC 2017Backward reachable sets and tubes, differential-game formulation, numerical toolsThe unviability kernel is the BRT of the failure set.
Alshiekh, Bloem, Ehlers, Könighofer, Niekum, Topcu — Safe Reinforcement Learning via ShieldingAAAI 2018Shields synthesised from the winning region of a safety game; preemptive and post-posed shieldsThe 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 GapNeurIPS 2019Zero duality gap for CMDPs under Slater's conditionWhat 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 RewardsIEEE TAC 69(7), 2024Some constrained problems are unsolvable by any weighted reward; multiplier-augmented states fix primal recoveryThe 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 SystemsIEEE CSM 43(5), 2023HJ, CBF and predictive filters as approximations of an ideal minimally invasive filterThe filter view of "stay in $Q_V$" that UPSi and Dyna-SAuR instantiate.

Flashcards