Lexicographic Ranking Supermartingales with Lazy Lower Bounds

Toru Takisaka, Libo Zhang, Changjiang Wang, Jiamou Liu · DOI

TL;DR

This paper introduces a more flexible way to prove that probabilistic programs eventually finish (almost-sure termination). By relaxing the strict "non-negativity" requirements usually needed for mathematical proofs of termination, the authors developed Lazy LexRSMs, a new framework that can automatically verify a wider variety of complex, nested programs than previous state-of-the-art methods.

What Problem Does This Paper Address?

Verifying that a program will eventually terminate is a fundamental challenge in computer science. For non-probabilistic programs, we use Ranking Functions (RFs)—functions that map program states to values that decrease with every step but can never drop below zero. If the value is always decreasing but has a floor, the program must eventually stop.

When programs have nested loops or multiple "phases," we use Lexicographic RFs, which return a vector of values (like a countdown timer showing hours, minutes, and seconds).

However, things get messy with probabilistic programs (programs that use random numbers). Here, we use Ranking Supermartingales (RSMs), where the value decreases on average (in expectation). The "negativity" problem is the big hurdle: in a probabilistic world, if a ranking function is allowed to go negative, a program might "cheat" by diving into infinitely deep negative values to satisfy the "average decrease" rule without ever actually stopping. This is known as "ill exploitation" of negativity. To prevent this, previous methods enforced very strict non-negativity rules, which unfortunately made them unable to prove termination for many valid programs.

Methods

The authors bridge the gap between flexible non-probabilistic proofs and rigid probabilistic ones through three key contributions:

  1. Fixability: They developed a theoretical "litmus test" called $\epsilon$-fixability. If you can take a potentially negative ranking function and "fix" it by capping all negative values at a constant floor ($-\epsilon$) without breaking the mathematical rules of the proof, then the original function is sound.
  2. Lazy LexRSM (LLexRSM): They proposed a new class of ranking functions that allows "harmless" negativity. The "Lazy" part comes from a stability at negativity condition: once a specific dimension of the ranking vector goes negative, it must stay negative until that entire phase of the program is finished. This prevents the "cheating" behavior mentioned earlier.
  3. Automated Synthesis: To make this useful for engineers, they created an algorithm that uses Linear Programming (LP) and Farkas’ Lemma to automatically find these LLexRSMs. They introduced a subclass called MCLC (Multiple-Choice Leftward Condition) that turns complex program logic into linear constraints that solvers like CPLEX can handle efficiently.

Datasets

The authors evaluated their approach using a benchmark suite of 135 programs derived from 55 different models. These included:

  • Standard non-probabilistic termination benchmarks.
  • Probabilistic modifications of those benchmarks (e.g., changing a fixed loop into a probabilistic one like while x < 5 do (if prob(0.5) then P else skip)).
  • Programs with "well-behaved" random distributions (like Uniform or Normal distributions).

Key Insights and Ideas

  • Negativity isn't always "ill": The paper distinguishes between "ill exploitation" (using negative values to fake progress) and "harmless" negativity (where a value goes negative simply because the "floor" hasn't been reached yet in a specific program path).
  • Redundancy in Prior Work: Surprisingly, the authors proved that a condition previously thought necessary for soundness (expected leftward non-negativity) is actually redundant for linear programs. This simplifies the search space for proofs.
  • Robustness to Translation: Their method is more robust to how a program is translated into a control-flow graph. Previous methods would sometimes fail if the same program logic was structured slightly differently; LLexRSM handles these variations more gracefully.

Key Results

The authors compared their new algorithms (SMC and EMC) against two baselines: STR (Strongly non-negative) and LWN (Leftward non-negative).

  • Higher Success Rate: SMC/EMC successfully proved termination for 119 out of 135 cases.
  • Outperforming Baselines: The new method had a 15.6% higher success rate than the STR baseline and a 10.4% higher success rate than the LWN baseline.
  • Efficiency: In most cases, the synthesis algorithm returned a result within a single second, making it practical for automated verification tools.
  • New Capabilities: The method successfully verified programs like speedDis1, which feature complex variable updates that previous state-of-the-art tools simply couldn't handle.

Limitations and Future Work

  • Linearity: The current synthesis algorithm is limited to programs with linear arithmetic. Extending this to non-linear programs (e.g., those with $x^2$ or $x \cdot y$) remains a challenge.
  • Well-Behaved Distributions: The proof of soundness currently relies on "well-behaved" probability distributions (where the "tails" of the distribution disappear quickly). While this covers most common distributions (Normal, Uniform, etc.), it might not cover "heavy-tailed" distributions.
  • Completeness: While the "Exhaustive" (EMC) version of their algorithm is mathematically complete, it is slow. The faster "Singleton" (SMC) version works great in practice, but the authors haven't yet proven if it will always find a solution if one exists.

Summary updated

BibTeX
@inproceedings{takisaka2024lexicographic,
  author = {Toru Takisaka and Libo Zhang and Changjiang Wang and Jiamou Liu},
  title = {{Lexicographic Ranking Supermartingales with Lazy Lower Bounds}},
  booktitle = {CAV},
  year = {2024},
  doi = {10.1007/978-3-031-65633-0\_19},
}
Figure