Abstract
Propositional model counting (#SAT) is a fundamental problem in computer science with applications ranging from probabilistic reasoning to circuit synthesis. However, the problem is #P-complete, making exact counting intractable for large-scale formulas. This paper presents ApproxMC, the first approximate model counter that provides rigorous $(\epsilon, \delta)$ guarantees while scaling to formulas with tens of thousands of variables. By utilizing XOR-based hashing to partition the solution space and leveraging modern SAT solvers, ApproxMC bridges the gap between theoretical algorithms and practical performance.
Introduction
The problem of propositional model counting, or #SAT, asks for the number of satisfying assignments for a given Boolean formula. While the decision problem (SAT) is NP-complete, the counting problem is significantly more difficult, belonging to the complexity class #P-complete. This complexity has historically limited the use of #SAT in practical applications like planning and multi-agent systems.
Existing approaches to #SAT generally fall into two categories: exact counters and approximate counters. Exact counters provide a perfect count but fail to scale beyond relatively small formulas. Approximate counters have traditionally been split between theoretical algorithms that offer formal $(\epsilon, \delta)$ guarantees but are too slow for practical use, and heuristic counters that are fast but offer no mathematical bounds on their accuracy. ApproxMC addresses this divide, offering a scalable solution that maintains rigorous theoretical guarantees.
Methodology: Hashing-Based Partitioning
The core innovation of ApproxMC is its use of hashing-based partitioning to estimate the size of the solution space. The algorithm follows a multi-step process to reduce a massive counting problem into a series of manageable SAT queries.
1. Slicing the Solution Space
ApproxMC employs 3-wise independent XOR hash functions to randomly partition the set of all possible satisfying assignments into smaller "cells." The goal is to divide the space until a single cell contains a small, countable number of solutions.
2. The Small Cell Strategy
Rather than counting all solutions at once, the algorithm adds XOR constraints to the formula until the number of solutions in a resulting cell falls below a specific threshold, referred to as the pivot. Once a cell is small enough, a standard SAT solver can enumerate the solutions within that cell exactly. The total count is then estimated by multiplying the count of the single cell by the total number of cells created by the hashing process.
3. Optimization and Robustness
To improve efficiency and reliability, ApproxMC incorporates several key techniques:
- The Median Trick: To ensure high confidence (the $\delta$ parameter), the algorithm repeats the estimation process multiple times and returns the median of the results. This prevents outliers from skewed random partitions from affecting the final estimate.
- Leap-frogging: To avoid redundant computation, the algorithm uses a heuristic to estimate the initial number of hashes required based on previous successful iterations, significantly speeding up the search for a "small" cell.
- XOR-Friendly Solving: Because XOR constraints are difficult for traditional Conflict-Driven Clause Learning (CDCL) solvers, ApproxMC utilizes CryptoMiniSAT, a solver specifically optimized for formulas containing both CNF clauses and XOR constraints.
Experimental Evaluation
The authors evaluated ApproxMC against a suite of over 200 benchmarks across diverse domains, including grid networks, plan recognition, circuit synthesis, and logistics. The benchmarks ranged in scale from 32 variables to over 229,000 variables.
Scalability
ApproxMC demonstrated a significant leap in scalability compared to exact counters. It successfully computed counts for benchmarks containing up to 33,000 variables. In contrast, the exact counter Cachet timed out after 20 hours on many of these same instances.
Accuracy
While the theoretical error bound was set at $\epsilon = 0.75$, the empirical performance was much stronger. On benchmarks where exact counts were available for comparison, the observed $L_1$ relative error was only 0.033 (3.3%). This suggests that the theoretical bounds are highly conservative and that the algorithm performs exceptionally well in practice. Furthermore, ApproxMC provided significantly tighter intervals than existing bounding counters like MBound or SampleCount for the same confidence levels.
Conclusion and Future Work
ApproxMC represents a major milestone in model counting, providing the first practical implementation of an $(\epsilon, \delta)$ approximate counter. By combining the mathematical rigor of hashing-based partitioning with the efficiency of modern SAT solvers, it enables the analysis of formulas previously considered unreachable.
Future research directions include extending these hashing techniques to Satisfiability Modulo Theories (SMT) and more complex probabilistic inference tasks. Additionally, while ApproxMC handles tens of thousands of variables, further optimizations are needed to address the "33k wall" and scale to the largest industrial benchmarks involving hundreds of thousands of variables.
Summary updated