Introduction
In the field of Boolean Satisfiability (SAT), while finding a single solution is a well-studied problem, two related tasks remain significantly more challenging: Uniform Generation (selecting a solution at random such that all solutions have an equal probability) and Model Counting (determining the total number of solutions). These tasks are essential for applications in hardware verification and probabilistic reasoning.
Historically, researchers have faced a trade-off between heuristic methods, which are fast but lack guarantees, and theoretical algorithms, which offer perfect guarantees but fail on large-scale problems. This work introduces UniWit and ApproxMC, two algorithms that bridge this gap by leveraging limited-independence hashing to handle formulas with tens of thousands of variables.
Methodology: The Hashing Trick
The core innovation of these algorithms is the use of limited-independence hashing via random XOR constraints. By adding constraints such as $x_1 \oplus x_3 \oplus x_7 = 0$, the algorithm partitions the solution space into smaller "cells." With the correct number of constraints, a single cell contains a manageable number of solutions that can be processed by a standard SAT solver.
UniWit (Sampling)
UniWit is an evolution of the BGP algorithm. It utilizes pairwise or 3-wise independent hash functions, which are significantly faster than the $n$-wise independence required by earlier theoretical frameworks. Additionally, it introduces a "pivot" reduction technique, decreasing the number of solutions required for enumeration in a cell from $n^2$ to $n^{1/k}$, thereby accelerating the sampling process.
ApproxMC (Counting)
ApproxMC estimates the total number of solutions by repeatedly partitioning the space until a "small" cell is found. The solutions in this cell are counted exactly, and the result is scaled by the number of cells. To ensure high confidence and accuracy, the algorithm takes the median of multiple runs (a "median-of-means" approach), which allows for exponential confidence boosting with only linear increases in runtime. The algorithm also employs a "leapfrogging" heuristic, using initial runs to estimate the optimal number of XOR constraints for subsequent iterations, preventing redundant computation.
Evaluation and Results
The algorithms were evaluated on over 200 benchmarks, including hardware verification designs and standard circuit benchmarks (ISCAS'85), with test cases ranging from 32 to over 229,000 variables.
Key Findings
- Scalability: ApproxMC successfully computed counts for benchmarks with up to 33,000 variables, whereas exact counters like Cachet timed out on much smaller instances.
- Accuracy: Despite a theoretical error tolerance of 75% ($\epsilon = 0.75$), the observed error in practice was approximately 4%.
- Performance: UniWit outperformed previous state-of-the-art tools like XORSample'. In comparative tests, UniWit successfully identified all solutions in complex cases where previous methods showed significant bias or missed solutions entirely.
Conclusion and Future Directions
The success of UniWit and ApproxMC demonstrates that "near-uniform" generation and approximate counting can be achieved in polynomial time relative to a SAT oracle. Future work includes addressing the increased hardness of SAT problems when XOR constraints are added, potentially through "low-density" XORs. Additionally, extending these techniques to handle Satisfiability Modulo Theories (SMT) directly and incorporating weighted sampling for real-world probabilistic models remain key areas for research.
Summary updated