Solving #SAT and Bayesian Inference with Backtracking Search

Fahiem Bacchus, Shannon Dalmao, Toniann PitassiJAIR 2009 · DOI

Abstract

Inference in Bayesian Networks (BAYES) and counting the number of satisfying assignments for a propositional formula (#SAT) are fundamental problems in artificial intelligence with wide-ranging applications. Both belong to the class of sum-of-products (SUMPROD) problems. This paper demonstrates that standard backtracking search, when augmented with a component caching mechanism, provides a unified framework for solving any SUMPROD problem. We prove that this approach, #DPLL-Cache, achieves time complexity at least as good as state-of-the-art exact algorithms like Variable Elimination and Recursive Conditioning. Furthermore, by utilizing flexible dynamic variable orderings, backtracking can achieve an exponential speedup over static-order algorithms on certain problem instances. We also discuss a variant that achieves the best known time-space tradeoff, providing a robust solution for memory-constrained environments.

Introduction: The SUMPROD Problem Class

Many critical tasks in automated reasoning and probabilistic inference can be framed as "Sum-of-Products" (SUMPROD) problems. This class includes #SAT, the task of counting satisfying assignments for a Boolean formula, and Bayesian Inference, the calculation of posterior probabilities in a graphical model.

While standard SAT (deciding if a formula is satisfiable) is NP-complete, #SAT and Bayesian Inference are #P-complete, making them significantly more challenging. Traditionally, these problems were solved using Variable Elimination (VE) or Recursive Conditioning (RC). These algorithms typically rely on a fixed "elimination order" or a static decomposition of the problem graph. However, a static order that works well for one part of the search space may be highly inefficient for another.

Methodology: #DPLL with Component Caching

The authors propose a framework based on the Davis-Putnam-Logemann-Loveland (DPLL) backtracking algorithm, enhanced with two key features:

  1. Component Caching (#DPLL-Cache): During the search, if setting a variable causes the remaining formula to split into independent sub-problems (components), the algorithm solves them separately. The results of these sub-problems are stored in a cache. If the same sub-problem is encountered again later in the search, the result is retrieved instantly rather than recomputed.
  2. Dynamic Variable Ordering: Unlike Variable Elimination, which follows a rigid sequence, backtracking can choose the next variable to branch on dynamically based on the current state of the formula. This allows the algorithm to exploit the problem's structure more effectively in real-time.
Figure 1: A hierarchical decomposition of a problem instance into independent sub-components, illustrating the structure used for caching results.

Theoretical Dominance and Simulation

A core contribution of this work is the theoretical comparison between #DPLL-Cache and existing methods. The authors prove a Simulation Theorem: #DPLL-Cache can polynomially simulate both Variable Elimination and Recursive Conditioning. This means that for any problem instance, #DPLL-Cache is guaranteed to be at least as efficient as these traditional methods, given a comparable variable ordering.

More importantly, the paper proves that the reverse is not true. Because #DPLL-Cache can use dynamic orderings, there are specific problem instances—such as the "String-of-Pearls" construction—where any static-order algorithm like VE will take exponential time, while #DPLL-Cache can solve them in polynomial time. This establishes backtracking with caching as a theoretically superior paradigm for exact inference.

Complexity and Practical Implementation

The complexity of #DPLL-Cache is bounded by the structural properties of the problem's interaction graph. Specifically, the authors show the algorithm runs in $n^{O(1)}2^{O(w)}$ time, where $w$ is the branch width of the problem. This matches the best known theoretical bounds for exact inference while providing the flexibility to outperform those bounds in practice.

For environments where memory is a limiting factor, the authors introduce #DPLL-Space, a variant that offers a linear space complexity. This allows for a controlled time-space tradeoff, ensuring that the algorithm can still function effectively even when the cache cannot fit in main memory.

Conclusion

By bridging the gap between SAT-based backtracking and probabilistic inference, this paper provides a rigorous foundation for modern solvers. The principles discussed here have been implemented in state-of-the-art systems like Cachet, which have demonstrated superior empirical performance across various benchmarks. The ability to dynamically adapt to problem structure through backtracking and caching remains a cornerstone of efficient exact inference in AI.

Summary updated

BibTeX
@article{bacchus2009solving,
  author = {Fahiem Bacchus and Shannon Dalmao and Toniann Pitassi},
  title = {{Solving \#SAT and Bayesian Inference with Backtracking Search}},
  journal = {J. Artif. Intell. Res.},
  year = {2009},
  doi = {10.1613/jair.2648},
}
Figure