Almost-Sure Termination for Probabilistic Program Inference and Verification

This direction is merged into another direction: quantitative termination analysis. Its last version stays readable and citable here.

Version 1 of 114 papers25 conceptsfrozen 2026-10-04

In traditional programming, a program that doesn't terminate is a bug. In probabilistic programming, a program that doesn't terminate is a mathematical catastrophe.

When we write probabilistic programs—scripts that describe random processes to perform Bayesian inference—we often rely on the assumption of almost-sure termination (AST). This is the guarantee that the program will finish with probability one. While this sounds like a simple safety property, recent research shows that AST is the bedrock upon which the validity of modern inference algorithms and verification tools is built.

The Hidden Requirement for Inference

Modern inference frameworks like Nonparametric Hamiltonian Monte Carlo (NP-HMC) and Nonparametric Involutive Markov Chain Monte Carlo (NP-iMCMC) are designed to handle "universal" models where the number of random variables isn't fixed. For example, a model might recursively generate new data points until a certain condition is met.

As Carol Mak, Fabian Zaiser, and Luke Ong demonstrate, these algorithms work by "lazily" extending the dimensions of the parameter space as the program executes. However, this mechanism has a critical dependency: if there is a non-zero chance that the program enters an infinite loop, the state space extension may never converge. Without AST, the mathematical foundations of trans-dimensional jumps—the very thing that allows us to sample from complex, recursive models—collapse, making it impossible to guarantee a valid posterior estimate.

Why Average Decrease is Not Enough

Proving that a probabilistic program terminates is harder than it looks. A common intuition is that if a program variable (like a counter) decreases on average in every step, the program must eventually hit zero and stop.

However, Mingzhang Huang, Krishnendu Chatterjee, and their colleagues point out a "drifting" flaw in this logic in Compositional Analysis for Almost-Sure Termination of Probabilistic Programs. If the random steps are not bounded, a program can actually drift toward infinity even if its average trend is downward.

To solve this, they introduced Descent Supermartingales (DSMs). The intuition is to combine a "ranking function" (which tracks progress) with a "bounded step" requirement. By ensuring that the expected decrease is strict and the potential "jumps" away from the goal are limited, they prove that the probability of the program continuing for $n$ steps decays exponentially. This modular approach allows researchers to verify termination even in complex, nested loops that were previously unprovable.

Termination as a Prerequisite for Safety

The importance of AST extends beyond inference into the realm of formal verification. When we want to know the probability that a program will crash or violate an assertion, we often model these probabilities as "fixed points" of mathematical functions.

In Quantitative Analysis of Assertion Violations in Probabilistic Programs, Jinyi Wang and Amir Kafshdar Goharshady show that while we can always find an upper bound for failure probabilities, finding a lower bound is only possible if the program is guaranteed to terminate.

Think of it this way: if a program might run forever, the "missing" probability mass from the executions that never finish makes it impossible to pin down the exact likelihood of a violation. AST ensures that the "least fixed point" of the system is unique, allowing researchers to derive bounds that are thousands of orders of magnitude tighter than previous statistical estimates.

Reliability at the Edges

The quest for guaranteed termination even affects fundamental sampling building blocks. In Multiparameter Bernoulli Factories, Jon Schneider and Renato Paes Leme address how classic sampling procedures often fail at the "edges" of probability (when inputs are exactly 0 or 1).

By redesigning these "factories" to guarantee termination across the entire domain, they enable the creation of robust software systems. This highlights the broader trend in the field: moving away from "usually works" heuristics toward mathematically rigorous frameworks where termination is a proven property rather than an optimistic assumption.

Papers in this version

History & citationVersion 1 · 2026-10-04

Merged into another direction · Permanent link

View frozen version 1

Cite this direction

Latest version (a living page):

@misc{lacuna_almost_sure_termination_for_probabilisti_6c21fb3c,
  title = {Almost-Sure Termination for Probabilistic Program Inference and Verification},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/almost-sure-termination-for-probabilistic-program-inference-and-verification/rdr_6c21fb3c483b4facb775637c81c32794},
  note = {Latest version of a living research direction; cite a version for a fixed text. Accessed 2026-11-28},
}

This exact version (version 1, frozen text):

@misc{lacuna_almost_sure_termination_for_probabilisti_6c21fb3c_v1,
  title = {Almost-Sure Termination for Probabilistic Program Inference and Verification},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/almost-sure-termination-for-probabilistic-program-inference-and-verification/rdr_6c21fb3c483b4facb775637c81c32794/v/1},
  note = {Version 1, frozen 2026-10-04. Accessed 2026-11-28},
}