LyZNet: A Lightweight Python Tool for Learning and Verifying Neural Lyapunov Functions and Regions of Attraction

Jun Liu, Yiming Meng, Maxwell Fitzsimmons, Ruikun Zhou

Abstract

In this paper, we describe a lightweight Python framework that provides integrated learning and verification of neural Lyapunov functions for stability analysis. The proposed tool, named LyZNet, learns neural Lyapunov functions using physics-informed neural networks (PINNs) to solve Zubov's equation and verifies them using satisfiability modulo theories (SMT) solvers. What distinguishes this tool from others in the literature is its ability to provide verified regions of attraction close to the domain of attraction. This is achieved by encoding Zubov's partial differential equation (PDE) into the PINN approach. By embracing the non-convex nature of the underlying optimization problems, we demonstrate that in cases where convex optimization, such as semidefinite programming, fails to capture the domain of attraction, our neural network framework proves more successful. The tool also offers automatic decomposition of coupled nonlinear systems into a network of low-dimensional subsystems for compositional verification. We illustrate the tool's usage and effectiveness with several numerical examples, including both non-trivial low-dimensional nonlinear systems and high-dimensional systems. The repository of the tool can be found at https://git.uwaterloo.ca/hybrid-systems-lab/lyznet.

Introduction

In engineering—from power grids to robotics—ensuring that a system returns to a stable state after a disturbance is paramount. This "safe zone" is formally known as the Region of Attraction (ROA). The standard approach to proving stability involves finding a Lyapunov function, a mathematical construct that decreases along system trajectories. However, finding these functions for complex, nonlinear systems is notoriously difficult. Traditional methods like Sum-of-Squares (SOS) rely on convex optimization and polynomials, which often produce overly conservative estimates of the ROA and struggle with non-polynomial dynamics.

Methods: Learning and Verification

LyZNet introduces a "learn-then-verify" pipeline to overcome these limitations.

Learning via PINNs

Instead of searching for any function satisfying stability inequalities, LyZNet uses Physics-Informed Neural Networks (PINNs) to solve Zubov’s Equation. This partial differential equation (PDE) characterizes the exact boundary of the Domain of Attraction (DOA). By encoding Zubov's PDE into the neural network's loss function, the model learns a "maximal" Lyapunov function that closely approximates the true stability boundary.

The learned Lyapunov function (left) and its corresponding level sets (right) for a nonlinear system.

Formal Verification and Compositionality

To ensure mathematical rigor, LyZNet uses Satisfiability Modulo Theories (SMT) solvers (specifically dReal) to formally verify that the learned function meets Lyapunov requirements. To handle the "curse of dimensionality" in high-dimensional systems, the tool can automatically decompose a large system into smaller, interconnected subsystems, verifying each piece to prove the stability of the whole.

Key Results

LyZNet was evaluated on several benchmarks, demonstrating significant improvements over traditional SOS methods.

  • Van der Pol Oscillator: In a high-stiffness scenario ($μ=3.0$), LyZNet verified a safe zone covering 85.21% of the domain, compared to 70.93% for a 6th-degree SOS polynomial.
  • Power Systems: For a two-machine power system, LyZNet achieved a verified volume of 82.34%, while SOS managed only 18.53%.
Comparison of level sets for a complex system, where LyZNet (blue) captures a significantly larger verified region than traditional SOS methods (red dashed).
  • Scalability: The tool successfully verified a 10D system using compositional techniques in under 25 seconds, a task that timed out after 12 hours using a monolithic approach.

Discussion and Future Work

LyZNet demonstrates that the non-convex nature of neural network training can find superior stability proofs where convex methods fail. While currently reliant on interval-based SMT solvers which can be conservative, the tool includes local verifiers to mitigate numerical artifacts. Future developments will focus on automating system decomposition, leveraging GPU acceleration for training, and extending the framework to simultaneous controller design and stability verification.

Summary updated

Abstract

In this paper, we describe a lightweight Python framework that provides integrated learning and verification of neural Lyapunov functions for stability analysis. The proposed tool, named LyZNet, learns neural Lyapunov functions using physics-informed neural networks (PINNs) to solve Zubov's equation and verifies them using satisfiability modulo theories (SMT) solvers. What distinguishes this tool from others in the literature is its ability to provide verified regions of attraction close to the domain of attraction. This is achieved by encoding Zubov's partial differential equation (PDE) into the PINN approach. By embracing the non-convex nature of the underlying optimization problems, we demonstrate that in cases where convex optimization, such as semidefinite programming, fails to capture the domain of attraction, our neural network framework proves more successful. The tool also offers automatic decomposition of coupled nonlinear systems into a network of low-dimensional subsystems for compositional verification. We illustrate the tool's usage and effectiveness with several numerical examples, including both non-trivial low-dimensional nonlinear systems and high-dimensional systems. The repository of the tool can be found at https://git.uwaterloo.ca/hybrid-systems-lab/lyznet.
BibTeX
@inproceedings{liu2024lyznet,
  author = {Jun Liu and Yiming Meng and Maxwell Fitzsimmons and Ruikun Zhou},
  title = {{LyZNet: A Lightweight Python Tool for Learning and Verifying Neural Lyapunov Functions and Regions of Attraction}},
  booktitle = {Hscc},
  year = {2024},
  doi = {10.1145/3641513.3650134},
}
Figure