StochasticBarrier.jl: A Toolbox for Stochastic Barrier Function Synthesis

Rayan Mazouz, Frederik Baymler Mathiesen, Luca Laurenti, Morteza LahijanianarXiv 2026 · arXiv

TL;DR

StochasticBarrier.jl is a new open-source Julia toolbox designed for the safety verification of discrete-time stochastic systems. By synthesizing Stochastic Barrier Functions (SBFs), it provides formal lower bounds on safety probabilities for linear, polynomial, and piecewise affine systems. Benchmarks show it outperforms existing state-of-the-art tools by up to three orders of magnitude in speed while delivering significantly tighter safety bounds and scaling to higher-dimensional systems.

What Problem Does This Paper Address?

Ensuring safety in autonomous systems—like robotics, self-driving cars, and unmanned aerial vehicles—is challenging due to inherent environmental noise and unpredictable dynamics. Traditional verification methods require propagating system uncertainty over time, which quickly becomes computationally intractable.

Stochastic Barrier Functions (SBFs) offer an elegant alternative. They use martingale theory to establish a static set of constraints that guarantee a lower bound on the probability of a system remaining safe over a given time horizon. However, existing tools for SBF synthesis suffer from severe limitations: they are often embedded in slower interpreted languages like MATLAB or Python, scale poorly to higher dimensions, or are restricted to low-degree polynomial systems. This paper introduces StochasticBarrier.jl to bridge this gap, providing a fast, scalable, and versatile toolbox for researchers and engineers.

Methods

StochasticBarrier.jl leverages Julia’s high-performance compiled nature and multiple dispatch system to implement two primary classes of SBF synthesis:

  1. Sum-of-Squares (SOS) Optimization: This traditional approach models the barrier function as a multivariate polynomial, transforming the verification problem into a Semi-Definite Program (SDP) solved via commercial solvers like Mosek. The toolbox uniquely extends this to support Piecewise Affine (PWA) inclusion dynamics, allowing it to bound and verify complex, non-polynomial nonlinear systems.
  2. Piecewise Constant (PWC) Functions: This newer approach partitions the safe state space into a grid (hyper-rectangles) and assumes a constant barrier value within each region. This reduces the optimization problem to a Linear Program (LP). StochasticBarrier.jl includes three distinct backend engines for PWC synthesis:
  3. Dual LP: An exact, duality-based approach.
  4. CEGIS LP: A Counter-Example Guided Inductive Synthesis method that alternates between generating candidate barriers and finding worst-case distribution witnesses.
  5. Projected Gradient Descent (GD): A highly scalable minimax formulation that minimizes a convex loss function, bypassing the memory bottlenecks of traditional LP solvers.
Table 1. Overview of SBF synthesis methods implemented in StochasticBarrier.jl for different classes of dynamics.

Datasets

The toolbox was evaluated using a comprehensive benchmark suite of over 30 case studies across 8 distinct dynamical systems. These systems span various dimensions and dynamics types:

  • Linear Systems: Contraction Maps (2D), Two-Tank System (2D), Room Temperature Control (3D), and a Quadrotor model (6D).
  • Polynomial Systems: A Thermostat model (1D) and the Van der Pol Oscillator (2D).
  • PWA Inclusion Systems: A Pendulum with a Neural Network Dynamical Model (2D) and a Unicycle model (4D).

Key Insights and Ideas

  • Language Matters for Verification: Moving from MATLAB (SOSTOOLS) or Python (PRoTECT) to Julia yields massive performance gains. Julia's native support for parametric typing allows customizable numerical precision, which is crucial when bridging high-level synthesis algorithms to low-level optimization solvers.
  • PWC Outperforms SOS on Nonlinearities: For highly nonlinear or hybrid systems (like the unicycle model), traditional polynomial SOS methods often fail to find non-trivial safety bounds. Piecewise Constant (PWC) barriers consistently deliver meaningful safety probabilities where SOS fails entirely.
  • Gradient Descent Scales Better Than LPs: As the state-space partition grid grows finer, traditional LP solvers run out of memory. The newly implemented Projected Gradient Descent engine provides a memory-efficient alternative that computes valid safety bounds rapidly, even with high partition counts.

Key Results

  • Speedup: StochasticBarrier.jl is up to 1000× faster than its closest competitor, PRoTECT, for successful SOS synthesis.
  • Tighter Bounds: In several complex benchmarks where older tools yielded a trivial safety probability bound of 0, StochasticBarrier.jl successfully proved a safety probability of up to 1.0.
  • Scalability: The toolbox successfully verified a 6-dimensional quadrotor model, effectively doubling the dimensionality limits of existing discrete-time SBF tools. It also scales efficiently to high-degree SOS barriers (up to degree 30).

Limitations and Future Work

The primary limitation of the current release is its strict focus on additive Gaussian noise. While Gaussian noise is standard in many engineering applications, real-world systems often exhibit non-Gaussian or non-additive (state-dependent) disturbances. The authors note that future extensions of StochasticBarrier.jl will focus on incorporating these more complex noise distributions to broaden the toolbox's practical applicability.

Summary updated

Abstract

We present StochasticBarrier.jl, an open-source Julia-based toolbox for generating Stochastic Barrier Functions (SBFs) for safety verification of discrete-time stochastic systems with additive Gaussian noise. StochasticBarrier.jl certifies linear, polynomial, and piecewise affine (PWA) systems. The latter enables verification for a wide range of system dynamics, including general nonlinear types. The toolbox implements a Sum-of-Squares (SOS) optimization approach, as well as methods based on piecewise constant (PWC) functions. For SOS-based SBFs, StochasticBarrier.jl leverages semi-definite programming solvers, while for PWC SBFs, it offers three engines: two using linear programming (LP) and one based on gradient descent (GD). Benchmarking StochasticBarrier.jl against the state-of-the-art shows that the tool outperforms existing tools in computation time, safety probability bounds, and scalability across over 30 case studies. Compared to its closest competitor, StochasticBarrier.jl is up to four orders of magnitude faster, achieves significant safety probability improvements, and supports higher-dimensional systems.
BibTeX
@misc{mazouz2026stochasticbarrier,
  author = {Rayan Mazouz and Frederik Baymler Mathiesen and Luca Laurenti and Morteza Lahijanian},
  title = {{StochasticBarrier.jl: A Toolbox for Stochastic Barrier Function Synthesis}},
  year = {2026},
  eprint = {2602.20359},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2602.20359},
}

Loading related content...

Figure