Abstract
Verifying the termination of probabilistic programs is a critical challenge in formal methods. While classical programs require termination on all paths, probabilistic programs are often analyzed for Almost-Sure Termination (AST)—the property that a program terminates with probability 1. Previous modular verification techniques, specifically the FHV-rule, were widely believed to be sound for this purpose. However, recent research has exposed fundamental flaws in these rules. This paper presents a new, sound framework for modular AST verification using Descent Supermartingales (DSMs), enabling efficient and reliable analysis of complex, nested probabilistic loops.
Introduction
In the realm of probabilistic programming, randomness is used to model uncertainty, sensor noise, or randomized algorithms. Proving that such programs eventually finish is not a matter of absolute certainty but of probability. A program satisfies Almost-Sure Termination (AST) if the probability of it running forever is zero.
To handle large-scale software, researchers employ modular verification, which decomposes a program into smaller components (like individual loops) to be analyzed in isolation. For years, the community relied on extensions of classical logic to the probabilistic domain. This work reveals that the most prominent of these extensions, the FHV-rule, is unsound, potentially validating programs that may never terminate.
The Flaw in Previous Modular Rules
The core issue with previous modular rules lies in how they handle "ranking functions"—mathematical measures intended to decrease as a program executes. The FHV-rule attempted to extend classical ranking functions to "Ranking Supermartingales." However, these rules failed to strictly enforce non-negativity or sufficient decrease conditions across modular boundaries.
The authors demonstrate this unsoundness through a counterexample: a 1D random walk with exponentially increasing step sizes. While the old rule suggests this program terminates, it actually possesses a non-zero probability of diverging to infinity. This discovery necessitated a complete rethink of how modularity should be handled in probabilistic verification.
Descent Supermartingales (DSMs)
To restore soundness, the researchers introduced Descent Supermartingales (DSMs). Unlike traditional approaches that require ranking functions to remain non-negative, DSMs allow values to become negative, provided they satisfy two critical properties:
- Strict Decrease: The expected value of the DSM must decrease by at least a fixed positive constant at every execution step.
- Difference-Boundedness: The change in the DSM's value during any single step must be bounded by a constant.
By applying Hoeffding’s Inequality, the authors prove that the existence of a DSM implies that the probability of the program running for $n$ steps decays exponentially as $n$ increases, thereby guaranteeing AST.
Automated Synthesis and Modularity
A significant advantage of the DSM framework is its compatibility with automated synthesis. The program is first transformed into a Control Flow Graph (CFG), where nodes represent program locations and edges represent transitions (assignments or guards).
Using Farkas' Lemma, the program's logic is converted into a system of linear constraints. This allows the verification problem to be solved efficiently using standard Linear Programming (LP) solvers. Because DSMs are label-dependent, the analysis is naturally modular: an inner loop can be verified independently, and its termination properties can then be treated as a single "step" in the analysis of the outer loop.
Experimental Results
The DSM-based approach was evaluated on a benchmark suite of 31 probabilistic programs, including network protocols and randomized algorithms, as well as complex nested loops.
- Soundness: The tool correctly identified non-terminating counterexamples that previous rules failed to catch.
- Efficiency: Most programs were verified in under 2 seconds, demonstrating that modularity significantly reduces the computational overhead compared to global analysis.
- Flexibility: The method successfully handled programs where variables could become arbitrarily large or negative, a common failure point for non-negative martingale methods.
Conclusion
The introduction of Descent Supermartingales provides a robust and sound foundation for the modular verification of probabilistic programs. By replacing the flawed FHV-rule with a framework based on difference-boundedness and strict decrease, researchers can now verify complex, nested loops with high confidence and speed. Future work will focus on extending this synthesis to non-linear ranking functions and integrating these techniques into interactive theorem provers.
Summary updated