January 01, 1970
Shielding is an effective approach to formally guarantee the safety of reinforcement learning agents in Markov decision processes (MDPs). However, existing shielding techniques typically assume knowledge of the safety-relevant transition dynamics – a requirement that is seldom met in practice. To address this limitation, we introduce a novel shielding framework for robust MDPs (RMDPs), MDPs with sets of transition probabilities. We define safety as the satisfaction of a linear temporal logic (LTL) formula with a certain threshold probability under the worst-case transition probabilities of the RMDP. We prove that our shielding framework is both sound and optimal for the RMDP: every policy admissible by the shield is safe, and conversely, every safe RMDP policy is admissible by the shield. We combine our approach with existing sampling methods for learning transition probabilities of MDPs with probably approximately correct (PAC) guarantees. This combination enables the construction of shields for MDPs that, with high confidence, guarantee safety while remaining minimally restrictive. Our experiments show that our shields for learned RMDPs guarantee safety in unknown MDPs while recovering strong expected return as the number of samples increases.
Reinforcement learning (RL) [1] optimizes the behavior of an agent taking actions in an unknown environment, generally modeled as a Markov decision process (MDP). While success stories of RL have reached into key areas, such as robotics [2], game playing [3], and autonomous driving [4], safety in RL remains a major concern. In particular, state-of-the-art RL algorithms let agents explore actions unrestrictedly and will thus inevitably select potentially harmful actions [5].
This unsafe exploration problem has triggered research on shielded RL [6]. A shield is a mechanism that prevents (“shields”) RL agents from executing unsafe actions. Shields have been developed for MDPs [7], [8] as well as partially observable MDPs (POMDPs) [9]. To guarantee safety, these approaches require knowing the MDP’s transition dynamics relevant to safety. However, in typical RL problems, these dynamics are unknown. Instead, our starting assumption is to have access to some prior data on the dynamics, whether from previous executions or a simulator. One solution is to use this data to learn point estimates of the dynamics, but doing so introduces statistical errors [10] that compromise the shield’s safety guarantees. An alternative is to learn an uncertainty set around each unknown transition probability that is probably approximately correct (PAC), contains the true probability with high confidence [11], [12]. Unfortunately, existing shielding approaches are limited to models with exact probabilities and thus incompatible with such uncertainty sets and PAC bounds.
We address this gap by developing a novel shielding framework for MDPs with sets of transition probabilities, known as robust MDPs (RMDPs) [13]. An RMDP can be seen as a game between the agent, which chooses the actions, and an adversary, which chooses transition probabilities from the uncertainty sets. Intuitively, our shield prevents the agent from deploying any policy that leads to unsafe outcomes under any choice by the adversary. As is common in shielding [6], [7], we adopt linear temporal logic (LTL) as a specification language, focusing on the safety fragment for algorithmic purposes [14]. When used to constrain the agent’s policy, our shield guarantees that, regardless of the choices by the adversary, the probability of satisfying a given LTL formula meets a prescribed threshold. As depicted in 1, we can instantiate our framework to shield unknown MDPs in two steps:
We use sampled transitions in the environment to learn the transition probabilities of the (unknown) MDP as an RMDP with PAC guarantees, the RMDP “contains” the true MDP with a prescribed (high) confidence probability \(\delta\). As common in shielding [6], we do not need to learn all probabilities, but instead only those relevant to the safety specification.
Based on the learned RMDP, we construct a shield. The shield restricts the agent’s choices to a subset of probability distributions over actions. When used to constrain the actions of the agent on the true MDP, the shield guarantees that, with the same confidence probability \(\delta\), the safety LTL formula is satisfied with at least the desired threshold probability.
As a key contribution, we prove, under mild assumptions detailed in 1 2, that our shield is both sound and optimal on the RMDP: every policy admissible under the shield is safe and, conversely, every safe RMDP policy is admissible under the shield. Since the RMDP converges to the true MDP as the number of sampled transitions increases, this optimality carries over to optimality for the MDP in the limit. Thus, our shield guarantees safety on the true MDP at any point with high confidence – both during learning and execution – and is minimally restrictive to the learning agent, enabling it to converge to optimal rewards as the quality of the learned RMDP increases. We demonstrate these results empirically and, by contrast, show that state-of-the-art shielding for learned MDPs with point estimates of probabilities can violate safety.
Safety in RL is an active area of research [5], [15], [16]. Shielding has proved to be a successful approach to block unsafe actions during training and execution [6], [8], [9], [17]–[21]. Closest to our approach is the probabilistic shielding for MDPs proposed in [7], which, however, assumes knowledge of the underlying MDP. Here, we consider the more challenging case of RMDPs and thereby shielding unknown MDPs learned as an RMDP. Existing shields on learned dynamics generally lack finite-sample guarantees by relying on, Monte Carlo sampling [22] or learned latent representations [23]. To our knowledge, the only existing RMDP shielding approach is [24], which considers RMDPs with intervals of probabilities (interval MDPs) and iteratively expands the allowed actions per state, yielding sound but overly conservative shields as a permissive policy [25].
Lagrangian approaches [26], [27] convert safety-constrained MDPs into unconstrained problems with dual variables to penalize cost violations in the reward objective. Recent works extend these ideas to robust constrained MDPs [28], [29]. While often empirically effective, these methods cannot provably guarantee safety at any time (as opposed to shields), thus limiting their use in safety-critical scenarios.
Lyapunov-based methods enforce safety by satisfying a Lyapunov decrease condition defined w.r.t. a safe baseline policy [30], [31], where guarantees depend on accurate safety critics and linearizations. In [32], Gaussian processes (GP) are used for model-based RL, but guarantees rely on the GP prior and a known Lyapunov function, which is hard to construct in practice. Finally, Dyna-style model-based RL uses rollouts on learned models to generate data for model-free agents [33]–[35], which reduces required system interactions but cannot give formal safety guarantees as shields do.
After the preliminaries in 2, we present our shields for RMDPs in 3. We discuss the setting of shielding unknown MDPs in 4 and empirically evaluate our approach in 5. Throughout the paper, we focus on intuition for our results and instead present all rigorous details about, measure-theoretic constructions, and proofs for our results in the appendix.
A Markov decision process (MDP) is a tuple \(\mathcal{M}=\langle S,A,P,s_\text{init},AP,L \rangle\), where \(S\) is an (in)finite set of states with initial state \(s_\text{init}\in S\); \(A\) is an (in)finite set of actions;1 \(P \colon S\times A \to \Delta(S)\) is a transition function; \(AP\) is a finite set of atomic propositions; and \(L \colon S\to2^{AP}\) is the labeling function. We say that \(\mathcal{M}\) is an MDP with rewards if it is additionally equipped with a reward function \(R \colon S\to \mathbb{R}\). For simplicity, we may write \(P(s,a,s')\) instead of \(P(s,a)(\{s'\})\). A finite history in \(\mathcal{M}\) of length \(n\) is a finite word \(h=s_0 a_0 \cdots s_{n-1}a_{n-1}s_n \in S( A S)^n\) for some \(n\in\mathbb{N}\), and we denote its last state \(s_n\) by \(\text{last}\left(h\right)\). An infinite history \(h=s_0 a_0\cdots s_n a_n\cdots\) is defined analogously. A policy \(\pi \colon H \to \Delta(A)\) of \(\mathcal{M}\) is a mapping from the set \(H\) of finite histories to distributions over actions. Fixing a policy \(\pi\) and state \(s \in S\) induces a probability measure \(\text{prob}^{s}_{\mathcal{M},\pi}\) over histories. We write \(\text{prob}_{\mathcal{M},\pi}\) for \(\text{prob}^{s_\text{init}}_{\mathcal{M},\pi}\). For details on policies and induced probability measures, see [36], [37].
We express objectives for MDPs in linear temporal logic (LTL) [38]. Following [36], an LTL formula \(\varphi\) over the atomic propositions \(AP\) is generated by the grammar \[\varphi\Coloneqq \top \mid p \mid \neg \varphi\mid \varphi\land \varphi \mid \mathbf{X}\varphi\mid \varphi\,\mathbf{U}\, \varphi, \qquad p \in AP.\] As standard, we define \(\varphi_1 \lor \varphi_2 \mathrel{\vcenter{:}}= \neg(\neg \varphi_1 \land \neg \varphi_2)\), \(\mathbf{F}\varphi\mathrel{\vcenter{:}}= \top \,\mathbf{U}\, \varphi\), and \(\mathbf{G}\varphi\mathrel{\vcenter{:}}= \neg \mathbf{F}\neg \varphi\). A finite (resp. infinite) trace is a sequence \(\tau = b_0b_1\cdots \in \Sigma^*\) (resp. \(\Sigma^\omega\)), where the alphabet \(\Sigma = 2^{AP}\) specifies which propositions hold at each timestep. Given an (in)finite history \(h=s_0 a_0 s_1 a_1 \cdots\), we denote by \(L(h)=L(s_0)L(s_1)L(s_2)\cdots\) the (in)finite trace induced by the labeling function. The satisfaction relation \(\tau,i \models \varphi\) for a formula \(\varphi\) is defined inductively over infinite traces \(\tau = b_0 b_1\cdots\) of \(\mathcal{M}\) as \[\begin{align} {2} \tau,i &\models p &&\iff p \in b_i,\\ \tau,i &\models \neg \varphi&&\iff \tau,i \not\models \varphi,\\ \tau,i &\models \varphi_1 \land \varphi_2 &&\iff \tau,i \models \varphi_1 \text{ and } \tau,i \models \varphi_2,\\ \tau,i &\models \mathbf{X}\varphi&&\iff \tau,i+1 \models \varphi,\\ \tau,i &\models \varphi_1 \,\mathbf{U}\, \varphi_2 &&\iff \exists j \geq i \text{ such that } \tau,j \models \varphi_2 \text{ and } \tau,k \models \varphi_1 \text{ for all } i \leq k < j. \end{align}\] We write \(\tau \models \varphi\) as shorthand for \(\tau,0 \models \varphi\). An LTL formula \(\varphi\) is a safety formula [14] if every violating trace has a finite witness of violation, for every \(\tau \in \Sigma^\omega\) such that \(\tau \not\models \varphi\), there exists a finite prefix \(u \prec \tau\) (called a bad prefix) such that for every \(\rho \in \Sigma^\omega\), \(u\rho \not\models \varphi\). For every safety formula \(\varphi\), there exists a DFA that accepts exactly all bad prefixes of \(\varphi\) [36]:
Definition 1 (DFA). A deterministic finite automaton* (DFA) over the alphabet \(\Sigma\) is a tuple \(\mathcal{A}=\langle Q,\Sigma,q_\text{init},\delta,F \rangle\), where \(Q\) is a finite set of states with initial state \(q_\text{init}\in Q\), \(\delta \colon Q\times\Sigma\to Q\) is the transition function, and \(F \subseteq Q\) is the set of accepting states.*
The transition function extends to finite words as standard: \(\delta^*(q,ua)=\delta(\delta^*(q,u),a)\) for \(u\in\Sigma^*\), \(a\in\Sigma\). A finite word \(u \in \Sigma^*\) is accepted by DFA \(\mathcal{A}\) iff \(\delta^*(q_\text{init},u)\in F\). A specification \(\Phi=\mathbb{P}_{\geq \lambda}(\varphi)\) combines an LTL formula \(\varphi\) and a threshold \(\lambda \in [0,1]\). For a policy \(\pi\), we write \((\mathcal{M},\pi)\models \mathbb{P}_{\geq \lambda}(\varphi)\) iff \(\text{prob}_{\mathcal{M},\pi} \bigl( \{h \mid L(h)\models \varphi\} \bigr) \geq \lambda\), the probability for generating a satisfying trace is at least \(\lambda\).
Our goal is to compute a policy \(\pi\) that (1) maximizes the \(\gamma\)-discounted expected return \(J_{\mathcal{M}}^{\gamma}(\pi) \mathrel{\vcenter{:}}= \mathbb{E}_{\mathcal{M},\pi}^{s_\text{init}} \left[ \sum_{t=0}^{\infty} \gamma^t R(s_t) \right],\) with the expectation taken w.r.t. the probability measure \(\text{prob}^{s_\text{init}}_{\mathcal{M},\pi}\), and (2) ensures the probability of violating a safety LTL formula \(\varphi\) is below a prescribed threshold \(p \in [0,1]\). Formally, this amounts to solving the safe policy optimization problem: \[\pi^\star \in \mathop{\mathrm{arg\,max}}\nolimits_{\pi}\; J_{\mathcal{M}}^{\gamma}(\pi) \quad \text{subject to} \quad (\mathcal{M},\pi)\models \mathbb{P}_{\geq {1-p}}(\varphi).\] If the MDP \(\mathcal{M}\) is known, \(\pi^\star\) can be computed using the probabilistic shielding techniques for MDPs from [7]. Here, however, we assume that the transition function \(P\) is unknown and we only have access to samples from \(P\), rendering existing techniques inapplicable. Instead, we develop a shielding framework for RMDPs (3) and use it to shield a learned RMDP of the unknown MDP (4).
Definition 2 (RMDP). A robust MDP* (RMDP) is a tuple \(\mathcal{M}_R= \langle S,A,\mathcal{P},s_\text{init},{AP},L \rangle\), where \(S\), \(A\), \(s_\text{init}\), \({AP}\), and \(L\) are defined as in an MDP, and \(\mathcal{P}\colon S\times A \to 2^{\Delta(S)}\) is an uncertain transition function that maps every state-action pair to a set of probability measures over \(S\).*
An RMDP with rewards is additionally equipped with a reward function \(R \colon S\to \mathbb{R}\). An RMDP defines a game between the agent that chooses actions via the policy \(\pi\), and an adversary \(\theta\) that chooses probability distributions in \(\mathcal{P}\). Formally, the adversary \(\theta\) is a mapping that associates every finite history \(h \in H\) to a distribution in \(\mathcal{P}(\text{last}\left(h\right), a)\) for every action \(a \in A\). Fixing an adversary \(\theta\) for \(\mathcal{M}_R\) induces a standard MDP [12], denoted by \(\mathcal{M}_R[\theta]\). We say that \(\mathcal{M}_R\) satisfies the specification \(\mathbb{P}_{\geq 1-p}(\varphi)\), denoted as \((\mathcal{M}_R,\pi)\models \mathbb{P}_{\geq 1-p}(\varphi)\), iff \((\mathcal{M}_R[\theta],\pi)\models \mathbb{P}_{\geq 1-p}(\varphi)\) for every adversary \(\theta\).
In this section, we present our shielding approach for RMDPs. We first define our general notion of shield in 3.1, instantiate it to finite RMDPs in 3.2, and show its correctness in 3.3.
A shield may need internal memory to remember enough about the history to determine which actions can still be taken while satisfying the specification. We encode this memory in a controllable monitor, which extends standard monitors (used in, runtime verification [39], [40]) with auxiliary actions.
Definition 3 (Controllable monitor). A controllable monitor* over an observation space \(\Xi\) is a tuple \(\mathcal{D}=\langle M, U,m_\text{init},\zeta \rangle\), where \(M\) is a space of monitor states, \(U\) is a space of auxiliary actions, \(m_\text{init}\in M\) is the initial state, and \(\zeta \colon M\times \Xi\times U\to M\) is a transition function.*
We will use the auxiliary action to allocate a remaining violation budget, which records how much probability of violating the specification is still allowed over the remaining execution.
Example 1. A DFA (without its accepting states) can be seen as a controllable monitor with singleton auxiliary action \(U=\{\ast\}\) and observation space \(\Xi = \Sigma\) as the alphabet of the DFA. An NFA, on the other hand, additionally requires auxiliary actions that resolve nondeterminism at each step.
To combine an RMDP with a controllable monitor, we construct a product model based on an observation map \(\alpha \colon S \to \Xi\) from the RMDP states \(S\) into the observation space \(\Xi\) of the monitor. The product state \((s,m)\) contains both the RMDP and monitor state, and the product action \((a,u)\) consists of both an RMDP action \(a \in A\) and an auxiliary action \(u \in U\).
Definition 4 (Product RMDP). Let \(\mathcal{M}_R=\langle S,A,\mathcal{P},s_\text{init},AP,L \rangle\) be an RMDP, let \(\alpha \colon S \to \Xi\) be an observation map, and let \(\mathcal{D}=\langle M, U,m_\text{init},\zeta \rangle\) be a controllable monitor over \(\Xi\). The product RMDP* of \(\mathcal{M}_R\) and \(\mathcal{D}\) (relative to \(\alpha\)) is the RMDP \(\mathcal{M}_R\otimes_{\alpha} \mathcal{D} = \langle \overline{S},\overline{A},\overline{\mathcal{P}},\overline{s_\text{init}}, AP,\overline{L} \rangle\), where \(\overline{S}=S\times M\), \(\overline{A}=A\times U\), \(\overline{s_\text{init}}=(s_\text{init},m_\text{init})\), and for every \((s,m)\in \overline{S}\),*
\(\overline{L}(s,m)=L(s)\), and
for every action \((a,u)\in\overline{A}((s,m))\), letting \(T(s') = \bigl(s',\zeta(m,\alpha(s'),u)\bigr)\), the uncertainty set \(\overline{\mathcal{P}}((s,m),(a,u))\) consists of all pushforward measures \(\mu\circ T^{-1}\) with \(\mu\in\mathcal{P}(s,a)\).
Intuitively, choosing action \((a,u)\) in state \((s,m)\) of the product RMDP means that the next RMDP state \(s' \in S\) is given by \(\mathcal{P}(s,a)\), and the next monitor state is \(m' = \zeta(m,\alpha(s'),u)\). 4 extends the usual product between an MDP \(\mathcal{M}\) and a DFA \(\mathcal{A}\), used in model checking [36] and shielding [6], with auxiliary actions. Indeed, this usual product can be recovered with \(\mathcal{M}\otimes_{L} \mathcal{A}\), where \(L\) is the labeling function of the MDP, and the DFA is identified with its associated monitor as in 1.
We can now define our notion of a shield. In a nutshell, a shield specifies, for every observation and monitor state, which randomized choices over (RMDP and auxiliary) actions are allowed.
Definition 5 (Shield). Let \(\Xi\) be a set of observation states and let \(A_\Xi\) be a set of actions. A shield* over \((\Xi,A_\Xi)\) is a pair \(\mathfrak S=(\mathcal{D},\Gamma)\), where \(\mathcal{D}=\langle M,U,m_\text{init},\zeta \rangle\) is a controllable monitor over \(\Xi\), and \(\Gamma\) is a map from \(\Xi\times M\) to \(2^{\Delta(A_\Xi \times U)}\) that models the allowed distributions over actions.*
The shield in 5 is defined over an observation space \(\Xi\), rather than directly over the full state space \(S\). This feature, in particular, allows us to construct shields on a safety abstraction of the RMDP [6]. Let \(\mathcal{M}_R=\langle S,A,\mathcal{P},s_\text{init},AP,L \rangle\) be an RMDP, let \(\mathfrak S=(\mathcal{D},\Gamma)\) be a shield over \((\Xi,A_\Xi)\), and let \(\alpha \colon S \to \Xi\) be an observation map. We say that the shield \(\mathfrak S\) acts on \((\mathcal{M}_R,\alpha)\) if \(A_{\Xi}=A\). As visualized in 2, at runtime, the shield observes only the abstract state \(\xi = \alpha(s)\) and monitor state \(m\), and enforces the agent to select a randomized choice over actions contained in \(\Gamma(\xi,m)\).
We now instantiate the general shield from 5 to finite RMDPs. Throughout this section, we assume we are given an RMDP \(\mathcal{M}_R\) with finite sets \(S\) and \(A\). Inspired by [7], our construction uses a robust upper bound on the probability of reaching a bad state, formalized as follows.
Definition 6. An \((\mathcal{M}_R,U)\)-inductive value function* is a function \(\beta:S\to [0;1]\) such that \(\left(\mathcal{B}_{\mathcal{M}_R}^{U}(\beta)\right)(s) \leq \beta(s)\) for every \(s \in S\), where \(\mathcal{B}_{\mathcal{M}_R}^{U}\) is the robust Bellman operator defined as \[\left(\mathcal{B}_{\mathcal{M}_R}^{U}(\beta)\right)(s) = \begin{cases} 1, & \text{ if } s\in U,\\[1mm] \displaystyle \inf_{a\in A}\;\sup_{\mu\in\mathcal{P}(s,a)} \mathbb{E}_{s'\sim \mu} \left[\beta(s')\right], & \text{otherwise.} \end{cases}\]*
In our case, the states \(U\) correspond to violating a given safety LTL formula \(\varphi\). This violating set is defined as \(S \times F\) on the product \(\mathcal{M}_R\otimes_L \mathcal{A}\) between the RMDP \(\mathcal{M}_R\) and DFA \(\mathcal{A}=\langle Q,2^{AP},q_\text{init},\delta,F \rangle\) that recognizes the bad prefixes of \(\varphi\). Thus, we use an \((\mathcal{M}_R\otimes_L\mathcal{A}, S \times F)\)-inductive value function \(\beta \colon S \times Q \to [0,1]\). Intuitively, \(\beta(s,q)\) is an upper bound on the probability of violating \(\varphi\) in state \((s,q)\) under an optimal policy and worst-case adversary. To enforce the probability threshold \(p \in [0,1]\), we thus require that \(\beta(s_\text{init},q_\text{init}) \leq p\). Furthermore, we define \(\mathcal{V}_\beta=\prod\nolimits_{(s,q)\in S\times Q} \left[ \beta(s,q),1 \right].\) Each \(v \in \mathcal{V}_\beta\) assigns an admissible violation budget \(v(s,q) \in [0,1]\) to every product state \((s,q)\).
Definition 7 (Shield for finite RMDP). Let \(\mathcal{M}_R\), \(\mathcal{A}\), and \(\beta\) be defined as above. The shield \(\mathfrak S(\mathcal{M}_R,\mathcal{A},\beta) = (\mathcal{D},\Gamma)\) is defined as an instantiation of 5 as follows:
\(\mathcal{D} = \langle M, \mathcal{V}_\beta,m_\text{init},\zeta \rangle\) is a controllable monitor over \(S\) with states \(M \mathrel{\vcenter{:}}= Q \times [0,1]\) and \(m_\text{init}\mathrel{\vcenter{:}}= (q_\text{init},p)\), auxiliary actions \(\mathcal{V}_\beta\), and transition function \(\zeta \colon M \times S \times \mathcal{V}_\beta \to M\) defined for all \((q,y) \in M\), \(s \in S\), and \(v \in \mathcal{V}_\beta\) as \(\zeta((q,y),s,v) = \bigl(\delta(q,L(s)), v(s,\delta(q,L(s)))\bigr);\)
for all states \((s,q,y)\) of \(\mathcal{M}_R\otimes\mathcal{D}\), the set \(\Gamma(s,q,y)\) contains exactly those distributions \(\overline{\rho} \in \Delta(A \times \mathcal{V}_\beta)\) such that \(\mathbb{E}_{(a,v)\sim\overline{\rho}} \Big[ \sup_{\mu\in\mathcal{P}(s,a)} \mathbb{E}_{s'\sim\mu} \left[ v\bigl(s',\delta(q,L(s'))\bigr) \right] \Big] \le y.\)
Intuitively, \(\Gamma\) contains those distributions \(\overline{\rho}\) such that the worst-case expected next budget remains below the current budget \(y\). Since the initial budget is at most \(p\), every policy allowed by the shield keeps the worst-case probability of reaching \(S \times F\) (and thus of a bad prefix) at most \(p\).
We now analyze the guarantees of the shield from 7. In this section, we return to the setup in 2, where \(\mathcal{M}_R\) may be an infinite RMDP but the observation space \(\Xi\) is finite. Thus, we in fact analyze the shield \(\mathfrak S(\mathcal{M}_R/\alpha,\mathcal{A},\beta)\) for the finite safety abstraction \(\mathcal{M}_R/\alpha\), which is defined as the standard quotient (see 15 in App. 7). Yet, the shield is deployed on the (non-abstracted) RMDP \(\mathcal{M}_R\), so we need to reason about policies on \(\mathcal{M}_R[\overline{\theta}] \otimes_\alpha \mathcal{D}\) for different adversaries \(\overline{\theta}\), on the product of the induced MDP \(\mathcal{M}_R[\overline{\theta}]\) and the monitor \(\mathcal{D}\), relative to the abstraction map \(\alpha\).
Definition 8 (Compliant Policies). A policy \(\overline{\pi}\) on \(\mathcal{M}_R\otimes_\alpha \mathcal{D}\) is compliant* with the shield \(\mathfrak S\) acting on \((\mathcal{M}_R, \alpha)\) up to time \(T\) under the adversary \(\overline{\theta}\), if \(\overline{\pi}\) only outputs distributions consistent with \(\Gamma\), \[\mathrm{prob}_{\mathcal{M}_R[\overline{\theta}]\otimes_\alpha\mathcal{D},\overline{\pi}} \left[ \forall t < T,\; \overline{\pi}(\cdot\mid \overline{h}_t) \in \Gamma(\alpha(s_t),m_t) \right] =1,\] where \(\overline{h}_t\) denotes the product history up to time \(t\), and \((s_t, m_t)\) is its last product state.*
We say that a shield is realizable if, after following any compliant policy up to time \(t\), there always exists a continuation policy that is compliant under every adversary.
Definition 9 (Shield realizability). A shield \(\mathfrak S=(\mathcal{D},\Gamma)\) acting on \((\mathcal{M}_R,\alpha)\) is realizable* over \((\mathcal{M}_R,\alpha)\) if, for all \(t\in\mathbb{N}\), adversaries \(\overline{\theta}\) of \(\mathcal{M}\otimes_\alpha\mathcal{D}\), and policies \(\overline{\pi}\) compliant with \(\mathfrak S\) up to time \(t\) under \(\overline{\theta}\), there exists a policy \(\overline{\pi}'\) that (1) coincides with \(\overline{\pi}\) on all histories of length up to \(t\), and (2) is compliant with \(\mathfrak S\) under every adversary \(\overline{\theta}'\) that coincides with \(\overline{\theta}\) on all histories of length up to \(t\).*
As a final ingredient for defining soundness and optimality, we need to project policies \(\overline{\pi}\) on \(\mathcal{M}_R\otimes_\alpha \mathcal{D}\) onto the original RMDP \(\mathcal{M}_R\). Intuitively, the projected policy \(\overline{\pi}^\downarrow\) is obtained from \(\overline{\pi}\) by ignoring the monitor component, at each history, it selects actions according to the marginal distribution induced by \(\pi\) over product histories consistent with that history (see 23 for a formal definition).
Definition 10 (Shield soundness). Let \(\Phi= \mathbb{P}_{\geq {1-p}}(\varphi)\) be a specification, and let \(\mathcal{M}_R\) be an RMDP equipped with an observation map \(\alpha \colon S \to \Xi\). A shield \(\mathfrak S=(\mathcal{D},\Gamma)\) acting on \((\mathcal{M}_R,\alpha)\) is sound* for \(\Phi\) if, for every policy \(\overline{\pi}\) on \(\mathcal{M}_R\otimes_\alpha\mathcal{D}\) compliant with \(\mathfrak S\), we have \((\mathcal{M}_R,\,\overline{\pi}^{\downarrow}) \models \Phi\).*
Definition 11 (Shield approximate optimality). Let \(\Phi= \mathbb{P}_{\geq {1-p}}(\varphi)\) be a specification, let \(\mathcal{M}_R\) be an RMDP equipped with observation map \(\alpha \colon S \to \Xi\), let \(\epsilon>0\), and let \(\gamma\in(0,1]\). A shield \(\mathfrak S=(\mathcal{D},\Gamma)\) acting on \((\mathcal{M}_R,\alpha)\) is \((\epsilon,\gamma)\)-optimal* for \(\Phi\) if, for every policy \(\pi\) of \(\mathcal{M}_R\) such that \((\mathcal{M}_R,\pi)\models\Phi\), there exists a policy \(\overline{\pi}\) of \(\mathcal{M}_R\otimes_\alpha\mathcal{D}\) compliant with \(\mathfrak S\) such that, for every adversary \(\theta\), \[J^\gamma_{\mathcal{M}_R[\theta]}(\overline{\pi}^{\downarrow}) \ge J^\gamma_{\mathcal{M}_R[\theta]}(\pi)-\epsilon.\]*
We now state the main results of this section. Recall \(\mathcal{M}_R\) is an RMDP equipped with a finite safety abstraction \(\alpha:S\to\Xi\), defining the quotient RMDP \(\mathcal{M}_R/\alpha = \langle \Xi,A_\alpha,\mathcal{P}_\alpha,\xi_\text{init},AP,L_\alpha \rangle\). Also, let \(\Phi=\mathbb{P}_{\ge 1-p}(\varphi)\), let \(\mathcal{A}=\langle Q,2^{AP},q_\text{init},\delta,F \rangle\) recognize the bad prefixes of \(\varphi\), and let \(\beta:\Xi\times Q\to[0,1]\) be an \(((\mathcal{M}_R/\alpha)\otimes_{L_\alpha}\mathcal{A},\Xi\times F)\)- inductive value function such that \(\beta(\xi_\text{init},q_\text{init})\le p\).
Theorem 1 (Realizability and soundness). The shield \(\mathfrak S(\mathcal{M}_R/\alpha,\mathcal{A},\beta)\) acts on \((\mathcal{M}_R,\alpha)\), is realizable over \((\mathcal{M}_R,\alpha)\), and is sound over \((\mathcal{M}_R,\alpha)\) for \(\Phi\).
We say an RMDP \(\mathcal{M}_R\) is conditionally deterministic w.r.t. abstraction \(\alpha\) if every reachable abstract history determines a unique concrete history, for every abstract history \(\widehat h_t=\xi_0a_0\xi_1a_1\cdots a_{t-1}\xi_t\) with \(\xi_0=\alpha(s_\text{init})\), there is at most one concrete history \(h_t=s_0a_0s_1a_1\cdots a_{t-1}s_t\) such that \(s_0=s_\text{init}\), \(\alpha(s_i)=\xi_i\) for all \(i\le t\), and \(h_t\) has positive probability under some adversary of \(\mathcal{M}_R\). We remark that this assumption is trivially satisfied if the safety abstraction \(\alpha\) is the identity. As another example, this assumption is satisfied by the Pacman environment used for our experimental evaluation in Section 5. This assumption is needed for 2 because an optimal safe policy might otherwise induce different safety-relevant behaviors on different concrete states associated with the same abstract history, in which case it might become impossible to certify the safety of that safe optimal policy without some further knowledge of the dynamics of the concrete MDP.
Theorem 2 (Approximate optimality). Let \(\epsilon= \frac{\|\beta-\beta^{\infty}\|_\infty}{\|\beta-\beta^{\infty}\|_\infty+p-\beta(\xi_\text{init},q_\text{init})},\) with \(\beta^\infty\) the least fixed point of \(B^{\Xi \times F}_{(M_R/\alpha)\otimes_{L_\alpha} A}\), suppose \(\beta(\xi_\text{init},q_\text{init})<p\), and that \(\mathcal{M}_R\) is conditionally deterministic w.r.t. \(\alpha\). Then, for the shield \(\mathfrak S(\mathcal{M}_R/\alpha,\mathcal{A},\beta)\), we have:
if the total undiscounted return is defined on all infinite paths, and if its absolute value is uniformly bounded by \(B\), then \(\mathfrak S(\mathcal{M}_R/\alpha,\mathcal{A},\beta)\) is \((2B\epsilon,1)\text{-optimal}\) over \((\mathcal{M}_R,\alpha)\) for \(\Phi\);
if \(0<\gamma< 1\) and \(\sup_{(s,a)\in S\times A}|R(s,a)|\le Z\), then \(\mathfrak S(\mathcal{M}_R/\alpha,\mathcal{A},\beta)\) is \((\frac{2Z\epsilon}{1-\gamma},\gamma)\text{-optimal}.\)
1 2 show that the shield in 7 is sound and approximately optimal, respectively. Furthermore, if the value function \(\beta\) used to define the shield is equal to the exact least fixed point \(\beta^\infty\), then our shield is (exactly) optimal, as long as the corresponding return is well-defined.
We use the shielding approach from 3 to shield unknown finite MDPs learned as an RMDP. A common approach to learning an unknown (finite) MDP is to estimate transition probabilities from samples and represent the resulting uncertainty via intervals [41]–[45]. For each state-action \((s,a)\) and next state \(s'\), we construct an interval \([\check{P}(s,a,s'), \hat{P}(s,a,s')] \subseteq [0,1]\) and define the uncertainty set \[\mathcal{P}(s,a) = \left\{ \mu \in \Delta(S) \;:\; \forall s' \in S,\; \mu(s') \in [\check{P}(s,a,s'), \hat{P}(s,a,s')] \right\}.\] Suppose that, for a fixed pair \((s,a)\), we obtain \(N_{s,a}\) samples from \(P(s,a)\), out of which \(N_{s,a,s'}\) led to a transition to \(s'\). For any confidence budget \(\tau\in (0,1)\), the Clopper-Pearson confidence interval [46] provides a probably approximately correct (PAC) estimator of the unknown probability \(P(s,a,s')\): \[\mathbb{P}\big\{ P(s,a,s') \in [\check{P}(s,a,s'), \hat{P}(s,a,s')] \big\} \ge 1 - \tau,\] which is defined via the inverse CDF of the beta distribution \(\mathrm{Beta}(\alpha, \nu)\), denoted by \(\mathrm{Beta}^{-1}(\cdot; \alpha, \nu)\): \[\begin{align} \check{P}(s,a,s') &= \begin{cases} 0, & N_{s,a,s'} = 0,\\ \mathrm{Beta}^{-1}(\tfrac{\tau}{2};\,\, N_{s,a,s'},\, N_{s,a}-N_{s,a,s'}+1), \,\,\,\,\,\,\,\,\,\, & \text{otherwise}, \end{cases} \\[0.0em] \hat{P}(s,a,s') &= \begin{cases} 1, & N_{s,a,s'} = N_{s,a},\\ \mathrm{Beta}^{-1}(1-\tfrac{\tau}{2};\,\, N_{s,a,s'}+1,\, N_{s,a}-N_{s,a,s'}), & \text{otherwise}. \end{cases} \end{align}\] By repeating this procedure for every state-action pair, we obtain the transition function \(\mathcal{P}\) for an RMDP such that \(\mathbb{P}\left\{ P \in \mathcal{P}\right\} \geq 1-\psi\cdot \tau,\) with \(\psi\leq |S|^2 \cdot |A|\) the number of transitions in the MDP.
Remark 1. Without further assumptions on the MDP, the Clopper-Pearson confidence interval cannot prove the absence of a transition \((s,a,s')\), even if \(N_{s,a,s'} = 0\) and \(N_{s,a}\) is high. A common workaround is to assume a minimum probability \(p_\text{min}\) for each transition in the MDP [41], [47]. If the sum of the lower bounds \(\check{P}(s,a,s')\) for all states \(s' \in S\) with \(N_{s,a,s'} > 0\) exceeds \(1-p_\text{min}\), then the probability of having overlooked another transition falls within the confidence budget.
In our experiments, we either assume that (a) the graph of the MDP (and thus \(\psi\)) is known, or (b) the graph of the MDP is unknown, but the minimum probability \(p_\text{min}\) is known (and \(\psi= |S|^2 \cdot |A|\)).
Finally, we use our approach from 3 to shield a learned RMDP \(\widehat{\mathcal{M}}\), representing an unknown MDP \(\mathcal{M}= \langle S,A,P,s_\text{init},AP,L,R \rangle\) equipped with a safety abstraction \(\alpha \colon S\to\Xi\) into a finite set \(\Xi\). We write \(\mathcal{M}/\alpha = \langle \Xi,A_\alpha,P_\alpha,\xi_\text{init},AP,L_\alpha \rangle\) for the quotient MDP (cf. 15), \(\Phi=\mathbb{P}_{\ge 1-p}(\varphi)\) is a specification, and \(\mathcal{A}\) is a DFA for the bad prefixes of \(\varphi\). In the following, we assume we have learned a finite RMDP such that the true \(P_\alpha\) is contained in the learned set \(\widehat\mathcal{P}\), \(P_\alpha(\xi,a)\in\widehat{\mathcal{P}}(\xi,a)\) \(\,\forall (\xi,a) \in \Xi \times A_\alpha\). In practice, this holds with probability \(\geq 1-\psi\cdot \tau\), so this confidence level carries over to 3 4 below.
Let \(\widehat\beta:\Xi\times Q\to[0,1]\) be an \((\widehat{\mathcal{M}}\otimes_{L_\alpha}\mathcal{A},\Xi\times F)\)-inductive value function such that \(\widehat\beta(\xi_\text{init},q_\text{init})\le p\). Then, the shield \(\mathfrak S(\widehat{\mathcal{M}},\mathcal{A},\widehat\beta)\) computed on the learned RMDP \(\widehat\mathcal{M}\) is sound for the unknown MDP \(\mathcal{M}\):
Theorem 3 (Soundness for the unknown MDP). The shield \(\mathfrak S(\widehat{\mathcal{M}},\mathcal{A},\widehat\beta)\) acts on \((\mathcal{M},\alpha)\), and every compliant policy \(\overline{\pi}\) satisfies the specification \(\Phi\) on the true MDP \(\mathcal{M}\), \((\mathcal{M},\overline{\pi}^\downarrow) \models \mathbb{P}_{\ge 1-p}(\varphi)\).
We now present our optimality results, which bound the gap in expected return between the optimal policy under the shield \(\mathfrak S(\widehat{\mathcal{M}},\mathcal{A},\widehat\beta)\), and the optimal safe policy on the true MDP \(\mathcal{M}\). These bounds depend on the total variation abstraction error \(\eta \mathrel{\vcenter{:}}= \sup_{(\xi,a) \in \Xi \times A_\alpha} \sup_{\widehat P\in\widehat{\mathcal{P}}(\xi,a)} \mathrm{TV}(P_\alpha(\xi,a),\widehat P)\), the least fixed points \(\widehat\beta^\infty\) and \(\beta^\infty\) of the Bellman operators \(\mathcal{B}_{\widehat{\mathcal{M}}\otimes_{L_\alpha}\mathcal{A}}^{\Xi\times F}\) and \(\mathcal{B}_{(\mathcal{M}/\alpha)\otimes_{L_\alpha}\mathcal{A}}^{\Xi\times F}\) as in 6, and the parameter \(q_\text{min} = \frac{p_\text{min}\left(\mathcal{M}\right) \cdot p_\text{min}(\widehat\mathcal{M})}{p_\text{min}(\mathcal{M}/\alpha)}\), where \(p_\text{min}(\cdot)\) denotes the minimum transition probability of the respective model. Finally, let \(H_{\max}\) be a uniform upper bound on the expected hitting time to either a bad automaton state or a safe absorbing component, taken over all deterministic \(\mathcal{A}\)-memory policies and all transitions in \(\widehat\mathcal{P}\). As a conservative bound, we may take \(H_{\max}= \frac{|S| \cdot |Q|}{ (q_\text{min})^{|S| \cdot |Q|}}\).
In 4, we again use optimality as per 11 and define \(\widehat\epsilon_\beta \mathrel{\vcenter{:}}= \frac{ \|\widehat\beta-\widehat\beta^\infty\|_\infty }{ \|\widehat\beta-\widehat\beta^\infty\|_\infty + p-\widehat\beta(\xi_\text{init},q_\text{init}) }\) for brevity. To ensure the denominator of \(\epsilon_{\widehat \beta}\) is nonzero, we assume \(\widehat\beta(\xi_\text{init},q_\text{init}) < p\), which in turn implies there exists a policy \(\pi_{\mathrm{sl}}\) and a constant \(\kappa>0\) such that \(\inf_{\widehat\theta} \mathrm{prob}_{\widehat{\mathcal{M}}[\widehat\theta],\pi_{\mathrm{sl}}}(\varphi) \ge 1-p+\kappa.\)
Theorem 4 (Near-optimality for the unknown MDP). If \(\mathcal{M}\) is conditionally deterministic w.r.t. \(\alpha\), it holds that:
if \(\mathcal{M}\) is finite, the learned \(\widehat\mathcal{M}\) is graph-preserving,2 and the absolute value of the total undiscounted return is uniformly bounded by \(B\), then the shield \(\mathfrak S(\widehat{\mathcal{M}},\mathcal{A},\widehat\beta)\) is \((2B\epsilon_{\mathrm{TV}},1)\)-optimal over \((\mathcal{M},\alpha)\) for \(\Phi\), where \(\epsilon_{\mathrm{TV}} \mathrel{\vcenter{:}}= \epsilon_{\widehat\beta} + \frac{\eta H_{\max}}{\kappa+\eta H_{\max}}\).
if \(0 < \gamma < 1\) and \(\sup_{(s,a)\in S\times A}|R(s,a)|\le Z\), then the shield \(\mathfrak S(\widehat{\mathcal{M}},\mathcal{A},\widehat\beta)\) is \(\left( \frac{2Z\epsilon_T}{1-\gamma}, \gamma \right)\)-optimal over \((\mathcal{M},\alpha)\) for \(\Phi\), where \(\epsilon_T \mathrel{\vcenter{:}}= \min_{T\in\mathbb{N}}\left( \epsilon_{\widehat\beta} + \gamma^T + \frac{T\eta + \|\widehat\beta^\infty-\beta^\infty\|_\infty}{\kappa+T\eta + \|\widehat\beta^\infty-\beta^\infty\|_\infty} \right).\)
The bounds in 4 separate three sources of suboptimality. First, \(\epsilon_{\widehat\beta}\) comes from using the inductive certificate \(\widehat\beta\) instead of the exact robust fixed point \(\widehat\beta^\infty\). Second, the terms with \(\eta\) quantify the mismatch between the learned RMDP and the true abstraction \(\mathcal{M}/\alpha\). Third, the additional term \(\gamma^T\) in the discounted case is the price of switching after \(T\) steps to a robustly safe Slater policy; increasing \(T\) reduces this switching cost but increases the finite-horizon model error term \(T\eta\).
We implement our shielding approach and perform numerical experiments to demonstrate our approach for safe reinforcement learning on unknown MDPs via shielding learned RMDPs.
Our shielding pipeline for unknown MDPs consists of three steps: (1) Learn an RMDP from sampled transitions; (2) Construct a shield on the learned RMDP; and (3) Run policy optimization with the shield active. We assume access to a simulator of the underlying MDP \(\mathcal{M}\), but crucially do not know its transition function \(P\). For step (1), we use this simulator (in fact, a simulator of the safety abstraction only suffices) to sample transitions for every state-action pair and learn an RMDP \(\widehat\mathcal{M}\) as described in 4 that is correct wrt a specified confidence \(\delta \in (0,1)\). For (2), we run robust value iteration [11], [48] on the product RMDP \(\widehat\mathcal{M}\otimes_L \mathcal{A}\) to compute an inductive value function \(\beta\) (cf. 6) to construct the shield as per 7. For (3), we use reinforcement learning on the MDP simulator with the action space restricted to \(A^{\mathfrak S}(s,m)=\Gamma(\alpha(s),m)\). This space \(A^{\mathfrak S}(s,m)\) is convex and can thus be given by its extremal points. In fact, the set of violation budgets \(\mathcal{V}_\beta\) that satisfy condition 2 in 7 has finitely many extremal points, allowing us to represent and optimize over the shielded action space (see 10.1 for details). In practice, we optimize the policy with PPO [49] and implement a heuristic for choosing the auxiliary actions, described in 10.1.
We conduct experiments comparing our contributions (cases 3 and 4 below) against two baselines that use state-of-the-art probabilistic shielding for MDPs (cases 1 and 2):
Known MDP (MDP). This baseline assumes full knowledge of the true MDP transition probabilities and uses the probabilistic shielding from [7] directly on the exact model. This baseline provides a reference for safety and performance under full knowledge of the MDP.
MLE-based Shielding (MLE). This baseline applies the probabilistic shielding from [7]
on a learned MDP with maximum-likelihood estimates (MLEs) of the transition probabilities. While this approach often achieves strong reward performance, the lack of uncertainty modeling prevents theoretical guarantees and can lead to unsafe
behavior.
RMDP Shield with Known Support (Kno). The MDP is unknown and is learned as an RMDP with PAC guarantees, but the graph of the true MDP is known in advance.
RMDP Shield with Unknown Support (Unk). Same as setting 3, but the graph of the true MDP is unknown and must instead be learned based on a given minimum transition probability \(p_\text{min}\) as part of the RMDP learning, as described in 1.
We compare these four cases on two variants of three environments: Media Streaming, Color Bomb Gridworld, and Pacman (see 10.2 for detailed descriptions).
We learn each RMDP with an overall confidence level of \(0.95\), taking between \(10\)–\(20\,000\) samples per distribution \(P(s,a)\) in the MDP simulator (except for the MDP baseline, which does not use sampling). For each configuration, we report two evaluation metrics: (1) expected discounted reward (rew) is the average
episodic return, and (2) specification satisfaction probability (sat) is the empirical probability that an evaluation rollout satisfies the safety specification on 15 episodes. The experiments are run on a server running Ubuntu 24.04.4 LTS,
with an Intel Core i7-10700K CPU, 32 GB of RAM, and NVIDIA GeForce RTX 3080 GPU with 10 GB VRAM. The code to reproduce our results is provided in the supplementary material. Our implementation builds upon the MASA library [50], for the PPO algorithm.
3 summarizes our experimental results, reporting the averaged metrics (rew and sat) during training as a function of the sample size for each environment. Learning curves showing the
evolution of these metrics are deferred to 10.2 to avoid clutter. Finally, all experiments are averaged over three random seeds, and shaded regions show the standard deviation. The MDP baseline
corresponds to a perfect-information setting and therefore remains constant across all sample sizes.
First, we observe that Kno and Unk cannot always be evaluated for small sample sizes, as illustrated by Pacman Slippery. In particular, for too low sample sizes, the learned uncertainty sets \(\mathcal{P}(s,a)\) of the RMDP are too large to construct a shield that satisfies the required satisfaction probability of \(1-p\). Increasing the sample size yields tighter sets \(\mathcal{P}(s,a)\), thereby mitigating this issue. For Unk, we additionally need at least a certain minimum number of samples from each distribution \(P(s,a)\) of the MDP to learn
the graph structure, as described in 1.
Despite these sampling requirements, 3 shows that the claimed safety probability of \(1-p\) is indeed satisfied empirically by our robust shields (Kno and
Unk). As the number of samples increases, the uncertainty sets become progressively tighter, reducing the conservativeness of the robust shield and allowing the methods to achieve increasingly higher expected rewards while maintaining safety.
By contrast, the MLE shield frequently fails to satisfy the required safety threshold for small to moderate sample sizes, despite often achieving strong reward performance, in the Pacman environment. The reason is that
MLE does not explicitly model uncertainty in the learned probabilities and thus cannot provide safety guarantees.
Overall, our results highlight a trade-off between the data used to learn the RMDP and the shield’s conservatism. For small sample sizes, our robust methods lead to suboptimal rewards, while the specification satisfaction probability remains well above
the required threshold. This conservatism is a typical limitation of robust methods, which rely on worst-case reasoning leading to loose bounds for small sample budgets [51], [52]. Nevertheless, as the sample size grows,
the learned RMDP becomes a tighter approximation to the true MDP, yielding results close to the baseline with a fully known MDP.
We presented a novel shielding approach for robust MDPs (RMDPs). Our shielding approach is sound and (approximately) optimal and can be used to shield unknown MDPs learned as an RMDP. By using existing sampling methods for learning transition probabilities with PAC guarantees, we construct shields that, with high confidence, ensure safety while remaining minimally restrictive. Our experiments confirmed that, while conservative for small sample sizes, our robust shields guarantee probabilistic safety, whereas shields constructed for MDPs with maximum likelihood estimates do not. In the future, we plan to extend our approach to robust shielding of stochastic games and investigate more sophisticated RMDP learning techniques to reduce the required sample sizes.
This research is supported by the EPSRC grant EP/Y028872/1, Mathematical Foundations of Intelligence: An “Erlangen Programme” for AI. Edwin Hamel-De le Court is funded by the ARIA opportunity seed grant titled “Hardware-Level AI Safety Verification.” Thom Badings was supported by the RWTH “Port to Europe” Postdoc Programme, as part of the Excellence Initiative of the German Research Foundation DFG.
Remark 2. Throughout the appendices, we provide formalizations of all definitions and results from the paper, including their measure-theoretic constructions and, for example, (R)MDPs with subsets of enabled actions. For completeness, we thus repeat all definitions and results from the paper, often extending them with the appropriate notations.
For a standard Borel space \(X\), we write \(\Delta(X)\) for the set of probability measures on \(X\), equipped with the evaluation \(\sigma\)-algebra. When \(X\) is endowed with a Polish topology generating its Borel \(\sigma\)-algebra, we equip \(\Delta(X)\) with the corresponding weak topology; its Borel \(\sigma\)-algebra coincides with the evaluation \(\sigma\)-algebra. For any set-valued map \(f\colon E\to 2^F\), we let \(\operatorname{Gr}(f)\) denote the graph of f, the set \(\{(x,y)\mid x\in E, y\in f(x)\}\).
A Markov Decision Process (MDP) is a tuple \(\mathcal{M}=\langle S,A,P,s_\text{init},AP,L \rangle\), where \(S\) is a standard Borel space of states; \(A\) is a mapping \(A\colon S\to 2^{\mathsf A}\) where \(\mathsf A\) is a standard Borel space of actions, that defines for each \(s\in S\) the actions \(A(s)\) enabled in \(s\), and such that \(\operatorname{Gr}(A)\) is Borel; the transition function \(P \colon \operatorname{Gr}(A) \to \Delta(S)\) is a measurable map; \(s_\text{init}\in S\) is the initial state; \(AP\) is a finite set of atomic propositions equipped with the discrete \(\sigma\)-algebra; and \(L\colon S\to2^{AP}\) is a measurable labeling function. We say that \(\mathcal{M}\) is an MDP with rewards if it is additionally equipped with a measurable reward function \(R\colon \operatorname{Gr}(A)\to \mathbb{R}\). For simplicity, we may write \(P(s,a,s')\) instead of \(P(s,a)(\{s'\})\) when \(\{s'\}\) is measurable. A finite path or history in \(\mathcal{M}\) is a finite word \(h=s_0 a_0 \cdots s_{n-1}a_{n-1}s_n\) in \(S(\mathsf A S)^n\) for some \(n\in\mathbb{N}\) such that \(a_i\in A(s_i)\) for \(i\in \{0,\ldots,n-1\}\). The length of a history \(h=s_0 a_0 \cdots s_{n-1}a_{n-1}s_n\) is \(n\), and we denote its last state \(s_n\) by \(\text{last}\left(h\right)\). An infinite path or infinite history \(h=s_0 a_0\cdots s_n a_n\cdots\) is defined analogously.
For \(n\in\mathbb{N}\), let \(H_n\) be the space of histories of length \(n\), equipped with the trace \(\sigma\)-algebra induced by the product \(\sigma\)-algebra of \(S\times (\mathsf A \times S)^n\) on \(H_n\). A policy of \(\mathcal{M}\) is a sequence \(\pi=(\pi_n)_{n\ge 0}\), where each \(\pi_n\) is a measurable map from \(H_n\) to \(\Delta(\mathsf A)\) such that \(\pi_n(h)(A(\text{last}\left(h\right)))=1\) for any \(h\in H_n\). We denote \(\pi_n(h)(E)\) by \(\pi(E\mid h)\). We write \(\mathrm{HR}\) for the general class of history-dependent randomized policies. A policy \(\pi\in\mathrm{HR}\) is memoryless deterministic if there exists a measurable map \(d\colon S\to\mathsf A\) such that \(d(s)\in A(s)\) for every \(s\in S\), and for every finite history \(h\), \(\pi(\cdot\mid h)=\mathrm{Dirac}\left(d(\text{last}\left(h\right))\right)\). We write \(\mathrm{MD}\) for the class of memoryless deterministic policies. In the rest of the paper, the policies considered are in \(\mathrm{HR}\) unless stated otherwise.
Fixing a policy \(\pi\) and an initial state \(s \in S\) induces a probability measure \(\text{prob}^{s}_{\mathcal{M},\pi}\) over paths of the MDP \(\langle S,A,P,s,AP,L \rangle\). We write \(\text{prob}_{\mathcal{M},\pi}\) for \(\text{prob}^{s_\text{init}}_{\mathcal{M},\pi}\). For details on policies and induced probability measures, see [36], [37].
We consider objectives for MDPs expressed in linear temporal logic (LTL). Following [36], an LTL formula \(\varphi\) over the atomic propositions \(AP\) is generated by the grammar \[\varphi::= \top \mid p \mid \neg \varphi\mid \varphi\land \varphi \mid \mathbf{X}\varphi\mid \varphi\,\mathbf{U}\, \varphi, \qquad p \in AP.\] As usual, we define \(\varphi_1 \lor \varphi_2 \mathrel{\vcenter{:}}= \neg(\neg \varphi_1 \land \neg \varphi_2)\), \(\mathbf{F}\varphi\mathrel{\vcenter{:}}= \top \,\mathbf{U}\, \varphi\), and \(\mathbf{G}\varphi\mathrel{\vcenter{:}}= \neg \mathbf{F}\neg \varphi\). A finite (resp. infinite) trace is a sequence \(\tau = b_0 b_1\cdots \in \Sigma^*\) (resp. \(\Sigma^\omega\)), where the alphabet \(\Sigma = 2^{AP}\) specifies which propositions hold at one instant. Given an (in)finite path \(h=s_0 a_0 s_1 a_1 \cdots\), we denote by \(L(h)=L(s_0)L(s_1)L(s_2)\cdots\) the (in)finite trace induced by the labeling function. The satisfaction relation \(\tau,i \models \varphi\) for a formula \(\varphi\) is defined inductively over infinite traces \(\tau = b_0 b_1\cdots\) of \(\mathcal{M}\) as \[\begin{align} {2} \tau,i &\models p &&\iff p \in b_i,\\ \tau,i &\models \neg \varphi&&\iff \tau,i \not\models \varphi,\\ \tau,i &\models \varphi_1 \land \varphi_2 &&\iff \tau,i \models \varphi_1 \text{ and } \tau,i \models \varphi_2,\\ \tau,i &\models \mathbf{X}\varphi&&\iff \tau,i+1 \models \varphi,\\ \tau,i &\models \varphi_1 \,\mathbf{U}\, \varphi_2 &&\iff \exists j \geq i \text{ such that } \tau,j \models \varphi_2 \text{ and } \tau,k \models \varphi_1 \text{ for all } i \leq k < j. \end{align}\] We write \(\tau \models \varphi\) as shorthand for \(\tau,0 \models \varphi\). An LTL formula \(\varphi\) is a safety formula [14] if every violating trace has a finite witness of violation, for every \(\tau \in \Sigma^\omega\) such that \(\tau \not\models \varphi\), there exists a finite prefix \(u \prec \tau\) (called a bad prefix) such that for every \(\rho \in \Sigma^\omega\), \(u\rho \not\models \varphi\). For every safety formula \(\varphi\), there exists a DFA that accepts exactly all bad prefixes of \(\varphi\):
Definition 12 (DFA, restatement of 1). A deterministic finite automaton* (DFA) over the alphabet \(\Sigma\) is a tuple \(\mathcal{A}=(Q,\Sigma,q_\text{init},\delta,F)\), where \(Q\) is a finite set of states, \(q_\text{init}\in Q\) is the initial state, \(\delta\colon Q\times\Sigma\to Q\) is the transition function, and \(F \subseteq Q\) is the set of accepting states.*
The transition function extends to finite words in the standard way: \(\delta^*(q,ua)=\delta(\delta^*(q,u),a)\) for \(u\in\Sigma^*\) and \(a\in\Sigma\). A finite word \(u \in \Sigma^*\) is accepted by the DFA \(\mathcal{A}\) iff \(\delta^*(q_\text{init},u)\in F\).
A specification \(\Phi=\mathbb{P}_{\geq p}(\varphi)\) combines an LTL formula \(\varphi\) and a threshold \(p \in [0,1]\). For a state \(s\in S\) and policy \(\pi\), we write \((\mathcal{M},\pi,s)\models \mathbb{P}_{\geq p}(\varphi)\) iff \(\text{prob}^{s}_{\mathcal{M},\pi} \bigl( \{h \mid L(h)\models \varphi\} \bigr) \geq p\), the probability for generating a trace satisfying \(\varphi\) is at least \(p\). When \(s=s_\text{init}\), we simply write \((\mathcal{M},\pi)\models \mathbb{P}_{\geq p}(\varphi)\).
Robust MDPs (RMDPs) extend MDPs with sets of transition probabilities [13].
Definition 13 (RMDP, restatement of 2). A robust MDP* (RMDP) is a tuple \(\mathcal{M}_R= \langle S,A,\mathcal{P},s_\text{init},{AP},L \rangle\), where \(S\), \(A\), \(s_\text{init}\), \({AP}\), and \(L\) are defined as in an MDP, and \(\mathcal{P}\colon \operatorname{Gr}(A) \to 2^{\Delta(S)}\) is a mapping with measurable graph called an uncertain transition function.*
We say that \(\mathcal{M}_R\) is an RMDP with rewards if, additionally, it is equipped with a measurable reward function. An RMDP defines a game between the agent that chooses actions via the policy \(\pi\), and an adversary \(\theta\) that chooses probability distributions in \(\mathcal{P}\). Formally, an adversary for an RMDP \(\mathcal{M}_R\) is a sequence \(\theta=(\theta_n)_{n\in\mathbb{N}}\), where each \(\theta_n\) assigns to every history \(h\in H_n\) and every action \(a\in A(\text{last}\left(h\right))\) a measure \(\theta_n(h,a)\in\mathcal{P}(\text{last}\left(h\right),a)\), and is measurable as a map \((h,a)\mapsto\theta_n(h,a)\). Fixing an adversary \(\theta\) induces an MDP on the history space \(H=\bigsqcup_{n\in\mathbb{N}}H_n\), whose enabled actions at \(h\in H\) are \(A(\text{last}\left(h\right))\), and whose transition kernel is given by \[P_\theta(h,a)(E) = \theta_n(h,a) \bigl(\{s'\in S: h a s'\in E\}\bigr), \qquad h\in H_n.\] We denote this history MDP by \(\mathcal{M}_R[\theta]\). For an RMDP \(\mathcal{M}_R\) and a policy \(\pi\), we write \(\mathcal{M}_R,\pi\models\Phi\) if, for every adversary \(\theta\) of \(\mathcal{M}\), \(\mathcal{M}_R[\theta],\pi\models\Phi\).
Remark 3. [def:RMDP,def:RMDP_appendix] describes an \((s,a)\)-rectangular RMDP, meaning the sets of probabilities between states and actions are independent, and optimal policies can be computed efficiently by robust dynamic programming [13]. More generally, RMDPs can be defined with dependent probabilities in different actions in the same state (\(s\)-rectangularity) or even in different states (non-rectangularity). However, computing optimal robust policies for non-rectangular RMDPs is NP-hard in general [13].
We could directly define a shield on the RMDP \(\mathcal{M}_R\), but often, parts of the state space are unimportant for the satisfaction of the safety formula \(\varphi\). Thus, we follow the common approach of defining a shield on a safety-relevant abstraction of the model [6], defined as follows.
Definition 14 (RMDP abstraction). Let \(\mathcal{M}_R= \langle S,A,\mathcal{P},s_\text{init},{AP},L \rangle\) be an RMDP, and let \(\Xi\) be a standard Borel space. A surjective measurable map \(\alpha \colon S\to \Xi\) is an abstraction* of \(\mathcal{M}_R\) if the following conditions hold for all \(s,s'\in S\):*
if \(\alpha(s)=\alpha(s')\), then \(L(s)=L(s')\) and \(A(s)=A(s')\);
for every action \(a\in A(s)\), we have \[\left\{\mu\circ \alpha^{-1}\mid \mu\in\mathcal{P}(s,a)\right\} = \left\{\mu\circ \alpha^{-1}\mid \mu\in\mathcal{P}(s',a)\right\};\]
the induced correspondence \(\mathcal{P}_\alpha\) defined by \(\mathcal{P}_\alpha(\xi,a) = \left\{\mu\circ\alpha^{-1}:\mu\in\mathcal{P}(s,a)\right\}\) for any \(s\in\alpha^{-1}(\xi)\) has measurable graph.
Intuitively, condition 1 requires that all states \(s,s' \in S\) mapping to the same abstract state have the same label and enabled actions, and condition 2 that these states induce the same sets of transition probabilities under the abstraction map. Since \(\alpha\) is surjective and refines the labeling, the induced labeling map \(L_\alpha\colon \Xi\to 2^{AP}\) is well-defined by \(L_\alpha(\xi)=L(s)\) for any \(s\in\alpha^{-1}(\{\xi\})\).
Definition 15 (Quotient RMDP). Let \(\mathcal{M}_R\) be an RMDP and let \(\alpha\colon S\to\Xi\) be an RMDP abstraction. The quotient RMDP of \(\mathcal{M}_R\) by \(\alpha\) is \(\mathcal{M}_R/\alpha = \langle \Xi,A_\alpha,\mathcal{P}_\alpha,\xi_\text{init},AP,L_\alpha \rangle\), where \(\xi_\text{init}=\alpha(s_\text{init})\), \(A_\alpha(\xi)=A(s)\) for any \(s\in\alpha^{-1}(\xi)\), \(\mathcal{P}_\alpha(\xi,a) = \left\{\mu\circ \alpha^{-1}\mid \mu\in\mathcal{P}(s,a)\right\}\) for any \(s\in\alpha^{-1}(\xi)\), \(L_\alpha\) is given by the abstraction property above.
In this appendix, we present all extended definitions, results, and proofs for our RMDP shielding approach from 3.
In this section, we formally define the notion of shield for an RMDP and how it constrains the action choices when deployed on an RMDP. We first define the notion of controllable monitor.
Definition 16 (Controllable monitor, restatement of 3). A controllable monitor over a measurable observation space \(\Xi\) is a tuple \(\mathcal{D}=\langle M, U,m_\text{init},\zeta \rangle\), where \(M\) is a measurable space of monitor states, \(U\) is a measurable space of auxiliary actions, \(m_\text{init}\in M\), and \(\zeta\colon M\times \Xi\times U\to M\) is a measurable transition function.
For simplicity, we identify DFAs and their associated controllable monitor. Recall that, for any measurable map \(T\colon X\to Y\) and any measure \(\mu\) on \(X\), the pushforward of \(\mu\) by \(T\) is the measure \(\mu\circ T^{-1}\) on \(Y\) defined by \((\mu\circ T^{-1})(E)=\mu(T^{-1}(E))\) for every measurable set \(E\subseteq Y\).
An observation map for a state space \(S\) is a measurable map \(\alpha\colon S\to\Xi\) into the observation space \(\Xi\) of a controllable monitor.
Lemma 1 (Measurability of the product uncertainty graph). Let \(S,\mathsf A,M,\Xi,U\) be standard Borel spaces. Let \(A\colon S\to 2^\mathsf A\) have measurable graph, and let \(\mathcal{P}\colon \operatorname{Gr}(A)\to 2^{\Delta(S)}\) have Borel measurable graph. Let \(\alpha\colon S\to\Xi\) be measurable and let \(\zeta\colon M\times\Xi\times U\to M\) be measurable. For \(m\in M\) and \(u\in U\), define \[T_{m,u}\colon S\to S\times M, \qquad T_{m,u}(s') = \bigl(s',\zeta(m,\alpha(s'),u)\bigr).\] Define the product uncertainty correspondence by \[\overline{\mathcal{P}}((s,m),(a,u)) = \left\{ \mu\circ T_{m,u}^{-1} : \mu\in\mathcal{P}(s,a) \right\}.\] Then \(\operatorname{Gr}(\overline{\mathcal{P}})\) is Borel measurable.
Proof. First, since \(\alpha\) and \(\zeta\) are measurable, the map \(K\colon M\times U\times S\to S\times M\) defined by \[K(m,u,s') = \bigl(s',\zeta(m,\alpha(s'),u)\bigr)\] is measurable. Hence, the induced pushforward map \(F\colon M\times U\times\Delta(S)\to\Delta(S\times M)\) such that \(F(m,u,\mu)=\mu\circ T_{m,u}^{-1}\), is measurable, since for every measurable \(E\subseteq S\times M\), we have \[F(m,u,\mu)(E) = \mu\bigl(\{s'\in S:K(m,u,s')\in E\}\bigr).\] Now define \(D = \{(s,m,a,u,\mu): (s,a,\mu)\in\operatorname{Gr}(\mathcal{P})\}.\) Since \(\operatorname{Gr}(\mathcal{P})\) is Borel, \(D\) is Borel. Let \(H\colon D\to (S\times M)\times(\mathsf A\times U)\times\Delta(S\times M)\) be the map such that \[H(s,m,a,u,\mu) = \bigl((s,m),(a,u),F(m,u,\mu)\bigr).\] The map \(H\) is Borel and injective. Indeed, from \(\nu=F(m,u,\mu)=\mu\circ T_{m,u}^{-1},\) we recover \(\mu=\nu \circ \mathrm{pr}_S^{-1},\) with the projection \(\mathrm{pr}_S\colon S\times M\to S\). Thus the value of \(\mu\) is uniquely determined by \(\nu\), \(m\), and \(u\).
By the Lusin–Souslin theorem, the image of a Borel set under an injective Borel map between standard Borel spaces is Borel. Hence \(H(D)\) is Borel.
Finally, \(H(D) = \operatorname{Gr}(\overline{\mathcal{P}}).\) Therefore \(\operatorname{Gr}(\overline{\mathcal{P}})\) is Borel measurable. ◻
The above lemma allows us to define the product of an RMDP and a controllable monitor.
Definition 17 (Product RMDP, extension of 4). Let \(\mathcal{M}_R=\langle S,A,\mathcal{P},s_\text{init},AP,L \rangle\) be an RMDP, let \(\alpha\colon S\to\Xi\) be an observation map, and let \(\mathcal{D}=\langle M, U,m_\text{init},\zeta \rangle\) be a controllable monitor over \(\Xi\). The product RMDP* of \(\mathcal{M}_R\) and \(\mathcal{D}\) (relative to \(\alpha\)) is the RMDP \(\mathcal{M}_R\otimes_{\alpha} \mathcal{D}=\langle \overline{S},\overline{A},\overline{\mathcal{P}},\overline{s_\text{init}}, AP,\overline{L} \rangle\), such that \(\overline{S}=S\times M\), \(\overline{s_\text{init}}=(s_\text{init},m_\text{init})\), and for any \((s,m)\in \overline{S}\),*
\(\overline{L}(s,m)=L(s)\),
\(\overline{A}\) is a mapping from \(S\) to \(2^{\overline{\mathsf A}}\), where \(\overline{\mathsf A}=\mathsf A\times U\), such that \(\overline{A}(s,m)=A(s)\times U\);
for every \((a,u)\in\overline{A}((s,m))\), letting \(T(s') = \bigl(s',\zeta(m,\alpha(s'),u)\bigr)\), the uncertainty set \(\overline{\mathcal{P}}((s,m),(a,u))\) consists of all pushforward measures \(\mu\circ T^{-1}\) with \(\mu\in\mathcal{P}(s,a)\).
We now state our general definition of a shield, which extends 5 from the main paper with the necessary measurability requirements.
Definition 18 (Shield, extension of 5). Let \(\Xi\) be a standard Borel space, and let \(\mathsf A_{\Xi}\) be a standard Borel space of actions, let \(A_\Xi\) assign to each \(\xi\in\Xi\) a subset \(A_\Xi(\xi)\subseteq \mathsf A_{\Xi}\) so that the graph \(\{(\xi,a)\mid \xi\in \Xi,a\in A_\Xi(\xi)\}\) is measurable. A shield over \((\Xi,A_\Xi)\) is a pair \(\mathfrak S=(\mathcal{D},\Gamma)\), where \(\mathcal{D}=\langle M,U,m_\text{init},\zeta \rangle\) is a controllable monitor over \(\Xi\), and where \(\Gamma\) is a mapping from \(\Xi\times M\) to \(2^{\Delta(\mathsf A_\Xi\times U)}\) such that
for every \((\xi,m)\in\Xi\times M\), \(\Gamma(\xi,m)\) is a closed subset of \(\Delta(\mathsf A_\Xi\times U)\);
for every open set \(O\subseteq\Delta(\mathsf A_\Xi\times U)\), the set \(\{(\xi,m)\in\Xi\times M:\Gamma(\xi,m)\cap O\neq\emptyset\}\) is measurable;
for every \((\xi,m)\in\Xi\times M\) and every \(\rho\in\Gamma(\xi,m)\), we have \(\rho(A_\Xi(\xi)\times U)=1\).
The robust Bellman operator \(\mathcal{B}_{\mathcal{M}_R}^{U}\) acts on functions \(f\in [0,1]^S\) as \[\left(\mathcal{B}_{\mathcal{M}_R}^{U}(f)\right)(s) = \begin{cases} 1, & \text{ if } s\in U,\\[1mm] \displaystyle \inf_{a\in A(s)}\;\sup_{\mu\in\mathcal{P}(s,a)} \mathbb{E}_{s'\sim \mu} \left[f(s')\right], & \text{otherwise.} \end{cases}\]
Definition 19 (Restatement of 6). An \((\mathcal{M}_R,U)\)-inductive value function* is a function \(\beta\colon S\to [0;1]\) such that, for all \(s\in S\), \(\left(\mathcal{B}_{\mathcal{M}_R}^{U}(\beta)\right)(s)-\beta(s)\leq 0\).*
In the following, we let \(\mathcal{M}_R=\langle S,A,\mathcal{P},s_\text{init},AP,L,R \rangle\) with \(A\colon S\to 2^{\mathsf A}\) be a finite RMDP, we let \(p\in [0;1]\) be a safety threshold, and we let \(\Phi=\mathbb{P}_{\geq 1-p}(\varphi)\) be a probabilistic safety LTL formula. We let \(\mathcal{A}=\langle Q,2^{AP},q_\text{init},\delta,F \rangle\) be a DFA recognizing the bad prefixes of \(\varphi\). We additionally let \(\beta\) be an \((\mathcal{M}_R\otimes_{L}\mathcal{A},S\times F)\)-inductive value function such that \(\beta(s_\text{init},q_\text{init}) \leq p\). Finally, we let \(\mathcal{V}_\beta=\prod_{(s,q)\in S\times Q}[\beta(s,q),1]\).
Definition 20 (Shield for finite RMDP, extension of 7). Let \(\mathcal{M}_R\), \(\mathcal{A}\), and \(\beta\) be defined as above. The shield \(\mathfrak S(\mathcal{M}_R,\mathcal{A},\beta) = (\mathcal{D},\Gamma)\) is defined as an instantiation of 5 as follows:
\(\mathcal{D} = \langle M, \mathcal{V}_\beta,m_\text{init},\zeta \rangle\) is a controllable monitor over \(S\) with states \(M \mathrel{\vcenter{:}}= Q \times [0,1]\), auxiliary actions \(\mathcal{V}_\beta\), initial state \(m_\text{init}= (q_\text{init},p)\), and transition function \(\zeta \colon M \times S \times \mathcal{V}_\beta \to M\) defined for all \((q,y) \in M\), \(s \in S\), and \(v \in \mathcal{V}_\beta\) as \[\zeta((q,y),s,v) = \bigl(\delta(q,L(s)), v(s,\delta(q,L(s)))\bigr);\]
for all states \((s,q,y)\) of \(\mathcal{M}_R\otimes\mathcal{D}\), the set \(\Gamma(s,q,y)\) contains exactly those distributions \(\overline{\rho} \in \Delta(\mathsf A\times\mathcal{V}_\beta)\) such that \(\overline{\rho}(A(s)\times\mathcal{V}_\beta)=1\), and such that \[\mathbb{E}_{(a,v)\sim\overline{\rho}} \Big[ \sup_{\mu\in\mathcal{P}(s,a)} \mathbb{E}_{s'\sim\mu} \left[ v\bigl(s',\delta(q,L(s'))\bigr) \right] \Big] \le y.\]
Lemma 2. The pair \(\mathfrak S(\mathcal{M}_R,\mathcal{A},\beta)=(\mathcal{D},\Gamma)\) is a shield over \((S,A)\).
Proof. Since \(S\), \(Q\), and \(\mathsf A\) are finite, we equip them with the discrete topology. The space \[\mathcal{V}_\beta = \prod_{(s,q)\in S\times Q}[\beta(s,q),1]\] is a compact metric space, as a finite product of compact intervals. Thus, \(M=Q\times[0,1]\) and \(\mathsf A\times\mathcal{V}_\beta\) are compact metric spaces. We equip \(\Delta(\mathsf A\times\mathcal{V}_\beta)\) with the weak topology.
The monitor transition \(\zeta((q,y),s,v) = \bigl(\delta(q,L(s)),v(s,\delta(q,L(s)))\bigr)\) is measurable, since \(S\) and \(Q\) are finite and \(v\mapsto v(s,q')\) is a coordinate projection on \(\mathcal{V}_\beta\).
It remains to show that \(\Gamma\) is a closed-valued measurable correspondence. For fixed \(s\in S\) and \(q\in Q\), define \[G_{s,q}(a,v) \mathrel{\vcenter{:}}= \begin{cases} \displaystyle \sup_{\mu\in\mathcal{P}(s,a)} \mathbb{E}_{s'\sim\mu} \left[ v\bigl(s',\delta(q,L(s'))\bigr) \right], & a\in A(s),\\[3mm] 0, & a\notin A(s). \end{cases}\] For \(a\in A(s)\), the map \(v\mapsto G_{s,q}(a,v)\) is continuous. Indeed, for any \(v,w\in\mathcal{V}_\beta\), \[|G_{s,q}(a,v)-G_{s,q}(a,w)| \le \|v-w\|_\infty.\] Since \(\mathsf A\) is finite and discrete, \(G_{s,q}\) is a bounded continuous function on \(\mathsf A\times\mathcal{V}_\beta\). Now, for \((s,q,y)\in S\times Q\times[0,1]\), \[\Gamma(s,q,y) = \left\{ \overline{\mu}\in\Delta(\mathsf A\times\mathcal{V}_\beta): \overline{\mu}(A(s)\times\mathcal{V}_\beta)=1 \text{ and } \int G_{s,q}(a,v)\,\overline{\mu}(d(a,v))\le y \right\}.\] The set \(A(s)\times\mathcal{V}_\beta\) is closed in \(\mathsf A\times\mathcal{V}_\beta\). Therefore the constraint \(\overline{\mu}(A(s)\times\mathcal{V}_\beta)=1\) defines a closed subset of \(\Delta(\mathsf A\times\mathcal{V}_\beta)\) by the Portmanteau theorem. Moreover, because \(G_{s,q}\) is bounded and continuous, the map \(\overline{\mu}\mapsto \int G_{s,q}(a,v)\,\overline{\mu}(d(a,v))\) is continuous under weak convergence. Hence each value \(\Gamma(s,q,y)\) is closed.
Finally, since \(S\) and \(Q\) are finite and the defining constraints are Borel in \(y\) and \(\overline{\mu}\), the correspondence \(\Gamma\) is measurable. Therefore \(\mathfrak S(\mathcal{M},\mathcal{A},\beta)\) is a shield over \((S,A)\). ◻
For any RMDP \(\mathcal{M}_R=\langle S,A,\mathcal{P},s_\text{init},AP,L \rangle\) with \(A\colon S\to 2^{\mathsf A}\) and monitor observation map \(\alpha\), we say that a shield \(\mathfrak S=(\mathcal{D},\Gamma)\) over \((\Xi,A_\Xi)\) with \(A_{\Xi}\colon \Xi \to 2^{\mathsf A_\Xi}\) acts on \((\mathcal{M},\alpha)\) if \(\mathsf A=\mathsf A_{\Xi}\), and if \(A(s)=A_\Xi(\alpha(s))\) for all \(s\in S\).
If \(\theta\) is an adversary of the RMDP \(\mathcal{M}_R\), we denote by \(\theta^\otimes\) the canonical adversary of the product RMDP \(\mathcal{M}_R\otimes_\alpha\mathcal{D}\) induced by \(\theta\), which is defined as follows. For a product history \(\overline{h}_t\) ending in \((s,m)\), and for a product action \((a,u)\in A(s)\times U\), let \(T_{m,u}\colon S\to S\times M\) be defined by \[T_{m,u}(s') = \bigl(s',\zeta(m,\alpha(s'),u)\bigr).\] Then \[\theta^\otimes_t(\overline{h}_t,(a,u)) = \theta_t(\overline{h}_t^\downarrow,a)\circ T_{m,u}^{-1}.\] A distribution \(\rho\in\Delta(\mathsf A\times U)\) is compliant with \(\mathfrak S\) at a product history \(\overline{h}_t\) ending in \((s,m)\) if \[\rho\in\Gamma(\alpha(s),m).\]
Let \(\overline{\pi}\) be an HR policy on \(\mathcal{M}_R\otimes_\alpha\mathcal{D}\). We say that \(\overline{\pi}\) is compliant with \(\mathfrak S\) up to time \(t\) under the adversary \(\theta\) of \(\mathcal{M}_R\) if \[\mathrm{prob}_{(\mathcal{M}_R\otimes_\alpha\mathcal{D})[\theta^\otimes],\overline{\pi}} \left[ \forall k<t,\; \overline{\pi}(\cdot\mid\overline{H}_k) \in \Gamma(\alpha(S_k),M_k) \right] = 1,\] where \(\overline{H}_k\) is the product history up to time \(k\), and \((S_k,M_k)\) is its last product state.
We say that \(\overline{\pi}\) is compliant with \(\mathfrak S\) up to time \(t\) if it is compliant up to time \(t\) under every adversary \(\theta\) of the base RMDP \(\mathcal{M}_R\). Finally, \(\overline{\pi}\) is compliant with \(\mathfrak S\) if it is compliant up to time \(t\) for every \(t\in\mathbb{N}\).
Definition 21 (Non-blocking Shield). Let \((\mathcal{D},\Gamma)\) be a shield acting on \((\mathcal{M}_R,\alpha)\), and let let \(D_\Gamma\) denote the set \(\{(\xi,m)\in\Xi\times M:\Gamma(\xi,m)\neq\emptyset\}\). The shield is \((\mathcal{D},\Gamma)\) non-blocking* over \((\mathcal{M}_R,\alpha)\) if \((\xi_\text{init},m_\text{init})\in D_\Gamma\) and if, for every \((\xi,m)\in D_\Gamma\) and every \(\rho\in\Gamma(\xi,m)\), we have \[\mathbb{E}_{(a,u)\sim\rho} \left[ \sup_{\mu\in\mathcal{P}_\alpha(\xi,a)} \mu\!\left( \left\{ \xi'\in\Xi: (\xi',\zeta(m,\xi',u))\notin D_\Gamma \right\} \right) \right] =0.\]*
We use the following concatenation notation for history-dependent randomized policies. Let \(t\in\mathbb{N}\), and let \(\overline{\pi}^-\) and \(\overline{\pi}^+\) be policies on \(\mathcal{M}_R\otimes_\alpha\mathcal{D}\). We define \(\overline{\pi}^-\star_t\overline{\pi}^+\) as the policy that follows \(\overline{\pi}^-\) for the first \(t\) decision times and then follows \(\overline{\pi}^+\). Formally, for every augmented history \(\overline{h}_k\) of length \(k\), \[(\overline{\pi}^-\star_t\overline{\pi}^+)(\cdot\mid \overline{h}_k) = \begin{cases} \overline{\pi}^-(\cdot\mid \overline{h}_k), & k<t,\\[1mm] \overline{\pi}^+(\cdot\mid \overline{h}_k), & k\ge t. \end{cases}\]
Similarly, if \(\overline{\theta}^-\) and \(\overline{\theta}^+\) are adversaries of \(\mathcal{M}_R\otimes_\alpha\mathcal{D}\), we write \(\overline{\theta}^-\star_t\overline{\theta}^+\) for the adversary defined by \[(\overline{\theta}^-\star_t\overline{\theta}^+)_k (\overline{h}_k,\overline{a}) = \begin{cases} \overline{\theta}^-_k(\overline{h}_k,\overline{a}), & k<t,\\ \overline{\theta}^+_k(\overline{h}_k,\overline{a}), & k\ge t. \end{cases}\]
Definition 22 (Realizable Shield, extension of 9). A shield \(\mathfrak S=(\mathcal{D},\Gamma)\) acting on \((\mathcal{M}_R,\alpha)\) is realizable* over \((\mathcal{M}_R,\alpha)\) if, for every \(t\in\mathbb{N}\), every adversary \(\overline{\theta}^-\) of \(\mathcal{M}_R\otimes_\alpha\mathcal{D}\), and every policy \(\overline{\pi}^-\) compliant with \(\mathfrak S\) up to time \(t\) under \(\overline{\theta}^-\), there exists a continuation policy \(\overline{\pi}^+\) such that, for every adversary \(\overline{\theta}^+\), the concatenated policy \(\overline{\pi}^-\star_t \overline{\pi}^+\) is compliant with \(\mathfrak S\) under the concatenated adversary \(\overline{\theta}^-\star_t \overline{\theta}^+\).*
Lemma 3 (Non-blocking shields are realizable). Every nonblocking shield is realizable.
Proof. Let \(\mathfrak S=(\mathcal{D},\Gamma)\) be nonblocking, and let \[D_\Gamma=\{(\xi,m):\Gamma(\xi,m)\neq\emptyset\}.\] Since \(\Gamma\) is closed-valued and measurable, \(D_\Gamma\) is measurable. By the Kuratowski–Ryll-Nardzewski selection theorem, there is a measurable selector \(g\colon D_\Gamma\to\Delta(\mathsf A\times U)\) such that \(g(\xi,m)\in\Gamma(\xi,m)\) for every \((\xi,m)\in D_\Gamma\). Fix \(t\in\mathbb{N}\), an adversary \(\overline{\theta}^-\), and a policy \(\overline{\pi}^-\) compliant up to time \(t\) under \(\overline{\theta}^-\). We first show that \((\alpha(s_t),m_t)\in D_\Gamma\) almost surely. This follows by induction on \(k\le t\). At \(k=0\), since the shield is non-blocking, \((\alpha(s_\text{init}),m_\text{init})\in D_\Gamma\). For the induction step, if \((\alpha(s_k),m_k)\in D_\Gamma\) almost surely and \(k<t\), compliance gives that the action distribution used at time \(k\) belongs to \(\Gamma(\alpha(s_k),m_k)\) almost surely. Since the shield is non-blocking, any such distribution keeps the next abstract-monitor state in \(D_\Gamma\) with conditional probability one, for every admissible adversarial transition. Thus \((\alpha(s_{k+1}),m_{k+1})\in D_\Gamma\) almost surely.
Now define a memoryless randomized continuation policy \(\overline{\pi}^+\) by \[\overline{\pi}^+(s,m) = \begin{cases} g(\alpha(s),m), & \text{if }(\alpha(s),m)\in D_\Gamma,\\ \rho_0(s,m), & \text{otherwise,} \end{cases}\] where \(\rho_0(s,m)\) is any measurable valid distribution supported on \(A(s)\times U\). The value outside \(D_\Gamma\) is irrelevant after a compliant prefix.
Let \(\overline{\theta}^+\) be any adversary continuation. Under \(\overline{\theta}^-\star_t\overline{\theta}^+\), the process is in \(D_\Gamma\) at time \(t\) almost surely. From then on, whenever the process is in \(D_\Gamma\), the continuation chooses \(g(\alpha(s),m)\in\Gamma(\alpha(s),m)\). Since the shield is non-blocking, the next abstract-monitor state remains in \(D_\Gamma\) almost surely, independently of the future adversary. Inducting over all future times, the concatenated policy \(\overline{\pi}^-\star_t\overline{\pi}^+\) is compliant under \(\overline{\theta}^-\star_t\overline{\theta}^+\). Since \(\overline{\theta}^+\) was arbitrary, the shield is realizable. ◻
Given a history \(\overline{h}_t=((s_0,m_0),(a_0,u_0),\dots,(a_{t-1},u_{t-1}),(s_t,m_t))\) of \(\mathcal{M}_R\otimes_{\alpha} \mathcal{D}\), its projection onto \(\mathcal{M}_R\) is the history \(\overline{h}_t^{\downarrow}=(s_0,a_0,s_1,a_1,\dots,s_{t-1},a_{t-1},s_t)\).
Definition 23 (Projected policy). Let \(\mathcal{M}_R\) be an RMDP, let \(\alpha\colon S\to\Xi\) be a monitor observation map, let \(\mathcal{D}\) be a controllable monitor over \(\Xi\), and let \(\overline{\pi}\) be a policy on \(\mathcal{M}_R\otimes_\alpha\mathcal{D}\). For every adversary \(\theta\) of the transition uncertainty of \(\mathcal{M}_R\), we denote by \(\overline{\pi}^{\downarrow,\theta}\) the projection of \(\overline{\pi}\) onto \(\mathcal{M}_R\) under \(\theta\), defined as follows:
For every projected history \(h\), let \(\nu_t^\theta(\cdot\mid h)\) be the conditional distribution of the augmented histories \(\overline{H}\) given \(\overline{H}^\downarrow=h\), as induced by the policy \(\overline{\pi}\) in the \((\mathcal{M}_R\otimes_\alpha \mathcal{D})[\theta^\otimes]\). The projection of \(\overline{\pi}\) onto \(\mathcal{M}_R\) under \(\theta\)* is the policy \(\overline{\pi}^{\downarrow,\theta}\) defined by \[\overline{\pi}^{\downarrow,\theta}(E\mid h) = \int \overline{\pi}(E\times U\mid \overline{h})\, \nu_t^\theta(d\overline{h}\mid h)\] for every measurable \(E\subseteq\mathsf A\).*
For two policies \(\pi\) and \(\pi'\) on an RMDP \(\mathcal{M}_R\), and for an adversary \(\theta\) of \(\mathcal{M}_R\), we write \(\pi\equiv_{\theta}\pi'\) if they induce the same probability measure on infinite state-action paths under \(\theta\), \(\mathrm{prob}_{\mathcal{M}_R[\theta],\pi} = \mathrm{prob}_{\mathcal{M}_R[\theta],\pi'}\).
Lemma 4 (Adversary-independent projection). Let \(\mathcal{M}_R\) be an RMDP, let \(\alpha\colon S\to\Xi\) be a monitor observation map, let \(\mathcal{D}\) be a controllable monitor over \(\Xi\), and let \(\overline{\pi}\) be an HR policy on \(\mathcal{M}_R\otimes_\alpha\mathcal{D}\). Then there exists an HR policy \(\overline{\pi}^\downarrow\) on \(\mathcal{M}_R\) such that, for every adversary \(\theta\) of \(\mathcal{M}_R\), for every \(t\in\mathbb{N}\), \[\overline{\pi}^{\downarrow,\theta}\equiv_\theta\overline{\pi}^\downarrow\]
Proof. We construct a common version of the projection. For each \(t\), define a kernel \[\nu_t(\cdot\mid h)\colon H_t\to\Delta(\overline{H}_t)\] which will serve as a conditional law of augmented histories given their projection, independently of the adversary. This kernel is defined as follows:
At time \(0\), set \(\nu_0(\cdot\mid s_0)=\mathrm{Dirac}\left((s_0,m_\text{init})\right).\) Assume that \(\nu_t\) has been constructed. Fix a projected history \(h_t=s_0a_0\cdots a_{t-1}s_t\). Draw \(\overline{h}_t\sim\nu_t(\cdot\mid h_t)\), and then draw a product action \((a,u)\sim\overline{\pi}(\cdot\mid\overline{h}_t)\). Since the spaces are standard Borel, there exists a regular conditional distribution \(R_t(d\overline{h}_t,du\mid h_t,a)\) of \((\overline{h}_t,u)\) given the observed base action \(a\).
For \(h_{t+1}=h_ta_ts_{t+1}\), define \[\Phi_{a_t,s_{t+1}}(\overline{h}_t,u) = \overline{h}_t\,(a_t,u)\, \bigl(s_{t+1},\zeta(m_t,\alpha(s_{t+1}),u)\bigr),\] where \(m_t\) is the monitor component of the last state of \(\overline{h}_t\). Then set \[\nu_{t+1}(\cdot\mid h_ta_ts_{t+1}) = R_t(\cdot\mid h_t,a_t)\circ \Phi_{a_t,s_{t+1}}^{-1}.\] On histories where the conditional distribution is not uniquely determined, choose an arbitrary version.
We claim that, for every adversary \(\theta\) of \(\mathcal{M}_R\), the kernel \(\nu_t\) is a version of the conditional law of \(\overline{H}_t\) given \(\overline{H}_t^\downarrow\) under \((\mathcal{M}_R\otimes_\alpha\mathcal{D})[\theta^\otimes]\) and \(\overline{\pi}\). We prove this by induction on \(t\). The case \(t=0\) is immediate. For the induction step, under the canonical product adversary, after an augmented history \(\overline{h}_t\) with projection \(h_t\), and after a product action \((a_t,u_t)\), the next concrete state is sampled from \(\theta_t(h_t,a_t)\). This distribution depends only on the projected history \(h_t\) and the base action \(a_t\), not on the hidden augmented history \(\overline{h}_t\) nor on the auxiliary action \(u_t\). Therefore, after conditioning on the projected next history \(h_ta_ts_{t+1}\), the hidden part is obtained by conditioning \((\overline{h}_t,u_t)\) on the observed base action \(a_t\), and then applying the deterministic monitor update. This is exactly the recursive definition of \(\nu_{t+1}\).
Now define the HR policy \(\overline{\pi}^\downarrow\) on \(\mathcal{M}_R\) by \[\overline{\pi}^\downarrow(E\mid h) = \int \overline{\pi}(E\times U\mid\overline{h})\, \nu_t(d\overline{h}\mid h), \qquad h\in H_t.\] For every adversary \(\theta\), the kernel \(\nu_t\) is a version of the conditional law used in the definition of \(\overline{\pi}^{\downarrow,\theta}\). Hence, for every \(t\), \[\overline{\pi}^{\downarrow,\theta}(\cdot\mid H_t) = \overline{\pi}^\downarrow(\cdot\mid H_t) \qquad \mathrm{prob}_{\mathcal{M}_R[\theta],\overline{\pi}^\downarrow}\text{-a.s.}\] Therefore, the two policies induce the same state-action path measure under \(\theta\), \[\overline{\pi}^{\downarrow,\theta}\equiv_\theta\overline{\pi}^\downarrow,\] which concludes the proof. ◻
Definition 24 (Shield soundness, extension of 10). Let \(\Phi\) be a specification, let \(\mathcal{M}_R\) be an RMDP equipped with a monitor observation map \(\alpha\). A shield \(\mathfrak S=(\mathcal{D},\Gamma)\) acting on \((\mathcal{M}_R,\alpha)\) is sound* over \((\mathcal{M}_R,\alpha)\) for \(\Phi\) if, for every policy \(\overline{\pi}\) on \(\mathcal{M}_R\otimes_\alpha\mathcal{D}\) compliant with \(\mathfrak S\), we have \(\mathcal{M}_R,\,\overline{\pi}^{\downarrow}\models \Phi\).*
For two policies \(\pi\) and \(\pi'\) on an RMDP \(\mathcal{M}_R\), we write \(\pi\equiv\pi'\) if, for every adversary \(\theta\) of \(\mathcal{M}_R\), \(\pi\equiv_{\theta}\pi'\).
Definition 25 (Shield completeness). Let \(\Phi\) be a specification and let \(\mathcal{M}_R\) be an RMDP equipped with a monitor observation map \(\alpha\). Let \(\mathcal{C}\subseteq \mathrm{HR}\) be a class of policies. A shield \(\mathfrak S=(\mathcal{D},\Gamma)\) acting on \((\mathcal{M}_R,\alpha)\) is \(\mathcal{C}\)-complete* over \((\mathcal{M}_R,\alpha)\) for \(\Phi\) if, for every policy \(\pi\in\mathcal{C}\) of \(\mathcal{M}_R\) such that \(\mathcal{M}_R,\pi\models\Phi\), there exists an HR policy \(\overline{\pi}\) of \(\mathcal{M}_R\otimes_\alpha\mathcal{D}\) compliant with \(\mathfrak S\) such that \(\pi\equiv\overline{\pi}^{\downarrow}\).*
For any two measures \(\mu,\nu\) over a measurable space \((X,\mathcal{F})\), we denote by \(\mathrm{TV}(\mu,\nu)\) their total variation distance, \(\mathrm{TV}(\mu,\nu) = \sup_{A\in\mathcal{F}} |\mu(A)-\nu(A)|\).
For any standard Borel spaces of states \(S\) and actions \(A\), for any \(\gamma\in(0,1)\), we let \(\Omega=(SA)^{\omega}\) equipped with the \(\sigma\)-algebra \(\mathcal{F}_\Omega\) generated by cylinder sets. The discounted Hamming distance on \(\Omega\) is the distance \(d_{\gamma}\) such that, for any two words \(h=s_0a_0s_1a_1\cdots\) and \(h'=s'_0a'_0s'_1a'_1\cdots\), we have \[d_\gamma(h,h') = (1-\gamma)\sum_{t=0}^{\infty}\gamma^t \mathbf{1}\!\left\{(s_t,a_t)\neq (s_t',a_t')\right\}.\]
The discounted Hamming distance is a metric on \(\Omega\), and it satisfies \(0\le d_\gamma(h,h')\le 1\). Given two probability measures \(\mu,\nu\) on \(\Omega\), a coupling of \(\mu\) and \(\nu\) is a probability measure \(\xi\) on \(\Omega\times\Omega\) whose first marginal is \(\mu\) and second marginal is \(\nu\). We denote by \(\Gamma(\mu,\nu)\) the set of all such couplings. We define the \(1\)-Wasserstein distance associated to \(d_{\gamma}\) as the distance \(W_{1,\gamma}\) on \(\Delta(\Omega,\mathcal{F}_\Omega)\) such that \[W_{1,\gamma}(\mu,\nu) = \inf_{\xi\in\Gamma(\mu,\nu)} \int_{\Omega\times\Omega} d_\gamma(h,h')\,\xi(dh,dh').\]
Lemma 5. For all probability measures \(\mu,\nu\) on \((\Omega,\mathcal{F}_{\Omega})\), it holds that \(W_{1,\gamma}(\mu,\nu)\le \mathrm{TV}(\mu,\nu).\)
Proof. Recall that the total variation distance admits the coupling characterization \[\mathrm{TV}(\mu,\nu) = \inf_{\xi\in\Gamma(\mu,\nu)} \xi(\omega\neq\omega').\] A coupling \(\xi^\star\in\Gamma(\mu,\nu)\) is called maximal if it attains this infimum, if \(\xi^\star(\omega\neq\omega')=\mathrm{TV}(\mu,\nu).\) Let \(\xi\in\Gamma(\mu,\nu)\) be a maximal coupling, so that \(\xi\bigl(\{(\omega,\omega')\in\Omega\times\Omega:\omega\neq\omega'\}\bigr) = \mathrm{TV}(\mu,\nu).\) Then, since \(d_\gamma\) is bounded by \(1\), we have \[\int d_\gamma(\omega,\omega')\,\xi(d\omega,d\omega') \le \xi(\omega\neq\omega') = \mathrm{TV}(\mu,\nu).\] Taking the infimum over all couplings yields \[W_{1,\gamma}(\mu,\nu)\le \mathrm{TV}(\mu,\nu).\] ◻
For any RMDP \(\mathcal{M}_R\), and any two policies \(\pi,\pi'\) over \(\mathcal{M}_R\), we define \[\mathrm{TV}_{\mathcal{M}_R}(\pi,\pi') = \sup_{\theta} \mathrm{TV}\!\left( \mathrm{prob}_{\mathcal{M}_R[\theta],\pi}, \mathrm{prob}_{\mathcal{M}_R[\theta],\pi'} \right),\] and, for \(\gamma\in(0,1)\), \[W_{1,\gamma}^{\mathcal{M}_R}(\pi,\pi') = \sup_{\theta} W_{1,\gamma}\!\left( \mathrm{prob}_{\mathcal{M}_R[\theta],\pi}, \mathrm{prob}_{\mathcal{M}_R[\theta],\pi'} \right),\] where the suprema range over all adversaries \(\theta\) of \(\mathcal{M}_R\).
Definition 26 (Shield approximate completeness). Let \(\Phi\) be a specification, let \(\mathcal{M}_R\) be an RMDP equipped with a monitor observation map \(\alpha\), and let \(\epsilon>0\). Let \(\mathcal{C}\subseteq\mathrm{HR}\) be a class of policies. A shield \(\mathfrak S=(\mathcal{D},\Gamma)\) acting on \((\mathcal{M}_R,\alpha)\) is \(\mathcal{C}\)-\(\epsilon\)-\(\mathrm{TV}\)-complete* (resp. \(\mathcal{C}\)-\(\epsilon\)-\(W_{1,\gamma}\)-complete) over \((\mathcal{M}_R,\alpha)\) for \(\Phi\) if, for every policy \(\pi\in\mathcal{C}\) of \(\mathcal{M}_R\) such that \(\mathcal{M}_R,\pi\models\Phi\), there exists an HR policy \(\overline{\pi}\) of \(\mathcal{M}_R\otimes_\alpha\mathcal{D}\) compliant with \(\mathfrak S\) such that \[\mathrm{TV}_{\mathcal{M}_R}\!\left(\pi,\overline{\pi}^{\downarrow} \right) \le \epsilon \text{ (resp. } W^{\mathcal{M}_R}_{1,\gamma}\!\left(\pi,\overline{\pi}^{\downarrow} \right) \le \epsilon).\]*
The notion of \(\mathcal{C}\)-completeness is equivalent to \(\mathcal{C}\)-\(0\)-\(\mathrm{TV}\)-completeness, and also to \(\mathcal{C}\)-\(0\)-\(W_{1,\gamma}\)-completeness.
Definition 27 (Shield approximate optimality, extension of 11). Let \(\Phi\) be a specification, let \(\mathcal{M}_R\) be an RMDP equipped with a monitor observation map \(\alpha\), let \(\epsilon>0\), and let \(\gamma\in(0,1]\). Let \(\mathcal{C}\subseteq \mathrm{HR}\) be a class of policies. A shield \(\mathfrak S=(\mathcal{D},\Gamma)\) acting on \((\mathcal{M}_R,\alpha)\) is \(\mathcal{C}\)-\((\epsilon,\gamma)\)-optimal* for \(\Phi\) if, for every policy \(\pi\in\mathcal{C}\) of \(\mathcal{M}_R\) such that \(\mathcal{M}_R,\pi\models\Phi\), there exists a policy \(\overline{\pi}\) of \(\mathcal{M}_R\otimes_\alpha\mathcal{D}\) compliant with \(\mathfrak S\) such that, for any adversary \(\theta\) of \(\mathcal{M}\), \[J^\gamma_{\mathcal{M}_R[\theta]}(\overline{\pi}^{\downarrow}) \ge J^\gamma_{\mathcal{M}_R[\theta]}(\pi)-\epsilon.\]*
Lemma 6. Let \(S\) be a set of states, \(A\) be a set of actions, \(\gamma\in(0,1)\), and let \(\Omega=(SA)^{\omega}\) be equipped with the \(\sigma\)-algebra \(\mathcal{F}_\Omega\) generated by cylinder sets. Suppose that \[\sup_{(s,a)\in S\times A} |R(s,a)|\le Z.\] Then, for all probability measures \(\mu,\nu\) on \(\Omega\), \[\left| \mathbb{E}_{s_0a_0\cdots \sim \mu}\left[\sum_{t=0}^{\infty}\gamma^t R(s_t,a_t)\right] - \mathbb{E}_{s_0a_0\cdots \sim \nu}\left[\sum_{t=0}^{\infty}\gamma^t R(s_t,a_t)\right] \right| \le \frac{2Z}{1-\gamma}\, W_{1,\gamma}(\mu,\nu).\]
Moreover, suppose that the absolute value of the total undiscounted return is uniformly bounded by \(B\) on \(\Omega\), \[\left|\sum_{t=0}^{\infty}R(s_t,a_t)\right|\le B \qquad\text{for all } s_0a_0s_1a_1\cdots\in\Omega.\] Then, for all probability measures \(\mu,\nu\) on \(\Omega\), \[\left| \mathbb{E}_{s_0a_0\cdots \sim \mu}\left[\sum_{t=0}^{\infty}R(s_t,a_t)\right] - \mathbb{E}_{s_0a_0\cdots \sim \nu}\left[\sum_{t=0}^{\infty}R(s_t,a_t)\right] \right| \le 2B\,\mathrm{TV}(\mu,\nu).\]
Proof. For any \(h=s_0a_0s_1a_1\cdots\), let \[G_\gamma(h)\mathrel{\vcenter{:}}=\sum_{t=0}^{\infty}\gamma^t R(s_t,a_t),\] and let \[\operatorname{span}(R)\mathrel{\vcenter{:}}= \sup_{(s,a),(s',a')\in S\times A} |R(s,a)-R(s',a')|.\] Since \(|R(s,a)|\le Z\) for all \((s,a)\), we have \[\operatorname{span}(R)\le 2Z.\]
Let \(\xi\in\Gamma(\mu,\nu)\) be any coupling. Then \[\begin{align} \left| \int G_\gamma\,d\mu - \int G_\gamma\,d\nu \right| &= \left| \int_{\Omega\times\Omega} \bigl(G_\gamma(h)-G_\gamma(h')\bigr)\,\xi(dh,dh') \right| \\ &\le \int_{\Omega\times\Omega} |G_\gamma(h)-G_\gamma(h')|\,\xi(dh,dh'). \end{align}\] Now, for \(h=s_0a_0\cdots\) and \(h'=s'_0a'_0\cdots\), \[\begin{align} |G_\gamma(h)-G_\gamma(h')| &\le \sum_{t=0}^{\infty} \gamma^t |R(s_t,a_t)-R(s_t',a_t')| \\ &\le \operatorname{span}(R) \sum_{t=0}^{\infty} \gamma^t \mathbf{1}\!\left\{(s_t,a_t)\neq (s_t',a_t')\right\} \\ &= \frac{\operatorname{span}(R)}{1-\gamma}\, d_\gamma(h,h'). \end{align}\] Hence \[\left| \int G_\gamma\,d\mu - \int G_\gamma\,d\nu \right| \le \frac{\operatorname{span}(R)}{1-\gamma} \int d_\gamma(h,h')\,\xi(dh,dh').\] Since this holds for every coupling \(\xi\in\Gamma(\mu,\nu)\), taking the infimum over \(\xi\) yields \[\left| \int G_\gamma\,d\mu - \int G_\gamma\,d\nu \right| \le \frac{\operatorname{span}(R)}{1-\gamma}\, W_{1,\gamma}(\mu,\nu) \le \frac{2Z}{1-\gamma}\, W_{1,\gamma}(\mu,\nu).\]
For the undiscounted case, define \[G_1(h)\mathrel{\vcenter{:}}=\sum_{t=0}^{\infty}R(s_t,a_t).\] By assumption, \(|G_1(h)|\le B\) for all \(h\in\Omega\), hence \[\operatorname{span}(G_1)\mathrel{\vcenter{:}}=\sup_{h,h'\in\Omega}|G_1(h)-G_1(h')|\le 2B.\] Using the standard inequality \[\left|\int f\,d\mu-\int f\,d\nu\right| \le \operatorname{span}(f)\,\mathrm{TV}(\mu,\nu)\] for bounded measurable functions \(f\), applied to \(f=G_1\), we obtain \[\left| \int G_1\,d\mu-\int G_1\,d\nu \right| \le 2B\,\mathrm{TV}(\mu,\nu). \qedhere\] ◻
Lemma 7 (Approximate completeness implies approximate optimality). Let \(\Phi\) be a specification, let \(\mathcal{M}_R\) be an RMDP equipped with a monitor observation map \(\alpha\), let \(\mathfrak S\) be a shield acting on \((\mathcal{M}_R,\alpha)\), and let \(\mathcal{C}\subseteq\mathrm{HR}\).
Suppose that \(\sup_{(s,a)\in S\times\mathsf A}|R(s,a)|\le Z\), that \(\gamma<1\), and that \(\mathfrak S\) is \(\mathcal{C}\)-\(\epsilon\)-\(W_{1,\gamma}\)-complete over \((\mathcal{M}_R,\alpha)\) for \(\Phi\). Then \(\mathfrak S\) is \[\mathcal{C}\text{-} \left(\frac{2Z\epsilon}{1-\gamma},\gamma\right)\text{-optimal}\] over \((\mathcal{M}_R,\alpha)\) for \(\Phi\).
Suppose that the absolute value of the total undiscounted return is uniformly bounded by \(B\), and that \(\mathfrak S\) is \(\mathcal{C}\)-\(\epsilon\)-\(\mathrm{TV}\)-complete over \((\mathcal{M}_R,\alpha)\) for \(\Phi\). Then \(\mathfrak S\) is \[\mathcal{C}\text{-}(2B\epsilon,1)\text{-optimal}\] over \((\mathcal{M}_R,\alpha)\) for \(\Phi\).
Proof. We prove the first item; the second is analogous. Let \(\pi\in\mathcal{C}\) be such that \(\mathcal{M}_R,\pi\models\Phi\). By \(\mathcal{C}\)-\(\epsilon\)-\(W_{1,\gamma}\)-completeness, there exists a compliant policy \(\overline{\pi}\) such that, \[W_{1,\gamma}\!\left( \mathrm{prob}_{\mathcal{M}_R[\theta],\pi}, \mathrm{prob}_{\mathcal{M}_R[\theta],\overline{\pi}^{\downarrow}} \right) \le \epsilon.\] Fix an adversary \(\theta\). Applying the previous lemma to the two path measures above yields \[\left| J^\gamma_{\mathcal{M}_R[\theta]}(\pi) - J^\gamma_{\mathcal{M}_R[\theta]}(\overline{\pi}^{\downarrow}) \right| \le \frac{2Z}{1-\gamma}\epsilon.\] Hence \[J^\gamma_{\mathcal{M}_R[\theta]}(\overline{\pi}^{\downarrow}) \ge J^\gamma_{\mathcal{M}_R[\theta]}(\pi) - \frac{2Z}{1-\gamma}\epsilon.\] Since \(\theta\) was arbitrary, \(\mathfrak S\) is \(\mathcal{C}\)-\(\left(\frac{2Z}{1-\gamma}\epsilon,\gamma\right)\)-optimal. ◻
In the rest of the section, we let \(\mathcal{M}_R\) be an RMDP equipped with a finite safety abstraction \(\alpha\colon S\to\Xi\), we let \(\langle \Xi,\mathsf A,A_\alpha,\mathcal{P}_\alpha,\xi_\text{init},AP,L_\alpha \rangle=\mathcal{M}_R/\alpha\), we let \(\Phi=\mathbb{P}_{\ge 1-p}(\varphi)\), we let \(\mathcal{A}=\langle Q,2^{AP},q_\text{init},\delta,F \rangle\) recognize the bad prefixes of \(\varphi\), and \(\beta\colon \Xi\times Q\to[0,1]\) be an \(((\mathcal{M}_R/\alpha)\otimes_{L_\alpha}\mathcal{A},\Xi\times F)\)- inductive value function such that \(\beta(\xi_\text{init},q_\text{init})\le p\).
Theorem 5 (Realizability and soundness, restatement of 1). The shield \(\mathfrak S(\mathcal{M}_R/\alpha,\mathcal{A},\beta)\) acts on \((\mathcal{M}_R,\alpha)\), is realizable over \((\mathcal{M}_R,\alpha)\), and is sound over \((\mathcal{M}_R,\alpha)\) for \(\Phi\).
Proof. Let \(\mathfrak S(\mathcal{M}_R/\alpha,\mathcal{A},\beta)=(\mathcal{D},\Gamma)\). Since \(\alpha\) is an abstraction of \(\mathcal{M}_R\), we have \(A(s)=A_\alpha(\alpha(s))\) for all \(s\in S\). Hence, the shield acts on \((\mathcal{M}_R,\alpha)\).
We first prove that the shield is nonblocking. Let \[D_\Gamma=\{(\xi,q,y):\Gamma(\xi,q,y)\neq\emptyset\}.\] We claim that \[B_\beta\mathrel{\vcenter{:}}=\{(\xi,q,y):\beta(\xi,q)\le y\}\subseteq D_\Gamma.\] Indeed, fix \((\xi,q,y)\in B_\beta\). Since \(\Xi\) and \(A_\alpha\) are finite, the infimum in the Bellman operator is attained. Hence, by inductiveness of \(\beta\), there exists \(a\in A_\alpha(\xi)\) such that \[\sup_{\mu\in\mathcal{P}_\alpha(\xi,a)} \mathbb{E}_{\xi'\sim\mu} \left[ \beta\bigl(\xi',\delta(q,L_\alpha(\xi'))\bigr) \right] \le \beta(\xi,q).\] If \(q\in F\), then \(\beta(\xi,q)=1\), and any enabled action satisfies the required bound since \(\beta\le 1\). Thus \[\mathrm{Dirac}\left(a\right)\otimes\mathrm{Dirac}\left(\beta\right)\in\Gamma(\xi,q,y),\] because \(y\ge\beta(\xi,q)\). Therefore \((\xi,q,y)\in D_\Gamma\).
Since \(\beta(\xi_\text{init},q_\text{init})\le p\), we have \((\xi_\text{init},q_\text{init},p)\in D_\Gamma\). Now let \((\xi,q,y)\in D_\Gamma\) and \(\rho\in\Gamma(\xi,q,y)\). By definition of the shield, \(\rho\) is supported on \(A_\alpha(\xi)\times\mathcal{V}_\beta\). Hence, for \(\rho\)-almost every \((a,v)\), every \(\mu\in\mathcal{P}_\alpha(\xi,a)\), and every next abstract state \(\xi'\), if \[q'=\delta(q,L_\alpha(\xi')), \qquad y'=v(\xi',q'),\] then \(y'\ge\beta(\xi',q')\), since \(v\in\mathcal{V}_\beta\). Thus \((\xi',q',y')\in B_\beta\subseteq D_\Gamma\). Therefore, every compliant one-step action distribution keeps the next abstract-monitor state in \(D_\Gamma\) with probability one under every admissible transition measure. Hence, the shield is nonblocking. By the previous lemma, it is realizable.
It remains to prove soundness. Let \(\overline{\pi}\) be an HR policy on \(\mathcal{M}_R\otimes_\alpha\mathcal{D}\) compliant with the shield, and let \(\theta\) be an adversary of \(\mathcal{M}_R\). Consider the product process under \(\overline{\pi}\) and the canonical product adversary \(\theta^\otimes\). Write \(\overline{S}_t=(S_t,Q_t,Y_t),\) and let \(\overline{\mathcal{F}}_t\) be the \(\sigma\)-algebra generated by the augmented history \(\overline{H}_t\).
By compliance, almost surely, \[\overline{\pi}(\cdot\mid \overline{H}_t) \in \Gamma(\alpha(S_t),Q_t,Y_t).\] For a realized product action \((a,v)\), the adversary chooses a measure in \(\mathcal{P}(S_t,a)\), whose pushforward by \(\alpha\) belongs to \(\mathcal{P}_\alpha(\alpha(S_t),a)\). Hence, the defining inequality of \(\Gamma\) gives \[\mathbb{E}[Y_{t+1}\mid\overline{\mathcal{F}}_t]\le Y_t.\] Thus \((Y_t)_{t\in\mathbb{N}}\) is a bounded supermartingale. Let \(\tau_F=\inf\{t\ge 0:Q_t\in F\}.\) Since \(\beta=1\) on \(\Xi\times F\), and every \(v\in\mathcal{V}_\beta\) satisfies \(v(\xi,q)\ge\beta(\xi,q)\), every reachable accepting monitor state satisfies \(Q_t\in F\Rightarrow Y_t=1\). Therefore, for every \(n\in\mathbb{N}\), \[\mathbf{1}_{\{\tau_F\le n\}}\le Y_{\tau_F\wedge n}.\] By optional stopping for bounded supermartingales, \[\Pr(\tau_F\le n) \le \mathbb{E}[Y_{\tau_F\wedge n}] \le Y_0 = p.\] Letting \(n\to\infty\), we obtain \[\Pr(\tau_F<\infty)\le p.\]
The DFA \(\mathcal{A}\) recognizes the bad prefixes of \(\varphi\), so \(\tau_F<\infty\) is exactly the event that \(\varphi\) is violated. Moreover, by construction of the projected policy, the law of paths in \(\mathcal{M}_R[\theta]\) under \(\overline{\pi}^\downarrow\) is the projection of the product path law. Since the product preserves labels, the satisfaction probability is the same under projection. Hence \[\mathcal{M}_R[\theta],\overline{\pi}^\downarrow \models \mathbb{P}_{\ge 1-p}(\varphi) = \Phi.\] Since \(\theta\) was arbitrary, we have \[\mathcal{M}_R,\overline{\pi}^\downarrow\models\Phi.\] Thus, the shield is sound. ◻
We proceed with proving the optimality results. In what follows, we let \(\beta^{\infty}\) be the lowest fixed point of \(\mathcal{B}_{(\mathcal{M}_R/\alpha)\otimes_{L_{\alpha}}\mathcal{A}}^{\Xi\times F}\). Furthermore, we say that an RMDP \(\mathcal{M}_R\) is conditionally deterministic w.r.t an abstraction \(\alpha\) if every reachable abstract history determines a unique concrete history. More precisely, for every abstract history \(\widehat h_t=\xi_0a_0\xi_1a_1\cdots a_{t-1}\xi_t\) with \(\xi_0=\alpha(s_\text{init})\), there is at most one concrete history \(h_t=s_0a_0s_1a_1\cdots a_{t-1}s_t\) such that \(s_0=s_\text{init}\), \(\alpha(s_i)=\xi_i\) for all \(i\le t\), and \(h_t\) has positive probability under some adversary of \(\mathcal{M}_R\). When such a concrete history exists, we denote its last state by \(\chi(\widehat h_t)=s_t\).
Theorem 6. Suppose that \(\beta(\xi_\text{init},q_\text{init})<p\), and that \(\mathcal{M}_R\) is conditionally deterministic w.r.t. \(\alpha\). Then the shield \(\mathfrak S(\mathcal{M}_R/\alpha,\mathcal{A},\beta)\) acts on \((\mathcal{M}_R,\alpha)\), and is \(\mathrm{HR}\)-\(\epsilon\)-TV-complete over \((\mathcal{M}_R,\alpha)\) for \(\Phi\), where \[\epsilon= \frac{\left\lVert\beta-\beta^{\infty}\right\rVert_{\infty}}{\left\lVert\beta-\beta^{\infty}\right\rVert_{\infty}+p-\beta(\xi_\text{init},q_\text{init})}.\] In particular, the shield \(\mathfrak S(\mathcal{M}_R/\alpha,\mathcal{A},\beta^{\infty})\) acts on \((\mathcal{M}_R,\alpha)\) and is \(\mathrm{HR}\)-complete over \((\mathcal{M}_R,\alpha)\) for \(\Phi\).
Proof. Since \(\alpha\) is an abstraction of \(\mathcal{M}_R\), we have \(A(s)=A_\alpha(\alpha(s))\) for all \(s\in S\), so the shield acts on \((\mathcal{M}_R,\alpha)\).
Fix an HR policy \(\pi\) of \(\mathcal{M}_R\) such that \(\mathcal{M}_R,\pi\models\Phi\). For a history \(\widetilde{h}\) of \(\mathcal{M}_R\otimes_{L}\mathcal{A}\), let \(V_\pi(\widetilde{h})\) denote the supremal probability, over all adversaries, of eventually reaching \(F\) when continuing from \(\widetilde{h}\) under \(\pi\). Since \(\pi\) satisfies \(\Phi=\mathbb{P}_{\ge 1-p}(\varphi)\), we have \(V_\pi((s_\text{init},q_\text{init}))\le p\).
Define \(\delta=\|\beta-\beta^\infty\|_\infty\) and \(V_\pi^\delta(\widetilde{h}) = \min\{1,V_\pi(\widetilde{h})+\delta\}\). For \(a\in A(s)\) and \(\xi'\in\Xi\), we write \(q_{\xi'}=\delta(q,L_\alpha(\xi'))\). We define \(z_{\widetilde{h},a}\in[0,1]^{\Xi\times Q}\) as follows. If, for any history \(\widetilde{h}=(s_0,q_0) a_0\cdots (s_n,q_n)\), denoting \(\widehat h=\alpha(s_0)a_0\cdots \alpha(s_n)\), the history \(\widehat{h}a\xi'\) is reachable in \(\mathcal{M}_R/\alpha\), then we set \[z_{\widetilde{h},a}(\xi',q_{\xi'}) = V_\pi^\delta\!\left( \widetilde{h} a\left(\chi\left({\widehat h}a\xi'\right),q_{\xi'}\right) \right).\] On entries \((\xi',q')\) with \(q'\neq q_{\xi'}\), and on unreachable abstract successors, we set \[z_{\widetilde{h},a}(\xi',q') = \min\{1,\beta^\infty(\xi',q')+\delta\}.\]
This vector belongs to \(\mathcal{V}_\beta\). Indeed, for unreachable entries and for entries not corresponding to the automaton successor, this follows immediately from \[\beta(\xi',q')\le \beta^\infty(\xi',q')+\delta \le \min\{1,\beta^\infty(\xi',q')+\delta\}.\] For the other entries, we have \[\beta^\infty(\xi',q_{\xi'}) \le V_\pi\!\left( \widetilde{h} a\left(\chi\left({\widehat h} a\xi'\right),q_{\xi'}\right) \right),\] and therefore \[\beta(\xi',q_{\xi'}) \le \min\{1,\beta^\infty(\xi',q_{\xi'})+\delta\} \le z_{\widetilde{h},a}(\xi',q_{\xi'}).\] Hence \(z_{\widetilde{h},a}\in\mathcal{V}_\beta\).
Define an HR policy \(\overline{\pi}^0\) on \(\mathcal{M}_R\otimes_\alpha\mathcal{D}\) as follows. For an augmented history \(\overline{h}\), let \(\widetilde{h}\) be its associated history in \(\mathcal{M}_R\otimes\mathcal{A}\). Then \(\overline{\pi}^0(\cdot\mid\overline{h})\) is the pushforward of \(\pi(\cdot\mid\overline{h}^\downarrow)\) by \(a\mapsto (a,z_{\widetilde{h},a})\). Thus, if \(\overline{\pi}^0\) is followed at all histories, then \[(\overline{\pi}^0)^\downarrow\equiv\pi.\]
We also define a safe HR policy \(\overline{\pi}_{\text{safe}}\). For every \((\xi,q)\), choose a distribution \(\mu_{\xi,q}\) over \(A_\alpha(\xi)\) witnessing the inductiveness of \(\beta\), namely \[\mathbb{E}_{a\sim\mu_{\xi,q}} \left[ \sup_{\lambda\in\mathcal{P}_\alpha(\xi,a)} \mathbb{E}_{\xi'\sim\lambda} \left[ \beta\bigl(\xi',\delta(q,L_\alpha(\xi'))\bigr) \right] \right] \le \beta(\xi,q).\] For an augmented history ending in \((s,q,y)\), set \[\overline{\pi}_{\text{safe}}(\cdot\mid\overline{h}) = \mu_{\alpha(s),q}\otimes\mathrm{Dirac}\left(\beta\right).\] Whenever \(y\ge\beta(\alpha(s),q)\), this distribution belongs to \(\Gamma(\alpha(s),q,y)\). Let \(\epsilon= \frac{\delta}{\delta+p-\beta(\xi_\text{init},q_\text{init})}.\) and define the shielded HR policy \(\overline{\pi}^\epsilon\) as follows:
At the initial history, set \(\overline{\pi}^\epsilon = (1-\epsilon)\overline{\pi}^0+\epsilon\overline{\pi}_{\text{safe}}.\)
At any non-initial augmented history \(\overline{h}\) ending in \((s,q,y)\), with projection \(\widetilde{h}\), set \[\overline{\pi}^\epsilon(\cdot\mid\overline{h}) = \begin{cases} \overline{\pi}^0(\cdot\mid\overline{h}), &\text{if } y\ge V_\pi^\delta(\widetilde{h}),\\[1mm] \overline{\pi}_{\text{safe}}(\cdot\mid\overline{h}), &\text{otherwise.} \end{cases}\]
We show that \(\overline{\pi}^\epsilon\) is compliant. At the initial state, the expected next \(y\)-value under \(\overline{\pi}^0\) is at most \(p+\delta\), while under \(\overline{\pi}_{\text{safe}}\) it is at most \(\beta(\xi_\text{init},q_\text{init})\). Hence \((1-\epsilon)(p+\delta) +\epsilon\beta(\xi_\text{init},q_\text{init}) = p,\) so the initial action distribution is compliant.
Moreover, along every reachable history we have \(y\ge\beta(\alpha(s),q)\), because both auxiliary vectors \(z_{\widetilde{h},a}\) and \(\beta\) belong to \(\mathcal{V}_\beta\). Thus, if the policy chooses \(\overline{\pi}_{\text{safe}}\), it is compliant. If the policy chooses \(\overline{\pi}^0\), then by definition \(y\ge V_\pi^\delta(\widetilde{h})\). We show that the shield constraint is satisfied. Let \(\widehat h\) be the abstract history of \(\mathcal{M}_R/\alpha\) associated to \(\widetilde{h}\), and let \(\xi=\alpha(s)\). For a chosen base action \(a\), let \(\Xi_{t+1}\) denote the next abstract state. Under the augmented action \((a,z_{\widetilde{h},a})\), the next budget coordinate is \[Y_{t+1} = z_{\widetilde{h},a} \bigl( \Xi_{t+1}, \delta(q,L_\alpha(\Xi_{t+1})) \bigr).\] Fix \(a\in A(s)\) and \(\lambda\in\mathcal{P}_\alpha(\xi,a)\). By the definition of the quotient RMDP, there exists \(\mu\in\mathcal{P}(s,a)\) such that \(\lambda=\mu\circ\alpha^{-1}\). Moreover, since \(\mathcal{M}_R\) is conditionally deterministic with respect to \(\alpha\), for every abstract successor \(\xi'\) in the support of \(\lambda\), the corresponding concrete successor is uniquely given by \(\chi(\widehat h a\xi')\). Therefore, \[\mathbb{E}_{\xi'\sim\lambda} \left[ z_{\widetilde{h},a}\bigl(\xi', \delta(q,L_\alpha(\xi'))\bigr) \right] \le \delta + \mathbb{E}_{s'\sim\mu} \left[ V_\pi\bigl(\widetilde{h} a(s', \delta(q,L(s')))\bigr) \right].\] Taking the supremum over \(\lambda\in\mathcal{P}_\alpha(\xi,a)\), we obtain \[\sup_{\lambda\in\mathcal{P}_\alpha(\xi,a)} \mathbb{E}_{\xi'\sim\lambda} \left[ z_{\widetilde{h},a}\bigl(\xi', \delta(q,L_\alpha(\xi'))\bigr) \right] \le \delta + \sup_{\mu\in\mathcal{P}(s,a)} \mathbb{E}_{s'\sim\mu} \left[ V_\pi\bigl(\widetilde{h} a(s', \delta(q,L(s')))\bigr) \right].\] Averaging over \(a\sim\pi(\cdot\mid\widetilde{h}^\downarrow)\) and using the dynamic programming inequality for \(V_\pi\), we get \[\mathbb{E}[Y_{t+1}\mid\overline{h},\overline{\pi}^0] \le V_\pi(\widetilde{h})+\delta.\] Since \(Y_{t+1}\in[0,1]\), this also implies \[\mathbb{E}[Y_{t+1}\mid\overline{h},\overline{\pi}^0] \le \min\{1,V_\pi(\widetilde{h})+\delta\} = V_\pi^\delta(\widetilde{h}) \le y.\] Hence the shield constraint is satisfied. Hence \(\overline{\pi}^\epsilon(\cdot\mid\overline{h})\in \Gamma(\alpha(s),q,y)\). Therefore \(\overline{\pi}^\epsilon\) is compliant.
It remains to bound the TV distance. Fix an adversary \(\theta\) of \(\mathcal{M}_R\). Couple the run of \(\pi\) and the projected run of \(\overline{\pi}^\epsilon\) as follows. At the initial decision, with probability \(1-\epsilon\), use the \(\overline{\pi}^0\)-component and couple the base action with the action sampled by \(\pi\); with probability \(\epsilon\), use the safe component. On the first event, the projected history agrees with the run of \(\pi\), the invariant \(y\ge V_\pi^\delta(\widetilde{h})\) ensures that \(\overline{\pi}^\epsilon\) keeps choosing \(\overline{\pi}^0\) forever. Indeed, whenever \(\overline{\pi}^0\) is used and the next abstract successor is \(\xi'\), the next budget is \[y' = z_{\widetilde{h},a}\bigl(\xi', \delta(q,L_\alpha(\xi'))\bigr) = V_\pi^\delta\!\left( \widetilde{h} a(\chi(\widehat h a\xi'), \delta(q,L_\alpha(\xi'))) \right),\] so the invariant is preserved along the coupled run. Thus the two projected paths agree on an event of probability at least \(1-\epsilon\). Consequently, \[\mathrm{TV}\!\left( \mathrm{prob}_{\mathcal{M}_R[\theta],\pi}, \mathrm{prob}_{\mathcal{M}_R[\theta],(\overline{\pi}^\epsilon)^\downarrow} \right) \le \epsilon .\] Since \(\theta\) was arbitrary, we obtain \[\mathrm{TV}_{\mathcal{M}_R}\!\left( \pi,(\overline{\pi}^\epsilon)^\downarrow \right) \le \epsilon.\] Therefore, the shield is \(\mathrm{HR}\)-\(\epsilon\)-TV-complete.
If \(\beta=\beta^\infty\), then \(\delta=0\), hence \(\epsilon=0\). The same construction gives a compliant policy \(\overline{\pi}^0\) whose projection is equivalent to \(\pi\). Therefore, the shield is \(\mathrm{HR}\)-complete. ◻
Notice that by Lemma 5, the above theorem implies that the shield \(\mathfrak S(\mathcal{M}_R/\alpha,\mathcal{A},\beta)\) is \(\mathrm{HR}\)-\(\epsilon\)-\(W_{1,\gamma}\)-complete over \((\mathcal{M}_R,\alpha)\) for \(\Phi\) as well.
By Lemma 7, we have the following.
Theorem 7 (Approximate optimality of the shield, extension of 2). Suppose that \(\beta(\xi_\text{init},q_\text{init})<p\), that \(\mathcal{M}_R\) is conditionally deterministic w.r.t. \(\alpha\), and let \[\epsilon= \frac{\|\beta-\beta^{\infty}\|_\infty}{\|\beta-\beta^{\infty}\|_\infty+p-\beta(\xi_\text{init},q_\text{init})}.\] Then the two following properties hold.
If the absolute value of the total undiscounted return is uniformly bounded by \(B\), then \(\mathfrak S(\mathcal{M}_R/\alpha,\mathcal{A},\beta)\) is \[\mathrm{HR}\text{-}(2B\epsilon,1)\text{-optimal}\] over \((\mathcal{M}_R,\alpha)\) for \(\Phi\).
If \(\gamma\in(0,1)\) and \(\sup_{(s,a)\in S\times\mathsf A}|R(s,a)|\le Z\), then \(\mathfrak S(\mathcal{M}_R/\alpha,\mathcal{A},\beta)\) is \[\mathrm{HR}\text{-} \left(\frac{2Z\epsilon}{1-\gamma},\gamma\right)\text{-optimal}\] over \((\mathcal{M}_R,\alpha)\) for \(\Phi\).
In particular, the shield \(\mathfrak S(\mathcal{M}_R/\alpha,\mathcal{A},\beta^\infty)\) is \(\mathrm{HR}\)-\((0,\gamma)\)-optimal for every \(\gamma\in(0,1]\) for which the corresponding return is well-defined.
In this appendix, we present all extended definitions, results, and proofs for our shielding approach for unknown MDPs, learned as RMDP from 4.
Throughout, we suppose that \(\mathcal{M}=\langle S,A,P,s_\text{init},AP,L,R \rangle\) is an MDP equipped with a finite abstraction \(\alpha\colon S\to\Xi\), we let \(\mathcal{M}/\alpha = \langle \Xi,A_\alpha,P_\alpha,\xi_\text{init},AP,L_\alpha \rangle\) by its quotient, we suppose that \(\Phi=\mathbb{P}_{\geq 1-p}(\varphi)\) is a probabilistic safety LTL formula, that \(\mathcal{A}=\langle Q,2^{AP},q_\text{init},\delta,F \rangle\) is a DFA recognizing the bad prefixes of \(\varphi\), and that \(\widehat{\mathcal{M}}=(\Xi,A_\alpha,\widehat{\mathcal{P}},\xi_\text{init},AP,L_\alpha,R_\alpha)\) is an RMDP with \(P_\alpha\in \widehat{\mathcal{P}}\). Furthermore, we suppose that \(\widehat \beta\) is an \((\widehat{\mathcal{M}}\otimes_{L_\alpha}\mathcal{A},\Xi\times F)\)-inductive value function such that \(\widehat\beta(\xi_\text{init},q_\text{init})\leq p\).
We first prove the soundness result from 3.
Definition 28 (Conditional concrete lift of the learned RMDP). For every \(\xi\in\Xi\), let \(C_\xi=\alpha^{-1}(\xi)\). Since \(\Xi\) is finite and \(\alpha\) is surjective, fix one representative \(r_\xi\in C_\xi\).
For every \((s,a)\in\operatorname{Gr}(A)\) and every \(\xi'\in\Xi\), define a probability measure \(K_{s,a}^{\xi'}\in\Delta(S)\) by \[K_{s,a}^{\xi'}(B) = \begin{cases} \displaystyle \frac{P(s,a)(B\cap C_{\xi'})}{P_\alpha(\alpha(s),a)(\xi')}, & \text{if }P_\alpha(\alpha(s),a)(\xi')>0,\\[3mm] \mathrm{Dirac}\left(r_{\xi'}\right)(B), & \text{if }P_\alpha(\alpha(s),a)(\xi')=0, \end{cases}\] for every measurable \(B\subseteq S\). Thus \(K_{s,a}^{\xi'}\) is the conditional distribution of the next concrete state inside the abstraction cell \(C_{\xi'}\), with an arbitrary choice when that cell has zero probability under the true transition.
For \(\widehat\mu\in\Delta(\Xi)\), define \[\Lambda_{s,a}(\widehat\mu) = \sum_{\xi'\in\Xi} \widehat\mu(\xi')K_{s,a}^{\xi'}.\] The conditional concrete lift* of \(\widehat{\mathcal{M}}\) is the RMDP \(\widetilde{\mathcal{M}} = \langle S,A,\widetilde{\mathcal{P}},s_\text{init},AP,L,R \rangle,\) where \[\widetilde{\mathcal{P}}(s,a) = \left\{ \Lambda_{s,a}(\widehat\mu): \widehat\mu\in\widehat{\mathcal{P}}(\alpha(s),a) \right\}.\]*
Lemma 8. The map \(\alpha:S\to\Xi\) is an abstraction of \(\widetilde{\mathcal{M}}\), and \(\widetilde{\mathcal{M}}/\alpha=\widehat{\mathcal{M}}.\) Moreover, there exists an adversary \(\theta^P\) of \(\widetilde{\mathcal{M}}\) such that \(\mathcal{M}=\widetilde{\mathcal{M}}[\theta^P].\)
Proof. The action and label conditions follow from the fact that \(\alpha\) is an abstraction of the true MDP.
We first identify the quotient transition correspondence. Fix \((s,a)\in\operatorname{Gr}(A)\), and write \(\xi=\alpha(s)\). For every \(\widehat\mu\in\widehat{\mathcal{P}}(\xi,a)\), we have \[\Lambda_{s,a}(\widehat\mu)\circ\alpha^{-1} = \widehat\mu.\] Indeed, each \(K_{s,a}^{\xi'}\) is supported on \(C_{\xi'}\), and therefore \[K_{s,a}^{\xi'}(\alpha^{-1}(\xi'')) = \mathbf{1}_{\{\xi'=\xi''\}},\] which implies that \[\{\mu\circ\alpha^{-1}:\mu\in\widetilde{\mathcal{P}}(s,a)\} = \widehat{\mathcal{P}}(\alpha(s),a).\] This set depends only on \(\alpha(s)\) and \(a\). Therefore \(\alpha\) is an abstraction of \(\widetilde{\mathcal{M}}\), and its quotient transition correspondence is exactly \(\widehat{\mathcal{P}}\). Thus \[\widetilde{\mathcal{M}}/\alpha=\widehat{\mathcal{M}}.\]
It remains to show that the true MDP is induced in \(\widetilde{\mathcal{M}}\) by an adversary. For every \((s,a)\), we have \[P(s,a) = \Lambda_{s,a}\bigl(P_\alpha(\alpha(s),a)\bigr).\] Indeed, for every measurable \(B\subseteq S\), \[\Lambda_{s,a}\bigl(P_\alpha(\alpha(s),a)\bigr)(B) = \sum_{\xi'\in\Xi} P_\alpha(\alpha(s),a)(\xi')K_{s,a}^{\xi'}(B).\] The terms with \(P_\alpha(\alpha(s),a)(\xi')=0\) vanish, and the remaining terms give \[\sum_{\xi'\in\Xi}P(s,a)(B\cap C_{\xi'}) = P(s,a)(B).\] Since \(P_\alpha(\alpha(s),a)\in\widehat{\mathcal{P}}(\alpha(s),a),\) we obtain \(P(s,a)\in\widetilde{\mathcal{P}}(s,a).\) Thus \(\mathcal{M}\) is induced by the adversary \(\theta^P\) that always selects the transition \(P(s,a)\).
Finally, the measurability of the lifted uncertainty correspondence follows from the measurability of \(\widehat{\mathcal{P}}\) and of the map \((s,a,\widehat\mu)\mapsto\Lambda_{s,a}(\widehat\mu)\). Since \(\Lambda_{s,a}(\widehat\mu)\circ\alpha^{-1}=\widehat\mu\), the relevant graph map is injective, so the image of the measurable graph of \(\widehat{\mathcal{P}}\) is measurable. ◻
Theorem 8 (Restatement of 3). The shield \(\mathfrak S(\widehat{\mathcal{M}},\mathcal{A},\widehat\beta)\) acts on \((\mathcal{M},\alpha)\), is nonblocking over \((\mathcal{M},\alpha)\), and is sound over \((\mathcal{M},\alpha)\) for \(\Phi\).
Proof. Let \(\widetilde{\mathcal{M}}\) be the concrete lift defined above. By the Lemma 8, \(\widetilde{\mathcal{M}}/\alpha=\widehat{\mathcal{M}}\). Therefore \[\mathfrak S(\widehat{\mathcal{M}},\mathcal{A},\widehat\beta) = \mathfrak S(\widetilde{\mathcal{M}}/\alpha,\mathcal{A},\widehat\beta).\] Applying Theorem 5 to \(\widetilde{\mathcal{M}}\), the shield acts on \((\widetilde{\mathcal{M}},\alpha)\), is nonblocking, and is sound over \((\widetilde{\mathcal{M}},\alpha)\).
Since the true MDP \(\mathcal{M}\) is induced by an adversary in \(\widetilde{\mathcal{M}}\), the non-blocking condition for all transitions in \(\widetilde{\mathcal{P}}\) implies the non-blocking condition for the true transition \(P\). Hence the shield is non-blocking over \((\mathcal{M},\alpha)\).
For soundness, let \(\overline{\pi}\) be a compliant policy on \(\mathcal{M}\otimes_\alpha\mathcal{D}\). We redefine \(\overline{\pi}\) arbitrarily on histories that are null under the true MDP, choosing a measurable compliant selector on \(D_\Gamma\). This modification does not change the induced path law under the true MDP, and it is compliant for the lifted RMDP. Applying soundness over \(\widetilde{\mathcal{M}}\) to this modified policy yields the desired soundness for \(\mathcal{M}\). ◻
In the following, we use policies with randomized memory. Formally, a memory-based randomized policy (MBR policy) on an RMDP \(\mathcal{M}_R\) is specified by a standard Borel memory space \(\mathsf Z\), an initial memory distribution \(\lambda\in\Delta(\mathsf Z)\), a measurable action-selection kernel \[\sigma\colon S\times\mathsf Z\to\Delta(\mathsf A),\] and a measurable memory-update kernel \[\upsilon\colon \mathsf Z\times S\times\mathsf A\times S\to\Delta(\mathsf Z),\] such that \(\sigma(s,z)(A(s))=1\) for all \((s,z)\in S\times\mathsf Z\). Such a policy is executed as follows. First, an initial memory state \(z_0\sim\lambda\) is sampled. At time \(t\), after observing the current state \(s_t\) and holding memory \(z_t\), the controller samples \[a_t\sim\sigma(s_t,z_t).\] After the next state \(s_{t+1}\) is generated by the measure selected by the adversary, the memory is updated according to \[z_{t+1}\sim \upsilon(\cdot\mid z_t,s_t,a_t,s_{t+1}).\]
Although MBR policies are useful as compact representations, in our setting, they do not induce more state-action path laws than HR policies. Indeed, every MBR policy admits an adversary-uniform HR realization.
Lemma 9 (HR realization of MBR policies). Let \(\mathcal{M}_R\) be an RMDP whose adversaries observe only the public state-action history. For every MBR policy \(\Pi\) on \(\mathcal{M}_R\), there exists an HR policy \(\Pi^\flat\) such that, for every adversary \(\theta\) of \(\mathcal{M}_R\), \[\mathrm{prob}_{\mathcal{M}_R[\theta],\Pi} = \mathrm{prob}_{\mathcal{M}_R[\theta],\Pi^\flat}.\]
Proof. Let \(\Pi=(\mathsf Z,\lambda,\sigma,\upsilon)\). We construct an HR policy \(\Pi^\flat\) that keeps, as a function of the public history, the belief over the private memory of \(\Pi\).
For a history \(h_t=s_0a_0\cdots a_{t-1}s_t\), let \(b_t(\cdot\mid h_t)\) be a probability measure on \(\mathsf Z\). At time \(0\), set \[b_0(\cdot\mid s_0)=\lambda.\] Given \(b_t(\cdot\mid h_t)\), define \[\Pi^\flat(E\mid h_t) = \int_{\mathsf Z}\sigma(s_t,z)(E)\,b_t(dz\mid h_t), \qquad E\subseteq\mathsf A.\]
It remains to define \(b_{t+1}\). Fix \(h_t\) and a possible next state \(s_{t+1}\). Define a probability measure \(K_{h_t,s_{t+1}}\) on \(\mathsf A\times\mathsf Z\) by \[K_{h_t,s_{t+1}}(E\times B) = \int_{\mathsf Z} \int_E \upsilon(B\mid z,s_t,a,s_{t+1})\, \sigma(da\mid s_t,z)\, b_t(dz\mid h_t),\] for measurable \(E\subseteq\mathsf A\) and \(B\subseteq\mathsf Z\). Since the spaces are standard Borel, this measure admits a regular conditional distribution of the next memory \(z_{t+1}\) given the observed action \(a_t\). Choose one such version and denote it by \[b_{t+1}(\cdot\mid h_ta_ts_{t+1}).\] On histories where this conditional distribution is not uniquely determined, any version may be chosen.
We claim that, for every adversary \(\theta\), \(b_t(\cdot\mid h_t)\) is a version of the conditional law of the private memory \(Z_t\) given the public history \(H_t=h_t\) under the process induced by \((\Pi,\theta)\). The proof is by induction on \(t\). The claim is immediate at \(t=0\). Assume it holds at time \(t\). Given \(H_t=h_t\), the MBR policy samples \(a_t\) according to \[\int_{\mathsf Z}\sigma(s_t,z)(\cdot)\,b_t(dz\mid h_t).\] The adversary then samples \(s_{t+1}\) according to \(\theta_t(h_t,a_t)\), which depends only on the public history and the chosen action, not on the private memory. Therefore, after conditioning on the public next history \(h_ta_ts_{t+1}\), the conditional law of \(Z_{t+1}\) is exactly the regular conditional distribution used above to define \(b_{t+1}(\cdot\mid h_ta_ts_{t+1})\). This proves the induction.
Consequently, under every adversary \(\theta\), after every public history \(h_t\), the action distribution of \(\Pi^\flat\) equals the conditional action distribution of \(\Pi\) after marginalizing its private memory. Since both policies then face the same adversarial transition kernel, they induce the same measures on all finite cylinders, and hence on infinite state-action paths: \[\mathrm{prob}_{\mathcal{M}_R[\theta],\Pi} = \mathrm{prob}_{\mathcal{M}_R[\theta],\Pi^\flat}.\] ◻
Bernoulli mixtures of policies are a special case of MBR policies. Let \(\Pi^0\) and \(\Pi^1\) be two policies on the same RMDP, and let \(\varepsilon\in[0,1]\). We write \[(1-\varepsilon)\Pi^0\oplus\varepsilon\Pi^1\] for the policy that first samples \(Z\in\{0,1\}\) with \(\Pr(Z=1)=\varepsilon\), and then follows \(\Pi^Z\) for the whole execution. We call \(\oplus\) an external mixture. It should not be confused with the combination of policies that, at each history, independently randomizes between the action distributions of \(\Pi^0\) and \(\Pi^1\).
We now define the policy class used in the following completeness theorem. Throughout this paragraph, \(\mathcal{M}\) is finite. Let \(\mathfrak D_{\mathcal{A}}(\mathcal{M})\) be the finite set of maps \(d\colon S\times Q\to\mathsf A\) such that \(d(s,q)\in A(s)\) for every \((s,q)\in S\times Q\).
For every \(\lambda\in\Delta(\mathfrak D_{\mathcal{A}}(\mathcal{M}))\), let \(\Pi_\lambda\) be the MBR policy:
memory space \(\mathsf Z=\mathfrak D_{\mathcal{A}}(\mathcal{M})\times Q,\)
initial memory distribution \(\lambda\otimes\mathrm{Dirac}\left(q_\text{init}\right),\)
action-selection kernel \(\sigma(s,(d,q))=\mathrm{Dirac}\left(d(s,q)\right),\) and
memory-update kernel \(\upsilon(\cdot\mid(d,q),s,a,s') = \mathrm{Dirac}\left((d,\delta(q,L(s')))\right).\)
Thus \(\Pi_\lambda\) first samples a deterministic map \(d\), keeps it fixed for the whole execution, and uses the DFA state as finite memory. Furthermore, we define \[\mathcal{C}_{\mathcal{A}}(\mathcal{M}) = \left\{ \Pi_\lambda^\flat: \lambda\in\Delta(\mathfrak D_{\mathcal{A}}(\mathcal{M})) \right\},\] where \(\Pi_\lambda^\flat\) denotes the HR realization of \(\Pi_\lambda\) from Lemma 9.
In the rest of this section, we assume that the MDP \(\mathcal{M}\) is finite, and that \(\widehat{\mathcal{M}}\) is graph-preserving. We define the minimum transition probability parameter \(\underline p_{\min}\) as \[\underline p_{\min} \mathrel{\vcenter{:}}= \min\left\{ \inf_{\mu\in\widetilde{\mathcal{P}}(s,a)}\mu(s') \;\middle|\; s\in S,\;a\in A(s),\;P(s,a,s')>0 \right\}.\] Furthermore, we define \(N=|S| \cdot |Q|\), \(H_{\max}=\frac{N}{\underline p_{\min}^{\,N}}\), and \[\eta=\sup_{(\xi,a)\in \Xi\times A_\alpha(\xi)} \sup_{\widehat P(\xi,a)\in \widehat{\mathcal{P}}(\xi,a)} \mathrm{TV}(P_\alpha(\xi,a),\widehat{P}(\xi,a)).\]
Lemma 10 (Concrete one-step perturbation). For every \((s,a)\in\operatorname{Gr}(A)\) and every \(\mu\in\widetilde{\mathcal{P}}(s,a)\), \[\mathrm{TV}\bigl(P(s,a),\mu\bigr)\le \eta.\]
Proof. By definition of the conditional lift, there exists \(\widehat\mu\in\widehat{\mathcal{P}}(\alpha(s),a)\) such that \[\mu=\Lambda_{s,a}(\widehat\mu) = \sum_{\xi'\in\Xi} \widehat\mu(\xi')K_{s,a}^{\xi'}.\] Moreover, \[P(s,a) = \Lambda_{s,a}\bigl(P_\alpha(\alpha(s),a)\bigr) = \sum_{\xi'\in\Xi} P_\alpha(\alpha(s),a)(\xi')K_{s,a}^{\xi'}.\] The kernels \(K_{s,a}^{\xi'}\) are supported on the disjoint cells \(C_{\xi'}=\alpha^{-1}(\xi')\). Hence, the total variation distance between the two concrete mixtures is exactly the total variation distance between their cell-mass distributions: \[\mathrm{TV}\bigl(P(s,a),\mu\bigr) = \mathrm{TV}\bigl(P_\alpha(\alpha(s),a),\widehat\mu\bigr).\] By definition of \(\eta\), the right-hand side is at most \(\eta\). ◻
Lemma 11 (Concrete perturbation bound). Let \(\pi\in\mathcal{C}_{\mathcal{A}}(\mathcal{M})\). Then \[\inf_{\widetilde{\theta}} \mathrm{prob}_{\widetilde{\mathcal{M}}[\widetilde{\theta}],\pi}(\varphi) \ge \mathrm{prob}_{\mathcal{M},\pi}(\varphi)-\eta H_{\max},\] where the infimum ranges over adversaries of \(\widetilde{\mathcal{M}}\).
Proof. First fix a deterministic \(\mathcal{A}\)-memory policy \(d\colon S\times Q\to\mathsf A\), and let \(C_d\) be the union of the bottom strongly connected components of the support graph of the concrete product chain induced by \(d\) on \(S\times Q\) that do not intersect \(S\times F\). Let \[\tau_d = \inf\{t\ge 0:(S_t,Q_t)\in C_d\cup(S\times F)\}.\]
Because the conditional lift is graph-preserving, every adversary of \(\widetilde{\mathcal{M}}\) induces the same support graph on \(S\times Q\) under \(d\). From any state outside \(C_d\cup(S\times F)\), there is a path of length at most \(N=|S|\cdot |Q|\) to \(C_d\cup(S\times F)\). Every edge on such a path has probability at least \(\underline p_{\min}\), under every adversary and after every history. Hence, conditionally on any history before hitting \(C_d\cup(S\times F)\), the probability of hitting this set within the next \(N\) steps is at least \(\underline p_{\min}^{N}\). Therefore \[\sup_{\widetilde{\theta}} \mathbb{E}_{\widetilde{\mathcal{M}}[\widetilde{\theta}],d}[\tau_d] \le \frac{N}{\underline p_{\min}^{N}} = H_{\max}.\]
Now fix an adversary \(\widetilde{\theta}\) of \(\widetilde{\mathcal{M}}\). Couple the run of \((\mathcal{M},d)\) and the run of \((\widetilde{\mathcal{M}}[\widetilde{\theta}],d)\) as follows. As long as the two concrete product histories coincide, the policy chooses the same action. At each step, use a maximal coupling between the true transition \(P(s,a)\) and the transition selected by \(\widetilde{\theta}\). By the previous lemma, the one-step mismatch probability is at most \(\eta\).
Let \(\sigma\) be the first mismatch time. If \(\sigma>\tau_d\), then the two product runs agree up to \(\tau_d\). At time \(\tau_d\), either both have reached \(S\times F\), in which case both have observed a bad prefix, or both have entered a bottom component \(C_d\) avoiding \(S\times F\), in which case neither run can later observe a bad prefix. Thus, the two satisfaction events can differ only on \(\{\sigma\le\tau_d\}\). Hence \[\left| \mathrm{prob}_{\widetilde{\mathcal{M}}[\widetilde{\theta}],d}(\varphi) - \mathrm{prob}_{\mathcal{M},d}(\varphi) \right| \le \Pr(\sigma\le\tau_d).\] The stepwise coupling gives \[\Pr(\sigma\le\tau_d) \le \eta\, \mathbb{E}_{\widetilde{\mathcal{M}}[\widetilde{\theta}],d}[\tau_d] \le \eta H_{\max}.\] Therefore, \[\mathrm{prob}_{\widetilde{\mathcal{M}}[\widetilde{\theta}],d}(\varphi) \ge \mathrm{prob}_{\mathcal{M},d}(\varphi)-\eta H_{\max}.\] Finally, let \(\pi\in\mathcal{C}_{\mathcal{A}}(\mathcal{M})\) and write \(\pi=\sum_d \lambda_d d\) as an initial mixture over deterministic \(\mathcal{A}\)-memory policies. For fixed \(\widetilde{\theta}\), the path law under \(\pi\) is the corresponding mixture of the path laws under the \(d\)’s. Averaging the previous inequality gives \[\mathrm{prob}_{\widetilde{\mathcal{M}}[\widetilde{\theta}],\pi}(\varphi) \ge \mathrm{prob}_{\mathcal{M},\pi}(\varphi)-\eta H_{\max}.\] Taking the infimum over \(\widetilde{\theta}\) proves the claim. ◻
We assume in the following that there exists a policy \(\pi_{\mathrm{sl}}\) on \(\widehat{\mathcal{M}}\) and a constant \(\kappa>0\) such that \[\inf_{\widehat\theta} \mathrm{prob}_{\widehat{\mathcal{M}}[\widehat\theta],\pi_{\mathrm{sl}}}(\varphi) \ge 1-p+\kappa.\] We identify \(\pi_{\mathrm{sl}}\) with its lift to the concrete state space via \(\alpha\).
Lemma 12 (Concrete Slater repair). Let \(\pi\in\mathcal{C}_{\mathcal{A}}(\mathcal{M})\) such that \(\mathcal{M},\pi\models\Phi\). Set \[r = \frac{\eta H_{\max}}{\kappa+\eta H_{\max}}, \qquad \widehat\pi = (1-r)\pi\oplus r\pi_{\mathrm{sl}}.\] Then, it holds that \(\widetilde{\mathcal{M}},\widehat\pi\models\Phi,\) and \(\mathrm{TV}_{\mathcal{M}}(\pi,\widehat\pi)\le r.\)
Proof. Since \(\mathcal{M},\pi\models\Phi\), we have \[\mathrm{prob}_{\mathcal{M},\pi}(\varphi)\ge 1-p.\] By the concrete perturbation bound, \[\inf_{\widetilde{\theta}} \mathrm{prob}_{\widetilde{\mathcal{M}}[\widetilde{\theta}],\pi}(\varphi) \ge 1-p-\eta H_{\max}.\] Since \(\widetilde{\mathcal{M}}/\alpha=\widehat{\mathcal{M}}\), the lifted Slater policy satisfies \[\inf_{\widetilde{\theta}} \mathrm{prob}_{\widetilde{\mathcal{M}}[\widetilde{\theta}],\pi_{\mathrm{sl}}}(\varphi) \ge 1-p+\kappa,\] so for every adversary \(\widetilde{\theta}\), \[\mathrm{prob}_{\widetilde{\mathcal{M}}[\widetilde{\theta}],\widehat\pi}(\varphi) \ge (1-r)(1-p-\eta H_{\max}) + r(1-p+\kappa).\] The choice \[r= \frac{\eta H_{\max}}{\kappa+\eta H_{\max}}\] makes the right-hand side equal to \(1-p\). Hence \[\widetilde{\mathcal{M}},\widehat\pi\models\Phi.\] Finally, the TV bound follows by coupling the initial mixture: with probability \(1-r\), \(\widehat\pi\) follows \(\pi\) for the whole run, and with probability \(r\), it follows \(\pi_{\mathrm{sl}}\). Thus, under the true MDP, \[\mathrm{TV}\!\left( \mathrm{prob}_{\mathcal{M},\pi}, \mathrm{prob}_{\mathcal{M},\widehat\pi} \right) \le r,\] which is equivalent to the claim \(\mathrm{TV}_{\mathcal{M}}(\pi,\widehat\pi)\le r\), which concludes the proof. ◻
Theorem 9 (TV completeness for concrete automaton-memory policies). Suppose that \(\mathcal{M}\) is finite, that \(\mathcal{M}\) is conditionally deterministic w.r.t. \(\alpha\), that \(\widehat{\mathcal{M}}\) is graph-preserving, that \(\underline p_{\min}>0\), and that there exists a Slater policy \(\pi_{\mathrm{sl}}\) with margin \(\kappa>0\). Suppose also that \(\widehat\beta(\xi_\text{init},q_\text{init})<p\). Then the shield \(\mathfrak S(\widehat{\mathcal{M}},\mathcal{A},\widehat\beta)\) acts on \((\mathcal{M},\alpha)\) and is \(\mathcal{C}_{\mathcal{A}}(\mathcal{M})\text{-}\epsilon\text{-}\mathrm{TV} \text{-complete}\) over \((\mathcal{M},\alpha)\) for \(\Phi\), where \[\epsilon = \frac{ \|\widehat\beta-\widehat\beta^\infty\|_\infty }{ \|\widehat\beta-\widehat\beta^\infty\|_\infty + p-\widehat\beta(\xi_\text{init},q_\text{init}) } + \frac{\eta H_{\max}}{\kappa+\eta H_{\max}},\] with \[H_{\max} = \frac{|S|\cdot |Q|}{(\underline p_{\min})^{\left(\,|S|\cdot |Q|\right)}}.\]
Proof. Let \(\pi\in\mathcal{C}_{\mathcal{A}}(\mathcal{M})\) be such that \(\mathcal{M},\pi\models\Phi\). By the Slater repair lemma, the policy \[\widehat\pi = (1-r)\pi\oplus r\pi_{\mathrm{sl}}, \qquad r= \frac{\eta H_{\max}}{\kappa+\eta H_{\max}},\] is safe for the conditional lift \(\widetilde{\mathcal{M}}\), and \(\mathrm{TV}_{\mathcal{M}}(\pi,\widehat\pi)\le r\).
Since \(\widetilde{\mathcal{M}}/\alpha=\widehat{\mathcal{M}}\), the shield \(\mathfrak S(\widehat{\mathcal{M}},\mathcal{A},\widehat\beta)\) is exactly \(\mathfrak S(\widetilde{\mathcal{M}}/\alpha,\mathcal{A},\widehat\beta)\). Since \(\mathcal{M}\) is conditionally deterministic with respect to \(\alpha\) and \(\widehat{\mathcal{M}}\) is graph-preserving, the conditional concrete lift \(\widetilde{\mathcal{M}}\) is conditionally deterministic with respect to \(\alpha\). Hence Theorem [th:RMDP-TV-completeness] applies to \(\widetilde{\mathcal{M}}\). As a consequence, there exists a compliant HR policy \(\overline{\pi}\) on \(\mathcal{M}\otimes_\alpha\mathcal{D}\) such that \[\mathrm{TV}_{\widetilde{\mathcal{M}}} \bigl(\widehat\pi,\overline{\pi}^\downarrow\bigr) \le \epsilon_\beta,\] where \[\epsilon_\beta = \frac{ \|\widehat\beta-\widehat\beta^\infty\|_\infty }{ \|\widehat\beta-\widehat\beta^\infty\|_\infty + p-\widehat\beta(\xi_\text{init},q_\text{init}) }.\] This, in particular, implies that \[\mathrm{TV}_{\mathcal{M}} \bigl(\widehat\pi,\overline{\pi}^\downarrow\bigr) \le \epsilon_\beta,\] which, by the triangle inequality, yields \[\mathrm{TV}_{\mathcal{M}} \bigl(\pi,\overline{\pi}^\downarrow\bigr) \le r+\epsilon_\beta.\] Thus, the shield is \(\mathcal{C}_{\mathcal{A}}(\mathcal{M})\)-\(\epsilon\)-TV-complete with \(\epsilon=\epsilon_\beta+ \frac{\eta H_{\max}}{\kappa+\eta H_{\max}},\) which concludes the proof. ◻
We now prove a \(W_{1,\gamma}\)-completeness result. In contrast to the \(\mathrm{TV}\)-completeness theorem above, this result does not require a uniform hitting-time bound. Instead, we only compare the true MDP and the conditional lift over a finite horizon \(T\).
Let \(\widehat{\beta}^{\infty}\) be the least fixed point of \(\mathcal{B}_{\widehat{\mathcal{M}}\otimes_{L_\alpha}\mathcal{A}}^{\Xi\times F}\). Let \(\beta^\infty\) be the least fixed point of \(\mathcal{B}_{(\mathcal{M}/\alpha)\otimes_{L_\alpha}\mathcal{A}}^{\Xi\times F}\). We define \(\Delta_\infty = \|\widehat{\beta}^{\infty}-\beta^\infty\|_\infty\). Since \(\alpha\) is an exact safety abstraction, the least bad-reachability value on the concrete product \(\mathcal{M}\otimes_{L}\mathcal{A}\) is the lift of \(\beta^\infty\), namely \((s,q)\mapsto \beta^\infty(\alpha(s),q)\).
Since the learned product RMDP is finite, choose a policy \(\widehat\pi^\star\) on \(\widehat{\mathcal{M}}\otimes_{L_\alpha}\mathcal{A}\) such that, for every \((\xi,q)\in\Xi\times Q\), \[\sup_{\widehat\theta} \mathrm{prob}_{\widehat{\mathcal{M}}[\widehat\theta],\widehat\pi^\star}^{(\xi,q)} \left[\left\{ h\mid h\models \mathbf{F}(\Xi\times F)\right\} \right] \le \widehat{\beta}^{\infty}(\xi,q).\] We identify \(\widehat\pi^\star\) with its lift to the concrete state space through \(\alpha\).
For an HR policy \(\pi\) on \(\mathcal{M}\) and \(T\in\mathbb{N}\), let \(\pi^{(T)}\) be the policy that follows \(\pi\) for the first \(T\) decision times and then follows the lifted policy \(\widehat\pi^\star\) forever.
Lemma 13 (Hard-switch perturbation bound). For every HR policy \(\pi\) on \(\mathcal{M}\) and every \(T\in\mathbb{N}\), \[\inf_{\widetilde{\theta}} \mathrm{prob}_{\widetilde{\mathcal{M}}[\widetilde{\theta}],\pi^{(T)}}(\varphi) \ge \mathrm{prob}_{\mathcal{M},\pi}(\varphi)-T\eta-\Delta_\infty,\] where the infimum ranges over adversaries of \(\widetilde{\mathcal{M}}\).
Proof. Fix an adversary \(\widetilde{\theta}\) of \(\widetilde{\mathcal{M}}\). We couple the run of \((\mathcal{M},\pi)\) with the run of \((\widetilde{\mathcal{M}}[\widetilde{\theta}],\pi^{(T)})\) during the first \(T\) decision times. As long as the two concrete histories coincide, the two policies choose the same action distribution, because \(\pi^{(T)}\) coincides with \(\pi\) before time \(T\). We couple the actions identically, and then use a maximal coupling between the true transition \(P(s,a)\) and the transition selected by \(\widetilde{\theta}\). By the concrete one-step perturbation lemma, the one-step mismatch probability is at most \(\eta\).
Let \(\sigma=\inf\{t\ge 0:S_t\neq \widetilde{S}_t\}\) be the first time at which the two concrete state sequences differ. Then \[\Pr(\sigma\le T)\le T\eta.\] Let \(B\) be the event that the true run violates \(\varphi\), and let \(\widetilde{B}\) be the event that the lifted run violates \(\varphi\). Let \(A_T\) be the event that no accepting state of the DFA has been reached up to time \(T\) along the true run. On the event \(\{\sigma>T\}\cap A_T\), the two product runs have the same concrete product state \((S_T,Q_T)\) at time \(T\). From that time onward, the lifted run follows \(\widehat\pi^\star\). Hence the conditional probability of eventually reaching \(S\times F\) is at most \[\widehat{\beta}^{\infty}(\alpha(S_T),Q_T).\] Therefore, we obtain \[\Pr(\widetilde{B}) \le \Pr(\sigma\le T) + \Pr(B\cap A_T^c) + \mathbb{E}\!\left[ \mathbf{1}_{A_T} \widehat{\beta}^{\infty}(\alpha(S_T),Q_T) \right].\]
Let \(v_\pi(H_T)\) be the conditional probability, under the true MDP and policy \(\pi\), of eventually violating \(\varphi\) after the concrete history \(H_T\). Using this notation, we write \[\Pr(B) = \Pr(B\cap A_T^c) + \mathbb{E}\!\left[ \mathbf{1}_{A_T}v_\pi(H_T) \right].\] Since \(\alpha\) is a safety abstraction, the least bad-reachability value on the concrete product is the lift of \(\beta^\infty\). Hence, on \(A_T\), \[\beta^\infty(\alpha(S_T),Q_T) \le v_\pi(H_T),\] from which we find that \[\widehat{\beta}^{\infty}(\alpha(S_T),Q_T)-v_\pi(H_T) \le \widehat{\beta}^{\infty}(\alpha(S_T),Q_T) - \beta^\infty(\alpha(S_T),Q_T) \le \Delta_\infty.\] Combining the previous inequalities gives \[\Pr(\widetilde{B})-\Pr(B) \le T\eta+\Delta_\infty,\] which is equivalent to \[\mathrm{prob}_{\widetilde{\mathcal{M}}[\widetilde{\theta}],\pi^{(T)}}(\varphi) \ge \mathrm{prob}_{\mathcal{M},\pi}(\varphi)-T\eta-\Delta_\infty.\] Taking the infimum over \(\widetilde{\theta}\) proves the claim. ◻
Lemma 14 (Hard-switch Wasserstein cost). For every HR policy \(\pi\) on \(\mathcal{M}\) and every \(T\in\mathbb{N}\), \[W_{1,\gamma}^{\mathcal{M}}\!\left(\pi,\pi^{(T)}\right) \le \gamma^T.\]
Proof. Couple the runs of \(\pi\) and \(\pi^{(T)}\) on the true MDP so that they use the same actions and transition randomness during the first \(T\) decision times. The two induced state-action trajectories then coincide up to time \(T\). Therefore, their discounted Hamming distance is at most \[(1-\gamma)\sum_{t=T}^{\infty}\gamma^t = \gamma^T.\] Taking the infimum over all couplings yields the claim. ◻
Lemma 15 (Hard-switch Slater repair). Assume that there exists a policy \(\pi_{\mathrm{sl}}\) on \(\widehat{\mathcal{M}}\) and a constant \(\kappa>0\) such that \[\inf_{\widehat\theta} \mathrm{prob}_{\widehat{\mathcal{M}}[\widehat\theta],\pi_{\mathrm{sl}}}(\varphi) \ge 1-p+\kappa.\] Let \(\pi\) be an HR policy on \(\mathcal{M}\) such that \(\mathcal{M},\pi\models\Phi.\) For \(T\in\mathbb{N}\), set \[\delta_T\mathrel{\vcenter{:}}= T\eta+\Delta_\infty, \qquad \lambda_T\mathrel{\vcenter{:}}= \frac{\delta_T}{\kappa+\delta_T},\] and define \[\widehat\pi^{(T)} \mathrel{\vcenter{:}}= (1-\lambda_T)\pi^{(T)} \oplus \lambda_T\pi_{\mathrm{sl}},\] where \(\pi_{\mathrm{sl}}\) is lifted to the concrete state space through \(\alpha\). Then \(\widetilde{\mathcal{M}},\widehat\pi^{(T)}\models\Phi.\) Moreover, \[W_{1,\gamma}^{\mathcal{M}}\!\left(\pi,\widehat\pi^{(T)}\right) \le \gamma^T+\lambda_T.\]
Proof. Since \(\mathcal{M},\pi\models\Phi\), we have \(\mathrm{prob}_{\mathcal{M},\pi}(\varphi)\ge 1-p.\) By Lemma 13, \[\inf_{\widetilde{\theta}} \mathrm{prob}_{\widetilde{\mathcal{M}}[\widetilde{\theta}],\pi^{(T)}}(\varphi) \ge 1-p-\delta_T.\] Since \(\widetilde{\mathcal{M}}/\alpha=\widehat{\mathcal{M}}\), the lifted Slater policy satisfies \[\inf_{\widetilde{\theta}} \mathrm{prob}_{\widetilde{\mathcal{M}}[\widetilde{\theta}],\pi_{\mathrm{sl}}}(\varphi) \ge 1-p+\kappa.\] Therefore, for every adversary \(\widetilde{\theta}\), \[\mathrm{prob}_{\widetilde{\mathcal{M}}[\widetilde{\theta}],\widehat\pi^{(T)}}(\varphi) \ge (1-\lambda_T)(1-p-\delta_T) + \lambda_T(1-p+\kappa).\] By the definition of \(\lambda_T\), the right-hand side is equal to \(1-p\), so the first claim \(\widetilde{\mathcal{M}},\widehat\pi^{(T)}\models\Phi\) follows.
Second, for the Wasserstein bound, by convexity of \(W_{1,\gamma}\) in its second argument, \[W_{1,\gamma}^{\mathcal{M}}\!\left(\pi,\widehat\pi^{(T)}\right) \le (1-\lambda_T) W_{1,\gamma}^{\mathcal{M}}\!\left(\pi,\pi^{(T)}\right) + \lambda_T W_{1,\gamma}^{\mathcal{M}}\!\left(\pi,\pi_{\mathrm{sl}}\right).\] Since \(W_{1,\gamma}\le 1\), and by Lemma 14, \[W_{1,\gamma}^{\mathcal{M}}\!\left(\pi,\widehat\pi^{(T)}\right) \le (1-\lambda_T)\gamma^T+\lambda_T \le \gamma^T+\lambda_T.\] ◻
Theorem 10 (Hard-switch \(W_{1,\gamma}\)-completeness). Suppose that \(\widehat{\beta}(\xi_\text{init},q_\text{init})<p\), suppose that \(\mathcal{M}\) is conditionally deterministic w.r.t. \(\alpha\), and suppose that there exists a Slater policy \(\pi_{\mathrm{sl}}\) with margin \(\kappa>0\), \[\inf_{\widehat\theta} \mathrm{prob}_{\widehat{\mathcal{M}}[\widehat\theta],\pi_{\mathrm{sl}}}(\varphi) \ge 1-p+\kappa.\] Then, for every \(T\in\mathbb{N}\), the shield \(\mathfrak S(\widehat{\mathcal{M}},\mathcal{A},\widehat{\beta})\) acts on \((\mathcal{M},\alpha)\) and is \(\mathrm{HR}\text{-}\epsilon_T\text{-}W_{1,\gamma}\text{-complete}\) over \((\mathcal{M},\alpha)\) for \(\Phi\), where \[\epsilon_T = \frac{ \|\widehat{\beta}-\widehat{\beta}^{\infty}\|_\infty }{ \|\widehat{\beta}-\widehat{\beta}^{\infty}\|_\infty + p-\widehat{\beta}(\xi_\text{init},q_\text{init}) } + \gamma^T + \frac{T\eta+\Delta_\infty}{\kappa+T\eta+\Delta_\infty}.\]
Proof. Let \(\pi\) be an HR policy on \(\mathcal{M}\) such that \[\mathcal{M},\pi\models\Phi.\] By Lemma 15, the policy \(\widehat\pi^{(T)}\) is safe for the conditional lift \(\widetilde{\mathcal{M}}\), and \[W_{1,\gamma}^{\mathcal{M}}\!\left(\pi,\widehat\pi^{(T)}\right) \le \gamma^T+ \frac{T\eta+\Delta_\infty}{\kappa+T\eta+\Delta_\infty}.\]
For brevity, define \[\epsilon_\beta = \frac{ \|\widehat{\beta}-\widehat{\beta}^{\infty}\|_\infty }{ \|\widehat{\beta}-\widehat{\beta}^{\infty}\|_\infty + p-\widehat{\beta}(\xi_\text{init},q_\text{init}) }.\] Since \(\widetilde{\mathcal{M}}/\alpha=\widehat{\mathcal{M}},\) the shield \(\mathfrak S(\widehat{\mathcal{M}},\mathcal{A},\widehat{\beta})\) is exactly \(\mathfrak S(\widetilde{\mathcal{M}}/\alpha,\mathcal{A},\widehat{\beta}).\) Applying the RMDP \(\mathrm{TV}\)-completeness theorem to \(\widetilde{\mathcal{M}}\), there exists a compliant HR policy \(\overline{\pi}\) on \(\mathcal{M}\otimes_\alpha\mathcal{D}\) such that \[\mathrm{TV}_{\widetilde{\mathcal{M}}} \left( \widehat\pi^{(T)},\overline{\pi}^\downarrow \right) \le \epsilon_\beta.\] Since the true MDP \(\mathcal{M}\) is a resolution of \(\widetilde{\mathcal{M}}\), this implies \[\mathrm{TV}_{\mathcal{M}} \left( \widehat\pi^{(T)},\overline{\pi}^\downarrow \right) \le \epsilon_\beta.\] By Lemma 5, we obtain \[W_{1,\gamma}^{\mathcal{M}} \left( \widehat\pi^{(T)},\overline{\pi}^\downarrow \right) \le \epsilon_\beta,\] which, via the triangle inequality gives \[W_{1,\gamma}^{\mathcal{M}} \left( \pi,\overline{\pi}^\downarrow \right) \le \epsilon_\beta + \gamma^T + \frac{T\eta+\Delta_\infty}{\kappa+T\eta+\Delta_\infty}.\] Thus, the shield is \(\mathrm{HR}\)-\(\epsilon_T\)-\(W_{1,\gamma}\)-complete. ◻
We now derive optimality guarantees presented in 4 from the completeness results above. The \(W_{1,\gamma}\)-result already applies to all HR policies. For the \(\mathrm{TV}\)-result, which was proved only for the class \(\mathcal{C}_{\mathcal{A}}(\mathcal{M})\), we first recall that this class is sufficient to attain the optimal value of the finite undiscounted safe policy optimization problem under standard total-reward assumptions.
Lemma 16 (Initial mixtures with automaton memory suffice). Assume that \(\mathcal{M}\) is finite. Consider the undiscounted safe policy optimization problem \[\sup_{\pi\in\mathrm{HR}} J^1_{\mathcal{M}}(\pi) \qquad \text{subject to} \qquad \mathcal{M},\pi\models\mathbb{P}_{\ge 1-p}(\varphi).\] Suppose that:
for every HR policy \(\pi\), the total reward \(\sum_{t=0}^{\infty}R(s_t,a_t)\) is almost surely convergent and has finite expectation;
an optimal feasible HR policy exists.
Then there exists an optimal feasible policy \(\pi^\star\in\mathcal{C}_{\mathcal{A}}(\mathcal{M}).\) Moreover, \(\pi^\star\) can be chosen as an initial mixture of at most two deterministic \(\mathcal{A}\)-memory policies.
Proof. Consider the product MDP \(\mathcal{M}\otimes_{L}\mathcal{A}\) with state space \(S\times Q\), and let \(G=S\times F\) be the set of bad product states. We make \(G\) absorbing and set the reward to zero after \(G\) is reached. This does not change either the event of violating \(\varphi\) or the value of the total reward up to violation.
The safety constraint can be written as a total-cost constraint. Define the one-step cost \[c((s,q),a) = \mathbb{P}_{s'\sim P(s,a)} \left[ \delta(q,L(s'))\in F \right]\] for \(q\notin F\), and \(c((s,q),a)=0\) for \(q\in F\). Then, for every policy \(\pi\), \[\mathbb{E}^\pi \left[ \sum_{t=0}^{\infty} c((s_t,q_t),a_t) \right]\] is the probability to reach \(G\) following \(\pi\), so the constraint \[\mathcal{M},\pi\models\mathbb{P}_{\ge 1-p}(\varphi)\] is equivalent to \[\mathbb{E}^\pi \left[ \sum_{t=0}^{\infty} c((s_t,q_t),a_t) \right] \le p.\]
Thus, the problem is a finite total-reward CMDP on the product MDP with one total-cost constraint. By the standard occupation-measure formulation for finite total-reward CMDPs, the achievable reward-cost region is the convex hull of the performance vectors of deterministic stationary policies on the product MDP. Hence, an optimal feasible point can be achieved by an initial mixture of deterministic stationary product policies. Since there is one cost constraint, Carathéodory’s theorem, or equivalently, the basic feasible solution structure of the corresponding linear program, implies that at most two deterministic stationary product policies are needed.
Finally, deterministic stationary policies on the product \(S\times Q\) are exactly deterministic \(\mathcal{A}\)-memory policies on \(\mathcal{M}\), and their initial mixtures are precisely the policies in \(\mathcal{C}_{\mathcal{A}}(\mathcal{M})\). Therefore, an optimal feasible policy exists in \(\mathcal{C}_{\mathcal{A}}(\mathcal{M})\). ◻
We are now ready to state our two final optimality results, as presented in 4. The first follows directly from combining Theorem 9, Lemma 16, and Lemma 7.
Theorem 11 (Undiscounted HR-optimality from TV-completeness; extension of 4, case 1). Assume the hypotheses of Theorem 9 and Lemma 16. Suppose moreover that the absolute value of the total undiscounted return is uniformly bounded by \(B\). Let \[\epsilon_{\mathrm{TV}} = \frac{ \|\widehat\beta-\widehat\beta^\infty\|_\infty }{ \|\widehat\beta-\widehat\beta^\infty\|_\infty + p-\widehat\beta(\xi_\text{init},q_\text{init}) } + \frac{\eta H_{\max}}{\kappa+\eta H_{\max}}.\] Then the shield \(\mathfrak S(\widehat{\mathcal{M}},\mathcal{A},\widehat\beta)\) is \[\mathrm{HR}\text{-}(2B\epsilon_{\mathrm{TV}},1)\text{-optimal}\] over \((\mathcal{M},\alpha)\) for \(\Phi\).
The following result follows directly from combining Theorem 10 and Lemma 7.
Theorem 12 (Discounted HR-optimality from hard-switch completeness; extension of 4, case 2). Assume the hypotheses of Theorem 10. Suppose that \(\sup_{(s,a)\in S\times\mathsf A}|R(s,a)|\le Z\). Then, the shield \(\mathfrak S(\widehat{\mathcal{M}},\mathcal{A},\widehat\beta)\) is \[\mathrm{HR}\text{-} \left( \frac{2Z\epsilon}{1-\gamma}, \gamma \right)\text{-optimal}\] over \((\mathcal{M},\alpha)\) for \(\Phi\), where \[\epsilon = \min_{T\in\mathbb{N}}\left(\frac{ \|\widehat\beta-\widehat\beta^\infty\|_\infty }{ \|\widehat\beta-\widehat\beta^\infty\|_\infty + p-\widehat\beta(\xi_\text{init},q_\text{init}) } + \gamma^T + \frac{T\eta+\Delta_\infty}{\kappa+T\eta+\Delta_\infty} \right).\]
In this appendix, we further detail the implementation of our shielding pipeline, in particular, for step (3) of running policy optimization with the shield active. Recall that the transition function \(P\) of the true MDP \(\mathcal{M}\) is unknown, but we instead have access to a simulator. Thus, enabling the shield means that we obtain a shielded simulator MDP \(\overline{\mathcal{M}}^{\mathfrak S} \left(\overline{S},A^{\mathfrak S},P^{\mathfrak S},\overline{s_\text{init}},AP,\overline{L}\right)\), obtained from the restriction of policy distributions allowed by the shield. More precisely, \(\overline{\mathcal{M}}^{\mathfrak S}\) is the MDP with same set of states, labels, labelling, and rewards as \(\mathcal{M}\otimes_{\alpha} \mathcal{D}\), but with action space \(A^{\mathfrak S}(s,m)=\Gamma(\alpha(s),m)\), and probability transition function \[\overline{P}^{\mathfrak S}((s,m),\rho)(E) = \int_{\mathsf A\times U} \overline{P}((s,m),(a,u))(E)\, \rho(d(a,u)).\] Given the definition of \(\Gamma\), the space \(A^{\mathfrak S}(s,m)\) is convex, and, for optimization purposes, \(A^{\mathfrak S}(s,m)\) can be taken as its extremal points. Furthermore, since \(\Gamma(\alpha(s),m)\) is defined over \(\overline{\mu}\in\Delta(\mathsf A\times\mathcal{V}_\beta)\) by a single scalar inequality, an extremal point of \(A^{\mathfrak S}(s,m)\) is always a mixture of at most two Dirac distributions over \(A\times U\). In addition, for a fixed action distribution \(\mu\) over two actions \(a\) and \(a'\), the set of all auxiliary actions \((v,v')\) that satisfy compliance with the shield is a convex polytope itself. More precisely, for any action distribution \(\mu\), the set of all possible auxiliary actions for every base action \(a\) that satisfy compliance with the shield is the set \(\mathcal{V}_{\lambda}(\xi,q,y)\) of all \((v_a)_{a\in A_\alpha(\xi)} \in \mathcal{V}_\beta^{A_\alpha(\xi)}\) such that \[\sum_{a\in A_\alpha(\xi)} \mu(a)\sup_{\mu\in\mathcal{P}_\alpha(\xi,a)} \mathbb{E}_{\xi'\sim\mu} \left[ v_a\bigl(\xi',\delta(q,L_\alpha(\xi'))\bigr) \right] \le y.\]
As a consequence, since we still assume the the quotient \(\mathcal{M}/\alpha\) is finite, the \(\mathcal{V}_\beta^{A_\alpha(\xi)}\) has finitely many extremal points. Thus, we can restrict the action space of \(\overline{\mathcal{M}}^{\mathfrak S}\) to
the choice of two actions, of a trade-off \(\lambda\in [0;1]\) between those two action, inducing a distribution \(\mu\) over actions, and
the choice of an extremal point of \(\mathcal{V}_{\lambda}(\xi,q,y)\).
In practice, we optimize with PPO [49] over \(\overline{\mathcal{M}}^{\mathfrak S}\), we leave the choice of the trade-off \(\lambda\) to the actor, and implement the following heuristic for the choice of the extremal point of \(\mathcal{V}_{\lambda}(\xi,q,y)\).
We describe the heuristic used to choose the auxiliary actions after the actor has selected a mixed base action. Fix a shield state \((\xi,q,y)\), and let \(\lambda\in\Delta(A_\alpha(\xi))\) be the action distribution selected by the actor. In principle, a compliant shielded action may assign an action-dependent continuation certificate \((v_a)_{a\in A_\alpha(\xi)}\in\mathcal{V}_{\widehat\beta}^{A_\alpha(\xi)}\) satisfying \[\sum_{a\in A_\alpha(\xi)} \lambda(a) \sup_{\widehat\mu\in\widehat{\mathcal{P}}(\xi,a)} \mathbb{E}_{\xi'\sim\widehat\mu} \left[ v_a\bigl(\xi',\delta(q,L_\alpha(\xi'))\bigr) \right] \le y .\] Rather than optimizing over this full polytope, our implementation uses a single shared continuation certificate \(v\in\mathcal{V}_{\widehat\beta}\) for all actions in the support of \(\lambda\). This is conservative but simplifies the shielded action parametrization. Starting from the baseline certificate \(\widehat\beta\), we distribute the available residual budget uniformly by considering the one-dimensional family \[v_m(\xi',q') = \min\{\widehat\beta(\xi',q')+m,1\}, \qquad m\ge 0.\] We then choose the largest margin \(m\) preserving one-step robust feasibility: \[m^\star = \sup \left\{ m\ge 0: \sum_{a\in A_\alpha(\xi)} \lambda(a) \sup_{\widehat\mu\in\widehat{\mathcal{P}}(\xi,a)} \mathbb{E}_{\xi'\sim\widehat\mu} \left[ v_m\bigl(\xi',\delta(q,L_\alpha(\xi'))\bigr) \right] \le y \right\}.\] The auxiliary action used by the shield is \(v_{m^\star}\), i.e. we take \(v_a=v_{m^\star}\) for every action \(a\) in the support of \(\lambda\). If \(m=0\) is already infeasible, then the proposed action distribution \(\lambda\) is not compatible with the shield; in that case the implementation falls back to a precomputed safe distribution witnessing the inductiveness of \(\widehat\beta\).
For finite RMDPs, the map \[m\mapsto \sum_{a\in A_\alpha(\xi)} \lambda(a) \sup_{\widehat\mu\in\widehat{\mathcal{P}}(\xi,a)} \mathbb{E}_{\xi'\sim\widehat\mu} \left[ v_m\bigl(\xi',\delta(q,L_\alpha(\xi'))\bigr) \right]\] is monotone and piecewise affine. Its breakpoints occur only when a coordinate \(\widehat\beta(\xi',q')+m\) reaches \(1\). We therefore compute \(m^\star\) by sorting these saturation breakpoints and scanning the corresponding affine pieces. On the first segment where the robust expectation reaches the budget \(y\), \(m^\star\) is obtained by solving a one-dimensional affine equation. If the robust expectation remains below \(y\) after all coordinates have saturated, then all continuation thresholds can be set to \(1\).
This section reports the full experimental results for each environment considered in the main paper.
We now provide a description of the environments used to evaluate our approach. These environments have been used in prior work, and their behavior remains unchanged unless stated otherwise. In particular, we consider two variants of the Media Streaming environment, two variants of the Colour Bomb Gridworld, as well as Pacman and its variant, Pacman Slippery, in which the agent may execute slippery actions.
Overall, this results in a total of six environments. For brevity, we provide a detailed description only for the general version of each environment family (three environments in total), while the corresponding variants differ only in the aspects mentioned above.
Media streaming. The agent manages a data buffer of size \(20\). Packets leave the buffer according to a Bernoulli process with rate \(\mu_{\textit{out}}=0.7\). At each timestep, the agent chooses between two actions \(A=\{\textit{slow},\textit{fast}\}\), which add packets according to Bernoulli rates \(\mu_{\textit{slow}}=0.1\) and \(\mu_{\textit{fast}}=0.9\), respectively. The reward objective is to minimise outage time: the agent receives reward \(-1\) whenever the buffer is empty and \(0\) otherwise. Safety is governed by a counter \(c_t\) recording the number of times the fast action has been used, capped at \(C+1\), with \(C=\lfloor T/2\rfloor\) and \(T=100\). We use the probabilistic safety constraint \[\mathbb{P}_{\geq 0.5} \left( \mathbf{G}(c_t \leq C) \right).\] The environment has \(20 \times 52 = 1040\) states, corresponding to the buffer level and the capped fast-action counter. A related benchmark has been considered in [53].
Media streaming - Alternative. We also consider a stochastic-safety variant of the media-streaming environment. The buffer dynamics and reward function are the same as above, but safety is governed by a danger level \(d_t\), initialised at \(0\) and capped at \(D_{\max}+1\), where \(D_{\max}=20\). We use the safety constraint \[\mathbb{P}_{\geq 0.5} \left( \mathbf{G}(d_t \leq D_{\max}) \right).\] Under the slow action, the danger level decreases by one with probability \(0.5\), remains unchanged with probability \(0.1\), and increases by one with probability \(0.4\). Under the fast action, the danger level increases by one with probability \(0.8\), remains unchanged with probability \(0.1\), and decreases by one with probability \(0.1\). Thus, the fast action improves the buffer more reliably but tends to increase the probability of entering unsafe states, while the slow action is safer on average but does not guarantee that danger decreases. The full observation is \((d_t,b_t,t)\), giving \(22 \times 20 \times 101 = 44440\) possible observations. Since the buffer affects reward but not safety, the shield uses the abstraction \((d_t,t)\), which has \(22 \times 101 = 2222\) states.
Colour bomb gridworld. The agent operates in a \(15\times 15\) gridworld, with discrete actions \(A=\{\textit{left},\textit{right},\textit{down},\textit{up},\textit{stay}\}\). Outside the medic states, the intended action is executed with probability \(0.9\), while with probability \(0.1\) the agent slips uniformly to one of the other actions. In medic states, the dynamics are deterministic. The environment contains wall cells, bomb cells, medic cells, and coloured goal regions. At the beginning of each episode, the initial state is sampled uniformly from a fixed set of start states. The agent receives reward \(+1\) upon entering any coloured goal region and reward \(0\) otherwise; after reaching such a goal region, the process is reset to a uniformly sampled start state. The base gridworld has \(15^2=225\) states. We consider the probabilistic safety constraint \[\mathbb{P}_{\geq 0.5} \left( \mathbf{G}\,\neg\mathsf{bomb} \right),\] and an LTL-safety variant \[\mathbb{P}_{\geq 0.99} \left( \mathbf{G} \left( \mathsf{bomb} \Rightarrow \mathbf{F}_{\leq 10} \left( \mathsf{medic} \wedge \mathbf{X}\mathsf{medic} \right) \right) \right).\] The LTL property is represented by a \(22\)-state safety automaton, so the product MDP used by the shield has \(225\times 22 = 4950\) states. A related gridworld has been used in [6].
Pacman and slippery Pacman. We consider a Pacman-with-coins environment on a \(7\times 10\) map. The environment contains one Pacman agent, one ghost, walls, and collectible coins, with reward \(+1\) obtained when Pacman visits a cell containing an uncollected coin. The full coin-augmented state is combinatorial: the map has \(28\) free cells, giving up to \(2^{28}\) possible coin configurations for each agent–ghost configuration. For shielding, we use a safety abstraction that discards the coins and retains only the positions and directions of Pacman and the ghost. This abstraction has \(4624\) states. The ghost dynamics are stochastic: the ghost chooses an available action directed toward Pacman with probability \(0.4\), and otherwise randomises uniformly over the other available actions with total probability \(0.6\). We use the safety specification \[\mathbb{P}_{\geq 1-p} \left( \mathbf{G}(\mathrm{loc}_{\mathrm{Pacman}} \neq \mathrm{loc}_{\mathrm{Ghost}}) \right),\] where \(p=0.05\) for Pacman and \(0.5\) for Pacman slippery. We also evaluate a slippery variant on the same map and with the same \(4624\)-state safety abstraction. In this variant, the requested Pacman action is executed with probability \(0.9\), while with probability \(0.1\) one of the other actions is executed uniformly at random. The task is to collect as many coins as possible while satisfying the probabilistic safety specification of avoiding the ghost throughout the episode. Similar environments were considered in [6], [7].
We use the shorthand labels MDP, MLE, Kno, and Unk in all plots to indicate the four different cases described in 5.
We report two evaluation metrics:
Expected discounted reward (rew): the average episodic return, corresponding to an empirical estimate of \(J^\gamma_M(\pi)\).
Specification satisfaction probability (sat): the empirical probability that a rollout satisfies the specification.
When learning curves are shown, we additionally report the corresponding training-time quantities rew and sat. For each environment, we provide two groups of plots:
learning curves over training steps, shown for each sample size (the specific number that changes across the various environments represents the minimum number of samples needed for Unk);
averaged performance as a function of sample size.
Figure 4: |
Samples | |
Figure 5: |
Figure 6: |
10 |
Figure 7: |
Figure 8: |
100 |
Figure 9: |
Figure 10: |
980 |
Figure 11: |
Figure 12: |
1000 |
Figure 13: |
Figure 14: |
5000 |
Figure 15: |
Figure 16: |
10000 |
Figure 17: |
|
20000 |
Figure 18: |
|
Figure 19: |
Figure 20: |
Figure 21: |
Samples | |
Figure 22: |
Figure 23: |
10 |
Figure 24: |
Figure 25: |
100 |
Figure 26: |
Figure 27: |
1000 |
Figure 28: |
Figure 29: |
1226 |
Figure 30: |
Figure 31: |
5000 |
Figure 32: |
Figure 33: |
10000 |
Figure 34: |
|
20000 |
Figure 35: |
|
Figure 36: |
Figure 37: |
Figure 38: |
Samples | |
Figure 39: |
Figure 40: |
10 |
Figure 41: |
Figure 42: |
100 |
Figure 43: |
Figure 44: |
317 |
Figure 45: |
Figure 46: |
1000 |
Figure 47: |
Figure 48: |
5000 |
Figure 49: |
Figure 50: |
10000 |
Figure 51: |
|
20000 |
Figure 52: |
|
Figure 53: |
Figure 54: |
Figure 55: |
Samples | |
Figure 56: |
Figure 57: |
10 |
Figure 58: |
Figure 59: |
100 |
Figure 60: |
Figure 61: |
1000 |
Figure 62: |
Figure 63: |
5000 |
Figure 64: |
Figure 65: |
10000 |
Figure 66: |
Figure 67: |
16215 |
Figure 68: |
|
20000 |
Figure 69: |
|
Figure 70: |
Figure 71: |
Figure 72: |
Samples | |
Figure 73: |
Figure 74: |
10 |
Figure 75: |
Figure 76: |
100 |
Figure 77: |
Figure 78: |
869 |
Figure 79: |
Figure 80: |
1000 |
Figure 81: |
Figure 82: |
5000 |
Figure 83: |
Figure 84: |
10000 |
Figure 85: |
|
20000 |
Figure 86: |
|
Figure 87: |
Figure 88: |
Figure 89: |
Samples | |
Figure 90: |
Figure 91: |
10 |
Figure 92: |
Figure 93: |
100 |
Figure 94: |
Figure 95: |
1000 |
Figure 96: |
Figure 97: |
5000 |
Figure 98: |
Figure 99: |
10000 |
Figure 100: |
|
20000 |
Figure 101: |
|
Figure 102: |
Figure 103: |
For notational simplicity, we assume every action is enabled in every state (see App. 7 for the case without this restriction).↩︎
An RMDP \(\mathcal{M}_R\) is graph-preserving if each induced MDP \(\mathcal{M}_R[\theta]\) has the same graph. For \(\widehat\mathcal{M}\), we can ensure graph-preservation (with the specified confidence budget) by using sufficiently many samples to satisfy 1.↩︎