NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

New Approaches for Almost-Sure Termination of Probabilistic Programs

Mingzhang Huang, Hongfei Fu, Krishnendu Chatterjee

Abstract

Verifying the termination of probabilistic programs is a fundamental challenge in formal methods. While traditional techniques focus on finite expected termination, many programs terminate with probability 1 despite having infinite expected running times. This paper introduces two novel frameworks for proving Almost-Sure Termination (AST): a refined supermartingale approach incorporating a Lower Bound on Conditional Absolute Difference (LBCAD) and a method leveraging the Central Limit Theorem (CLT) for incremental loops. These approaches provide the first optimal tail bounds for such programs and enable the verification of algorithms previously considered beyond the reach of automated tools.

Introduction

In software verification, the Halting Problem takes on a unique dimension when applied to probabilistic programs—code that incorporates stochasticity through random assignments or branching. For these programs, we evaluate Almost-Sure Termination (AST), which asks whether the probability that a program eventually stops is exactly 1.

Historically, the primary tool for proving AST has been the Ranking Supermartingale (RSM). An RSM is a function of the program state that, on average, decreases at each step. However, standard RSMs are often limited to proving finite expected termination time. This is a stricter condition than AST; for example, a symmetric 1D random walk terminates with probability 1 but has an infinite expected termination time. Furthermore, existing methods often require program variables to be bounded below, a constraint that many real-world stochastic processes do not satisfy.

Proposed Methodologies

1. Supermartingales with LBCAD

The authors extend the supermartingale framework by introducing the Lower Bound on Conditional Absolute Difference (LBCAD). Traditional ranking functions require a steady average decrease toward a termination threshold. In contrast, the LBCAD condition requires that the "distance-to-exit" function maintains a minimum level of "vibration" or variance ($\delta$) at each step.

This insight is crucial: for AST, a program does not necessarily need to move closer to the exit on every step, provided it remains sufficiently dynamic. The LBCAD ensures the system does not settle into a state where it is technically active but practically stagnant, thereby guaranteeing that it will eventually hit the termination condition.

2. The CLT-Based Approach

For programs involving "incremental" loops—where variables are updated by independent and identically distributed (i.i.d.) samples—the authors propose a framework based on the Central Limit Theorem (CLT). This represents a significant conceptual shift from analyzing step-by-step transitions to analyzing the long-term aggregate distribution of program variables.

The CLT approach is particularly powerful because it can handle programs where variables lack a global lower bound. By focusing on the long-term trend of the distribution, the authors can prove termination even when a variable may wander deep into negative territory before eventually returning to trigger a termination condition.

3. Algorithmic Automation

To make these theoretical frameworks practical, the paper details an automation strategy using "templates." These are pre-defined functional forms for distance functions with unknown coefficients. By applying the LBCAD or CLT conditions, the verification problem is reduced to finding valid coefficients, which can be solved efficiently using standard optimization techniques such as Linear Programming (LP).

Key Results and Insights

Optimal Tail Bounds

A major contribution of this work is the derivation of optimal "tail bounds," which quantify the probability that a program is still running after $k$ steps. The authors establish that for "difference-bounded" programs, the probability of non-termination decreases at a rate of $O(1/\sqrt{k})$. For more general program structures, they establish a bound of $O(k^{-1/6})$. These represent the first explicit, optimal bounds for these classes of probabilistic programs.

Empirical Validation

The frameworks were evaluated against synthetic benchmarks and classic stochastic models, including:

  • Symmetric Random Walks: Demonstrating the ability to prove AST where expected termination time is infinite.
  • Incremental Loops: Verifying programs with complex sampling distributions (e.g., two-sided geometric distributions) that lack lower bounds and were previously unverifiable by state-of-the-art tools.

Limitations and Future Work

While the paper advances the state of the art, several challenges remain:

  • Nested Loops: The current methodology is optimized for single loops or sequences of loops. Truly nested structures often violate the independence or non-negativity assumptions required by these proofs.
  • Continuous State Spaces: While the logic is expected to hold for real-valued variables, the current proofs focus on integer-valued variables to avoid the technical complexities of measurability in continuous spaces.
  • Non-determinism: The CLT approach currently assumes independence between steps. Extending this to handle "demonic" non-determinism—where an adversary chooses the worst-case transition—remains an open problem.

Conclusion

By introducing the LBCAD condition and leveraging the Central Limit Theorem, this research provides a more robust mathematical foundation for verifying probabilistic software. These methods not only expand the class of programs that can be formally verified but also provide rigorous quantitative guarantees on their termination behavior.

Summary updated

BibTeX
@inproceedings{huang2018new,
  author = {Mingzhang Huang and Hongfei Fu and Krishnendu Chatterjee},
  title = {{New Approaches for Almost-Sure Termination of Probabilistic Programs}},
  booktitle = {APLAS},
  year = {2018},
  doi = {10.1007/978-3-030-02768-1\_11},
}
Figure