Abstract
We study the problem of bounding the posterior distribution of discrete probabilistic programs with unbounded support, loops, and conditioning. Loops pose the main difficulty in this setting: even if exact Bayesian inference is possible, the state of the art requires user-provided loop invariant templates. By contrast, we aim to find guaranteed bounds, which sandwich the true distribution. They are fully automated, applicable to more programs and provide more provable guarantees than approximate sampling-based inference. Since lower bounds can be obtained by unrolling loops, the main challenge is upper bounds, and we attack it in two ways. The first is called residual mass semantics, which is a flat bound based on the residual probability mass of a loop. The approach is simple, efficient, and has provable guarantees. The main novelty of our work is the second approach, called geometric bound semantics. It operates on a novel family of distributions, called eventually geometric distributions (EGDs), and can bound the distribution of loops with a new form of loop invariants called contraction invariants. The invariant synthesis problem reduces to a system of polynomial inequality constraints, which is a decidable problem with automated solvers. If a solution exists, it yields an exponentially decreasing bound on the whole distribution, and can therefore bound moments and tail asymptotics as well, not just probabilities as in the first approach. Both semantics enjoy desirable theoretical properties. In particular, we prove soundness and convergence, i.e. the bounds converge to the exact posterior as loops are unrolled further. On the practical side, we describe Diabolo, a fully-automated implementation of both semantics, and evaluate them on a variety of benchmarks from the literature, demonstrating their general applicability and the utility of the resulting bounds.
Introduction
Probabilistic programming allows developers to build complex models that incorporate randomness and observed data through conditioning. However, performing Bayesian inference—calculating the "posterior" distribution after seeing data—is notoriously difficult, especially when programs contain loops. Current approaches typically fall into two categories: exact inference, which is often mathematically impossible for unbounded loops without manual templates, and approximate inference (like MCMC), which provides stochastic estimates without hard guarantees on error.
This paper introduces a middle ground: guaranteed bounds. These are deterministic results that define a range $[lower, upper]$ where the true probability mass, expected value, or tail behavior is guaranteed to reside.
As shown in the comparison above, our proposed methods—Residual Mass Semantics and Geometric Bound Semantics—fill critical gaps in the literature, particularly regarding automation and the ability to bound moments and tail asymptotics.
Methodology
Residual Mass Semantics
This "flat" bounding approach serves as a baseline. Lower bounds are obtained by unrolling a loop a finite number of times. The "residual mass"—the probability mass that hasn't yet exited the loop—is used to create a coarse upper bound. While simple, it is highly efficient and provides provable guarantees.
Geometric Bound Semantics
To achieve tighter bounds and understand tail behavior, we introduce two core innovations:
- Eventually Geometric Distributions (EGDs): A novel abstract domain where a distribution behaves arbitrarily for small values but is guaranteed to decay geometrically (exponentially) beyond a certain threshold.
- Contraction Invariants: A new form of loop invariant. By proving that each loop iteration reduces the probability mass by a factor $c < 1$, we can derive an exponential upper bound on the entire distribution.
The synthesis of these invariants is reduced to solving a system of polynomial inequality constraints, making the process fully automated through numerical solvers like IPOPT.
Implementation and Results
We implemented these methods in Diabolo, a tool written in Rust, and evaluated it on 43 benchmarks from established research tools (Polar, Prodigy, PSI) and real-world protocols.
Key results from our evaluation include:
- Performance: Diabolo achieved speedups of $10^2$ to $10^5$ times over previous state-of-the-art tools like GuBPI.
- Applicability: The tool successfully found bounds for 86% of the benchmarks. Failures were primarily limited to programs with infinite expected running times.
- Tightness: For many classic problems, such as the "die paradox," the bounds on expected values were extremely tight (e.g., within $10^{-6}$ of the true value).
- Convergence: We proved that as loops are unrolled further, these bounds are guaranteed to converge toward the exact posterior distribution.
Conclusion and Future Work
Diabolo provides a powerful, automated framework for taming the uncertainty of probabilistic loops. While currently restricted to discrete, non-negative integer variables, the success of EGDs suggests a path forward. Future work will explore extending this logic to the integers ($\mathbb{Z}$) and continuous distributions to support a broader range of probabilistic programming applications.
Summary updated