Skip to content

Menu

WorksComputer Science

Solving Restricted Versions of #SAT Faster than 2m2^m: Algorithms and Lower Bounds

Download PDFView on arXiv

Ask your agent about this work

Your agent reads this work through Valency, with its citations and similar works. Paste this at the start of a chat.

Use the Valency MCP. Work: W_g9qbymau. Fetch it with get_paper_by_id, then find its nearest works with find_similar_papers and tell me what it adds.

Works with any MCP client. Not connected yet? Connect your agent

Abstract

Under the Strong Exponential Time Hypothesis (SETH), for any constant ε>0\varepsilon > 0, the #SAT problem (counting the number of satisfying assignments of a CNF formula) cannot be solved in O∗((2−ε)n)\mathcal{O}^*((2-\varepsilon)^n) or O∗((2−ε)m)\mathcal{O}^*((2-\varepsilon)^m) time, where nn is the number of variables and mm is the number of clauses. On the other hand, simple exhaustive search and the standard inclusion-exclusion give O∗(2n)\mathcal{O}^*(2^n)-time and O∗(2m)\mathcal{O}^*(2^m)-time algorithms, respectively. A natural line of research is to beat these SETH-based barriers for restricted versions, such as #kk-SAT (where each clause contains at most kk literals) or #dd-occ-SAT (where each variable appears in at most dd clauses). It is known that the 2n2^n-barrier can be broken when kk or dd is any constant; yet, whether the 2m2^m-barrier can also be broken in these cases remains unknown. We present two simple algorithms that overcome the 2m2^m-barrier. First, for #kk-SAT, we give an O∗(2m(1−1/O(k)))\mathcal{O}^*(2^{m(1-1/O(k))})-time algorithm, thereby breaking the 2m2^m-barrier for any constant kk. Second, for #22-occ-SAT (which also includes the problem of counting the number of edge covers in a graph as a special case), we provide an algorithm with runtime O∗(2mω/3)\mathcal{O}^*(2^{mω/3}), where ω<2.3714ω< 2.3714 is the matrix multiplication exponent. Furthermore, we demonstrate that both algorithms generalize to the weighted counting setting while preserving the same runtime bounds. On the hardness side, we present a reduction from #Max-dd-SAT to #dd-occ-SAT, showing that for any d≥3d\ge 3, #dd-occ-SAT admits no O∗((2−ε)m)\mathcal{O}^*((2-\varepsilon)^m)-time algorithm for any constant ε>0\varepsilon>0, even on positive formulas, under the hypothesis that #Max-3-SAT on nn variables admits no O∗((2−ε)n)\mathcal{O}^*((2-\varepsilon)^n)-time algorithm for any such ε\varepsilon.

Sanjay Jain and Frank Stephan were supported by Singapore Ministry of Education (MOE) AcRF Tier 2 grant MOE-000538-01. Additionally, Sanjay Jain was supported by NUS grant E-252-00-0021-09. Junqiang Peng was supported by the European Research Council (ERC) via grant NewPC, reference 101199930.

Introduction

The Satisfiability (SAT) problem, which involves determining the satisfiability of a given propositional formula in Conjunctive Normal Form (CNF), is one of the most fundamental and important NP-complete problems [9, 24] in theoretical computer science. Its counting variant, Propositional Model Counting (#SAT), requires computing the exact number of satisfying assignments (also called models). As a canonical #P-complete [34] problem, #SAT finds applications in various areas (see [16] for a comprehensive introduction).

In this paper, we focus on exact exponential-time algorithms for #SAT. This falls into the rich area of research devoted to designing exact algorithms for NP-hard problems that are faster than naïve brute-force methods and improve runtimes beyond natural barriers. A recent survey by Nederlof [28] refers to this field as the “fine-grained complexity of NP-complete problems”; we direct interested readers to this survey for a broader context.

By enumerating all 2n2^n possible assignments, SAT and #SAT can be solved in O∗(2n)O^*(2^n) time, where O∗(⋅)O^*(\cdot) omits polynomial factors in the input size and nn is the number of variables. However, no algorithm for SAT with runtime O∗((2−ε)n)O^*((2-\varepsilon)^n) is known for any constant ε>0\varepsilon> 0. Under the Strong Exponential Time Hypothesis (SETH) [18], no such algorithm exists.

While the 2n2^n-barrier is insurmountable under SETH for general SAT and #SAT, it can be broken for restricted classes of formulas. Notable examples include kk-CNF (where each clause contains at most kk literals) and dd-occ-CNF (where each variable appears in at most dd clauses). The corresponding problems are denoted by kk-SAT, dd-occ-SAT, #kk-SAT, and #dd-occ-SAT, respectively. It is well-established that kk-SAT can be solved in O∗(2n(1−Ω(1/k)))O^*(2^{n(1-\Omega(1/k))}) time via various algorithmic paradigms [29, 31, 11, 6], and dd-occ-SAT can be solved in O∗(2n(1−Ω(1/log⁡d)))O^*(2^{n(1-\Omega(1/\log d))}) time [8, 13]. Remarkably, the same runtime bounds can be achieved for the counting counterparts: Impagliazzo, Matthews, and Paturi [17] gave Las Vegas randomized algorithms for #kk-SAT in O∗(2n(1−Ω(1/k)))O^*(2^{n(1-\Omega(1/k))}) time and #dd-occ-SAT in O∗(2n(1−Ω(1/log⁡d)))O^*(2^{n(1-\Omega(1/\log d))}) time. Subsequently, Chan and Williams [11] developed the deterministic algorithms achieving the respective runtime bounds, albeit requiring exponential space.

In this paper, we turn our attention to another natural parameter: the number of clauses mm. The complexity landscape is markedly different under this parameterization. In particular, SAT can be solved in O∗(1.2226m)O^*(1.2226^m) time [12], whereas #SAT can be solved in O∗(2m)O^*(2^m) time via standard inclusion-exclusion [19, 26]. Moreover, the authors in [7] showed that no O∗((2−ε)m)O^*((2-\varepsilon)^m)-time algorithm exists for any ε>0\varepsilon> 0 under SETH.

For restricted versions, it is known that weighted #2-SAT can be solved in O∗(1.1082m)O^*(1.1082^m) time and exponential space [30] (the definition of the weighted setting is deferred later). Furthermore, an O∗(1.1082L)O^*(1.1082^L)-time algorithm for general #SAT can be obtained by reducing an instance of length LL (the sum of the lengths of all clauses) to a weighted #2-SAT instance with m=Lm = L clauses [3, 4] and invoking the aforementioned algorithm [30]. For #kk-SAT, since L≤kmL \le km, this yields an O∗(1.1082km)O^*(1.1082^{km})-time algorithm and breaks the 2m2^m-barrier for #kk-SAT when k≤6k \le6. Nevertheless, whether this barrier can be broken for any arbitrary fixed kk remains unknown. Moreover, for #dd-occ-SAT, to the best of our knowledge, no algorithm was known to break the 2m2^m-barrier even for the most restrictive case of d=2d = 2.

Why parameter mm. The parameters nn and mm capture two different natural search spaces: assignments of variables and subsets of clauses, underlying the O∗(2n)O^*(2^n)-time exhaustive-search and O∗(2m)O^*(2^m)-time inclusion-exclusion algorithms, respectively. Results parameterized by nn do not directly yield savings over the 2m2^m-barrier; for example, although a kk-CNF satisfies n≤kmn \le km, this relation turns an O∗(2n(1−Ω(1/k)))O^*(2^{n(1-\Omega(1/k))})-time algorithm only into an O∗(2m(k−Ω(1)))O^*(2^{m(k-\Omega(1))})-time algorithm. Thus, parameter mm provides a natural perspective complementary to parameter nn.

Furthermore, #SAT parameterized by mm contains #All Set Cover parameterized by the universe size as a special case. Given a universe U\mathcal{U} and subsets S1,…,SrS_1,\ldots,S_r of U\mathcal{U} (not necessarily distinct), #All Set Cover asks for the number of index sets I⊆{1,…,r}I \subseteq\{1,\ldots,r\} such that ⋃i∈ISi=U\bigcup_{i\in I} S_i = \mathcal{U}. Introducing one variable xix_i for each i∈{1,…,r}i \in\{1,\ldots,r\} and one positive clause Cu=⋁i:u∈SixiC_u = \bigvee_{i:u\in S_i} x_i for each u∈Uu \in\mathcal{U} gives a bijection between satisfying assignments and set covers, with m=∣U∣m = |\mathcal{U}|.

Our main results. In this work, we present algorithms that break the 2m2^m-barrier for restricted versions of #SAT, namely #kk-SAT for any fixed kk and #2-occ-SAT, as well as hardness results for #dd-occ-SAT for every fixed d≥3d \ge3 via a reduction from #Max-dd-SAT. Known results and our results for #SAT and its restricted versions are summarized in Table 1.

ProblemsPrevious Results: Parameter nnPrevious Results: Parameter mmOur Results
#SATO∗(2n)O^*(2^n)<br>Det. & Poly-SO∗(2m)O^*(2^m)<br>Det. & Poly-S [19, 26]—
#2-SATO∗(1.2377n)O^*(1.2377^n)<br>Det. & Poly-S [35]O∗(1.1082m)O^*(1.1082^m)<br>Det. & Exp-S [30]—
#kk-SAT (k≥3k \ge3)O∗(2n(1−Ω(1/k)))O^*(2^{n(1-\Omega(1/k))})<br>Rand. & Poly-S [17]<br>Det. & Exp-S [11]O∗(1.1082km)O^*(1.1082^{km}) for k≤6k \le6<br>Det. & Exp-S [3, 4, 30]<br>O∗(2m)O^*(2^m) for k≥7k \ge7O∗(2m(1−Ω(1/k)))O^*(2^{m(1-\Omega(1/k))})<br>Det. & Poly-S § 3
#2-occ-SATO∗(1.2282n)O^*(1.2282^n)<br>Det. & Exp-S [3, 4, 30]O∗(2m)O^*(2^m)O∗(2mω/3)⊆O∗(1.7297m)O^*(2^{m\omega/3}) \subseteq O^*(1.7297^m)<br>Det. & Exp-S § 4
#dd-occ-SAT (d≥3d \ge3)O∗(2n(1−Ω(1/log⁡d)))O^*(2^{n(1-\Omega(1/\log d))})<br>Rand. & Poly-S [17]<br>Det. & Exp-S [11]O∗(2m)O^*(2^m)No O∗((2−ε)m)O^*((2-\varepsilon)^m)-time algorithm under the #Max-3-SAT Hypothesis<br>Section 6

Table 1. Summary of known results and our results. The runtime bound O∗(1.2282n)O^*(1.2282^n) for #2-occ-SAT follows directly from the O∗(1.1082L)O^*(1.1082^L)-time algorithm for #SAT since L≤2nL \le2n. Here, ω<2.3714\omega< 2.3714 is the matrix multiplication exponent [1]. ‘Det.’ and ‘Rand.’ refer to ‘deterministic’ and ‘randomized’, respectively, while ‘Poly-S’ and ‘Exp-S’ stand for ‘polynomial space’ and ‘exponential space’.

Our algorithmic results are as follows.

Theorem 1. #kk-SAT with mm clauses can be solved in O∗(2m(1−15k))⊆O∗(2m(1−Ω(1/k)))O^*(2^{m(1-\frac{1}{5k})}) \subseteq O^*(2^{m(1-\Omega(1/k))}) time and polynomial space.

Theorem 2. #2-occ-SAT with mm clauses can be solved in O∗(2mω/3)⊆O∗(1.7297m)O^*(2^{m\omega/3}) \subseteq O^*(1.7297^m) time and exponential space, where ω<2.3714\omega< 2.3714 denotes the matrix multiplication exponent.

An edge cover of a multigraph G=(V,E)G = (V,E) is a subset of edges incident to every vertex in VV, where parallel edges are treated as distinct and a loop covers its incident vertex. #All Edge Cover involves computing the number of edge covers of a given multigraph (where parallel edges and loops are allowed), which naturally reduces to #2-occ-SAT. Specifically, #All Edge Cover is the special case of #All Set Cover in which the universe is VV and each edge corresponds to the set of its incident vertices, of size one or two. Under the reduction to #SAT described above, each non-loop edge variable appears in the two clauses corresponding to its endpoints, while each loop variable appears only in the clause corresponding to its incident vertex. Thus each variable occurs in at most two clauses, yielding a #2-occ-SAT instance with m=∣V∣m = |V| clauses. To the best of our knowledge, no algorithm for #All Edge Cover with runtime O∗((2−ε)∣V∣)O^*((2-\varepsilon)^{|V|}) for any ε>0\varepsilon> 0 was known. Our Theorem 2 implies an algorithm for #All Edge Cover:

Corollary 1. #All Edge Cover on multigraphs with nn vertices can be solve in O∗(2nω/3)⊆O∗(1.7297n)O^*(2^{n\omega/3}) \subseteq O^*(1.7297^n) time and exponential space.

We further demonstrate that our algorithms (Theorem 1 and Theorem 2) generalize to the weighted counting setting while preserving the same runtime bounds. In the weighted setting, each literal is associated with a weight; the weight of a truth assignment is the product of the weights of the literals it satisfies, and the weighted model count of a formula is the sum of these weights over all satisfying assignments.

Our hardness results are based on the following hypothesis.

Hypothesis 1 (#Max-3-SAT Hypothesis). For every constant ε>0\varepsilon> 0, #Max-3-SAT on nn variables cannot be solved in O∗((2−ε)n)O^*((2-\varepsilon)^n) time.

Here, #Max-dd-SAT asks for the number of truth assignments that maximize the number of satisfied clauses in a CNF formula whose clauses contain at most dd literals. We note that the stronger hypothesis that Max-3-SAT on nn variables cannot be solved in O∗((2−ε)n)O^*((2-\varepsilon)^n) time for any constant ε>0\varepsilon> 0 has been used in the literature [27, 5, 22, 2]. We show that, for every fixed d≥3d \ge3 and constant ε>0\varepsilon> 0, #dd-occ-SAT with mm clauses cannot be solved in O∗((2−ε)m)O^*((2-\varepsilon)^m) time, even on positive formulas, under the #Max-3-SAT Hypothesis. A formula is positive if it contains only positive literals. To this end, we prove the following theorem.

Theorem 3. For every fixed d≥2d \ge2, there is a polynomial-time non-adaptive Turing reduction from #Max-dd-SAT on nn variables to #dd-occ-SAT on positive formulas with exactly nn clauses. Thus, for any constant γ≥1\gamma\ge1, an O∗(γm)O^*(\gamma^m)-time algorithm for the latter problem with mm clauses yields an O∗(γn)O^*(\gamma^n)-time algorithm for the former problem, preserving polynomial space.

We note that #dd-occ-SAT on positive formulas parameterized by the number of clauses is equivalent to #All Set Cover with sets of size at most dd parameterized by the number of elements. Here, the sets need not be distinct. The reduction from #All Set Cover to #SAT described above produces positive formulas; when each set has size at most dd, each variable occurs in at most dd clauses. Conversely, #dd-occ-SAT on positive formulas also naturally reduces to #All Set Cover with sets of size at most dd: each clause corresponds to one element in the universe, and each variable corresponds to a subset of the universe containing precisely the elements corresponding to clauses containing that variable. Each such subset has size at most dd, and selecting the sets corresponding to variables assigned true gives a bijection between satisfying assignments and set covers. Based on this equivalence, we have the following consequences of Theorem 3.

Corollary 2. For every constant ε>0\varepsilon> 0, an algorithm for #All Edge Cover on multigraphs with NN vertices running in O∗((2−ε)N)O^*((2-\varepsilon)^N) time and polynomial space yields an algorithm for #Max-2-SAT on nn variables running in O∗((2−ε)n)O^*((2-\varepsilon)^n) time and polynomial space.

Corollary 3. For every fixed d≥3d \ge3, #All Set Cover on a universe of nn elements with sets of size at most dd cannot be solved in O∗((2−ε)n)O^*((2-\varepsilon)^n) time for any constant ε>0\varepsilon> 0, under the #Max-3-SAT Hypothesis.

Preliminaries

Let VV be a set of Boolean variables. A Boolean variable x∈Vx \in V can be assigned a value of 1 (True) or 0 (False). A variable xx has two corresponding literals: the positive literal xx and the negative literal x‾\overline{x}. We use ℓ‾\overline{\ell} to denote the negation of literal ℓ\ell, so ℓ‾‾=ℓ\overline{\overline{\ell}} = \ell. A clause on VV is a set of literals on VV, which might be empty. A CNF formula φ\varphi over VV is a multiset of clauses on VV, allowing identical clauses. Different copies of the same clause are treated as distinct. Let var⁡(φ)\operatorname{var}(\varphi) denote the variable set of φ\varphi. For a collection SS of clauses, we use lit⁡(S)\operatorname{lit}(S) to denote the set of literals appearing in the clauses of SS (i.e., ℓ∈lit⁡(S)\ell\in\operatorname{lit}(S) if ℓ∈C\ell\in C for some C∈SC \in S).

An assignment for a variable set VV is a mapping σ:V→{0,1}\sigma: V \to\{0,1\}. Given an assignment σ\sigma, a clause is satisfied by σ\sigma if at least one literal in it evaluates to 1 under σ\sigma. An assignment for var⁡(φ)\operatorname{var}(\varphi) is called a satisfying assignment (or model) of φ\varphi if σ\sigma satisfies all clauses in φ\varphi. We denote by M(φ)\mathcal{M}(\varphi) the set of all satisfying assignments of φ\varphi, and let #(φ):=∣M(φ)∣\#(\varphi) := \lvert\mathcal{M}(\varphi)\rvert.

Without loss of generality, we assume throughout that no clause contains both a variable and its negation. Such tautological clauses can be deleted while retaining the variable set, without changing the set of satisfying assignments. The degree of a variable xx, denoted by deg⁡φ(x)\deg_{\varphi}(x), is the number of its occurrences in φ\varphi. A formula φ\varphi is called kk-CNF if each clause has length at most kk, and called dd-occ-CNF if each variable appears in at most dd clauses.

Throughout, we use ω\omega to denote the matrix multiplication exponent, that is, a constant such that two N×NN \times N matrices can be multiplied using O(Nω)O(N^{\omega}) arithmetic operations. Known matrix multiplication algorithms allow us to choose ω<2.3714\omega< 2.3714 [1].

An Algorithm for #kk-SAT via Clause Branching

In this section, we present an O∗(2m(1−Ω(1/k)))O^*(2^{m(1-\Omega(1/k))})-time branching algorithm for #kk-SAT, where mm is the number of clauses. We first introduce some necessary notation.

For a literal ℓ\ell, let φ[ℓ=1]\varphi[\ell= 1] denote the formula obtained by assigning ℓ=1\ell= 1 (removing clauses containing ℓ\ell and deleting ℓ‾\overline{\ell} from others), and let φ[ℓ=0]:=φ[ℓ‾=1]\varphi[\ell= 0] := \varphi[\overline{\ell} = 1]. For a clause C=(ℓ1∨⋯∨ℓk)C = (\ell_1 \vee\cdots\vee\ell_k), we write φ[C=0]:=φ[ℓ1=0,…,ℓk=0]\varphi[C = 0] := \varphi[\ell_1 = 0, \ldots, \ell_k = 0] to denote the formula obtained by falsifying CC, and let φ∖{C}\varphi\setminus\{C\} denote the formula obtained by removing (one copy of) CC from φ\varphi. Clause deletion retains the variable set, while assignment removes the assigned variables and retains all other variables. The algorithm consists of only a simple clause-based branching rule and two reduction rules. We will first introduce these rules and then present the algorithm along with the analysis.

Clause Branching and Isolated Clause Reduction

Lemma 1 (clause branching). Let CC be a clause in formula φ\varphi. Then

#(φ)=#(φ∖{C})−#((φ∖{C})[C=0]).\#(\varphi) = \#(\varphi\setminus\{C\}) - \#((\varphi\setminus\{C\})[C = 0]).

Proof of Lemma 1. We partition the satisfying assignments of formula φ∖{C}\varphi\setminus\{C\} into those satisfying CC (which are exactly the satisfying assignments of formula φ\varphi) and those falsifying CC. Since falsifying CC requires assigning 0 to all its literals, the number of such assignments is exactly #((φ∖{C})[C=0])\#((\varphi\setminus\{C\})[C = 0]). Thus, we have #(φ∖{C})=#(φ)+#((φ∖{C})[C=0])\#(\varphi\setminus\{C\}) = \#(\varphi) + \#((\varphi\setminus\{C\})[C = 0]). Rearranging this equation yields the lemma. ▢

A clause CC is called isolated if all variables in CC only appear once in the formula, i.e., deg⁡φ(x)=1\deg_{\varphi}(x) = 1 for all x∈var⁡(C)x \in\operatorname{var}(C). Since it shares no variables with the rest of the formula, we can compute its satisfying assignments independently, leading to the following reduction rule.

Lemma 2 (isolated clause reduction). Let CC be an isolated clause in formula φ\varphi. Let rem⁡(φ,C)\operatorname{rem}(\varphi,C) denote the formula obtained by deleting CC and removing the variables in var⁡(C)\operatorname{var}(C) from the variable set. Then,

#(φ)=#(rem⁡(φ,C))⋅(2∣C∣−1).\#(\varphi)=\#(\operatorname{rem}(\varphi,C))\cdot(2^{|C|}-1).

Proof of Lemma 2. Since CC is isolated, its variables do not appear in any other clause. Thus, the satisfying assignments of φ\varphi are the Cartesian product of the satisfying assignments of CC and those of rem⁡(φ,C)\operatorname{rem}(\varphi,C). Exactly one of the 2∣C∣2^{|C|} assignments to var⁡(C)\operatorname{var}(C) falsifies CC, so CC has 2∣C∣−12^{|C|}-1 satisfying assignments. This yields the claimed equality.

The Algorithm

Let V≥2(φ,C):={x∈var⁡(C)∣deg⁡φ(x)≥2}V_{\ge2}(\varphi,C):=\{x\in\operatorname{var}(C)\mid\deg_{\varphi}(x)\ge2\}. If φ\varphi contains no tautological clauses, these are precisely the variables in CC that also appear in at least one other clause in φ∖{C}\varphi\setminus\{C\}. The algorithm, denoted as alg-count(φ)(\varphi), recursively computes #(φ)\#(\varphi) by applying the following steps in decreasing order of priority.

Step 1. Base Cases: If φ\varphi contains the empty clause, return 0. If φ=∅\varphi=\varnothing, return 2∣var⁡(φ)∣2^{|\operatorname{var}(\varphi)|}.

Step 2. Tautological Clause Reduction: If there exists a clause CC containing both xx and xˉ\bar{x} for some variable xx, return alg-count(φ∖{C})(\varphi\setminus\{C\}), retaining the variable set.

Step 3. Isolated Clause Reduction: If there exists an isolated clause C∈φC\in\varphi (i.e., V≥2(φ,C)=∅V_{\ge2}(\varphi,C)=\varnothing), apply Lemma Lemma 2 and return (2∣C∣−1)⋅(2^{|C|}-1)\cdot alg-count(rem⁡(φ,C))(\operatorname{rem}(\varphi,C)).

Step 4. Clause Branching: Select a pivot clause C∈φC\in\varphi that minimizes ∣V≥2(φ,C)∣|V_{\ge2}(\varphi,C)|. Since Steps 2 and 3 were not triggered, we are guaranteed that 1≤∣V≥2(φ,C)∣≤k1\le|V_{\ge2}(\varphi,C)|\le k. Pick an arbitrary variable x∈V≥2(φ,C)x\in V_{\ge2}(\varphi,C), and choose a neighboring clause C′∈φ∖{C}C'\in\varphi\setminus\{C\} such that x∈var⁡(C′)x\in\operatorname{var}(C'). Apply the clause branching rule (Lemma Lemma 1) on C′C' and return alg-count(φ∖{C′})−(\varphi\setminus\{C'\})-alg-count((φ∖{C′})[C′=0])((\varphi\setminus\{C'\})[C'=0]).

To bound the size of the search tree generated by alg-count(φ)(\varphi), we adopt the Measure and Conquer paradigm [15]. Let m(φ)m(\varphi) denote the number of clauses in φ\varphi. The measure of a formula φ\varphi is defined as:

μ(φ):=m(φ)+η(φ)k,\mu(\varphi):=m(\varphi)+\frac{\eta(\varphi)}{k},

where η(φ):=min⁡C∈φ∣V≥2(φ,C)∣\eta(\varphi):=\min_{C\in\varphi}|V_{\ge2}(\varphi,C)| with the convention that η(∅)=0\eta(\varnothing)=0. Intuitively, the fractional term η(φ)/k\eta(\varphi)/k tracks the progress toward isolating a clause. Since η(φ)≤k\eta(\varphi)\le k, we have μ(φ)≤m(φ)+1\mu(\varphi)\le m(\varphi)+1. Thus, any bound of O∗(cμ)O^*(c^{\mu}) for some cc implies O∗(cm)O^*(c^{m}).

Lemma 3. Applying tautological clause reduction or isolated clause reduction does not increase the measure μ(φ)\mu(\varphi).

Proof of Lemma 3. For tautological clause reduction, let φ′=φ∖{C}\varphi'=\varphi\setminus\{C\}. Since m(φ′)=m(φ)−1m(\varphi')=m(\varphi)-1 and η(φ′)≤k\eta(\varphi')\le k, we have μ(φ′)≤m(φ)≤μ(φ)\mu(\varphi')\le m(\varphi)\le\mu(\varphi).

For an isolated clause C∈φC\in\varphi, ∣V≥2(φ,C)∣=0|V_{\ge2}(\varphi,C)|=0. By the definition of η(φ)\eta(\varphi), we have η(φ)=0\eta(\varphi)=0 and μ(φ)=m(φ)\mu(\varphi)=m(\varphi). The reduction removes CC and var⁡(C)\operatorname{var}(C), yielding a residual formula φ′:=rem⁡(φ,C)\varphi':=\operatorname{rem}(\varphi,C) with m(φ′)=m(φ)−1m(\varphi')=m(\varphi)-1. Although the new minimum η(φ′)\eta(\varphi') might increase, it is bounded by kk. Thus, the new measure is:

μ(φ′)=m(φ′)+η(φ′)k≤m(φ)−1+kk=m(φ)=μ(φ).\mu(\varphi')=m(\varphi')+\frac{\eta(\varphi')}{k}\le m(\varphi)-1+\frac{k}{k}=m(\varphi)=\mu(\varphi).

Therefore, the measure never increases during this reduction.

Next, we analyze how the measure μ(φ)\mu(\varphi) decreases in each recursive step. The key observation is that our pivot clause CC acts as a “witness” to prevent the fractional part of the measure from increasing after removing its neighboring clause C′C', and even forces a decrease in the fractional part when falsifying C′C'.

Lemma 4. In Step 4 of the algorithm, branching on C′C' reduces the measure μ\mu by at least Δ1≥1\Delta_1 \ge1 in the branch φ∖{C′}\varphi\setminus\{C'\} and by at least Δ2≥1+1/k\Delta_2 \ge1 + 1/k in the branch (φ∖{C′})[C′=0](\varphi\setminus\{C'\})[C' = 0].

Proof of Lemma 4. Let CC be the pivot clause chosen in Step 4, with ∣V≥2(φ,C)∣=η(φ)≥1|V_{\ge2}(\varphi,C)| = \eta(\varphi) \ge1.

  • Branch 1 (removing C′C'): The formula becomes φ′:=φ∖{C′}\varphi' := \varphi\setminus\{C'\}. The number of clauses decreases by 1, so m(φ′)=m(φ)−1m(\varphi') = m(\varphi) - 1. Since C′≠CC' \ne C, the pivot clause CC remains in φ′\varphi'. Removing C′C' can only decrease or maintain the degrees of the remaining variables, so η(φ′)≤η(φ)\eta(\varphi') \le\eta(\varphi). The total measure drop is:

Δ1:=(m(φ)+η(φ)k)−(m(φ′)+η(φ′)k)=1+η(φ)−η(φ′)k≥1.\Delta_1 := \left(m(\varphi) + \frac{\eta(\varphi)}{k}\right) - \left(m(\varphi') + \frac{\eta(\varphi')}{k}\right) = 1 + \frac{\eta(\varphi) - \eta(\varphi')}{k} \ge1.
  • Branch 2 (falsifying C′C'): The formula becomes φ′′:=(φ∖{C′})[C′=0]\varphi'' := (\varphi\setminus\{C'\})[C' = 0]. The clause count mm decreases by at least 1. Furthermore, since x∈var⁡(C)∩var⁡(C′)x \in\operatorname{var}(C) \cap\operatorname{var}(C'), falsifying C′C' assigns a truth value to xx. This removes xx from CC, which implies ∣V≥2(φ′′,C)∣≤∣V≥2(φ,C)∣−1|V_{\ge2}(\varphi'',C)| \le|V_{\ge2}(\varphi,C)| - 1. Thus, η(φ′′)≤η(φ)−1\eta(\varphi'') \le\eta(\varphi) - 1 and the measure drop is:

Δ2:=(m(φ)+η(φ)k)−(m(φ′′)+η(φ′′)k)≥1+η(φ)−η(φ′′)k≥1+1k.\Delta_2 := \left(m(\varphi) + \frac{\eta(\varphi)}{k}\right) - \left(m(\varphi'') + \frac{\eta(\varphi'')}{k}\right) \ge1 + \frac{\eta(\varphi) - \eta(\varphi'')}{k} \ge1 + \frac{1}{k}.

Note that if CC happens to be satisfied and hence removed as a side effect in the second branch, mm decreases by at least 2. Even if η(φ)\eta(\varphi) could increase from its minimum possible value of 1 to the maximum possible value of kk, the measure drop is at least 2+1−kk=1+1k2 + \frac{1-k}{k} = 1 + \frac{1}{k}. Thus, the claimed bounds hold in all cases.

With Lemma 3 and Lemma 4, we are ready to prove Theorem 1.

Theorem 1. kk-SAT with mm clauses can be solved in O∗(2m(1−15k))⊆O∗(2m(1−Ω(1/k)))O^*(2^{m(1-\frac{1}{5k})}) \subseteq O^*(2^{m(1-\Omega(1/k))}) time and polynomial space.

Proof of Theorem 1. Tautological clause reduction preserves the set of satisfying assignments. Together with Lemma 2 and Lemma 1, the correctness of alg-count($\varphi$) is guaranteed. Clearly, the algorithm takes polynomial space. Let T(μ)T(\mu) denote the maximum number of leaves in the search tree of alg-count($\varphi$) for a formula φ\varphi of measure at most μ\mu. Both reduction rules can be performed in polynomial time, and they do not increase the measure by Lemma 3. By Lemma 4, the two subinstances created by clause branching have measure decreases of at least 1 and 1+1/k1 + 1/k, respectively. Hence, at branching nodes, we have the following recurrence:

T(μ)≤T(μ−1)+T(μ−1−1/k).T(\mu) \le T(\mu- 1) + T(\mu- 1 - 1/k).

Since every measure is an integer multiple of 1/k1/k, we prove by induction on kμk\mu that T(μ)≤2μ(1−ϵ)T(\mu) \le2^{\mu(1-\epsilon)} for ϵ:=15k\epsilon:= \frac{1}{5k}. Note that this value is chosen for the simplicity of the proof, rather than optimizing the bound; we believe that the constant factor in ϵ\epsilon can be further optimized via a more careful analysis. The bound trivially holds for the base cases. Assuming the bound holds for all values smaller than μ\mu, substituting it into the recurrence gives:

T(μ)≤2(μ−1)(1−15k)+2(μ−1−1k)(1−15k).T(\mu) \le2^{(\mu-1)(1-\frac{1}{5k})} + 2^{(\mu-1-\frac{1}{k})(1-\frac{1}{5k})}.

To complete the inductive step, the right-hand side must be at most 2μ(1−15k)2^{\mu(1-\frac{1}{5k})}. Dividing this inequality by 2μ(1−15k)2^{\mu(1-\frac{1}{5k})} yields the condition:

2−(1−15k)+2−(1+1k)(1−15k)≤1.2^{-(1-\frac{1}{5k})} + 2^{-(1+\frac{1}{k})(1-\frac{1}{5k})} \le1.

Multiplying both sides by 22, we obtain the equivalent condition:

215k+215k−1k(1−15k)≤2⟺215k(1+2−5k−15k2)≤2.2^{\frac{1}{5k}} + 2^{\frac{1}{5k}-\frac{1}{k}(1-\frac{1}{5k})} \le2 \Longleftrightarrow2^{\frac{1}{5k}}\left(1+2^{-\frac{5k-1}{5k^2}}\right) \le2.

To verify this inequality, we apply the bounds 2y≤1+y2^y \le1+y and 1+2−y≤2−y/21+2^{-y} \le2-y/2, which hold for y∈[0,1]y \in[0,1]. Since k≥1k \ge1, the exponents y1:=15ky_1 := \frac{1}{5k} and y2:=5k−15k2y_2 := \frac{5k-1}{5k^2} are in (0,1](0,1]. Applying these bounds gives:

215k(1+2−5k−15k2)≤(1+15k)(2−5k−110k2)=2−5k−110k2+25k−5k−150k3=2−k−110k2−5k−150k3<2(for any integer k≥1).\begin{aligned} 2^{\frac{1}{5k}}\left(1+2^{-\frac{5k-1}{5k^2}}\right) \le\left(1+\frac{1}{5k}\right)\left(2-\frac{5k-1}{10k^2}\right) \\ &= 2-\frac{5k-1}{10k^2}+\frac{2}{5k}-\frac{5k-1}{50k^3} \\ &= 2-\frac{k-1}{10k^2}-\frac{5k-1}{50k^3}<2 \qquad\text{(for any integer \(k \ge1\)).} \end{aligned}

This completes the induction. The total running time is bounded by O∗(2μ(1−15k))O^*(2^{\mu(1-\frac{1}{5k})}), which establishes the claimed O∗(2m(1−15k))O^*(2^{m(1-\frac{1}{5k})}) bound since μ(φ)≤m(φ)+1\mu(\varphi) \le m(\varphi)+1.

An Algorithm for #2-occ-SAT via Split-and-List

In this section, we present an O∗(2mω/3)O^*(2^{m\omega/3})-time algorithm for #2-occ-SAT, where mm is the number of clauses. Our approach builds upon the standard inclusion-exclusion formulation for #SAT [19, 26]. One can evaluate this formulation by enumerating all 2m2^m subsets of clauses, taking O∗(2m)O^*(2^m) time. To avoid this, we employ the Split-and-List method [36, 23]. For convenience and clarity, we will first recast the subset-based inclusion-exclusion formulation into an equivalent sum-product form, and then apply Split-and-List to evaluate it. In a sum-product problem, the objective is to evaluate a multi-dimensional sum over a product of lower-dimensional local functions. As we will show, for a 2-occ-CNF, the local functions in the formulation have at most two dependencies. This property is precisely what enables a more efficient evaluation via Split-and-List.

From Inclusion-Exclusion Formulation to Sum-Product Formulation

We begin by recalling the inclusion-exclusion formulation for #SAT [19, 26]. For a CNF formula φ={C1,C2,…,Cm}\varphi= \{C_1, C_2, \ldots, C_m\} over nn variables, let AiA_i be the set of assignments that falsify clause CiC_i. The number of satisfying assignments is given by #(φ)=2n−∣⋃i=1mAi∣\#(\varphi) = 2^n - \left|\bigcup_{i=1}^{m} A_i\right|. By the inclusion-exclusion principle, the cardinality of this union can be explicitly expanded as:

∣⋃i=1mAi∣=∑i=1m∣Ai∣−∑1≤i1<i2≤m∣Ai1∩Ai2∣+⋯+(−1)m−1∣A1∩A2∩⋯∩Am∣.\left|\bigcup_{i=1}^{m} A_i\right| = \sum_{i=1}^{m}|A_i|-\sum_{1\le i_1<i_2\le m}|A_{i_1}\cap A_{i_2}|+\cdots+(-1)^{m-1}|A_1\cap A_2\cap\cdots\cap A_m|.

To express this more compactly, let N(S)N(S) denote the number of assignments that simultaneously falsify every clause in a given subset S⊆φS \subseteq\varphi. We can then rewrite the formulation as a summation over all subsets of clauses:

#(φ)=∑S⊆φ(−1)∣S∣N(S) where N(S):={0if ∃x∈var⁡(φ),{x,x‾}⊆lit⁡(S)2n−∣lit⁡(S)∣otherwise(1)\#(\varphi) = \sum_{S \subseteq\varphi} (-1)^{|S|}N(S) \text{ where } N(S) := \begin{cases} 0 & \text{if } \exists x \in\operatorname{var}(\varphi), \{x, \overline{x}\} \subseteq\operatorname{lit}(S) \\ 2^{n-|\operatorname{lit}(S)|} & \text{otherwise} \end{cases} \tag*{(1)}

We then translate Eq. (1) to an equivalent sum-product formulation. To this end, we introduce a vector of Boolean indicator variables y:=(y1,y2,…,ym)∈{0,1}m\boldsymbol{y} := (y_1,y_2,\ldots,y_m) \in\{0,1\}^{m}, where its jj-th bit yjy_j indicates whether the clause CjC_j is included in the subset SS (i.e., yj=1⟺Cj∈Sy_j = 1 \Longleftrightarrow C_j \in S). The sign term (−1)∣S∣(-1)^{|S|} naturally factorizes as ∏j=1m(−1)yj\prod_{j=1}^{m}(-1)^{y_j}.

Crucially, the term N(S)N(S) factorizes into the product of individual contributions from the nn variables. Recall that every assignment in N(S)N(S) should simultaneously falsify all clauses in SS, i.e., setting all literals in lit⁡(S)\operatorname{lit}(S) to false. Thus, for a variable xix_i, the number of valid Boolean assignments to meet this condition depends only on how it appears in the selected clauses SS, independent of all other variables. Specifically, its contribution is 00 if both its positive and negative literals appear in SS (a logical conflict), 11 if exactly one positive literal or exactly one negative literal appears (fixing its truth value), and 22 if it does not appear in SS at all (leaving it free).

We introduce some notations before formally presenting the formulation. Let φ={C1,C2,…,Cm}\varphi= \{C_1,C_2,\ldots,C_m\} be a 22-occ-CNF over nn variables V={x1,x2,…,xn}V = \{x_1,x_2,\ldots,x_n\}. Recall that for a variable xi∈Vx_i \in V, deg⁡φ(xi)\deg_{\varphi}(x_i) denotes the number of times it appears in φ\varphi. We assume without loss of generality that deg⁡φ(xi)∈{1,2}\deg_{\varphi}(x_i) \in\{1,2\} for all xix_i, as variables with deg⁡φ(xi)=0\deg_{\varphi}(x_i) = 0 can be trivially factored out. We partition the variable set VV into two disjoint subsets:

  • V1:={xi∈V∣deg⁡φ(xi)=1}V_1 := \{x_i \in V \mid\deg_{\varphi}(x_i) = 1\}: the set of variables appearing exactly once. For each xi∈V1x_i \in V_1, let c1(i)c_1(i) denote the index of the unique clause containing xix_i.

  • V2:={xi∈V∣deg⁡φ(xi)=2}V_2 := \{x_i \in V \mid\deg_{\varphi}(x_i) = 2\}: the set of variables appearing exactly twice. For each xi∈V2x_i \in V_2, let c1(i)c_1(i) and c2(i)c_2(i) denote the indices of the two clauses containing xix_i, respectively.

We say a variable xi∈Vx_i \in V is mixed if it has both positive and negative literals in φ\varphi; otherwise, xix_i is pure. The sum-product formulation is as follows.

Lemma 5 (sum-product formulation). For any 22-occ-CNF φ\varphi, it holds that

#(φ)=∑y∈{0,1}m(∏j=1m(−1)yj∏xi∈V1Ui(yc1(i))∏xi∈V2Wi(yc1(i),yc2(i))),(2)\#(\varphi) = \sum_{\boldsymbol{y} \in\{0,1\}^{m}} \left( \prod_{j=1}^{m}(-1)^{y_j} \prod_{x_i \in V_1} U_i(y_{c_1(i)}) \prod_{x_i \in V_2} W_i(y_{c_1(i)},y_{c_2(i)}) \right), \tag*{(2)}

where Ui:{0,1}→{1,2}U_i : \{0,1\} \to\{1,2\} and Wi:{0,1}2→{0,1,2}W_i : \{0,1\}^{2} \to\{0,1,2\} are local weight functions mapping the selection status of the clauses containing variable xix_i to the number of valid Boolean assignments of xix_i. Specifically, these functions are defined as follows:

  • For any xi∈V1x_i \in V_1, Ui(yc1(i)):=2−yc1(i)U_i(y_{c_1(i)}) := 2 - y_{c_1(i)}.

  • For any xi∈V2x_i \in V_2, Wi(yc1(i),yc2(i)):={2−max⁡(yc1(i),yc2(i))if xi is pure,2−(yc1(i)+yc2(i))if xi is mixed.W_i(y_{c_1(i)},y_{c_2(i)}) := \begin{cases} 2 - \max(y_{c_1(i)},y_{c_2(i)}) & \text{if } x_i \text{ is pure}, \\ 2 - (y_{c_1(i)} + y_{c_2(i)}) & \text{if } x_i \text{ is mixed}. \end{cases}

Proof of Lemma 5. By substituting the indicator vector y∈{0,1}m\boldsymbol{y} \in\{0,1\}^{m} into Eq. (1), the summation over subsets SS transforms into a summation over y\boldsymbol{y}, and the term (−1)∣S∣(-1)^{|S|} transforms to ∏j=1m(−1)yj\prod_{j=1}^{m}(-1)^{y_j}. As established, N(S)N(S) factorizes into independent valid assignment counts for each variable. It suffices to verify that UiU_i and WiW_i correctly compute these counts for variables in V1V_1 and V2V_2, respectively.

For a variable xi∈V1x_i \in V_1, the unique clause containing xix_i is selected if and only if yc1(i)=1y_{c_1(i)} = 1. If yc1(i)=0y_{c_1(i)} = 0, xix_i is free and has 2 valid assignments; if yc1(i)=1y_{c_1(i)} = 1, its truth value is fixed to falsify the clause and has 1 valid assignment. The expression 2−yc1(i)2-y_{c_1(i)} matches these counts.

For a variable xi∈V2x_i \in V_2, let b1:=yc1(i)b_1 := y_{c_1(i)} and b2:=yc2(i)b_2 := y_{c_2(i)} denote the Boolean selection indicators of its two clauses. We verify the soundness of Wi(b1,b2)W_i(b_1,b_2) for each type of xix_i:

  • xix_i is pure. The two literals of xix_i share the same polarity. Then, xix_i has 1 valid assignment if at least one of its clauses is selected (i.e., max⁡(b1,b2)=1\max(b_1,b_2) = 1), and has 2 valid assignments only if neither is selected (i.e., b1=b2=0b_1 = b_2 = 0). The expression 2−max⁡(b1,b2)2-\max(b_1,b_2) matches this.

  • xix_i is mixed. The two literals of xix_i have opposite polarities. Selecting both clauses (b1=b2=1b_1 = b_2 = 1) leads to a conflict, leaving 0 valid assignments. Selecting exactly one clause (b1+b2=1b_1+b_2 = 1) leaves 1 valid assignment, and selecting neither (b1=b2=0b_1 = b_2 = 0) leaves 2 valid assignments. The expression 2−(b1+b2)2-(b_1+b_2) matches these counts.

Taking the product of these local functions over all variables reconstructs N(S)N(S), which completes the proof.

Fast Solving the Sum-Product Problem

To evaluate our sum-product formulation, we employ the Split and List method, whose foundational idea was first introduced by [36]. This idea was subsequently adapted by Koivisto [23] to solve a class of sum-product problems. For completeness and clarity, we provide a concise, self-contained proof that applies Koivisto’s approach in [23] to our specific formulation. At a high level, we partition the mm clauses into three equal groups and list the 2m/32^{m/3} indicator states for each. Because each variable in a 2-occ-CNF appears in at most two clauses, its local weight depends on at most two of these groups. This allows us to factorize the inner product into three pairwise components and reduce the entire multidimensional summation to computing the trace of the product of three matrices.

Lemma 6. The sum-product formulation given in Eq. (2) can be evaluated in O∗(2ωm/3)O^*(2^{\omega m/3}) time and O∗(22m/3)O^*(2^{2m/3}) space.

Proof of Lemma 6. For convenience, we extend unary local weight functions to binary. For each variable xi∈V1x_i \in V_1, let c2(i):=c1(i)c_2(i) := c_1(i) and Wi(yc1(i),yc2(i)):=Ui(yc1(i))W_i(y_{c_1(i)},y_{c_2(i)}) := U_i(y_{c_1(i)}). Eq. (2) becomes:

#(φ)=∑y∈{0,1}m(∏j=1m(−1)yj∏i=1nWi(yc1(i),yc2(i))).(3)\#(\varphi)=\sum_{y\in\{0,1\}^m}\left(\prod_{j=1}^{m}(-1)^{y_j}\prod_{i=1}^{n}W_i(y_{c_1(i)},y_{c_2(i)})\right). \tag*{(3)}

Assume without loss of generality that mm is divisible by 3 (padding with at most two unit clauses on fresh variables if necessary). We partition the clause indices {1,…,m}\{1,\ldots,m\} into three disjoint subsets II, JJ, and KK, each of size m/3m/3. For any vector y∈{0,1}my\in\{0,1\}^m, let yI,yJ,yK∈{0,1}m/3y_I,y_J,y_K\in\{0,1\}^{m/3} denote its projections onto the coordinates in II, JJ, and KK, respectively.

Let Ei:={c1(i),c2(i)}⊆{1,…,m}E_i := \{c_1(i),c_2(i)\}\subseteq\{1,\ldots,m\} denote the set of clause indices associated with xix_i. Since ∣Ei∣≤2|E_i|\leq2 for every xi∈Vx_i\in V, no set EiE_i intersects all three subsets II, JJ, and KK. This bounded dependency allows us to partition the variable set VV as follows:

  • XI,J:={xi∈V∣Ei⊆I∪J}X_{I,J} := \{x_i\in V\mid E_i\subseteq I\cup J\},

  • XJ,K:={xi∈V∣Ei⊆J∪K}∖XI,JX_{J,K} := \{x_i \in V \mid E_i \subseteq J \cup K\} \setminus X_{I,J},

  • XK,I:={xi∈V∣Ei⊆K∪I}∖(XI,J∪XJ,K)X_{K,I} := \{x_i \in V \mid E_i \subseteq K \cup I\} \setminus(X_{I,J} \cup X_{J,K}).

For each xi∈XP,Qx_i \in X_{P,Q}, where (P,Q)∈{(I,J),(J,K),(K,I)}(P,Q) \in\{(I,J),(J,K),(K,I)\}, both clause indices c1(i)c_1(i) and c2(i)c_2(i) lie in P∪QP \cup Q. Consequently, its local weight Wi(yc1(i),yc2(i))W_i(y_{c_1(i)}, y_{c_2(i)}) depends only on the sub-vectors yPy_P and yQy_Q. We distribute the terms in Eq. (3) into three pairwise functions:

FI,J(yI,yJ):=(∏j∈I(−1)yj)∏xi∈XI,JWi(yc1(i),yc2(i)),FJ,K(yJ,yK):=(∏j∈J(−1)yj)∏xi∈XJ,KWi(yc1(i),yc2(i)),FK,I(yK,yI):=(∏j∈K(−1)yj)∏xi∈XK,IWi(yc1(i),yc2(i)).\begin{aligned} F_{I,J}(y_I,y_J) &:= \left(\prod_{j\in I}(-1)^{y_j}\right)\prod_{x_i\in X_{I,J}} W_i(y_{c_1(i)},y_{c_2(i)}),\\ F_{J,K}(y_J,y_K) &:= \left(\prod_{j\in J}(-1)^{y_j}\right)\prod_{x_i\in X_{J,K}} W_i(y_{c_1(i)},y_{c_2(i)}),\\ F_{K,I}(y_K,y_I) &:= \left(\prod_{j\in K}(-1)^{y_j}\right)\prod_{x_i\in X_{K,I}} W_i(y_{c_1(i)},y_{c_2(i)}). \end{aligned}

Multiplying these exactly reconstructs the summand. Thus, the formulation factorizes as:

#(φ)=∑y∈{0,1}m(∏j=1m(−1)yj∏i=1nWi(yc1(i),yc2(i)))=∑yI∑yJ∑yKFI,J(yI,yJ)⋅FJ,K(yJ,yK)⋅FK,I(yK,yI).(4)\#(\varphi)=\sum_{y\in\{0,1\}^m}\left(\prod_{j=1}^{m}(-1)^{y_j}\prod_{i=1}^{n}W_i(y_{c_1(i)},y_{c_2(i)})\right) =\sum_{y_I}\sum_{y_J}\sum_{y_K}F_{I,J}(y_I,y_J)\cdot F_{J,K}(y_J,y_K)\cdot F_{K,I}(y_K,y_I). \tag*{(4)}

We define three 2m/3×2m/32^{m/3}\times2^{m/3} matrices AA, BB, and CC with entries A[yI,yJ]:=FI,J(yI,yJ)A[y_I,y_J] := F_{I,J}(y_I,y_J), B[yJ,yK]:=FJ,K(yJ,yK)B[y_J,y_K] := F_{J,K}(y_J,y_K), and C[yK,yI]:=FK,I(yK,yI)C[y_K,y_I] := F_{K,I}(y_K,y_I). Recall that the trace of a matrix MM, denoted by Tr⁡(M)\operatorname{Tr}(M), is the sum of its diagonal entries. By the definition of matrix multiplication, Eq. (4) equals the trace of the product of these three matrices:

#(φ)=∑yI(ABC)[yI,yI]=Tr⁡(ABC).(5)\#(\varphi)=\sum_{y_I}(ABC)[y_I,y_I]=\operatorname{Tr}(ABC). \tag*{(5)}

We then analyze the time and space required by the above approach. Generating the matrices requires evaluating the pairwise functions for all 22m/32^{2m/3} sub-vector pairs, taking O∗(22m/3)O^*(2^{2m/3}) time and space. Computing the product ABCABC via fast matrix multiplication takes O∗((2m/3)ω)=O∗(2mω/3)O^*((2^{m/3})^\omega)=O^*(2^{m\omega/3}) time and O∗(22m/3)O^*(2^{2m/3}) space, which completes the proof.

Combining Lemma 5 and Lemma 6, we have:

Theorem 2. #2-occ-SAT with mm clauses can be solved in O∗(2mω/3)⊆O∗(1.7297m)O^*(2^{m\omega/3}) \subseteq O^*(1.7297^m) time and exponential space, where ω<2.3714\omega< 2.3714 denotes the matrix multiplication exponent.

Generalizing to Weighted Model Counting

In this section, we demonstrate that our algorithms for #k-SAT and #2-occ-SAT can be naturally extended to the weighted setting with the same time complexity.

Definition 1 (Weighted Model Count). Let lit⁡(φ):=⋃x∈var⁡(φ){x,x‾}\operatorname{lit}(\varphi) := \bigcup_{x\in\operatorname{var}(\varphi)}\{x,\overline{x}\} be the set of literals over var⁡(φ)\operatorname{var}(\varphi). Let w:lit⁡(φ)→Zw : \operatorname{lit}(\varphi) \to\mathbb{Z} be a weight function that assigns an integer weight (possibly negative) to each literal. Let M(φ)\mathcal{M}(\varphi) be the set of all satisfying assignments of φ\varphi. The weighted model count WMC⁡(φ,w)\operatorname{WMC}(\varphi,w) is defined as

WMC⁡(φ,w):=∑σ∈M(φ)(∏x∈var⁡(φ)σ(x)=1w(x)⋅∏y∈var⁡(φ)σ(y)=0w(y‾)).\operatorname{WMC}(\varphi,w) := \sum_{\sigma\in\mathcal{M}(\varphi)}\left(\prod_{\substack{x\in\operatorname{var}(\varphi)\\\sigma(x)=1}}w(x)\cdot\prod_{\substack{y\in\operatorname{var}(\varphi)\\\sigma(y)=0}}w(\overline{y})\right).

In the Weighted Model Counting (WMC) problem, given a formula φ\varphi and a weight function ww, the goal is to compute the weighted model count WMC⁡(φ,w)\operatorname{WMC}(\varphi,w) of formula φ\varphi. We denote by weighted #k\#k-SAT and weighted #2\#2-occ-SAT the restricted versions of WMC where the inputs are kk-CNF and 22-occ-CNF formulas, respectively.

Before detailing the specific extensions, we analyze the computational cost of handling weights. Let Wmax⁡:=max⁡{1,max⁡ℓ∈lit⁡(φ)∣w(ℓ)∣}W_{\max} := \max\{1,\max_{\ell\in\operatorname{lit}(\varphi)}|w(\ell)|\}. Every integer arising in the branching recursion or the sum-product computation has absolute value at most 2O(n+m)Wmax⁡O(n)2^{O(n+m)}W_{\max}^{O(n)} and therefore has bit length O((m+n)log⁡(1+Wmax⁡))O((m+n)\log(1+W_{\max})). Thus, arithmetic operations on these numbers incur only a polynomial overhead, which is absorbed by the O∗(⋅)O^*(\cdot) notation.

Weighted #k\#k-SAT

The algorithm alg-count in § 3.2 can be modified for the weighted setting. For the base case where φ=∅\varphi=\emptyset, the algorithm returns ∏x∈var⁡(φ)(w(x)+w(x‾))\prod_{x\in\operatorname{var}(\varphi)}(w(x)+w(\overline{x})), which is the total weight of all possible assignments to the remaining variables. Tautology reduction applies unchanged in the weighted setting. For a clause C∈φC\in\varphi, the clause branching rule (Lemma 1) generalizes to the weighted setting as follows:

WMC⁡(φ,w)=WMC⁡(φ∖{C},w)−WMC⁡((φ∖{C})[C=0],w)⋅∏ℓ∈Cw(ℓ‾).\operatorname{WMC}(\varphi,w)=\operatorname{WMC}(\varphi\setminus\{C\},w)-\operatorname{WMC}((\varphi\setminus\{C\})[C=0],w)\cdot\prod_{\ell\in C}w(\overline{\ell}).

Similarly, for an isolated clause CC, the reduction rule (Lemma 2) generalizes to:

WMC⁡(φ,w)=WMC⁡(rem⁡(φ,C),w)⋅(∏ℓ∈C(w(ℓ)+w(ℓ‾))−∏ℓ∈Cw(ℓ‾)).\operatorname{WMC}(\varphi,w)=\operatorname{WMC}(\operatorname{rem}(\varphi,C),w)\cdot\left(\prod_{\ell\in C}(w(\ell)+w(\overline{\ell}))-\prod_{\ell\in C}w(\overline{\ell})\right).

The correctness of these weighted extensions follows the same logic as the proofs of Lemma 1 and Lemma 2. For the branching rule, we partition M(φ∖{C})\mathcal{M}(\varphi\setminus\{C\}) into assignments satisfying CC and those falsifying CC. The former are precisely M(φ)\mathcal{M}(\varphi). The latter are in bijection with M((φ∖{C})[C=0])\mathcal{M}((\varphi\setminus\{C\})[C=0]): each residual assignment extends uniquely by setting every literal in CC to false. The weight of this extension is the weight of the residual assignment multiplied by ∏ℓ∈Cw(ℓ‾)\prod_{\ell\in C}w(\overline{\ell}). Since the total weight is additive over disjoint sets of assignments, the subtraction correctly yields the total weight of M(φ)\mathcal{M}(\varphi). The isolated clause reduction holds because the weights of independent variables are multiplicative; the term ∏ℓ∈C(w(ℓ)+w(ℓ‾))\prod_{\ell\in C}(w(\ell)+w(\overline{\ell})) represents the total weight of all assignments to the variables in CC, while ∏ℓ∈Cw(ℓ‾)\prod_{\ell\in C}w(\overline{\ell}) is the weight of the unique assignment that falsifies CC.

Since the measure drop in the branching algorithm is the same as that in the unweighted case, the complexity is the same as that in Theorem 1.

Theorem 4. Weighted #k\#k-SAT with mm clauses can be solved in O∗(2m(1−15k))⊆O∗(2m(1−Ω(1/k)))O^*(2^{m(1-\frac{1}{5k})})\subseteq O^*(2^{m(1-\Omega(1/k))}) time and polynomial space.

Weighted #2-occ-SAT

The inclusion-exclusion formulation extends to the weighted setting: For a formula φ\varphi and weight function ww, let Nw(S)N_w(S) denote the total weight of assignments falsifying every clause in S⊆φS \subseteq\varphi. Then it holds that WMC⁡(φ,w)=∑S⊆φ(−1)∣S∣Nw(S)\operatorname{WMC}(\varphi,w)=\sum_{S\subseteq\varphi}(-1)^{\lvert S\rvert}N_w(S). As in § 4, variables of degree zero can be factored out independently; in the weighted setting, each such variable xx contributes a factor w(x)+w(x‾)w(x)+w(\overline{x}). We therefore assume that every variable belongs to V1∪V2V_1\cup V_2. Analogously to Lemma 5, Nw(S)N_w(S) then factorizes into the independent contributions of the variables.

Lemma 7 (weighted sum-product formulation). For any 2-occ-CNF φ\varphi and weight function ww, it holds that:

WMC⁡(φ,w)=∑y∈{0,1}m(∏j=1m(−1)yj∏xi∈V1U~i(yc1(i))∏xi∈V2W~i(yc1(i),yc2(i))).\operatorname{WMC}(\varphi,w)=\sum_{y\in\{0,1\}^{m}}\left(\prod_{j=1}^{m}(-1)^{y_j}\prod_{x_i\in V_1}\widetilde{U}_i(y_{c_1(i)})\prod_{x_i\in V_2}\widetilde{W}_i(y_{c_1(i)},y_{c_2(i)})\right).

where the local functions U~i:{0,1}→Z\widetilde{U}_i:\{0,1\}\to\mathbb{Z} and W~i:{0,1}2→Z\widetilde{W}_i:\{0,1\}^{2}\to\mathbb{Z} are defined as follows:

  • For xi∈V1x_i\in V_1, let ℓ\ell be the literal of xix_i appearing in Cc1(i)C_{c_1(i)}. Then U~i(yc1(i)):=(w(xi)+w(xi‾))⋅(1−yc1(i))+w(ℓ)⋅yc1(i)\widetilde{U}_i(y_{c_1(i)}):=(w(x_i)+w(\overline{x_i}))\cdot(1-y_{c_1(i)})+w(\ell)\cdot y_{c_1(i)}.

  • For a pure variable xi∈V2x_i\in V_2, let ℓ\ell be the literal of xix_i appearing in both Cc1(i)C_{c_1(i)} and Cc2(i)C_{c_2(i)}. Then W~i(yc1(i),yc2(i)):=(w(xi)+w(xi‾))⋅(1−max⁡(yc1(i),yc2(i)))+w(ℓ)⋅max⁡(yc1(i),yc2(i))\widetilde{W}_i(y_{c_1(i)},y_{c_2(i)}):=(w(x_i)+w(\overline{x_i}))\cdot(1-\max(y_{c_1(i)},y_{c_2(i)}))+w(\ell)\cdot\max(y_{c_1(i)},y_{c_2(i)}).

  • For a mixed variable xi∈V2x_i\in V_2, we assume without loss of generality that Cc1(i)C_{c_1(i)} contains the positive literal xix_i and Cc2(i)C_{c_2(i)} contains the negative literal xi‾\overline{x_i}. Then W~i(yc1(i),yc2(i)):=(w(xi)+w(xi‾))(1−yc1(i))(1−yc2(i))+w(xi‾)yc1(i)(1−yc2(i))+w(xi)(1−yc1(i))yc2(i)\widetilde{W}_i(y_{c_1(i)},y_{c_2(i)}):=(w(x_i)+w(\overline{x_i}))(1-y_{c_1(i)})(1-y_{c_2(i)})+w(\overline{x_i})y_{c_1(i)}(1-y_{c_2(i)})+w(x_i)(1-y_{c_1(i)})y_{c_2(i)}.

The above formulation has the same sum-product structure as its unweighted counterpart. It can therefore be evaluated by the same Split-and-List procedure using fast matrix multiplication, as described in Lemma 6. Consequently, the overall complexity is the same as that in Theorem 2.

Theorem 5. Weighted #2-occ-SAT with mm clauses can be solved in O∗(2mω/3)⊆O∗(1.7297m)O^*(2^{m\omega/3})\subseteq O^*(1.7297^m) time and exponential space, where ω<2.3714\omega<2.3714 denotes the matrix multiplication exponent.

Hardness of #d-occ-SAT

In this section, we prove Theorem 3, restated below.

Theorem 3. For every fixed d≥2d\geq2, there is a polynomial-time non-adaptive Turing reduction from #Max-dd-SAT on nn variables to #dd-occ-SAT on positive formulas with exactly nn clauses. Thus, for any constant γ≥1\gamma\geq1, an O∗(γm)O^*(\gamma^m)-time algorithm for the latter problem with mm clauses yields an O∗(γn)O^*(\gamma^n)-time algorithm for the former problem, preserving polynomial space.

Our proof uses polynomial interpolation, a technique for reductions between counting problems. It proceeds in three steps: first, encode the desired information in the coefficients of a polynomial of polynomially bounded degree; second, construct counting instances whose counts give the values of this polynomial at sufficiently many distinct points; and third, recover the polynomial by interpolation and decode the desired information from its coefficients. This paradigm has been used in counting-complexity reductions [25, 21, 33 DHM+14, Curl8].

Following this paradigm, our reduction has the following outline. Suppose Φ\Phi is the input #Max-dd-SAT formula.

  • Construct a polynomial PΦP_{\Phi} whose coefficients encode the optimum and the number of optimal assignments.

  • With the aim of constructing PΦP_{\Phi}, we first express assignment scores for #Max-dd-SAT as a sum of subset indicators. Similarly, we express the inclusion-exclusion formulation for #dd-occ-SAT on positive formulas in terms of subset indicators. This common structure guides the construction of PΦP_{\Phi} as well as the construction of #dd-occ-SAT instances.

  • Construct #dd-occ-SAT instances on positive formulas to realize evaluations of this polynomial. Each instance has one clause per variable of the #Max-dd-SAT instance.

  • Recover the polynomial by Lagrange interpolation and obtain the optimum and the number of optimal assignments from its coefficients.

Throughout this section, d≥2d \ge2 is fixed.

Two formulations over subsets

For every nonnegative integer kk, write [k]={1,…,k}[k] = \{1,\ldots,k\}, with [0]=∅[0] = \varnothing. For a proposition P\mathcal{P}, let 1[P]1[\mathcal{P}] be 1 if it holds and 0 otherwise. All empty products equal 1.

The formulation for #Max-dd-SAT

Let Φ=C1∧⋯∧Cm\Phi= C_1 \land\cdots\land C_m be the dd-CNF of the #Max-dd-SAT instance, over the variable set var⁡(Φ)={x1,…,xn}\operatorname{var}(\Phi) = \{x_1,\ldots,x_n\}. An assignment is represented by S={i∈[n]:xi=1}S = \{i \in[n] : x_i = 1\}. Its score is the number of clauses it satisfies. Each copy of an identical clause contributes separately to the score. Without loss of generality, we assume that Φ\Phi contains no tautological clauses.

For a clause CC, define C+={i:xi∈C}C^{+} = \{i : x_i \in C\} and C−={i:xi‾∈C}C^{-} = \{i : \overline{x_i} \in C\}. These sets are disjoint. Let score⁡C(S)\operatorname{score}_C(S) be 1 if the assignment SS satisfies CC and 0 otherwise. A clause is falsified exactly when all its literals are false. Expanding gives

score⁡C(S)=1−∏i∈C+(1−1[i∈S])∏i∈C−1[i∈S]=1−∑U⊆C+(−1)∣U∣1[C−∪U⊆S].(6)\begin{aligned} \operatorname{score}_C(S) &= 1 - \prod_{i \in C^{+}} (1 - 1[i \in S]) \prod_{i \in C^{-}} 1[i \in S] \\ &= 1 - \sum_{U \subseteq C^{+}} (-1)^{|U|}1[C^{-} \cup U \subseteq S]. \tag*{(6)} \end{aligned}

For example, for C=x1∨x2‾C = x_1 \lor\overline{x_2}, score⁡C(S)=1−1[{2}⊆S]+1[{1,2}⊆S]\operatorname{score}_C(S) = 1 - 1[\{2\} \subseteq S] + 1[\{1,2\} \subseteq S]. The score is 0 exactly when S={2}S = \{2\}, i.e., x1=0x_1 = 0 and x2=1x_2 = 1.

Let score⁡Φ(S)\operatorname{score}_{\Phi}(S) be the total number of clauses satisfied by SS, and let OPT⁡(Φ)=max⁡S⊆[n]score⁡Φ(S)\operatorname{OPT}(\Phi) = \max_{S \subseteq[n]} \operatorname{score}_{\Phi}(S). Every subset C−∪UC^{-} \cup U has size at most dd. Summing (6) and collecting identical subsets therefore produces integer coefficients aAa_A with

score⁡Φ(S)=∑A⊆[n]∣A∣≤daA1[A⊆S].(7)\operatorname{score}_{\Phi}(S) = \sum_{\substack{A \subseteq[n] \\ |A| \le d}} a_A 1[A \subseteq S]. \tag*{(7)}

The coefficients can be computed by expanding at most 2d2^d terms per clause.

The formulation for #d\#d-occ-SAT on positive formulas

Let Ψ=D1∧⋯∧DM\Psi= D_1 \land\cdots\land D_M be a positive dd-occ-CNF over var⁡(Ψ)\operatorname{var}(\Psi). For each y∈var⁡(Ψ)y \in\operatorname{var}(\Psi), define

Occ⁡y={i∈[M]:y∈Di}.(8)\operatorname{Occ}_y = \{i \in[M] : y \in D_i\}. \tag*{(8)}

The occurrence bound gives ∣Occ⁡y∣≤d|\operatorname{Occ}_y| \le d. For R⊆[M]R \subseteq[M], falsifying the clauses indexed by RR sets all variables in ⋃i∈RDi\bigcup_{i\in R} D_i to zero and leaves the others free. Inclusion-exclusion gives

#(Ψ)=∑R⊆[M](−1)∣R∣∣{σ:σ falsifies every Di, i∈R}∣=∑R⊆[M](−1)∣R∣2∣var⁡(Ψ)∣−∣⋃i∈RDi∣=∑R⊆[M](−1)∣R∣2∣{y∈var⁡(Ψ):Occ⁡y∩R=∅}∣=(−1)M∑S⊆[M](−1)∣S∣2∑y∈var⁡(Ψ)1[Occ⁡y⊆S].(9)\begin{aligned} \#(\Psi) &= \sum_{R\subseteq[M]}(-1)^{|R|}\left|\{\sigma: \sigma\text{ falsifies every }D_i,\ i\in R\}\right| \\ &= \sum_{R\subseteq[M]}(-1)^{|R|}2^{|\operatorname{var}(\Psi)|-\left|\bigcup_{i\in R}D_i\right|} \\ &= \sum_{R\subseteq[M]}(-1)^{|R|}2^{|\{y\in\operatorname{var}(\Psi):\operatorname{Occ}_y\cap R=\varnothing\}|} \\ &= (-1)^M\sum_{S\subseteq[M]}(-1)^{|S|}2^{\sum_{y\in\operatorname{var}(\Psi)}1[\operatorname{Occ}_y\subseteq S]}. \tag*{(9)} \end{aligned}

For the last equality, we substitute S=[M]∖RS = [M] \setminus R. Under this substitution, Occ⁡y∩R=∅\operatorname{Occ}_y \cap R = \varnothing becomes Occ⁡y⊆S\operatorname{Occ}_y \subseteq S, and ∣R∣=M−∣S∣|R| = M - |S| gives (−1)∣R∣=(−1)M(−1)∣S∣(-1)^{|R|} = (-1)^M(-1)^{|S|}.

The Reduction

With the formulations above, we are ready to present the reduction in Theorem 3. The main idea is as follows. Let Φ\Phi be the input dd-CNF on nn variables for #Max\#\mathrm{Max}-dd-SAT. Our aim is to construct a univariate polynomial PΦP_\Phi whose degree is polynomially bounded in the size of Φ\Phi and whose coefficients allow us to compute both OPT(Φ)\mathrm{OPT}(\Phi) and the number of assignments attaining this score. We construct PΦP_\Phi so that, for each integer r≥1r \ge1, we can build a positive dd-occ-CNF Ψr\Psi_r with exactly nn clauses satisfying #(Ψr)=(−1)nPΦ(2r)\#(\Psi_r) = (-1)^nP_\Phi(2^r). The number of satisfying assignments for Ψr\Psi_r therefore allows us to compute PΦ(2r)P_\Phi(2^r). Then, by choosing polynomially many distinct values of rr, we obtain sufficiently many evaluations to recover the coefficients of PΦP_\Phi using Lagrange interpolation. Finally, we use these coefficients to compute OPT(Φ)\mathrm{OPT}(\Phi) and the number of optimal assignments. Below, we first present the construction of PΦP_\Phi and then the construction of positive dd-occ-CNF Ψr\Psi_r.

Encoding the objective in a polynomial

For clarity, before defining the univariate polynomial PΦP_\Phi, we introduce an auxiliary multivariate polynomial QΦQ_\Phi:

QΦ(X,Y,Z)=∑S⊆[n](−1)∣S∣Xp(S)Yq(S)Z∣S∣,(10)Q_\Phi(X,Y,Z)=\sum_{S\subseteq[n]}(-1)^{|S|}X^{p(S)}Y^{q(S)}Z^{|S|}, \tag*{(10)}

where p(S)p(S) and q(S)q(S) are the sums of contributions from the positive and negative coefficients aAa_A with A≠∅A\ne\varnothing in (7), respectively, with the negative coefficients taken in absolute value:

p(S)=∑A≠∅aA>0aA1[A⊆S],q(S)=∑A≠∅aA<0(−aA)1[A⊆S].(11)p(S)=\sum_{\substack{A\ne\varnothing\\a_A>0}}a_A1[A\subseteq S],\qquad q(S)=\sum_{\substack{A\ne\varnothing\\a_A<0}}(-a_A)1[A\subseteq S]. \tag*{(11)}

Here and below, sums over AA range over subsets of [n][n] of size at most dd. Setting c=a∅c=a_\varnothing, we have

score⁡Φ(S)=c+p(S)−q(S).(12)\operatorname{score}_\Phi(S)=c+p(S)-q(S). \tag*{(12)}

We now give intuition behind the definition of QΦQ_{\Phi}. We want to evaluate a polynomial using the count of a #d\#d-occ-SAT instance on a positive formula. A natural starting point is the score generating function FΦ(X)=∑S⊆[n]Xscore⁡Φ(S)F_{\Phi}(X)=\sum_{S\subseteq[n]}X^{\operatorname{score}_{\Phi}(S)} (see, e.g., [32]). Its largest exponent is the optimum, and the corresponding coefficient is the number of optimal assignments. However, using it here faces two obstacles.

First, the formulation for #d\#d-occ-SAT on positive formulas in (9) contains the factor (−1)∣S∣(-1)^{|S|}. Incorporating this factor directly into FΦF_{\Phi} gives F~Φ(X)=∑S⊆[n](−1)∣S∣Xscore⁡Φ(S)\widetilde{F}_{\Phi}(X)=\sum_{S\subseteq[n]}(-1)^{|S|}X^{\operatorname{score}_{\Phi}(S)}. However, equal scores can receive opposite signs and cancel: if exactly two assignments have score jj, one with even ∣S∣|S| and one with odd ∣S∣|S|, the coefficient of XjX^j is 1−1=01-1=0. To prevent this cancellation, we can record ∣S∣|S| with an additional variable and use the modified polynomial

GΦ(X,Z)=∑S⊆[n](−1)∣S∣Xscore⁡Φ(S)Z∣S∣.G_{\Phi}(X,Z)=\sum_{S\subseteq[n]}(-1)^{|S|}X^{\operatorname{score}_{\Phi}(S)}Z^{|S|}.

All contributions to the coefficient of XjZhX^jZ^h now have the same sign (−1)h(-1)^h, so they cannot cancel.

Second, with M=nM=n, the exponent in (9) can be expressed as g(S)=∑AkA1[A⊆S]g(S)=\sum_A k_A\mathbf{1}[A\subseteq S], where kA≥0k_A\geq0 counts variables with occurrence set AA. However, the coefficients aAa_A in (7) may be negative, whereas each kAk_A must be nonnegative because it counts variables. Thus we record the contributions from positive and negative coefficients, represented by p(S)p(S) and q(S)q(S), in separate coordinates, yielding QΦQ_{\Phi} in (10), and subtract only when decoding c+p(S)−q(S)c+p(S)-q(S).

We then use QΦQ_{\Phi} to construct the desired univariate polynomial PΦP_{\Phi}. To this end, define

W=∑A≠∅∣aA∣,B=W+1.(13)W=\sum_{A\ne\varnothing}|a_A|,\qquad B=W+1. \tag*{(13)}

Thus 0≤p(S),q(S)<B0\leq p(S),q(S)<B. Expanding each clause gives terms whose absolute coefficient values sum to at most 1+2d1+2^d. Hence

B≤1+m(1+2d).(14)B\leq1+m(1+2^d). \tag*{(14)}

In particular, B=O(m)B=O(m) for fixed dd. Define the new univariate polynomial

PΦ(T)=QΦ(T,TB,TB2)=∑S⊆[n](−1)∣S∣TE(S),where E(S)=p(S)+Bq(S)+B2∣S∣.(15)P_{\Phi}(T)=Q_{\Phi}(T,T^B,T^{B^2})=\sum_{S\subseteq[n]}(-1)^{|S|}T^{E(S)},\qquad\text{where }E(S)=p(S)+Bq(S)+B^2|S|. \tag*{(15)}

Since 0≤p(S),q(S)<B0\leq p(S),q(S)<B for every assignment SS, the degree of PΦP_{\Phi} is at most

(B−1)+B(B−1)+B2n=B2(n+1)−1=:D.(16)(B-1)+B(B-1)+B^2n=B^2(n+1)-1=:D. \tag*{(16)}

For fixed dd, the bound DD is polynomial in the input size of the #Max\#\mathrm{Max}-dd-SAT instance.

Lemma 8 (Coefficient decoding). For every nonnegative integer ee, let beb_e denote the coefficient of TeT^e in PΦ(T)P_{\Phi}(T), and set pe=e mod Bp_e=e\bmod B, qe=⌊e/B⌋ mod Bq_e=\lfloor e/B\rfloor\bmod B, and he=⌊e/B2⌋h_e=\lfloor e/B^2\rfloor. Then be=(−1)he∣{S⊆[n]:E(S)=e}∣b_e=(-1)^{h_e}|\{S\subseteq[n]:E(S)=e\}| for every e≥0e\geq0. Define the support supp⁡(PΦ)={e:be≠0}\operatorname{supp}(P_{\Phi})=\{e:b_e\ne0\}, the set of exponents with nonzero coefficients. Then

OPT⁡(Φ)=c+max⁡e∈supp⁡(PΦ)(pe−qe).(17)\operatorname{OPT}(\Phi)=c+\max_{e\in\operatorname{supp}(P_{\Phi})}(p_e-q_e). \tag*{(17)}

Moreover, the number of optimal assignments is

∑e∈supp⁡(PΦ)c+pe−qe=OPT⁡(Φ)∣be∣.(18)\sum_{\substack{e\in\operatorname{supp}(P_{\Phi})\\c+p_e-q_e=\operatorname{OPT}(\Phi)}}|b_e|. \tag*{(18)}

Proof. For an assignment with E(S)=eE(S)=e, taking ee modulo BB gives p(S)=pep(S)=p_e. Taking ⌊e/B⌋\lfloor e/B\rfloor modulo BB gives q(S)=qeq(S)=q_e. Finally, 0≤p(S)+Bq(S)<B20\le p(S)+Bq(S)<B^2, so taking ⌊e/B2⌋\lfloor e/B^2\rfloor gives ∣S∣=he|S|=h_e. These statements remain valid for B=1B=1: then p=q=0p=q=0 and E(S)=∣S∣E(S)=|S|. Thus every assignment contributing to beb_e has sign (−1)he(-1)^{h_e}, proving the stated formula for beb_e. The coefficient beb_e is nonzero exactly when there is an assignment SS with E(S)=eE(S)=e. The identity score⁡Φ(S)=c+p(S)−q(S)\operatorname{score}_{\Phi}(S)=c+p(S)-q(S) then gives (17). The support is nonempty because there is at least one assignment and no coefficient cancellation. By this formula, ∣be∣|b_e| is the number of assignments with exponent ee, each having score c+pe−qec+p_e-q_e. Summing these counts over all ee with c+pe−qe=OPT⁡(Φ)c+p_e-q_e=\operatorname{OPT}(\Phi) therefore gives the number of optimal assignments, as stated in (18).

Realizing evaluations by #d-occ-SAT instances on positive formulas

For the given #Max-dd-SAT instance Φ\Phi and an integer r≥1r\ge1, we construct a positive CNF Ψr\Psi_r as follows. Create nn clauses D1,…,DnD_1,\ldots,D_n and introduce the following three groups of distinct fresh variables:

  • Group 1: For each nonempty AA with aA>0a_A>0, introduce raAra_A variables, each placed in exactly the clauses DiD_i with i∈Ai\in A.

  • Group 2: For each nonempty AA with aA<0a_A<0, introduce rB(−aA)rB(-a_A) variables, each placed in exactly the clauses DiD_i with i∈Ai\in A.

  • Group 3: For every i∈[n]i\in[n], introduce rB2rB^2 variables placed only in DiD_i.

All literals are positive. A variable from groups 1 and 2 has occurrence set AA, hence occurs in at most dd clauses; a variable from group 3 occurs once. These last variables also ensure that each clause is nonempty when n≥1n\ge1. The formula has exactly nn clauses.

Lemma 9 (Evaluation identity). For every integer r≥1r\ge1, #(Ψr)=(−1)nPΦ(2r)\#(\Psi_r)=(-1)^nP_{\Phi}(2^r).

Proof. Fix S⊆[n]S\subseteq[n]. Let V1,V2,V3V_1,V_2,V_3 be the sets of fresh variables introduced in groups 1, 2, and 3, respectively. They form a disjoint partition var⁡(Ψr)=V1∪˙V2∪˙V3\operatorname{var}(\Psi_r)=V_1\mathbin{\dot\cup}V_2\mathbin{\dot\cup}V_3. Each variable contributes 11 to the sum ∑y∈var⁡(Ψr)1[Occ⁡y⊆S]\sum_{y\in\operatorname{var}(\Psi_r)}\mathbf{1}[\operatorname{Occ}_y\subseteq S] if its occurrence set is contained in SS, and 00 otherwise.

For each nonempty AA with aA>0a_A>0, V1V_1 contains raAra_A variables with Occ⁡y=A\operatorname{Occ}_y=A. For each nonempty AA with aA<0a_A<0, V2V_2 contains rB(−aA)rB(-a_A) variables with the same occurrence set. For each i∈[n]i\in[n], V3V_3 contains rB2rB^2 variables with Occ⁡y={i}\operatorname{Occ}_y=\{i\}. Therefore, using the definitions of p(S)p(S) and q(S)q(S) in (11),

∑y∈V11[Occ⁡y⊆S]=r∑A≠∅aA>0aA1[A⊆S]=rp(S).\sum_{y\in V_1}\mathbf{1}[\operatorname{Occ}_y\subseteq S] =r\sum_{\substack{A\ne\varnothing\\a_A>0}}a_A\mathbf{1}[A\subseteq S] =rp(S).
∑y∈V21[Occ⁡y⊆S]=rB∑A≠∅aA<0(−aA)1[A⊆S]=rBq(S).\sum_{y\in V_2}\mathbf{1}[\operatorname{Occ}_y\subseteq S] =rB\sum_{\substack{A\ne\varnothing\\a_A<0}}(-a_A)\mathbf{1}[A\subseteq S] =rBq(S).
∑y∈V31[Occ⁡y⊆S]=rB2∑i∈[n]1[{i}⊆S]=rB2∣S∣.\sum_{y\in V_3}\mathbf{1}[\operatorname{Occ}_y\subseteq S] =rB^2\sum_{i\in[n]}\mathbf{1}[\{i\}\subseteq S] =rB^2|S|.

Summing over the partition gives

∑y∈var⁡(Ψr)1[Occ⁡y⊆S]=∑j=13∑y∈Vj1[Occ⁡y⊆S]=rp(S)+rBq(S)+rB2∣S∣=rE(S).\sum_{y\in\operatorname{var}(\Psi_r)}\mathbf{1}[\operatorname{Occ}_y\subseteq S] =\sum_{j=1}^{3}\sum_{y\in V_j}\mathbf{1}[\operatorname{Occ}_y\subseteq S] =rp(S)+rBq(S)+rB^2|S|=rE(S).

Substituting into the formulation for #d-occ-SAT on positive formulas in (9) with M=nM = n gives

#(Ψr)=(−1)n∑S⊆[n](−1)∣S∣2rE(S)=(−1)nPΦ(2r),\#(\Psi_r) = (-1)^n \sum_{S \subseteq[n]} (-1)^{|S|} 2^{rE(S)} = (-1)^n P_{\Phi}(2^r),

as required.

Putting it all together

We are now ready to prove Theorem 3.

Proof of Theorem 3. Let Φ\Phi be a given #Max-dd-SAT instance on nn variables. We compute its number of optimal assignments using #dd-occ-SAT queries on positive formulas with exactly nn clauses. With DD as defined in (16), query Ψr\Psi_r for r=1,…,D+1r = 1, \ldots, D + 1. Using the counts returned by these #dd-occ-SAT queries on positive formulas, Lemma 9 gives PΦ(2r)P_{\Phi}(2^r) at D+1D + 1 distinct points. Since the degree of PΦP_{\Phi} is at most DD, we can recover its coefficients from these D+1D + 1 values by Lagrange interpolation. Lemma 8 then gives OPT⁡(Φ)\operatorname{OPT}(\Phi) and the number of optimal assignments via (17) and (18), respectively.

We now analyze the time complexity of the reduction. Each coefficient aAa_A with A≠∅A \ne\emptyset contributes at most rB∣aA∣rB|a_A| variables, so the number NrN_r of variables in Ψr\Psi_r satisfies Nr≤r(BW+nB2)N_r \le r(BW + nB^2). There are D+1=B2(n+1)D + 1 = B^2(n + 1) queries, and each formula Ψr\Psi_r has length at most dNrdN_r. By the bound on BB in (14) and the definition of DD in (16), both the number of queries and the size of each formula are polynomial in the input size. Moreover, #(Ψr)≤2Nr\#(\Psi_r) \le2^{N_r}, so each returned count requires at most Nr+1N_r + 1 bits. Since the degree upper bound DD, the bit lengths of the points 2r2^r, and the bit lengths of the returned counts are all polynomially bounded in the input size, Lagrange interpolation can be performed in polynomial time. Summing the absolute values of the relevant coefficients takes polynomial time.

All queries depend only on Φ\Phi, so the reduction is non-adaptive. There are polynomially many queries, each with exactly nn clauses, and all remaining computation takes polynomial time. Thus an algorithm for #dd-occ-SAT on positive formulas running in O∗(γM)O^*(\gamma^M) time yields an algorithm for #Max-dd-SAT running in O∗(γn)O^*(\gamma^n) time. If the former algorithm uses polynomial space, so does the latter. This completes the proof.

Conclusion and Discussion

We have explored the complexity landscape of #SAT parameterized by the number of clauses mm. We have presented algorithms that break the 2m2^m-barrier for #kk-SAT and #2-occ-SAT, and these results naturally generalize to the weighted setting. Observe that if one recursively applies the clause branching rule to all clauses, the resulting search tree exactly corresponds to the standard subset-based inclusion-exclusion formulation. Basically, our algorithms exploit the specific structural properties of kk-CNF and 2-occ-CNF, respectively, to evaluate this formulation without explicitly exploring all 2m2^m terms.

For #dd-occ-SAT with d≥3d \ge3, our results suggest that breaking the 2m2^m-barrier may be difficult: for every fixed d≥3d \ge3, no O∗((2−ε)m)O^*((2-\varepsilon)^m)-time algorithm exists for any constant ε>0\varepsilon> 0, even on positive formulas, under the #Max-3-SAT Hypothesis. It is worth mentioning that, in contrast, the 2m2^m-barrier can be broken when computing only the parity of the number of satisfying assignments of a dd-occ-CNF [JPS+26].

Declarations

We used OpenAI ChatGPT to assist in proofreading, language polishing, and checking the clarity and logical consistency of the proofs, resulting in minor modifications. In addition, the idea for the reduction in Theorem 3 was suggested by ChatGPT-5.6 Sol; the authors checked its correctness and rewrote its exposition. The authors assume responsibility for all content.

References

References

  1. [1]Josh Alman, Ran Duan, Virginia Vassilevska Williams, Yinzhan Xu, Zixuan Xu, and Renfei Zhou. More asymmetry yields faster matrix multiplication. In Proceedings of the 2025 Annual ACM–SIAM Symposium on Discrete Algorithms (SODA 2025), pages 2005–2039, 2025. 3, 5arxiv.org/abs/2404.16349
  2. [2]Josh Alman and Virginia Vassilevska Williams. OV graphs are (probably) hard instances. In 11th Innovations in Theoretical Computer Science Conference (ITCS 2020), volume 151 of Leibniz International Proceedings in Informatics (LIPIcs), pages 83:1–83:18. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2020. 4DOI
  3. [3]Max Bannach, Erik D. Demaine, Timothy Gomez, and Markus Hecher. #p is sandwiched by one and two #2dnf calls: Is subtraction stronger than we thought? In Proceedings of the 40th Annual ACM/IEEE Symposium on Logic in Computer Science (LICS 2025), pages 31–43, 2025. 2, 3arxiv.org/abs/2506.06716
  4. [4]Max Bannach, Erik D. Demaine, Timothy Gomez, and Markus Hecher. A novel reduction from #SAT to #2SAT based on symmetry: Simply Drop the Large Clauses. In Proceedings of the 2026 Symposium on Simplicity in Algorithms (SOSA 2026), pages 254–265, 2026. 2, 3DOI
  5. [5]Karl Bringmann, Nick Fischer, and Marvin Künnemann. A fine-grained analogue of Schaefer’s theorem in P: Dichotomy of ∃k∀-quantified first-order graph properties. In Proceedings of the 34th Computational Complexity Conference (CCC 2019), volume 137 of Leibniz International Proceedings in Informatics (LIPIcs), pages 31:1–31:27. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2019. 4DOI
  6. [6]Joshua Brakensiek and Venkatesan Guruswami. Bridging between 0/1 and linear programming via random walks. In Proceedings of the 51st Annual ACM SIGACT Symposium on Theory of Computing (STOC 2019), pages 568–577, 2019. 2arxiv.org/abs/1904.04860
  7. [7]Marek Cygan, Holger Dell, Daniel Lokshtanov, Dániel Marx, Jesper Nederlof, Yoshio Okamoto, Ramamohan Paturi, Saket Saurabh, and Magnus Wahlström. On problems as hard as CNF-SAT. ACM Trans. Algorithms, 12(3):41:1–41:24, 2016. 2
  8. [8]Chris Calabro, Russell Impagliazzo, and Ramamohan Paturi. A duality between clause width and clause density for SAT. In Proceedings of the 21st Annual IEEE Conference on Computational Complexity (CCC 2006), pages 252–260, 2006. 2DOI
  9. [9]Stephen A. Cook. The complexity of theorem-proving procedures. In Proceedings of the 3rd Annual ACM Symposium on Theory of Computing (STOC 1971), pages 151–158, 1971. 2DOI
  10. [11][CW16] Timothy M. Chan and Ryan Williams. Deterministic apsp, orthogonal vectors, and more: Quickly derandomizing razborov-smolensky. In Proceedings of the 27th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA 2016), pages 1246–1255, 2016. 2, 3
  11. [12][CXZ21] Huairui Chu, Mingyu Xiao, and Zhe Zhang. An improved upper bound for SAT. Theor. Comput. Sci., 887:51–62, 2021. 2
  12. [13][DH21] Evgeny Dantsin and Edward A. Hirsch. Worst-case upper bounds. In Handbook of Satisfiability - Second Edition, pages 669–692. 2021. 2
  13. [15][FGK09] Fedor V. Fomin, Fabrizio Grandoni, and Dieter Kratsch. A measure & conquer approach for the analysis of exact algorithms. J. ACM, 56(5):25:1–25:32, 2009. 6DOI
  14. [16][GSS21] Carla P. Gomes, Ashish Sabharwal, and Bart Selman. Model counting. In Handbook of Satisfiability - Second Edition, pages 993–1014. 2021. 2
  15. [17][IMP12] Russell Impagliazzo, William Matthews, and Ramamohan Paturi. A satisfiability algorithm for AC⁰. In Proceedings of the 23rd Annual ACM-SIAM Symposium on Discrete Algorithms (SODA 2012), pages 961–972, 2012. 2, 3
  16. [18][IP01] Russell Impagliazzo and Ramamohan Paturi. On the complexity of k-SAT. J. Comput. Syst. Sci., 62(2):367–375, 2001. 2DOI
  17. [19][Iwa89] Kazuo Iwama. CNF satisfiability test by counting and polynomial average time. SIAM J. Comput., 18(2):385–391, 1989. 2, 3, 8DOI
  18. [21][JVW90] François Jaeger, Dirk L. Vertigan, and Dominic J. A. Welsh. On the computational complexity of the Jones and Tutte polynomials. Mathematical Proceedings of the Cambridge Philosophical Society, 108(1):35–53, 1990. 13DOI
  19. [22][JW20] Bart M. P. Jansen and Michał Włodarczyk. Optimal polynomial-time compression for boolean max CSP. In 28th Annual European Symposium on Algorithms (ESA 2020), volume 173 of Leibniz International Proceedings in Informatics (LIPICs), pages 63:1–63:19. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2020. 4
  20. [23][Koi06] Mikko Koivisto. Optimal 2-constraint satisfaction via sum-product algorithms. Information Processing Letters, 98(1):24–28, 2006. 8, 10DOI
  21. [24]Leonid A. Levin. Universal sequential search problems. Problems of Information Transmission, 9(3):265–266, 1973.
  22. [25]Nathan Linial. Hard enumeration problems in geometry and combinatorics. SIAM Journal on Algebraic and Discrete Methods, 7(2):331–335, 1986.DOI
  23. [26]Eliezer L. Lozinskii. Counting propositional models. Inf. Process. Lett., 41(6):327–332, 1992.
  24. [27]Andrea Lincoln, Virginia Vassilevska Williams, and Ryan Williams. Tight hardness for shortest cycles and paths in sparse graphs. In Proceedings of the 2018 Annual ACM-SIAM Symposium on Discrete Algorithms (SODA 2018), pages 1236–1252. SIAM, 2018.arxiv.org/abs/1712.08147
  25. [28]Jesper Nederlof. An invitation to “fine-grained complexity of NP-complete problems”. Computer Science Review, 61:100919, 2026.
  26. [29]Ramamohan Paturi, Pavel Pudlák, Michael E. Saks, and Francis Zane. An improved exponential-time algorithm for k-SAT. J. ACM, 52(3):337–364, 2005.
  27. [30]Junqiang Peng, Zimo Sheng, and Mingyu Xiao. New algorithms for #2-SAT and #3-SAT. In Proceedings of the 34th International Joint Conference on Artificial Intelligence (IJCAI 2025), pages 2666–2674, 2025.arxiv.org/abs/2507.14504
  28. [31]Uwe Schöning. A probabilistic algorithm for k-SAT and constraint satisfaction problems. In Proceedings of the 40th Annual Symposium on Foundations of Computer Science (FOCS 1999), pages 410–414, 1999.
  29. [32]Alexander D. Scott and Gregory B. Sorkin. Polynomial constraint satisfaction problems, graph bisection, and the Ising partition function. ACM Transactions on Algorithms, 5(4):45:1–45:27, 2009.DOI
  30. [33]Salil P. Vadhan. The complexity of counting in sparse, regular, and planar graphs. SIAM Journal on Computing, 31(2):398–427, 2001.DOI
  31. [34]Leslie G. Valiant. The complexity of computing the permanent. Theor. Comput. Sci., 8:189–201, 1979.DOI
  32. [35]Magnus Wahlström. A tighter bound for counting max-weight solutions to 2SAT instances. In Proceedings of the 3rd International Workshop on Parameterized and Exact Computation (IWPEC 2008), pages 202–213, 2008.DOI
  33. [36]Ryan Williams. A new algorithm for optimal 2-constraint satisfaction and its implications. Theoretical Computer Science, 348(2-3):357–365, 2005.DOI

AI tools statement

This work lists 2 AI tools.

  • OpenAI ChatGPT · AI tool

    Roles
    ValidationWriting — review & editing
    Verification
    self-declared at submission
  • GPT-5.6 Sol (bare) · AI tool

    Roles
    Conceptualization
    Verification
    self-declared at submission

Recorded on the work at submission, not per version. Names and roles are shown as submitted; roles use the CRediT taxonomy.

How AI tools are recorded

Paper details

Cite this paper

Publication

Published
Version
Latest

Data & code

No code, data or supplementary files were declared for this version.

Pick where to look, or just type