Abstract
Proving termination in probabilistic programs requires finding a Ranking Supermartingale (RSM), a task traditionally handled by brittle symbolic tools. This paper presents a novel machine learning framework that synthesizes Neural RSMs (NRSMs) from execution traces. By combining a neural network learner with an SMT-based verifier in a Counterexample-Guided Inductive Synthesis (CEGIS) loop, the approach successfully verifies complex non-linear programs that elude state-of-the-art analytical methods.
Introduction
In formal verification, proving that a program will eventually halt is a fundamental challenge. For probabilistic programs—which incorporate randomness in branching or assignments—the goal is often to prove Positive Almost-Sure Termination (PAST). This guarantees that the expected number of execution steps is finite.
The standard proof technique involves finding a Ranking Supermartingale (RSM). An RSM is a non-negative function of the program state that decreases in expectation at each step. While existing tools attempt to synthesize RSMs directly from source code using constraint solving, they often fail when faced with non-linear arithmetic, complex probability distributions (e.g., Cauchy), or state-dependent parameters.
Methodology: The CEGIS Framework
The proposed method decouples the discovery of an RSM from its formal verification using a two-phase approach integrated into a Counterexample-Guided Inductive Synthesis (CEGIS) loop.
1. The Learner (Guessing)
Instead of analyzing source code syntax, an interpreter executes the program to generate transition samples. A neural network, termed a Neural RSM (NRSM), is trained on these traces. The training objective uses a custom loss function to penalize states where the network's output does not decrease across transitions.
To satisfy the mathematical requirement that an RSM must be bounded from below (non-negative), the authors employ specific network architectures. As shown in the NRSM architecture diagram, the function $\eta(x)$ is constructed as a sum of functions $f$, such as a Sum of ReLUs (SOR) or Sum of Squares (SOS). This architectural constraint ensures non-negativity by construction, simplifying the subsequent verification task.
2. The Verifier (Checking)
Once a candidate NRSM is trained, it is passed to a symbolic verifier. The program logic and the NRSM are translated into logical formulas for an SMT solver (Z3). The solver attempts to prove that the NRSM's expected value decreases across all possible valid state transitions. If the solver finds a state where this property fails, it provides a counterexample. This counterexample is fed back into the interpreter to generate more targeted training data, and the loop repeats.
Key Results and Insights
The framework demonstrates significant advantages over traditional syntax-based tools:
- Syntax Agnosticism: By learning from numerical traces, the model is indifferent to the mathematical complexity of the program's source code.
- Superior Performance on Complex Benchmarks: The method successfully verified 12 highly complex programs featuring non-linearities and multivariate distributions that state-of-the-art tools like AMBER and ABSYNTH could not process.
- Efficiency: On standard benchmarks (WTC suite), the tool achieved near 100% success, often finding a valid proof in the first iteration (0 CEGIS loops) within seconds.
Conclusion and Future Work
This research highlights the power of "guessing" via machine learning and "checking" via formal methods. While highly effective, the current prototype requires manual intervention for marginalizing continuous distributions and can struggle with extremely rare program transitions. Future work aims to automate these processes and extend the framework to non-termination proofs and concurrent systems.
Summary updated