Abstract
This paper presents a novel framework for addressing model counting (#SAT) and uniform sampling by leveraging generalized algebraic structures. By "lifting" basic selective semirings into extended forms, the authors demonstrate that complex inference problems can be solved using standard, "black-box" tensor network contraction algorithms. Their implementation, MCSSE, proves competitive with specialized state-of-the-art solvers, highlighting the power of pushing algorithmic complexity into the underlying algebra.
Introduction
In computational logic and inference, problem complexity typically scales from decision (satisfiability) to optimization (finding the best solution), and finally to counting and sampling (determining the number of solutions or generating a random one). While frameworks like Marginalize a Product Function (MPF) effectively handle decision and optimization tasks—powering applications from Kalman filters to SAT solvers—counting and sampling have traditionally required highly specialized, complex algorithms.
The primary challenge is the lack of a unified, "plug-and-play" algebraic approach. Currently, a solver designed for finding a single satisfying assignment for a Boolean formula cannot easily be adapted to count all such assignments (#SAT) without significant architectural changes. This paper bridges that gap by proposing a method to solve these harder problems using existing tensor contraction machinery.
Methodology: Selective Semiring Extensions
The authors' approach treats inference problems as tensor hypernetwork contractions over a semiring—a set of values equipped with "addition" (for aggregation) and "multiplication" (for combination) operations. The core innovation lies in the Selective Semiring Extension.
Lifting and Selective Semirings
Selective semirings are those where the addition operation always selects one of its inputs (e.g., the max operation). The authors provide a mathematical template to "lift" these basic semirings into more complex ones. For instance, by combining a semiring that identifies a maximum value with the standard sum-product semiring of integers, the resulting extended semiring can simultaneously track the optimal value and the total number of ways to achieve it.
Uniform Sampling via Probabilistic Aggregation
To enable uniform sampling without the memory explosion associated with enumerating all solutions, the authors implement "probabilistic aggregation." During the tensor contraction process, when the algorithm must choose between paths, it makes a random selection weighted by the model counts calculated in previous steps. This ensures that the final output is a truly uniform random sample produced in a single pass.
Because the underlying problem structure (the tensor network) remains unchanged, the authors can utilize highly optimized "black-box" contraction algorithms, such as opt_einsum, to process the lifted queries.
Evaluation and Results
The authors evaluated their implementation, MCSSE, against two major benchmarks: 200 Boolean formulas from the 2022 Model Counting Competition and 773 Conjunctive Normal Form (CNF) formulas for sampling.
Model Counting Performance
MCSSE proved competitive with specialized tools like SharpSAT-TD and D4. On several non-trivial instances, the tensor-based approach was faster, suggesting that it can contribute to improving the "virtual best solver"—the aggregate performance of the best available tools for any given instance.
Sampling Speedups
In sampling benchmarks, MCSSE outperformed the popular WAPS sampler on 293 out of 591 instances. On these specific cases, MCSSE was 49.5 times faster on average. This performance gain is largely attributed to MCSSE's ability to avoid the expensive "knowledge compilation" phase required by tools like WAPS.
Discussion and Future Work
While powerful, the current approach has limitations. For very small problems, the overhead of constructing the tensor network and determining the optimal contraction order can exceed the time needed for direct solving. Furthermore, the current use of dense tensors limits the scale of problems that can be handled due to memory constraints.
Future work will focus on transitioning to sparse tensor formats to handle larger, real-world formulas and optimizing the implementation using lower-level languages or GPU acceleration. By shifting the focus from specialized algorithms to robust algebraic data types, this research opens new avenues for leveraging decades of progress in tensor network optimization for complex logical inference.
Summary updated