WorksComputer Science
Solving Restricted Versions of #SAT Faster than : Algorithms and Lower Bounds
Abstract
Under the Strong Exponential Time Hypothesis (SETH), for any constant , the #SAT problem (counting the number of satisfying assignments of a CNF formula) cannot be solved in or time, where is the number of variables and is the number of clauses. On the other hand, simple exhaustive search and the standard inclusion-exclusion give -time and -time algorithms, respectively. A natural line of research is to beat these SETH-based barriers for restricted versions, such as #-SAT (where each clause contains at most literals) or #-occ-SAT (where each variable appears in at most clauses). It is known that the -barrier can be broken when or is any constant; yet, whether the -barrier can also be broken in these cases remains unknown. We present two simple algorithms that overcome the -barrier. First, for #-SAT, we give an -time algorithm, thereby breaking the -barrier for any constant . Second, for #-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 , where 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--SAT to #-occ-SAT, showing that for any , #-occ-SAT admits no -time algorithm for any constant , even on positive formulas, under the hypothesis that #Max-3-SAT on variables admits no -time algorithm for any such .
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 possible assignments, SAT and #SAT can be solved in time, where omits polynomial factors in the input size and is the number of variables. However, no algorithm for SAT with runtime is known for any constant . Under the Strong Exponential Time Hypothesis (SETH) [18], no such algorithm exists.
While the -barrier is insurmountable under SETH for general SAT and #SAT, it can be broken for restricted classes of formulas. Notable examples include -CNF (where each clause contains at most literals) and -occ-CNF (where each variable appears in at most clauses). The corresponding problems are denoted by -SAT, -occ-SAT, #-SAT, and #-occ-SAT, respectively. It is well-established that -SAT can be solved in time via various algorithmic paradigms [29, 31, 11, 6], and -occ-SAT can be solved in 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 #-SAT in time and #-occ-SAT in 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 . The complexity landscape is markedly different under this parameterization. In particular, SAT can be solved in time [12], whereas #SAT can be solved in time via standard inclusion-exclusion [19, 26]. Moreover, the authors in [7] showed that no -time algorithm exists for any under SETH.
For restricted versions, it is known that weighted #2-SAT can be solved in time and exponential space [30] (the definition of the weighted setting is deferred later). Furthermore, an -time algorithm for general #SAT can be obtained by reducing an instance of length (the sum of the lengths of all clauses) to a weighted #2-SAT instance with clauses [3, 4] and invoking the aforementioned algorithm [30]. For #-SAT, since , this yields an -time algorithm and breaks the -barrier for #-SAT when . Nevertheless, whether this barrier can be broken for any arbitrary fixed remains unknown. Moreover, for #-occ-SAT, to the best of our knowledge, no algorithm was known to break the -barrier even for the most restrictive case of .
Why parameter . The parameters and capture two different natural search spaces: assignments of variables and subsets of clauses, underlying the -time exhaustive-search and -time inclusion-exclusion algorithms, respectively. Results parameterized by do not directly yield savings over the -barrier; for example, although a -CNF satisfies , this relation turns an -time algorithm only into an -time algorithm. Thus, parameter provides a natural perspective complementary to parameter .
Furthermore, #SAT parameterized by contains #All Set Cover parameterized by the universe size as a special case. Given a universe and subsets of (not necessarily distinct), #All Set Cover asks for the number of index sets such that . Introducing one variable for each and one positive clause for each gives a bijection between satisfying assignments and set covers, with .
Our main results. In this work, we present algorithms that break the -barrier for restricted versions of #SAT, namely #-SAT for any fixed and #2-occ-SAT, as well as hardness results for #-occ-SAT for every fixed via a reduction from #Max--SAT. Known results and our results for #SAT and its restricted versions are summarized in Table 1.
| Problems | Previous Results: Parameter | Previous Results: Parameter | Our Results |
| #SAT | <br>Det. & Poly-S | <br>Det. & Poly-S [19, 26] | — |
| #2-SAT | <br>Det. & Poly-S [35] | <br>Det. & Exp-S [30] | — |
| #-SAT () | <br>Rand. & Poly-S [17]<br>Det. & Exp-S [11] | for <br>Det. & Exp-S [3, 4, 30]<br> for | <br>Det. & Poly-S § 3 |
| #2-occ-SAT | <br>Det. & Exp-S [3, 4, 30] | <br>Det. & Exp-S § 4 | |
| #-occ-SAT () | <br>Rand. & Poly-S [17]<br>Det. & Exp-S [11] | No -time algorithm under the #Max-3-SAT Hypothesis<br>Section 6 |
Table 1. Summary of known results and our results. The runtime bound for #2-occ-SAT follows directly from the -time algorithm for #SAT since . Here, 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. #-SAT with clauses can be solved in time and polynomial space.
Theorem 2. #2-occ-SAT with clauses can be solved in time and exponential space, where denotes the matrix multiplication exponent.
An edge cover of a multigraph is a subset of edges incident to every vertex in , 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 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 clauses. To the best of our knowledge, no algorithm for #All Edge Cover with runtime for any was known. Our Theorem 2 implies an algorithm for #All Edge Cover:
Corollary 1. #All Edge Cover on multigraphs with vertices can be solve in 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 , #Max-3-SAT on variables cannot be solved in time.
Here, #Max--SAT asks for the number of truth assignments that maximize the number of satisfied clauses in a CNF formula whose clauses contain at most literals. We note that the stronger hypothesis that Max-3-SAT on variables cannot be solved in time for any constant has been used in the literature [27, 5, 22, 2]. We show that, for every fixed and constant , #-occ-SAT with clauses cannot be solved in 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 , there is a polynomial-time non-adaptive Turing reduction from #Max--SAT on variables to #-occ-SAT on positive formulas with exactly clauses. Thus, for any constant , an -time algorithm for the latter problem with clauses yields an -time algorithm for the former problem, preserving polynomial space.
We note that #-occ-SAT on positive formulas parameterized by the number of clauses is equivalent to #All Set Cover with sets of size at most 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 , each variable occurs in at most clauses. Conversely, #-occ-SAT on positive formulas also naturally reduces to #All Set Cover with sets of size at most : 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 , 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 , an algorithm for #All Edge Cover on multigraphs with vertices running in time and polynomial space yields an algorithm for #Max-2-SAT on variables running in time and polynomial space.
Corollary 3. For every fixed , #All Set Cover on a universe of elements with sets of size at most cannot be solved in time for any constant , under the #Max-3-SAT Hypothesis.
Preliminaries
Let be a set of Boolean variables. A Boolean variable can be assigned a value of 1 (True) or 0 (False). A variable has two corresponding literals: the positive literal and the negative literal . We use to denote the negation of literal , so . A clause on is a set of literals on , which might be empty. A CNF formula over is a multiset of clauses on , allowing identical clauses. Different copies of the same clause are treated as distinct. Let denote the variable set of . For a collection of clauses, we use to denote the set of literals appearing in the clauses of (i.e., if for some ).
An assignment for a variable set is a mapping . Given an assignment , a clause is satisfied by if at least one literal in it evaluates to 1 under . An assignment for is called a satisfying assignment (or model) of if satisfies all clauses in . We denote by the set of all satisfying assignments of , and let .
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 , denoted by , is the number of its occurrences in . A formula is called -CNF if each clause has length at most , and called -occ-CNF if each variable appears in at most clauses.
Throughout, we use to denote the matrix multiplication exponent, that is, a constant such that two matrices can be multiplied using arithmetic operations. Known matrix multiplication algorithms allow us to choose [1].
An Algorithm for #-SAT via Clause Branching
In this section, we present an -time branching algorithm for #-SAT, where is the number of clauses. We first introduce some necessary notation.
For a literal , let denote the formula obtained by assigning (removing clauses containing and deleting from others), and let . For a clause , we write to denote the formula obtained by falsifying , and let denote the formula obtained by removing (one copy of) from . 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 be a clause in formula . Then
Proof of Lemma 1. We partition the satisfying assignments of formula into those satisfying (which are exactly the satisfying assignments of formula ) and those falsifying . Since falsifying requires assigning 0 to all its literals, the number of such assignments is exactly . Thus, we have . Rearranging this equation yields the lemma. ▢
A clause is called isolated if all variables in only appear once in the formula, i.e., for all . 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 be an isolated clause in formula . Let denote the formula obtained by deleting and removing the variables in from the variable set. Then,
Proof of Lemma 2. Since is isolated, its variables do not appear in any other clause. Thus, the satisfying assignments of are the Cartesian product of the satisfying assignments of and those of . Exactly one of the assignments to falsifies , so has satisfying assignments. This yields the claimed equality.
The Algorithm
Let . If contains no tautological clauses, these are precisely the variables in that also appear in at least one other clause in . The algorithm, denoted as alg-count, recursively computes by applying the following steps in decreasing order of priority.
Step 1. Base Cases: If contains the empty clause, return 0. If , return .
Step 2. Tautological Clause Reduction: If there exists a clause containing both and for some variable , return alg-count, retaining the variable set.
Step 3. Isolated Clause Reduction: If there exists an isolated clause (i.e., ), apply Lemma Lemma 2 and return alg-count.
Step 4. Clause Branching: Select a pivot clause that minimizes . Since Steps 2 and 3 were not triggered, we are guaranteed that . Pick an arbitrary variable , and choose a neighboring clause such that . Apply the clause branching rule (Lemma Lemma 1) on and return alg-countalg-count.
To bound the size of the search tree generated by alg-count, we adopt the Measure and Conquer paradigm [15]. Let denote the number of clauses in . The measure of a formula is defined as:
where with the convention that . Intuitively, the fractional term tracks the progress toward isolating a clause. Since , we have . Thus, any bound of for some implies .
Lemma 3. Applying tautological clause reduction or isolated clause reduction does not increase the measure .
Proof of Lemma 3. For tautological clause reduction, let . Since and , we have .
For an isolated clause , . By the definition of , we have and . The reduction removes and , yielding a residual formula with . Although the new minimum might increase, it is bounded by . Thus, the new measure is:
Therefore, the measure never increases during this reduction.
Next, we analyze how the measure decreases in each recursive step. The key observation is that our pivot clause acts as a “witness” to prevent the fractional part of the measure from increasing after removing its neighboring clause , and even forces a decrease in the fractional part when falsifying .
Lemma 4. In Step 4 of the algorithm, branching on reduces the measure by at least in the branch and by at least in the branch .
Proof of Lemma 4. Let be the pivot clause chosen in Step 4, with .
Branch 1 (removing ): The formula becomes . The number of clauses decreases by 1, so . Since , the pivot clause remains in . Removing can only decrease or maintain the degrees of the remaining variables, so . The total measure drop is:
Branch 2 (falsifying ): The formula becomes . The clause count decreases by at least 1. Furthermore, since , falsifying assigns a truth value to . This removes from , which implies . Thus, and the measure drop is:
Note that if happens to be satisfied and hence removed as a side effect in the second branch, decreases by at least 2. Even if could increase from its minimum possible value of 1 to the maximum possible value of , the measure drop is at least . Thus, the claimed bounds hold in all cases.
With Lemma 3 and Lemma 4, we are ready to prove Theorem 1.
Theorem 1. -SAT with clauses can be solved in 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 denote the maximum number of leaves in the search tree of alg-count($\varphi$) for a formula of measure at most . 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 , respectively. Hence, at branching nodes, we have the following recurrence:
Since every measure is an integer multiple of , we prove by induction on that for . Note that this value is chosen for the simplicity of the proof, rather than optimizing the bound; we believe that the constant factor in 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 , substituting it into the recurrence gives:
To complete the inductive step, the right-hand side must be at most . Dividing this inequality by yields the condition:
Multiplying both sides by , we obtain the equivalent condition:
To verify this inequality, we apply the bounds and , which hold for . Since , the exponents and are in . Applying these bounds gives:
This completes the induction. The total running time is bounded by , which establishes the claimed bound since .
An Algorithm for #2-occ-SAT via Split-and-List
In this section, we present an -time algorithm for #2-occ-SAT, where 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 subsets of clauses, taking 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 over variables, let be the set of assignments that falsify clause . The number of satisfying assignments is given by . By the inclusion-exclusion principle, the cardinality of this union can be explicitly expanded as:
To express this more compactly, let denote the number of assignments that simultaneously falsify every clause in a given subset . We can then rewrite the formulation as a summation over all subsets of clauses:
We then translate Eq. (1) to an equivalent sum-product formulation. To this end, we introduce a vector of Boolean indicator variables , where its -th bit indicates whether the clause is included in the subset (i.e., ). The sign term naturally factorizes as .
Crucially, the term factorizes into the product of individual contributions from the variables. Recall that every assignment in should simultaneously falsify all clauses in , i.e., setting all literals in to false. Thus, for a variable , the number of valid Boolean assignments to meet this condition depends only on how it appears in the selected clauses , independent of all other variables. Specifically, its contribution is if both its positive and negative literals appear in (a logical conflict), if exactly one positive literal or exactly one negative literal appears (fixing its truth value), and if it does not appear in at all (leaving it free).
We introduce some notations before formally presenting the formulation. Let be a -occ-CNF over variables . Recall that for a variable , denotes the number of times it appears in . We assume without loss of generality that for all , as variables with can be trivially factored out. We partition the variable set into two disjoint subsets:
: the set of variables appearing exactly once. For each , let denote the index of the unique clause containing .
: the set of variables appearing exactly twice. For each , let and denote the indices of the two clauses containing , respectively.
We say a variable is mixed if it has both positive and negative literals in ; otherwise, is pure. The sum-product formulation is as follows.
Lemma 5 (sum-product formulation). For any -occ-CNF , it holds that
where and are local weight functions mapping the selection status of the clauses containing variable to the number of valid Boolean assignments of . Specifically, these functions are defined as follows:
For any , .
For any ,
Proof of Lemma 5. By substituting the indicator vector into Eq. (1), the summation over subsets transforms into a summation over , and the term transforms to . As established, factorizes into independent valid assignment counts for each variable. It suffices to verify that and correctly compute these counts for variables in and , respectively.
For a variable , the unique clause containing is selected if and only if . If , is free and has 2 valid assignments; if , its truth value is fixed to falsify the clause and has 1 valid assignment. The expression matches these counts.
For a variable , let and denote the Boolean selection indicators of its two clauses. We verify the soundness of for each type of :
is pure. The two literals of share the same polarity. Then, has 1 valid assignment if at least one of its clauses is selected (i.e., ), and has 2 valid assignments only if neither is selected (i.e., ). The expression matches this.
is mixed. The two literals of have opposite polarities. Selecting both clauses () leads to a conflict, leaving 0 valid assignments. Selecting exactly one clause () leaves 1 valid assignment, and selecting neither () leaves 2 valid assignments. The expression matches these counts.
Taking the product of these local functions over all variables reconstructs , 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 clauses into three equal groups and list the 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 time and space.
Proof of Lemma 6. For convenience, we extend unary local weight functions to binary. For each variable , let and . Eq. (2) becomes:
Assume without loss of generality that is divisible by 3 (padding with at most two unit clauses on fresh variables if necessary). We partition the clause indices into three disjoint subsets , , and , each of size . For any vector , let denote its projections onto the coordinates in , , and , respectively.
Let denote the set of clause indices associated with . Since for every , no set intersects all three subsets , , and . This bounded dependency allows us to partition the variable set as follows:
,
,
.
For each , where , both clause indices and lie in . Consequently, its local weight depends only on the sub-vectors and . We distribute the terms in Eq. (3) into three pairwise functions:
Multiplying these exactly reconstructs the summand. Thus, the formulation factorizes as:
We define three matrices , , and with entries , , and . Recall that the trace of a matrix , denoted by , 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:
We then analyze the time and space required by the above approach. Generating the matrices requires evaluating the pairwise functions for all sub-vector pairs, taking time and space. Computing the product via fast matrix multiplication takes time and space, which completes the proof.
Combining Lemma 5 and Lemma 6, we have:
Theorem 2. #2-occ-SAT with clauses can be solved in time and exponential space, where 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 be the set of literals over . Let be a weight function that assigns an integer weight (possibly negative) to each literal. Let be the set of all satisfying assignments of . The weighted model count is defined as
In the Weighted Model Counting (WMC) problem, given a formula and a weight function , the goal is to compute the weighted model count of formula . We denote by weighted -SAT and weighted -occ-SAT the restricted versions of WMC where the inputs are -CNF and -occ-CNF formulas, respectively.
Before detailing the specific extensions, we analyze the computational cost of handling weights. Let . Every integer arising in the branching recursion or the sum-product computation has absolute value at most and therefore has bit length . Thus, arithmetic operations on these numbers incur only a polynomial overhead, which is absorbed by the notation.
Weighted -SAT
The algorithm alg-count in § 3.2 can be modified for the weighted setting. For the base case where , the algorithm returns , which is the total weight of all possible assignments to the remaining variables. Tautology reduction applies unchanged in the weighted setting. For a clause , the clause branching rule (Lemma 1) generalizes to the weighted setting as follows:
Similarly, for an isolated clause , the reduction rule (Lemma 2) generalizes to:
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 into assignments satisfying and those falsifying . The former are precisely . The latter are in bijection with : each residual assignment extends uniquely by setting every literal in to false. The weight of this extension is the weight of the residual assignment multiplied by . Since the total weight is additive over disjoint sets of assignments, the subtraction correctly yields the total weight of . The isolated clause reduction holds because the weights of independent variables are multiplicative; the term represents the total weight of all assignments to the variables in , while is the weight of the unique assignment that falsifies .
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 -SAT with clauses can be solved in time and polynomial space.
Weighted #2-occ-SAT
The inclusion-exclusion formulation extends to the weighted setting: For a formula and weight function , let denote the total weight of assignments falsifying every clause in . Then it holds that . As in § 4, variables of degree zero can be factored out independently; in the weighted setting, each such variable contributes a factor . We therefore assume that every variable belongs to . Analogously to Lemma 5, then factorizes into the independent contributions of the variables.
Lemma 7 (weighted sum-product formulation). For any 2-occ-CNF and weight function , it holds that:
where the local functions and are defined as follows:
For , let be the literal of appearing in . Then .
For a pure variable , let be the literal of appearing in both and . Then .
For a mixed variable , we assume without loss of generality that contains the positive literal and contains the negative literal . Then .
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 clauses can be solved in time and exponential space, where denotes the matrix multiplication exponent.
Hardness of #d-occ-SAT
In this section, we prove Theorem 3, restated below.
Theorem 3. For every fixed , there is a polynomial-time non-adaptive Turing reduction from #Max--SAT on variables to #-occ-SAT on positive formulas with exactly clauses. Thus, for any constant , an -time algorithm for the latter problem with clauses yields an -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 is the input #Max--SAT formula.
Construct a polynomial whose coefficients encode the optimum and the number of optimal assignments.
With the aim of constructing , we first express assignment scores for #Max--SAT as a sum of subset indicators. Similarly, we express the inclusion-exclusion formulation for #-occ-SAT on positive formulas in terms of subset indicators. This common structure guides the construction of as well as the construction of #-occ-SAT instances.
Construct #-occ-SAT instances on positive formulas to realize evaluations of this polynomial. Each instance has one clause per variable of the #Max--SAT instance.
Recover the polynomial by Lagrange interpolation and obtain the optimum and the number of optimal assignments from its coefficients.
Throughout this section, is fixed.
Two formulations over subsets
For every nonnegative integer , write , with . For a proposition , let be 1 if it holds and 0 otherwise. All empty products equal 1.
The formulation for #Max--SAT
Let be the -CNF of the #Max--SAT instance, over the variable set . An assignment is represented by . 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 contains no tautological clauses.
For a clause , define and . These sets are disjoint. Let be 1 if the assignment satisfies and 0 otherwise. A clause is falsified exactly when all its literals are false. Expanding gives
For example, for , . The score is 0 exactly when , i.e., and .
Let be the total number of clauses satisfied by , and let . Every subset has size at most . Summing (6) and collecting identical subsets therefore produces integer coefficients with
The coefficients can be computed by expanding at most terms per clause.
The formulation for -occ-SAT on positive formulas
Let be a positive -occ-CNF over . For each , define
The occurrence bound gives . For , falsifying the clauses indexed by sets all variables in to zero and leaves the others free. Inclusion-exclusion gives
For the last equality, we substitute . Under this substitution, becomes , and gives .
The Reduction
With the formulations above, we are ready to present the reduction in Theorem 3. The main idea is as follows. Let be the input -CNF on variables for --SAT. Our aim is to construct a univariate polynomial whose degree is polynomially bounded in the size of and whose coefficients allow us to compute both and the number of assignments attaining this score. We construct so that, for each integer , we can build a positive -occ-CNF with exactly clauses satisfying . The number of satisfying assignments for therefore allows us to compute . Then, by choosing polynomially many distinct values of , we obtain sufficiently many evaluations to recover the coefficients of using Lagrange interpolation. Finally, we use these coefficients to compute and the number of optimal assignments. Below, we first present the construction of and then the construction of positive -occ-CNF .
Encoding the objective in a polynomial
For clarity, before defining the univariate polynomial , we introduce an auxiliary multivariate polynomial :
where and are the sums of contributions from the positive and negative coefficients with in (7), respectively, with the negative coefficients taken in absolute value:
Here and below, sums over range over subsets of of size at most . Setting , we have
We now give intuition behind the definition of . We want to evaluate a polynomial using the count of a -occ-SAT instance on a positive formula. A natural starting point is the score generating function (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 -occ-SAT on positive formulas in (9) contains the factor . Incorporating this factor directly into gives . However, equal scores can receive opposite signs and cancel: if exactly two assignments have score , one with even and one with odd , the coefficient of is . To prevent this cancellation, we can record with an additional variable and use the modified polynomial
All contributions to the coefficient of now have the same sign , so they cannot cancel.
Second, with , the exponent in (9) can be expressed as , where counts variables with occurrence set . However, the coefficients in (7) may be negative, whereas each must be nonnegative because it counts variables. Thus we record the contributions from positive and negative coefficients, represented by and , in separate coordinates, yielding in (10), and subtract only when decoding .
We then use to construct the desired univariate polynomial . To this end, define
Thus . Expanding each clause gives terms whose absolute coefficient values sum to at most . Hence
In particular, for fixed . Define the new univariate polynomial
Since for every assignment , the degree of is at most
For fixed , the bound is polynomial in the input size of the --SAT instance.
Lemma 8 (Coefficient decoding). For every nonnegative integer , let denote the coefficient of in , and set , , and . Then for every . Define the support , the set of exponents with nonzero coefficients. Then
Moreover, the number of optimal assignments is
Proof. For an assignment with , taking modulo gives . Taking modulo gives . Finally, , so taking gives . These statements remain valid for : then and . Thus every assignment contributing to has sign , proving the stated formula for . The coefficient is nonzero exactly when there is an assignment with . The identity then gives (17). The support is nonempty because there is at least one assignment and no coefficient cancellation. By this formula, is the number of assignments with exponent , each having score . Summing these counts over all with 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--SAT instance and an integer , we construct a positive CNF as follows. Create clauses and introduce the following three groups of distinct fresh variables:
Group 1: For each nonempty with , introduce variables, each placed in exactly the clauses with .
Group 2: For each nonempty with , introduce variables, each placed in exactly the clauses with .
Group 3: For every , introduce variables placed only in .
All literals are positive. A variable from groups 1 and 2 has occurrence set , hence occurs in at most clauses; a variable from group 3 occurs once. These last variables also ensure that each clause is nonempty when . The formula has exactly clauses.
Lemma 9 (Evaluation identity). For every integer , .
Proof. Fix . Let be the sets of fresh variables introduced in groups 1, 2, and 3, respectively. They form a disjoint partition . Each variable contributes to the sum if its occurrence set is contained in , and otherwise.
For each nonempty with , contains variables with . For each nonempty with , contains variables with the same occurrence set. For each , contains variables with . Therefore, using the definitions of and in (11),
Summing over the partition gives
Substituting into the formulation for #d-occ-SAT on positive formulas in (9) with gives
as required.
Putting it all together
We are now ready to prove Theorem 3.
Proof of Theorem 3. Let be a given #Max--SAT instance on variables. We compute its number of optimal assignments using #-occ-SAT queries on positive formulas with exactly clauses. With as defined in (16), query for . Using the counts returned by these #-occ-SAT queries on positive formulas, Lemma 9 gives at distinct points. Since the degree of is at most , we can recover its coefficients from these values by Lagrange interpolation. Lemma 8 then gives and the number of optimal assignments via (17) and (18), respectively.
We now analyze the time complexity of the reduction. Each coefficient with contributes at most variables, so the number of variables in satisfies . There are queries, and each formula has length at most . By the bound on in (14) and the definition of in (16), both the number of queries and the size of each formula are polynomial in the input size. Moreover, , so each returned count requires at most bits. Since the degree upper bound , the bit lengths of the points , 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 , so the reduction is non-adaptive. There are polynomially many queries, each with exactly clauses, and all remaining computation takes polynomial time. Thus an algorithm for #-occ-SAT on positive formulas running in time yields an algorithm for #Max--SAT running in 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 . We have presented algorithms that break the -barrier for #-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 -CNF and 2-occ-CNF, respectively, to evaluate this formulation without explicitly exploring all terms.
For #-occ-SAT with , our results suggest that breaking the -barrier may be difficult: for every fixed , no -time algorithm exists for any constant , even on positive formulas, under the #Max-3-SAT Hypothesis. It is worth mentioning that, in contrast, the -barrier can be broken when computing only the parity of the number of satisfying assignments of a -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]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]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]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]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]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]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]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]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]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
- [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
- [12][CXZ21] Huairui Chu, Mingyu Xiao, and Zhe Zhang. An improved upper bound for SAT. Theor. Comput. Sci., 887:51–62, 2021. 2
- [13][DH21] Evgeny Dantsin and Edward A. Hirsch. Worst-case upper bounds. In Handbook of Satisfiability - Second Edition, pages 669–692. 2021. 2
- [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
- [16][GSS21] Carla P. Gomes, Ashish Sabharwal, and Bart Selman. Model counting. In Handbook of Satisfiability - Second Edition, pages 993–1014. 2021. 2
- [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
- [18][IP01] Russell Impagliazzo and Ramamohan Paturi. On the complexity of k-SAT. J. Comput. Syst. Sci., 62(2):367–375, 2001. 2DOI
- [19][Iwa89] Kazuo Iwama. CNF satisfiability test by counting and polynomial average time. SIAM J. Comput., 18(2):385–391, 1989. 2, 3, 8DOI
- [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
- [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
- [23][Koi06] Mikko Koivisto. Optimal 2-constraint satisfaction via sum-product algorithms. Information Processing Letters, 98(1):24–28, 2006. 8, 10DOI
- [24]Leonid A. Levin. Universal sequential search problems. Problems of Information Transmission, 9(3):265–266, 1973.
- [25]Nathan Linial. Hard enumeration problems in geometry and combinatorics. SIAM Journal on Algebraic and Discrete Methods, 7(2):331–335, 1986.DOI
- [26]Eliezer L. Lozinskii. Counting propositional models. Inf. Process. Lett., 41(6):327–332, 1992.
- [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
- [28]Jesper Nederlof. An invitation to “fine-grained complexity of NP-complete problems”. Computer Science Review, 61:100919, 2026.
- [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.
- [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
- [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.
- [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
- [33]Salil P. Vadhan. The complexity of counting in sparse, regular, and planar graphs. SIAM Journal on Computing, 31(2):398–427, 2001.DOI
- [34]Leslie G. Valiant. The complexity of computing the permanent. Theor. Comput. Sci., 8:189–201, 1979.DOI
- [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
- [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.