Solving Projected Model Counting by Utilizing Treewidth and its Limits

Johannes K. Fichte, Markus Hecher, Michael Morak, Patrick Thier, Stefan WoltranarXiv 2023

TL;DR

This paper presents a novel algorithm for Projected Model Counting (PMC) that is fixed-parameter tractable with respect to treewidth, proving a tight double-exponential runtime bound under the Exponential Time Hypothesis. To bridge the gap between theory and practice, the authors introduce nested dynamic programming and a database-backed solver, nestHDB, which successfully tackles problem instances with treewidth exceeding 200.

What Problem Does This Paper Address?

At its core, the paper deals with Projected Model Counting (PMC). While standard model counting (#SAT) asks "how many ways can we satisfy this Boolean formula?", PMC asks a more nuanced question: "If we only care about a specific subset of variables (projection variables), how many unique ways can those variables be assigned such that the rest of the formula remains satisfiable?"

This is significantly harder than standard counting—theoretically, it jumps from #P-complete to the even more daunting #·NP-complete class. PMC is vital for applications where auxiliary variables are used for encoding but aren't part of the final result, such as in reliability estimation, Bayesian reasoning, and automated planning. The challenge is that traditional algorithms struggle as the "treewidth" (a measure of how tree-like a graph is) of the problem increases.

Methods

The authors approach the problem from two angles: theoretical limits and practical implementation.

1. The Theoretical Algorithm

They propose a multi-pass dynamic programming (DP) algorithm that operates on a tree decomposition (TD) of the formula's primal graph.

  • Pass 1: Solves standard SAT to find partial models.
  • Pass 2: Uses the inclusion-exclusion principle to count unique projected models by traversing the TD again. The resulting runtime is $O(2^{2^{k+4}} n^2)$, where $k$ is the treewidth. Crucially, they use the Exponential Time Hypothesis (ETH) to prove that this double-exponential dependency on $k$ is likely unavoidable for any treewidth-based PMC algorithm.

2. Nested Dynamic Programming & Hybrid Solving

To make this work in the real world, where treewidth is often high, they introduce Nested DP. Instead of a single massive DP table, they use "abstractions" to hide complex parts of the graph.

  • Abstraction: They simplify the primal graph by focusing on a subset of variables.
  • Nesting: Subproblems "hidden" by the abstraction are solved recursively or delegated to standard solvers.
  • Hybrid Solving: If a subproblem's treewidth is too high for DP, the system automatically switches to a search-based solver (like a SAT or #SAT solver).
Figure 2: The DP approach, where table algorithm A modifies tables. [56]

3. Database-Backed Implementation (nestHDB)

The authors implemented their approach in a tool called nestHDB. Uniquely, it uses PostgreSQL to handle the heavy lifting of table manipulations (joins, projections, and aggregations) required by the DP algorithm, leveraging decades of database optimization research.

Datasets

The authors evaluated their solver against 16 state-of-the-art solvers using two primary benchmarks:

  • #SAT Benchmarks: 1,494 instances previously used in model counting competitions to test standard counting performance.
  • PMC Benchmarks: 610 instances from the projMC and Fremont collections, covering planning, circuits, random instances, and symbolic-markov applications.

Key Insights and Ideas

  • The Double-Exponential Wall: The paper establishes that PMC is fundamentally harder than #SAT when using treewidth. While #SAT is single-exponential ($2^k$), PMC requires double-exponential ($2^{2^k}$) time. This isn't a flaw in their algorithm, but a fundamental limit of the problem itself under ETH.
  • Abstraction as a Scalpel: The "Aha!" moment is that you don't have to solve the whole graph with DP. By abstracting away parts of the graph, you can keep the "width" of the DP nodes manageable, delegating the messy bits to specialized SAT solvers.
  • SQL for Logic: Using a relational database (PostgreSQL) as the execution engine for dynamic programming is a clever engineering choice. Databases are built for exactly the kind of large-scale set operations that TD-based algorithms require.

Key Results

  • Theoretical Tightness: The algorithm achieves the best possible theoretical runtime for treewidth-based PMC.
  • Practical Scaling: nestHDB solved instances with treewidth upper bounds beyond 200. For context, traditional DP approaches usually fail once treewidth hits 30-40.
  • Competitive Performance: In PMC benchmarks, nestHDB solved 251 instances, outperforming specialized solvers like projMC (225) and ganak (205).
  • Parallelism: The nested approach naturally allows for solving subproblems in parallel, providing a significant speedup on multi-core systems.

Limitations and Future Work

  • Nesting Depth: The current implementation is mostly tested with a nesting depth of 2. Increasing this depth leads to an exponential explosion of rows, and the authors note they don't yet have an efficient way to handle very deep nesting.
  • Heuristic Dependency: The performance of the nested approach relies heavily on the quality of the abstraction—choosing which variables to "hide." The authors suggest that domain-specific information could help improve these heuristics.
  • Quantified Boolean Formulas (QBF): The authors believe their nested DP framework could be extended to even harder problems, like QBF solving, which sits even higher on the complexity hierarchy.

Summary updated

BibTeX
@misc{fichte2023solving,
  author = {Johannes K. Fichte and Markus Hecher and Michael Morak and Patrick Thier and Stefan Woltran},
  title = {{Solving Projected Model Counting by Utilizing Treewidth and its Limits}},
  year = {2023},
  eprint = {2305.19212},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2305.19212},
}
Figure