Formally Verifying Deep Reinforcement Learning Controllers with Lyapunov Barrier Certificates

Udayan Mandal, Guy Amir, Haoze Wu, Ieva Daukantas, Fletcher Lee Newell, Umberto J. Ravaioli, Baoluo Meng, Michael Durling, Milan Ganai, Tobey Shim, Guy Katz, Clark W. Barrett

This paper presents a significant step forward in the formal verification of Deep Reinforcement Learning (DRL) controllers, particularly for safety-critical systems like autonomous spacecraft. By combining neural networks with classical control theory, the authors provide a scalable way to prove that an agent will both stay safe and eventually reach its goal.

TL;DR

The authors introduce a framework for formally verifying DRL controllers using Compositional Neural Lyapunov Barrier (NLB) certificates. By breaking down complex state spaces into a sequence of simpler, "filtered" certificates, they successfully provide safety and liveness guarantees for a spacecraft docking task that was previously beyond the reach of automated verification tools.

What Problem Does This Paper Address?

Deep Reinforcement Learning is excellent at solving complex control problems, but it produces "black box" models. In safety-critical domains—like autonomous driving or aerospace—we need formal guarantees that these models won't fail.

Traditional formal verification (like unrolling a neural network over many time steps) struggles with "reactive" systems where an agent interacts with an environment over long periods. The state space explodes, and the verification task becomes computationally impossible. While Lyapunov Barrier functions offer a theoretical way to prove long-term behavior (safety and liveness) without unrolling time, they are notoriously difficult to design manually for complex, non-linear systems.

Methods

The authors propose three key innovations to make neural certificates practical:

  1. Filtered Reach-While-Avoid (FRWA) Certificates: Instead of forcing a neural network to learn the entire certificate function from scratch, they use "filters." They hard-code the certificate's values for known goal and unsafe regions. This "wrapper" approach simplifies the training process and reduces the number of queries the verification engine needs to process.
  2. Compositional Certificates (CRWA): This is the "divide and conquer" strategy. Rather than training one massive certificate for a huge starting region, the authors train a sequence of certificates. Each one guides the system from a larger region into a smaller "safe" region handled by the next certificate in the chain, eventually reaching the final goal.
  3. CEGIS Loop (Counterexample-Guided Inductive Synthesis): The framework uses an iterative loop (see Figure 1). A controller and certificate are trained together; a formal verifier (Marabou) then searches for counterexamples. If one is found, it's added to the training data, and the models are refined until no more violations exist.
Fig. 1: The CEGIS Loop used to iteratively train and verify controller π and certificate V . Verification counterexamples are used to augment the training dataset.

Datasets

The primary benchmark is a 2D Spacecraft Docking Task.

  • Dynamics: Based on the Clohessy-Wiltshire equations, which model relative orbital motion.
  • Challenge: The deputy spacecraft must dock with a chief spacecraft (liveness) while obeying a non-linear, distance-dependent velocity constraint (safety).
  • Complexity: The system exhibits highly non-linear spiral trajectories (see Figure 3), making simple inductive proofs difficult.
Fig. 3: A spiral trajectory: The DRL-controlled spacecraft (starting from the red point) eventually reaches the destination (orange) point within the docking region.

Key Insights and Ideas

  • Verification-Aware Training: By training the controller jointly with the certificate, the agent learns a policy that is inherently easier to prove safe.
  • The Power of Composition: The compositional approach (CRWA) effectively sidesteps the scalability limits of DNN verifiers. It allows the team to verify initial regions that are orders of magnitude larger than what standalone methods can handle.
  • Filtering as a Heuristic: Hard-coding boundary conditions (filtering) acts as a powerful inductive bias, preventing the neural network from "wandering" into invalid certificate values during training.

Key Results

The experiments compared standard RWA certificates against the new FRWA and compositional CRWA methods:

  • FRWA vs. RWA: FRWA was significantly more robust. For a starting region of $[-2, 2]$, FRWA had a 100% success rate in producing a verified certificate, while standard RWA failed in every trial.
  • Scalability: Standalone certificates (even with filtering) timed out after 12 hours when the starting region exceeded $[-3, 3]$. In contrast, the compositional approach (CRWA) successfully verified a 5-stage certificate for a massive $[-11, 11]$ region in just 5.7 hours.
  • Efficiency: As shown in Figure 4, the compositional methods (CFRWA-1, 2, 3) achieved 100% success rates with much lower mean training/verification times compared to standalone attempts on larger regions.
Fig. 4: The first 2 rows show average times and success rates for creating verified certificates over 5 trials. The bottom 2 rows show specific times for each trial, separated into failed (“F- ”) and verified (“V-”) certificates. CFRWA-1, CFRWA-2, and CFRWA-3 refer to the first (up to) three CRWA tasks for the given starting region, corresponding, respectively to the first (up to) three rows for that starting region in Table II.

Limitations and Future Work

  • Manual Decomposition: Currently, the choice of intermediate regions for the compositional chain relies on simple heuristics or manual selection. The authors suggest that automating this decomposition is a promising next step.
  • Controller Size: The study focused on relatively small neural networks (two hidden layers of 20 neurons). Scaling these verification techniques to the much larger architectures common in modern DRL remains a challenge.
  • Integration: The authors plan to explore how this approach can be combined with "shielding" techniques, which provide runtime safety layers for DRL agents.

This work demonstrates that while DRL controllers may be "black boxes," we are developing the mathematical "flashlights" needed to see inside them and guarantee their safety in the real world.

Summary updated

BibTeX
@misc{mandal2024formally,
  author = {Udayan Mandal and Guy Amir and Haoze Wu and Ieva Daukantas and Fletcher Lee Newell and Umberto J. Ravaioli and Baoluo Meng and Michael Durling and Milan Ganai and Tobey Shim and Guy Katz and Clark W. Barrett},
  title = {{Formally Verifying Deep Reinforcement Learning Controllers with Lyapunov Barrier Certificates}},
  year = {2024},
  eprint = {2405.14058},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2405.14058},
}
Figure