Fairness in Ranking Supermartingales

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

Abstract

Lexicographic Ranking SuperMartingale (LexRSM) is a probabilistic extension of Lexicographic Ranking Function (LexRF), a widely accepted technique for verifying program termination. This paper proposes sound probabilistic extensions of LexRF with a weaker non-negativity condition, called single-component (SC) non-negativity. We introduce the notion of fixability to analyze the soundness of possibly negative LexRSM and propose Lazy LexRSM for automated verification. Our synthesis algorithm, based on linear programming, demonstrates improved success rates over existing benchmarks.

The Challenge of Probabilistic Termination

Verifying that probabilistic programs eventually stop—known as almost-sure termination—is a notoriously difficult task. In deterministic verification, Ranking Functions (RFs) are used: functions that decrease at each step but are bounded below by zero. For probabilistic programs, Ranking Supermartingales (RSMs) are employed, requiring a decrease only in expectation.

Lexicographic versions (LexRSM) handle programs with multiple phases or nested loops by using vectors instead of single numbers. The "holy grail" of LexRSM is the single-component (SC) non-negativity condition. This is the weakest possible constraint, making it the most flexible for proof generation. However, simply applying SC non-negativity to probabilistic programs was previously considered unsound, as it could lead to false proofs of termination for programs that actually run forever.

Methods: Fixability and Lazy LexRSM

To bridge the gap between theoretical flexibility and soundness, the authors introduce two key concepts:

  1. Fixability: A theoretical framework that determines if a ranking function remains sound even if it temporarily takes negative values. It asks if capping negative values at a small constant would still satisfy the ranking condition.
  2. Lazy LexRSM (LLexRSM): A practical implementation utilizing "stability at negativity." If a component of the ranking vector becomes negative, it must remain negative until that program phase concludes. This prevents the "ill" exploitation of unbounded negative values to satisfy expectation requirements.
Comparison of non-negativity conditions for ranking vectors.

The hierarchy of non-negativity conditions is illustrated above. While Strong (ST) and Leftward (LW) conditions require multiple components to be non-negative, the SC condition significantly reduces these requirements, easing the automated synthesis process.

Illustrative Example and Synthesis

The authors developed an automated synthesis algorithm that converts these requirements into linear constraints using Farkas’ Lemma, solvable via standard Linear Programming (LP).

Example of a probabilistic program with its associated ranking vectors (η) and invariants.

The figure above demonstrates a probabilistic program with nested control flow. The ranking vectors (η) are synthesized for each location (ℓ1 to ℓ5), ensuring that the expected decrease holds across random assignments (e.g., Unif[1,2]). This "Lazy" approach allows certain values to go negative temporarily without compromising the termination proof.

Experimental Evaluation

The approach was evaluated against 135 benchmarks, including modifications of the "speedDis1" suite and specific counterexamples designed to challenge existing methods.

  • Success Rate: The "Lazy" algorithms (SMC and EMC) successfully verified 119 cases, representing a 15.6% higher success rate over the standard Strong (98) and Leftward (105) baselines.
  • Performance: Synthesis typically completed in under one second, demonstrating that the more flexible mathematical framework does not compromise computational efficiency.
  • Robustness: The method proved resilient to different control-flow graph translations, making it more practical for integration into real-world compilers.

Conclusion

This work establishes a sound foundation for using single-component non-negativity in probabilistic program verification. By introducing Lazy LexRSM, the authors have expanded the range of programs that can be automatically proven to terminate. Future research will focus on extending these techniques to non-linear arithmetic and exploring the impact of heavy-tailed probability distributions on the proof of soundness.

Summary updated

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