Quantitative analysis of assertion violations in probabilistic programs

Jinyi Wang, Yican Sun, Hongfei Fu, Krishnendu Chatterjee, Amir Kafshdar Goharshady

TL;DR

This paper tackles the challenge of calculating the probability that a probabilistic program will violate a given assertion (e.g., crash, time out, or compute erroneously). The authors introduce novel fixed-point theorems and automated algorithms to derive both upper and lower bounds for these probabilities. Notably, their approach yields bounds that are up to thousands of orders of magnitude tighter than previous methods, providing a massive leap forward in the quantitative analysis of probabilistic programs.

What Problem Does This Paper Address?

Probabilistic programs—which extend standard code with the ability to sample random values—are ubiquitous in machine learning, robotics, and network analysis. A fundamental question when analyzing these programs is: What is the probability that a specific assertion is violated? For example, what are the chances a randomized algorithm takes longer than 500 steps, or a program running on unreliable hardware fails?

Historically, researchers relied on concentration inequalities or automata-based approaches to find upper bounds for these probabilities. However, these methods often yield loose bounds and generally cannot compute lower bounds. The authors address this gap by proposing a completely automated framework to synthesize remarkably tight upper and lower bounds for assertion violation probabilities.

Methods

The authors pivot away from traditional concentration inequalities and instead frame the problem using fixed-point theory. They define a "probability transformer function" and prove that the assertion violation probability is its least fixed-point.

From this theoretical foundation, they develop three automated algorithms to synthesize exponential bounds (which are ideal for probabilities that decrease drastically as variables change):

  1. A Sound Polynomial-Time Algorithm (Upper Bounds): This method synthesizes Repulsing Ranking Supermartingales (RepRSMs) and applies Hoeffding’s lemma to generate exponentially decreasing upper bounds.
  2. A Complete Algorithm (Upper Bounds): For affine programs (where updates and guards are linear), they use Minkowski decomposition and a custom quantifier elimination procedure to translate the problem into a convex optimization task. This algorithm is complete, meaning it is guaranteed to find a near-optimal exponential template if one exists.
  3. A Lower-Bound Algorithm: By assuming the program almost-surely terminates (terminates with probability 1), they reduce the lower-bound problem to finding a post fixed-point. They use Jensen’s inequality to relax exponential constraints into linear ones, allowing them to solve it efficiently via Linear Programming.

Datasets

The authors evaluated their algorithms on a variety of classic probabilistic programming benchmarks drawn from existing literature. These are categorized into:

  • Deviation: Programs where the goal is to bound the probability of a variable deviating from its expected value (e.g., RdAdder, Robot).
  • Concentration: Programs analyzing the probability of not terminating within a given number of steps (e.g., Coupon, Prspeed, Rdwalk).
  • StoInv (Stochastic Invariants): Random walk models (e.g., 1DWalk, 2DWalk, 3DWalk, Race).
  • Hardware: Programs simulating execution on unreliable hardware that might fail at any step (e.g., M1DWalk, Newton, Ref).

Key Insights and Ideas

  • Fixed-points unlock both bounds: By characterizing the violation probability as a fixed point, the authors can use pre fixed-points to establish upper bounds and post fixed-points to establish lower bounds. This unified theoretical view is much more flexible than prior ad-hoc statistical methods.
  • Completeness via Convex Optimization: The realization that finding the optimal exponential upper bound for affine programs can be exactly translated into a convex optimization problem is a major breakthrough. It bridges the gap between abstract program verification and highly efficient, solvable math.
  • Lower bounds require termination guarantees: To ensure their lower bounds are mathematically sound, the authors rely on the "almost-sure termination" assumption. If a program is guaranteed to eventually stop, the fixed-point is unique, allowing post fixed-points to safely act as lower bounds.

Key Results

  • Shattering Previous Upper Bounds: The complete algorithm (Section 5.2) consistently and significantly outperformed previous methods. The improvement ratio ranged from a modest 1.07x tighter to an astonishing $1.3 \times 10^{2069}$ times tighter (on the 3DWalk benchmark).
  • Highly Efficient: Despite the theoretical worst-case complexity of Minkowski decomposition, the complete algorithm solved every single benchmark in under 1.72 seconds.
  • Pioneering Lower Bounds: The authors provided the first automated algorithm for lower bounds. On the Ref hardware benchmark, their automated lower bounds beat previous manually-derived bounds by a factor of 3.33 to 4.66.

Limitations and Future Work

The authors acknowledge a few limitations:

  • Scope of bounds: The algorithms specifically target exponential bounds over affine/polynomial programs. They do not currently synthesize other mathematical forms.
  • Termination assumption: The lower-bound algorithm strictly requires the probabilistic program to terminate with probability 1. If the program can run infinitely with a non-zero probability, the lower-bound theorem does not hold.
  • Theoretical trade-offs: The complete algorithm is not guaranteed to run in polynomial time (even though it is fast in practice), while the polynomial-time algorithms are not strictly complete.

For future work, the authors suggest exploring more expressive forms of bounds beyond exponential templates, and developing compositional verification methods to scale these analyses to even larger, more complex probabilistic systems.

Summary updated

BibTeX
@inproceedings{wang2021quantitative,
  author = {Jinyi Wang and Yican Sun and Hongfei Fu and Krishnendu Chatterjee and Amir Kafshdar Goharshady},
  title = {{Quantitative analysis of assertion violations in probabilistic programs}},
  booktitle = {PLDI},
  year = {2021},
  doi = {10.1145/3453483.3454102},
}
Figure