Adaptive Shielding via Parametric Safety Proofs

Yao Feng, Jun Zhu, André Platzer, Jonathan Laurent

Abstract

Reinforcement learning (RL) agents often struggle with deployment in safety-critical environments due to their inherent "black-box" nature. While traditional shielding techniques provide safety guarantees by overriding unsafe actions with pre-proven fallbacks, they are frequently over-conservative, relying on worst-case assumptions that hinder performance. This paper introduces a framework for adaptive shielding, which utilizes parametric safety proofs and a novel statistical inference language to allow shields to become more permissive as an agent gathers data. By shifting complex safety analysis offline while enabling online model refinement, the framework provides rigorous, end-to-end probabilistic safety guarantees without sacrificing real-time performance.

Introduction

Reinforcement learning has demonstrated remarkable potential in domains ranging from robotics to autonomous driving. However, the lack of formal guarantees makes RL agents dangerous for real-world deployment. To mitigate this, researchers employ shielding—a runtime monitoring system that ensures an agent remains within a "sandbox" of safe states. If an agent proposes an action that could lead to a violation, the shield overrides it with a safe fallback, such as emergency braking.

Despite their utility, traditional shields are often static and conservative. Because they rely on fixed models of the physical world, they must assume worst-case scenarios—such as maximum track slipperiness for a train—at all times. While online methods can update these models, they often struggle to maintain formal safety proofs or incur computational costs too high for real-time control. This research addresses these limitations by proposing a framework where safety models are parametric, allowing the shield to adapt its restrictiveness based on gathered evidence.

Methodology

The proposed framework decouples the heavy lifting of formal verification from the real-time execution of the agent, utilizing a three-tiered approach to safety.

1. Parametric Differential Dynamic Logic (dL)

The framework models hybrid systems—those combining discrete software logic with continuous physical motion—using Parametric Differential Dynamic Logic (dL). Unlike standard models that use fixed constants for environmental variables (e.g., friction, slope, or intruder behavior), these models use variables with defined bounds. These bounds can be refined at runtime as the agent observes its environment.

2. Inference Strategy DSL

To manage how these parameters are updated, the authors designed a domain-specific language (DSL) for inference strategies. This DSL allows experts to define how noisy observations should be translated into model updates. A key feature is the AGGREGATE construct, which utilizes statistical tail inequalities (such as Gaussian or Hoeffding bounds) to ensure that parameter updates are mathematically sound with a high probability (e.g., $1 - 10^{-7}$).

3. Separation of Concerns and Soundness

The framework establishes a clear division of labor:

  • The Expert defines the safety model and the sound inference strategy.
  • The Framework automatically generates formal proof obligations to verify the strategy's mathematical soundness.
  • The Agent learns an inference policy via RL, determining how to best "spend" its safety budget—for instance, deciding which sensors to prioritize to gain the most environmental freedom.

This structure ensures soundness by construction. Even if the RL agent’s inference policy is suboptimal or malicious, the underlying dL proof obligations prevent the shield from entering an unsafe state.

Case Studies and Evaluation

The framework was evaluated across four simulated environments, each presenting unique uncertainty challenges:

  • Sisyphean Train: A train navigating hills with unknown, varying slopes.
  • Versatile Train: A meta-learning scenario where the agent must adapt to new track topologies in every episode.
  • Crossing the River: A robot requiring "active sensing" (e.g., using a lamp) to locate a bridge, balancing energy costs against safety requirements.
  • Revisiting ACAS X: A collision avoidance scenario where the agent infers whether an intruder aircraft is compliant or adversarial.

Key Results

The experimental results highlight the efficacy of adaptive shielding:

  • Provable Safety: Shielded agents encountered zero crashes during both training and testing phases, whereas unshielded agents crashed hundreds of times.
  • Performance Gains: Adaptive shields significantly outperformed static ones. By refining environmental models, the agents achieved higher returns (e.g., faster arrival times) as the shield became less restrictive over time.
  • Active Sensing: Agents naturally learned to seek knowledge. In the "Crossing the River" case, the agent learned to move toward the river and activate its lamp specifically to gather data needed to "unlock" a faster, more permissive shield.
  • Efficiency: Despite the formal verification layer, runtime overhead remained below 15%, making it suitable for real-time applications. Furthermore, the authors used the KeYmaera X theorem prover to automate 27 out of 32 proof obligations.

Conclusion and Future Work

Adaptive shielding via parametric safety proofs offers a path toward deploying RL in high-stakes environments without the performance penalties of traditional, static safety monitors. By treating safety as a "budget" that can be spent on statistical inference, the framework allows agents to safely explore and optimize their behavior.

Future work aims to reduce the reliance on human experts for writing initial dL models and to automate complex proof obligations, such as loop invariants for physics models. Additionally, the authors suggest exploring the integration of reachability analysis to handle more complex, non-linear dynamics in future iterations of the framework.

Summary updated

BibTeX
@article{feng2025adaptive,
  author = {Yao Feng and Jun Zhu and André Platzer and Jonathan Laurent},
  title = {{Adaptive Shielding via Parametric Safety Proofs}},
  journal = {Proc. ACM Program. Lang.},
  year = {2025},
  doi = {10.1145/3720450},
}
Figure