Approximate Counting in SMT and Value Estimation for Probabilistic Programs

Dmitry Chistikov, Rayna Dimitrova, Rupak Majumdar

TL;DR

This paper tackles the challenging problem of "model counting" in Satisfiability Modulo Theories (SMT), which generalizes tasks like counting satisfying assignments of Boolean formulas and computing volumes of geometric shapes. The authors introduce a novel approach that reduces approximate model counting to standard SMT solving, enabling the analysis of probabilistic programs.

What Problem Does This Paper Address?

The core problem is #SMT, which involves counting the number of solutions (models) for a given logical formula within a specific theory (like integer or real arithmetic). This is a computationally hard problem (#P-complete), meaning exact solutions are likely infeasible for large instances. #SMT has practical applications in areas like quantitative information flow and static analysis of probabilistic programs. Existing methods for #SMT are often exponential or lack provable guarantees. The authors aim to develop efficient approximate #SMT solvers that provide formal bounds on their error, leveraging the power of modern SMT solvers.

Methods

The paper's main contribution is a reduction from approximate #SMT to standard SMT solving. They achieve this by extending the hashing approach commonly used in #SAT to the SMT context. This involves:

  • Measured Theories: A formal framework to define model counting for various theories by equipping variable domains with measures.
  • Randomized Algorithms: The core algorithms are randomized and rely on an SMT solver as an oracle.
  • Approximate Model Counting: For integer arithmetic, they provide a randomized algorithm that approximates the model count within a multiplicative error $(1+\epsilon)$ using a polynomial number of SMT queries. For linear real arithmetic, they achieve an additive error $\gamma N$ (where $N$ is an upper bound on the volume).
  • Probabilistic Program Analysis: They show how to reduce the problem of estimating the "value" of a probabilistic program (the probability of acceptance given termination) to #SMT. This allows them to use their approximate #SMT techniques for program analysis.

Datasets

Not discussed in the paper. The paper focuses on theoretical algorithms and their application to general probabilistic programs and logical theories, rather than specific datasets.

Key Insights and Ideas

  • Leveraging SMT Solvers: The key insight is that sophisticated, off-the-shelf SMT solvers can be used as "oracles" to perform approximate counting. This "lazy" approach avoids explicitly encoding complex #SMT problems into simpler ones like #SAT, which might lose valuable structure.
  • Hashing for Approximation: The hashing technique, proven effective for #SAT, is generalized to SMT. This allows for probabilistic approximation with provable error bounds by reducing the problem to a series of satisfiability checks.
  • Unified Framework for Probabilistic Programs: The paper provides a unified way to model and analyze probabilistic programs by reducing their value estimation to model counting problems in SMT. This bridges the gap between program analysis and formal verification techniques.
  • Trade-off between Exactness and Efficiency: The authors demonstrate that approximate solutions can be obtained efficiently, with formal guarantees on the approximation error, which is often sufficient for practical applications.

Key Results

  • Theorems for Approximate #SMT: The paper presents Theorem 1 and Theorem 2, which provide polynomial-time randomized algorithms for approximate model counting in bounded integer arithmetic (multiplicative error) and linear real arithmetic (additive error), respectively, using SMT oracles.
  • Value Estimation for Probabilistic Programs: Proposition 2 and Theorem 4 establish that the value problem for loop-free probabilistic programs is #P-complete and can be approximated using their #SMT techniques.
  • Experimental Evaluation: The authors implemented their algorithm on top of the Z3 SMT solver and evaluated it on several examples, including the Monty Hall problem and Bayesian networks. Table 2 and Table 3 show the input parameters and running times, demonstrating the feasibility of their approach. For instance, the Monty Hall problem was solved with an approximation factor $\epsilon=0.2$ and error probability $\alpha=0.01$.

Limitations and Future Work

  • Scalability: The authors acknowledge that scalability is a major challenge, particularly with the increasing number of XOR constraints introduced by the hashing technique. They suggest incorporating XOR-aware reasoning into SMT solvers as a crucial step.
  • Theories: While the techniques are demonstrated for integer and linear real arithmetic, extending them to other theories (e.g., string constraints) remains an open area.
  • Distributions: The current model primarily supports uniform distributions. Incorporating non-uniform distributions as a primitive would enhance expressiveness.
  • Approximate Synthesis: The paper focuses on verification (computing the value of a given program). Extending their work to "approximate synthesis" (finding a program that achieves a desired value) is suggested as future work.
  • Monte Carlo vs. Hashing: The paper discusses the complementary nature of Monte Carlo methods and their hashing-based approach, noting that Monte Carlo excels in "regular" settings (non-vanishing probabilities) while hashing is better for "singular" settings (probabilities close to zero). Future work might explore hybrid approaches.

Summary updated

BibTeX
@inproceedings{chistikov2015approximate,
  author = {Dmitry Chistikov and Rayna Dimitrova and Rupak Majumdar},
  title = {{Approximate Counting in SMT and Value Estimation for Probabilistic Programs}},
  booktitle = {TACAS},
  year = {2015},
  doi = {10.1007/978-3-662-46681-0\_26},
}
Figure