complexity of generalized satisfiability counting problems

12
information and computation 125, 112 (1996) Complexity of Generalized Satisfiability Counting Problems Nadia Creignou Departement de Mathematiques, Universite de Caen, 14032 Caen, France and Miki Hermann* CRIN ( CNRS) and INRIA-Lorraine, BP 239, 54506 Vandsuvre-le s-Nancy, France The class of generalized satisfiability problems, introduced in 1978 by Schaefer, presents a uniform way of studying the complexity of satisfiability problems with special conditions. The complexity of each decision and counting problem in this class depends on the involved logical relations. In 1979, Valiant defined the class *P, the class of functions definable as the number of accepting computations of a polynomial-time nondeterministic Turing machine. Clearly, all satisfiability counting problems belong to this class *P. We prove a Dichotomy Theorem for generalized satisfiability counting problems. That is, if all logical relations involved in a generalized satisfia- bility counting problem are affine then the number of satisfying assignments of this problem can be computed in polynomial time, otherwise this function is *P-complete. This gives us a comparison between decision and counting generalized satisfiability problems. We can determine exactly the polynomial satisfiability decision problems whose number of solutions can be computed in polynomial time and also the polynomial satisfiability decision problems whose counting counterparts are already *P-complete. Moreover, taking advantage of a similar dichotomy result proved in 1978 by Schaefer for generalized satisfiability decision problems, we get as a corollary the implication that the counting counterpart of each NP-complete generalized satisfiability decision problem is *P-complete. ] 1996 Academic Press, Inc. 1. INTRODUCTION Counting problems represent the quantitative counter- part to decision problems. These problems arise naturally in situations where we are not interested principally in the existence of a solution but ask for the number of distinct solutions for a given problem, provided that there is only a finite number of them. Such problems were studied, e.g., in propositional logic and graph theory [Koz92, Val79a, Val79b], geometry and combinatorics [Lin86], in graph theory and network reliability [PB83], and in unification and matching [HK94]. Interesting insights can be found also in the work of Simon [Sim75, Sim77] and in a note by Galil [Gal74]. Valiant introduced in [Val79a, Val79b] the complexity class *P and proved several counting problems to be *P- complete. The class *P is defined as the class of counting problems computable in nondeterministic polynomial time. In other words, a function f belongs to *P if and only if there is a nondeterministic Turing machine M that runs in polynomial time with the property that f ( x ) equals the number of accepting computation paths of M on input x. Hence, *P can be also seen as a class of functions. The counting satisfiability problem is known to be *P- complete, mainly because Cook's generic transformation [Coo71] can be made parsimonious in the sense that the number of satisfying assignments to the Boolean formula corresponds exactly to the number of accepting computa- tions of the nondeterministic Turing machine being simulated, as pointed out first by Simon [Sim75]. For some decision problems that can be solved in polynomial time, the corresponding counting problems cannot be solved in polynomial time unless P=NP (and perhaps not even then), whereas for others, such as the spanning tree problem, the counting problems can be solved in polyno- mial time. We extend this classification to all satisfiability counting problems. We believe that this classification of satisfiability counting problems gives a better insight into the counting class *P. Moreover, as the *P-hardness of other counting problems is often proved by a reduction from a *P-complete satisfiability counting problem, this classification allows us to use the most suitable problem for that reduction and, hence, perform the *P-hardness proofs of other problems in a uniform way. Intuitively, it seems that for almost every NP-complete problem the corresponding counting problem is *P-com- plete. This is often stated in the literature [Joh90, p. 107; PB83, p. 779; Sim77, p. 484], but the explicit proofs are omitted. In fact, it is sometimes not straightforward to find an appropriate reduction [Val79b, Gal74, CH93]. Dichotomy results in complexity theory are usually rare. To our knowledge, there are only three such dichotomic article no. 0016 1 0890-540196 18.00 Copyright 1996 by Academic Press, Inc. All rights of reproduction in any form reserved. * Partially supported by Institute National Polytechnique de Lorraine Grant 910 0146 R1.

Upload: independent

Post on 15-Nov-2023

0 views

Category:

Documents


0 download

TRANSCRIPT

File: 643J 253801 . By:BV . Date:25:01:00 . Time:11:33 LOP8M. V8.0. Page 01:01Codes: 6844 Signs: 4804 . Length: 60 pic 11 pts, 257 mm

Information and Computation � IC2538

information and computation 125, 1�12 (1996)

Complexity of Generalized Satisfiability Counting Problems

Nadia Creignou

De� partement de Mathe� matiques, Universite� de Caen, 14032 Caen, France

and

Miki Hermann*CRIN (CNRS) and INRIA-Lorraine, BP 239, 54506 Vandsuvre-le� s-Nancy, France

The class of generalized satisfiability problems, introduced in 1978by Schaefer, presents a uniform way of studying the complexity ofsatisfiability problems with special conditions. The complexity of eachdecision and counting problem in this class depends on the involvedlogical relations. In 1979, Valiant defined the class *P, the classof functions definable as the number of accepting computationsof a polynomial-time nondeterministic Turing machine. Clearly, allsatisfiability counting problems belong to this class *P. We prove aDichotomy Theorem for generalized satisfiability counting problems.That is, if all logical relations involved in a generalized satisfia-bility counting problem are affine then the number of satisfyingassignments of this problem can be computed in polynomial time,otherwise this function is *P-complete. This gives us a comparisonbetween decision and counting generalized satisfiability problems. Wecan determine exactly the polynomial satisfiability decision problemswhose number of solutions can be computed in polynomial time andalso the polynomial satisfiability decision problems whose countingcounterparts are already *P-complete. Moreover, taking advantage ofa similar dichotomy result proved in 1978 by Schaefer for generalizedsatisfiability decision problems, we get as a corollary the implicationthat the counting counterpart of each NP-complete generalizedsatisfiability decision problem is *P-complete. ] 1996 Academic Press, Inc.

1. INTRODUCTION

Counting problems represent the quantitative counter-part to decision problems. These problems arise naturally insituations where we are not interested principally in theexistence of a solution but ask for the number of distinctsolutions for a given problem, provided that there is only afinite number of them. Such problems were studied, e.g., inpropositional logic and graph theory [Koz92, Val79a,Val79b], geometry and combinatorics [Lin86], in graphtheory and network reliability [PB83], and in unificationand matching [HK94]. Interesting insights can be foundalso in the work of Simon [Sim75, Sim77] and in a note byGalil [Gal74].

Valiant introduced in [Val79a, Val79b] the complexityclass *P and proved several counting problems to be *P-complete. The class *P is defined as the class of countingproblems computable in nondeterministic polynomial time.In other words, a function f belongs to *P if and only ifthere is a nondeterministic Turing machine M that runs inpolynomial time with the property that f (x) equals thenumber of accepting computation paths of M on input x.Hence, *P can be also seen as a class of functions.

The counting satisfiability problem is known to be *P-complete, mainly because Cook's generic transformation[Coo71] can be made parsimonious in the sense that thenumber of satisfying assignments to the Boolean formulacorresponds exactly to the number of accepting computa-tions of the nondeterministic Turing machine beingsimulated, as pointed out first by Simon [Sim75]. For somedecision problems that can be solved in polynomial time,the corresponding counting problems cannot be solved inpolynomial time unless P=NP (and perhaps not eventhen), whereas for others, such as the spanning treeproblem, the counting problems can be solved in polyno-mial time. We extend this classification to all satisfiabilitycounting problems. We believe that this classification ofsatisfiability counting problems gives a better insight intothe counting class *P. Moreover, as the *P-hardness ofother counting problems is often proved by a reductionfrom a *P-complete satisfiability counting problem, thisclassification allows us to use the most suitable problem forthat reduction and, hence, perform the *P-hardness proofsof other problems in a uniform way.

Intuitively, it seems that for almost every NP-completeproblem the corresponding counting problem is *P-com-plete. This is often stated in the literature [Joh90, p. 107;PB83, p. 779; Sim77, p. 484], but the explicit proofs areomitted. In fact, it is sometimes not straightforward to findan appropriate reduction [Val79b, Gal74, CH93].

Dichotomy results in complexity theory are usually rare.To our knowledge, there are only three such dichotomic

article no. 0016

1 0890-5401�96 �18.00

Copyright � 1996 by Academic Press, Inc.All rights of reproduction in any form reserved.

* Partially supported by Institute National Polytechnique de LorraineGrant 910 0146 R1.

File: 643J 253802 . By:BV . Date:25:01:00 . Time:11:33 LOP8M. V8.0. Page 01:01Codes: 6293 Signs: 5295 . Length: 56 pic 0 pts, 236 mm

classifications. The first one is a dichotomy result for thegeneralized satisfiability decision problem by Schaefer[Sch78]. The second one studies the H-coloring of graphs[HN90]. The third one studies the subgraph homeo-morphism problems [FHW80]. There was a fourth butunsuccessful attempt by Feder and Vardi [FV93] to provea dichotomy theorem for constraint satisfaction. Schaefer in[Sch78] gave conditions, in his Dichotomy Theorem,under which a satisfiability decision problem is in P; other-wise, it is NP-complete. The aim of this paper is to study thecomplexity of the corresponding counting problems. Inparticular, there are three interesting questions:

1. Is there also a dichotomy theorem for countingsatisfiability problems?

2. Is the counting counterpart of each NP-completesatisfiability decision problem *P-complete?

3. What is the class of polynomial time solvable decisionproblems, whose counting counterpart remains polyno-mially solvable, and conversely what are the polynomialtime solvable decision problems, whose counting counter-parts are already *P-complete?

In this paper we answer all three questions. We prove adichotomy theorem for satisfiability counting problems. Infact, this is the first dichotomic result for the class *P. It isinteresting to see that the dichotomic classification is pre-served for general satisfiability problems (even if the condi-tions in the Dichotomy Theorem change) during the movefrom decision to counting problems. In this way, we extenda classification proposed in [GJ79, p. 169]. We prove as acorollary that the NP-completeness of a satisfiability deci-sion problem implies the *P-completeness of the corre-sponding counting problem. This result confirms, for aninfinite and general class of problems, the intuitive opinionthat each NP-complete problem leads to a corresponding*P-complete counting problem.

There are two other results that are related to our work.Dubois [Dub91] pointed out that although the problem*2Sat (the problem of counting the number of satisfyingassignments of propositional formul$ in conjunctive nor-mal form with exactly two literals per clause) is *P-com-plete, the question ``Given a number n and a 2Sat formula,are there no more than n satisfying assignments?'' does havea pseudopolynomial algorithm. Roth [Rot93] gave acharacterization of *2Sat problems based on structuralproperties of the considered formul$. Roth's results areorthogonal to our Dichotomy Theorem that is based on acharacterization of the satisfiability counting problems interms of generalized connectives involved in the construc-tion of the considered formul$.

2. COUNTING CLASS *P

Let us recall some basic definitions and notions of count-ing complexity classes. More information on counting

classes can be found in Chapter 18 of the book [Pap94].Let 7 and 1 be nonempty alphabets, and let w : 7* �P(1*) be a mapping from the strings 7* to the power setof 1*. We refer to the elements of w(x) as witnesses for x andto w as witness function.

Let us denote the natural numbers by N, the integers byZ, the size of a string x by |x|, and the cardinality of a setA by |A|.

The following definition was given first by Valiant[Val79a, Val79b]. We introduce it in the formulation givenby Hemachandra and Ogiwara [HO92].

Definition 2.1. Let *accM be the function mappingfrom input x to the number of accepting paths of a non-deterministic Turing machine M on input x. The class *Pconsists of all functions *accM for all nondeterministicTuring machines M each of whose accepting path haspolynomial length with respect to the size of the input x.

Kozen [Koz92] gave another definition of the class *P.His definition is essentially equivalent to Valiant's. In hisformalism, the class *P is the class of witness functions wsuch that:

1. there is a polynomial-time algorithm to determine,for given x and y, if y # w(x);

2. there exists a constant k # N such that for all y # w(x),| y|�|x|k holds. (The constant k can depend on w).

By the same token, FP denotes the class of functionscalculable in deterministic polynomial time. Clearly, FP is asubclass of *P. It is important not to confuse the countingclasses FP and *P (i.e., classes that contain countingproblems or functions) with the classes P and NP (i.e.,classes that contain decision problems).

Counting problems relate to each other via countingreductions and parsimonious reductions, which are strongerthan the polynomial-time reductions between NP-problems.

Definition 2.2 [Koz92]. Let w : 7* � P(1*) andv : 6* � P(2*) be two counting problems. A polynomialmany-one counting reduction (or, simply, counting reduction)from w to v consists of a pair of polynomial-time com-putable functions _ : 7* � 6* and { : N � N such that theequality |w(x)|={( |v(_(x))| ) holds. When such a reductionexists we say that w reduces to v. Such reductions are oftencalled weakly parsimonious. A parsimonious reduction from vto w is a counting reduction _, { from v to w such that { isthe identity function.

The reductions in the *P-hardness proofs must preservethe number of solutions, whence the necessity to look forparsimonious or weakly parsimonious reductions. Notethat the composition of (weakly) parsimonious reductionsis a (weakly) parsimonious reduction.

2 CREIGNOU AND HERMANN

File: 643J 253803 . By:BV . Date:25:01:00 . Time:11:33 LOP8M. V8.0. Page 01:01Codes: 5934 Signs: 4471 . Length: 56 pic 0 pts, 236 mm

The *P-complete problems are the most difficultproblems in the class *P.

Definition 2.3. A counting problem w is *P-hard if forall problems v # *P there exists a counting reduction fromv to w. If in addition w is a member of *P, then we say thatthe counting problem w is *P-complete.

If w is a *P-complete problem and there is a countingreduction from w to v then v is a *P-hard problem. Provingthat a counting problem is *P-hard is viewed as evidencethat this problem is truly intractable. Actually, in com-plexity theory it is generally believed that *P-hardproblems are not members of the class FPH, the functionalanalog of the polynomial hierarchy PH. In particular, no*P-hard problem is known to belong to the class FPNP ofall functions that are computable in polynomial time usingNP oracles [Joh90, Section 4.1]. In contrast, Toda[Tod89] showed that the polynomial hierarchy is con-tained in the class P*P of problems computable in polyno-mial time with the help of *P-oracles. Thus, to the extentof course that one can compare decision problems withcounting problems, a *P-completeness result suggests ahigher level of intractability than an NP-completenessresult.

The following two *P-complete counting problems areused in the sequel to prove *P-hardness of the consideredsatisfiability counting problems.

Positive 2Sat (*pos-2sat) (called monotone in the originaltext) Valiant [Valiant-79b].

Instance: A set V of Boolean variables, a Boolean for-mula B over V in conjunctive normal form, where eachclause of B has exactly two positive literals.

Question: How many truth assignments for V satisfy B?

Implicative 2Sat (*impl-2sat) Linial [Lin86] based onProvan and Ball [PB83].

Instance: A set V of Boolean variables, a Boolean for-mula B over V in conjunctive normal form, where eachclause of B has exactly one positive and one negative literal.

Question: How many truth assignments for V satisfy B?

3. LOGICAL PRELIMINARIES

Note. Several parts of this section are taken from[Sch78] and are quoted only for self-containment of thepaper. Nevertheless, if a construction is defined differentlyfrom Schaefer's article, we explicitly point it out.

Let S=[R1 , ..., Rm] be a finite set of logical relations.A logical relation is defined to be any subset of [0, 1]k forsome integer k�1, called the rank of the relation. An S-for-mula is any conjunction of clauses, each of the form ri (v� ),

where v� =v1 , ..., vk are (not necessarily distinct) variableswhose number matches the rank of Ri , and ri is a relationsymbol representing the relation Ri . The S-satisfiabilitydecision problem is the problem of deciding whether a givenS-formula is satisfiable. The S-satisfiability counting problemis the problem of counting the satisfying assignments for agiven S-formula. We denote by Sat(S) the set of all satis-fiable S-formul$ and by *Sat(S ) the associated countingproblem.

Example 3.1. Consider the problem *1-in-3Sat ofcounting the satisfying assignments of a formula in con-junctive normal form with three literals per clause with theadditional requirement that in each clause only one literalevaluates to true. Every *1-in-3Sat problem can beexpressed as an S-satisfiability counting problem *Sat(S )with the set of logical relations S=[R0 , R1 , R2 , R3], wherethe relations are

R0=[(1, 0, 0), (0, 1, 0), (0, 0, 1)],

R1=[(0, 0, 0), (1, 1, 0), (1, 0, 1)],

R2=[(0, 1, 0), (1, 0, 0), (1, 1, 1)],

R3=[(0, 1, 1), (1, 0, 1), (1, 1, 0)].

Let us define the predicate 1-in-3, where 1-in-3(l1 , l2 , l3)requires one of the literals li to evaluate to true and the twoothers to false. A usual instance of 1-in-3Sat, like for example1-in-3(x, y, z) 7 1-in-3(u� , v, w) 7 1-in-3(u� , x� , y), is thengiven through the relation symbols ri by the conjunctionr0(x, y, z) 7 r1(u, v, w) 7 r2(u, x, y).

The main result of this paper characterizes the complexityof *Sat(S ) as properties of logical relations in the set S.

3.1. Notation

If x is a variable, x� denotes its negation. If A is a formula,Var(A) denotes the set of variables occurring in A. Wedenote by Sat(A) the set of assignments s : Var(A) �[0, 1] that satisfy the formula A. Let s, s1 , s2 # Sat(A) besatisfying assignments of the formula A. We define thefollowing four operations on assignments:

v s� =19 &s is defined by s� (x)=1 iff s(x)=0 and s� (x)=0otherwise,

v s=s1 �s2 is defined by s(x)=1 iff s1(x){s2(x) ands(x)=0 otherwise,

v s=s1 & s2 is defined by s(x)=1 iff s1(x)=s2(x)=1 ands(x)=0 otherwise,

v s=s1 _ s2 is defined by s(x)=0 iff s1(x)=s2(x)=0 ands(x)=1 otherwise.

3GENERALIZED SATISFIABILITY COUNTING PROBLEMS

File: 643J 253804 . By:BV . Date:25:01:00 . Time:11:33 LOP8M. V8.0. Page 01:01Codes: 6279 Signs: 4961 . Length: 56 pic 0 pts, 236 mm

The assignment s� is called the dual assignment to s, whereasthe assignments s1 & s2 and s1 _ s2 are called the directproduct and direct co-product, respectively, of the assign-ments s1 and s2 . If s is an assignment and V is a set ofvariables, then s |V denotes the restriction of the assignments to the variables V. If s : V � [0, 1] is an assignment thenthe inverse s&1: [0, 1] � 2V denotes the set of variabless&1(k) that is assigned by s to the Boolean constant k, fork # [0, 1].

Two formul$ A and B are logically equivalent if and onlyif they have have the same variable domains and their setsof satisfying assignments coincide, i.e., if the equalitiesVar(A)=Var(B) and Sat(A)=Sat(B) hold. Two formul$A and B are quasi-equivalent if and only if there exists abijection (a one-to-one and onto mapping) between the setsSat(A) and Sat(B), such that each pair of assignments sand s$ in the bijection coincides on the common variables ofthe formul$ A and B, i.e., such that the equality s(v)=s$(v)holds for every variable v # Var(A) & Var(B) whenever thepair of satisfying assignments s # Sat(A) and s$ # Sat(B)belongs to the bijective mapping. As a consequence, the setsof satisfying assignments Sat(A) and Sat(B) have the samecardinality. Obviously, quasi-equivalent formul$ need notto have the same variables. In the same way, two logicalrelations R and R$ are equivalent (resp. quasi-equivalent ) iffthey are defined by equivalent (quasi-equivalent) formul$.Note that both these equivalence relations are transitive, inthe case of quasi-equivalence modulo a possible variablerenaming. Let us point out that the notion of quasi-equiv-alence is new and was not introduced in Schaefer's article. Infact, Schaefer tried to get existential formul$ logicallyequivalent, for example, to (x6 y 6 z). Roughly speaking,existential formul$ preserve the notion of satisfiability butnot necessarily the number of satisfying assignments. Inorder to adapt Schaefer's proof to counting problems weintroduce the notion of quasi-equivalence. Allowing quasi-equivalent formul$ is similar in spirit to allowing existentialformul$ and in addition keeping control of the number ofsatisfying assignments. Let us point out that every formulaquasi-equivalent to one of x 6 y, x� 6 y or x� 6 y� necessarilycontains at least two different variables.

Example 3.2. The clauses x 6 y and x 6 z are quasi-equivalent. The formula (x� 6 y� ) 7 (z#x� y) is quasi-equivalent to the clause x� 6 y� , since the value of z isfunctionally dependent on the variables x and y.

We will use the notion of quasi-equivalence principally toexpress negation in formul$.

Example 3.3. Let A(x, y, z) be a Boolean formula. Theformula obtained by negating the variable x, namelyA(x� , y, z), is quasi-equivalent to A(x$, y, z) 7 (x$�x).

If A is a formula, v is a variable, and l is a literal or aBoolean constant 0 or 1, then A[l�v] denotes the formulaobtained from A by replacing each occurrence of v by l. IfV is a set of variables, then A[l�V] denotes the result ofsubstituting l for every occurrence of every variable in V. Wedenote by [A] the logical relation defined by the formulaA, when the variables are taken in lexicographic order.

The set of S-formul$ with constants, Gen(S), is thesmallest set of formul$ such that

v for all logical relations R # S and all variables v� , theformula r(v� ) belongs to Gen(S ), and

v for all formul$ A, B # Gen(S) and all variables x, v, thefollowing formul$ are all in Gen(S): A 7 B, A[x�v],A[0�v], and A[1�v].

Our definition of Gen(S ) differs from Schaefer's definition.We do not include formul$ with existential quantifiers(_v)A. The set of S-formul$ without Boolean constants 0and 1 is denoted by Gennc(S ).

We define the set of all relations that are representable byS-formul$ with Boolean constants as

Rep(S )=[[A]|A # Gen(S )]

and the set of all relations that are representable byS-formul$ without Boolean constants

Repnc(S )=[[A] | A # Gen(S ), 0 and 1

does not occur in A]

Repk(S ) is the set of all relations that are representable byS-formul$ with the Boolean constant k, where k # [0, 1].Gen+(S ) is the set of formul$ quasi-equivalent to a formulain Gen(S ). Rep+(S ), Rep+

nc (S ), and Rep+k (S ) are defined

from Rep(S ), Repnc(S ), and Repk(S ), respectively, in thesame way.

In the sequel, an implicative clause means a clause con-taining exactly one positive and one negative literal, i.e., aclause of the type x� 6 y.

Definition 3.4. A logical relation R is

0-valid if (0, ..., 0) # R, 1-valid if (1, ..., 1) # R;

weakly positive (respectively weakly negative) if the for-mula r(v� ) is logically equivalent to a formula in conjunctivenormal form having at most one negated (resp. unnegated)variable in each clause;

affine if the formula r(v� ) is logically equivalent to asystem of linear equations over the field Z�2Z ; that is, if theformula r(v� ) is logically equivalent to a system of linearequations of the forms v1� } } } �vn=0 and v1� } } } �vn

= 1, where � denotes the exclusive or connective;

4 CREIGNOU AND HERMANN

File: 643J 253805 . By:BV . Date:25:01:00 . Time:11:33 LOP8M. V8.0. Page 01:01Codes: 6383 Signs: 5036 . Length: 56 pic 0 pts, 236 mm

complementive if for every vector (a1 , ..., an) # R thereexists the complementary vector (1&a1 , ..., 1&an) # R ;

implicative if the formula r(v� ) is logically equivalent toa formula in conjunctive normal form whose every clause iseither unary or implicative.

Clauses with at most one unnegated variable are usuallycalled Horn clauses.

4. GENERAL SATISFIABILITY COUNTING PROBLEM

The rest of the article is devoted to the proof of the follow-ing dichotomy result.

Theorem 4.1 (Dichotomy Theorem). Let S be a finiteset of logical relations. If every relation in S is affine then*Sat(S ) is in FP, otherwise *Sat(S ) is *P-complete.

Together with Schaefer's Dichotomy Theorem, the pre-vious theorem immediately implies the following result.

Corollary 4.2. If Sat(S ) is NP-complete then*Sat(S ) is *P-complete.

Proof. Straightforward, because if S does not satisfy anyof the conditions in Schaefer's Dichotomy Theorem, that isif Sat(S ) is NP-complete, then S is non-affine. K

A variation of the *Sat(S ) problem allows the Booleanconstants 0 and 1 to occur in the formul$ (e.g. a clauser(x, 0, y) is allowed), denoted by *Satc(S ). By *Satk(S )we denote the variation of *Sat(S ), allowing only theBoolean constant k in the formul$, where k # [0, 1]. Weshow that if there is a non-affine relation in S then we canconstruct a parsimonious reduction from *Pos-2Sat or*Impl-2Sat to *Sat(S ), possibly using *Satc(S ) or*Satk(S ) as an intermediate problem.

The proofs of the first reduction, namely from *Pos-2Sator *Impl-2Sat to *Satc(S ) or *Satk(S ), obey the follow-ing principle. If the set of representable relations Rep+(S )contains the relations [x 6 y], [x� 6 y� ], or [x� 6 y], thenthere exists an S-formula A (possibly involving the Booleanconstants 0 and 1) quasi-equivalent to one of the clausesx6 y, x� 6 y� or x� 6 y. If there is a formula B in conjunctivenormal form with two literals per clause (a 2CNF formula)where all clauses are positive, negative or implicative, wecan construct a formula B$ quasi-equivalent to B by replac-ing each 2-clause by the formula A with appropriatevariables. This implies a parsimonious reduction from*Pos-2Sat or *Impl-2Sat to *Satc(S ) or *Satk(S ) fork # [0, 1].

Example 4.3. Let 1-in-3 be the predicate defined inExample 3.1. It is straightforward to get a parsimoniousreduction from the problem *Neg-2Sat (i.e., the problemof counting the satisfying assignments of a formula in

the conjunctive normal form where each clause is formed bytwo negative literals) to the problem *1-in-3Sat by observ-ing that the clause (x� 6 y� ) is quasi-equivalent to1-in-3(w� , x, y).

Theorem 4.4. Let S be a finite set of logical relations. Ifevery relation in S is affine then *Satc(S ) is in FP.Otherwise *Satc(S ) is *P-complete.

The proof of this theorem requires several intermediatelemmas. The analysis of this theorem needs a detailedknowledge of the affine and implicative logical relations.

The following result is a stability characterization ofaffine relations with respect to their set of satisfyingassignments in terms of a barycentre constructed by theexclusive-or connective.

Lemma 4.5. Let R be a logical relation and let A=r(v� )be the corresponding formula. Then

1. the relation R is affine if and only if for all satisfyingassignments s1 , s2 , s3 # Sat(A) the assignment s1�s2�s3

also satisfies A;

2. the relation R is affine and 0-valid if and only if the vec-tor 09 satisfies A and for all satisfying assignments s1 , s2 #Sat(A) the assignment s1 �s2 also satisfies the formula A;

3. the relation R is affine and 1-valid if and only if the vec-tor 19 satisfies A and for all satisfying assignmentss1 , s2 # Sat(A) the assignment s1�s2�19 also satisfies theformula A.

Proof. The characterization in the first point followsfrom a classical result in linear algebra. If a relation R isaffine, i.e., the formula A is logically equivalent to a systemof linear equations over the field Z�2Z , then for all satisfyingassignments s1 , s2 , s3 # Sat(A) (i.e., for all solutions s1 , s2 ,s3 of the previous system of linear equations) the assignments1�s2 �s3 also satisfies A. Conversely, if for all satisfyingassignments s1 , s2 , s3 # Sat(A) the membership s1�s2�s3

# Sat(A) holds, then the set Sat(A) can be seen as an affinesubspace over the field Z�2Z . Therefore, the set Sat(A) is theintersection of a finite number of kernels of affine transfor-mations. Hence, the formula A is logically equivalent to asystem of linear equations over the field Z�2Z .

Concerning point 2, suppose that for all satisfyingassignments s1 , s2 # Sat(A) the assignment s1�s2=s1�s2 �09 satisfies the formula A. Let s3 be an assignmentthat satisfies A. By assumption, the assignment(s1�s2 �09 )�s3�09 also satisfies A. Thus, we have themembership s1�s2 �s3 # Sat(A), since the connective � isassociative, commutative, and the axiom \x(x�09 =x)holds in the field. Hence, the fact that the relation R is affinefollows from point 1. Conversely, if the relation R is 0-validthen obviously 09 # Sat(A) holds. The rest follows, oncemore, from the point 1.

5GENERALIZED SATISFIABILITY COUNTING PROBLEMS

File: 643J 253806 . By:MC . Date:12:01:00 . Time:10:38 LOP8M. V8.0. Page 01:01Codes: 5488 Signs: 3965 . Length: 56 pic 0 pts, 236 mm

The proof of point 3 is almost identical to that of point 2,except that the identity 19 �19 =09 is used in addition duringthe evaluation of the assignment (s1�s2 �19 )�s3�19 . K

Lemma 4.6 (Negated Substitution). Let the relation[x�y] be included in Rep(S ). If a formula A belongs to theset Gen+(S ) and u, v are variables, then the formula A[v� �u]is contained in the set Gen+(S ), too.

Proof. By assumption, there exists a formula in Gen(S )logically equivalent to x�y, therefore we can construct theformula A[v$�u] 7 (v$�v). Note that A[v� �u] is quasi-equivalent to A[v$�u] 7 (v$�v) where v$ is a new variablenot occurring in A. K

The characterization given in Lemma 4.5 is used now tostudy the relations that are representable by a non-affineformula and the negation connective.

Lemma 4.7. Let R be a non-affine relation. Then the setRep+([R, [x�y]]) contains the relations [x6 y],[x� 6 y], [x 6 y� ] or [x� 6 y� ].

Proof. Let A=r(v� ) be the formula corresponding tothe relation R. The set of satisfying assignments Sat(A) isnonempty, since every empty relation R is affine. UsingLemma 4.5, let s0 , s1 , and s2 be assignments satisfying A,such that the assignment s0�s1 �s2 does not satisfy A.Create the formula A$ from A by negating all occurrencesof the variables in the set [v | s0(v)=1]. From the NegatedSubstitution Lemma it follows that the membershipA$ # Gen+([R, [x�y]) holds. Form the assignments si$=si�s0 , for i=1, 2. Observe that an assignment s satisfies theformula A$ iff the assignment s�s0 satisfies A. Thus, theassignments 09 , s$1 , s$2 all satisfy the formula A$, but theassignment s$1�s$2 does not satisfy it.

For i, j=0, 1, construct the sets

Vi, j=[v # Var(A$) | s$1(v)=i and s$2(v)= j ]

and create the new formula

B=A$[0�V0, 0 , x�V0, 1 , y�V1, 0 , z�V1, 1].

Clearly, the membership B # Gen+([R, [x�y]]) holds.Observe that at least two of the variables x, y, and z actuallyoccur in the formula B. Note that if the sets of variables V0, 1

FIG 1. Analysis of 16 cases for Lemma 4.7.

and V1, 0 are empty then s$1=s$2 holds. Thus, we get theequality s$1 �s$2=09 , contradicting the fact that 09 satisfies theformula A$ but the assignment s$1�s$2 does not satisfy it. Inthe same way, if the sets V0, 1 and V1, 1 are empty (respec-tively V1, 0 and V1, 1 are empty) then s$2=09 holds (respec-tively s$1=09 holds), thus we get the equality s$1�s$2=s$1(respectively s$1�s$2=s$2) that constitutes a contradiction.Hence, there are four cases to consider:

Case 1. All three variables x, y, and z occur in B. Theset of vectors

[(0, 0, 0), (0, 1, 1), (1, 0, 1)]

is called the base in the sequel. By the statement just madeabout satisfaction of the formula A$, the relation [B] mustcontain the base, but cannot contain the vector (1, 1, 0). Wedo not know whether the relation [B] contains the vectors(0, 0, 1), (0, 1, 0), (1, 0, 0), and (1, 1, 1). Therefore there are16 cases to analyze (see Fig. 1). We show that the formulaB with some constraints can always represent one of therelations [x 6 y], [x� 6 y], [x 6 y� ] or [x� 6 y� ].

Case 2. Only the variables x and y occur in B. Then therelation [B] contains the vectors (0, 0), (0, 1) and (1, 0) butnot (1, 1). Thus, the relation represented by the formula Bis [x� 6 y� ].

Case 3. Only the variables x and z occur in B. Then therelation [B] contains the vectors (0, 0), (0, 1) and (1, 1) butnot (1, 0). Thus, the relation represented by the formula Bis [x� 6 z].

Case 4. Only the variables y and z occur in B. Then therelation [B] contains the vectors (0, 0), (1, 1) and (0, 1) butnot (1, 0). Thus, the relation represented by the formula Bis [ y� 6 z].

Hence, in all cases the set Rep+([R, [x�y]) necessarilycontains one of the relations [x 6 y], [x� 6 y], [x6 y� ] or[x� 6 y� ]. K

We need the following technical lemma to establish therelation between implicative relations on one hand and rela-tions which are both weakly positive and weakly negativeon the other.

Lemma 4.8. A logical relation R is both weakly positiveand weakly negative if and only if R is implicative.

6 CREIGNOU AND HERMANN

File: 643J 253807 . By:BV . Date:25:01:00 . Time:11:33 LOP8M. V8.0. Page 01:01Codes: 6609 Signs: 5336 . Length: 56 pic 0 pts, 236 mm

Proof. Recall that H is a Horn formula, i.e., a formulain conjunctive normal form having at most one unnegatedvariable in each clause, if and only if for all satisfyingassignments s1 , s2 # Sat(H) the direct product s1 & s2 alsosatisfies H. This characterization of the weakly negativerelations is the propositional version of McKinsey'stheorem [McK43] and of a result proved in [Hor51] thatHorn sentences are preserved under direct products. Seealso the monographs [CK90, Section 6.2; Hod93, Sec-tion 9.1]. This result is also proved by Schaefer, with a dif-ferent vocabulary, in the Lemma 3.1W [Sch78, p. 220].

Suppose that R is both a weakly positive and weaklynegative logical relation. Let A be a formula in conjunctivenormal form having at most one negated variable in eachclause, logically equivalent to r(v� ). Such a formula existssince R is weakly positive. Thus, the formula A is logicallyequivalent to the conjunction �n

i=1 ci , where every ci is eithera unary clause, or a positive clause ci=(x1 6 } } } 6 xn), ora clause with one negative literal ci=(x� 1 6 x2 6 } } } 6 xn).Moreover, the formula A is logically equivalent to a Hornformula since the relation R is weakly negative.

First, consider a positive clause ci=(x1 6 } } } 6 xn) fromthe formula A. Take the generic assignment

s0= ,s # Sat(A)

s.

Since A is logically equivalent to a Horn formula, thegeneric assignment s0 satisfies the formula A. Thus, thereexists a variable xk , 1�k�n, such that the equalitys0(xk)=1 holds, since the clause ci is satisfiable by thegeneric assignment s0 . This means that the equalitys(xk)=1 holds for all assignments s # Sat(A), by definitionof the generic assignment s0 . Hence, the clause ci can bereplaced by the unary clause xk .

Second, consider a clause ci=(x� 1 6 } } } 6 xn) with onenegative literal. If s(x1)=0 holds for all assignmentss # Sat(A), then the clause ci can be replaced by the unaryclause x� 1 . Otherwise, let s1 be the assignment defined by

s1= ,s # Sat(A) s(x1)=1

s.

Since A is logically equivalent to a Horn formula, theassignment s1 satisfies A. Since s1(x1)=1 holds, there existsa variable xk, 2�k�n, such that the equality s1(xk)=1holds, since the clause ci is satisfiable by the assignment s1.This means that s(xk)=1 holds for all satisfyingassignments s # Sat(A) where s(x1)=1 holds. Thus, theclause ci can be replaced by the clause (x� 1 6 xk).

We proved that each clause ci of the formula A can bereplaced either by a unary clause or by an implicativeclause. Hence, the formula A is logically equivalent to aconjunction of unary and implicative clauses. Therefore, ifthe relation R is both weakly positive and weakly negativethen R is implicative.

Conversely, by definition every implicative relation isboth weakly positive and weakly negative. K

The following result is a stability characterization ofimplicative logical relations with respect to their set ofsatisfying assignments in terms of intersection (directproduct) and union (direct co-product). This characteriza-tion is used later to construct S-formul$ quasi-equivalent tothe clauses x 6 y, x� 6 y, x 6 y� or x� 6 y� .

Lemma 4.9. Let R be a logical relation and let A=r(v� )be the corresponding formula. The relation R is implicative ifand only if for all assignments s1 and s2 that satisfy the for-mula A, the assignments s1 _ s2 and s1 & s2 also satisfy A.

Proof. Recall that the formula A is logically equivalentto a Horn formula if and only if for all satisfyingassignments s1 , s2 # Sat(A) the direct product s1 & s2

also satisfies the formula A, as mentioned earlier at thebeginning of the proof of Lemma 4.8.

Similarly, from this characterization of the weaklynegative relations and the duality of the weakly positiverelations with respect to propositional Horn formul$ itfollows that the relation R is weakly positive if and only iffor all satisfying assignments s1 , s2 # Sat(A), the direct co-product s1 _ s2 also satisfies the formula A.

The lemma follows from these observations since everyimplicative relation is both weakly positive and weaklynegative, and conversely by Lemma 4.8, every relation thatis both weakly positive and weakly negative is animplicative relation. K

The previous characterization of implicative relations isused in the following lemma to study the relations that arerepresentable by a non-implicative formula.

Lemma 4.10. Let R be a logical relation. If R is notimplicative then the set Rep([R]) contains the relations[x�y], [x 6 y] or [x� 6 y� ].

Proof. Let R be a relation that is not implicative and letA=r(v� ) be the corresponding formula. From Lemma 4.9follows that there exist two assignments s1 and s2 satisfyingA, such that the assignment s1 & s2 or s1 _ s2 does not satisfythe formula A. Suppose, for example, that the direct products1 & s2 does not satisfy A (the other case is treated similarly).

For i, j=0, 1, construct the sets

Vi, j=[v # Var(A) | s1(v)=i and s2(v)= j ]

and create the formula

B=A[0�V0, 0 , x�V0, 1 , y�V1, 0 , 1�V1, 1].

Clearly, the membership B # Gen([R]) holds. Observe thatboth variables x and y occur in the formula B. Note that ifthe set of variables V0, 1 (respectively V1, 0) is empty, thenthe direct product s1 & s2 is equal to the assignment s2

(respectively s1), contradicting the fact according to whichthe assignment s2 (respectively s1) satisfies the formula A,

7GENERALIZED SATISFIABILITY COUNTING PROBLEMS

File: 643J 253808 . By:BV . Date:25:01:00 . Time:11:33 LOP8M. V8.0. Page 01:01Codes: 6738 Signs: 5571 . Length: 56 pic 0 pts, 236 mm

but the direct product s1 & s2 does not satisfy it. Hence, bothassignments s1 and s2 satisfy the formula B, but the directproduct s1 & s2 does not satisfy it. Therefore, the relation[B] contains the vectors (0, 1) and (1, 0), but does notcontain the vector (0, 0). Thus, depending on whether thevector (1, 1) is in [B], the relation [B] equals either[x�y] or [x 6 y]. K

In fact, in the proof of Theorem 4.4 we need to distinguishbetween affine and non-affine relations. In the presence of anon-affine relation we must distinguish whether this relationis implicative or not. Therefore we need to study the proper-ties of implicative relations.

Lemma 4.11. Let R be an implicative relation. Either R isaffine or the set Repnc([R]) contains the relation [x� 6 y].

Proof. Let R be an implicative relation and let A be aconjunction of implicative clauses logically equivalent tor(v� ) (for readability we suppose that A does not containany unary clause; the proof in the general case can be easilydeduced from this one). Associate with A the orientedgraph G=(V, A) where the variables V=Var(A) form theset of nodes and there exists an arc (xi � xj) # A iff (x� i 6 xj)is a clause of the formula A. Decompose G into stronglyconnected components. For each variable x, let C(x) be thestrongly connected component containing x. The sets C(x)partition the set of nodes V. Let C(x1), ..., C(xk) be such apartition. It is clear that all variables of a component C(x)are assigned the same value, otherwise we would have theimplication 1#0. Thus the formula A is quasi-equivalentto the formula A$=A[ y1 �C(x1), ..., yk �C(xk)]. The for-mula A$ contains only implicative clauses, i.e., clauses of thetype x� 6 y and x 6 y� .

Once more, associate with A$ the oriented graphG$=(V$, A$) where the variables V$=Var(A$) form the setof nodes and the membership ( yi � yj) # A$ holds iff( y� i 6 yj) is a clause of the formula A$ and i{ j. The graphG$ is acyclic since the strongly connected components of thegraph G have been replaced by new variables and the self-cycles y � y are ignored. There are two cases to analyze:

Case 1. All nodes of G$ are isolated, thus the set of arcsA$ is empty. This means that the formula A$ is a conjunc-tion of implicative clauses with two different variables, thusthe number of satisfying assignments of A$ is 2 |V$|=2k.Hence, the formula A is logically equivalent to the conjunc-tion �k

i=1 (�x # C(xi) (x#xi)). But this is the same as sayingthat the relation R is affine because the equivalence clausex#y is expressed as the equation x�y=0.

Case 2. There exists a non-isolated node, the set of arcsA$ is nonempty. Since the graph G$ is acyclic, it contains atleast one non-isolated node x with no predecessors. Con-struct a new formula B=A$[x�x, y�V$&[x]]. The for-mula B is a conjunction of implicative clauses with apossibility to repeat a variable in a clause. The clause

(x 6 y� ) does not occur in the formula B since the node xdoes not have a predecessor in the graph G. The clause(x� 6 y) occurs at least once in B because the node x is notisolated. Thus, the formula B is logically equivalent to theclause (x� 6 y), moreover the membership B # Gennc([R])holds. Hence, the relation [x� 6 y] is included in the setRepnc([R]).

Therefore, according to the emptyness of the set of arcsA$, we have proved that the relation R is either affine or wecan use it to represent the relation [x� 6 y] without usingthe Boolean constants. K

We have now assembled the information necessary toprove Theorem 4.4 (Dichotomy Theorem with constants),saying that if every relation in S is affine then the problem*Satc(S ) is in FP, otherwise *Satc(S) is *P-complete.

Proof of Theorem 4.4. If A is an affine S-formula, thenit can be transformed into an equivalent system of linearequations over Z�2Z . This system is transformed into a tri-angular system by Gauss' elimination method, a polynomialalgorithm, followed by elimination of the trivial equations0=0 and 1=1. If the equation 0=1 is deduced then thesystem has no solution. Otherwise, suppose that there are nvariables and n&k equations in the final triangular system.Then the number of solutions is 2k.

Suppose that S contains at least one non-affine relation R.There are two cases to analyze: either R is implicative or not.

If R is an implicative relation then the set Repnc([R])contains the relation [x� 6 y], following Lemma 4.11. If therelation R is not implicative then the intersectionRep([R]) & [[x�y], [x 6 y], [x� 6 y� ]] is nonempty,following Lemma 4.10. If the set Rep([R]) contains onlythe relation [x�y] then the intersection Rep+([R]) &

[[x 6 y], [x� 6 y� ], [x 6 y� ], [x� 6 y]] is nonempty,following Lemma 4.7. Hence, in all cases, if S contains anon-affine relation then there exists an S-formula B quasi-equivalent to one of the clauses x 6 y, x� 6 y� , x 6 y� orx� 6 y. Therefore there exists a parsimonious reduction from*Pos-2Sat (for x 6 y and x� 6 y� ) or *Impl-2Sat (for x 6 y�and x� 6 y) to *Satc(S ).

Membership in *P for *Satc(S ) is obvious. Hence,*Satc(S ) is *P-complete. K

To prove results on *Sat(S ), we use an intermediateproposition which, using Theorem 4.4, implies the proofof Theorem 4.1. The following intermediate propositionshows when there exists a (weakly) parsimonious reductionfrom a satisfiability counting problem with constants*Satc(S ) to a satisfiability counting problem without con-stants *Sat(S ).

Proposition 4.12. Let S be a finite set of logical rela-tions. If the relations in S are neither all 0-valid nor all1-valid then there exists a (weakly) parsimonious reductionfrom *Satc(S ) to *Sat(S ).

8 CREIGNOU AND HERMANN

File: 643J 253809 . By:BV . Date:25:01:00 . Time:11:33 LOP8M. V8.0. Page 01:01Codes: 6371 Signs: 4934 . Length: 56 pic 0 pts, 236 mm

To prove this proposition, we need once more a support-ing lemma.

Lemma 4.13. Let S be a nonempty finite set of logicalrelations. At least one of the following conditions holds:

1. Every relation in S is 0-valid.

2. Every relation in S is 1-valid.

3. The set Repnc(S ) contains the relation [x� 7 y].

4. The set Repnc(S ) contains the relation [x�y].

Moreover, if the conditions [x� 7 y] � Repnc(S ) and[x�y] # Repnc(S ) hold then every relation in S is com-plementive.

Proof. Assume that the relations in S are neither all0-valid nor all 1-valid. We show that at least one of the rela-tions [x� 7 y] and [x�y] belongs to the set Repnc(S ).There are two cases to analyze:

Case 1. Every relation in S is either 0-valid or 1-valid.Then the set S contains a relation R0 that is 0-valid but not1-valid and a relation R1 1-valid but not 0-valid. Let Ai=ri (v� ) be the formula corresponding to the relation R. Hence,the formula A0[x�Var(A0)] 7A1[y�Var(A1)] is logicallyequivalent to the conjunction x� 7 y, thus the relation[x� 7 y] is contained in the set Repnc(S ).

Case 2. The set S contains a relation R that is neither 0-valid nor 1-valid. Let A=r(v� ) be the formula corre-sponding to the relation R and let s be an assignmentssatisfying A. Construct the formula

B=A[x�s&1(0), y�s&1(1)].

By assumption, both variables x and y occur in the formulaB, and the relation [B] contains neither (0, 0) nor (1, 1).Hence, the relation [B] equals either [(0, 1)] or [(0, 1),(1, 0)]. Thus we have [B]=[x� 7 y] or [B]=[x�y].

Assume that the conditions [x�y] # Repnc(S ) and[x� 7 y] � Repnc(S ) hold. In order to produce a contradic-tion, suppose that the set S contains a non-complementiverelation R. Let A=r(v� ) be the formula corresponding tothe relation R. Take a satisfying assignment s # Sat(A),such that the dual assignment s� does not satisfy the formulaA. Construct the formula B=A[x�s&1(0), y�s&1(1)]. Weanalyze the occurrence of the variables x and y in the for-mula B.

Suppose that the variable x alone occurs in the formulaB, i.e., the equality [B]=[0] holds. Construct the formulaB$=B 7 (x�y). Hence, the relation [B$]=[(0, 1)] isrepresented by the conjunction (x� 7 y), what contradictsthe assumption that the set Repnc(S ) does not contain therelation [x� 7 y].

Suppose that the variable y alone occurs in the formulaB, i.e., the equality [B]=[1] holds. Construct once morethe formula B$=B 7 (x�y). The formula B$ implies thesame contradiction as in the previous case.

Suppose that both variables x and y occur in the formulaB. Then the relation [B] contains the vector (0, 1) but notthe vector (1, 0), since the assignment s is not complemen-tive. The relation [B] must contain also the vectors (0, 0)or (1, 1), since otherwise the set Repnc(S ) would contain therelation [x� 7 y]. We construct the formula B$=B 7

(x�y) that represents the relation [B$]=[x� 7 y], what isonce more a contradiction.

We have shown that if the set Repnc(S ) contains the rela-tion [x�y] but not the relation [x� 7 y] then every rela-tion in S must be complementive. K

We are ready now to prove the proposition on reductionsfrom *Satc(S ) to *Sat(S ) if S contains a relation that isnot 0-valid and a relation that is not 1-valid.

Proof of Proposition 4.12. By assumption, the relationsin S are neither all 0-valid nor all 1-valid. Hence, there aretwo cases to analyze, following Lemma 4.13.

Case 1. Let [x� 7 y] # Repnc(S ). Suppose that thereexists an S-formula A with constants. Construct theformula A$=A" 7 ( y� 0 7 y1), where A" is constructedfrom A by replacing each occurrence of the Booleanconstant k by the new variable yk , for k=0, 1. Hence, A$ isan S-formula without constants. We show that theformul$ A and A$ are quasi-equivalent.

The formula A$ is satisfiable if and only if A is satisfiable.Moreover, if the assignment s satisfies A then there exists aunique extension s$, such that the assignment s equals therestriction s$ | Var(A) and the equalities s$( yk)=k hold fork=0, 1.

Conversely, let s$ be an assignment satisfying the formulaA$. Since the conjunction ( y� 0 7 y1) is a subformula of A$,the equalities s$( yk)=k hold for k=0, 1 and the restrictions$ | Var(A) satisfies the formula A.

Thus, we have a one-to-one mapping between the satisfy-ing assignments Sat(A) and Sat(A$) that implies a par-simonious reduction from *Satc(S ) to *Sat(S ).

Case 2. Let [x�y] # Repnc(S ) and assume that everyrelation in S is complementive. Suppose there is an S-for-mula A with constants. Construct, similarly to the previouscase, the formula A$=A 7 ( y0�y1), where A" is con-structed from A (as in the previous case) by replacing eachoccurrence of the Boolean constant k by the new variableyk , for k=0, 1. Hence, A$ is an S-formula without con-stants.

The formula A is satisfiable if and only if A$ is satisfiable,since every relation in S is complementive. Moreover, if theassignment s satisfies A then there are two assignments s$and s� $ that satisfy A$, such that s equals the restriction

9GENERALIZED SATISFIABILITY COUNTING PROBLEMS

File: 643J 253810 . By:BV . Date:25:01:00 . Time:11:33 LOP8M. V8.0. Page 01:01Codes: 6573 Signs: 5310 . Length: 56 pic 0 pts, 236 mm

s$ | Var(A) , the equalities s$( yk)=k hold for k=0, 1, ands� $=19 &s$ is the dual assignment to s$. The assignment s$and its dual s� $ both satisfy the formula A$, since every rela-tion in S is complementive.

Conversely, let s$ be an assignment satisfying the formulaA$. If the equalities s$( yk)=k hold for k=0, 1 then therestriction s$ | Var(A) satisfies the formula A. If the equalitiess$( yk)=1&k hold for k=0, 1 then the dual 19 &s$ | Var(A) ofthe restriction satisfies A.

Thus, in the second case we get the equality |Sat(A$)|=2|Sat(A)|, therefore the proposed reduction is weakly par-simonious with factor 2.

In both cases we showed that there exists a (weakly) par-simonious reduction from an S-formula with constants toan S-formula without constants. K

In the case when the relations in S are all 0-valid (or1-valid), the problem *Satc(S ) is not a suitable inter-mediate problem. The difficulty in this case is that the twodifferent Boolean constants cannot be both defined by an S-formula. If every relation in S is 0-valid (resp. 1-valid) thenall relations that are representable by S-formul$ are still 0-valid (resp. 1-valid). Thus, the relation [x] (resp. [x� ]) doesnot belong to the set Repnc(S ). Therefore we need to restrictthe intermediate problem to the case where only oneBoolean constant is authorized in the formul$. For all casesnot treated by Proposition 4.12, the suitable intermediateproblem is Satk(S ) for k=0 or k=1.

Lemma 4.14. Let R be a k-valid and non-affine relation,where k # [0, 1]. Then the set Rep+

k ([R]) contains the rela-tions [x 6 y], [x� 6 y], [x 6 y� ] or [x� 6 y� ].

Proof. The proof is similar to the proof of Lemma 4.7.We assume that k=0, i.e., that R is a 0-valid and non-affinerelation. The proof for k=1, i.e., for a 1-valid relation R, issimilar.

Let A=r(v� ) be the formula corresponding to the relationR. Following Lemma 4.5, point 2, there are satisfyingassignments s1 , s2 # Sat(A), such that the assignments1�s2 does not satisfy the formula A. Form the sets Vi, j=[v # Var(A) | s1(v)=i 7 s2(v)= j ] and construct the for-mula B=A[0�V0, 0 , x�V0, 1 , y�V1, 0 , z�V1, 1]. Clearly, themembership B # Gen+

k ([R]) holds. Observe that at leasttwo of the variables x, y, and z occur in the formula B. Theargument is identical to that of Lemma 4.7. Hence, there arefour cases to consider:

Case 1. All three variables x, y, and z occur in the for-mula B. Thus, the relation [B] must contain thebase=[(0, 0, 0), (0, 1, 1), (1, 0, 1)], but cannot contain thevector (1, 1, 0) since the assignment s1�s2 does not satisfythe formula A. There are, once more, 16 cases to analyze,depending on the occurrence of the vectors (1, 1, 1),(1, 0, 0), (0, 1, 0), and (0, 0, 1) in the relation [B]. Almostall the cases are identical to those of Fig. 1, except two.

These two cases are those where a variable in the formula Bis replaced by the Boolean constant 1. We are obliged toreplace variables in B only by the Boolean constant 0, or torename variables, since the Boolean constant 1 is notauthorized in S-formul$ (when we choose k=0). Thus, wechange these two replacements to:

v if [B]=base _ [(1, 1, 1)] then the formulaB[ y$�[ y, z]] is quasi-equivalent to the clause x� 6 y$;

v if [B]=base _ [(0, 0, 1), (1, 0, 0)] then the formulaB[0�x] is quasi-equivalent to the clause y� 6z.

The other cases for different occurrences of the variablesx, y, and z in B are identical to those of Lemma 4.7.

The case for k=1 is similar to the previous method. Inthis case, it is necessary to replace variables in the formulaB only by the Boolean constant 1, or to rename variables,since only the Boolean constant 1 is authorized in S-for-mul$. Thus, we must change all replacements by theBoolean constant 0 to 1 in Fig. 1. The details should be evi-dent to the reader. K

We can now compose the reductions from *Pos-2Sat or*Impl-2Sat to *Satc(S ), following Theorem 4.4, or to*Satk(S ), following Lemma 4.14, and from these to*Sat(S ).

Proof of Theorem 4.1. If A is an affine S-formula, thenit can be transformed to an equivalent system of linear equa-tions over the field Z�2Z and solved by Gaussian elimina-tion, as in the proof of Theorem 4.4. Thus, if the formula Ais affine, the number of solutions can be computed in poly-nomial time.

Suppose that the set S contains a non-affine relation.Membership in *P for *Sat(S ) is obvious, as for*Satc(S ). Concerning *P-hardness, there are three casesto analyze:

Case 1. The set S contains a non-affine relation that isneither 0-valid nor 1-valid. Since S contains a non-affinerelation, the problem with constants *Satc(S ) is *P-com-plete. Using Proposition 4.12, there exists a (weakly) par-simonious reduction from *Satc(S ) to *Sat(S ), since therelations in S are neither all 0-valid nor all 1-valid.

Case 2. The set S contains a non-affine relation R thatis k-valid and not (1&k)-valid, where k # [0, 1]. Thereexists a parsimonious reduction to *Satk([R]), either from*Pos-2Sat (for the clauses x 6 y and x� 6 y� ) or from*Impl-2Sat (for the clauses x 6 y� and x� 6 y), followingLemma 4.14. If there is a formula A=r(v� ) containing theBoolean constant k then we construct the formula A$ fromA by replacing each occurrence of the constant k by the newvariable xk , for k # [0, 1]. Hence, we construct a new for-mula A$ 7 A[xk�Var(A)] quasi-equivalent to A. Thisimplies a parsimonious reduction from *Satk(S ) to*Sat(S ).

10 CREIGNOU AND HERMANN

File: 643J 253811 . By:BV . Date:25:01:00 . Time:11:33 LOP8M. V8.0. Page 01:01Codes: 6296 Signs: 5044 . Length: 56 pic 0 pts, 236 mm

Case 3. The set S contains a non-affine relation R thatis 0-valid and 1-valid.

If R is a complementive relation then there exists aparsimonious reduction to the problem *Sat0([R])following Lemma 4.14, either from *Pos-2Sat or from*Impl-2Sat. Let A=r(v� ) be a formula containing theBoolean constant 0. We construct the formula A$ from Aby replacing each occurrence of 0 by the new variable x0 .Thus, we get the equality |Sat(A$)|=2|Sat(A)|, sincethe relation R is complementive. This implies a weakly par-simonious reduction from *Sat0(S ) to *Sat(S ).

If R is a non-complementive relation then there exists aparsimonious reduction to the problem *Sat([R]) from*Impl-2Sat. Let A=r(v� ) be the formula corresponding tothe relation R. Take a satisfying assignment s # Sat(A),such that the dual assignment s� does not satisfy the formulaA. Form the sets of variables

V0=[x # Var(A) | s(x)=0]

and

V1=[x # Var(A | s(x)=1],

and construct the formula B=A[x�V0 , y�V1]. It is easy tosee that the relation [B] equals [x� 6 y], since theassignments s, 09 and 19 satisfy the formula A, whereas thedual assignment s� does not satisfy it. Hence, the relation[x� 6 y] is included in the set Repnc([R]). This implies aparsimonious reduction from *Impl-2Sat to *Sat(S ).

Thus, if the set S contains a non-affine relation, then*Sat(S ) is a *P-complete problem. K

5. CONCLUSION

Our main result is a dichotomy theorem, thus theclassification for *P is complete, provided that FP is dif-ferent from *P. There are three particular situations topoint out.

If Sat(S ) is an NP-complete problem, we deriveautomatically that the corresponding counting problem*Sat(S ) is *P-complete.

Example 5.1. Not-All-Equal 3Sat and 1-in-3Sat areNP-complete decision problems, as pointed out in [Sch78,GJ79], thus their corresponding counting problems are*P-complete.

We can recognize all polynomial satisfiability decisionproblems whose corresponding counting problem is *P-complete.

Example 5.2. The satisfiability of a propositional Hornformula is a problem solvable in polynomial time, sinceevery Horn formula is equivalent to a weakly negative logi-cal relation and Schaefer's Dichotomy Theorem applies.On the other hand, counting the number of satisfying

assignments of a Horn formula is a *P-complete problem,since there are propositional Horn formul$ representingnon-affine relations.

We can recognize all polynomial satisfiability decision pro-blems whose corresponding counting problem is polynomial.

Example 5.3. *2-Colorability of a graph can be solvedin polynomial time since it is equivalent to the problem*Sat([E ]) where E(x, y)=(x�y=1).

We think that these results contribute to a better under-standing of the class *P. Moreover, our DichotomyTheorem considerably simplifies the proof of other *P-hard problems. Such proofs can now be made straight-forward homogeneously from a general counting satis-fiability problem.

A natural question arises immediately, whether there is acomparable dichotomic result for counting H-colorings ofgraphs. Unfortunately, the proof of Hell and Nes� etr� il[HN90] cannot be adapted to counting as in the case ofSchaefer's proof, since it uses combinatoric properties ofgraphs.

ACKNOWLEDGMENTS

We thank Phokion Kolaitis who advised us to look at Schaefer's articleand proposed the development of a similar concept for satisfiability count-ing problems. We are grateful to Etienne Grandjean for suggesting severalinteresting references and for helpful discussions. We also thank theanonymous referee for his numerous suggestions that helped us ameliorateour article. Our special thanks to the Computer Science Laboratory ofE� cole Normale Supe� rieure, especially to Laurent Fribourg, who gratefullyprovided us with a meeting room on several occasions.

Received April 22, 1994; final manuscript received September 6, 1995

REFERENCES

[CH93] Creignou, N., and Hermann, M. (1993), ``On *P-Complete-ness of Some Counting Problems,'' Research report 2144,Institut de Recherche en Informatique et en Automatique.

[CK90] Chang, C. C., and Keisler, H. J. (1990), ``Model Theory,'' 3rded., Studies in Logic and the Foundation of Mathematics,Vol. 73, North-Holland, Amsterdam.

[Coo71] Cook, S. A. (1971), The complexity of theorem-proving proce-dures, in ``Proceedings 3rd Symposium on Theory of Comput-ing, Shaker Heights, OH,'' pp. 151�158, ACM, New York.

[Dub91] Dubois, O. (1991), Counting the number of solutions forinstances of satisfiability, Theor. Comput. Sci. 81(2), 49�64.

[FHW80] Fortune, S., Hopcroft, J., and Wyllie, J. (1980), The directedsubgraph homeomorphism problem, Theor. Comput. Sci.10(2), 111�121.

[FV93] Feder, T., and Vardi, M. Y. (1993), Monotone monadic SNPand constraint satisfaction, in ``Proceedings 25th Symposiumon Theory of Computing, San Diego, CA,'' pp. 612�622,ACM, New York.

[Gal74] Galil, Z. (1974), On some direct encodings of nondeterministicTuring machines operating in polynomial time into P-com-plete problems, SIGACT News 6(1), 19�24.

11GENERALIZED SATISFIABILITY COUNTING PROBLEMS

File: 643J 253812 . By:BV . Date:25:01:00 . Time:11:34 LOP8M. V8.0. Page 01:01Codes: 4195 Signs: 3323 . Length: 56 pic 0 pts, 236 mm

[GJ79] Garey, M. R., and Johnson, D. S. (1979), ``Computers andIntractability: A Guide to the Theory of NP-Completeness,''Freeman, San Francisco.

[HK94] Hermann, M., and Kolaitis, P. G. (1994), The complexity ofcounting problems in equational matching, in ``Proceedings,12th International Conference on Automated Deduction,Nancy, France'' (A. Bundy, Ed.), Lecture Notes in ComputerScience (in Artificial Intelligence), Vol. 814, pp. 560�574,Springer-Verlag, Berlin�New York, J. Symbolic Comput., toappear.

[HN90] Hell, P., and Nes� etr� il, N. (1990), On the complexity ofH-coloring, J. Combin. Theory Ser. B 48, 92�110.

[HO92] Hemachandra, L. A., and Ogiwara, M. (1992), Is *P closedunder subtraction? Bull. European Assoc. Theoret. Comput.Sci. 46, 107�122.

[Hod93] Hodges, W. (1993), ``Model Theory,'' Encyclopedia ofMahtematics and its Applications, Vol. 42, Cambridge Univ.Press, Cambridge, UK.

[Hor51] Horn, A. (1951), On sentences which are true of direct unionsof algebras, J. Symbolic Logic 16, 14�21.

[Joh90] Johnson, D. S. (1990), A catalog of complexity classes, in``Handbook of Theoretical Computer Science, Volume A:Algorithms and Complexity'' (J. van Leeuwen, Ed.), Chap. 2,pp. 67�161, North-Holland, Amsterdam.

[Koz92] Kozen, D. C. (1992), Counting problems and *P, in ``TheDesign and Analysis of Algorithms,'' Chap. 26, pp. 138�143,Springer-Verlag, Berlin�New York.

[Lin86] Linial, N. (1986), Hard enumeration problems in geometryand combinatorics, SIAM J. Algebraic Discrete Methods 7(2),331�335.

[McK43] McKinsey, J. C. C. (1943), The decision problem for some classesof sentences without quantifiers, J. Symbolic Logic 8, 61�76.

[Pap94] Papadimitriou, C. H. (1994), ``Computational Complexity,''Addison�Wesley, Reading, MA.

[PB83] Provan, J. S., and Ball, M. O. (1983), The complexity of count-ing cuts and of computing the probability that a graph is con-nected, SIAM J. Comput. 12(4), 777�788.

[Rot93] Roth, D. (1993), On the hardness of approximate reasoning, in``Proceedings 13th International Joint Conference on ArtificialIntelligence'' (R. Bajcsy, Ed.), Vol. 1, pp. 613�618, Chambe� ry,France.

[Sch78] Schaefer, T. J. (1978), The complexity of satisfiabilityproblems, in ``Proceedings 10th Symposium on Theory ofComputing, San Diego, CA,'' pp. 216�226.

[Sim75] Simon, J. (1975), ``On Some Central Problems in Computa-tional Complexity,'' Ph.D. thesis, Cornell Univ., Ithaca, NY.Available as Cornell Department of Computer Science Techni-cal Report TR75-224.

[Sim77] Simon, J. (1977), On the difference between one and many,in ``Proceedings, 4th ICALP Conference, Turku, Finland''(A. Salomaa and M. Steinby, Eds.), Lecture Notes in Com-puter Science, Vol. 52, pp. 480�491, Springer-Verlag, Berlin�New York.

[Tod89] Toda, S. (1989), On the computational power of PP and �P,in ``Proceedings 30th IEEE Symposium on Foundations ofComputer Science,'' pp. 514�519, Research Triangle Park, NC.

[Val79a] Valiant, L. G. (1979), The complexity of computing the perma-nent, Theoret. Comput. Sci. 8, 189�201.

[Val79b] Valiant, L. G. (1979), The complexity of enumeration andreliability problems, SIAM J. on Comput. 8(3), 410�421.

12 CREIGNOU AND HERMANN