Abstract
Model counting (#SAT) is a fundamental problem in computer science with applications ranging from probabilistic reasoning to formal verification. While exact counting is #P-complete and approximate counting often requires near-impossible uniform sampling, this paper introduces SampleCount. By leveraging biased solution sampling as a heuristic to guide variable fixing, SampleCount provides provably sound, high-confidence lower bounds for formulas that are orders of magnitude beyond the reach of current exact methods.
Introduction
The task of determining the total number of satisfying assignments for a Boolean formula, known as model counting or #SAT, is computationally daunting. It sits in the #P-complete complexity class, making it significantly harder than the NP-complete SAT problem. Existing tools generally fall into two categories: exact counters, which are precise but fail on large problems, and approximate counters, which often rely on the difficult requirement of uniform sampling. SampleCount bridges this gap by providing a scalable method with rigorous probabilistic guarantees.
The SampleCount Algorithm
SampleCount operates through iterative simplification of the input formula. The process begins by using a local search sampler, such as SampleSat, to obtain a set of solutions. A key innovation is that this sampler does not need to be uniform; even biased samples can effectively guide the algorithm.
The algorithm identifies "balanced variables"—those that appear as True in approximately half the samples. This heuristic aims to split the solution space evenly. Once a variable is selected, the algorithm flips a fair coin to fix its value, rather than following the sample frequency. This random choice, combined with a multiplier of 2 for each fixed variable, ensures that the expected value of the count remains equal to the true total count.
By repeating this process until the formula is small enough for an exact counter like Cachet, and applying Markov’s Inequality across multiple runs, SampleCount produces a lower bound that is correct with a user-defined confidence level (e.g., 99%).
Experimental Results
The authors evaluated SampleCount across a diverse set of benchmarks, including circuit synthesis, random k-CNF formulas, Latin squares, and Langford problems.
As shown in the results table, SampleCount excels on massive problems. For the 3bitadd_32 circuit formula, which contains nearly 9,000 variables, exact counters failed to find even one solution within 12 hours. In contrast, SampleCount provided a lower bound of $10^{1339}$ solutions in just 32 minutes. Furthermore, unlike ApproxCount, which can produce wildly inaccurate estimates, SampleCount consistently adhered to its probabilistic guarantees.
Key Insights
A major takeaway is that the correctness of SampleCount's lower bound is independent of the sampler's quality. While a biased sampler might result in a looser bound, it will never produce an invalid (too high) result. This decoupling allows the algorithm to leverage fast, biased local search samplers to "shave off" thousands of variables, leaving a manageable "hard core" for exact counters to solve.
Conclusion
SampleCount represents a significant step forward in model counting. By combining the speed of heuristic sampling with the rigor of probabilistic bounds, it enables the analysis of combinatorial problems previously considered intractable. Future work involves stabilizing the variance of estimates through "bucketing" strategies to provide even tighter lower bounds.
Summary updated