Weighted Model Counting with Twin-Width

Robert Ganian, Filip Pokrývka, André Schidler, Kirill Simonov, Stefan Szeider

TL;DR

This paper extends the powerful graph invariant twin-width to the domain of propositional logic by introducing "signed twin-width" for CNF formulas. The authors prove that Bounded-ones Weighted Model Counting (BWMC)—a major generalization of SAT and model counting—is fixed-parameter tractable (FPT) when parameterized by this new width measure plus the literal bound $k$. Crucially, they demonstrate that this parameterization is tight; stripping away the signs or the bound $k$ causes the problem to spiral back into parameterized intractability.

What Problem Does This Paper Address?

Model counting (#SAT) asks not just if a boolean formula can be satisfied, but in how many ways. It is a foundational problem for probabilistic reasoning and AI, but it is notoriously difficult (#P-complete). To tackle this hardness, researchers often look at the structural properties of the formula when represented as a graph (e.g., connecting variables to the clauses they appear in). If this graph has a low "width" (like treewidth or clique-width), the problem becomes efficiently solvable (fixed-parameter tractable, or FPT).

Recently, a highly generalized graph parameter called twin-width was introduced, showing immense promise because it can keep graphs "simple" even when traditional measures like treewidth fail (e.g., on dense graphs like grids or planars). However, "vanilla" twin-width ignores whether a variable appears as a positive ($x$) or negative ($\neg x$) literal. This paper addresses this gap: How can we leverage the expressive power of twin-width for SAT and model counting without losing the vital positive/negative structural information of boolean formulas?

Methods

The authors bridge this gap by introducing two novel concepts:

  1. Signed Twin-Width: Instead of a standard graph, they map the CNF formula to a signed incidence graph, where edges are explicitly labeled as positive or negative depending on the literal's sign. The twin-width contraction rules are adapted to preserve these signs or turn conflicting connections into "red edges" (representing errors/uncertainty).
  2. Bipartite Contraction Sequences: To keep the execution of the algorithm clean, they force the graph contractions to only merge variables with variables, and clauses with clauses. They prove a key lemma showing that this restriction is "essentially harmless"—it increases the twin-width by at most a constant factor of 2.

Using these tools, they design a sophisticated dynamic programming algorithm over the contraction sequence to solve Bounded-ones Weighted Model Counting (BWMC), which counts satisfying assignments that contain at most $k$ positive literals.

Datasets

The authors evaluated their approach empirically using several types of CNF instances:

  • Proof Complexity Benchmarks: Hard structural formulas generated via the CNFGen tool, including pigeonhole principle (pidgeon), counting assertions (count), graph matching (matching), and Tseitin formulas.
  • Random $k$-SAT: Randomly generated instances with 15 variables and varying clause lengths/counts.
  • SATLIB Uniform Random 3-SAT: 100 randomly selected instances from the well-known uf20-91 benchmark set.

Key Insights and Ideas

  • Vanilla Twin-Width Fails for SAT: A key "aha!" moment is the realization that unsigned twin-width is blind to literal negation. The authors prove that without tracking signs, even basic SAT remains intractable on graphs with low vanilla twin-width.
  • The Necessity of the Bound ($k$): Twin-width allows for very dense graph structures. Because of this density, you cannot count an unrestricted number of models efficiently. Introducing the bound $k$ (limiting the number of true variables) acts as a mathematical anchor that keeps the dynamic programming states from exploding.
  • Surprisingly Small in Practice: Theoretically, signed twin-width can be larger than treewidth or signed clique-width by a constant factor. However, in practical experiments, signed twin-width was consistently smaller than both treewidth and clique-width across every single tested instance.

Key Results

  • Main Theorem: BWMC is fixed-parameter tractable (FPT) when parameterized by $k$ plus the signed twin-width. The algorithm runs in $O(n^4 \cdot d^{O(kd^2)})$ time, where $d$ is the signed twin-width.
  • Tightness Matrix: The authors established a comprehensive hardness framework showing their parameter choices are optimal:
Overview of complexity results based on parameter choice
  • Empirical Performance: Using SAT-based encodings to compute these widths, the authors showed that signed twin-width scales gracefully. For instance, on the uf20_3_91 random SAT dataset, while the average treewidth was 14.5, the signed twin-width upper bound was only 7.7.

Limitations and Future Work

  • Sequence Availability: The FPT algorithm assumes that an optimal (or near-optimal) signed contraction sequence is provided upfront as part of the input. Finding this sequence automatically in FPT time remains an open challenge.
  • The $k$ Dependency: While the algorithm works beautifully for BWMC, it cannot solve standard, unrestricted model counting ($k = |var|$) in FPT time due to the paraNP-hardness barrier when $k$ is unrestricted.
  • Future Direction: A major open question is whether another structural parameter exists that can generalize signed clique-width to achieve FPT algorithms for pure SAT without needing the restriction of the bound $k$.

Summary updated

BibTeX
@inproceedings{ganian2022weighted,
  author = {Robert Ganian and Filip Pokrývka and André Schidler and Kirill Simonov and Stefan Szeider},
  title = {{Weighted Model Counting with Twin-Width}},
  booktitle = {SAT},
  year = {2022},
  doi = {10.4230/lipics.sat.2022.15},
}
Figure