| {"paper_meta":{"paper_id":"arxiv:0710.4272","title":"0710.4272","authors":[],"year":null,"published":null,"updated":null,"venue_or_source":"arxiv-papers-shard","primary_category":"cs","secondary_categories":[],"doi":null,"license":"unknown","source_type":"pdf+shard","source_url":null,"pdf_url":null},"abstract":{"raw":"","cleaned":"","offsets":[]},"full_paper_text":{"raw_ordered_text":"arXiv:0710.4272v2 [cs.CC] 22 Jul 2009\nAn approximation trichotomy for Boolean #CSP ∗\nMartin Dyer\nSchool of Computing\nUniversity of Leeds\nLeeds LS2 9JT, UK\nLeslie Ann Goldberg\nDepartment of Computer Science,\nUniversity of Liverpool,\nLiverpool L69 3BX, UK\nMark Jerrum\nSchool of Mathematical Sciences,\nQueen Mary, University of London\nMile End Road, London E1 4NS, UK\nOctober 31, 2018\nAbstract\nWe give a trichotomy theorem for the complexity of approximately\ncounting the number of satisfying assignments of a Boolean CSP instance.\nSuch problems are parameterised by a constraint language specifying the\nrelations that may be used in constraints. If every relation in the con-\nstraint language is affine then the number of satisfying assignments can\nbe exactly counted in polynomial time.\nOtherwise, if every relation in\nthe constraint language is in the co-clone IM2 from Post’s lattice, then\nthe problem of counting satisfying assignments is complete with respect\nto approximation-preserving reductions for the complexity class #RHΠ1.\nThis means that the problem of approximately counting satisfying as-\nsignments of such a CSP instance is equivalent in complexity to several\nother known counting problems, including the problem of approximately\ncounting the number of independent sets in a bipartite graph. For every\nother fixed constraint language, the problem is complete for #P with re-\nspect to approximation-preserving reductions, meaning that there is no\nfully polynomial randomised approximation scheme for counting satisfying\nassignments unless NP=RP.\n1\nIntroduction\nThis paper gives a trichotomy theorem for the complexity of approximately\ncounting the number of satisfying assignments of a Boolean CSP instance. Such\nproblems are parameterised by a constraint language Γ which specifies relations\nthat may be used in constraints. In the Boolean case, the relations are on a\ndomain which has two elements. Then #CSP(Γ) will denote the problem of\n∗This work was partially supported by the EPSRC grant “The Complexity of Counting in\nConstraint Satisfaction Problems”\n1\n\ndetermining the number of (distinct) satisfying assignments of a CSP instance\nwith constraint language Γ. Further details are given in Section 1.1 below.\nCreignou and Hermann [6] have given a dichotomy theorem for the exact\ncounting problem. They have shown that if every relation in Γ is affine, then\n#CSP(Γ) is in FP. Otherwise, it is #P-complete. The complexity classes FP\nand #P are the analogues of P and NP for counting problems. FP is the class\nof functions computable in deterministic polynomial time. #P is the class of\ninteger functions that can be expressed as the number of accepting computations\nof a polynomial-time non-deterministic Turing machine.\nIn this paper we build on previous work on the complexity of approximate\ncounting to identify a trichotomy in the complexity of approximate counting\nfor Boolean #CSP.\nTogether with Greenhill [9], we have previously studied approximation-\npreserving reductions (AP-reductions) between counting problems.\nWe will\ngive details of AP-reductions in Section 1.2. For now it suffices to note that if\nan AP-reduction exists from a counting problem f to a counting problem g and\ng has a Fully Polynomial Randomised Approximation Scheme (FPRAS) then f\nalso has an FPRAS.\nIf an AP-reduction from f to g exists we write f ≤AP g, and say that f\nis AP-reducible to g. If f ≤AP g and g ≤AP f then we say that f and g are\nAP-interreducible, and write f =AP g.\nWe previously identified [9] three natural classes of counting problems that\nare interreducible under AP-reductions.\nThese are (i) those problems that\nhave an FPRAS, (ii) those problems that are complete for #P with respect to\nAP-reducibility, and a third class of intermediate complexity. Two counting\nproblems played a special role in [9].\nName. #SAT.\nInstance. A Boolean formula φ in conjunctive normal form.\nOutput. The number of satisfying assignments of φ.\nName. #BIS.\nInstance. A bipartite graph B.\nOutput. The number of independent sets in B.\nAll problems in #P are AP-reducible to #SAT (see [9, Section 3]). Thus\n#SAT is complete for #P with respect to AP-reducibility. This means that\n#SAT cannot have an FPRAS unless NP = RP.\nThe same is true of any\nproblem in #P to which #SAT is AP-reducible.\nWe showed in [9, Sections 4, 5] that #BIS is AP-interreducible with many\nother natural counting problems such as counting downsets in a partial order.\nMoreover, #BIS is complete for #RHΠ1, a logically-defined subclass of #P,\nwith respect to AP-reductions.\nThe main theorem of our current paper (Theorem 3) shows that every prob-\nlem #CSP(Γ) falls neatly into one of the three classes from [9]: If every relation\n2\n\nin Γ is affine, then trivially #CSP(Γ) has an FPRAS since it is in FP. Other-\nwise, if every relation in Γ is in a certain set IM2, then #CSP(Γ) =AP #BIS.\nOtherwise #CSP(Γ) =AP #SAT. A formal definition of IM2\nappears in Sec-\ntion 1.4 — it is the set of relations which can be expressed as conjunctions\ninvolving only binary implication and unary relations.\nIt is worth pointing out that, while every problem #CSP(Γ) falls into one\nof the three approximation classes from [9], the three classes may well not\nprovide a partition of all approximate counting problems in #P. For example,\nthe problem of approximately counting 3-colourings of a bipartite graph is a\nproblem that may well lie between #BIS and #SAT in approximability (see [9]).\n1.1\nConstraint satisfaction\nConstraint Satisfaction, which originated in Artificial Intelligence, provides a\ngeneral framework for modelling decision problems, and has many practical\napplications. (See, for example [18].) Decisions are modelled by variables, which\nare subject to constraints, modelling logical and resource restrictions.\nThe\nparadigm is sufficiently broad that many interesting problems can be modelled,\nfrom satisfiability problems to scheduling problems and graph-theory problems.\nUnderstanding the complexity of constraint satisfaction problems has become\na major and active area within computational complexity [7, 11].\nA Constraint Satisfaction Problem (CSP) typically has a finite domain,\nwhich we denote by {0, . . . , q −1} for a positive integer q. In this paper we\nare interested in the Boolean case q = 2. A constraint language Γ with domain\n{0, . . . , q −1} is a set of relations on {0, . . . , q −1}. For example, take q = 2.\nThe relation R = {(0, 0, 1), (0, 1, 0), (1, 0, 0), (1, 1, 1)} is a 3-ary relation on the\ndomain {0, 1}, with four tuples.\nOnce we have fixed a constraint language Γ, an instance of the CSP is a set of\nvariables V = {v1, . . . , vn} and a set of constraints. Each constraint has a scope,\nwhich is a tuple of variables (for example, (v4, v5, v1)) and a relation from Γ of\nthe same arity, which constrains the variables in the scope. An assignment σ\nis a function from V to {0, . . . , q −1}. The assignment σ is satisfying if the\nscope of every constraint is mapped to a tuple that is in the corresponding\nrelation. In our example above, an assignment σ satisfies the constraint with\nscope (v4, v5, v1) and relation R, written R(v4, v5, v1), if and only if it maps an\nodd number of the variables in {v1, v4, v5} to the value 1. Given an instance I\nof a CSP with constraint language Γ, the decision problem CSP(Γ) asks us to\ndetermine whether any assignment satisfies I. The counting problem #CSP(Γ)\nasks us to determine the number of (distinct) satisfying assignments of I, which\nwe will denote by #csp(I).\nVarying the constraint language Γ defines the classes CSP and #CSP of\ndecision and counting problems.\nThese contain problems of different com-\nputational complexities.\nFor example, consider the binary relations defined\nby OR = {(0, 1), (1, 0), (1, 1)}, Implies = {(0, 0), (0, 1), (1, 1)}, and NAND =\n{(0, 0), (0, 1), (1, 0)}. If Γ = {OR, Implies, NAND} then CSP(Γ) is the classical\n2-Satisfiability problem, which is in P. On the other hand, there is a similar con-\nstraint language Γ′ with four relations of arity 3 such that 3-Satisfiability (which\n3\n\nis NP-complete) can be represented in CSP(Γ′). It may happen, as here, that\nthe counting problem is harder than the decision problem: #CSP(Γ) contains\nthe problem of counting independent sets in graph, and is thus #P-complete.\nAny decision problem CSP(Γ) is in NP, but not every problem in NP can be\nrepresented as a CSP. For example, the question “Is G Hamiltonian?” cannot\nbe expressed as a CSP, because the property of being Hamiltonian cannot be\ncaptured by relations of bounded size. This limitation of the class CSP has an\nimportant advantage. If P ̸= NP, then there are problems which are neither\nin P nor NP-complete [15]. But, for well-behaved smaller classes of decision\nproblems, the situation can be simpler. We may have a dichotomy theorem,\npartitioning all problems in the class into those which are in P and those which\nare NP-complete. There are no “leftover” problems of intermediate complex-\nity. It has been conjectured that there is a dichotomy theorem for CSP. The\nconjecture is that CSP(Γ) is in P for some constraint languages Γ, and CSP(Γ)\nis NP-complete for all other constraint languages Γ. This conjecture appeared\nin a seminal paper of Feder and Vardi [13], but has not yet been proved. A\nsimilar dichotomy, between FP and #P-complete, is conjectured for #CSP [4].\nRecently, Bulatov [3] has announced a positive resolution of this conjecture.\nThere have been many important results for subclasses of CSP and #CSP.\nWe mention the most relevant to our paper here. The first decision dichotomy\nwas that of Schaefer [19], for the Boolean domain {0, 1}. Schaefer’s result is as\nfollows.\nTheorem 1 (Schaefer [19]). Let Γ be a constraint language with domain {0, 1}.\nThe problem CSP(Γ) is in P if Γ satisfies one of the conditions below. Other-\nwise, CSP(Γ) is NP-complete.\n(i) Γ is 0-valid or 1-valid.\n(ii) Γ is weakly positive or weakly negative.\n(iii) Γ is affine.\n(iv) Γ is bijunctive.\nWe will not give detailed definitions of the conditions in Theorem 1, but\nthe interested reader is referred to the paper [19] or to Theorem 6.2 of the\ntextbook [7]. An interesting feature is that the conditions in [7, Theorem 6.2]\nare all checkable. That is, there is an algorithm to determine whether CSP(Γ)\nis in P or NP-complete, given a constraint language Γ with domain {0, 1}. We\nsay in this case that the dichotomy is effective.\nA Boolean relation R is said to be affine if the set of tuples x ∈R is the set of\nsolutions to a system of linear equations over GF(2). Creignou and Hermann [6]\nadapted Schaefer’s decision dichotomy to obtain a counting dichotomy for the\nBoolean domain. Their result is as follows.\nTheorem 2 (Creignou and Hermann [6]). Let Γ be a constraint language with\ndomain {0, 1}. The problem #CSP(Γ) is in FP if every relation in Γ is affine.\nOtherwise, #CSP(Γ) is #P-complete.\nCreignou and Hermann’s result is an important starting point for our work,\nand we will discuss it further below. Note that there is an algorithm for deter-\nmining whether a relation is affine, so the dichotomy is effective.\n4\n\nWe have recently [10] extended Creignou and Hermann’s dichotomy to the\ndomain of weighted Boolean #CSP giving an effective dichotomy between FP\nand FP#P for the problem of computing the partition function of a weighted\nBoolean CSP instance.\n1.2\nThe complexity of approximate counting\nWe now recall the necessary background from [9]. A randomised approxima-\ntion scheme is an algorithm for approximately computing the value of a func-\ntion f : Σ∗→N. The approximation scheme has a parameter ε > 0 which\nspecifies the error tolerance. A randomised approximation scheme for f is a\nrandomised algorithm that takes as input an instance x ∈Σ∗(e.g., an encoding\nof a CSP instance) and an error tolerance ε > 0, and outputs an integer z (a\nrandom variable on the “coin tosses” made by the algorithm) such that, for\nevery instance x,\nPr\n \ne−εf(x) ≤z ≤eεf(x)\n \n≥3\n4 .\n(1)\nThe randomised approximation scheme is said to be a fully polynomial ran-\ndomised approximation scheme, or FPRAS, if it runs in time bounded by a\npolynomial in |x| and ε−1. (See Mitzenmacher and Upfal [16, Definition 10.2].)\nNote that the quantity 3/4 in Equation (1) could be changed to any value in the\nopen interval (1\n2, 1) without changing the set of problems that have randomised\napproximation schemes [14, Lemma 6.1].\nSuppose that f and g are functions from Σ∗to N.\nAn “approximation-\npreserving reduction” (AP-reduction) from f to g gives a way to turn an FPRAS\nfor g into an FPRAS for f. An AP-reduction from f to g is a randomised\nalgorithm A for computing f using an oracle for g1. The algorithm A takes\nas input a pair (x, ε) ∈Σ∗× (0, 1), and satisfies the following three conditions:\n(i) every oracle call made by A is of the form (w, δ), where w ∈Σ∗is an instance\nof g, and 0 < δ < 1 is an error bound satisfying δ−1 ≤poly(|x|, ε−1); (ii)\nthe algorithm A meets the specification for being a randomised approximation\nscheme for f (as described above) whenever the oracle meets the specification\nfor being a randomised approximation scheme for g; and (iii) the run-time of A\nis polynomial in |x| and ε−1.\nIn formulating a definition of approximation-\npresering reduction, a number of choices must be faced. The key requirement is\nthat the class of functions computable by an FPRAS should be closed under AP-\nreducibility. Informally, we have gone for the most liberal notion of reduction\nmeeting this requirement.\n1.3\nNotation for relations\nDefine the unary relations δ0 = {(0)} and δ1 = {(1)}. Recall the binary relation\nImplies = {(0, 0), (0, 1), (1, 1)}.\nFor convenience, according to context, we view a k-ary relation R either as a\nset of k-tuples or as a k-ary predicate. Thus the notations R(x1, . . . , xk) = 1 (or\n1The reader who is not familiar with oracle Turing machines can just think of this as an\nimaginary (unwritten) subroutine for computing g.\n5\n\njust R(x1, . . . , xk)) and (x1, . . . , xk) ∈R are equivalent. For example, δ0(x) = x,\nδ1(x) = x and Implies(x, y) = x ∨y.\n1.4\nThe set of relations IM2\nAn n-ary relation R is in IM2 if and only if R(x1, . . . , xn) is logically equivalent\nto a conjunction of predicates of the form δ0(xi), δ1(xi) and Implies(xi, xj).\nAs we will discuss below, Creignou, Kolaitis, and Zanuttini [8] have shown\nthat IM2 is a co-clone in Post’s lattice (see [2]).\n1.5\nOur result\nWe can now state our main theorem.\nTheorem 3. Let Γ be a constraint language with domain {0, 1}. If every rela-\ntion in Γ is affine then #CSP(Γ) is in FP. Otherwise if every relation in Γ is\nin IM2 then #CSP(Γ) =AP #BIS. Otherwise #CSP(Γ) =AP #SAT.\nThe main ingredients in the proof are: (1) the AP-reduction technology\nof [9], which allows us to effectively “pin” certain CSP variables in hardness\nproofs (see Section 2.3); (2) the “implementations” of Creignou, Khanna and\nSudan [7], which show how to construct the key relations OR, Implies, and NAND\nfrom a non-affine relation and δ0 or δ1 (see Section 2.5); (3) the complexity class\n#RHΠ1 from [9], consisting of those problems which are AP-interreducible with\n#BIS; and (4) the co-clone IM2 in Post’s lattice (see Section 2.8), since the\ncomplexity of #CSP(Γ) for Γ ⊆IM2 turns out to be closely connected to the\ncomplexity of #BIS.\n2\nThe pieces of the proof\n2.1\nTypes of relations\nA relation R is 0-valid if the all-zero tuple is in R.\nSimilarly, R is 1-valid\nif the all-ones tuple is in R. Following [7], we say that a k-ary relation R is\ncomplement-closed (C-closed in [7]) if\n(x1, . . . , xk) ∈R ⇔(x1 ⊕1, . . . , xk ⊕1) ∈R,\nwhere ⊕is the exclusive or operator.\nWe say that Γ is 0-valid if every R ∈Γ is 0-valid and we define what it\nmeans for Γ to be 1-valid or complement-closed similarly.\n2.2\nSome preliminary complexity results\nWe start by observing that every problem #CSP(Γ) is AP-reducible to #SAT\nObservation 4. Let Γ be a constraint language with domain {0, 1}.\nThen\n#CSP(Γ) ≤AP #SAT.\n6\n\nObservation 4 follows from the fact that all problems in #P\nare AP-\nreducible to #SAT [9]. Another, very simple, but useful, observation is the\nfollowing.\nObservation 5. Let Γ be a constraint language with domain {0, 1}. Suppose\nΓ′ ⊆Γ. Then #CSP(Γ′) ≤AP #CSP(Γ).\nObservation 5 is true for the simple reason that every instance of #CSP(Γ′)\nis an instance of #CSP(Γ).\nRecall the relations OR = {(0, 1), (1, 0), (1, 1)} and NAND = {(0, 0), (0, 1),\n(1, 0)}. These relations are particularly fundamental for us, and we start with\ncomplexity results about these.\nLemma 6. #SAT ≤AP #CSP({NAND}).\nProof. It was shown in [9] that the following problem is AP-interreducible with\n#SAT.\nName. #IS.\nInstance. A graph G.\nOutput. The number of independent sets in G.\nWe show that #IS ≤AP #CSP({NAND}). Let G = (V, E) be an instance\nof #IS. Construct an instance I of #CSP({NAND}) with variable set V . For\nevery edge (u, v) ∈E, add constraint NAND(u, v). There is now a bijection\nbetween independent sets of G and satisfying assignments σ of I: variables v\nwith σ(v) = 1 correspond to vertices in the independent set.\nLemma 7. #SAT ≤AP #CSP({OR}).\nProof. The proof that #IS ≤AP #CSP({OR}) is similar (just associate variables\nv with σ(v) = 1 with vertices that are out of the independent set).\nFinally, we will need a couple of complexity results involving #BIS.\nLemma 8. #BIS ≤AP #CSP({Implies}).\nProof. Let G be an instance of #BIS with vertex sets U and V and edge set E.\nConstruct an instance I of #CSP({Implies}) with variable set U ∪V . For every\nedge (u, v) ∈E with u ∈U add constraint Implies(u, v). There is now a bijection\nbetween independent sets of G and satisfying assignments σ of I: a variable\nu ∈U with σ(u) = 1 is in the independent set and a variable v ∈V with\nσ(v) = 0 is in the independent set.\nLemma 9. Suppose Γ ⊆IM2. Then #CSP(Γ) ≤AP #BIS.\n7\n\nProof. It is straightforward to show that #CSP(Γ) is in the complexity class\n#RHΠ1 which has #BIS as a complete problem [9].\nHowever, to avoid giving a definition of #RHΠ1, which requires some nota-\ntion, we will instead show #CSP(Γ) ≤AP #Downsets, where #Downsets is\nthe following counting problem which was shown in [9] to be AP-interreducible\nwith #BIS.\nName. #Downsets.\nInstance. A partially ordered set (X, ⪯).\nOutput. The number of downsets2 in (X, ⪯).\nConsider an instance I of #CSP(Γ) with variables v1, . . . , vn. The set of\nconstraints can be viewed as an equivalent set of constraints of the form δ0(vi),\nδ1(vi) or Implies(vi, vj). Denote by Implies∗the transitive closure of the Implies\nrelation on {v1, . . . , vn}: thus Implies∗(vi, vj) if there is a sequence of variables,\nstarting with vi and ending with vj, such that every adjacent pair in the se-\nquence is constrained by Implies.\nLet N0(I) be the set of variables vi for which either (i) a constraint δ0(vi)\noccurs in I, or (ii) there exists a variable vj such that Implies∗(vi, vj) and a\nconstraint δ0(vj) occurs in I. These are the variables that are forced to be 0\nin any satisfying assignment of I. Define N1(I) analogously to be the set of\nvariables that are forced to be 1 in any satisfying assignment. We can assume\nwithout loss of generality that N0(I) and N1(I) are disjoint. Otherwise the\ninstance I has no satisfying assignments, and we can determine this without\neven using the downsets oracle.\nNow remove all the variables in N0(I) and N1(I) from the instance I: this\ndoes not affect the number of satisfying assignments, since these variables do\nnot constrain any of the others. Also identify all pairs of variables vi, vj such\nthat Implies∗(vi, vj) and Implies∗(vj, vi): again, this does not affect the number\nof satisfying assignments.\nThe remaining variables and relations define a partial order (X, ⪯) since our\nconstruction forces antisymmetry. The satisfying assignments of I correspond\n1–1 with the downsets of (X, ⪯).\n2.3\nA useful tool: pinning\nPinning is the ability to tie certain CSP variables to specific values in hard-\nness proofs. This idea was used by Creignou and Hermann in their dichotomy\ntheorem [6]. Similar ideas have been used in many other hardness proofs and\ndichotomy theorems [4, 5, 10, 12]. As we show in this section, AP-reductions\nfacilitate a particularly useful form of pinning.\nLemma 10. Let Γ be a constraint language with domain {0, 1}. Suppose there\nis a relation R ∈Γ for which, for some position j, R has more tuples t with\ntj = 0 than with tj = 1. Then #CSP(Γ ∪{δ0}) ≤AP #CSP(Γ). Similarly, if\n2A downset in (X, ⪯) is a subset D ⊆X that is closed under ⪯; i.e., x ⪯y and y ∈D\nimplies x ∈D.\n8\n\nthere is a relation R ∈Γ for which, for some position j, R has more tuples t\nwith tj = 1 than with tj = 0 then #CSP(Γ ∪{δ1}) ≤AP #CSP(Γ).\nProof. Consider an instance I of #CSP(Γ ∪{δ0}) with n variables. Suppose\nthere is an arity-k relation R ∈Γ for which, for position j, R has w tuples t\nwith tj = 0 and w′ < w tuples t with tj = 1.\nAs in the proof of Lemma 9, let N0(I) be the set of variables x to which one\nor more constraints δ0(x) occurs in I and let N1(I) be the set of variables y to\nwhich one or more constraints δ1(y) occurs. Let n0 = |N0(I)|. Let m = ⌈(n +\n2)/ lg(w/w′)⌉. Construct an instance I′ of #CSP(Γ). Include all constraints\nin I other than those involving δ0. For each variable x ∈N0(I), and every\na ∈{1, . . . , m}, introduce k −1 new variables x′\na,b for b ∈{1, . . . , k} −{j}.\nIntroduce a new constraint in I′ with relation R and variable x in the j th\nposition, and x′\na,b in the b th position, for all b.\nNow a satisfying assignment for I can be extended in wmn0 ways to satisfying\nassignments of I′. An assignment for I that violates one of the δ0(x) constraints\ncan be extended in at most wm(n0−1)w′ m ways to satisfying assignments of I′.\nThus,\n#csp(I)wmn0 ≤#csp(I′) ≤#csp(I)wmn0 + 2nwm(n0−1)w′ m,\ni.e.,\n#csp(I) ≤#csp(I′)\nwmn0\n≤#csp(I) + 2n(w′/w)m.\nSo, by definition of m,\n#csp(I) ≤#csp(I′)\nwmn0\n≤#csp(I) + 1\n4.\nThus we have constructed a reduction from #CSP(Γ ∪{δ0}) to #CSP(Γ):\nGiven an instance I of #CSP(Γ ∪{δ0}), use an oracle for #CSP(Γ) to approxi-\nmate #csp(I′), divide by wmn0, and round to the nearest integer (always down).\nNote that the reduction makes only one oracle call (and uses no randomisation).\nTo show that the reduction is indeed an AP-reduction, we add some techni-\ncal details concerning the choice of the accuracy parameter δ in the oracle call\n(see the definition of AP-reduction in Section 1.2). These details are here to\nmake the proof complete, but they are not essential for understanding the rest\nof the paper.\nIf we had\n#csp(I) = #csp(I′)\nwmn0\n,\nwe could simply set δ = ε, since division by a constant preserves relative error.\nInstead we have\n#csp(I) =\n #csp(I′)\nwmn0\n \n.\nThe discontinuous floor function could spoil the approximation when its argu-\nment is small.\nThe situation here is that the true answer N = #csp(I) is obtained by\nrounding the fraction Q = #csp(I′)\nwmn0\nwhere we have |Q −N| ≤1/4.\n9\n\nSuppose that the oracle provides an approximation bQ to Q satisfying Qe−δ ≤\nbQ ≤Qeδ (as it is required to do with probability at least 3/4). Set δ = ε/21,\nwhere ε is the accuracy parameter governing the final result. There are two\ncases.\nIf N ≤2/ε, then a short calculation yields | bQ −Q| < 1/4 implying\nthat the result returned by the algorithm is exact. If N > 2/ε, then the result\nreturned is in the range [(N −1/4)e−δ −1/2, (N + 1/4)eδ + 1/2] which, for the\nchosen δ, is contained in [Ne−ε, Neε].\nThus, we have an AP-reduction from #CSP(Γ ∪{δ0}) to #CSP(Γ). The\nreduction showing #CSP(Γ ∪{δ1}) ≤AP #CSP(Γ) is similar.\n2.4\nAffine relations\nWe use the following well-known facts about affine relations.\nLemma 11.\n(i) A k-ary Boolean relation R is affine if and only if a, b, c ∈R\nimplies d = a⊕b⊕c ∈R, where the ⊕operator is applied componentwise.\n(ii) If R is not affine, then for any fixed a ∈R there are b, c ∈R such that\na ⊕b ⊕c ̸∈R.\n(iii) If R is not affine, then there are a, b in R such that a ⊕b ̸∈R.\nProof. For Part (i) see, for example, Lemma 4.10 of [7]). Part (ii) is proved in\nthe same place, but since it is a little less well-known, we provide the proof:\nSuppose the contrary that R is not affine, but for all b, c ∈R, a ⊕b ⊕c ∈R.\nChoose s0, s1, s2 ∈R such that s0 ⊕s1 ⊕s2 ̸∈R.\nFrom b = s0, c = s1,\nd = a ⊕s0 ⊕s1 we have d ∈R. From b = s2, c = d we have a ⊕s2 ⊕d =\ns0 ⊕s1 ⊕s2 ∈R, a contradiction.\nTo see Part (iii), note that the condition “∀a, b : a, b ∈R implies a ⊕b ∈R”\nimplies that R is affine, so, if R is not affine then the condition is false.\n2.5\nImplementation\nLet Γ be a constraint language with domain {0, 1}. Γ is said to implement3 a\nk-ary relation R if, for some k′ ≥k there is a CSP instance I with variables\nx1, . . . , xk′ and constraints in Γ such that, for every tuple (s1, . . . , sk) ∈R, there\nis exactly one satisfying assignment σ of I with σ(x1) = s1, . . . , σ(xk) = sk and\nfor every tuple (s1, . . . , sk) ̸∈R, there are no satisfying assignments σ of I with\nσ(x1) = s1, . . . , σ(xk) = sk. Note the following straightforward observation,\nwhich is essentially a parsimonious reduction [17, p.441].\nObservation 12. If Γ implements R then #CSP(Γ ∪{R}) ≤AP #CSP(Γ).\nWe will use several implementations of Creignou, Khanna and Sudan. Proofs\nare provided in the appendix in order to make the paper self-contained.\nLemma 13. (Creignou, Khanna and Sudan, [7, Lemmas 5.24 and 5.25]) Let\nΓ be a constraint language with domain {0, 1}.\n3There are many variants of “implement” defined in the literature. See [7, Chapter 5],\nwhere the kind of implementation we define here is called “faithful” and “perfect”.\n10\n\n(i) If Γ contains a relation R that is 0-valid, 1-valid and not complement-\nclosed then Γ implements the relation R′ = {(0, 0), (1, 1), (1, 0)}.\n(ii) If Γ contains a relation R that is not 0-valid, not 1-valid and not comple-\nment-closed then Γ implements δ0 and δ1.\n(iii) If Γ contains a relation R that is 0-valid and not 1-valid then Γ imple-\nments δ0.\n(iv) If Γ contains a relation R that is 1-valid and not 0-valid then Γ imple-\nments δ1.\nLemma 14. (Creignou, Khanna and Sudan, [7, Claim 5.31])\nLet R be a\nternary relation containing (0, 0, 0), (0, 1, 1) and (1, 0, 1) but not (1, 1, 0). Then\n{R, δ0} implements one of Implies and NAND.\nLemma 15. (Creignou, Khanna and Sudan, [7, Lemma 5.30]) If R is a rela-\ntion over {0, 1} that is not affine then {R, δ0} implements one of OR, Implies,\nand NAND and so does {R, δ1}.\n2.6\nPinning revisited\nCombining the useful pinning that we get from AP-reductions (Lemma 10) with\nthe implementations of OR, Implies and NAND in Section 2.5, we obtain a useful\nlemma which says that we can always do some pinning.\nLemma 16. Let Γ be a constraint language with domain {0, 1}. Then either\n#CSP(Γ ∪{δ0}) ≤AP #CSP(Γ) or #CSP(Γ ∪{δ1}) ≤AP #CSP(Γ) (or both).\nProof. First, suppose that Γ is not complement-closed. If Γ contains a relation\nR that is not 0-valid, not 1-valid and not complement-closed then we finish by\nObservation 12 and Part (ii) of Lemma 13. If Γ contains a relation R that\nis 0-valid, 1-valid and not complement-closed then it implements the relation\nR′ from Part (i) of Lemma 13 so by Observation 12, #CSP(Γ ∪{R′}) ≤AP\n#CSP(Γ). But Lemma 10 shows both #CSP(Γ∪{R′, δ0}) ≤AP #CSP(Γ∪{R′})\nand #CSP(Γ ∪{R′, δ1}) ≤AP #CSP(Γ ∪{R′}). Otherwise Γ contains a relation\nR that is 0-valid and not 1-valid (or vice-versa) and we finish by Part (iii) (or\nPart (iv)) of Lemma 13, and Observation 12.\nSecond (and finally), suppose that Γ is complement-closed. Here is a sim-\nple AP-reduction from #CSP(Γ ∪{δ0}) to #CSP(Γ). Let I be an instance of\n#CSP(Γ ∪{δ0}). Construct an instance I′ of #CSP(Γ) by adding a new vari-\nable z0. For all x ∈N0(I) (all variables x to which one or more constraints δ0(x)\nin I apply), replace all occurrences of variable x with z0 in I′. Now note that\n2#csp(I) = #csp(I′) since there is a one-to-two map from satisfying assign-\nments of I and satisfying assignments of I′. In particular, if s is an assignment\nto all variables of I other than those in N0(I) and s is satisfying, provided the\nrest of the variables are assigned value 0, then s is mapped to s; z0 = 0 and\ns; z0 = 1, where s is the tuple obtained from s by complementing the assign-\nment of every variable. Both satisfy I′ since Γ is complement-closed. It is clear\nthat all satisfying assignments of I′ arise in this way.\n11\n\n2.7\nNotation for Boolean functions\nThe following definitions are from [1, 2].\nAn m-ary Boolean function f is\nmonotonic if and only if (a1, . . . , am) ≤(b1, . . . , bm) componentwise implies\nf(a1, . . . , am) ≤f(b1, . . . , bm).\nLet M2 be the set of all monotone Boolean\nfunctions f satisfying f(0, . . . , 0) = 0 and f(1, . . . , 1) = 1. Given a set B of\nBoolean functions, the closure [B] consists of all functions that can be defined\nby propositional formulas with connectives from B (see [1]).\nAn m-ary Boolean function f is said to be a polymorphism of an n-ary\nrelation R(x1, . . . , xn) if applying f componentwise to m tuples in R results in\na tuple that is also in R.\n2.8\nPolymorphisms and IM2\nIn the terminology of universal algebra, Creignou, Kolaitis, and Zanuttini [8]\nhave shown that IM2 is precisely the co-clone corresponding to M2, which is a\nclone in Post’s lattice (see [2]). The direction of this result that we will use is\nthe following.\nLemma 17. (Creignou, Kolaitis, Zanuttini, [8]) If the relation R is not in IM2\nthen there is an f ∈M2 that is not a polymorphism of R.\nCorollary 18. If the n-ary relation R is not in IM2 then there are Boolean\ntuples (a1, . . . , an) ∈R and (b1, . . . , bn) ∈R such that either (a1 ∧b1, . . . , an ∧\nbn) ̸∈R or (a1 ∨b1, . . . , an ∨bn) ̸∈R (or both).\nProof. We will use the fact (see [1]) that M2 = [{∨, ∧}] where x ∨y is the OR\nof the Boolean values x and y and x ∧y is the AND of x and y. Thus, every\nfunction f ∈M2 can be defined by a propositional formula using the 2-ary\nconnectives ∨and ∧.\nThe proof is by induction on the number of connectives used in the propo-\nsitional formula used to represent the function f from Lemma 17.\nThe case f(x) = x (in which f has no connectives) cannot arise since the\nidentity function is a polymorphism of every relation. The cases f(x, y) = x∨y\nand f(x, y) = x ∧y (in which f has one connective) immediately give the\ncorollary.\nFor the inductive step, we assume either f(x1, . . . , xm) = f ′(x1, . . . , xm) ∨\nf ′′(x1, . . . , xm) or f(x1, . . . , xm) = f ′(x1, . . . , xm)∧f ′′(x1, . . . , xm) where f ′ and\nf ′′ have fewer connectives than f. Note that f ′ and f ′′ may not actually use\nall of the variables in x1, . . . , xm.\nThese two cases are similar, so suppose we are in the first of them. That is,\nsuppose\nf(x1, . . . , xm) = f ′(x1, . . . , xm) ∨f ′′(x1, . . . , xm).\nSuppose also that f ′ and f ′′ are polymorphisms of R (otherwise we will apply\nthe inductive hypothesis to one of these functions which has fewer connectives).\nLet t1, . . . , tm be m n-tuples in R, such that the tuple obtained by applying\nf componentwise to t1, . . . , tm is not in R. Let t′ be the n-tuple obtained by\napplying f ′ componentwise to t1, . . . , tm and let t′′ be the n-tuple obtained by\n12\n\napplying f ′′ componentwise to t1, . . . , tm. Since f ′ and f ′′ are polymorphisms\nof R, we know that t′ and t′′ are in R. However, since f is not a polymorphism\nof R, the tuple t′ ∨t′′ is not in R, proving the corollary.\n3\nPutting it all together: the proof of Theorem 3\nWe start with a lemma establishing a reduction from #SAT.\nLemma 19. Let R1 and R2 be relations on {0, 1}. If R1 is not affine and R2\nis not in IM2 then #SAT ≤AP #CSP({R1, R2}).\nProof. Apply Lemma 16 with Γ = {R1, R2}. Then either #CSP({R1, R2, δ0}) ≤AP\n#CSP({R1, R2}) or #CSP({R1, R2, δ1}) ≤AP #CSP({R1, R2}).\nAssume the\nformer (the latter case is symmetric).\nNow use Lemma 15 together with Observation 12. Since R1 is not affine\nthis shows one of the following.\n• #CSP({R1, R2, δ0, OR}) ≤AP #CSP({R1, R2, δ0}), or\n• #CSP({R1, R2, δ0, NAND}) ≤AP #CSP({R1, R2, δ0}), or\n• #CSP({R1, R2, δ0, Implies}) ≤AP #CSP({R1, R2, δ0}).\nIn the first two of these cases, we are finished by Observation 5 and Lem-\nmas 6 and 7, so assume the final case. Using Lemma 10 with the second position\nof Implies, we get #CSP({R1, R2, δ0, Implies, δ1}) ≤AP #CSP({R1, R2, δ0}).\nSimplifying the chain of reductions and using Observation 5 to drop R1 from\nthe left-hand side, we get #CSP({Implies, R2, δ0, δ1}) ≤AP #CSP({R1, R2}).\nWe will now finish by showing #SAT ≤AP #CSP({Implies, R2, δ0, δ1}).\nCase 1.\nUsing Corollary 18, suppose that t and t′ are tuples in R2 but\nthe tuple t ∧t′ (in which the operator ∧is applied componentwise) is not in\nR2. We will show that {Implies, R2, δ0, δ1} implements one of OR and XOR =\n{(0, 1), (1, 0)}. Let k be the arity of R2. As in the implementations of Creignou\net al. [7], define ri to be u if ti = t′\ni = 0 or x if ti = 0, t′\ni = 1 or y if ti =\n1, t′\ni = 0, or v if ti = t′\ni = 1. Let R′ be the relation implemented by R′(x, y) =\nR2(r1, . . . , rk) ∧δ0(u) ∧δ1(v). Note that both x and y appear as arguments\nof R′ since t ̸= t ∧t′ and t′ ̸= t ∧t′. If t ∨t′ is in R2 then R′(x, y) implements\nOR(x, y), so we are finished. Otherwise R′ = XOR (which we now assume).\nUsing Observation 12 and 5, we have\n#CSP({Implies, XOR}) ≤AP #CSP({R1, R2}).\nWe will finish by showing that {Implies, XOR} implements NAND. (The result\nthen follows by Lemma 6 and Observation 12.)\nThe implementation is given by NAND(x, z) = Implies(x, y) ∧XOR(y, z).\nCase 2.\nOtherwise, by Corollary 18, there are t and t′ in R2 such that t ∨t′\nis not in R2. This case is dual to Case 1.\n13\n\nWe can now prove the main theorem.\nTheorem 3.\nLet Γ be a constraint language with domain {0, 1}. If every\nrelation in Γ is affine then #CSP(Γ) is in FP. Otherwise if every relation in Γ\nis in IM2 then #CSP(Γ) =AP #BIS. Otherwise #CSP(Γ) =AP #SAT.\nProof. First, suppose that every relation in Γ is affine. In this case, the number\nof satisfying assignments of an instance I of #CSP(Γ) is the number of solutions\nto a system of linear equations over GF(2).\nThis can be computed exactly,\nby Gaussian elimination, in polynomial time, as Creignou and Hermann have\nnoted [6].\nNext, suppose that Γ contains a relation R that is not affine, but every\nrelation in Γ is in IM2. By Lemma 9, #CSP(Γ) ≤AP #BIS\nTo see that #BIS ≤AP #CSP(Γ), apply Lemma 16. Then we know that\neither #CSP(Γ ∪{δ0}) ≤AP #CSP(Γ) or #CSP(Γ ∪{δ1}) ≤AP #CSP(Γ) (or\nboth). We will show\n#BIS ≤AP #CSP(Γ ∪{δ0})\n(2)\nand\n#BIS ≤AP #CSP(Γ ∪{δ1})\n(3)\nand then we will be able to conclude #BIS ≤AP #CSP(Γ).\nThe proofs of\nEquations (2) and (3) are similar, so we just prove (2). By Lemma 15, Γ ∪{δ0}\nimplements one of OR, Implies, and NAND. So by Observation 12 we have (at\nleast) one of the following.\n(i) #CSP(Γ ∪{δ0, OR}) ≤AP #CSP(Γ ∪{δ0})\n(ii) #CSP(Γ ∪{δ0, Implies}) ≤AP #CSP(Γ ∪{δ0})\n(iii) #CSP(Γ ∪{δ0, NAND}) ≤AP #CSP(Γ ∪{δ0})\nEquation (2) follows from the combination of Lemma 8 and (ii) using Obser-\nvation 5. Also, since #BIS ≤AP #SAT (see [9]), Equation (2) follows from the\ncombination of Lemma 7 and (i) using Observation 5. Similarly, it follows from\nthe combination of Lemma 6 and (iii) using Observation 5.\nFinally, suppose that Γ contains a relation R1 that is not affine and a rela-\ntion R2 that is not in IM2. (R1 and R2 might possibly be the same relation.)\nThe fact that #CSP(Γ) ≤AP #SAT follows from Observation 4 and the fact\nthat #SAT ≤AP #CSP(Γ) follows from Lemma 19 and Observation 5.\nReferences\n[1] E. B ̈ohler, N. Creignou, S. Reith and H. Vollmer, Playing with Boolean\nblocks, Part I: Post’s lattice with applications to complexity theory, ACM\nSIGACT Newsletter 34 (2003), 38–52.\n[2] E. B ̈ohler, S. Reith, H. Schnoor and H. Vollmer, Bases for Boolean co-clones,\nInformation Processing Letters 96 (2005), 59–66.\n[3] A. Bulatov, The complexity of the counting constraint satisfaction problem,\nProc. 35th International Colloquium for Automata, Languages and Program-\nming, Lecture Notes in Computer Science 5125, Springer-Verlag, 2008, 646–\n661.\n14\n\n[4] A. Bulatov and V. Dalmau, Towards a dichotomy theorem for the counting\nconstraint satisfaction problem, in Proc. 44th Annual IEEE Symposium on\nFoundations of Computer Science, 2003, 562–573.\n[5] A. Bulatov and M. Grohe, The complexity of partition functions, Theoretical\nComputer Science 348 (2005), 148–186.\n[6] N. Creignou and M. Hermann, Complexity of generalized satisfiability\ncounting problems, Information and Computation 125 (1996), 1–12.\n[7] N. Creignou, S. Khanna and M. Sudan, Complexity classifications of Boolean\nconstraint satisfaction problems, SIAM Press, 2001.\n[8] N. Creignou, P. Kolaitis and B. Zanuttini, Preferred representations of\nBoolean relations, Electronic Colloquium on Computational Complexity, Re-\nport No. 119, 2005.\n[9] M. Dyer, L.A. Goldberg, C. Greenhill and M. Jerrum, The relative complex-\nity of approximate counting problems, Algorithmica 38 (2004), 471–500.\n[10] M. Dyer, L.A. Goldberg and M. Jerrum, The Complexity of Weighted\nBoolean #CSP, SIAM Journal on Computing 38 (2009), 1970–1986.\n[11] P. Hell and J. Neˇsetˇril, Graphs and homomorphisms, Oxford University\nPress, 2004.\n[12] M. Dyer and C. Greenhill, The complexity of counting graph homomor-\nphisms, Random Structures and Algorithms 17 (2000), 260–289.\n[13] T. Feder and M. Vardi, The computational structure of monotone monadic\nSNP and constraint satisfaction: a study through Datalog and group theory,\nSIAM Journal on Computing 28 (1999), 57–104.\n[14] M. Jerrum, L. Valiant and V. Vazirani, Random generation of combinato-\nrial structures from a uniform distribution, Theoretical Computer Science\n43 (1986), 169–188.\n[15] R. Ladner, On the structure of polynomial time reducibility, Journal of the\nAssociation for Computing Machinery 22 (1975), 155–171.\n[16] M. Mitzenmacher and E. Upfal, Probability and Computing, Cambridge\nUniversity Press, 2005.\n[17] C.H. Papadimitriou, Computational Complexity, Addison-Wesley, 1994.\n[18] F. Rossi, P. van Beek and T. Walsh (Eds.), Handbook of constraint pro-\ngramming, Elsevier, 2006.\n[19] T. Schaefer, The complexity of satisfiability problems, in Proc. 10th Annual\nACM Symposium on Theory of Computing, ACM Press, 1978, 216–226.\n15\n\nAppendix: The implementations of Creignou, Khanna\nand Sudan\nIn order to make our paper self-contained, we give the details of the implemen-\ntations of Creignou, Khanna and Sudan that we use. In particular, we provide\nthe proofs for Lemmas 13, 14 and 15. (These proofs can be found in [7].)\nWe start with the construction for Lemma 13.\nSuppose R ∈Γ is not\ncomplement-closed. Choose (s1, . . . , sk) in R such that (s1 ⊕1, . . . , sk ⊕1) is\nnot in R. Now consider the relation R′ implemented by R′(x, y) = R(r1, . . . , rk)\nwhere ri = x if si = 1 and ri = y otherwise. In the first case, R′ is the relation\n{(0, 0), (1, 1), (1, 0)}. In the second case, R′ = {(1, 0)} so R′ gives an implemen-\ntation of both δ1 and δ0. The construction for the third and fourth cases are\nthe trivial implementations δ0(x) = R(x, . . . , x) and δ1(x) = R(x, . . . , x).\nWe now give the construction for Lemma 14. If R excludes exactly one\nof (0, 1, 0) and (1, 1, 1) then R(x, y, x) implements Implies(y, x) or NAND(x, y)\n(depending on which is excluded). Similarly, if R excludes exactly one of (1, 0, 0)\nand (1, 1, 1) then R(x, y, y) implements Implies(x, y) or NAND(x, y). If both\n(0, 1, 0) and (1, 0, 0) are in R then fR(x, y, z) ∧δ0(z) implements fNAND(x, y).\nIf (0, 1, 0), (1, 1, 1) and (1, 0, 0) are excluded from R and so is (0, 0, 1) then\nR(x, y, z) implements NAND(x, y). Finally, if (0, 1, 0), (1, 1, 1) and (1, 0, 0) are\nexcluded but (0, 0, 1) is in R then R(x, y, z) ∧δ0(x) implements Implies(y, z).\nFinally, we give the construction for Lemma 15. We will show that {R, δ0}\nimplements one of the named relations. A similar argument shows that {R, δ1}\ndoes. Let k be the arity of R.\nFirst, suppose that R is 0-valid. Using part (iii) of Lemma 11, let s and s′\nbe tuples in R such that s ⊕s′ is not in R. Let ri = w if si = s′\ni = 0. Let\nri = x if si = 0, s′\ni = 1. Let ri = y if si = 1, s′\ni = 0. Let ri = z if si = s′\ni = 1.\nNow we know that at least one of x and y occurs as an ri, since s ̸= s′. Let R′\nbe the relation implemented by R(r1, . . . , rk) ∧δ0(w). There are a few cases to\nconsider. If x occurs as an argument to R but y does not then z occurs since\ns ̸= 0. Thus, the relation R′(x, z) is Implies. (Technically, this is a ternary\nrelation in variables x, y and z, but it can be viewed as a binary relation since y\ndoes not appear.) The situation is similar if y occurs as an argument to R but\nx does not. If both x and y occur as arguments but z does not then the relation\nR′(x, y) is NAND. Otherwise, x, y and z all occur as arguments. Furthermore,\nsince R is 0-valid, lemma 14 applies to the relation given by R′(x, y, z).\nSecond (and finally), suppose that R is not 0-valid. Note that {R, δ0} can\nimplement δ1. To see this, let s be a tuple in R. Let ri = x if si = 1 and let\nri = y otherwise. Then δ1(x) is implemented by R(r1, . . . , rk) ∧δ0(y). Now\nconsider two sub-cases.\nFor the first sub-case, suppose that for any two tuples, t and t′, in R,\nthe tuple t ∧t′,where ∧is applied componentwise, is also in R. Let s be the\nintersection of all tuples in R. Then s ∈R. By Part (ii) of Lemma 11, there\nare two tuples s′ and s′′ in R such that s ⊕s′ ⊕s′′ is not in R. Let ri = u if\nsi = s′\ni = s′′\ni = 0. Let ri = x if si = 0, s′\ni = 0, s′′\ni = 1. Let ri = y if si = 0, s′\ni =\n1, s′′\ni = 0. Let ri = z if si = 0, s′\ni = 1, s′′\ni = 1. Let ri = v if si = s′\ni = s′′\ni = 1.\n16\n\nLet R′ be the relation implemented by R(r1, . . . , rk) ∧δ0(u) ∧δ1(v). If y does\nnot occur as an argument of R′ then R′(x, z) implements Implies. Similarly, if x\ndoes not occur as an argument of R′ then R′(y, z) implements Implies. If z does\nnot occur as an argument of R′ then R′(x, y) implements NAND. So we assume\nthat x, y and z occur as argments. Then apply Lemma 14 to R′(x, y, z).\nFor the final subcase, suppose that there are tuples t and t′ in R such that\nt ∧t′ is not in R. Define ri to be u if ti = t′\ni = 0 or x if ti = 0, t′\ni = 1 or y\nif ti = 1, t′\ni = 0, or v if ti = t′\ni = 1. Let R′ be the relation implemented by\nR′(x, y) = R(r1, . . . , rk)∧δ0(u)∧δ1(v). If t∨t′ is in R then R′(x, y) implements\nOR(x, y), so we are finished.\nOtherwise R′ = {(0, 1), (1, 0)} (which we now\nassume).\nNow using Part (i) of Lemma 11, let s, s′ and s′′ be tuples in R so that\ns ⊕s′ ⊕s′′ is not in R. Define ri as follows.\nsi\ns′\ni\ns′′\ni\nri\n0\n0\n0\nu\n0\n0\n1\nx\n0\n1\n0\ny\n0\n1\n1\nz\n1\n0\n0\nz′\n1\n0\n1\ny′\n1\n1\n0\nx′\n1\n1\n1\nu′\nLet R′′ be the relation implemented by\nR(r1, . . . , rk) ∧δ0(u) ∧R′(u, u′) ∧R′(x, x′) ∧R′(y, y′) ∧R′(z, z′).\nBy writing x′ = x, y′ = y and z′ = z, we can think of R′′ as a function of\nx, y and z.\nIf x does not occur as an argument then R′′(y, z) implements\nImplies(y, z). Similarly, we can assume that y and z occur as arguments. Now\nconsider the relation R′′(x, y, z). We know that (0, 0, 0), (0, 1, 1), (1, 0, 1) ∈R′′,\nsince s, s′, s′′ ∈R.\nAlso (1, 1, 0) /∈R′′ since s ⊕s′ ⊕s′′ /∈R.\nThen apply\nLemma 14 to R′′.\n17","paragraphs":[{"paragraph_id":"p1","order":1,"text":"arXiv:0710.4272v2 [cs.CC] 22 Jul 2009\nAn approximation trichotomy for Boolean #CSP ∗\nMartin Dyer\nSchool of Computing\nUniversity of Leeds\nLeeds LS2 9JT, UK\nLeslie Ann Goldberg\nDepartment of Computer Science,\nUniversity of Liverpool,\nLiverpool L69 3BX, UK\nMark Jerrum\nSchool of Mathematical Sciences,\nQueen Mary, University of London\nMile End Road, London E1 4NS, UK\nOctober 31, 2018\nAbstract\nWe give a trichotomy theorem for the complexity of approximately\ncounting the number of satisfying assignments of a Boolean CSP instance.\nSuch problems are parameterised by a constraint language specifying the\nrelations that may be used in constraints. If every relation in the con-\nstraint language is affine then the number of satisfying assignments can\nbe exactly counted in polynomial time.\nOtherwise, if every relation in\nthe constraint language is in the co-clone IM2 from Post’s lattice, then\nthe problem of counting satisfying assignments is complete with respect\nto approximation-preserving reductions for the complexity class #RHΠ1.\nThis means that the problem of approximately counting satisfying as-\nsignments of such a CSP instance is equivalent in complexity to several\nother known counting problems, including the problem of approximately\ncounting the number of independent sets in a bipartite graph. For every\nother fixed constraint language, the problem is complete for #P with re-\nspect to approximation-preserving reductions, meaning that there is no\nfully polynomial randomised approximation scheme for counting satisfying\nassignments unless NP=RP.\n1\nIntroduction\nThis paper gives a trichotomy theorem for the complexity of approximately\ncounting the number of satisfying assignments of a Boolean CSP instance. Such\nproblems are parameterised by a constraint language Γ which specifies relations\nthat may be used in constraints. In the Boolean case, the relations are on a\ndomain which has two elements. Then #CSP(Γ) will denote the problem of\n∗This work was partially supported by the EPSRC grant “The Complexity of Counting in\nConstraint Satisfaction Problems”\n1"},{"paragraph_id":"p2","order":2,"text":"determining the number of (distinct) satisfying assignments of a CSP instance\nwith constraint language Γ. Further details are given in Section 1.1 below.\nCreignou and Hermann [6] have given a dichotomy theorem for the exact\ncounting problem. They have shown that if every relation in Γ is affine, then\n#CSP(Γ) is in FP. Otherwise, it is #P-complete. The complexity classes FP\nand #P are the analogues of P and NP for counting problems. FP is the class\nof functions computable in deterministic polynomial time. #P is the class of\ninteger functions that can be expressed as the number of accepting computations\nof a polynomial-time non-deterministic Turing machine.\nIn this paper we build on previous work on the complexity of approximate\ncounting to identify a trichotomy in the complexity of approximate counting\nfor Boolean #CSP.\nTogether with Greenhill [9], we have previously studied approximation-\npreserving reductions (AP-reductions) between counting problems.\nWe will\ngive details of AP-reductions in Section 1.2. For now it suffices to note that if\nan AP-reduction exists from a counting problem f to a counting problem g and\ng has a Fully Polynomial Randomised Approximation Scheme (FPRAS) then f\nalso has an FPRAS.\nIf an AP-reduction from f to g exists we write f ≤AP g, and say that f\nis AP-reducible to g. If f ≤AP g and g ≤AP f then we say that f and g are\nAP-interreducible, and write f =AP g.\nWe previously identified [9] three natural classes of counting problems that\nare interreducible under AP-reductions.\nThese are (i) those problems that\nhave an FPRAS, (ii) those problems that are complete for #P with respect to\nAP-reducibility, and a third class of intermediate complexity. Two counting\nproblems played a special role in [9].\nName. #SAT.\nInstance. A Boolean formula φ in conjunctive normal form.\nOutput. The number of satisfying assignments of φ.\nName. #BIS.\nInstance. A bipartite graph B.\nOutput. The number of independent sets in B.\nAll problems in #P are AP-reducible to #SAT (see [9, Section 3]). Thus\n#SAT is complete for #P with respect to AP-reducibility. This means that\n#SAT cannot have an FPRAS unless NP = RP.\nThe same is true of any\nproblem in #P to which #SAT is AP-reducible.\nWe showed in [9, Sections 4, 5] that #BIS is AP-interreducible with many\nother natural counting problems such as counting downsets in a partial order.\nMoreover, #BIS is complete for #RHΠ1, a logically-defined subclass of #P,\nwith respect to AP-reductions.\nThe main theorem of our current paper (Theorem 3) shows that every prob-\nlem #CSP(Γ) falls neatly into one of the three classes from [9]: If every relation\n2"},{"paragraph_id":"p3","order":3,"text":"in Γ is affine, then trivially #CSP(Γ) has an FPRAS since it is in FP. Other-\nwise, if every relation in Γ is in a certain set IM2, then #CSP(Γ) =AP #BIS.\nOtherwise #CSP(Γ) =AP #SAT. A formal definition of IM2\nappears in Sec-\ntion 1.4 — it is the set of relations which can be expressed as conjunctions\ninvolving only binary implication and unary relations.\nIt is worth pointing out that, while every problem #CSP(Γ) falls into one\nof the three approximation classes from [9], the three classes may well not\nprovide a partition of all approximate counting problems in #P. For example,\nthe problem of approximately counting 3-colourings of a bipartite graph is a\nproblem that may well lie between #BIS and #SAT in approximability (see [9]).\n1.1\nConstraint satisfaction\nConstraint Satisfaction, which originated in Artificial Intelligence, provides a\ngeneral framework for modelling decision problems, and has many practical\napplications. (See, for example [18].) Decisions are modelled by variables, which\nare subject to constraints, modelling logical and resource restrictions.\nThe\nparadigm is sufficiently broad that many interesting problems can be modelled,\nfrom satisfiability problems to scheduling problems and graph-theory problems.\nUnderstanding the complexity of constraint satisfaction problems has become\na major and active area within computational complexity [7, 11].\nA Constraint Satisfaction Problem (CSP) typically has a finite domain,\nwhich we denote by {0, . . . , q −1} for a positive integer q. In this paper we\nare interested in the Boolean case q = 2. A constraint language Γ with domain\n{0, . . . , q −1} is a set of relations on {0, . . . , q −1}. For example, take q = 2.\nThe relation R = {(0, 0, 1), (0, 1, 0), (1, 0, 0), (1, 1, 1)} is a 3-ary relation on the\ndomain {0, 1}, with four tuples.\nOnce we have fixed a constraint language Γ, an instance of the CSP is a set of\nvariables V = {v1, . . . , vn} and a set of constraints. Each constraint has a scope,\nwhich is a tuple of variables (for example, (v4, v5, v1)) and a relation from Γ of\nthe same arity, which constrains the variables in the scope. An assignment σ\nis a function from V to {0, . . . , q −1}. The assignment σ is satisfying if the\nscope of every constraint is mapped to a tuple that is in the corresponding\nrelation. In our example above, an assignment σ satisfies the constraint with\nscope (v4, v5, v1) and relation R, written R(v4, v5, v1), if and only if it maps an\nodd number of the variables in {v1, v4, v5} to the value 1. Given an instance I\nof a CSP with constraint language Γ, the decision problem CSP(Γ) asks us to\ndetermine whether any assignment satisfies I. The counting problem #CSP(Γ)\nasks us to determine the number of (distinct) satisfying assignments of I, which\nwe will denote by #csp(I).\nVarying the constraint language Γ defines the classes CSP and #CSP of\ndecision and counting problems.\nThese contain problems of different com-\nputational complexities.\nFor example, consider the binary relations defined\nby OR = {(0, 1), (1, 0), (1, 1)}, Implies = {(0, 0), (0, 1), (1, 1)}, and NAND =\n{(0, 0), (0, 1), (1, 0)}. If Γ = {OR, Implies, NAND} then CSP(Γ) is the classical\n2-Satisfiability problem, which is in P. On the other hand, there is a similar con-\nstraint language Γ′ with four relations of arity 3 such that 3-Satisfiability (which\n3"},{"paragraph_id":"p4","order":4,"text":"is NP-complete) can be represented in CSP(Γ′). It may happen, as here, that\nthe counting problem is harder than the decision problem: #CSP(Γ) contains\nthe problem of counting independent sets in graph, and is thus #P-complete.\nAny decision problem CSP(Γ) is in NP, but not every problem in NP can be\nrepresented as a CSP. For example, the question “Is G Hamiltonian?” cannot\nbe expressed as a CSP, because the property of being Hamiltonian cannot be\ncaptured by relations of bounded size. This limitation of the class CSP has an\nimportant advantage. If P ̸= NP, then there are problems which are neither\nin P nor NP-complete [15]. But, for well-behaved smaller classes of decision\nproblems, the situation can be simpler. We may have a dichotomy theorem,\npartitioning all problems in the class into those which are in P and those which\nare NP-complete. There are no “leftover” problems of intermediate complex-\nity. It has been conjectured that there is a dichotomy theorem for CSP. The\nconjecture is that CSP(Γ) is in P for some constraint languages Γ, and CSP(Γ)\nis NP-complete for all other constraint languages Γ. This conjecture appeared\nin a seminal paper of Feder and Vardi [13], but has not yet been proved. A\nsimilar dichotomy, between FP and #P-complete, is conjectured for #CSP [4].\nRecently, Bulatov [3] has announced a positive resolution of this conjecture.\nThere have been many important results for subclasses of CSP and #CSP.\nWe mention the most relevant to our paper here. The first decision dichotomy\nwas that of Schaefer [19], for the Boolean domain {0, 1}. Schaefer’s result is as\nfollows.\nTheorem 1 (Schaefer [19]). Let Γ be a constraint language with domain {0, 1}.\nThe problem CSP(Γ) is in P if Γ satisfies one of the conditions below. Other-\nwise, CSP(Γ) is NP-complete.\n(i) Γ is 0-valid or 1-valid.\n(ii) Γ is weakly positive or weakly negative.\n(iii) Γ is affine.\n(iv) Γ is bijunctive.\nWe will not give detailed definitions of the conditions in Theorem 1, but\nthe interested reader is referred to the paper [19] or to Theorem 6.2 of the\ntextbook [7]. An interesting feature is that the conditions in [7, Theorem 6.2]\nare all checkable. That is, there is an algorithm to determine whether CSP(Γ)\nis in P or NP-complete, given a constraint language Γ with domain {0, 1}. We\nsay in this case that the dichotomy is effective.\nA Boolean relation R is said to be affine if the set of tuples x ∈R is the set of\nsolutions to a system of linear equations over GF(2). Creignou and Hermann [6]\nadapted Schaefer’s decision dichotomy to obtain a counting dichotomy for the\nBoolean domain. Their result is as follows.\nTheorem 2 (Creignou and Hermann [6]). Let Γ be a constraint language with\ndomain {0, 1}. The problem #CSP(Γ) is in FP if every relation in Γ is affine.\nOtherwise, #CSP(Γ) is #P-complete.\nCreignou and Hermann’s result is an important starting point for our work,\nand we will discuss it further below. Note that there is an algorithm for deter-\nmining whether a relation is affine, so the dichotomy is effective.\n4"},{"paragraph_id":"p5","order":5,"text":"We have recently [10] extended Creignou and Hermann’s dichotomy to the\ndomain of weighted Boolean #CSP giving an effective dichotomy between FP\nand FP#P for the problem of computing the partition function of a weighted\nBoolean CSP instance.\n1.2\nThe complexity of approximate counting\nWe now recall the necessary background from [9]. A randomised approxima-\ntion scheme is an algorithm for approximately computing the value of a func-\ntion f : Σ∗→N. The approximation scheme has a parameter ε > 0 which\nspecifies the error tolerance. A randomised approximation scheme for f is a\nrandomised algorithm that takes as input an instance x ∈Σ∗(e.g., an encoding\nof a CSP instance) and an error tolerance ε > 0, and outputs an integer z (a\nrandom variable on the “coin tosses” made by the algorithm) such that, for\nevery instance x,\nPr"},{"paragraph_id":"p6","order":6,"text":"e−εf(x) ≤z ≤eεf(x)"},{"paragraph_id":"p7","order":7,"text":"≥3\n4 .\n(1)\nThe randomised approximation scheme is said to be a fully polynomial ran-\ndomised approximation scheme, or FPRAS, if it runs in time bounded by a\npolynomial in |x| and ε−1. (See Mitzenmacher and Upfal [16, Definition 10.2].)\nNote that the quantity 3/4 in Equation (1) could be changed to any value in the\nopen interval (1\n2, 1) without changing the set of problems that have randomised\napproximation schemes [14, Lemma 6.1].\nSuppose that f and g are functions from Σ∗to N.\nAn “approximation-\npreserving reduction” (AP-reduction) from f to g gives a way to turn an FPRAS\nfor g into an FPRAS for f. An AP-reduction from f to g is a randomised\nalgorithm A for computing f using an oracle for g1. The algorithm A takes\nas input a pair (x, ε) ∈Σ∗× (0, 1), and satisfies the following three conditions:\n(i) every oracle call made by A is of the form (w, δ), where w ∈Σ∗is an instance\nof g, and 0 < δ < 1 is an error bound satisfying δ−1 ≤poly(|x|, ε−1); (ii)\nthe algorithm A meets the specification for being a randomised approximation\nscheme for f (as described above) whenever the oracle meets the specification\nfor being a randomised approximation scheme for g; and (iii) the run-time of A\nis polynomial in |x| and ε−1.\nIn formulating a definition of approximation-\npresering reduction, a number of choices must be faced. The key requirement is\nthat the class of functions computable by an FPRAS should be closed under AP-\nreducibility. Informally, we have gone for the most liberal notion of reduction\nmeeting this requirement.\n1.3\nNotation for relations\nDefine the unary relations δ0 = {(0)} and δ1 = {(1)}. Recall the binary relation\nImplies = {(0, 0), (0, 1), (1, 1)}.\nFor convenience, according to context, we view a k-ary relation R either as a\nset of k-tuples or as a k-ary predicate. Thus the notations R(x1, . . . , xk) = 1 (or\n1The reader who is not familiar with oracle Turing machines can just think of this as an\nimaginary (unwritten) subroutine for computing g.\n5"},{"paragraph_id":"p8","order":8,"text":"just R(x1, . . . , xk)) and (x1, . . . , xk) ∈R are equivalent. For example, δ0(x) = x,\nδ1(x) = x and Implies(x, y) = x ∨y.\n1.4\nThe set of relations IM2\nAn n-ary relation R is in IM2 if and only if R(x1, . . . , xn) is logically equivalent\nto a conjunction of predicates of the form δ0(xi), δ1(xi) and Implies(xi, xj).\nAs we will discuss below, Creignou, Kolaitis, and Zanuttini [8] have shown\nthat IM2 is a co-clone in Post’s lattice (see [2]).\n1.5\nOur result\nWe can now state our main theorem.\nTheorem 3. Let Γ be a constraint language with domain {0, 1}. If every rela-\ntion in Γ is affine then #CSP(Γ) is in FP. Otherwise if every relation in Γ is\nin IM2 then #CSP(Γ) =AP #BIS. Otherwise #CSP(Γ) =AP #SAT.\nThe main ingredients in the proof are: (1) the AP-reduction technology\nof [9], which allows us to effectively “pin” certain CSP variables in hardness\nproofs (see Section 2.3); (2) the “implementations” of Creignou, Khanna and\nSudan [7], which show how to construct the key relations OR, Implies, and NAND\nfrom a non-affine relation and δ0 or δ1 (see Section 2.5); (3) the complexity class\n#RHΠ1 from [9], consisting of those problems which are AP-interreducible with\n#BIS; and (4) the co-clone IM2 in Post’s lattice (see Section 2.8), since the\ncomplexity of #CSP(Γ) for Γ ⊆IM2 turns out to be closely connected to the\ncomplexity of #BIS.\n2\nThe pieces of the proof\n2.1\nTypes of relations\nA relation R is 0-valid if the all-zero tuple is in R.\nSimilarly, R is 1-valid\nif the all-ones tuple is in R. Following [7], we say that a k-ary relation R is\ncomplement-closed (C-closed in [7]) if\n(x1, . . . , xk) ∈R ⇔(x1 ⊕1, . . . , xk ⊕1) ∈R,\nwhere ⊕is the exclusive or operator.\nWe say that Γ is 0-valid if every R ∈Γ is 0-valid and we define what it\nmeans for Γ to be 1-valid or complement-closed similarly.\n2.2\nSome preliminary complexity results\nWe start by observing that every problem #CSP(Γ) is AP-reducible to #SAT\nObservation 4. Let Γ be a constraint language with domain {0, 1}.\nThen\n#CSP(Γ) ≤AP #SAT.\n6"},{"paragraph_id":"p9","order":9,"text":"Observation 4 follows from the fact that all problems in #P\nare AP-\nreducible to #SAT [9]. Another, very simple, but useful, observation is the\nfollowing.\nObservation 5. Let Γ be a constraint language with domain {0, 1}. Suppose\nΓ′ ⊆Γ. Then #CSP(Γ′) ≤AP #CSP(Γ).\nObservation 5 is true for the simple reason that every instance of #CSP(Γ′)\nis an instance of #CSP(Γ).\nRecall the relations OR = {(0, 1), (1, 0), (1, 1)} and NAND = {(0, 0), (0, 1),\n(1, 0)}. These relations are particularly fundamental for us, and we start with\ncomplexity results about these.\nLemma 6. #SAT ≤AP #CSP({NAND}).\nProof. It was shown in [9] that the following problem is AP-interreducible with\n#SAT.\nName. #IS.\nInstance. A graph G.\nOutput. The number of independent sets in G.\nWe show that #IS ≤AP #CSP({NAND}). Let G = (V, E) be an instance\nof #IS. Construct an instance I of #CSP({NAND}) with variable set V . For\nevery edge (u, v) ∈E, add constraint NAND(u, v). There is now a bijection\nbetween independent sets of G and satisfying assignments σ of I: variables v\nwith σ(v) = 1 correspond to vertices in the independent set.\nLemma 7. #SAT ≤AP #CSP({OR}).\nProof. The proof that #IS ≤AP #CSP({OR}) is similar (just associate variables\nv with σ(v) = 1 with vertices that are out of the independent set).\nFinally, we will need a couple of complexity results involving #BIS.\nLemma 8. #BIS ≤AP #CSP({Implies}).\nProof. Let G be an instance of #BIS with vertex sets U and V and edge set E.\nConstruct an instance I of #CSP({Implies}) with variable set U ∪V . For every\nedge (u, v) ∈E with u ∈U add constraint Implies(u, v). There is now a bijection\nbetween independent sets of G and satisfying assignments σ of I: a variable\nu ∈U with σ(u) = 1 is in the independent set and a variable v ∈V with\nσ(v) = 0 is in the independent set.\nLemma 9. Suppose Γ ⊆IM2. Then #CSP(Γ) ≤AP #BIS.\n7"},{"paragraph_id":"p10","order":10,"text":"Proof. It is straightforward to show that #CSP(Γ) is in the complexity class\n#RHΠ1 which has #BIS as a complete problem [9].\nHowever, to avoid giving a definition of #RHΠ1, which requires some nota-\ntion, we will instead show #CSP(Γ) ≤AP #Downsets, where #Downsets is\nthe following counting problem which was shown in [9] to be AP-interreducible\nwith #BIS.\nName. #Downsets.\nInstance. A partially ordered set (X, ⪯).\nOutput. The number of downsets2 in (X, ⪯).\nConsider an instance I of #CSP(Γ) with variables v1, . . . , vn. The set of\nconstraints can be viewed as an equivalent set of constraints of the form δ0(vi),\nδ1(vi) or Implies(vi, vj). Denote by Implies∗the transitive closure of the Implies\nrelation on {v1, . . . , vn}: thus Implies∗(vi, vj) if there is a sequence of variables,\nstarting with vi and ending with vj, such that every adjacent pair in the se-\nquence is constrained by Implies.\nLet N0(I) be the set of variables vi for which either (i) a constraint δ0(vi)\noccurs in I, or (ii) there exists a variable vj such that Implies∗(vi, vj) and a\nconstraint δ0(vj) occurs in I. These are the variables that are forced to be 0\nin any satisfying assignment of I. Define N1(I) analogously to be the set of\nvariables that are forced to be 1 in any satisfying assignment. We can assume\nwithout loss of generality that N0(I) and N1(I) are disjoint. Otherwise the\ninstance I has no satisfying assignments, and we can determine this without\neven using the downsets oracle.\nNow remove all the variables in N0(I) and N1(I) from the instance I: this\ndoes not affect the number of satisfying assignments, since these variables do\nnot constrain any of the others. Also identify all pairs of variables vi, vj such\nthat Implies∗(vi, vj) and Implies∗(vj, vi): again, this does not affect the number\nof satisfying assignments.\nThe remaining variables and relations define a partial order (X, ⪯) since our\nconstruction forces antisymmetry. The satisfying assignments of I correspond\n1–1 with the downsets of (X, ⪯).\n2.3\nA useful tool: pinning\nPinning is the ability to tie certain CSP variables to specific values in hard-\nness proofs. This idea was used by Creignou and Hermann in their dichotomy\ntheorem [6]. Similar ideas have been used in many other hardness proofs and\ndichotomy theorems [4, 5, 10, 12]. As we show in this section, AP-reductions\nfacilitate a particularly useful form of pinning.\nLemma 10. Let Γ be a constraint language with domain {0, 1}. Suppose there\nis a relation R ∈Γ for which, for some position j, R has more tuples t with\ntj = 0 than with tj = 1. Then #CSP(Γ ∪{δ0}) ≤AP #CSP(Γ). Similarly, if\n2A downset in (X, ⪯) is a subset D ⊆X that is closed under ⪯; i.e., x ⪯y and y ∈D\nimplies x ∈D.\n8"},{"paragraph_id":"p11","order":11,"text":"there is a relation R ∈Γ for which, for some position j, R has more tuples t\nwith tj = 1 than with tj = 0 then #CSP(Γ ∪{δ1}) ≤AP #CSP(Γ).\nProof. Consider an instance I of #CSP(Γ ∪{δ0}) with n variables. Suppose\nthere is an arity-k relation R ∈Γ for which, for position j, R has w tuples t\nwith tj = 0 and w′ < w tuples t with tj = 1.\nAs in the proof of Lemma 9, let N0(I) be the set of variables x to which one\nor more constraints δ0(x) occurs in I and let N1(I) be the set of variables y to\nwhich one or more constraints δ1(y) occurs. Let n0 = |N0(I)|. Let m = ⌈(n +\n2)/ lg(w/w′)⌉. Construct an instance I′ of #CSP(Γ). Include all constraints\nin I other than those involving δ0. For each variable x ∈N0(I), and every\na ∈{1, . . . , m}, introduce k −1 new variables x′\na,b for b ∈{1, . . . , k} −{j}.\nIntroduce a new constraint in I′ with relation R and variable x in the j th\nposition, and x′\na,b in the b th position, for all b.\nNow a satisfying assignment for I can be extended in wmn0 ways to satisfying\nassignments of I′. An assignment for I that violates one of the δ0(x) constraints\ncan be extended in at most wm(n0−1)w′ m ways to satisfying assignments of I′.\nThus,\n#csp(I)wmn0 ≤#csp(I′) ≤#csp(I)wmn0 + 2nwm(n0−1)w′ m,\ni.e.,\n#csp(I) ≤#csp(I′)\nwmn0\n≤#csp(I) + 2n(w′/w)m.\nSo, by definition of m,\n#csp(I) ≤#csp(I′)\nwmn0\n≤#csp(I) + 1\n4.\nThus we have constructed a reduction from #CSP(Γ ∪{δ0}) to #CSP(Γ):\nGiven an instance I of #CSP(Γ ∪{δ0}), use an oracle for #CSP(Γ) to approxi-\nmate #csp(I′), divide by wmn0, and round to the nearest integer (always down).\nNote that the reduction makes only one oracle call (and uses no randomisation).\nTo show that the reduction is indeed an AP-reduction, we add some techni-\ncal details concerning the choice of the accuracy parameter δ in the oracle call\n(see the definition of AP-reduction in Section 1.2). These details are here to\nmake the proof complete, but they are not essential for understanding the rest\nof the paper.\nIf we had\n#csp(I) = #csp(I′)\nwmn0\n,\nwe could simply set δ = ε, since division by a constant preserves relative error.\nInstead we have\n#csp(I) =\n #csp(I′)\nwmn0"},{"paragraph_id":"p12","order":12,"text":".\nThe discontinuous floor function could spoil the approximation when its argu-\nment is small.\nThe situation here is that the true answer N = #csp(I) is obtained by\nrounding the fraction Q = #csp(I′)\nwmn0\nwhere we have |Q −N| ≤1/4.\n9"},{"paragraph_id":"p13","order":13,"text":"Suppose that the oracle provides an approximation bQ to Q satisfying Qe−δ ≤\nbQ ≤Qeδ (as it is required to do with probability at least 3/4). Set δ = ε/21,\nwhere ε is the accuracy parameter governing the final result. There are two\ncases.\nIf N ≤2/ε, then a short calculation yields | bQ −Q| < 1/4 implying\nthat the result returned by the algorithm is exact. If N > 2/ε, then the result\nreturned is in the range [(N −1/4)e−δ −1/2, (N + 1/4)eδ + 1/2] which, for the\nchosen δ, is contained in [Ne−ε, Neε].\nThus, we have an AP-reduction from #CSP(Γ ∪{δ0}) to #CSP(Γ). The\nreduction showing #CSP(Γ ∪{δ1}) ≤AP #CSP(Γ) is similar.\n2.4\nAffine relations\nWe use the following well-known facts about affine relations.\nLemma 11.\n(i) A k-ary Boolean relation R is affine if and only if a, b, c ∈R\nimplies d = a⊕b⊕c ∈R, where the ⊕operator is applied componentwise.\n(ii) If R is not affine, then for any fixed a ∈R there are b, c ∈R such that\na ⊕b ⊕c ̸∈R.\n(iii) If R is not affine, then there are a, b in R such that a ⊕b ̸∈R.\nProof. For Part (i) see, for example, Lemma 4.10 of [7]). Part (ii) is proved in\nthe same place, but since it is a little less well-known, we provide the proof:\nSuppose the contrary that R is not affine, but for all b, c ∈R, a ⊕b ⊕c ∈R.\nChoose s0, s1, s2 ∈R such that s0 ⊕s1 ⊕s2 ̸∈R.\nFrom b = s0, c = s1,\nd = a ⊕s0 ⊕s1 we have d ∈R. From b = s2, c = d we have a ⊕s2 ⊕d =\ns0 ⊕s1 ⊕s2 ∈R, a contradiction.\nTo see Part (iii), note that the condition “∀a, b : a, b ∈R implies a ⊕b ∈R”\nimplies that R is affine, so, if R is not affine then the condition is false.\n2.5\nImplementation\nLet Γ be a constraint language with domain {0, 1}. Γ is said to implement3 a\nk-ary relation R if, for some k′ ≥k there is a CSP instance I with variables\nx1, . . . , xk′ and constraints in Γ such that, for every tuple (s1, . . . , sk) ∈R, there\nis exactly one satisfying assignment σ of I with σ(x1) = s1, . . . , σ(xk) = sk and\nfor every tuple (s1, . . . , sk) ̸∈R, there are no satisfying assignments σ of I with\nσ(x1) = s1, . . . , σ(xk) = sk. Note the following straightforward observation,\nwhich is essentially a parsimonious reduction [17, p.441].\nObservation 12. If Γ implements R then #CSP(Γ ∪{R}) ≤AP #CSP(Γ).\nWe will use several implementations of Creignou, Khanna and Sudan. Proofs\nare provided in the appendix in order to make the paper self-contained.\nLemma 13. (Creignou, Khanna and Sudan, [7, Lemmas 5.24 and 5.25]) Let\nΓ be a constraint language with domain {0, 1}.\n3There are many variants of “implement” defined in the literature. See [7, Chapter 5],\nwhere the kind of implementation we define here is called “faithful” and “perfect”.\n10"},{"paragraph_id":"p14","order":14,"text":"(i) If Γ contains a relation R that is 0-valid, 1-valid and not complement-\nclosed then Γ implements the relation R′ = {(0, 0), (1, 1), (1, 0)}.\n(ii) If Γ contains a relation R that is not 0-valid, not 1-valid and not comple-\nment-closed then Γ implements δ0 and δ1.\n(iii) If Γ contains a relation R that is 0-valid and not 1-valid then Γ imple-\nments δ0.\n(iv) If Γ contains a relation R that is 1-valid and not 0-valid then Γ imple-\nments δ1.\nLemma 14. (Creignou, Khanna and Sudan, [7, Claim 5.31])\nLet R be a\nternary relation containing (0, 0, 0), (0, 1, 1) and (1, 0, 1) but not (1, 1, 0). Then\n{R, δ0} implements one of Implies and NAND.\nLemma 15. (Creignou, Khanna and Sudan, [7, Lemma 5.30]) If R is a rela-\ntion over {0, 1} that is not affine then {R, δ0} implements one of OR, Implies,\nand NAND and so does {R, δ1}.\n2.6\nPinning revisited\nCombining the useful pinning that we get from AP-reductions (Lemma 10) with\nthe implementations of OR, Implies and NAND in Section 2.5, we obtain a useful\nlemma which says that we can always do some pinning.\nLemma 16. Let Γ be a constraint language with domain {0, 1}. Then either\n#CSP(Γ ∪{δ0}) ≤AP #CSP(Γ) or #CSP(Γ ∪{δ1}) ≤AP #CSP(Γ) (or both).\nProof. First, suppose that Γ is not complement-closed. If Γ contains a relation\nR that is not 0-valid, not 1-valid and not complement-closed then we finish by\nObservation 12 and Part (ii) of Lemma 13. If Γ contains a relation R that\nis 0-valid, 1-valid and not complement-closed then it implements the relation\nR′ from Part (i) of Lemma 13 so by Observation 12, #CSP(Γ ∪{R′}) ≤AP\n#CSP(Γ). But Lemma 10 shows both #CSP(Γ∪{R′, δ0}) ≤AP #CSP(Γ∪{R′})\nand #CSP(Γ ∪{R′, δ1}) ≤AP #CSP(Γ ∪{R′}). Otherwise Γ contains a relation\nR that is 0-valid and not 1-valid (or vice-versa) and we finish by Part (iii) (or\nPart (iv)) of Lemma 13, and Observation 12.\nSecond (and finally), suppose that Γ is complement-closed. Here is a sim-\nple AP-reduction from #CSP(Γ ∪{δ0}) to #CSP(Γ). Let I be an instance of\n#CSP(Γ ∪{δ0}). Construct an instance I′ of #CSP(Γ) by adding a new vari-\nable z0. For all x ∈N0(I) (all variables x to which one or more constraints δ0(x)\nin I apply), replace all occurrences of variable x with z0 in I′. Now note that\n2#csp(I) = #csp(I′) since there is a one-to-two map from satisfying assign-\nments of I and satisfying assignments of I′. In particular, if s is an assignment\nto all variables of I other than those in N0(I) and s is satisfying, provided the\nrest of the variables are assigned value 0, then s is mapped to s; z0 = 0 and\ns; z0 = 1, where s is the tuple obtained from s by complementing the assign-\nment of every variable. Both satisfy I′ since Γ is complement-closed. It is clear\nthat all satisfying assignments of I′ arise in this way.\n11"},{"paragraph_id":"p15","order":15,"text":"2.7\nNotation for Boolean functions\nThe following definitions are from [1, 2].\nAn m-ary Boolean function f is\nmonotonic if and only if (a1, . . . , am) ≤(b1, . . . , bm) componentwise implies\nf(a1, . . . , am) ≤f(b1, . . . , bm).\nLet M2 be the set of all monotone Boolean\nfunctions f satisfying f(0, . . . , 0) = 0 and f(1, . . . , 1) = 1. Given a set B of\nBoolean functions, the closure [B] consists of all functions that can be defined\nby propositional formulas with connectives from B (see [1]).\nAn m-ary Boolean function f is said to be a polymorphism of an n-ary\nrelation R(x1, . . . , xn) if applying f componentwise to m tuples in R results in\na tuple that is also in R.\n2.8\nPolymorphisms and IM2\nIn the terminology of universal algebra, Creignou, Kolaitis, and Zanuttini [8]\nhave shown that IM2 is precisely the co-clone corresponding to M2, which is a\nclone in Post’s lattice (see [2]). The direction of this result that we will use is\nthe following.\nLemma 17. (Creignou, Kolaitis, Zanuttini, [8]) If the relation R is not in IM2\nthen there is an f ∈M2 that is not a polymorphism of R.\nCorollary 18. If the n-ary relation R is not in IM2 then there are Boolean\ntuples (a1, . . . , an) ∈R and (b1, . . . , bn) ∈R such that either (a1 ∧b1, . . . , an ∧\nbn) ̸∈R or (a1 ∨b1, . . . , an ∨bn) ̸∈R (or both).\nProof. We will use the fact (see [1]) that M2 = [{∨, ∧}] where x ∨y is the OR\nof the Boolean values x and y and x ∧y is the AND of x and y. Thus, every\nfunction f ∈M2 can be defined by a propositional formula using the 2-ary\nconnectives ∨and ∧.\nThe proof is by induction on the number of connectives used in the propo-\nsitional formula used to represent the function f from Lemma 17.\nThe case f(x) = x (in which f has no connectives) cannot arise since the\nidentity function is a polymorphism of every relation. The cases f(x, y) = x∨y\nand f(x, y) = x ∧y (in which f has one connective) immediately give the\ncorollary.\nFor the inductive step, we assume either f(x1, . . . , xm) = f ′(x1, . . . , xm) ∨\nf ′′(x1, . . . , xm) or f(x1, . . . , xm) = f ′(x1, . . . , xm)∧f ′′(x1, . . . , xm) where f ′ and\nf ′′ have fewer connectives than f. Note that f ′ and f ′′ may not actually use\nall of the variables in x1, . . . , xm.\nThese two cases are similar, so suppose we are in the first of them. That is,\nsuppose\nf(x1, . . . , xm) = f ′(x1, . . . , xm) ∨f ′′(x1, . . . , xm).\nSuppose also that f ′ and f ′′ are polymorphisms of R (otherwise we will apply\nthe inductive hypothesis to one of these functions which has fewer connectives).\nLet t1, . . . , tm be m n-tuples in R, such that the tuple obtained by applying\nf componentwise to t1, . . . , tm is not in R. Let t′ be the n-tuple obtained by\napplying f ′ componentwise to t1, . . . , tm and let t′′ be the n-tuple obtained by\n12"},{"paragraph_id":"p16","order":16,"text":"applying f ′′ componentwise to t1, . . . , tm. Since f ′ and f ′′ are polymorphisms\nof R, we know that t′ and t′′ are in R. However, since f is not a polymorphism\nof R, the tuple t′ ∨t′′ is not in R, proving the corollary.\n3\nPutting it all together: the proof of Theorem 3\nWe start with a lemma establishing a reduction from #SAT.\nLemma 19. Let R1 and R2 be relations on {0, 1}. If R1 is not affine and R2\nis not in IM2 then #SAT ≤AP #CSP({R1, R2}).\nProof. Apply Lemma 16 with Γ = {R1, R2}. Then either #CSP({R1, R2, δ0}) ≤AP\n#CSP({R1, R2}) or #CSP({R1, R2, δ1}) ≤AP #CSP({R1, R2}).\nAssume the\nformer (the latter case is symmetric).\nNow use Lemma 15 together with Observation 12. Since R1 is not affine\nthis shows one of the following.\n• #CSP({R1, R2, δ0, OR}) ≤AP #CSP({R1, R2, δ0}), or\n• #CSP({R1, R2, δ0, NAND}) ≤AP #CSP({R1, R2, δ0}), or\n• #CSP({R1, R2, δ0, Implies}) ≤AP #CSP({R1, R2, δ0}).\nIn the first two of these cases, we are finished by Observation 5 and Lem-\nmas 6 and 7, so assume the final case. Using Lemma 10 with the second position\nof Implies, we get #CSP({R1, R2, δ0, Implies, δ1}) ≤AP #CSP({R1, R2, δ0}).\nSimplifying the chain of reductions and using Observation 5 to drop R1 from\nthe left-hand side, we get #CSP({Implies, R2, δ0, δ1}) ≤AP #CSP({R1, R2}).\nWe will now finish by showing #SAT ≤AP #CSP({Implies, R2, δ0, δ1}).\nCase 1.\nUsing Corollary 18, suppose that t and t′ are tuples in R2 but\nthe tuple t ∧t′ (in which the operator ∧is applied componentwise) is not in\nR2. We will show that {Implies, R2, δ0, δ1} implements one of OR and XOR =\n{(0, 1), (1, 0)}. Let k be the arity of R2. As in the implementations of Creignou\net al. [7], define ri to be u if ti = t′\ni = 0 or x if ti = 0, t′\ni = 1 or y if ti =\n1, t′\ni = 0, or v if ti = t′\ni = 1. Let R′ be the relation implemented by R′(x, y) =\nR2(r1, . . . , rk) ∧δ0(u) ∧δ1(v). Note that both x and y appear as arguments\nof R′ since t ̸= t ∧t′ and t′ ̸= t ∧t′. If t ∨t′ is in R2 then R′(x, y) implements\nOR(x, y), so we are finished. Otherwise R′ = XOR (which we now assume).\nUsing Observation 12 and 5, we have\n#CSP({Implies, XOR}) ≤AP #CSP({R1, R2}).\nWe will finish by showing that {Implies, XOR} implements NAND. (The result\nthen follows by Lemma 6 and Observation 12.)\nThe implementation is given by NAND(x, z) = Implies(x, y) ∧XOR(y, z).\nCase 2.\nOtherwise, by Corollary 18, there are t and t′ in R2 such that t ∨t′\nis not in R2. This case is dual to Case 1.\n13"},{"paragraph_id":"p17","order":17,"text":"We can now prove the main theorem.\nTheorem 3.\nLet Γ be a constraint language with domain {0, 1}. If every\nrelation in Γ is affine then #CSP(Γ) is in FP. Otherwise if every relation in Γ\nis in IM2 then #CSP(Γ) =AP #BIS. Otherwise #CSP(Γ) =AP #SAT.\nProof. First, suppose that every relation in Γ is affine. In this case, the number\nof satisfying assignments of an instance I of #CSP(Γ) is the number of solutions\nto a system of linear equations over GF(2).\nThis can be computed exactly,\nby Gaussian elimination, in polynomial time, as Creignou and Hermann have\nnoted [6].\nNext, suppose that Γ contains a relation R that is not affine, but every\nrelation in Γ is in IM2. By Lemma 9, #CSP(Γ) ≤AP #BIS\nTo see that #BIS ≤AP #CSP(Γ), apply Lemma 16. Then we know that\neither #CSP(Γ ∪{δ0}) ≤AP #CSP(Γ) or #CSP(Γ ∪{δ1}) ≤AP #CSP(Γ) (or\nboth). We will show\n#BIS ≤AP #CSP(Γ ∪{δ0})\n(2)\nand\n#BIS ≤AP #CSP(Γ ∪{δ1})\n(3)\nand then we will be able to conclude #BIS ≤AP #CSP(Γ).\nThe proofs of\nEquations (2) and (3) are similar, so we just prove (2). By Lemma 15, Γ ∪{δ0}\nimplements one of OR, Implies, and NAND. So by Observation 12 we have (at\nleast) one of the following.\n(i) #CSP(Γ ∪{δ0, OR}) ≤AP #CSP(Γ ∪{δ0})\n(ii) #CSP(Γ ∪{δ0, Implies}) ≤AP #CSP(Γ ∪{δ0})\n(iii) #CSP(Γ ∪{δ0, NAND}) ≤AP #CSP(Γ ∪{δ0})\nEquation (2) follows from the combination of Lemma 8 and (ii) using Obser-\nvation 5. Also, since #BIS ≤AP #SAT (see [9]), Equation (2) follows from the\ncombination of Lemma 7 and (i) using Observation 5. Similarly, it follows from\nthe combination of Lemma 6 and (iii) using Observation 5.\nFinally, suppose that Γ contains a relation R1 that is not affine and a rela-\ntion R2 that is not in IM2. (R1 and R2 might possibly be the same relation.)\nThe fact that #CSP(Γ) ≤AP #SAT follows from Observation 4 and the fact\nthat #SAT ≤AP #CSP(Γ) follows from Lemma 19 and Observation 5.\nReferences\n[1] E. B ̈ohler, N. Creignou, S. Reith and H. Vollmer, Playing with Boolean\nblocks, Part I: Post’s lattice with applications to complexity theory, ACM\nSIGACT Newsletter 34 (2003), 38–52.\n[2] E. B ̈ohler, S. Reith, H. Schnoor and H. Vollmer, Bases for Boolean co-clones,\nInformation Processing Letters 96 (2005), 59–66.\n[3] A. Bulatov, The complexity of the counting constraint satisfaction problem,\nProc. 35th International Colloquium for Automata, Languages and Program-\nming, Lecture Notes in Computer Science 5125, Springer-Verlag, 2008, 646–\n661.\n14"},{"paragraph_id":"p18","order":18,"text":"[4] A. Bulatov and V. Dalmau, Towards a dichotomy theorem for the counting\nconstraint satisfaction problem, in Proc. 44th Annual IEEE Symposium on\nFoundations of Computer Science, 2003, 562–573.\n[5] A. Bulatov and M. Grohe, The complexity of partition functions, Theoretical\nComputer Science 348 (2005), 148–186.\n[6] N. Creignou and M. Hermann, Complexity of generalized satisfiability\ncounting problems, Information and Computation 125 (1996), 1–12.\n[7] N. Creignou, S. Khanna and M. Sudan, Complexity classifications of Boolean\nconstraint satisfaction problems, SIAM Press, 2001.\n[8] N. Creignou, P. Kolaitis and B. Zanuttini, Preferred representations of\nBoolean relations, Electronic Colloquium on Computational Complexity, Re-\nport No. 119, 2005.\n[9] M. Dyer, L.A. Goldberg, C. Greenhill and M. Jerrum, The relative complex-\nity of approximate counting problems, Algorithmica 38 (2004), 471–500.\n[10] M. Dyer, L.A. Goldberg and M. Jerrum, The Complexity of Weighted\nBoolean #CSP, SIAM Journal on Computing 38 (2009), 1970–1986.\n[11] P. Hell and J. Neˇsetˇril, Graphs and homomorphisms, Oxford University\nPress, 2004.\n[12] M. Dyer and C. Greenhill, The complexity of counting graph homomor-\nphisms, Random Structures and Algorithms 17 (2000), 260–289.\n[13] T. Feder and M. Vardi, The computational structure of monotone monadic\nSNP and constraint satisfaction: a study through Datalog and group theory,\nSIAM Journal on Computing 28 (1999), 57–104.\n[14] M. Jerrum, L. Valiant and V. Vazirani, Random generation of combinato-\nrial structures from a uniform distribution, Theoretical Computer Science\n43 (1986), 169–188.\n[15] R. Ladner, On the structure of polynomial time reducibility, Journal of the\nAssociation for Computing Machinery 22 (1975), 155–171.\n[16] M. Mitzenmacher and E. Upfal, Probability and Computing, Cambridge\nUniversity Press, 2005.\n[17] C.H. Papadimitriou, Computational Complexity, Addison-Wesley, 1994.\n[18] F. Rossi, P. van Beek and T. Walsh (Eds.), Handbook of constraint pro-\ngramming, Elsevier, 2006.\n[19] T. Schaefer, The complexity of satisfiability problems, in Proc. 10th Annual\nACM Symposium on Theory of Computing, ACM Press, 1978, 216–226.\n15"},{"paragraph_id":"p19","order":19,"text":"Appendix: The implementations of Creignou, Khanna\nand Sudan\nIn order to make our paper self-contained, we give the details of the implemen-\ntations of Creignou, Khanna and Sudan that we use. In particular, we provide\nthe proofs for Lemmas 13, 14 and 15. (These proofs can be found in [7].)\nWe start with the construction for Lemma 13.\nSuppose R ∈Γ is not\ncomplement-closed. Choose (s1, . . . , sk) in R such that (s1 ⊕1, . . . , sk ⊕1) is\nnot in R. Now consider the relation R′ implemented by R′(x, y) = R(r1, . . . , rk)\nwhere ri = x if si = 1 and ri = y otherwise. In the first case, R′ is the relation\n{(0, 0), (1, 1), (1, 0)}. In the second case, R′ = {(1, 0)} so R′ gives an implemen-\ntation of both δ1 and δ0. The construction for the third and fourth cases are\nthe trivial implementations δ0(x) = R(x, . . . , x) and δ1(x) = R(x, . . . , x).\nWe now give the construction for Lemma 14. If R excludes exactly one\nof (0, 1, 0) and (1, 1, 1) then R(x, y, x) implements Implies(y, x) or NAND(x, y)\n(depending on which is excluded). Similarly, if R excludes exactly one of (1, 0, 0)\nand (1, 1, 1) then R(x, y, y) implements Implies(x, y) or NAND(x, y). If both\n(0, 1, 0) and (1, 0, 0) are in R then fR(x, y, z) ∧δ0(z) implements fNAND(x, y).\nIf (0, 1, 0), (1, 1, 1) and (1, 0, 0) are excluded from R and so is (0, 0, 1) then\nR(x, y, z) implements NAND(x, y). Finally, if (0, 1, 0), (1, 1, 1) and (1, 0, 0) are\nexcluded but (0, 0, 1) is in R then R(x, y, z) ∧δ0(x) implements Implies(y, z).\nFinally, we give the construction for Lemma 15. We will show that {R, δ0}\nimplements one of the named relations. A similar argument shows that {R, δ1}\ndoes. Let k be the arity of R.\nFirst, suppose that R is 0-valid. Using part (iii) of Lemma 11, let s and s′\nbe tuples in R such that s ⊕s′ is not in R. Let ri = w if si = s′\ni = 0. Let\nri = x if si = 0, s′\ni = 1. Let ri = y if si = 1, s′\ni = 0. Let ri = z if si = s′\ni = 1.\nNow we know that at least one of x and y occurs as an ri, since s ̸= s′. Let R′\nbe the relation implemented by R(r1, . . . , rk) ∧δ0(w). There are a few cases to\nconsider. If x occurs as an argument to R but y does not then z occurs since\ns ̸= 0. Thus, the relation R′(x, z) is Implies. (Technically, this is a ternary\nrelation in variables x, y and z, but it can be viewed as a binary relation since y\ndoes not appear.) The situation is similar if y occurs as an argument to R but\nx does not. If both x and y occur as arguments but z does not then the relation\nR′(x, y) is NAND. Otherwise, x, y and z all occur as arguments. Furthermore,\nsince R is 0-valid, lemma 14 applies to the relation given by R′(x, y, z).\nSecond (and finally), suppose that R is not 0-valid. Note that {R, δ0} can\nimplement δ1. To see this, let s be a tuple in R. Let ri = x if si = 1 and let\nri = y otherwise. Then δ1(x) is implemented by R(r1, . . . , rk) ∧δ0(y). Now\nconsider two sub-cases.\nFor the first sub-case, suppose that for any two tuples, t and t′, in R,\nthe tuple t ∧t′,where ∧is applied componentwise, is also in R. Let s be the\nintersection of all tuples in R. Then s ∈R. By Part (ii) of Lemma 11, there\nare two tuples s′ and s′′ in R such that s ⊕s′ ⊕s′′ is not in R. Let ri = u if\nsi = s′\ni = s′′\ni = 0. Let ri = x if si = 0, s′\ni = 0, s′′\ni = 1. Let ri = y if si = 0, s′\ni =\n1, s′′\ni = 0. Let ri = z if si = 0, s′\ni = 1, s′′\ni = 1. Let ri = v if si = s′\ni = s′′\ni = 1.\n16"},{"paragraph_id":"p20","order":20,"text":"Let R′ be the relation implemented by R(r1, . . . , rk) ∧δ0(u) ∧δ1(v). If y does\nnot occur as an argument of R′ then R′(x, z) implements Implies. Similarly, if x\ndoes not occur as an argument of R′ then R′(y, z) implements Implies. If z does\nnot occur as an argument of R′ then R′(x, y) implements NAND. So we assume\nthat x, y and z occur as argments. Then apply Lemma 14 to R′(x, y, z).\nFor the final subcase, suppose that there are tuples t and t′ in R such that\nt ∧t′ is not in R. Define ri to be u if ti = t′\ni = 0 or x if ti = 0, t′\ni = 1 or y\nif ti = 1, t′\ni = 0, or v if ti = t′\ni = 1. Let R′ be the relation implemented by\nR′(x, y) = R(r1, . . . , rk)∧δ0(u)∧δ1(v). If t∨t′ is in R then R′(x, y) implements\nOR(x, y), so we are finished.\nOtherwise R′ = {(0, 1), (1, 0)} (which we now\nassume).\nNow using Part (i) of Lemma 11, let s, s′ and s′′ be tuples in R so that\ns ⊕s′ ⊕s′′ is not in R. Define ri as follows.\nsi\ns′\ni\ns′′\ni\nri\n0\n0\n0\nu\n0\n0\n1\nx\n0\n1\n0\ny\n0\n1\n1\nz\n1\n0\n0\nz′\n1\n0\n1\ny′\n1\n1\n0\nx′\n1\n1\n1\nu′\nLet R′′ be the relation implemented by\nR(r1, . . . , rk) ∧δ0(u) ∧R′(u, u′) ∧R′(x, x′) ∧R′(y, y′) ∧R′(z, z′).\nBy writing x′ = x, y′ = y and z′ = z, we can think of R′′ as a function of\nx, y and z.\nIf x does not occur as an argument then R′′(y, z) implements\nImplies(y, z). Similarly, we can assume that y and z occur as arguments. Now\nconsider the relation R′′(x, y, z). We know that (0, 0, 0), (0, 1, 1), (1, 0, 1) ∈R′′,\nsince s, s′, s′′ ∈R.\nAlso (1, 1, 0) /∈R′′ since s ⊕s′ ⊕s′′ /∈R.\nThen apply\nLemma 14 to R′′.\n17"}],"pages":[{"page":1,"text":"arXiv:0710.4272v2 [cs.CC] 22 Jul 2009\nAn approximation trichotomy for Boolean #CSP ∗\nMartin Dyer\nSchool of Computing\nUniversity of Leeds\nLeeds LS2 9JT, UK\nLeslie Ann Goldberg\nDepartment of Computer Science,\nUniversity of Liverpool,\nLiverpool L69 3BX, UK\nMark Jerrum\nSchool of Mathematical Sciences,\nQueen Mary, University of London\nMile End Road, London E1 4NS, UK\nOctober 31, 2018\nAbstract\nWe give a trichotomy theorem for the complexity of approximately\ncounting the number of satisfying assignments of a Boolean CSP instance.\nSuch problems are parameterised by a constraint language specifying the\nrelations that may be used in constraints. If every relation in the con-\nstraint language is affine then the number of satisfying assignments can\nbe exactly counted in polynomial time.\nOtherwise, if every relation in\nthe constraint language is in the co-clone IM2 from Post’s lattice, then\nthe problem of counting satisfying assignments is complete with respect\nto approximation-preserving reductions for the complexity class #RHΠ1.\nThis means that the problem of approximately counting satisfying as-\nsignments of such a CSP instance is equivalent in complexity to several\nother known counting problems, including the problem of approximately\ncounting the number of independent sets in a bipartite graph. For every\nother fixed constraint language, the problem is complete for #P with re-\nspect to approximation-preserving reductions, meaning that there is no\nfully polynomial randomised approximation scheme for counting satisfying\nassignments unless NP=RP.\n1\nIntroduction\nThis paper gives a trichotomy theorem for the complexity of approximately\ncounting the number of satisfying assignments of a Boolean CSP instance. Such\nproblems are parameterised by a constraint language Γ which specifies relations\nthat may be used in constraints. In the Boolean case, the relations are on a\ndomain which has two elements. Then #CSP(Γ) will denote the problem of\n∗This work was partially supported by the EPSRC grant “The Complexity of Counting in\nConstraint Satisfaction Problems”\n1"},{"page":2,"text":"determining the number of (distinct) satisfying assignments of a CSP instance\nwith constraint language Γ. Further details are given in Section 1.1 below.\nCreignou and Hermann [6] have given a dichotomy theorem for the exact\ncounting problem. They have shown that if every relation in Γ is affine, then\n#CSP(Γ) is in FP. Otherwise, it is #P-complete. The complexity classes FP\nand #P are the analogues of P and NP for counting problems. FP is the class\nof functions computable in deterministic polynomial time. #P is the class of\ninteger functions that can be expressed as the number of accepting computations\nof a polynomial-time non-deterministic Turing machine.\nIn this paper we build on previous work on the complexity of approximate\ncounting to identify a trichotomy in the complexity of approximate counting\nfor Boolean #CSP.\nTogether with Greenhill [9], we have previously studied approximation-\npreserving reductions (AP-reductions) between counting problems.\nWe will\ngive details of AP-reductions in Section 1.2. For now it suffices to note that if\nan AP-reduction exists from a counting problem f to a counting problem g and\ng has a Fully Polynomial Randomised Approximation Scheme (FPRAS) then f\nalso has an FPRAS.\nIf an AP-reduction from f to g exists we write f ≤AP g, and say that f\nis AP-reducible to g. If f ≤AP g and g ≤AP f then we say that f and g are\nAP-interreducible, and write f =AP g.\nWe previously identified [9] three natural classes of counting problems that\nare interreducible under AP-reductions.\nThese are (i) those problems that\nhave an FPRAS, (ii) those problems that are complete for #P with respect to\nAP-reducibility, and a third class of intermediate complexity. Two counting\nproblems played a special role in [9].\nName. #SAT.\nInstance. A Boolean formula φ in conjunctive normal form.\nOutput. The number of satisfying assignments of φ.\nName. #BIS.\nInstance. A bipartite graph B.\nOutput. The number of independent sets in B.\nAll problems in #P are AP-reducible to #SAT (see [9, Section 3]). Thus\n#SAT is complete for #P with respect to AP-reducibility. This means that\n#SAT cannot have an FPRAS unless NP = RP.\nThe same is true of any\nproblem in #P to which #SAT is AP-reducible.\nWe showed in [9, Sections 4, 5] that #BIS is AP-interreducible with many\nother natural counting problems such as counting downsets in a partial order.\nMoreover, #BIS is complete for #RHΠ1, a logically-defined subclass of #P,\nwith respect to AP-reductions.\nThe main theorem of our current paper (Theorem 3) shows that every prob-\nlem #CSP(Γ) falls neatly into one of the three classes from [9]: If every relation\n2"},{"page":3,"text":"in Γ is affine, then trivially #CSP(Γ) has an FPRAS since it is in FP. Other-\nwise, if every relation in Γ is in a certain set IM2, then #CSP(Γ) =AP #BIS.\nOtherwise #CSP(Γ) =AP #SAT. A formal definition of IM2\nappears in Sec-\ntion 1.4 — it is the set of relations which can be expressed as conjunctions\ninvolving only binary implication and unary relations.\nIt is worth pointing out that, while every problem #CSP(Γ) falls into one\nof the three approximation classes from [9], the three classes may well not\nprovide a partition of all approximate counting problems in #P. For example,\nthe problem of approximately counting 3-colourings of a bipartite graph is a\nproblem that may well lie between #BIS and #SAT in approximability (see [9]).\n1.1\nConstraint satisfaction\nConstraint Satisfaction, which originated in Artificial Intelligence, provides a\ngeneral framework for modelling decision problems, and has many practical\napplications. (See, for example [18].) Decisions are modelled by variables, which\nare subject to constraints, modelling logical and resource restrictions.\nThe\nparadigm is sufficiently broad that many interesting problems can be modelled,\nfrom satisfiability problems to scheduling problems and graph-theory problems.\nUnderstanding the complexity of constraint satisfaction problems has become\na major and active area within computational complexity [7, 11].\nA Constraint Satisfaction Problem (CSP) typically has a finite domain,\nwhich we denote by {0, . . . , q −1} for a positive integer q. In this paper we\nare interested in the Boolean case q = 2. A constraint language Γ with domain\n{0, . . . , q −1} is a set of relations on {0, . . . , q −1}. For example, take q = 2.\nThe relation R = {(0, 0, 1), (0, 1, 0), (1, 0, 0), (1, 1, 1)} is a 3-ary relation on the\ndomain {0, 1}, with four tuples.\nOnce we have fixed a constraint language Γ, an instance of the CSP is a set of\nvariables V = {v1, . . . , vn} and a set of constraints. Each constraint has a scope,\nwhich is a tuple of variables (for example, (v4, v5, v1)) and a relation from Γ of\nthe same arity, which constrains the variables in the scope. An assignment σ\nis a function from V to {0, . . . , q −1}. The assignment σ is satisfying if the\nscope of every constraint is mapped to a tuple that is in the corresponding\nrelation. In our example above, an assignment σ satisfies the constraint with\nscope (v4, v5, v1) and relation R, written R(v4, v5, v1), if and only if it maps an\nodd number of the variables in {v1, v4, v5} to the value 1. Given an instance I\nof a CSP with constraint language Γ, the decision problem CSP(Γ) asks us to\ndetermine whether any assignment satisfies I. The counting problem #CSP(Γ)\nasks us to determine the number of (distinct) satisfying assignments of I, which\nwe will denote by #csp(I).\nVarying the constraint language Γ defines the classes CSP and #CSP of\ndecision and counting problems.\nThese contain problems of different com-\nputational complexities.\nFor example, consider the binary relations defined\nby OR = {(0, 1), (1, 0), (1, 1)}, Implies = {(0, 0), (0, 1), (1, 1)}, and NAND =\n{(0, 0), (0, 1), (1, 0)}. If Γ = {OR, Implies, NAND} then CSP(Γ) is the classical\n2-Satisfiability problem, which is in P. On the other hand, there is a similar con-\nstraint language Γ′ with four relations of arity 3 such that 3-Satisfiability (which\n3"},{"page":4,"text":"is NP-complete) can be represented in CSP(Γ′). It may happen, as here, that\nthe counting problem is harder than the decision problem: #CSP(Γ) contains\nthe problem of counting independent sets in graph, and is thus #P-complete.\nAny decision problem CSP(Γ) is in NP, but not every problem in NP can be\nrepresented as a CSP. For example, the question “Is G Hamiltonian?” cannot\nbe expressed as a CSP, because the property of being Hamiltonian cannot be\ncaptured by relations of bounded size. This limitation of the class CSP has an\nimportant advantage. If P ̸= NP, then there are problems which are neither\nin P nor NP-complete [15]. But, for well-behaved smaller classes of decision\nproblems, the situation can be simpler. We may have a dichotomy theorem,\npartitioning all problems in the class into those which are in P and those which\nare NP-complete. There are no “leftover” problems of intermediate complex-\nity. It has been conjectured that there is a dichotomy theorem for CSP. The\nconjecture is that CSP(Γ) is in P for some constraint languages Γ, and CSP(Γ)\nis NP-complete for all other constraint languages Γ. This conjecture appeared\nin a seminal paper of Feder and Vardi [13], but has not yet been proved. A\nsimilar dichotomy, between FP and #P-complete, is conjectured for #CSP [4].\nRecently, Bulatov [3] has announced a positive resolution of this conjecture.\nThere have been many important results for subclasses of CSP and #CSP.\nWe mention the most relevant to our paper here. The first decision dichotomy\nwas that of Schaefer [19], for the Boolean domain {0, 1}. Schaefer’s result is as\nfollows.\nTheorem 1 (Schaefer [19]). Let Γ be a constraint language with domain {0, 1}.\nThe problem CSP(Γ) is in P if Γ satisfies one of the conditions below. Other-\nwise, CSP(Γ) is NP-complete.\n(i) Γ is 0-valid or 1-valid.\n(ii) Γ is weakly positive or weakly negative.\n(iii) Γ is affine.\n(iv) Γ is bijunctive.\nWe will not give detailed definitions of the conditions in Theorem 1, but\nthe interested reader is referred to the paper [19] or to Theorem 6.2 of the\ntextbook [7]. An interesting feature is that the conditions in [7, Theorem 6.2]\nare all checkable. That is, there is an algorithm to determine whether CSP(Γ)\nis in P or NP-complete, given a constraint language Γ with domain {0, 1}. We\nsay in this case that the dichotomy is effective.\nA Boolean relation R is said to be affine if the set of tuples x ∈R is the set of\nsolutions to a system of linear equations over GF(2). Creignou and Hermann [6]\nadapted Schaefer’s decision dichotomy to obtain a counting dichotomy for the\nBoolean domain. Their result is as follows.\nTheorem 2 (Creignou and Hermann [6]). Let Γ be a constraint language with\ndomain {0, 1}. The problem #CSP(Γ) is in FP if every relation in Γ is affine.\nOtherwise, #CSP(Γ) is #P-complete.\nCreignou and Hermann’s result is an important starting point for our work,\nand we will discuss it further below. Note that there is an algorithm for deter-\nmining whether a relation is affine, so the dichotomy is effective.\n4"},{"page":5,"text":"We have recently [10] extended Creignou and Hermann’s dichotomy to the\ndomain of weighted Boolean #CSP giving an effective dichotomy between FP\nand FP#P for the problem of computing the partition function of a weighted\nBoolean CSP instance.\n1.2\nThe complexity of approximate counting\nWe now recall the necessary background from [9]. A randomised approxima-\ntion scheme is an algorithm for approximately computing the value of a func-\ntion f : Σ∗→N. The approximation scheme has a parameter ε > 0 which\nspecifies the error tolerance. A randomised approximation scheme for f is a\nrandomised algorithm that takes as input an instance x ∈Σ∗(e.g., an encoding\nof a CSP instance) and an error tolerance ε > 0, and outputs an integer z (a\nrandom variable on the “coin tosses” made by the algorithm) such that, for\nevery instance x,\nPr\n \ne−εf(x) ≤z ≤eεf(x)\n \n≥3\n4 .\n(1)\nThe randomised approximation scheme is said to be a fully polynomial ran-\ndomised approximation scheme, or FPRAS, if it runs in time bounded by a\npolynomial in |x| and ε−1. (See Mitzenmacher and Upfal [16, Definition 10.2].)\nNote that the quantity 3/4 in Equation (1) could be changed to any value in the\nopen interval (1\n2, 1) without changing the set of problems that have randomised\napproximation schemes [14, Lemma 6.1].\nSuppose that f and g are functions from Σ∗to N.\nAn “approximation-\npreserving reduction” (AP-reduction) from f to g gives a way to turn an FPRAS\nfor g into an FPRAS for f. An AP-reduction from f to g is a randomised\nalgorithm A for computing f using an oracle for g1. The algorithm A takes\nas input a pair (x, ε) ∈Σ∗× (0, 1), and satisfies the following three conditions:\n(i) every oracle call made by A is of the form (w, δ), where w ∈Σ∗is an instance\nof g, and 0 < δ < 1 is an error bound satisfying δ−1 ≤poly(|x|, ε−1); (ii)\nthe algorithm A meets the specification for being a randomised approximation\nscheme for f (as described above) whenever the oracle meets the specification\nfor being a randomised approximation scheme for g; and (iii) the run-time of A\nis polynomial in |x| and ε−1.\nIn formulating a definition of approximation-\npresering reduction, a number of choices must be faced. The key requirement is\nthat the class of functions computable by an FPRAS should be closed under AP-\nreducibility. Informally, we have gone for the most liberal notion of reduction\nmeeting this requirement.\n1.3\nNotation for relations\nDefine the unary relations δ0 = {(0)} and δ1 = {(1)}. Recall the binary relation\nImplies = {(0, 0), (0, 1), (1, 1)}.\nFor convenience, according to context, we view a k-ary relation R either as a\nset of k-tuples or as a k-ary predicate. Thus the notations R(x1, . . . , xk) = 1 (or\n1The reader who is not familiar with oracle Turing machines can just think of this as an\nimaginary (unwritten) subroutine for computing g.\n5"},{"page":6,"text":"just R(x1, . . . , xk)) and (x1, . . . , xk) ∈R are equivalent. For example, δ0(x) = x,\nδ1(x) = x and Implies(x, y) = x ∨y.\n1.4\nThe set of relations IM2\nAn n-ary relation R is in IM2 if and only if R(x1, . . . , xn) is logically equivalent\nto a conjunction of predicates of the form δ0(xi), δ1(xi) and Implies(xi, xj).\nAs we will discuss below, Creignou, Kolaitis, and Zanuttini [8] have shown\nthat IM2 is a co-clone in Post’s lattice (see [2]).\n1.5\nOur result\nWe can now state our main theorem.\nTheorem 3. Let Γ be a constraint language with domain {0, 1}. If every rela-\ntion in Γ is affine then #CSP(Γ) is in FP. Otherwise if every relation in Γ is\nin IM2 then #CSP(Γ) =AP #BIS. Otherwise #CSP(Γ) =AP #SAT.\nThe main ingredients in the proof are: (1) the AP-reduction technology\nof [9], which allows us to effectively “pin” certain CSP variables in hardness\nproofs (see Section 2.3); (2) the “implementations” of Creignou, Khanna and\nSudan [7], which show how to construct the key relations OR, Implies, and NAND\nfrom a non-affine relation and δ0 or δ1 (see Section 2.5); (3) the complexity class\n#RHΠ1 from [9], consisting of those problems which are AP-interreducible with\n#BIS; and (4) the co-clone IM2 in Post’s lattice (see Section 2.8), since the\ncomplexity of #CSP(Γ) for Γ ⊆IM2 turns out to be closely connected to the\ncomplexity of #BIS.\n2\nThe pieces of the proof\n2.1\nTypes of relations\nA relation R is 0-valid if the all-zero tuple is in R.\nSimilarly, R is 1-valid\nif the all-ones tuple is in R. Following [7], we say that a k-ary relation R is\ncomplement-closed (C-closed in [7]) if\n(x1, . . . , xk) ∈R ⇔(x1 ⊕1, . . . , xk ⊕1) ∈R,\nwhere ⊕is the exclusive or operator.\nWe say that Γ is 0-valid if every R ∈Γ is 0-valid and we define what it\nmeans for Γ to be 1-valid or complement-closed similarly.\n2.2\nSome preliminary complexity results\nWe start by observing that every problem #CSP(Γ) is AP-reducible to #SAT\nObservation 4. Let Γ be a constraint language with domain {0, 1}.\nThen\n#CSP(Γ) ≤AP #SAT.\n6"},{"page":7,"text":"Observation 4 follows from the fact that all problems in #P\nare AP-\nreducible to #SAT [9]. Another, very simple, but useful, observation is the\nfollowing.\nObservation 5. Let Γ be a constraint language with domain {0, 1}. Suppose\nΓ′ ⊆Γ. Then #CSP(Γ′) ≤AP #CSP(Γ).\nObservation 5 is true for the simple reason that every instance of #CSP(Γ′)\nis an instance of #CSP(Γ).\nRecall the relations OR = {(0, 1), (1, 0), (1, 1)} and NAND = {(0, 0), (0, 1),\n(1, 0)}. These relations are particularly fundamental for us, and we start with\ncomplexity results about these.\nLemma 6. #SAT ≤AP #CSP({NAND}).\nProof. It was shown in [9] that the following problem is AP-interreducible with\n#SAT.\nName. #IS.\nInstance. A graph G.\nOutput. The number of independent sets in G.\nWe show that #IS ≤AP #CSP({NAND}). Let G = (V, E) be an instance\nof #IS. Construct an instance I of #CSP({NAND}) with variable set V . For\nevery edge (u, v) ∈E, add constraint NAND(u, v). There is now a bijection\nbetween independent sets of G and satisfying assignments σ of I: variables v\nwith σ(v) = 1 correspond to vertices in the independent set.\nLemma 7. #SAT ≤AP #CSP({OR}).\nProof. The proof that #IS ≤AP #CSP({OR}) is similar (just associate variables\nv with σ(v) = 1 with vertices that are out of the independent set).\nFinally, we will need a couple of complexity results involving #BIS.\nLemma 8. #BIS ≤AP #CSP({Implies}).\nProof. Let G be an instance of #BIS with vertex sets U and V and edge set E.\nConstruct an instance I of #CSP({Implies}) with variable set U ∪V . For every\nedge (u, v) ∈E with u ∈U add constraint Implies(u, v). There is now a bijection\nbetween independent sets of G and satisfying assignments σ of I: a variable\nu ∈U with σ(u) = 1 is in the independent set and a variable v ∈V with\nσ(v) = 0 is in the independent set.\nLemma 9. Suppose Γ ⊆IM2. Then #CSP(Γ) ≤AP #BIS.\n7"},{"page":8,"text":"Proof. It is straightforward to show that #CSP(Γ) is in the complexity class\n#RHΠ1 which has #BIS as a complete problem [9].\nHowever, to avoid giving a definition of #RHΠ1, which requires some nota-\ntion, we will instead show #CSP(Γ) ≤AP #Downsets, where #Downsets is\nthe following counting problem which was shown in [9] to be AP-interreducible\nwith #BIS.\nName. #Downsets.\nInstance. A partially ordered set (X, ⪯).\nOutput. The number of downsets2 in (X, ⪯).\nConsider an instance I of #CSP(Γ) with variables v1, . . . , vn. The set of\nconstraints can be viewed as an equivalent set of constraints of the form δ0(vi),\nδ1(vi) or Implies(vi, vj). Denote by Implies∗the transitive closure of the Implies\nrelation on {v1, . . . , vn}: thus Implies∗(vi, vj) if there is a sequence of variables,\nstarting with vi and ending with vj, such that every adjacent pair in the se-\nquence is constrained by Implies.\nLet N0(I) be the set of variables vi for which either (i) a constraint δ0(vi)\noccurs in I, or (ii) there exists a variable vj such that Implies∗(vi, vj) and a\nconstraint δ0(vj) occurs in I. These are the variables that are forced to be 0\nin any satisfying assignment of I. Define N1(I) analogously to be the set of\nvariables that are forced to be 1 in any satisfying assignment. We can assume\nwithout loss of generality that N0(I) and N1(I) are disjoint. Otherwise the\ninstance I has no satisfying assignments, and we can determine this without\neven using the downsets oracle.\nNow remove all the variables in N0(I) and N1(I) from the instance I: this\ndoes not affect the number of satisfying assignments, since these variables do\nnot constrain any of the others. Also identify all pairs of variables vi, vj such\nthat Implies∗(vi, vj) and Implies∗(vj, vi): again, this does not affect the number\nof satisfying assignments.\nThe remaining variables and relations define a partial order (X, ⪯) since our\nconstruction forces antisymmetry. The satisfying assignments of I correspond\n1–1 with the downsets of (X, ⪯).\n2.3\nA useful tool: pinning\nPinning is the ability to tie certain CSP variables to specific values in hard-\nness proofs. This idea was used by Creignou and Hermann in their dichotomy\ntheorem [6]. Similar ideas have been used in many other hardness proofs and\ndichotomy theorems [4, 5, 10, 12]. As we show in this section, AP-reductions\nfacilitate a particularly useful form of pinning.\nLemma 10. Let Γ be a constraint language with domain {0, 1}. Suppose there\nis a relation R ∈Γ for which, for some position j, R has more tuples t with\ntj = 0 than with tj = 1. Then #CSP(Γ ∪{δ0}) ≤AP #CSP(Γ). Similarly, if\n2A downset in (X, ⪯) is a subset D ⊆X that is closed under ⪯; i.e., x ⪯y and y ∈D\nimplies x ∈D.\n8"},{"page":9,"text":"there is a relation R ∈Γ for which, for some position j, R has more tuples t\nwith tj = 1 than with tj = 0 then #CSP(Γ ∪{δ1}) ≤AP #CSP(Γ).\nProof. Consider an instance I of #CSP(Γ ∪{δ0}) with n variables. Suppose\nthere is an arity-k relation R ∈Γ for which, for position j, R has w tuples t\nwith tj = 0 and w′ < w tuples t with tj = 1.\nAs in the proof of Lemma 9, let N0(I) be the set of variables x to which one\nor more constraints δ0(x) occurs in I and let N1(I) be the set of variables y to\nwhich one or more constraints δ1(y) occurs. Let n0 = |N0(I)|. Let m = ⌈(n +\n2)/ lg(w/w′)⌉. Construct an instance I′ of #CSP(Γ). Include all constraints\nin I other than those involving δ0. For each variable x ∈N0(I), and every\na ∈{1, . . . , m}, introduce k −1 new variables x′\na,b for b ∈{1, . . . , k} −{j}.\nIntroduce a new constraint in I′ with relation R and variable x in the j th\nposition, and x′\na,b in the b th position, for all b.\nNow a satisfying assignment for I can be extended in wmn0 ways to satisfying\nassignments of I′. An assignment for I that violates one of the δ0(x) constraints\ncan be extended in at most wm(n0−1)w′ m ways to satisfying assignments of I′.\nThus,\n#csp(I)wmn0 ≤#csp(I′) ≤#csp(I)wmn0 + 2nwm(n0−1)w′ m,\ni.e.,\n#csp(I) ≤#csp(I′)\nwmn0\n≤#csp(I) + 2n(w′/w)m.\nSo, by definition of m,\n#csp(I) ≤#csp(I′)\nwmn0\n≤#csp(I) + 1\n4.\nThus we have constructed a reduction from #CSP(Γ ∪{δ0}) to #CSP(Γ):\nGiven an instance I of #CSP(Γ ∪{δ0}), use an oracle for #CSP(Γ) to approxi-\nmate #csp(I′), divide by wmn0, and round to the nearest integer (always down).\nNote that the reduction makes only one oracle call (and uses no randomisation).\nTo show that the reduction is indeed an AP-reduction, we add some techni-\ncal details concerning the choice of the accuracy parameter δ in the oracle call\n(see the definition of AP-reduction in Section 1.2). These details are here to\nmake the proof complete, but they are not essential for understanding the rest\nof the paper.\nIf we had\n#csp(I) = #csp(I′)\nwmn0\n,\nwe could simply set δ = ε, since division by a constant preserves relative error.\nInstead we have\n#csp(I) =\n #csp(I′)\nwmn0\n \n.\nThe discontinuous floor function could spoil the approximation when its argu-\nment is small.\nThe situation here is that the true answer N = #csp(I) is obtained by\nrounding the fraction Q = #csp(I′)\nwmn0\nwhere we have |Q −N| ≤1/4.\n9"},{"page":10,"text":"Suppose that the oracle provides an approximation bQ to Q satisfying Qe−δ ≤\nbQ ≤Qeδ (as it is required to do with probability at least 3/4). Set δ = ε/21,\nwhere ε is the accuracy parameter governing the final result. There are two\ncases.\nIf N ≤2/ε, then a short calculation yields | bQ −Q| < 1/4 implying\nthat the result returned by the algorithm is exact. If N > 2/ε, then the result\nreturned is in the range [(N −1/4)e−δ −1/2, (N + 1/4)eδ + 1/2] which, for the\nchosen δ, is contained in [Ne−ε, Neε].\nThus, we have an AP-reduction from #CSP(Γ ∪{δ0}) to #CSP(Γ). The\nreduction showing #CSP(Γ ∪{δ1}) ≤AP #CSP(Γ) is similar.\n2.4\nAffine relations\nWe use the following well-known facts about affine relations.\nLemma 11.\n(i) A k-ary Boolean relation R is affine if and only if a, b, c ∈R\nimplies d = a⊕b⊕c ∈R, where the ⊕operator is applied componentwise.\n(ii) If R is not affine, then for any fixed a ∈R there are b, c ∈R such that\na ⊕b ⊕c ̸∈R.\n(iii) If R is not affine, then there are a, b in R such that a ⊕b ̸∈R.\nProof. For Part (i) see, for example, Lemma 4.10 of [7]). Part (ii) is proved in\nthe same place, but since it is a little less well-known, we provide the proof:\nSuppose the contrary that R is not affine, but for all b, c ∈R, a ⊕b ⊕c ∈R.\nChoose s0, s1, s2 ∈R such that s0 ⊕s1 ⊕s2 ̸∈R.\nFrom b = s0, c = s1,\nd = a ⊕s0 ⊕s1 we have d ∈R. From b = s2, c = d we have a ⊕s2 ⊕d =\ns0 ⊕s1 ⊕s2 ∈R, a contradiction.\nTo see Part (iii), note that the condition “∀a, b : a, b ∈R implies a ⊕b ∈R”\nimplies that R is affine, so, if R is not affine then the condition is false.\n2.5\nImplementation\nLet Γ be a constraint language with domain {0, 1}. Γ is said to implement3 a\nk-ary relation R if, for some k′ ≥k there is a CSP instance I with variables\nx1, . . . , xk′ and constraints in Γ such that, for every tuple (s1, . . . , sk) ∈R, there\nis exactly one satisfying assignment σ of I with σ(x1) = s1, . . . , σ(xk) = sk and\nfor every tuple (s1, . . . , sk) ̸∈R, there are no satisfying assignments σ of I with\nσ(x1) = s1, . . . , σ(xk) = sk. Note the following straightforward observation,\nwhich is essentially a parsimonious reduction [17, p.441].\nObservation 12. If Γ implements R then #CSP(Γ ∪{R}) ≤AP #CSP(Γ).\nWe will use several implementations of Creignou, Khanna and Sudan. Proofs\nare provided in the appendix in order to make the paper self-contained.\nLemma 13. (Creignou, Khanna and Sudan, [7, Lemmas 5.24 and 5.25]) Let\nΓ be a constraint language with domain {0, 1}.\n3There are many variants of “implement” defined in the literature. See [7, Chapter 5],\nwhere the kind of implementation we define here is called “faithful” and “perfect”.\n10"},{"page":11,"text":"(i) If Γ contains a relation R that is 0-valid, 1-valid and not complement-\nclosed then Γ implements the relation R′ = {(0, 0), (1, 1), (1, 0)}.\n(ii) If Γ contains a relation R that is not 0-valid, not 1-valid and not comple-\nment-closed then Γ implements δ0 and δ1.\n(iii) If Γ contains a relation R that is 0-valid and not 1-valid then Γ imple-\nments δ0.\n(iv) If Γ contains a relation R that is 1-valid and not 0-valid then Γ imple-\nments δ1.\nLemma 14. (Creignou, Khanna and Sudan, [7, Claim 5.31])\nLet R be a\nternary relation containing (0, 0, 0), (0, 1, 1) and (1, 0, 1) but not (1, 1, 0). Then\n{R, δ0} implements one of Implies and NAND.\nLemma 15. (Creignou, Khanna and Sudan, [7, Lemma 5.30]) If R is a rela-\ntion over {0, 1} that is not affine then {R, δ0} implements one of OR, Implies,\nand NAND and so does {R, δ1}.\n2.6\nPinning revisited\nCombining the useful pinning that we get from AP-reductions (Lemma 10) with\nthe implementations of OR, Implies and NAND in Section 2.5, we obtain a useful\nlemma which says that we can always do some pinning.\nLemma 16. Let Γ be a constraint language with domain {0, 1}. Then either\n#CSP(Γ ∪{δ0}) ≤AP #CSP(Γ) or #CSP(Γ ∪{δ1}) ≤AP #CSP(Γ) (or both).\nProof. First, suppose that Γ is not complement-closed. If Γ contains a relation\nR that is not 0-valid, not 1-valid and not complement-closed then we finish by\nObservation 12 and Part (ii) of Lemma 13. If Γ contains a relation R that\nis 0-valid, 1-valid and not complement-closed then it implements the relation\nR′ from Part (i) of Lemma 13 so by Observation 12, #CSP(Γ ∪{R′}) ≤AP\n#CSP(Γ). But Lemma 10 shows both #CSP(Γ∪{R′, δ0}) ≤AP #CSP(Γ∪{R′})\nand #CSP(Γ ∪{R′, δ1}) ≤AP #CSP(Γ ∪{R′}). Otherwise Γ contains a relation\nR that is 0-valid and not 1-valid (or vice-versa) and we finish by Part (iii) (or\nPart (iv)) of Lemma 13, and Observation 12.\nSecond (and finally), suppose that Γ is complement-closed. Here is a sim-\nple AP-reduction from #CSP(Γ ∪{δ0}) to #CSP(Γ). Let I be an instance of\n#CSP(Γ ∪{δ0}). Construct an instance I′ of #CSP(Γ) by adding a new vari-\nable z0. For all x ∈N0(I) (all variables x to which one or more constraints δ0(x)\nin I apply), replace all occurrences of variable x with z0 in I′. Now note that\n2#csp(I) = #csp(I′) since there is a one-to-two map from satisfying assign-\nments of I and satisfying assignments of I′. In particular, if s is an assignment\nto all variables of I other than those in N0(I) and s is satisfying, provided the\nrest of the variables are assigned value 0, then s is mapped to s; z0 = 0 and\ns; z0 = 1, where s is the tuple obtained from s by complementing the assign-\nment of every variable. Both satisfy I′ since Γ is complement-closed. It is clear\nthat all satisfying assignments of I′ arise in this way.\n11"},{"page":12,"text":"2.7\nNotation for Boolean functions\nThe following definitions are from [1, 2].\nAn m-ary Boolean function f is\nmonotonic if and only if (a1, . . . , am) ≤(b1, . . . , bm) componentwise implies\nf(a1, . . . , am) ≤f(b1, . . . , bm).\nLet M2 be the set of all monotone Boolean\nfunctions f satisfying f(0, . . . , 0) = 0 and f(1, . . . , 1) = 1. Given a set B of\nBoolean functions, the closure [B] consists of all functions that can be defined\nby propositional formulas with connectives from B (see [1]).\nAn m-ary Boolean function f is said to be a polymorphism of an n-ary\nrelation R(x1, . . . , xn) if applying f componentwise to m tuples in R results in\na tuple that is also in R.\n2.8\nPolymorphisms and IM2\nIn the terminology of universal algebra, Creignou, Kolaitis, and Zanuttini [8]\nhave shown that IM2 is precisely the co-clone corresponding to M2, which is a\nclone in Post’s lattice (see [2]). The direction of this result that we will use is\nthe following.\nLemma 17. (Creignou, Kolaitis, Zanuttini, [8]) If the relation R is not in IM2\nthen there is an f ∈M2 that is not a polymorphism of R.\nCorollary 18. If the n-ary relation R is not in IM2 then there are Boolean\ntuples (a1, . . . , an) ∈R and (b1, . . . , bn) ∈R such that either (a1 ∧b1, . . . , an ∧\nbn) ̸∈R or (a1 ∨b1, . . . , an ∨bn) ̸∈R (or both).\nProof. We will use the fact (see [1]) that M2 = [{∨, ∧}] where x ∨y is the OR\nof the Boolean values x and y and x ∧y is the AND of x and y. Thus, every\nfunction f ∈M2 can be defined by a propositional formula using the 2-ary\nconnectives ∨and ∧.\nThe proof is by induction on the number of connectives used in the propo-\nsitional formula used to represent the function f from Lemma 17.\nThe case f(x) = x (in which f has no connectives) cannot arise since the\nidentity function is a polymorphism of every relation. The cases f(x, y) = x∨y\nand f(x, y) = x ∧y (in which f has one connective) immediately give the\ncorollary.\nFor the inductive step, we assume either f(x1, . . . , xm) = f ′(x1, . . . , xm) ∨\nf ′′(x1, . . . , xm) or f(x1, . . . , xm) = f ′(x1, . . . , xm)∧f ′′(x1, . . . , xm) where f ′ and\nf ′′ have fewer connectives than f. Note that f ′ and f ′′ may not actually use\nall of the variables in x1, . . . , xm.\nThese two cases are similar, so suppose we are in the first of them. That is,\nsuppose\nf(x1, . . . , xm) = f ′(x1, . . . , xm) ∨f ′′(x1, . . . , xm).\nSuppose also that f ′ and f ′′ are polymorphisms of R (otherwise we will apply\nthe inductive hypothesis to one of these functions which has fewer connectives).\nLet t1, . . . , tm be m n-tuples in R, such that the tuple obtained by applying\nf componentwise to t1, . . . , tm is not in R. Let t′ be the n-tuple obtained by\napplying f ′ componentwise to t1, . . . , tm and let t′′ be the n-tuple obtained by\n12"},{"page":13,"text":"applying f ′′ componentwise to t1, . . . , tm. Since f ′ and f ′′ are polymorphisms\nof R, we know that t′ and t′′ are in R. However, since f is not a polymorphism\nof R, the tuple t′ ∨t′′ is not in R, proving the corollary.\n3\nPutting it all together: the proof of Theorem 3\nWe start with a lemma establishing a reduction from #SAT.\nLemma 19. Let R1 and R2 be relations on {0, 1}. If R1 is not affine and R2\nis not in IM2 then #SAT ≤AP #CSP({R1, R2}).\nProof. Apply Lemma 16 with Γ = {R1, R2}. Then either #CSP({R1, R2, δ0}) ≤AP\n#CSP({R1, R2}) or #CSP({R1, R2, δ1}) ≤AP #CSP({R1, R2}).\nAssume the\nformer (the latter case is symmetric).\nNow use Lemma 15 together with Observation 12. Since R1 is not affine\nthis shows one of the following.\n• #CSP({R1, R2, δ0, OR}) ≤AP #CSP({R1, R2, δ0}), or\n• #CSP({R1, R2, δ0, NAND}) ≤AP #CSP({R1, R2, δ0}), or\n• #CSP({R1, R2, δ0, Implies}) ≤AP #CSP({R1, R2, δ0}).\nIn the first two of these cases, we are finished by Observation 5 and Lem-\nmas 6 and 7, so assume the final case. Using Lemma 10 with the second position\nof Implies, we get #CSP({R1, R2, δ0, Implies, δ1}) ≤AP #CSP({R1, R2, δ0}).\nSimplifying the chain of reductions and using Observation 5 to drop R1 from\nthe left-hand side, we get #CSP({Implies, R2, δ0, δ1}) ≤AP #CSP({R1, R2}).\nWe will now finish by showing #SAT ≤AP #CSP({Implies, R2, δ0, δ1}).\nCase 1.\nUsing Corollary 18, suppose that t and t′ are tuples in R2 but\nthe tuple t ∧t′ (in which the operator ∧is applied componentwise) is not in\nR2. We will show that {Implies, R2, δ0, δ1} implements one of OR and XOR =\n{(0, 1), (1, 0)}. Let k be the arity of R2. As in the implementations of Creignou\net al. [7], define ri to be u if ti = t′\ni = 0 or x if ti = 0, t′\ni = 1 or y if ti =\n1, t′\ni = 0, or v if ti = t′\ni = 1. Let R′ be the relation implemented by R′(x, y) =\nR2(r1, . . . , rk) ∧δ0(u) ∧δ1(v). Note that both x and y appear as arguments\nof R′ since t ̸= t ∧t′ and t′ ̸= t ∧t′. If t ∨t′ is in R2 then R′(x, y) implements\nOR(x, y), so we are finished. Otherwise R′ = XOR (which we now assume).\nUsing Observation 12 and 5, we have\n#CSP({Implies, XOR}) ≤AP #CSP({R1, R2}).\nWe will finish by showing that {Implies, XOR} implements NAND. (The result\nthen follows by Lemma 6 and Observation 12.)\nThe implementation is given by NAND(x, z) = Implies(x, y) ∧XOR(y, z).\nCase 2.\nOtherwise, by Corollary 18, there are t and t′ in R2 such that t ∨t′\nis not in R2. This case is dual to Case 1.\n13"},{"page":14,"text":"We can now prove the main theorem.\nTheorem 3.\nLet Γ be a constraint language with domain {0, 1}. If every\nrelation in Γ is affine then #CSP(Γ) is in FP. Otherwise if every relation in Γ\nis in IM2 then #CSP(Γ) =AP #BIS. Otherwise #CSP(Γ) =AP #SAT.\nProof. First, suppose that every relation in Γ is affine. In this case, the number\nof satisfying assignments of an instance I of #CSP(Γ) is the number of solutions\nto a system of linear equations over GF(2).\nThis can be computed exactly,\nby Gaussian elimination, in polynomial time, as Creignou and Hermann have\nnoted [6].\nNext, suppose that Γ contains a relation R that is not affine, but every\nrelation in Γ is in IM2. By Lemma 9, #CSP(Γ) ≤AP #BIS\nTo see that #BIS ≤AP #CSP(Γ), apply Lemma 16. Then we know that\neither #CSP(Γ ∪{δ0}) ≤AP #CSP(Γ) or #CSP(Γ ∪{δ1}) ≤AP #CSP(Γ) (or\nboth). We will show\n#BIS ≤AP #CSP(Γ ∪{δ0})\n(2)\nand\n#BIS ≤AP #CSP(Γ ∪{δ1})\n(3)\nand then we will be able to conclude #BIS ≤AP #CSP(Γ).\nThe proofs of\nEquations (2) and (3) are similar, so we just prove (2). By Lemma 15, Γ ∪{δ0}\nimplements one of OR, Implies, and NAND. So by Observation 12 we have (at\nleast) one of the following.\n(i) #CSP(Γ ∪{δ0, OR}) ≤AP #CSP(Γ ∪{δ0})\n(ii) #CSP(Γ ∪{δ0, Implies}) ≤AP #CSP(Γ ∪{δ0})\n(iii) #CSP(Γ ∪{δ0, NAND}) ≤AP #CSP(Γ ∪{δ0})\nEquation (2) follows from the combination of Lemma 8 and (ii) using Obser-\nvation 5. Also, since #BIS ≤AP #SAT (see [9]), Equation (2) follows from the\ncombination of Lemma 7 and (i) using Observation 5. Similarly, it follows from\nthe combination of Lemma 6 and (iii) using Observation 5.\nFinally, suppose that Γ contains a relation R1 that is not affine and a rela-\ntion R2 that is not in IM2. (R1 and R2 might possibly be the same relation.)\nThe fact that #CSP(Γ) ≤AP #SAT follows from Observation 4 and the fact\nthat #SAT ≤AP #CSP(Γ) follows from Lemma 19 and Observation 5.\nReferences\n[1] E. B ̈ohler, N. Creignou, S. Reith and H. Vollmer, Playing with Boolean\nblocks, Part I: Post’s lattice with applications to complexity theory, ACM\nSIGACT Newsletter 34 (2003), 38–52.\n[2] E. B ̈ohler, S. Reith, H. Schnoor and H. Vollmer, Bases for Boolean co-clones,\nInformation Processing Letters 96 (2005), 59–66.\n[3] A. Bulatov, The complexity of the counting constraint satisfaction problem,\nProc. 35th International Colloquium for Automata, Languages and Program-\nming, Lecture Notes in Computer Science 5125, Springer-Verlag, 2008, 646–\n661.\n14"},{"page":15,"text":"[4] A. Bulatov and V. Dalmau, Towards a dichotomy theorem for the counting\nconstraint satisfaction problem, in Proc. 44th Annual IEEE Symposium on\nFoundations of Computer Science, 2003, 562–573.\n[5] A. Bulatov and M. Grohe, The complexity of partition functions, Theoretical\nComputer Science 348 (2005), 148–186.\n[6] N. Creignou and M. Hermann, Complexity of generalized satisfiability\ncounting problems, Information and Computation 125 (1996), 1–12.\n[7] N. Creignou, S. Khanna and M. Sudan, Complexity classifications of Boolean\nconstraint satisfaction problems, SIAM Press, 2001.\n[8] N. Creignou, P. Kolaitis and B. Zanuttini, Preferred representations of\nBoolean relations, Electronic Colloquium on Computational Complexity, Re-\nport No. 119, 2005.\n[9] M. Dyer, L.A. Goldberg, C. Greenhill and M. Jerrum, The relative complex-\nity of approximate counting problems, Algorithmica 38 (2004), 471–500.\n[10] M. Dyer, L.A. Goldberg and M. Jerrum, The Complexity of Weighted\nBoolean #CSP, SIAM Journal on Computing 38 (2009), 1970–1986.\n[11] P. Hell and J. Neˇsetˇril, Graphs and homomorphisms, Oxford University\nPress, 2004.\n[12] M. Dyer and C. Greenhill, The complexity of counting graph homomor-\nphisms, Random Structures and Algorithms 17 (2000), 260–289.\n[13] T. Feder and M. Vardi, The computational structure of monotone monadic\nSNP and constraint satisfaction: a study through Datalog and group theory,\nSIAM Journal on Computing 28 (1999), 57–104.\n[14] M. Jerrum, L. Valiant and V. Vazirani, Random generation of combinato-\nrial structures from a uniform distribution, Theoretical Computer Science\n43 (1986), 169–188.\n[15] R. Ladner, On the structure of polynomial time reducibility, Journal of the\nAssociation for Computing Machinery 22 (1975), 155–171.\n[16] M. Mitzenmacher and E. Upfal, Probability and Computing, Cambridge\nUniversity Press, 2005.\n[17] C.H. Papadimitriou, Computational Complexity, Addison-Wesley, 1994.\n[18] F. Rossi, P. van Beek and T. Walsh (Eds.), Handbook of constraint pro-\ngramming, Elsevier, 2006.\n[19] T. Schaefer, The complexity of satisfiability problems, in Proc. 10th Annual\nACM Symposium on Theory of Computing, ACM Press, 1978, 216–226.\n15"},{"page":16,"text":"Appendix: The implementations of Creignou, Khanna\nand Sudan\nIn order to make our paper self-contained, we give the details of the implemen-\ntations of Creignou, Khanna and Sudan that we use. In particular, we provide\nthe proofs for Lemmas 13, 14 and 15. (These proofs can be found in [7].)\nWe start with the construction for Lemma 13.\nSuppose R ∈Γ is not\ncomplement-closed. Choose (s1, . . . , sk) in R such that (s1 ⊕1, . . . , sk ⊕1) is\nnot in R. Now consider the relation R′ implemented by R′(x, y) = R(r1, . . . , rk)\nwhere ri = x if si = 1 and ri = y otherwise. In the first case, R′ is the relation\n{(0, 0), (1, 1), (1, 0)}. In the second case, R′ = {(1, 0)} so R′ gives an implemen-\ntation of both δ1 and δ0. The construction for the third and fourth cases are\nthe trivial implementations δ0(x) = R(x, . . . , x) and δ1(x) = R(x, . . . , x).\nWe now give the construction for Lemma 14. If R excludes exactly one\nof (0, 1, 0) and (1, 1, 1) then R(x, y, x) implements Implies(y, x) or NAND(x, y)\n(depending on which is excluded). Similarly, if R excludes exactly one of (1, 0, 0)\nand (1, 1, 1) then R(x, y, y) implements Implies(x, y) or NAND(x, y). If both\n(0, 1, 0) and (1, 0, 0) are in R then fR(x, y, z) ∧δ0(z) implements fNAND(x, y).\nIf (0, 1, 0), (1, 1, 1) and (1, 0, 0) are excluded from R and so is (0, 0, 1) then\nR(x, y, z) implements NAND(x, y). Finally, if (0, 1, 0), (1, 1, 1) and (1, 0, 0) are\nexcluded but (0, 0, 1) is in R then R(x, y, z) ∧δ0(x) implements Implies(y, z).\nFinally, we give the construction for Lemma 15. We will show that {R, δ0}\nimplements one of the named relations. A similar argument shows that {R, δ1}\ndoes. Let k be the arity of R.\nFirst, suppose that R is 0-valid. Using part (iii) of Lemma 11, let s and s′\nbe tuples in R such that s ⊕s′ is not in R. Let ri = w if si = s′\ni = 0. Let\nri = x if si = 0, s′\ni = 1. Let ri = y if si = 1, s′\ni = 0. Let ri = z if si = s′\ni = 1.\nNow we know that at least one of x and y occurs as an ri, since s ̸= s′. Let R′\nbe the relation implemented by R(r1, . . . , rk) ∧δ0(w). There are a few cases to\nconsider. If x occurs as an argument to R but y does not then z occurs since\ns ̸= 0. Thus, the relation R′(x, z) is Implies. (Technically, this is a ternary\nrelation in variables x, y and z, but it can be viewed as a binary relation since y\ndoes not appear.) The situation is similar if y occurs as an argument to R but\nx does not. If both x and y occur as arguments but z does not then the relation\nR′(x, y) is NAND. Otherwise, x, y and z all occur as arguments. Furthermore,\nsince R is 0-valid, lemma 14 applies to the relation given by R′(x, y, z).\nSecond (and finally), suppose that R is not 0-valid. Note that {R, δ0} can\nimplement δ1. To see this, let s be a tuple in R. Let ri = x if si = 1 and let\nri = y otherwise. Then δ1(x) is implemented by R(r1, . . . , rk) ∧δ0(y). Now\nconsider two sub-cases.\nFor the first sub-case, suppose that for any two tuples, t and t′, in R,\nthe tuple t ∧t′,where ∧is applied componentwise, is also in R. Let s be the\nintersection of all tuples in R. Then s ∈R. By Part (ii) of Lemma 11, there\nare two tuples s′ and s′′ in R such that s ⊕s′ ⊕s′′ is not in R. Let ri = u if\nsi = s′\ni = s′′\ni = 0. Let ri = x if si = 0, s′\ni = 0, s′′\ni = 1. Let ri = y if si = 0, s′\ni =\n1, s′′\ni = 0. Let ri = z if si = 0, s′\ni = 1, s′′\ni = 1. Let ri = v if si = s′\ni = s′′\ni = 1.\n16"},{"page":17,"text":"Let R′ be the relation implemented by R(r1, . . . , rk) ∧δ0(u) ∧δ1(v). If y does\nnot occur as an argument of R′ then R′(x, z) implements Implies. Similarly, if x\ndoes not occur as an argument of R′ then R′(y, z) implements Implies. If z does\nnot occur as an argument of R′ then R′(x, y) implements NAND. So we assume\nthat x, y and z occur as argments. Then apply Lemma 14 to R′(x, y, z).\nFor the final subcase, suppose that there are tuples t and t′ in R such that\nt ∧t′ is not in R. Define ri to be u if ti = t′\ni = 0 or x if ti = 0, t′\ni = 1 or y\nif ti = 1, t′\ni = 0, or v if ti = t′\ni = 1. Let R′ be the relation implemented by\nR′(x, y) = R(r1, . . . , rk)∧δ0(u)∧δ1(v). If t∨t′ is in R then R′(x, y) implements\nOR(x, y), so we are finished.\nOtherwise R′ = {(0, 1), (1, 0)} (which we now\nassume).\nNow using Part (i) of Lemma 11, let s, s′ and s′′ be tuples in R so that\ns ⊕s′ ⊕s′′ is not in R. Define ri as follows.\nsi\ns′\ni\ns′′\ni\nri\n0\n0\n0\nu\n0\n0\n1\nx\n0\n1\n0\ny\n0\n1\n1\nz\n1\n0\n0\nz′\n1\n0\n1\ny′\n1\n1\n0\nx′\n1\n1\n1\nu′\nLet R′′ be the relation implemented by\nR(r1, . . . , rk) ∧δ0(u) ∧R′(u, u′) ∧R′(x, x′) ∧R′(y, y′) ∧R′(z, z′).\nBy writing x′ = x, y′ = y and z′ = z, we can think of R′′ as a function of\nx, y and z.\nIf x does not occur as an argument then R′′(y, z) implements\nImplies(y, z). Similarly, we can assume that y and z occur as arguments. Now\nconsider the relation R′′(x, y, z). We know that (0, 0, 0), (0, 1, 1), (1, 0, 1) ∈R′′,\nsince s, s′, s′′ ∈R.\nAlso (1, 1, 0) /∈R′′ since s ⊕s′ ⊕s′′ /∈R.\nThen apply\nLemma 14 to R′′.\n17"}]},"section_tree":[],"assets":{"figures":[],"tables":[],"images":[]},"math_expressions":{"inline":[],"block":[{"equation_id":"eq1","equation_number":null,"raw_text":"assignments unless NP=RP.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq2","equation_number":null,"raw_text":"AP-interreducible, and write f =AP g.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq3","equation_number":null,"raw_text":"#SAT cannot have an FPRAS unless NP = RP.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq4","equation_number":null,"raw_text":"wise, if every relation in Γ is in a certain set IM2, then #CSP(Γ) =AP #BIS.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq5","equation_number":null,"raw_text":"Otherwise #CSP(Γ) =AP #SAT. A formal definition of IM2","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq6","equation_number":null,"raw_text":"are interested in the Boolean case q = 2. A constraint language Γ with domain","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq7","equation_number":null,"raw_text":"{0, . . . , q −1} is a set of relations on {0, . . . , q −1}. For example, take q = 2.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq8","equation_number":null,"raw_text":"The relation R = {(0, 0, 1), (0, 1, 0), (1, 0, 0), (1, 1, 1)} is a 3-ary relation on the","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq9","equation_number":null,"raw_text":"variables V = {v1, . . . , vn} and a set of constraints. Each constraint has a scope,","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq10","equation_number":null,"raw_text":"by OR = {(0, 1), (1, 0), (1, 1)}, Implies = {(0, 0), (0, 1), (1, 1)}, and NAND =","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq11","equation_number":null,"raw_text":"{(0, 0), (0, 1), (1, 0)}. If Γ = {OR, Implies, NAND} then CSP(Γ) is the classical","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq12","equation_number":null,"raw_text":"important advantage. If P ̸= NP, then there are problems which are neither","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq13","equation_number":null,"raw_text":"Define the unary relations δ0 = {(0)} and δ1 = {(1)}. Recall the binary relation","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq14","equation_number":null,"raw_text":"Implies = {(0, 0), (0, 1), (1, 1)}.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq15","equation_number":null,"raw_text":"set of k-tuples or as a k-ary predicate. Thus the notations R(x1, . . . , xk) = 1 (or","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq16","equation_number":null,"raw_text":"just R(x1, . . . , xk)) and (x1, . . . , xk) ∈R are equivalent. For example, δ0(x) = x,","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq17","equation_number":null,"raw_text":"δ1(x) = x and Implies(x, y) = x ∨y.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq18","equation_number":null,"raw_text":"in IM2 then #CSP(Γ) =AP #BIS. Otherwise #CSP(Γ) =AP #SAT.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq19","equation_number":null,"raw_text":"Recall the relations OR = {(0, 1), (1, 0), (1, 1)} and NAND = {(0, 0), (0, 1),","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq20","equation_number":null,"raw_text":"We show that #IS ≤AP #CSP({NAND}). Let G = (V, E) be an instance","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq21","equation_number":null,"raw_text":"with σ(v) = 1 correspond to vertices in the independent set.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq22","equation_number":null,"raw_text":"v with σ(v) = 1 with vertices that are out of the independent set).","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq23","equation_number":null,"raw_text":"u ∈U with σ(u) = 1 is in the independent set and a variable v ∈V with","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq24","equation_number":null,"raw_text":"σ(v) = 0 is in the independent set.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq25","equation_number":null,"raw_text":"tj = 0 than with tj = 1. Then #CSP(Γ ∪{δ0}) ≤AP #CSP(Γ). Similarly, if","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq26","equation_number":null,"raw_text":"with tj = 1 than with tj = 0 then #CSP(Γ ∪{δ1}) ≤AP #CSP(Γ).","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq27","equation_number":null,"raw_text":"with tj = 0 and w′ < w tuples t with tj = 1.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq28","equation_number":null,"raw_text":"which one or more constraints δ1(y) occurs. Let n0 = |N0(I)|. Let m = ⌈(n +","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq29","equation_number":null,"raw_text":"#csp(I) = #csp(I′)","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq30","equation_number":null,"raw_text":"we could simply set δ = ε, since division by a constant preserves relative error.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq31","equation_number":null,"raw_text":"#csp(I) =","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq32","equation_number":null,"raw_text":"The situation here is that the true answer N = #csp(I) is obtained by","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq33","equation_number":null,"raw_text":"rounding the fraction Q = #csp(I′)","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq34","equation_number":null,"raw_text":"bQ ≤Qeδ (as it is required to do with probability at least 3/4). Set δ = ε/21,","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq35","equation_number":null,"raw_text":"implies d = a⊕b⊕c ∈R, where the ⊕operator is applied componentwise.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq36","equation_number":null,"raw_text":"From b = s0, c = s1,","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq37","equation_number":null,"raw_text":"d = a ⊕s0 ⊕s1 we have d ∈R. From b = s2, c = d we have a ⊕s2 ⊕d =","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq38","equation_number":null,"raw_text":"is exactly one satisfying assignment σ of I with σ(x1) = s1, . . . , σ(xk) = sk and","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq39","equation_number":null,"raw_text":"σ(x1) = s1, . . . , σ(xk) = sk. Note the following straightforward observation,","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq40","equation_number":null,"raw_text":"closed then Γ implements the relation R′ = {(0, 0), (1, 1), (1, 0)}.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq41","equation_number":null,"raw_text":"2#csp(I) = #csp(I′) since there is a one-to-two map from satisfying assign-","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq42","equation_number":null,"raw_text":"rest of the variables are assigned value 0, then s is mapped to s; z0 = 0 and","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq43","equation_number":null,"raw_text":"s; z0 = 1, where s is the tuple obtained from s by complementing the assign-","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq44","equation_number":null,"raw_text":"functions f satisfying f(0, . . . , 0) = 0 and f(1, . . . , 1) = 1. Given a set B of","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq45","equation_number":null,"raw_text":"Proof. We will use the fact (see [1]) that M2 = [{∨, ∧}] where x ∨y is the OR","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq46","equation_number":null,"raw_text":"The case f(x) = x (in which f has no connectives) cannot arise since the","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq47","equation_number":null,"raw_text":"identity function is a polymorphism of every relation. The cases f(x, y) = x∨y","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq48","equation_number":null,"raw_text":"and f(x, y) = x ∧y (in which f has one connective) immediately give the","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq49","equation_number":null,"raw_text":"For the inductive step, we assume either f(x1, . . . , xm) = f ′(x1, . . . , xm) ∨","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq50","equation_number":null,"raw_text":"f ′′(x1, . . . , xm) or f(x1, . . . , xm) = f ′(x1, . . . , xm)∧f ′′(x1, . . . , xm) where f ′ and","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq51","equation_number":null,"raw_text":"f(x1, . . . , xm) = f ′(x1, . . . , xm) ∨f ′′(x1, . . . , xm).","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq52","equation_number":null,"raw_text":"Proof. Apply Lemma 16 with Γ = {R1, R2}. Then either #CSP({R1, R2, δ0}) ≤AP","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq53","equation_number":null,"raw_text":"R2. We will show that {Implies, R2, δ0, δ1} implements one of OR and XOR =","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq54","equation_number":null,"raw_text":"et al. [7], define ri to be u if ti = t′","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq55","equation_number":null,"raw_text":"i = 0 or x if ti = 0, t′","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq56","equation_number":null,"raw_text":"i = 1 or y if ti =","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq57","equation_number":null,"raw_text":"i = 0, or v if ti = t′","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq58","equation_number":null,"raw_text":"i = 1. Let R′ be the relation implemented by R′(x, y) =","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq59","equation_number":null,"raw_text":"of R′ since t ̸= t ∧t′ and t′ ̸= t ∧t′. If t ∨t′ is in R2 then R′(x, y) implements","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq60","equation_number":null,"raw_text":"OR(x, y), so we are finished. Otherwise R′ = XOR (which we now assume).","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq61","equation_number":null,"raw_text":"The implementation is given by NAND(x, z) = Implies(x, y) ∧XOR(y, z).","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq62","equation_number":null,"raw_text":"is in IM2 then #CSP(Γ) =AP #BIS. Otherwise #CSP(Γ) =AP #SAT.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq63","equation_number":null,"raw_text":"not in R. Now consider the relation R′ implemented by R′(x, y) = R(r1, . . . , rk)","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq64","equation_number":null,"raw_text":"where ri = x if si = 1 and ri = y otherwise. In the first case, R′ is the relation","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq65","equation_number":null,"raw_text":"{(0, 0), (1, 1), (1, 0)}. In the second case, R′ = {(1, 0)} so R′ gives an implemen-","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq66","equation_number":null,"raw_text":"the trivial implementations δ0(x) = R(x, . . . , x) and δ1(x) = R(x, . . . , x).","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq67","equation_number":null,"raw_text":"be tuples in R such that s ⊕s′ is not in R. Let ri = w if si = s′","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq68","equation_number":null,"raw_text":"i = 0. Let","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq69","equation_number":null,"raw_text":"ri = x if si = 0, s′","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq70","equation_number":null,"raw_text":"i = 1. Let ri = y if si = 1, s′","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq71","equation_number":null,"raw_text":"i = 0. Let ri = z if si = s′","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq72","equation_number":null,"raw_text":"i = 1.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq73","equation_number":null,"raw_text":"Now we know that at least one of x and y occurs as an ri, since s ̸= s′. Let R′","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq74","equation_number":null,"raw_text":"s ̸= 0. Thus, the relation R′(x, z) is Implies. (Technically, this is a ternary","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq75","equation_number":null,"raw_text":"implement δ1. To see this, let s be a tuple in R. Let ri = x if si = 1 and let","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq76","equation_number":null,"raw_text":"ri = y otherwise. Then δ1(x) is implemented by R(r1, . . . , rk) ∧δ0(y). Now","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq77","equation_number":null,"raw_text":"are two tuples s′ and s′′ in R such that s ⊕s′ ⊕s′′ is not in R. Let ri = u if","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq78","equation_number":null,"raw_text":"si = s′","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq79","equation_number":null,"raw_text":"i = s′′","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq80","equation_number":null,"raw_text":"i = 0. Let ri = x if si = 0, s′","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq81","equation_number":null,"raw_text":"i = 0, s′′","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq82","equation_number":null,"raw_text":"i = 1. Let ri = y if si = 0, s′","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq83","equation_number":null,"raw_text":"i =","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq84","equation_number":null,"raw_text":"i = 0. Let ri = z if si = 0, s′","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq85","equation_number":null,"raw_text":"i = 1, s′′","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq86","equation_number":null,"raw_text":"i = 1. Let ri = v if si = s′","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq87","equation_number":null,"raw_text":"i = s′′","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq88","equation_number":null,"raw_text":"i = 1.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq89","equation_number":null,"raw_text":"t ∧t′ is not in R. Define ri to be u if ti = t′","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq90","equation_number":null,"raw_text":"i = 0 or x if ti = 0, t′","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq91","equation_number":null,"raw_text":"i = 1 or y","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq92","equation_number":null,"raw_text":"if ti = 1, t′","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq93","equation_number":null,"raw_text":"i = 0, or v if ti = t′","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq94","equation_number":null,"raw_text":"i = 1. Let R′ be the relation implemented by","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq95","equation_number":null,"raw_text":"R′(x, y) = R(r1, . . . , rk)∧δ0(u)∧δ1(v). If t∨t′ is in R then R′(x, y) implements","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq96","equation_number":null,"raw_text":"Otherwise R′ = {(0, 1), (1, 0)} (which we now","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq97","equation_number":null,"raw_text":"By writing x′ = x, y′ = y and z′ = z, we can think of R′′ as a function of","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"}],"equation_refs":[]},"symbol_table":[],"references":{"in_text_markers":[],"bibliography":[]},"claims":[],"flow_graph":{"nodes":[],"edges":[]},"quality":{"text_char_count":43037,"parse_confidence":0.5,"equation_parse_rate_proxy":1.0,"citation_resolution_rate_proxy":0.0,"structure_coverage_proxy":0.0,"asset_coverage_proxy":0.0,"accepted_for_training":true}} |