In computational complexity, there is a massive gulf between finding a single solution to a problem and counting how many solutions exist. Finding a satisfying assignment for a logic formula is NP-complete, but counting those assignments (#SAT) is #P-complete—a class generally considered much harder. Similarly, in probabilistic inference, calculating the "partition function" (the sum over all possible states) is often the primary bottleneck for machine learning models.
A powerful research direction has emerged to bridge this gap. By using random parity constraints (XORs) as a form of "hashing," researchers have found ways to reduce these intractable counting problems into a series of standard optimization tasks. This allows us to leverage the incredible speed of modern SAT and Mixed Integer Programming (MIP) solvers to solve problems that were previously thought to be computationally impossible.
The Intuition: Thinning the Search Space
Imagine you are trying to count the number of people in a massive, crowded stadium, but you can only see through a tiny window that fits exactly one person. If you look through the window and see someone, you don't know if there are 10 people or 10,000.
However, suppose you have a way to "filter" the crowd. You ask everyone to flip a coin; if it's tails, they leave. You repeat this $k$ times. If, after 10 rounds of filtering, you still see exactly one person through your window, you can reasonably guess there were originally about $2^{10}$ (1,024) people.
In the digital world, random XOR constraints act as this filter. As shown by Carla P Gomes, Stefano Ermon, Ashish Sabharwal, and Bart Selman in their work on the WISH algorithm, adding $k$ random parity constraints to a problem reduces the number of satisfying solutions by a factor of roughly $2^k$. By repeatedly adding constraints and checking for satisfiability using an "NP oracle" (like a SAT solver), we can pinpoint the magnitude of the solution set.
Folding Counting into Optimization
This hashing technique does more than just count; it allows us to perform complex inference. In many real-world scenarios, we face the Marginal Maximum A Posteriori (MMAP) problem, which involves both maximizing over some variables and summing over others. This "sum-of-max" structure is notoriously difficult.
Yexiang Xue, Stefano Ermon, and colleagues introduced XOR_MMAP, which "folds" the intractable counting subproblems into a single optimization task. By adding XOR constraints, they transform a problem that is theoretically harder than NP into a series of queries that a standard MIP or SAT solver can handle. This shift is transformative: it moves the burden from specialized, often slow inference algorithms to general-purpose optimization engines that have benefited from decades of industrial engineering.
This approach extends even to continuous spaces. Fan Ding and Yexiang Xue developed XOR-SGD, which uses XOR-sampling to replace traditional Markov Chain Monte Carlo (MCMC) methods. Because XOR-sampling uses NP-oracles to jump directly to representative samples, it avoids the "slow mixing" problems that plague MCMC in high-dimensional, multi-modal landscapes.
Projected Counting and Logical Structures
Often, we don't need to count every possible assignment of every variable. We might only care about unique assignments to a specific subset of "important" variables—a task known as projected model counting.
Kuldeep S. Meel has been a central figure in applying these techniques to complex logical structures. For instance, in Counting Maximal Satisfiable Subsets, Jaroslav Bendík and Meel show how to count the largest possible groups of non-contradictory rules in an inconsistent system. They do this by transforming the problem into a projected count over "activation variables" that represent the presence or absence of specific constraints.
Similarly, Mohimenul Kabir, Meel, and Supratik Chakraborty developed sharpASP-SR to count answer sets in logic programming. By using a "subtractive reduction" to turn hard counting into projected counting, they can handle solution sets as large as $2^{127}$, far beyond the reach of traditional tools.
From Theory to 50-Year-Old Puzzles
The power of this paradigm—reducing #P-hard counting to NP-hard SAT queries—is best illustrated by its application to diverse fields:
- Formal Verification: Bernd Finkbeiner and colleagues use these reductions in Model Checking Quantitative Hyperproperties to measure security risks. Instead of asking "Can information leak?", they use Max#Sat to ask "How many bits of information can leak?"
- Recreational Mathematics: In Solving Rep-tile by Computers, Kenji Hashimoto and others used projected model counting to solve a 50-year-old open question about polyomino tiling, finding every possible way a shape can be tiled by smaller versions of itself.
- Complexity Theory: Kuldeep S. Meel and Supratik Chakraborty proved in On the Hardness of Probabilistic Inference Relaxations that while many approximations remain hard, the NP-oracle reduction provides a "sweet spot" that makes these problems practically solvable.
By treating SAT solvers as powerful "black boxes" or oracles, this research direction has turned the theoretical hardness of counting into a practical engineering challenge, enabling us to quantify uncertainty and complexity at scales previously deemed unreachable.