cs-lora-training-data / structured /0704.3683.structured.json
Shivatandav64's picture
Upload folder using huggingface_hub
a3b809c verified
{"paper_meta":{"paper_id":"arxiv:0704.3683","title":"0704.3683","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:0704.3683v2 [cs.CC] 19 Jun 2008\nThe Complexity of Weighted 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\n28 April 2008\nAbstract\nThis paper gives a dichotomy theorem for the complexity of computing the partition\nfunction of an instance of a weighted Boolean constraint satisfaction problem. The prob-\nlem is parameterised by a finite set F of non-negative functions that may be used to\nassign weights to the configurations (feasible solutions) of a problem instance. Classical\nconstraint satisfaction problems correspond to the special case of 0,1-valued functions.\nWe show that computing the partition function, i.e. the sum of the weights of all config-\nurations, is FP#P-complete unless either (1) every function in F is of “product type”, or\n(2) every function in F is “pure affine”. In the remaining cases, computing the partition\nfunction is in P.\n1\nIntroduction\nThis paper gives a dichotomy theorem for the complexity of the partition function of weighted\nBoolean constraint satisfaction problems. Such problems are parameterised by a set F of\nnon-negative functions that may be used to assign weights to configurations (solutions) of\nthe instance. These functions take the place of the allowed constraint relations in classical\nconstraint satisfaction problems (CSPs). Indeed, the classical setting may be recovered by\nrestricting F to functions with range {0, 1}. The key problem associated with an instance\nof a weighted CSP is to compute its partition function, i.e., the sum of weights of all its\nconfigurations. Computing the partition function of a weighted CSP may be viewed a gen-\neralisation of counting the number of satisfying solutions of a classical CSP. Many partition\nfunctions from statistical physics may be expressed as weighted CSPs.\nFor example, the\nPotts model [23] is naturally expressible as a weighted CSP, whereas in the classical frame-\nwork only the “hard core” versions may be directly expressed. (The hard-core version of the\nantiferromagnetic Potts model corresponds to graph colouring and the hard-core version of\nthe ferromagnetic Potts model is trivial — acceptable configurations colour the entire graph\nwith a single colour.) A corresponding weighted version of the decision CSP was investigated\nby Cohen, Cooper, Jeavons and Krokhin [3]. This results in optimisation problems.\n1\n\nWe use #CSP(F) to denote the problem of computing the partition function of weighted\nCSP instances that can be expressed using only functions from F. We show in Theorem 4\nbelow that if every function f ∈F is “of product type” then computing the partition function\nZ(I) of an instance I can be done in polynomial time. Formal definitions are given later,\nbut the condition of being “of product type” is easily checked — it essentially means that\nthe partition function factors. We show further in Theorem 4 that if every function f ∈F is\n“pure affine” then the partition function of Z(I) can be computed in polynomial time. Once\nagain, there is an algorithm to check whether F is pure affine. For each other set F, we show\nin Theorem 4 that computing the partition function of a #CSP(F) instance is complete for\nthe class FP#P. The existence of algorithms for testing the properties of being purely affine\nor of product type means that the dichotomy is effectively decidable.\n1.1\nConstraint satisfaction\nConstraint Satisfaction, which originated in Artificial Intelligence, provides a general frame-\nwork for modelling decision problems, and has many practical applications. (See, for exam-\nple [18].) Decisions are modelled by variables, which are subject to constraints, modelling\nlogical and resource restrictions. The paradigm is sufficiently broad that many interesting\nproblems can be modelled, from satisfiability problems to scheduling problems and graph-\ntheory problems. Understanding the complexity of constraint satisfaction problems has be-\ncome a major and active area within computational complexity [7, 14].\nA Constraint Satisfaction Problem (CSP) typically has a finite domain, which we will\ndenote by [q] = {0, 1 . . . , q −1} for a positive integer q.1\nA constraint language Γ with\ndomain [q] is a set of relations on [q]. For example, take q = 2. The relation R = {(0, 0, 1),\n(0, 1, 0), (1, 0, 0), (1, 1, 1)} is a 3-ary relation on the domain {0, 1}, with four tuples.\nOnce we have fixed a constraint language Γ, an instance of the CSP is a set of variables\nV = {v1, . . . , vn} and a set of constraints. Each constraint has a scope, which is a tuple of\nvariables (for example, (v4, v5, v1)) and a relation from Γ of the same arity, which constrains\nthe variables in the scope. A configuration σ is a function from V to [q]. The configuration σ\nis satisfying if the scope of every constraint is mapped to a tuple that is in the corresponding\nrelation. In our example above, a configuration σ satisfies the constraint with scope (v4, v5, v1)\nand relation R if and only if it maps an odd number of the variables in {v1, v4, v5} to the\nvalue 1. Given an instance of a CSP with constraint language Γ, the decision problem CSP(Γ)\nasks us to determine whether any configuration is satisfying. The counting problem #CSP(Γ)\nasks us to determine the number of (distinct) satisfying configurations.\nVarying the constraint language Γ defines the classes CSP and #CSP of decision and\ncounting problems.\nThese contain problems of different computational complexities.\nFor\nexample, if Γ = {R1, R2, R3} where R1, R2 and R3 are the three binary relations defined\nby R1 = {(0, 1), (1, 0), (1, 1)}, R2 = {(0, 0), (0, 1), (1, 1)} and R3 = {(0, 0), (0, 1), (1, 0)}, then\nCSP(Γ) is the classical 2-Satisfiability problem, which is in P.\nOn the other hand, there\nis a similar constraint language Γ′ with four relations of arity 3 such that 3-Satisfiability\n(which is NP-complete) can be represented in CSP(Γ′). It may happen that the counting\nproblem is harder than the decision problem. If Γ is the constraint language of 2-Satisfiability\nabove, then #CSP(Γ) contains the problem of counting independent sets in graph, and is\n#P-complete [22], even if restricted to 3-regular graphs [12].\n1 Usually [q] is defined to be {1, 2, . . . , q}, but it is more convenient here to start the enumeration of domain\nelements at 0 rather than 1.\n2\n\nAny decision problem CSP(Γ) is in NP, but not every problem in NP can be represented\nas a CSP. For example, the question “Is G Hamiltonian?” cannot naturally be expressed\nas a CSP, because the property of being Hamiltonian cannot be captured by relations of\nbounded size. This limitation of the class CSP has an important advantage. If P ̸= NP,\nthen there are problems which are neither in P nor NP-complete [16]. But, for well-behaved\nsmaller classes of decision problems, the situation can be simpler. We may have a dichotomy\ntheorem, partitioning all problems in the class into those which are in P and those which\nare NP-complete. There are no “leftover” problems of intermediate complexity. It has been\nconjectured that there is a dichotomy theorem for CSP. The conjecture is that CSP(Γ) is\nin P for some constraint languages Γ, and CSP(Γ) is NP-complete for all other constraint\nlanguages Γ. This conjecture appeared in a seminal paper of Feder and Vardi [10], but has\nnot yet been proved.\nA similar dichotomy, between FP and #P-complete, is conjectured for #CSP [2]. The\ncomplexity classes FP and #P are the analogues of P and NP for counting problems. FP\nis simply the class of functions computable in deterministic polynomial time.\n#P is the\nclass of integer functions that can be expressed as the number of accepting computations of\na polynomial-time non-deterministic Turing machine. Completeness in #P is defined with\nrespect to polynomial-time Turing reducibility [17, Chap. 18]. Bulatov and Dalmau [2] have\nshown in one direction that, if #CSP(Γ) is solvable in polynomial time, then the constraints\nin Γ must have certain algebraic properties (assuming P ̸= #P). In particular, they must\nhave a so-called Mal’tsev polymorphism. The converse is known to be false, though it remains\npossible that the dichotomy (if it exists) does have an algebraic characterisation.\nThe conjectured dichotomies for CSP and #CSP are major open problems for computa-\ntional complexity theory. There have been many important results for subclasses of CSP and\n#CSP. We mention the most relevant to our paper here. The first decision dichotomy was\nthat of Schaefer [19], for the Boolean domain {0, 1}. Schaefer’s result is as follows.\nTheorem 1 (Schaefer [19]). Let Γ be a constraint language with domain {0, 1}. The problem\nCSP(Γ) is in P if Γ satisfies one of the conditions below. Otherwise, CSP(Γ) is NP-complete.\n(1) Γ is 0-valid or 1-valid.\n(2) Γ is weakly positive or weakly negative.\n(3) Γ is affine.\n(4) Γ is bijunctive.\nWe will not give detailed definitions of the conditions in Theorem 1, but the interested\nreader is referred to the paper [19] or to Theorem 6.2 of the textbook [7]. An interesting feature\nis that the conditions in [7, Theorem 6.2] are all checkable. That is, there is an algorithm\nto determine whether CSP(Γ) is in P or NP-complete, given a constraint language Γ with\ndomain {0, 1}. Creignou and Hermann [6] adapted Schaefer’s decision dichotomy to obtain a\ncounting dichotomy for the Boolean domain. Their result is as follows.\nTheorem 2 (Creignou and Hermann [6]). Let Γ be a constraint language with domain {0, 1}.\nThe problem #CSP(Γ) is in FP if Γ is affine. Otherwise, #CSP(Γ) is #P-complete.\nA constraint language Γ with domain {0, 1} is affine if every relation R ∈Γ is affine. A\nrelation R is affine if the set of tuples x ∈R is the set of solutions to a system of linear\nequations over GF(2). These equations are of the form v1 ⊕· · · ⊕vn = 0 and v1 ⊕· · · ⊕vn = 1\nwhere ⊕is the exclusive or operator. It is well known (see, for example, Lemma 4.10 of [7])\n3\n\nthat a relation R is affine iffa, b, c ∈R implies d = a ⊕b ⊕c ∈R.\n(We will use this\ncharacterisation below.) There is an algorithm for determining whether a Boolean constraint\nlanguage Γ is affine, so there is an algorithm for determining whether #CSP(Γ) is in FP or\n#P-complete.\n1.2\nWeighted #CSP\nThe weighted framework of [4] extends naturally to Constraint Satisfaction Problems. Fix\nthe domain [q].\nInstead of constraining a length-k scope with an arity-k relation on [q],\nwe give a weight to the configuration on this scope by applying a function f from [q]k to\nthe non-negative rationals.\nLet Fq = {f : [q]k →Q+ | k ∈N} be the set of all such\nfunctions (of all arities).2 Given a function f ∈Fq of arity k, the underlying relation of f\nis given by Rf = {x ∈[q]k | f(x) ̸= 0}. It is often helpful to think of Rf as a table, with\nk columns corresponding to the positions of a k-tuple.\nEach row corresponds to a tuple\nx = (x1, . . . , xk) ∈Rf. The entry in row x and column j is xj, which is a value in [q].\nA weighted #CSP problem is parameterised by a finite subset F of Fq, and will be\ndenoted by #CSP(F). An instance I of #CSP(F) consists of a set V of variables and a\nset C of constraints. Each constraint C ∈C consists of a function fC ∈F (say of arity kC)\nand a scope, which is a sequence sC = (vC,1, . . . , vC,kC) of variables from V . The variables\nvC,1, . . . , vC,kC need not be distinct. As in the unweighted case, a configuration σ for the\ninstance I is a function from V to [q]. The weight of the configuration σ is given by\nw(σ) =\nY\nC∈C\nfC(σ(vC,1), . . . , σ(vC,kC)).\nFinally, the partition function Z(I) is given, for instance I, by\nZ(I) =\nX\nσ:V →[q]\nw(σ).\n(1)\nIn the computational problem #CSP(F), the goal is to compute Z(I), given an instance I.\nNote that an (unweighted) CSP counting problem #CSP(Γ) can be represented naturally\nas a weighted CSP counting problem.\nFor each relation R ∈Γ, let f R be the indicator\nfunction for membership in R.\nThat is, if x ∈R we set f R(x) = 1.\nOtherwise we set\nf R(x) = 0. Let F = {f R | R ∈Γ}. Then for any instance I of #CSP(Γ), the number of\nsatisfying configurations for I is given by the (weighted) partition function Z(I) from (1).\nThis framework has been employed previously in connection with graph homomorphisms [1].\nSuppose H = (Hij) is any symmetric square matrix H of rational numbers. We view H as\nbeing an edge-weighting of an undirected graph H, where a zero weight in H means that\nthe corresponding edge is absent from H. Given a (simple) graph G = (V, E) we consider\ncomputing the partition function\nZH(G) =\nX\nσ:V →[q]\nw(σ),\nwhere w(σ) =\nY\n{u,v}∈E\nHσ(u)σ(v).\nWithin our framework above, we view H as the binary function h : [q]2 →R, and the problem\nis then computing the partition function of #CSP({h}).\n2We assume 0 ∈N, so we allow non-negative constants.\n4\n\nBulatov and Grohe [4] call H connected if H is connected and bipartite if H is bipartite.\nThey give the following dichotomy theorem for non-negative H.3\nTheorem 3 (Bulatov and Grohe [4]). Let H be a symmetric matrix with non-negative rational\nentries.\n(1) If H is connected and not bipartite, then computing ZH is in FP if the rank of H is at\nmost 1; otherwise computing ZH is #P-hard.\n(2) If H is connected and bipartite, then computing ZH is in FP if the rank of H is at most 2;\notherwise computing ZH is #P-hard.\n(3) If H is not connected, then computing ZH is in FP if each of its connected components\nsatisfies the corresponding conditions stated in (1) or (2); otherwise computing ZH is\n#P-hard.\nMany partition functions arising in statistical physics may be viewed as weighted #CSP\nproblems. An example is the q-state Potts model (which is, in fact, a weighted graph ho-\nmomorphism problem). In general, weighted #CSP is very closely related to the problem of\ncomputing the partition function of a Gibbs measure in the framework of Dobrushin, Lanford\nand Ruelle (see [1]). See also the framework of Scott and Sorkin [20].\n1.3\nSome Notation\nWe will call the class of (rational) weighted #CSP problems weighted #CSP. The sub-class\nhaving domain size q = 2 will be called weighted Boolean #CSP, and will be the main focus\nof this paper. We will give a dichotomy theorem for weighted Boolean #CSP.\nSince weights can be arbitrary non-negative rational numbers, the solution to these prob-\nlems is not an integer in general. Therefore #CSP(F) is not necessarily in the class #P.\nHowever, Goldberg and Jerrum [11] have observed that Z(I) = ̃Z(I)/K(I), where ̃Z is a\nfunction in #P and K(I) is a positive integer computable in FP. This follows because, for all\nf ∈F, we can ensure that f(·) = ̃f(·)/K(I), where ̃f(·) ∈N, by“clearing denominators”. The\ndenominator K(I) can obviously be computed in polynomial time, and it is straightforward\nto show that computing ̃Z(I) is in #P, so the characterisation of [11] follows. The resulting\ncomplexity class, comprising functions which are a function in #P divided by a function in\nFP, is named #PQ in [11], where it is used in the context of approximate counting. Clearly\nwe have\nweighted #CSP ⊆#PQ ⊆FP#P.\nOn the other hand, if Z(I) ∈weighted #CSP is #P-hard, then, using an oracle for computing\nZ(I), we can construct a #P oracle ̃Z(I) as outlined above.\n(Note that Z(I) /∈#P in\ngeneral.) Using this, we can compute any function in FP#P with a polynomial time-bounded\noracle Turing machine. Thus any #P-hard function in weighted #CSP is complete for FP#P.\nWe will use this observation to state our main result in terms of completeness for the class\nFP#P.\nWe make the following definition, which relates to the discussion above. We will say that\nF ⊆Fq simulates f ∈Fq if, for each instance I of #CSP(F ∪{f}), there is a polynomial time\ncomputable instance I′ of #CSP(F), such that Z(I) = φ(I)Z(I′) for some φ(I) ∈Q which is\nFP-computable. This generalises the notion of parsimonious reduction [17] among problems in\n3This is not quite the original statement of the theorem. We have chosen here to restrict all inputs to be\nrational, in order to avoid issues of how to represent, and compute with, arbitrary real numbers.\n5\n\n#P. We will use ≤T to denote the relation “is polynomial-time Turing-reducible to” between\ncomputational problems. Clearly, if F simulates f, we have #CSP(F ∪{f}) ≤T #CSP(F).\nNote also that, if ̃f = Kf, for some constant K > 0, then {f} simulates ̃f. Thus there is no\nneed to distinguish between “proportional” functions.\nWe use the following terminology for certain functions. Let χ= be the binary equality\nfunction defined on [q] as follows. For any element c ∈[q], χ=(c, c) = 1 and for any pair (c, d)\nof distinct elements of [q], χ=(c, d) = 0. Let χ̸= be the binary disequality function given by\nχ̸=(c, d) = 1 −χ=(c, d) for all c, d ∈[q].4 We say that a function f is of product type if f can\nbe expressed as a product of unary functions and binary functions of the form χ= and χ̸=.\nWe focus attention in this paper on the Boolean case, q = 2. In this case, we say that a\nfunction f ∈F2 has affine support if its underlying relation Rf, defined earlier, is affine. We\nsay that f is pure affine if it has affine support and range {0, w} for some w > 0. Thus a\nfunction is pure affine if and only if it is a positive real multiple of some (0,1-valued) function\nwhich is affine over GF(2).\n1.4\nOur Result\nOur main result is the following.\nTheorem 4. Suppose F ⊆F2 = {f : {0, 1}k →Q+ | k ∈N}. If every function in F is of\nproduct type then #CSP(F) is in FP. If every function in F is pure affine then #CSP(F) is\nin FP. Otherwise, #CSP(F) is FP#P-complete.\nProof. Suppose first that F is of product type. In this case the partition function Z(I) of\nan instance I with variable set V is easy to evaluate because it can be factored into easy-\nto-evaluate pieces: Partition the variables in V into equivalence classes according to whether\nor not they are related by an equality or disequality function. (The equivalence relation on\nvariables here is “depends linearly on”.) An equivalence class consists of two (possibly empty)\nsets of variables U1 and U2. All of the variables in U1 must be assigned the same value by a\nconfiguration σ of nonzero weight, and all variables in U2 must be assigned the other value.\nVariables in U1∪U2 are not related by equality or disequality to variables in V \\(U1∪U2). The\nequivalence class contributes one weight, say α, to the partition function if variables in U1\nare given value “0” by σ and it contributes another weight, say β, to the partition function\nif variables in U1 are given value “1” by σ. Thus, Z(I) = (α + β)Z(I′), where I′ is the\ninstance formed from I by removing this equivalence class. Therefore, suppose we choose any\nequivalence class and remove its variables. Since F contains only unary, equality or binary\ndisequality constraints, we can also remove all functions involving variables in U1 ∪U2 to give\nF′. Then I′ is of product type with fewer variables, so we may compute Z(I′) recursively.\nSuppose second that F if pure affine. Then Z(I) = Q\nf∈F wkf\nf Z(I′), where {0, wf} is the\nrange of f, kf is the number of constraints involving f in I, and I′ is the instance obtained\nfrom I by replacing every function f by its underlying relation Rf (viewed as a function with\nrange {0, 1}). Z(I′) is easy to evaluate, because this is just counting solutions to a linear\nsystem over GF(2), as Creignou and Hermann have observed [6].\nFinally, the #P-hardness in Theorem 4 follows from Lemma 5 below.\nLemma 5. If f ∈F2 is not of product type and g ∈F2 is not pure affine then #CSP({f, g})\nis #P-hard.\n4A more general disequality function is defined in the Appendix.\n6\n\nNote that the functions f and g in Lemma 5 may be one and the same function. So\n#CSP({f}) is #P-hard when f is not of product type nor pure affine. The rest of this article\ngives the proof of Lemma 5.\n2\nUseful tools for proving hardness of #CSP\n2.1\nNotation\nFor any sequence u1, . . . , uk of variables of I and any sequence c1, . . . , ck of elements of the\ndomain [q], we will let Z(I | σ(u1) = c1, . . . , σ(uk) = ck) denote the contribution to Z(I) from\nassignments σ with σ(u1) = c1, · · · , σ(uk) = ck.\n2.2\nProjection\nThe first tool that we study is projection, which is referred to as “integrating out” in the\nstatistical physics literature.\nLet f be a function of arity k, and let J = {j1, . . . , jr} be a size-r subset of {1, . . . , k},\nwhere j1 < · · · < jr.5 We say that a k-tuple x′ ∈[q]k extends an r-tuple x ∈[q]r on J (written\nx′ ⊒J x) if x′ agrees with x on indices in J; that is to say, x′\nji = xi for all 1 ≤i ≤r. The\nprojection g of f onto J is defined as follows. For every x ∈[q]r, g(x) = P\nx′⊒Jx f(x′).\nThe following lemma may be viewed as a weighted version of Proposition 2 of [2], where\nit is proved for the unweighted case. It is expressed somewhat differently in [2], in terms of\ncounting the number of solutions to an existential formula.\nLemma 6. Suppose F ⊆Fq. Let g be a projection of a function f ∈F onto a subset of its\nindices. Then #CSP(F ∪{g}) ≤T #CSP(F).\nProof. Let k be the arity of f and let g be the projection of f onto the subset J of its indices.\nLet I be an instance of #CSP(F ∪{g}). We will construct an instance I′ of #CSP(F) such\nthat Z(I) = Z(I′). The instance I′ is identical to I except that every constraint C of I\ninvolving g is replaced with a new constraint C′ of I′ involving f. The corresponding scope\n(vC′,1, . . . , vC′,k) is constructed as follows. If jlis the l’th element of J, then v′\nC′,jl= vC,l. The\nother variables, vC′,j (j /∈J), are distinct new variables. We have shown that F simulates g\nwith φ(I) = 1.\n2.3\nPinning\nFor c ∈[q], δc denotes the unary function with δc(c) = 1 and δc(d) = 0 for d ̸= c. The\nfollowing lemma, which allows “pinning” CSP variables to specific values in hardness proofs,\ngeneralises Theorem 8 of [2], which does the unweighted case. Again [2] employs different\nterminology, and its theorem is a statement about the full idempotent reduct of a finite\nalgebra. The idea of pinning was used previously by Bulatov and Grohe of [4] in the context\nof counting weighted graph homomorphisms (see Lemma 32 of [4]). A similar idea was used\nby Dyer and Greenhill in the context of counting unweighted graph homomorphisms — in\nthat context, Theorem 4.1 of [8] allows pinning all variables to a particular component of the\ntarget graph H.\n5It is not necessary to choose this particular ordering for J, but it is convenient to do so.\n7\n\nLemma 7. For every F ⊆Fq, #CSP(F ∪S\nc∈[q] δc) ≤T #CSP(F).\nThe proof of Lemma 7 is deferred to the appendix. Since we only use the case q = 2 in\nthis paper, we provide the (simpler) proof for the Boolean case here.\nLemma 8. For every F ⊆F2, #CSP(F ∪{δ0, δ1}) ≤T #CSP(F).\nProof. For x ∈[2]k, let x be the k-tuple whose i’th component, xi, is xi ⊕1, for all i. Say\nthat F is symmetric if it is the case that for every arity-k function f ∈F and every x ∈[2]k,\nf(x) = f(x).\nGiven an instance I of #CSP(F ∪{δ0, δ1}) with variable set V we consider two instances\nI′ and I′′ of #CSP(F). Let V0 be the set of variables v of I to which the constraint δ0(v) is\napplied. Let V1 be the set of variables v of I to which the constraint δ1(v) is applied. We\ncan assume without loss of generality that V0 and V1 do not intersect. (Otherwise, Z(I) = 0\nand we can determine this without using an oracle for #CSP(F).) Let V2 = V \\ (V0 ∪V1).\nThe instance I′ has variables V2 ∪{t0, t1} where t0 and t1 are distinct new variables that are\nnot in V . Every constraint C of I involving a function f ∈F corresponds to a constraint C′\nof I′. C′ is the same as C except that variables in V0 are replaced with t0 and variables\nin V1 are replaced with t1. Similarly, the instance I′′ has variables V2 ∪{t} where t is a new\nvariable that is not in V . Every constraint C of I involving a function f ∈F corresponds to\na constraint C′′ of I′′. The constraint C′′ is the same as C except that variables in V0 ∪V1\nare replaced with t.\nCase 1. F is symmetric:\nBy construction,\nZ(I′) −Z(I′′) = Z(I′ | σ(t0) = 0, σ(t1) = 1) + Z(I′ | σ(t0) = 1, σ(t1) = 0).\nBy symmetry, the summands are the same, so\nZ(I′) −Z(I′′) = 2Z(I′ | σ(t0) = 0, σ(t1) = 1) = 2Z(I).\nCase 2. F is not symmetric:\nLet f be an arity-k function in F and let x ∈[2]k so that\nf(x) > f(x) ≥0. Let s = (tx1, . . . , txk) and let I′\nx be the instance derived from I′ by adding a\nnew constraint with function f and scope s. Similarly, let I′′\nx be the instance derived from I′′\nby adding a new constraint with function f and scope (t, . . . , t). Now\nZ(I′\nx) = Z(I′ | σ(t0) = 0, σ(t1) = 1)f(x) + Z(I′ | σ(t0) = 1, σ(t1) = 0)f(x)\n+ Z(I′ | σ(t0) = 0, σ(t1) = 0)f(0, . . . , 0) + Z(I′ | σ(t0) = 1, σ(t1) = 1)f(1, . . . , 1)\n= Z(I′ | σ(t0) = 0, σ(t1) = 1)f(x) + Z(I′ | σ(t0) = 1, σ(t1) = 0)f(x) + Z(I′′\nx).\nThus we have two independent equations,\nZ(I′\nx) −Z(I′′\nx) = Z(I′ | σ(t0) = 0, σ(t1) = 1)f(x) + Z(I′ | σ(t0) = 1, σ(t1) = 0)f(x),\nZ(I′) −Z(I′′) = Z(I′ | σ(t0) = 0, σ(t1) = 1)\n+ Z(I′ | σ(t0) = 1, σ(t1) = 0)\n,\nin the unknowns Z(I′ | σ(t0) = 0, σ(t1) = 1) and Z(I′ | σ(t0) = 1, σ(t1) = 0). Solving these,\nwe obtain the value of Z(I′ | σ(t0) = 0, σ(t1) = 1) = Z(I).\n8\n\n2.4\n#P-hard problems\nTo prove Lemma 5, we will give reductions from some known #P-hard problems. The first of\nthese is the problem of counting homomorphisms from simple graphs to 2-vertex multigraphs.\nWe use the following special case of Bulatov and Grohe’s Theorem 3.\nCorollary 9 (Bulatov and Grohe [4]). Let H be a symmetric 2 × 2 matrix with non-negative\nreal entries. If H has rank 2 and at most one entry of H is 0 then Eval(H) is #P-hard.\nWe will also use the problem of computing the weight enumerator of a linear code. Given a\ngenerating matrix A ∈{0, 1}r×C of rank r, a code word c is any vector in the linear subspace Υ\ngenerated by the rows of A over GF(2). For any real number λ, the weight enumerator of the\ncode is given by WA(λ) = P\nc∈Υ λ∥c∥, where ∥c∥is the number of 1’s in c. The problem of\ncomputing the weight enumerator of a linear code is in FP for λ ∈{−1, 0, 1}, and is known to\nbe #P-hard for every other fixed λ ∈Q (see [23]). We could not find a proof, so we provide\none here. We restrict attention to positive λ, since that is adequate for our purposes.\nLemma 10. Computing the Weight Enumerator of a Linear Code is #P-hard for any fixed\npositive rational number λ ̸= 1.\nProof. We will prove hardness by reduction from a problem Eval(H), for some appropriate H,\nusing Corollary 9. Let the input to Eval(H) be a connected graph G = (V, E) with V =\n{v1, . . . , vn} and E = {e1, . . . , em}. Let B be the n × m incidence matrix of G, with bij = 1\nif vi ∈ej and bij = 0 otherwise. Let A be the (n −1) × m matrix which is B with the row\nfor vn deleted. A will be the generating matrix of the Weight Enumerator instance, with\nr = n −1 and C = m. It has rank (n −1) since G contains a spanning tree. A code word\nc has cj = L\ni∈U bij, where U ⊆V \\ {vn}. Thus cj = 1 if and only if ej has exactly one\nendpoint in U, and the weight of c is λk, where k is the number of edges in the cut U, V \\ U.\nThus WA(λ) = 1\n2ZH(G), where H is the symmetric weight matrix with H11 = H22 = 1 and\nH12 = H21 = λ. The 1\n2 arises because we fixed which side of the cut contains vn. Now H\nhas rank 2 unless λ = 1, so this problem is #P-hard by Corollary 9. Note, by the way, that\nZH(G) is the partition function of the Ising model in statistical physics [5].\n3\nThe Proof of Lemma 5\nThroughout this section, we assume q = 2. The following Lemma is a generalisation of a result\nof Creignou and Hermann [6], which deals with the case in which f is a relation (or, in our\nsetting, a function with range {0, 1}). The inductive technique used in the proof of Lemma 11\n(combined with the follow-up in Lemma 12) is good for showing that #CSP(F) is #P-hard\nwhen F contains a single function. A very different situation arises when #CSP({f}) and\n#CSP({g}) are in FP but #CSP({f, g}) is #P-hard due to interactions between f and g —\nwe deal with that problem later.\nLemma 11. Suppose that f ∈F2 does not have affine support. Then #CSP({f}) is #P-hard.\nProof. Let k be the arity of f, and let us denote the ith component of k-tuple a ∈Rf by ai.\nThe proof is by induction on k. The lemma is trivially true for k = 1, since all functions of\narity 1 have affine support.\n9\n\nFor k = 2, we note that since Rf is not affine, it is of the form Rf = {(α, β), ( ̄α, β), ( ̄α, ̄β)}\nfor some α ∈{0, 1} and β ∈{0, 1}. We can show that #CSP({f}) is #P-hard by reduction\nfrom Eval(H) using\nH =\n f(0, 0)\nf(0, 1)\nf(1, 0)\nf(1, 1)\n \n,\nwhich has rank 2 and exactly one entry that is 0. Given an instance G = (V, E) of Eval(H)\nwe construct an instance I of #CSP({f}) as follows. The variables of I are the vertices of G.\nFor each edge e = (u, v) of G, add a constraint with function f and variable sequence u, v.\nCorollary 9 now tells us that Eval(H) is #P-hard, so #CSP({f}) is #P-hard.\nSuppose k > 2.\nWe start with some general arguments and notation.\nFor any i ∈\n{1, . . . , k} and any α ∈{0, 1} let f i=α be the function of arity k −1 derived from f by pinning\nthe i’th position to α. That is, f i=α(x1, . . . , xk−1) = f(x1, . . . , xi−1, α, xi+1, . . . , xk). Also,\nlet f i=∗be the projection of f onto all positions apart from position i (see Section 2.2).\nNote that #CSP({f i=α}) ≤T #CSP({f, δ0, δ1}), since f i=α can obviously be simulated by\n{f, δ0, δ1}.\nFurthermore, by Lemma 8, #CSP({f, δ0, δ1}) ≤T #CSP({f}).\nThus, we can\nassume that f i=α has affine support — otherwise, we are finished by induction. Similarly, by\nLemma 6, #CSP(\n \nf i=∗ \n) ≤T #CSP({f}). Thus we can assume that f i=∗has affine support\n— otherwise, we are finished by induction.\nNow, recall that Rf is not affine. Consider any a, b, c ∈Rf such that d = a ⊕b ⊕c /∈Rf.\nWe have 4 cases.\nCase 1:\nThere are indices 1 ≤i < j ≤k such that (ai, bi, ci) = (aj, bj, cj):\nWithout loss of generality, suppose i = 1 and j = 2. Define the function f ′ of arity (k −1) by\nf ′(r2, . . . , rk) = f(r2, r2, . . . , rk). Note that Rf′ is not affine since the condition a⊕b⊕c /∈Rf is\ninherited by Rf′. So, by induction, #CSP({f ′}) is #P-hard. Now note that #CSP({f ′}) ≤T\n#CSP({f}). To see this, note that any instance I1 of #CSP({f ′}) can be turned into an\ninstance I of #CSP({f}) by repeating the first variable in the sequence of variables for each\nconstraint.\nCase 2: There is an index 1 ≤i ≤k such that ai = bi = ci: Since d is not in Rf and\ndi = ai, we find that f i=ai does not have affine support, contrary to earlier assumptions.\nHaving finished Cases 1 and 2, we may assume without loss of generality that we are in\nCase 3 or Case 4 below, where {α, β} ∈{0, 1}, ̄α = 1 −α, ̄β = 1 −β and a′, b′, c′ ∈{0, 1}k−2.\nCase 3:\na = ( ̄α, ̄β, a′), b = ( ̄α, β, b′), c = (α, ̄β, c′): Since Rf1=∗is affine and a, b\nand c are in Rf, we must have either d = (α, β, d′) ∈Rf or e = ( ̄α, β, d′) ∈Rf, where\nd′ = a′ ⊕b′ ⊕c′. In the first case, we are done (we have contradicted the assumption that\nd ̸∈Rf), so assume that e ∈Rf but d ̸∈Rf.\nSimilarly, since Rf2=∗is affine, we may\nassume that g = (α, ̄β, d′) ∈Rf. Since Rf1= ̄α is affine and a, b and e are in Rf, we find\nthat h = a ⊕b ⊕e = ( ̄α, ̄β, c′) ∈Rf. Since Rf2= ̄β is affine and a, c and g are in Rf, we\nfind that i = ( ̄α, ̄β, b′) ∈Rf. Also, since Rf2= ̄β is affine and a, h and i are in Rf, we find\nthat j = ( ̄α, ̄β, d′) ∈Rf. Let f ′(r1, r2) = f(r1, r2, d3, . . . , dk). Since e, g and j are in Rf\nbut d is not, we have ( ̄α, β), (α, ̄β), ( ̄α, ̄β) ∈Rf′, but (α, β) /∈Rf′. Thus, f ′ does not have\naffine support and #CSP({f ′}) is #P-hard by induction. Also, #CSP({f ′}) ≤T #CSP({f})\nby Lemma 8.\nCase 4: a = ( ̄α, α, a′), b = ( ̄α, α, b′), c = (α, ̄α, c′): Since Rf1=∗is affine and a, b and c\nare in Rf but d is not, we have e = ( ̄α, ̄α, d′) ∈Rf. Similarly, since Rf2=∗is affine and a, b\nand c are in Rf but d is not, we have g = (α, α, d′) ∈Rf. Now since Rf1= ̄α is affine and a, b\nand e are in Rf, we have h = ( ̄α, ̄α, c′) ∈Rf. Also, since Rf2=α is affine and a, b and g are in\n10\n\nRf, we have i = (α, α, c′) ∈Rf.\nLet f ′(r1, r2) = f(r1, r2, c3, . . . , ck). If j = ( ̄α, α, c′) ̸∈Rf then f ′ does not have affine\nsupport (since c, h and i are in Rf) so we finish by induction as in Case 3. Suppose j ∈Rf.\nSince Rf1= ̄α is affine and a, b and j are in Rf, we have l= ( ̄α, α, d′) ∈Rf. Let f ′′(r1, r2) =\nf(r1, r2, d3, . . . , dk). Then f ′′ does not have affine support (since e, g and lare in Rf but d\nis not) so we finish by induction as in Case 3.\nLemma 11 showed that #CSP({f}) is #P-hard when f does not have affine support. The\nfollowing lemma gives another (rather technical, but useful) condition which implies that\n#CSP({f}) is #P-hard. We start with some notation. Let f be an arity-k function. For a\nvalue b ∈{0, 1}, an index i ∈{1, . . . , k}, and a tuple y ∈{0, 1}k−1, let yi=b denote the tuple\nx ∈{0, 1}k formed by setting xi = b and xj = yj (j ∈{1, . . . , k} \\ {i}).\nWe say that index i of f is useful if there is a tuple y such that f(yi=0) > 0 and f(yi=1) > 0.\nWe say that f is product-like if, for every useful index i, there is a rational number λi such\nthat, for all y ∈{0, 1}k−1,\nf(yi=0) = λif(yi=1).\n(2)\nIf every position i of f is useful then being product-like is the same as being of product type.\nHowever, being product-like is less demanding because it does not restrict indices that are\nnot useful.\nLemma 12. If f ∈F2 is not product-like then #CSP({f}) is #P-hard.\nProof. We’ll use Corollary 9 to prove hardness, following an argument from [9]. Choose a\nuseful index i so that there is no λi satisfying (2).\nSuppose f has arity k.\nLet A be the 2 × 2k−1 matrix such that for b ∈{0, 1} and\ny ∈{0, 1}k−1, Ab,y = f(yi=b). Let A′ = AAT .\nFirst, we show that Eval(A′) is #P-hard. Note that A′ is the following symmetric 2 × 2\nmatrix with non-negative rational entries.\n \nP\ny A2\n0,y\nP\ny A0,yA1,y\nP\ny A0,yA1,y\nP\ny A2\n1,y\n \n=\n \nP\ny f(yi=0)2\nP\ny f(yi=0)f(yi=1)\nP\ny f(yi=0)f(yi=1)\nP\ny f(yi=1)2\n!\nSince index i is useful, all four entries of A′ are positive. To show that Eval(A′) is #P-hard\nby Corollary 9, we just need to show that its determinant is non-zero. By Cauchy-Schwartz,\nthe determinant is non-negative, and is zero only if λi exists, which have assumed not to be\nthe case. Thus Eval(A′) is #P-hard by Corollary 9.\nNow we reduce Eval(A′) to #CSP({f}). To do this, take an undirected graph G which\nis an instance of Eval(A′). Construct an instance Y of #CSP({f}). For every vertex v of G\nwe introduce a variable xv of Y . Also, for every edge e of G we introduce k −1 variables\nxe,1, . . . , xe,k−1 of Y . We introduce constraints in Y as follows. For each edge e = (v, v′) of G\nwe introduce constraints f(xv, xe,1, . . . , xe,k−1) and f(xv′, xe,1, . . . , xe,k−1) into Y , where we\nhave assumed, without loss of generality, that the first index is useful.\nIt is clear that Eval(A′) is exactly equal to the partition function of the #CSP({f})\ninstance Y .\nFor w ∈Q+, let Uw denote the unary function mapping 0 to 1 and 1 to w. Note that\nU0 = δ0, and U1 gives the constant (0-ary function) 1, occurrences of which leave the partition\nfunction unchanged. So, by Lemma 8, we can discard these constraints since they do not\n11\n\nadd to the complexity of the problem. Note, by the observation above about proportional\nfunctions, that the functions Uw include all unary functions except for δ1 and the constant 0.\nWe can discard δ1 by Lemma 8, and if the constant 0 function is in F, any instance I where\nit appears as a constraint has Z(I) = 0. So again we can discard these constraints since they\nnot add to the complexity of the problem.\nThus Uw will be called nontrivial if w /∈{0, 1}. Let ⊕k : {0, 1}k →{0, 1} be the arity-k\nparity function that is 1 iffits argument has an odd number of 1s. Let ¬⊕k : {0, 1}k →{0, 1}\nbe the function 1 −⊕k. The following lemma shows that even a simple function like ⊕3 can\nlead to intractable #CSP instances when it is combined with a nontrivial weight function Uλ.\nLemma 13. #CSP(⊕3, Uλ, δ0, δ1) and #CSP(¬⊕3, Uλ, δ0, δ1) are both #P-hard, for any pos-\nitive λ ̸= 1.\nProof. We give a reduction from computing the Weight Enumerator of a Linear Code, which\nwas shown to be #P-hard in Lemma 10. In what follows, it is sometimes convenient to view\n⊕k, δ0, etc., as relations as well as functions to {0, 1}.\nWe first argue that for any k, the relation ⊕k can be simulated by {⊕3, δ0, δ1}.\nFor\nexample, to simulate x1 ⊕· · · ⊕xk for k > 3, take new variables y, z and w and let m = ⌈k/2⌉\nand use x1 ⊕· · · ⊕xm ⊕y and xm+1 ⊕· · · ⊕xk ⊕z and y ⊕z ⊕w and δ0(w).\nSince {⊕3, δ0, δ1} can be used to simulate any relation ⊕k, we can use {⊕3, δ0, δ1} to\nsimulate an arbitrary system of linear equations over GF(2). In particular we can use them\nto simulate the subspace Υ of code words for a given generating matrix A.\nFinally, we can use Uλ to simulate the function which evaluates the weight enumerator on\nΥ. Then, since λ ̸= 0, 1, we can apply Lemma 10 to complete the argument. The same proof,\nwith minor modifications, applies to ¬⊕3.\nLemma 14. Suppose f ∈F2 is not of product type. Then, for any positive λ ̸= 1, there exists\na constant c, depending on f, such that #CSP({f, δ0, δ1, Uλ, Uc}) is #P-hard.\nProof. If f does not have affine support, the result follows by Lemma 11. So suppose f has\naffine support. Consider the underlying relation Rf, viewed as a table. The rows of the table\nrepresent the tuples of the relation. Let J be the set of columns on which the relation is not\nconstant. That is, if i ∈J then there is a row x with xi = 0 and a row y with yi = 1. Group\nthe columns in J into equivalence classes: two columns are equivalent iffthey are equal or\ncomplementary. Let k be the number of equivalence classes. Take one column from each of\nthe k equivalence classes as a representative, and focus on the arity-k relation R induced by\nthose columns.\nCase 1: Suppose R is the complete relation of arity k.\nLet f ∗be the projection of f onto the k columns of R. By Lemma 6,\n#CSP({f ∗}) ≤T #CSP({f}) ≤T #CSP({f, δ0, δ1, Uλ, Uc}).\nWe will argue that #CSP({f ∗}) is #P-hard. To see this, note that every column of f ∗is\nuseful. Thus, if f ∗were product-like, we could conclude that f ∗was of product type. But\nthis would imply that f is of product type, which is not the case by assumption. So f ∗is not\nproduct-like and hardness follows from Lemma 12.\nCase 2: Suppose R is not the complete relation of arity k.\nWe had assumed that Rf is affine. This means that given three vectors, x, y and z, in Rf,\nx ⊕y ⊕z is in Rf as well. The arity-k relation R inherits this property, so is also affine.\n12\n\nChoose a minimal set of columns of R that do not induce the complete relation. This exists\nby assumption. Suppose there are j columns in this minimal set. Observe that j ̸= 1 because\nthere are no constant columns in J. Also j ̸= 2, since otherwise the two columns would be\nrelated by equality or disequality, contradicting the preprocessing step. The argument here\nis that on two columns, R cannot have exactly three tuples because it is affine, and having\ntuples x, y and z in would require the fourth tuple x ⊕y ⊕z. But if it has two tuples then,\nbecause there are no constant columns, the only possibilities are either (0, 0) and (1, 1), or\n(0, 1) and (1, 0). Both contradict the preprocessing step, so j ≥3.\nLet R′ be the restriction of R to the j columns. Now R′ of course has fewer than 2j rows,\nand at least 2j−1 by minimality. It is affine, and hence must be ⊕j or ¬⊕j. To see this, first\nnote that the size of R′ has to be a power of 2 since R′ is the solution to a system of linear\nequations. Hence the size of R′ must be 2j−1. Then, since there are j variables, there can\nonly be one defining equation. And, since every subset of j −1 variables induces a complete\nrelation, this single equation must involve all variables. Therefore, the equation is ⊕j or ¬⊕j.\nLet f ′ be the projection of f onto the j columns just identified. Let f ′′ be further obtained\nby pinning all but three of the j variables to 0. Pinning j −3 variables to 0 leaves a single\nequation involving all three remaining variables. Thus Rf′′ must be ⊕3 or ¬⊕3.\nNow define the symmetric function f ′′′ by\nf ′′′(a, b, c) = f ′′(a, b, c)f ′′(a, c, b)f ′′(b, a, c)f ′′(b, c, a)f ′′(c, a, b)f ′′(c, b, a),\nNote that Rf′′′ is ⊕3 or ¬⊕3, since Rf′′ is symmetric and hence Rf′′′ = Rf′′.\nTo summarise: using f and the constant functions δ0 and δ1, we have simulated a function\nf ′′′ such that its underlying relation Rf′′′ is either ⊕3 or ¬⊕3. Furthermore, if triples x and y\nhave the same number of 1s then f ′′′(x) = f ′′′(y).\nWe can now simulate an unweighted version of ⊕3 or ¬⊕3 using f ′′′ and a unary function\nUc, with c set to a conveniently-chosen value. There are two cases. Suppose first that the\naffine support of f ′′′ is ¬⊕3. Then let w0 denote the value of f ′′′ when applied to the 3-tuple\n(0, 0, 0) and let w2 denote f ′′′(0, 1, 1) = f ′′′(1, 0, 1) = f ′′′(1, 1, 0).\nRecall that f ′′′(x) = 0\nfor any other 3-tuple x.\nNow let c = (w0/w2)1/2.\nNote from the definition of f ′′′ that\nw0 and w2 are squares of rational numbers, so c is also rational.\nDefine a function g of\narity 3 by g(α, β, γ) = Uc(α)Uc(β)Uc(γ)f ′′′(α, β, γ). Note that g(0, 0, 0) = w0 and g(0, 1, 1) =\ng(1, 0, 1) = g(1, 1, 0) = c2w2 = w0. Thus, g is a pure affine function with affine support ¬⊕3\nand range {0, w0}. The other case, in which the affine support of f ′′′ is ⊕3, is similar.\nWe have established a reduction from either #CSP(⊕3, Uλ, δ0, δ1) or #CSP(¬⊕3, Uλ, δ0, δ1),\nwhich are both #P-hard by Lemma 13.\nLemma 15. If f ∈F2 is not of product type, then #CSP({f, δ0, δ1, Uλ}) is #P-hard for any\npositive λ ̸= 1.\nProof. Take an instance I of #CSP({f, δ0, δ1, Uλ, Uc}), from Lemma 14, with n variables\nx1, x2, . . . , xn.\nWe want to compute the partition function Z(I) using only instances of\n#CSP({f, δ0, δ1, Uλ}). That is, instances which avoid using constraints Uc. For each i, let mi\ndenote the number of copies of Uc that are applied to xi, and let m = Pn\ni=1 mi. Then we can\nwrite the partition function as Z(I) = Z(I; c) where\nZ(I; w) =\nX\nσ∈{0,1}n\nˆZ(σ)\nY\ni:σi=1\nwmi =\nX\nσ∈{0,1}n\nˆZ(σ)w\nPn\ni=1 miσi,\n13\n\nwhere ˆZ(σ) denotes the value corresponding to the assignment σ(xi) = σi, ignoring constraints\napplying Uc, and w is a variable. So ˆZ(σ) is the weight of σ, taken over all constraints other\nthan those applying Uc. Note also that Z(I; w) is a polynomial of degree m in w. We can\nevaluate Z(I; w) at the point w = λj by replacing each Uc constraint with j copies of a Uλ\nconstraint.\nThis evaluation is an instance of #CSP({f, δ0, δ1, Uλ}). So, using m different\nvalues of j and interpolating, we learn the coefficients of the polynomial Z(I; w). Then we\ncan put w = c to evaluate Z(I).\nLemma 16. Suppose f ∈F2 is not of product type, and g ∈F2 is not pure affine. Then\n#CSP({f, g, δ0, δ1}) is #P-hard.\nProof. If g does not have affine support we are done by Lemma 11. So suppose that g has\naffine support. Since g is not pure affine, the range of g contains at least two non-zero values.\nThe high-level idea will be to use pinning and bisection to extract a non-trivial unary\nweight function Uλ from g. Then we can reduce from #CSP({f, δ0, δ1, Uλ}), which we proved\n#P-hard in Lemma 15.\nLook at the relation Rg, viewed as a table. If every column were constant, then g would\nbe pure affine, so this is not the case. Select a non-constant column with index h. If there\nare two non-zero values in the range of g amongst the rows of Rg that are 0 in column h\nthen we derive a new function g′ by pinning column h to 0.\nThe new function g′ is not\npure affine, since the two non-zero values prevent this.\nSo we will show inductively that\n#CSP({f, g′, δ0, δ1}) is #P-hard. This will give the result since #CSP({f, g′, δ0, δ1}) trivially\nreduces to #CSP({f, g, δ0, δ1}).\nIf we don’t finish this way, or symmetrically by pinning column h to 1, then we know\nthat there are distinct positive values w0 and w1 such that, for every row x of Rg with 0 in\ncolumn h, g(x) = w0 and, for every row x of Rg with 1 in column h, g(x) = w1. Now note\nthat, because the underlying relation Rg is affine, it has the same number of 0’s in column h\nas 1’s. This is because Rg is the solution of a set of linear equations. Adding the equation\nxh = 0 or xh = 1 exactly halves the set of solutions in either case. We now project onto the\nindex set {h}. We obtain the unary weight function Uλ, with λ = w1/w0, on using the earlier\nobservation about proportional functions. This was our goal, and completes the proof.\nLemma 5 now follows from Lemma 8 and Lemma 16, completing the proof of Theorem 4.\nReferences\n[1] G. Brightwell and P. Winkler, Graph homomorphisms and phase transitions, Journal of\nCombinatorial Theory (Series B) 77 (1999), 221–262\n[2] A. Bulatov and V. Dalmau, Towards a dichotomy theorem for the counting constraint\nsatisfaction problem, in Proc. 44th Annual IEEE Symposium on Foundations of Computer\nScience, 2003, pp. 562–573.\n[3] D. Cohen, M. Cooper, P. Jeavons and A. Krokhin, The complexity of soft constraint\nsatisfaction, Artificial Intelligence 170 (2006), 983–1016.\n[4] A. Bulatov and M. Grohe, The complexity of partition functions, Theoretical Computer\nScience 348 (2005), 148–186.\n14\n\n[5] B. Cipra, An Introduction to the Ising Model, American Mathematical Monthly 94 (1987),\n937–959.\n[6] N. Creignou and M. Hermann, Complexity of generalized satisfiability counting problems,\nInformation and Computation 125 (1996), 1–12.\n[7] N. Creignou, S. Khanna, M. Sudan, Complexity classifications of Boolean constraint sat-\nisfaction problems, SIAM Press, 2001.\n[8] M. Dyer and C. Greenhill, The complexity of counting graph homomorphisms, Random\nStructures and Algorithms 17 (2000), 260–289.\n[9] M. Dyer, L.A. Goldberg and M. Paterson, On counting homomorphisms to directed acyclic\ngraphs, in Proc. 33rd International Colloquium on Automata, Languages and Program-\nming, Lecture Notes in Computer Science 4051, Springer, 2006, pp. 38–49.\n[10] T. Feder and M. Vardi, The computational structure of monotone monadic SNP and\nconstraint satisfaction: a study through Datalog and group theory, SIAM Journal on\nComputing 28 (1999), 57–104.\n[11] L.A.\nGoldberg\nand\nM.\nJerrum,\nInapproximability\nof\nthe\nTutte\npolynomial,\nhttp://arxiv.org/abs/cs.CC/0605140, 2006.\n[12] C. Greenhill, The complexity of counting colourings and independent sets in sparse\ngraphs and hypergraphs, Computational Complexity 9 (2000), 52–72.\n[13] P. Hell and J. Neˇsetˇril, On the complexity of H-coloring, Journal of Combinatorial\nTheory (Series B) 48 (1990), 92–110.\n[14] P. Hell and J. Neˇsetˇril, Graphs and homomorphisms, Oxford University Press, 2004.\n[15] L. Lov ́asz, Operations with structures, Acta Mathematica Hungarica 18 (1967), 321–328.\n[16] R. Ladner, On the structure of polynomial time reducibility, Journal of the Association\nfor Computing Machinery 22 (1975), 155–171.\n[17] C. Papadimitriou, Computational complexity, Addison-Wesley, 1994.\n[18] F. Rossi, P. van Beek and T. Walsh (Eds.), Handbook of constraint programming, Elsevier,\n2006.\n[19] T. Schaefer, The complexity of satisfiability problems, in Proc. 10th Annual ACM Sym-\nposium on Theory of Computing, ACM Press, 1978, pp. 216–226.\n[20] A. Scott and G. Sorkin, Polynomial constraint satisfaction: a framework for counting\nand sampling CSPs and other problems, http://arxiv.org/abs/cs/0604079.\n[21] J. Schwartz, Fast probabilistic algorithms for verification of polynomial identities, Jour-\nnal of the Association for Computing Machinery 27 (1980), 701–717.\n[22] L. Valiant, The complexity of enumeration and reliability problems, SIAM Journal on\nComputing 8 (1979), 410–421.\n[23] D. Welsh, Complexity: knots, colourings and counting, LMS Lecture Note Series, vol. 186,\nCambridge University Press, 1993.\n15\n\n4\nAppendix\nThe purpose of this appendix is to prove Lemma 7 for an arbitrary fixed domain [q]. We\nused only the special case q = 2, which we stated and proved as Lemma 8. However, pinning\nappears to be a useful technique for studying the complexity of #CSP, so we give a proof of\nthe general Lemma 7, which we believe will be applicable elsewhere.\nLemma 7. For every F ⊆Fq, #CSP(F ∪S\nc∈[q] δc) ≤T #CSP(F).\nIn order to prove the lemma, we introduce a useful, but less natural, variant of #CSP.\nSuppose F ⊆Fq. An instance I of #CSP̸=(F) consists of a set V of variables and a set C of\nconstraints, just like an instance of #CSP(F). In addition, the instance may contain a single\nextra constraint C applying the arity-q disequality relation χ̸= with scope (vC,1, . . . , vC,q).\nThe disequality relation χ̸= is defined by χ̸=(x1, . . . , xq) = 1 if x1, . . . , xq ∈[q] are pairwise\ndistinct. That is, if they are a permutation of the domain [q]. Otherwise, χ̸=(x1, . . . , xq) = 0.\nLemma 7 follows immediately from Lemma 17 and 18 below.\nLemma 17. For every F ⊆Fq, #CSP(F ∪S\nc∈[q] δc) ≤T #CSP̸=(F).\nProof. We follow the proof lines of Lemma 8, but instead of subtracting the contribution\ncorresponding to configurations in which some ti’s get the same value, we use the disequality\nrelation to restrict the partition function to configurations in which they get distinct values.\nSay that F is symmetric if it is the case that for every arity-k function f ∈F and every\ntuple x ∈[q]k and every permutation π : [q] →[q], f(x1, . . . , xk) = f(π(x1), . . . , π(xk)).\nLet I be an instance of #CSP(F ∪S\nc∈[q] δc) with variable set V . Let Vc be the set of\nvariables v ∈V to which the constraint δc(v) is applied. Assume without loss of generality\nthat the sets Vc are pairwise disjoint. Let Vq = V \\ S\nc∈[q] Vc. We construct an instance I′ of\n#CSP̸=(F). The instance has variables Vq ∪{t0, . . . , tq−1}. Every constraint C of I involving\na function f ∈F corresponds to a constraint C′ of I′. Here C′ is the same as C except that\nvariables in Vc are replaced with tc, for each c ∈[q]. Also, we add a new disequality constraint\nto the new variables t0, . . . , tq−1.\nCase 1. F is symmetric:\nBy construction, Z(I′) = P\ny0,...,yq−1 Z(I′ | σ(t0) = y0, . . . , σ(tq−1) = yq−1), where the sum\nis over all permutations y0, . . . , yq−1 of [q]. By symmetry, the summands are all the same, so\nZ(I′) = q!Z(I′ | σ(t0) = 0, . . . , σ(tq−1) = q −1) = q!Z(I).\nCase 2. F is not symmetric:\nSay that two permutations π1 : [q] →[q] and π2 : [q] →[q] are equivalent if, for every\nf ∈F and every tuple x ∈[q]k, f(π1(x1), . . . , π1(xk)) = f(π2(x1), . . . , π2(xk)). Partition the\npermutations π : [q] →[q] into equivalence classes. Let h be the number of equivalence classes\nand ni be the size of the i’th equivalence class, so n1 + · · · + nh = q!.6 Let {π1, . . . , πh} be\na set of representatives of the equivalence classes with π1 being the identity. We know that\nn1 ̸= q! since F is not symmetric.\nFor a positive integer lwe will now build an instance I′\nlby adding new constraints to I′.\nFor each πi other than π1 we add constraints as follows. Choose a function fi ∈F and a tuple y\nsuch that fi(y1, . . . , yk) ̸= fi(πi(y1), . . . , πi(yk)). If fi(y1, . . . , yk) > fi(πi(y1), . . . , πi(yk)) then\ndefine the k-tuple xi by (xi\n1, . . . , xi\nk) = (y1, . . . , yk).\nOtherwise, let n be the order of the\n6In fact, it can be shown that these equivalence classes are cosets of the symmetry group of f, and hence\nare of equal size, though we do not use this fact here.\n16\n\npermutation πi and let gr denote fi(πr\ni (y1), . . . , πr\ni (yk)). Since g0 < g1 and gn = g0 there\nexists a ξ ∈{1, . . . , n −1} such that gξ > gξ+1. Let (xi\n1, . . . , xi\nk) = (πξ(y1), . . . , πξ(yk)) so\nfi(xi\n1, . . . , xi\nk) > fi(πi(xi\n1), . . . , πi(xi\nk)).\nLet wij denote fi(πj(xi\n1), . . . , πj(xi\nk)) so, since π1 is the identity, we have just ensured that\nwi1 > wii. Let si = (txi\n1, . . . , txi\nk), and let 0 ≤zi ≤h (i = 2, . . . , h) be positive integers, which\nwe will determine below. Add lzi new constraints to I′\nlwith relation fi and scope si. Let\nλi = Qh\nγ=2 wzγ\nγi . Note that, given σ(t0) = πi(0), . . . , σ(tq−1) = πi(q −1), the contribution to\nZ(I′\nl) for the new constraints is\nh\nY\nγ=2\nfγ(σ(txγ\n1), . . . , σ(txγ\nk))zγl=\nh\nY\nγ=2\nfγ(πi(xγ\n1), . . . , πi(xγ\nk))zγl=\nh\nY\nγ=2\nwzγl\nγ,i =\n \nh\nY\nγ=2\nwzγ\nγ,i\n l\n= λil.\nSo\nZ(I′\nl) =\nh\nX\ni=1\nni Z( I′ | σ(t0) = πi(0), . . . , σ(tq−1) = πi(q −1) ) λl\ni.\nWe have ensured that λ1 > 0, since wi1 > wii ≥0, so wi1 > 0 for all i = 2, . . . , h. We now\nchoose the zi’s so that λi ̸= λ1 for all i = 2, . . . , h. If wγi = 0 for any γ = 2, . . . , h, we have\nλi = 0 and hence λi ̸= λ1. Thus we will assume, without loss of generality, that wγi > 0 for\nall γ = 2, . . . , h and i = 2, . . . , h′, where h′ ≤h. Then we have\nλi\nλ1\n=\nh\nY\nγ=2\n wγi\nwγ1\n zγ = e\nPh\nγ=2 αγizγ\n(i = 2, . . . , h′),\nwhere αγi = ln(wγi/wγ1). Note that αii < 0, since wii < wi1. We need to find an integer\nvector z = (z2, . . . , zh) so that none of the linear forms Li(z) = Ph\nγ=2 αγizγ is zero, for\ni = 2, . . . , h′.\nWe do this using a proof method similar to the Schwartz-Zippel Lemma.\n(See, for example, [21].) None of the Li(z) is identically zero, since αii ̸= 0. Consider the\ninteger vectors z ∈[h]h−1. At most hh−2 of these can make Li(z) zero for any i, since the\nequation Li(z) = 0 makes zi a linear function of zγ (γ ̸= i). Therefore there are at most\n(h′ −1)hh−2 < hh−1 such z which make any Li(z) zero. Therefore there must be a vector\nz ∈[h]h−1 for which none of the Li(z) is zero, and this is the vector we require.\nNow, by combining terms with equal λi and ignoring terms with λi = 0, we can view\nZ(I′\nl) as a sum Z(I′\nl) = P\ni ciλl\ni where the λi’s are positive and pairwise distinct and\nc1 = n1Z(I′ | σ(t0) = 0, . . . , σ(tq−1) = q −1).\nThus, by Lemma 3.2 of [8] we can interpolate to recover c1. Dividing by n1, we get\nZ(I′ | σ(t0) = 0, . . . , σ(tq−1) = q −1) = Z(I).\nLemma 18. For every F ⊆Fq, #CSP̸=(F) ≤T #CSP(F).\nProof. We use M ̈obius inversion for posets, following the lines of the proof of [2, Theorem 8].7\nConsider the set of partitions of [q].\nLet 0 denote the partition with q singleton classes.\nConsider the partial order in which η ≤θ iffevery class of η is a subset of some class\n7Lov ́asz [15] had previously used M ̈obius inversion in a similar context.\n17\n\nof θ. Define μ(0) = 1 and for any θ ̸= 0 define μ(θ) = −P\nη≤θ,η̸=θ μ(η). Consider the sum\nP\nη≤θ μ(η). Clearly, this sum is 1 if θ = 0. From the definition of μ, it is also easy to see that\nthe sum is 0 otherwise, since\nX\nη≤θ\nμ(η) = μ(θ) +\nX\nη≤θ,η̸=θ\nμ(η) = 0.\nNow let I be an instance of #CSP̸=(F) with a disequality constraint applied to variables\nt0, . . . , tq−1. Let V be the set of variables of I. Given a configuration σ : V →[q], let θ(σ)\nbe the partition of [q] induced by of (σ(t0), . . . , σ(tq−1)). Thus i and j in [q] are in the same\nclass of θ(σ) iffσ(ti) = σ(tj). We say that a partition η is consistent with σ (written η ≼σ)\nif η ≤θ(σ). Note that η ≼σ means that for any i and j in the same class of η, σ(ti) = σ(tj).\nLet Ωbe the set of configurations σ that satisfy all constraints in I except possibly the\ndisequality constraint. Then Z(I) = P\nσ∈Ωw(σ)1σ, where 1σ = 1 if σ respects the disequality\nconstraint, meaning that θ(σ) = 0, and 1σ = 0 otherwise. By the M ̈obius inversion formula\nderived above,\nZ(I) =\nX\nσ∈Ω\nw(σ)\nX\nη≤θ(σ)\nμ(η).\nChanging the order of summation, we get\nZ(I) =\nX\nη\nμ(η)\nX\nη≤θ\nX\nσ∈Ω:θ(σ)=θ\nw(σ) =\nX\nη\nμ(η)\nX\nσ∈Ω:η≼σ\nw(σ).\nNow note that P\nσ:η≼σ w(σ) is the partition function Z(Iη) of an instance Iη of #CSP(F).\nThe instance Iη is formed from I by ignoring the disequality constraint, and identifying\nvariables in t0, . . . , tq−1 whose indices are in the same class of η. Thus we can compute all\nthe Z(Iη) in #CSP(F). Finally, Z(I) = P\nη μ(η)Z(Iη), completing the reduction.\n18","paragraphs":[{"paragraph_id":"p1","order":1,"text":"arXiv:0704.3683v2 [cs.CC] 19 Jun 2008\nThe Complexity of Weighted 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\n28 April 2008\nAbstract\nThis paper gives a dichotomy theorem for the complexity of computing the partition\nfunction of an instance of a weighted Boolean constraint satisfaction problem. The prob-\nlem is parameterised by a finite set F of non-negative functions that may be used to\nassign weights to the configurations (feasible solutions) of a problem instance. Classical\nconstraint satisfaction problems correspond to the special case of 0,1-valued functions.\nWe show that computing the partition function, i.e. the sum of the weights of all config-\nurations, is FP#P-complete unless either (1) every function in F is of “product type”, or\n(2) every function in F is “pure affine”. In the remaining cases, computing the partition\nfunction is in P.\n1\nIntroduction\nThis paper gives a dichotomy theorem for the complexity of the partition function of weighted\nBoolean constraint satisfaction problems. Such problems are parameterised by a set F of\nnon-negative functions that may be used to assign weights to configurations (solutions) of\nthe instance. These functions take the place of the allowed constraint relations in classical\nconstraint satisfaction problems (CSPs). Indeed, the classical setting may be recovered by\nrestricting F to functions with range {0, 1}. The key problem associated with an instance\nof a weighted CSP is to compute its partition function, i.e., the sum of weights of all its\nconfigurations. Computing the partition function of a weighted CSP may be viewed a gen-\neralisation of counting the number of satisfying solutions of a classical CSP. Many partition\nfunctions from statistical physics may be expressed as weighted CSPs.\nFor example, the\nPotts model [23] is naturally expressible as a weighted CSP, whereas in the classical frame-\nwork only the “hard core” versions may be directly expressed. (The hard-core version of the\nantiferromagnetic Potts model corresponds to graph colouring and the hard-core version of\nthe ferromagnetic Potts model is trivial — acceptable configurations colour the entire graph\nwith a single colour.) A corresponding weighted version of the decision CSP was investigated\nby Cohen, Cooper, Jeavons and Krokhin [3]. This results in optimisation problems.\n1"},{"paragraph_id":"p2","order":2,"text":"We use #CSP(F) to denote the problem of computing the partition function of weighted\nCSP instances that can be expressed using only functions from F. We show in Theorem 4\nbelow that if every function f ∈F is “of product type” then computing the partition function\nZ(I) of an instance I can be done in polynomial time. Formal definitions are given later,\nbut the condition of being “of product type” is easily checked — it essentially means that\nthe partition function factors. We show further in Theorem 4 that if every function f ∈F is\n“pure affine” then the partition function of Z(I) can be computed in polynomial time. Once\nagain, there is an algorithm to check whether F is pure affine. For each other set F, we show\nin Theorem 4 that computing the partition function of a #CSP(F) instance is complete for\nthe class FP#P. The existence of algorithms for testing the properties of being purely affine\nor of product type means that the dichotomy is effectively decidable.\n1.1\nConstraint satisfaction\nConstraint Satisfaction, which originated in Artificial Intelligence, provides a general frame-\nwork for modelling decision problems, and has many practical applications. (See, for exam-\nple [18].) Decisions are modelled by variables, which are subject to constraints, modelling\nlogical and resource restrictions. The paradigm is sufficiently broad that many interesting\nproblems can be modelled, from satisfiability problems to scheduling problems and graph-\ntheory problems. Understanding the complexity of constraint satisfaction problems has be-\ncome a major and active area within computational complexity [7, 14].\nA Constraint Satisfaction Problem (CSP) typically has a finite domain, which we will\ndenote by [q] = {0, 1 . . . , q −1} for a positive integer q.1\nA constraint language Γ with\ndomain [q] is a set of relations on [q]. For example, take q = 2. The relation R = {(0, 0, 1),\n(0, 1, 0), (1, 0, 0), (1, 1, 1)} is a 3-ary relation on the domain {0, 1}, with four tuples.\nOnce we have fixed a constraint language Γ, an instance of the CSP is a set of variables\nV = {v1, . . . , vn} and a set of constraints. Each constraint has a scope, which is a tuple of\nvariables (for example, (v4, v5, v1)) and a relation from Γ of the same arity, which constrains\nthe variables in the scope. A configuration σ is a function from V to [q]. The configuration σ\nis satisfying if the scope of every constraint is mapped to a tuple that is in the corresponding\nrelation. In our example above, a configuration σ satisfies the constraint with scope (v4, v5, v1)\nand relation R if and only if it maps an odd number of the variables in {v1, v4, v5} to the\nvalue 1. Given an instance of a CSP with constraint language Γ, the decision problem CSP(Γ)\nasks us to determine whether any configuration is satisfying. The counting problem #CSP(Γ)\nasks us to determine the number of (distinct) satisfying configurations.\nVarying the constraint language Γ defines the classes CSP and #CSP of decision and\ncounting problems.\nThese contain problems of different computational complexities.\nFor\nexample, if Γ = {R1, R2, R3} where R1, R2 and R3 are the three binary relations defined\nby R1 = {(0, 1), (1, 0), (1, 1)}, R2 = {(0, 0), (0, 1), (1, 1)} and R3 = {(0, 0), (0, 1), (1, 0)}, then\nCSP(Γ) is the classical 2-Satisfiability problem, which is in P.\nOn the other hand, there\nis a similar constraint language Γ′ with four relations of arity 3 such that 3-Satisfiability\n(which is NP-complete) can be represented in CSP(Γ′). It may happen that the counting\nproblem is harder than the decision problem. If Γ is the constraint language of 2-Satisfiability\nabove, then #CSP(Γ) contains the problem of counting independent sets in graph, and is\n#P-complete [22], even if restricted to 3-regular graphs [12].\n1 Usually [q] is defined to be {1, 2, . . . , q}, but it is more convenient here to start the enumeration of domain\nelements at 0 rather than 1.\n2"},{"paragraph_id":"p3","order":3,"text":"Any decision problem CSP(Γ) is in NP, but not every problem in NP can be represented\nas a CSP. For example, the question “Is G Hamiltonian?” cannot naturally be expressed\nas a CSP, because the property of being Hamiltonian cannot be captured by relations of\nbounded size. This limitation of the class CSP has an important advantage. If P ̸= NP,\nthen there are problems which are neither in P nor NP-complete [16]. But, for well-behaved\nsmaller classes of decision problems, the situation can be simpler. We may have a dichotomy\ntheorem, partitioning all problems in the class into those which are in P and those which\nare NP-complete. There are no “leftover” problems of intermediate complexity. It has been\nconjectured that there is a dichotomy theorem for CSP. The conjecture is that CSP(Γ) is\nin P for some constraint languages Γ, and CSP(Γ) is NP-complete for all other constraint\nlanguages Γ. This conjecture appeared in a seminal paper of Feder and Vardi [10], but has\nnot yet been proved.\nA similar dichotomy, between FP and #P-complete, is conjectured for #CSP [2]. The\ncomplexity classes FP and #P are the analogues of P and NP for counting problems. FP\nis simply the class of functions computable in deterministic polynomial time.\n#P is the\nclass of integer functions that can be expressed as the number of accepting computations of\na polynomial-time non-deterministic Turing machine. Completeness in #P is defined with\nrespect to polynomial-time Turing reducibility [17, Chap. 18]. Bulatov and Dalmau [2] have\nshown in one direction that, if #CSP(Γ) is solvable in polynomial time, then the constraints\nin Γ must have certain algebraic properties (assuming P ̸= #P). In particular, they must\nhave a so-called Mal’tsev polymorphism. The converse is known to be false, though it remains\npossible that the dichotomy (if it exists) does have an algebraic characterisation.\nThe conjectured dichotomies for CSP and #CSP are major open problems for computa-\ntional complexity theory. There have been many important results for subclasses of CSP and\n#CSP. We mention the most relevant to our paper here. The first decision dichotomy was\nthat of Schaefer [19], for the Boolean domain {0, 1}. Schaefer’s result is as follows.\nTheorem 1 (Schaefer [19]). Let Γ be a constraint language with domain {0, 1}. The problem\nCSP(Γ) is in P if Γ satisfies one of the conditions below. Otherwise, CSP(Γ) is NP-complete.\n(1) Γ is 0-valid or 1-valid.\n(2) Γ is weakly positive or weakly negative.\n(3) Γ is affine.\n(4) Γ is bijunctive.\nWe will not give detailed definitions of the conditions in Theorem 1, but the interested\nreader is referred to the paper [19] or to Theorem 6.2 of the textbook [7]. An interesting feature\nis that the conditions in [7, Theorem 6.2] are all checkable. That is, there is an algorithm\nto determine whether CSP(Γ) is in P or NP-complete, given a constraint language Γ with\ndomain {0, 1}. Creignou and Hermann [6] adapted Schaefer’s decision dichotomy to obtain a\ncounting dichotomy for the Boolean domain. Their result is as follows.\nTheorem 2 (Creignou and Hermann [6]). Let Γ be a constraint language with domain {0, 1}.\nThe problem #CSP(Γ) is in FP if Γ is affine. Otherwise, #CSP(Γ) is #P-complete.\nA constraint language Γ with domain {0, 1} is affine if every relation R ∈Γ is affine. A\nrelation R is affine if the set of tuples x ∈R is the set of solutions to a system of linear\nequations over GF(2). These equations are of the form v1 ⊕· · · ⊕vn = 0 and v1 ⊕· · · ⊕vn = 1\nwhere ⊕is the exclusive or operator. It is well known (see, for example, Lemma 4.10 of [7])\n3"},{"paragraph_id":"p4","order":4,"text":"that a relation R is affine iffa, b, c ∈R implies d = a ⊕b ⊕c ∈R.\n(We will use this\ncharacterisation below.) There is an algorithm for determining whether a Boolean constraint\nlanguage Γ is affine, so there is an algorithm for determining whether #CSP(Γ) is in FP or\n#P-complete.\n1.2\nWeighted #CSP\nThe weighted framework of [4] extends naturally to Constraint Satisfaction Problems. Fix\nthe domain [q].\nInstead of constraining a length-k scope with an arity-k relation on [q],\nwe give a weight to the configuration on this scope by applying a function f from [q]k to\nthe non-negative rationals.\nLet Fq = {f : [q]k →Q+ | k ∈N} be the set of all such\nfunctions (of all arities).2 Given a function f ∈Fq of arity k, the underlying relation of f\nis given by Rf = {x ∈[q]k | f(x) ̸= 0}. It is often helpful to think of Rf as a table, with\nk columns corresponding to the positions of a k-tuple.\nEach row corresponds to a tuple\nx = (x1, . . . , xk) ∈Rf. The entry in row x and column j is xj, which is a value in [q].\nA weighted #CSP problem is parameterised by a finite subset F of Fq, and will be\ndenoted by #CSP(F). An instance I of #CSP(F) consists of a set V of variables and a\nset C of constraints. Each constraint C ∈C consists of a function fC ∈F (say of arity kC)\nand a scope, which is a sequence sC = (vC,1, . . . , vC,kC) of variables from V . The variables\nvC,1, . . . , vC,kC need not be distinct. As in the unweighted case, a configuration σ for the\ninstance I is a function from V to [q]. The weight of the configuration σ is given by\nw(σ) =\nY\nC∈C\nfC(σ(vC,1), . . . , σ(vC,kC)).\nFinally, the partition function Z(I) is given, for instance I, by\nZ(I) =\nX\nσ:V →[q]\nw(σ).\n(1)\nIn the computational problem #CSP(F), the goal is to compute Z(I), given an instance I.\nNote that an (unweighted) CSP counting problem #CSP(Γ) can be represented naturally\nas a weighted CSP counting problem.\nFor each relation R ∈Γ, let f R be the indicator\nfunction for membership in R.\nThat is, if x ∈R we set f R(x) = 1.\nOtherwise we set\nf R(x) = 0. Let F = {f R | R ∈Γ}. Then for any instance I of #CSP(Γ), the number of\nsatisfying configurations for I is given by the (weighted) partition function Z(I) from (1).\nThis framework has been employed previously in connection with graph homomorphisms [1].\nSuppose H = (Hij) is any symmetric square matrix H of rational numbers. We view H as\nbeing an edge-weighting of an undirected graph H, where a zero weight in H means that\nthe corresponding edge is absent from H. Given a (simple) graph G = (V, E) we consider\ncomputing the partition function\nZH(G) =\nX\nσ:V →[q]\nw(σ),\nwhere w(σ) =\nY\n{u,v}∈E\nHσ(u)σ(v).\nWithin our framework above, we view H as the binary function h : [q]2 →R, and the problem\nis then computing the partition function of #CSP({h}).\n2We assume 0 ∈N, so we allow non-negative constants.\n4"},{"paragraph_id":"p5","order":5,"text":"Bulatov and Grohe [4] call H connected if H is connected and bipartite if H is bipartite.\nThey give the following dichotomy theorem for non-negative H.3\nTheorem 3 (Bulatov and Grohe [4]). Let H be a symmetric matrix with non-negative rational\nentries.\n(1) If H is connected and not bipartite, then computing ZH is in FP if the rank of H is at\nmost 1; otherwise computing ZH is #P-hard.\n(2) If H is connected and bipartite, then computing ZH is in FP if the rank of H is at most 2;\notherwise computing ZH is #P-hard.\n(3) If H is not connected, then computing ZH is in FP if each of its connected components\nsatisfies the corresponding conditions stated in (1) or (2); otherwise computing ZH is\n#P-hard.\nMany partition functions arising in statistical physics may be viewed as weighted #CSP\nproblems. An example is the q-state Potts model (which is, in fact, a weighted graph ho-\nmomorphism problem). In general, weighted #CSP is very closely related to the problem of\ncomputing the partition function of a Gibbs measure in the framework of Dobrushin, Lanford\nand Ruelle (see [1]). See also the framework of Scott and Sorkin [20].\n1.3\nSome Notation\nWe will call the class of (rational) weighted #CSP problems weighted #CSP. The sub-class\nhaving domain size q = 2 will be called weighted Boolean #CSP, and will be the main focus\nof this paper. We will give a dichotomy theorem for weighted Boolean #CSP.\nSince weights can be arbitrary non-negative rational numbers, the solution to these prob-\nlems is not an integer in general. Therefore #CSP(F) is not necessarily in the class #P.\nHowever, Goldberg and Jerrum [11] have observed that Z(I) = ̃Z(I)/K(I), where ̃Z is a\nfunction in #P and K(I) is a positive integer computable in FP. This follows because, for all\nf ∈F, we can ensure that f(·) = ̃f(·)/K(I), where ̃f(·) ∈N, by“clearing denominators”. The\ndenominator K(I) can obviously be computed in polynomial time, and it is straightforward\nto show that computing ̃Z(I) is in #P, so the characterisation of [11] follows. The resulting\ncomplexity class, comprising functions which are a function in #P divided by a function in\nFP, is named #PQ in [11], where it is used in the context of approximate counting. Clearly\nwe have\nweighted #CSP ⊆#PQ ⊆FP#P.\nOn the other hand, if Z(I) ∈weighted #CSP is #P-hard, then, using an oracle for computing\nZ(I), we can construct a #P oracle ̃Z(I) as outlined above.\n(Note that Z(I) /∈#P in\ngeneral.) Using this, we can compute any function in FP#P with a polynomial time-bounded\noracle Turing machine. Thus any #P-hard function in weighted #CSP is complete for FP#P.\nWe will use this observation to state our main result in terms of completeness for the class\nFP#P.\nWe make the following definition, which relates to the discussion above. We will say that\nF ⊆Fq simulates f ∈Fq if, for each instance I of #CSP(F ∪{f}), there is a polynomial time\ncomputable instance I′ of #CSP(F), such that Z(I) = φ(I)Z(I′) for some φ(I) ∈Q which is\nFP-computable. This generalises the notion of parsimonious reduction [17] among problems in\n3This is not quite the original statement of the theorem. We have chosen here to restrict all inputs to be\nrational, in order to avoid issues of how to represent, and compute with, arbitrary real numbers.\n5"},{"paragraph_id":"p6","order":6,"text":"#P. We will use ≤T to denote the relation “is polynomial-time Turing-reducible to” between\ncomputational problems. Clearly, if F simulates f, we have #CSP(F ∪{f}) ≤T #CSP(F).\nNote also that, if ̃f = Kf, for some constant K > 0, then {f} simulates ̃f. Thus there is no\nneed to distinguish between “proportional” functions.\nWe use the following terminology for certain functions. Let χ= be the binary equality\nfunction defined on [q] as follows. For any element c ∈[q], χ=(c, c) = 1 and for any pair (c, d)\nof distinct elements of [q], χ=(c, d) = 0. Let χ̸= be the binary disequality function given by\nχ̸=(c, d) = 1 −χ=(c, d) for all c, d ∈[q].4 We say that a function f is of product type if f can\nbe expressed as a product of unary functions and binary functions of the form χ= and χ̸=.\nWe focus attention in this paper on the Boolean case, q = 2. In this case, we say that a\nfunction f ∈F2 has affine support if its underlying relation Rf, defined earlier, is affine. We\nsay that f is pure affine if it has affine support and range {0, w} for some w > 0. Thus a\nfunction is pure affine if and only if it is a positive real multiple of some (0,1-valued) function\nwhich is affine over GF(2).\n1.4\nOur Result\nOur main result is the following.\nTheorem 4. Suppose F ⊆F2 = {f : {0, 1}k →Q+ | k ∈N}. If every function in F is of\nproduct type then #CSP(F) is in FP. If every function in F is pure affine then #CSP(F) is\nin FP. Otherwise, #CSP(F) is FP#P-complete.\nProof. Suppose first that F is of product type. In this case the partition function Z(I) of\nan instance I with variable set V is easy to evaluate because it can be factored into easy-\nto-evaluate pieces: Partition the variables in V into equivalence classes according to whether\nor not they are related by an equality or disequality function. (The equivalence relation on\nvariables here is “depends linearly on”.) An equivalence class consists of two (possibly empty)\nsets of variables U1 and U2. All of the variables in U1 must be assigned the same value by a\nconfiguration σ of nonzero weight, and all variables in U2 must be assigned the other value.\nVariables in U1∪U2 are not related by equality or disequality to variables in V \\(U1∪U2). The\nequivalence class contributes one weight, say α, to the partition function if variables in U1\nare given value “0” by σ and it contributes another weight, say β, to the partition function\nif variables in U1 are given value “1” by σ. Thus, Z(I) = (α + β)Z(I′), where I′ is the\ninstance formed from I by removing this equivalence class. Therefore, suppose we choose any\nequivalence class and remove its variables. Since F contains only unary, equality or binary\ndisequality constraints, we can also remove all functions involving variables in U1 ∪U2 to give\nF′. Then I′ is of product type with fewer variables, so we may compute Z(I′) recursively.\nSuppose second that F if pure affine. Then Z(I) = Q\nf∈F wkf\nf Z(I′), where {0, wf} is the\nrange of f, kf is the number of constraints involving f in I, and I′ is the instance obtained\nfrom I by replacing every function f by its underlying relation Rf (viewed as a function with\nrange {0, 1}). Z(I′) is easy to evaluate, because this is just counting solutions to a linear\nsystem over GF(2), as Creignou and Hermann have observed [6].\nFinally, the #P-hardness in Theorem 4 follows from Lemma 5 below.\nLemma 5. If f ∈F2 is not of product type and g ∈F2 is not pure affine then #CSP({f, g})\nis #P-hard.\n4A more general disequality function is defined in the Appendix.\n6"},{"paragraph_id":"p7","order":7,"text":"Note that the functions f and g in Lemma 5 may be one and the same function. So\n#CSP({f}) is #P-hard when f is not of product type nor pure affine. The rest of this article\ngives the proof of Lemma 5.\n2\nUseful tools for proving hardness of #CSP\n2.1\nNotation\nFor any sequence u1, . . . , uk of variables of I and any sequence c1, . . . , ck of elements of the\ndomain [q], we will let Z(I | σ(u1) = c1, . . . , σ(uk) = ck) denote the contribution to Z(I) from\nassignments σ with σ(u1) = c1, · · · , σ(uk) = ck.\n2.2\nProjection\nThe first tool that we study is projection, which is referred to as “integrating out” in the\nstatistical physics literature.\nLet f be a function of arity k, and let J = {j1, . . . , jr} be a size-r subset of {1, . . . , k},\nwhere j1 < · · · < jr.5 We say that a k-tuple x′ ∈[q]k extends an r-tuple x ∈[q]r on J (written\nx′ ⊒J x) if x′ agrees with x on indices in J; that is to say, x′\nji = xi for all 1 ≤i ≤r. The\nprojection g of f onto J is defined as follows. For every x ∈[q]r, g(x) = P\nx′⊒Jx f(x′).\nThe following lemma may be viewed as a weighted version of Proposition 2 of [2], where\nit is proved for the unweighted case. It is expressed somewhat differently in [2], in terms of\ncounting the number of solutions to an existential formula.\nLemma 6. Suppose F ⊆Fq. Let g be a projection of a function f ∈F onto a subset of its\nindices. Then #CSP(F ∪{g}) ≤T #CSP(F).\nProof. Let k be the arity of f and let g be the projection of f onto the subset J of its indices.\nLet I be an instance of #CSP(F ∪{g}). We will construct an instance I′ of #CSP(F) such\nthat Z(I) = Z(I′). The instance I′ is identical to I except that every constraint C of I\ninvolving g is replaced with a new constraint C′ of I′ involving f. The corresponding scope\n(vC′,1, . . . , vC′,k) is constructed as follows. If jlis the l’th element of J, then v′\nC′,jl= vC,l. The\nother variables, vC′,j (j /∈J), are distinct new variables. We have shown that F simulates g\nwith φ(I) = 1.\n2.3\nPinning\nFor c ∈[q], δc denotes the unary function with δc(c) = 1 and δc(d) = 0 for d ̸= c. The\nfollowing lemma, which allows “pinning” CSP variables to specific values in hardness proofs,\ngeneralises Theorem 8 of [2], which does the unweighted case. Again [2] employs different\nterminology, and its theorem is a statement about the full idempotent reduct of a finite\nalgebra. The idea of pinning was used previously by Bulatov and Grohe of [4] in the context\nof counting weighted graph homomorphisms (see Lemma 32 of [4]). A similar idea was used\nby Dyer and Greenhill in the context of counting unweighted graph homomorphisms — in\nthat context, Theorem 4.1 of [8] allows pinning all variables to a particular component of the\ntarget graph H.\n5It is not necessary to choose this particular ordering for J, but it is convenient to do so.\n7"},{"paragraph_id":"p8","order":8,"text":"Lemma 7. For every F ⊆Fq, #CSP(F ∪S\nc∈[q] δc) ≤T #CSP(F).\nThe proof of Lemma 7 is deferred to the appendix. Since we only use the case q = 2 in\nthis paper, we provide the (simpler) proof for the Boolean case here.\nLemma 8. For every F ⊆F2, #CSP(F ∪{δ0, δ1}) ≤T #CSP(F).\nProof. For x ∈[2]k, let x be the k-tuple whose i’th component, xi, is xi ⊕1, for all i. Say\nthat F is symmetric if it is the case that for every arity-k function f ∈F and every x ∈[2]k,\nf(x) = f(x).\nGiven an instance I of #CSP(F ∪{δ0, δ1}) with variable set V we consider two instances\nI′ and I′′ of #CSP(F). Let V0 be the set of variables v of I to which the constraint δ0(v) is\napplied. Let V1 be the set of variables v of I to which the constraint δ1(v) is applied. We\ncan assume without loss of generality that V0 and V1 do not intersect. (Otherwise, Z(I) = 0\nand we can determine this without using an oracle for #CSP(F).) Let V2 = V \\ (V0 ∪V1).\nThe instance I′ has variables V2 ∪{t0, t1} where t0 and t1 are distinct new variables that are\nnot in V . Every constraint C of I involving a function f ∈F corresponds to a constraint C′\nof I′. C′ is the same as C except that variables in V0 are replaced with t0 and variables\nin V1 are replaced with t1. Similarly, the instance I′′ has variables V2 ∪{t} where t is a new\nvariable that is not in V . Every constraint C of I involving a function f ∈F corresponds to\na constraint C′′ of I′′. The constraint C′′ is the same as C except that variables in V0 ∪V1\nare replaced with t.\nCase 1. F is symmetric:\nBy construction,\nZ(I′) −Z(I′′) = Z(I′ | σ(t0) = 0, σ(t1) = 1) + Z(I′ | σ(t0) = 1, σ(t1) = 0).\nBy symmetry, the summands are the same, so\nZ(I′) −Z(I′′) = 2Z(I′ | σ(t0) = 0, σ(t1) = 1) = 2Z(I).\nCase 2. F is not symmetric:\nLet f be an arity-k function in F and let x ∈[2]k so that\nf(x) > f(x) ≥0. Let s = (tx1, . . . , txk) and let I′\nx be the instance derived from I′ by adding a\nnew constraint with function f and scope s. Similarly, let I′′\nx be the instance derived from I′′\nby adding a new constraint with function f and scope (t, . . . , t). Now\nZ(I′\nx) = Z(I′ | σ(t0) = 0, σ(t1) = 1)f(x) + Z(I′ | σ(t0) = 1, σ(t1) = 0)f(x)\n+ Z(I′ | σ(t0) = 0, σ(t1) = 0)f(0, . . . , 0) + Z(I′ | σ(t0) = 1, σ(t1) = 1)f(1, . . . , 1)\n= Z(I′ | σ(t0) = 0, σ(t1) = 1)f(x) + Z(I′ | σ(t0) = 1, σ(t1) = 0)f(x) + Z(I′′\nx).\nThus we have two independent equations,\nZ(I′\nx) −Z(I′′\nx) = Z(I′ | σ(t0) = 0, σ(t1) = 1)f(x) + Z(I′ | σ(t0) = 1, σ(t1) = 0)f(x),\nZ(I′) −Z(I′′) = Z(I′ | σ(t0) = 0, σ(t1) = 1)\n+ Z(I′ | σ(t0) = 1, σ(t1) = 0)\n,\nin the unknowns Z(I′ | σ(t0) = 0, σ(t1) = 1) and Z(I′ | σ(t0) = 1, σ(t1) = 0). Solving these,\nwe obtain the value of Z(I′ | σ(t0) = 0, σ(t1) = 1) = Z(I).\n8"},{"paragraph_id":"p9","order":9,"text":"2.4\n#P-hard problems\nTo prove Lemma 5, we will give reductions from some known #P-hard problems. The first of\nthese is the problem of counting homomorphisms from simple graphs to 2-vertex multigraphs.\nWe use the following special case of Bulatov and Grohe’s Theorem 3.\nCorollary 9 (Bulatov and Grohe [4]). Let H be a symmetric 2 × 2 matrix with non-negative\nreal entries. If H has rank 2 and at most one entry of H is 0 then Eval(H) is #P-hard.\nWe will also use the problem of computing the weight enumerator of a linear code. Given a\ngenerating matrix A ∈{0, 1}r×C of rank r, a code word c is any vector in the linear subspace Υ\ngenerated by the rows of A over GF(2). For any real number λ, the weight enumerator of the\ncode is given by WA(λ) = P\nc∈Υ λ∥c∥, where ∥c∥is the number of 1’s in c. The problem of\ncomputing the weight enumerator of a linear code is in FP for λ ∈{−1, 0, 1}, and is known to\nbe #P-hard for every other fixed λ ∈Q (see [23]). We could not find a proof, so we provide\none here. We restrict attention to positive λ, since that is adequate for our purposes.\nLemma 10. Computing the Weight Enumerator of a Linear Code is #P-hard for any fixed\npositive rational number λ ̸= 1.\nProof. We will prove hardness by reduction from a problem Eval(H), for some appropriate H,\nusing Corollary 9. Let the input to Eval(H) be a connected graph G = (V, E) with V =\n{v1, . . . , vn} and E = {e1, . . . , em}. Let B be the n × m incidence matrix of G, with bij = 1\nif vi ∈ej and bij = 0 otherwise. Let A be the (n −1) × m matrix which is B with the row\nfor vn deleted. A will be the generating matrix of the Weight Enumerator instance, with\nr = n −1 and C = m. It has rank (n −1) since G contains a spanning tree. A code word\nc has cj = L\ni∈U bij, where U ⊆V \\ {vn}. Thus cj = 1 if and only if ej has exactly one\nendpoint in U, and the weight of c is λk, where k is the number of edges in the cut U, V \\ U.\nThus WA(λ) = 1\n2ZH(G), where H is the symmetric weight matrix with H11 = H22 = 1 and\nH12 = H21 = λ. The 1\n2 arises because we fixed which side of the cut contains vn. Now H\nhas rank 2 unless λ = 1, so this problem is #P-hard by Corollary 9. Note, by the way, that\nZH(G) is the partition function of the Ising model in statistical physics [5].\n3\nThe Proof of Lemma 5\nThroughout this section, we assume q = 2. The following Lemma is a generalisation of a result\nof Creignou and Hermann [6], which deals with the case in which f is a relation (or, in our\nsetting, a function with range {0, 1}). The inductive technique used in the proof of Lemma 11\n(combined with the follow-up in Lemma 12) is good for showing that #CSP(F) is #P-hard\nwhen F contains a single function. A very different situation arises when #CSP({f}) and\n#CSP({g}) are in FP but #CSP({f, g}) is #P-hard due to interactions between f and g —\nwe deal with that problem later.\nLemma 11. Suppose that f ∈F2 does not have affine support. Then #CSP({f}) is #P-hard.\nProof. Let k be the arity of f, and let us denote the ith component of k-tuple a ∈Rf by ai.\nThe proof is by induction on k. The lemma is trivially true for k = 1, since all functions of\narity 1 have affine support.\n9"},{"paragraph_id":"p10","order":10,"text":"For k = 2, we note that since Rf is not affine, it is of the form Rf = {(α, β), ( ̄α, β), ( ̄α, ̄β)}\nfor some α ∈{0, 1} and β ∈{0, 1}. We can show that #CSP({f}) is #P-hard by reduction\nfrom Eval(H) using\nH =\n f(0, 0)\nf(0, 1)\nf(1, 0)\nf(1, 1)"},{"paragraph_id":"p11","order":11,"text":",\nwhich has rank 2 and exactly one entry that is 0. Given an instance G = (V, E) of Eval(H)\nwe construct an instance I of #CSP({f}) as follows. The variables of I are the vertices of G.\nFor each edge e = (u, v) of G, add a constraint with function f and variable sequence u, v.\nCorollary 9 now tells us that Eval(H) is #P-hard, so #CSP({f}) is #P-hard.\nSuppose k > 2.\nWe start with some general arguments and notation.\nFor any i ∈\n{1, . . . , k} and any α ∈{0, 1} let f i=α be the function of arity k −1 derived from f by pinning\nthe i’th position to α. That is, f i=α(x1, . . . , xk−1) = f(x1, . . . , xi−1, α, xi+1, . . . , xk). Also,\nlet f i=∗be the projection of f onto all positions apart from position i (see Section 2.2).\nNote that #CSP({f i=α}) ≤T #CSP({f, δ0, δ1}), since f i=α can obviously be simulated by\n{f, δ0, δ1}.\nFurthermore, by Lemma 8, #CSP({f, δ0, δ1}) ≤T #CSP({f}).\nThus, we can\nassume that f i=α has affine support — otherwise, we are finished by induction. Similarly, by\nLemma 6, #CSP("},{"paragraph_id":"p12","order":12,"text":"f i=∗ \n) ≤T #CSP({f}). Thus we can assume that f i=∗has affine support\n— otherwise, we are finished by induction.\nNow, recall that Rf is not affine. Consider any a, b, c ∈Rf such that d = a ⊕b ⊕c /∈Rf.\nWe have 4 cases.\nCase 1:\nThere are indices 1 ≤i < j ≤k such that (ai, bi, ci) = (aj, bj, cj):\nWithout loss of generality, suppose i = 1 and j = 2. Define the function f ′ of arity (k −1) by\nf ′(r2, . . . , rk) = f(r2, r2, . . . , rk). Note that Rf′ is not affine since the condition a⊕b⊕c /∈Rf is\ninherited by Rf′. So, by induction, #CSP({f ′}) is #P-hard. Now note that #CSP({f ′}) ≤T\n#CSP({f}). To see this, note that any instance I1 of #CSP({f ′}) can be turned into an\ninstance I of #CSP({f}) by repeating the first variable in the sequence of variables for each\nconstraint.\nCase 2: There is an index 1 ≤i ≤k such that ai = bi = ci: Since d is not in Rf and\ndi = ai, we find that f i=ai does not have affine support, contrary to earlier assumptions.\nHaving finished Cases 1 and 2, we may assume without loss of generality that we are in\nCase 3 or Case 4 below, where {α, β} ∈{0, 1}, ̄α = 1 −α, ̄β = 1 −β and a′, b′, c′ ∈{0, 1}k−2.\nCase 3:\na = ( ̄α, ̄β, a′), b = ( ̄α, β, b′), c = (α, ̄β, c′): Since Rf1=∗is affine and a, b\nand c are in Rf, we must have either d = (α, β, d′) ∈Rf or e = ( ̄α, β, d′) ∈Rf, where\nd′ = a′ ⊕b′ ⊕c′. In the first case, we are done (we have contradicted the assumption that\nd ̸∈Rf), so assume that e ∈Rf but d ̸∈Rf.\nSimilarly, since Rf2=∗is affine, we may\nassume that g = (α, ̄β, d′) ∈Rf. Since Rf1= ̄α is affine and a, b and e are in Rf, we find\nthat h = a ⊕b ⊕e = ( ̄α, ̄β, c′) ∈Rf. Since Rf2= ̄β is affine and a, c and g are in Rf, we\nfind that i = ( ̄α, ̄β, b′) ∈Rf. Also, since Rf2= ̄β is affine and a, h and i are in Rf, we find\nthat j = ( ̄α, ̄β, d′) ∈Rf. Let f ′(r1, r2) = f(r1, r2, d3, . . . , dk). Since e, g and j are in Rf\nbut d is not, we have ( ̄α, β), (α, ̄β), ( ̄α, ̄β) ∈Rf′, but (α, β) /∈Rf′. Thus, f ′ does not have\naffine support and #CSP({f ′}) is #P-hard by induction. Also, #CSP({f ′}) ≤T #CSP({f})\nby Lemma 8.\nCase 4: a = ( ̄α, α, a′), b = ( ̄α, α, b′), c = (α, ̄α, c′): Since Rf1=∗is affine and a, b and c\nare in Rf but d is not, we have e = ( ̄α, ̄α, d′) ∈Rf. Similarly, since Rf2=∗is affine and a, b\nand c are in Rf but d is not, we have g = (α, α, d′) ∈Rf. Now since Rf1= ̄α is affine and a, b\nand e are in Rf, we have h = ( ̄α, ̄α, c′) ∈Rf. Also, since Rf2=α is affine and a, b and g are in\n10"},{"paragraph_id":"p13","order":13,"text":"Rf, we have i = (α, α, c′) ∈Rf.\nLet f ′(r1, r2) = f(r1, r2, c3, . . . , ck). If j = ( ̄α, α, c′) ̸∈Rf then f ′ does not have affine\nsupport (since c, h and i are in Rf) so we finish by induction as in Case 3. Suppose j ∈Rf.\nSince Rf1= ̄α is affine and a, b and j are in Rf, we have l= ( ̄α, α, d′) ∈Rf. Let f ′′(r1, r2) =\nf(r1, r2, d3, . . . , dk). Then f ′′ does not have affine support (since e, g and lare in Rf but d\nis not) so we finish by induction as in Case 3.\nLemma 11 showed that #CSP({f}) is #P-hard when f does not have affine support. The\nfollowing lemma gives another (rather technical, but useful) condition which implies that\n#CSP({f}) is #P-hard. We start with some notation. Let f be an arity-k function. For a\nvalue b ∈{0, 1}, an index i ∈{1, . . . , k}, and a tuple y ∈{0, 1}k−1, let yi=b denote the tuple\nx ∈{0, 1}k formed by setting xi = b and xj = yj (j ∈{1, . . . , k} \\ {i}).\nWe say that index i of f is useful if there is a tuple y such that f(yi=0) > 0 and f(yi=1) > 0.\nWe say that f is product-like if, for every useful index i, there is a rational number λi such\nthat, for all y ∈{0, 1}k−1,\nf(yi=0) = λif(yi=1).\n(2)\nIf every position i of f is useful then being product-like is the same as being of product type.\nHowever, being product-like is less demanding because it does not restrict indices that are\nnot useful.\nLemma 12. If f ∈F2 is not product-like then #CSP({f}) is #P-hard.\nProof. We’ll use Corollary 9 to prove hardness, following an argument from [9]. Choose a\nuseful index i so that there is no λi satisfying (2).\nSuppose f has arity k.\nLet A be the 2 × 2k−1 matrix such that for b ∈{0, 1} and\ny ∈{0, 1}k−1, Ab,y = f(yi=b). Let A′ = AAT .\nFirst, we show that Eval(A′) is #P-hard. Note that A′ is the following symmetric 2 × 2\nmatrix with non-negative rational entries."},{"paragraph_id":"p14","order":14,"text":"P\ny A2\n0,y\nP\ny A0,yA1,y\nP\ny A0,yA1,y\nP\ny A2\n1,y"},{"paragraph_id":"p15","order":15,"text":"="},{"paragraph_id":"p16","order":16,"text":"P\ny f(yi=0)2\nP\ny f(yi=0)f(yi=1)\nP\ny f(yi=0)f(yi=1)\nP\ny f(yi=1)2\n!\nSince index i is useful, all four entries of A′ are positive. To show that Eval(A′) is #P-hard\nby Corollary 9, we just need to show that its determinant is non-zero. By Cauchy-Schwartz,\nthe determinant is non-negative, and is zero only if λi exists, which have assumed not to be\nthe case. Thus Eval(A′) is #P-hard by Corollary 9.\nNow we reduce Eval(A′) to #CSP({f}). To do this, take an undirected graph G which\nis an instance of Eval(A′). Construct an instance Y of #CSP({f}). For every vertex v of G\nwe introduce a variable xv of Y . Also, for every edge e of G we introduce k −1 variables\nxe,1, . . . , xe,k−1 of Y . We introduce constraints in Y as follows. For each edge e = (v, v′) of G\nwe introduce constraints f(xv, xe,1, . . . , xe,k−1) and f(xv′, xe,1, . . . , xe,k−1) into Y , where we\nhave assumed, without loss of generality, that the first index is useful.\nIt is clear that Eval(A′) is exactly equal to the partition function of the #CSP({f})\ninstance Y .\nFor w ∈Q+, let Uw denote the unary function mapping 0 to 1 and 1 to w. Note that\nU0 = δ0, and U1 gives the constant (0-ary function) 1, occurrences of which leave the partition\nfunction unchanged. So, by Lemma 8, we can discard these constraints since they do not\n11"},{"paragraph_id":"p17","order":17,"text":"add to the complexity of the problem. Note, by the observation above about proportional\nfunctions, that the functions Uw include all unary functions except for δ1 and the constant 0.\nWe can discard δ1 by Lemma 8, and if the constant 0 function is in F, any instance I where\nit appears as a constraint has Z(I) = 0. So again we can discard these constraints since they\nnot add to the complexity of the problem.\nThus Uw will be called nontrivial if w /∈{0, 1}. Let ⊕k : {0, 1}k →{0, 1} be the arity-k\nparity function that is 1 iffits argument has an odd number of 1s. Let ¬⊕k : {0, 1}k →{0, 1}\nbe the function 1 −⊕k. The following lemma shows that even a simple function like ⊕3 can\nlead to intractable #CSP instances when it is combined with a nontrivial weight function Uλ.\nLemma 13. #CSP(⊕3, Uλ, δ0, δ1) and #CSP(¬⊕3, Uλ, δ0, δ1) are both #P-hard, for any pos-\nitive λ ̸= 1.\nProof. We give a reduction from computing the Weight Enumerator of a Linear Code, which\nwas shown to be #P-hard in Lemma 10. In what follows, it is sometimes convenient to view\n⊕k, δ0, etc., as relations as well as functions to {0, 1}.\nWe first argue that for any k, the relation ⊕k can be simulated by {⊕3, δ0, δ1}.\nFor\nexample, to simulate x1 ⊕· · · ⊕xk for k > 3, take new variables y, z and w and let m = ⌈k/2⌉\nand use x1 ⊕· · · ⊕xm ⊕y and xm+1 ⊕· · · ⊕xk ⊕z and y ⊕z ⊕w and δ0(w).\nSince {⊕3, δ0, δ1} can be used to simulate any relation ⊕k, we can use {⊕3, δ0, δ1} to\nsimulate an arbitrary system of linear equations over GF(2). In particular we can use them\nto simulate the subspace Υ of code words for a given generating matrix A.\nFinally, we can use Uλ to simulate the function which evaluates the weight enumerator on\nΥ. Then, since λ ̸= 0, 1, we can apply Lemma 10 to complete the argument. The same proof,\nwith minor modifications, applies to ¬⊕3.\nLemma 14. Suppose f ∈F2 is not of product type. Then, for any positive λ ̸= 1, there exists\na constant c, depending on f, such that #CSP({f, δ0, δ1, Uλ, Uc}) is #P-hard.\nProof. If f does not have affine support, the result follows by Lemma 11. So suppose f has\naffine support. Consider the underlying relation Rf, viewed as a table. The rows of the table\nrepresent the tuples of the relation. Let J be the set of columns on which the relation is not\nconstant. That is, if i ∈J then there is a row x with xi = 0 and a row y with yi = 1. Group\nthe columns in J into equivalence classes: two columns are equivalent iffthey are equal or\ncomplementary. Let k be the number of equivalence classes. Take one column from each of\nthe k equivalence classes as a representative, and focus on the arity-k relation R induced by\nthose columns.\nCase 1: Suppose R is the complete relation of arity k.\nLet f ∗be the projection of f onto the k columns of R. By Lemma 6,\n#CSP({f ∗}) ≤T #CSP({f}) ≤T #CSP({f, δ0, δ1, Uλ, Uc}).\nWe will argue that #CSP({f ∗}) is #P-hard. To see this, note that every column of f ∗is\nuseful. Thus, if f ∗were product-like, we could conclude that f ∗was of product type. But\nthis would imply that f is of product type, which is not the case by assumption. So f ∗is not\nproduct-like and hardness follows from Lemma 12.\nCase 2: Suppose R is not the complete relation of arity k.\nWe had assumed that Rf is affine. This means that given three vectors, x, y and z, in Rf,\nx ⊕y ⊕z is in Rf as well. The arity-k relation R inherits this property, so is also affine.\n12"},{"paragraph_id":"p18","order":18,"text":"Choose a minimal set of columns of R that do not induce the complete relation. This exists\nby assumption. Suppose there are j columns in this minimal set. Observe that j ̸= 1 because\nthere are no constant columns in J. Also j ̸= 2, since otherwise the two columns would be\nrelated by equality or disequality, contradicting the preprocessing step. The argument here\nis that on two columns, R cannot have exactly three tuples because it is affine, and having\ntuples x, y and z in would require the fourth tuple x ⊕y ⊕z. But if it has two tuples then,\nbecause there are no constant columns, the only possibilities are either (0, 0) and (1, 1), or\n(0, 1) and (1, 0). Both contradict the preprocessing step, so j ≥3.\nLet R′ be the restriction of R to the j columns. Now R′ of course has fewer than 2j rows,\nand at least 2j−1 by minimality. It is affine, and hence must be ⊕j or ¬⊕j. To see this, first\nnote that the size of R′ has to be a power of 2 since R′ is the solution to a system of linear\nequations. Hence the size of R′ must be 2j−1. Then, since there are j variables, there can\nonly be one defining equation. And, since every subset of j −1 variables induces a complete\nrelation, this single equation must involve all variables. Therefore, the equation is ⊕j or ¬⊕j.\nLet f ′ be the projection of f onto the j columns just identified. Let f ′′ be further obtained\nby pinning all but three of the j variables to 0. Pinning j −3 variables to 0 leaves a single\nequation involving all three remaining variables. Thus Rf′′ must be ⊕3 or ¬⊕3.\nNow define the symmetric function f ′′′ by\nf ′′′(a, b, c) = f ′′(a, b, c)f ′′(a, c, b)f ′′(b, a, c)f ′′(b, c, a)f ′′(c, a, b)f ′′(c, b, a),\nNote that Rf′′′ is ⊕3 or ¬⊕3, since Rf′′ is symmetric and hence Rf′′′ = Rf′′.\nTo summarise: using f and the constant functions δ0 and δ1, we have simulated a function\nf ′′′ such that its underlying relation Rf′′′ is either ⊕3 or ¬⊕3. Furthermore, if triples x and y\nhave the same number of 1s then f ′′′(x) = f ′′′(y).\nWe can now simulate an unweighted version of ⊕3 or ¬⊕3 using f ′′′ and a unary function\nUc, with c set to a conveniently-chosen value. There are two cases. Suppose first that the\naffine support of f ′′′ is ¬⊕3. Then let w0 denote the value of f ′′′ when applied to the 3-tuple\n(0, 0, 0) and let w2 denote f ′′′(0, 1, 1) = f ′′′(1, 0, 1) = f ′′′(1, 1, 0).\nRecall that f ′′′(x) = 0\nfor any other 3-tuple x.\nNow let c = (w0/w2)1/2.\nNote from the definition of f ′′′ that\nw0 and w2 are squares of rational numbers, so c is also rational.\nDefine a function g of\narity 3 by g(α, β, γ) = Uc(α)Uc(β)Uc(γ)f ′′′(α, β, γ). Note that g(0, 0, 0) = w0 and g(0, 1, 1) =\ng(1, 0, 1) = g(1, 1, 0) = c2w2 = w0. Thus, g is a pure affine function with affine support ¬⊕3\nand range {0, w0}. The other case, in which the affine support of f ′′′ is ⊕3, is similar.\nWe have established a reduction from either #CSP(⊕3, Uλ, δ0, δ1) or #CSP(¬⊕3, Uλ, δ0, δ1),\nwhich are both #P-hard by Lemma 13.\nLemma 15. If f ∈F2 is not of product type, then #CSP({f, δ0, δ1, Uλ}) is #P-hard for any\npositive λ ̸= 1.\nProof. Take an instance I of #CSP({f, δ0, δ1, Uλ, Uc}), from Lemma 14, with n variables\nx1, x2, . . . , xn.\nWe want to compute the partition function Z(I) using only instances of\n#CSP({f, δ0, δ1, Uλ}). That is, instances which avoid using constraints Uc. For each i, let mi\ndenote the number of copies of Uc that are applied to xi, and let m = Pn\ni=1 mi. Then we can\nwrite the partition function as Z(I) = Z(I; c) where\nZ(I; w) =\nX\nσ∈{0,1}n\nˆZ(σ)\nY\ni:σi=1\nwmi =\nX\nσ∈{0,1}n\nˆZ(σ)w\nPn\ni=1 miσi,\n13"},{"paragraph_id":"p19","order":19,"text":"where ˆZ(σ) denotes the value corresponding to the assignment σ(xi) = σi, ignoring constraints\napplying Uc, and w is a variable. So ˆZ(σ) is the weight of σ, taken over all constraints other\nthan those applying Uc. Note also that Z(I; w) is a polynomial of degree m in w. We can\nevaluate Z(I; w) at the point w = λj by replacing each Uc constraint with j copies of a Uλ\nconstraint.\nThis evaluation is an instance of #CSP({f, δ0, δ1, Uλ}). So, using m different\nvalues of j and interpolating, we learn the coefficients of the polynomial Z(I; w). Then we\ncan put w = c to evaluate Z(I).\nLemma 16. Suppose f ∈F2 is not of product type, and g ∈F2 is not pure affine. Then\n#CSP({f, g, δ0, δ1}) is #P-hard.\nProof. If g does not have affine support we are done by Lemma 11. So suppose that g has\naffine support. Since g is not pure affine, the range of g contains at least two non-zero values.\nThe high-level idea will be to use pinning and bisection to extract a non-trivial unary\nweight function Uλ from g. Then we can reduce from #CSP({f, δ0, δ1, Uλ}), which we proved\n#P-hard in Lemma 15.\nLook at the relation Rg, viewed as a table. If every column were constant, then g would\nbe pure affine, so this is not the case. Select a non-constant column with index h. If there\nare two non-zero values in the range of g amongst the rows of Rg that are 0 in column h\nthen we derive a new function g′ by pinning column h to 0.\nThe new function g′ is not\npure affine, since the two non-zero values prevent this.\nSo we will show inductively that\n#CSP({f, g′, δ0, δ1}) is #P-hard. This will give the result since #CSP({f, g′, δ0, δ1}) trivially\nreduces to #CSP({f, g, δ0, δ1}).\nIf we don’t finish this way, or symmetrically by pinning column h to 1, then we know\nthat there are distinct positive values w0 and w1 such that, for every row x of Rg with 0 in\ncolumn h, g(x) = w0 and, for every row x of Rg with 1 in column h, g(x) = w1. Now note\nthat, because the underlying relation Rg is affine, it has the same number of 0’s in column h\nas 1’s. This is because Rg is the solution of a set of linear equations. Adding the equation\nxh = 0 or xh = 1 exactly halves the set of solutions in either case. We now project onto the\nindex set {h}. We obtain the unary weight function Uλ, with λ = w1/w0, on using the earlier\nobservation about proportional functions. This was our goal, and completes the proof.\nLemma 5 now follows from Lemma 8 and Lemma 16, completing the proof of Theorem 4.\nReferences\n[1] G. Brightwell and P. Winkler, Graph homomorphisms and phase transitions, Journal of\nCombinatorial Theory (Series B) 77 (1999), 221–262\n[2] A. Bulatov and V. Dalmau, Towards a dichotomy theorem for the counting constraint\nsatisfaction problem, in Proc. 44th Annual IEEE Symposium on Foundations of Computer\nScience, 2003, pp. 562–573.\n[3] D. Cohen, M. Cooper, P. Jeavons and A. Krokhin, The complexity of soft constraint\nsatisfaction, Artificial Intelligence 170 (2006), 983–1016.\n[4] A. Bulatov and M. Grohe, The complexity of partition functions, Theoretical Computer\nScience 348 (2005), 148–186.\n14"},{"paragraph_id":"p20","order":20,"text":"[5] B. Cipra, An Introduction to the Ising Model, American Mathematical Monthly 94 (1987),\n937–959.\n[6] N. Creignou and M. Hermann, Complexity of generalized satisfiability counting problems,\nInformation and Computation 125 (1996), 1–12.\n[7] N. Creignou, S. Khanna, M. Sudan, Complexity classifications of Boolean constraint sat-\nisfaction problems, SIAM Press, 2001.\n[8] M. Dyer and C. Greenhill, The complexity of counting graph homomorphisms, Random\nStructures and Algorithms 17 (2000), 260–289.\n[9] M. Dyer, L.A. Goldberg and M. Paterson, On counting homomorphisms to directed acyclic\ngraphs, in Proc. 33rd International Colloquium on Automata, Languages and Program-\nming, Lecture Notes in Computer Science 4051, Springer, 2006, pp. 38–49.\n[10] T. Feder and M. Vardi, The computational structure of monotone monadic SNP and\nconstraint satisfaction: a study through Datalog and group theory, SIAM Journal on\nComputing 28 (1999), 57–104.\n[11] L.A.\nGoldberg\nand\nM.\nJerrum,\nInapproximability\nof\nthe\nTutte\npolynomial,\nhttp://arxiv.org/abs/cs.CC/0605140, 2006.\n[12] C. Greenhill, The complexity of counting colourings and independent sets in sparse\ngraphs and hypergraphs, Computational Complexity 9 (2000), 52–72.\n[13] P. Hell and J. Neˇsetˇril, On the complexity of H-coloring, Journal of Combinatorial\nTheory (Series B) 48 (1990), 92–110.\n[14] P. Hell and J. Neˇsetˇril, Graphs and homomorphisms, Oxford University Press, 2004.\n[15] L. Lov ́asz, Operations with structures, Acta Mathematica Hungarica 18 (1967), 321–328.\n[16] R. Ladner, On the structure of polynomial time reducibility, Journal of the Association\nfor Computing Machinery 22 (1975), 155–171.\n[17] C. Papadimitriou, Computational complexity, Addison-Wesley, 1994.\n[18] F. Rossi, P. van Beek and T. Walsh (Eds.), Handbook of constraint programming, Elsevier,\n2006.\n[19] T. Schaefer, The complexity of satisfiability problems, in Proc. 10th Annual ACM Sym-\nposium on Theory of Computing, ACM Press, 1978, pp. 216–226.\n[20] A. Scott and G. Sorkin, Polynomial constraint satisfaction: a framework for counting\nand sampling CSPs and other problems, http://arxiv.org/abs/cs/0604079.\n[21] J. Schwartz, Fast probabilistic algorithms for verification of polynomial identities, Jour-\nnal of the Association for Computing Machinery 27 (1980), 701–717.\n[22] L. Valiant, The complexity of enumeration and reliability problems, SIAM Journal on\nComputing 8 (1979), 410–421.\n[23] D. Welsh, Complexity: knots, colourings and counting, LMS Lecture Note Series, vol. 186,\nCambridge University Press, 1993.\n15"},{"paragraph_id":"p21","order":21,"text":"4\nAppendix\nThe purpose of this appendix is to prove Lemma 7 for an arbitrary fixed domain [q]. We\nused only the special case q = 2, which we stated and proved as Lemma 8. However, pinning\nappears to be a useful technique for studying the complexity of #CSP, so we give a proof of\nthe general Lemma 7, which we believe will be applicable elsewhere.\nLemma 7. For every F ⊆Fq, #CSP(F ∪S\nc∈[q] δc) ≤T #CSP(F).\nIn order to prove the lemma, we introduce a useful, but less natural, variant of #CSP.\nSuppose F ⊆Fq. An instance I of #CSP̸=(F) consists of a set V of variables and a set C of\nconstraints, just like an instance of #CSP(F). In addition, the instance may contain a single\nextra constraint C applying the arity-q disequality relation χ̸= with scope (vC,1, . . . , vC,q).\nThe disequality relation χ̸= is defined by χ̸=(x1, . . . , xq) = 1 if x1, . . . , xq ∈[q] are pairwise\ndistinct. That is, if they are a permutation of the domain [q]. Otherwise, χ̸=(x1, . . . , xq) = 0.\nLemma 7 follows immediately from Lemma 17 and 18 below.\nLemma 17. For every F ⊆Fq, #CSP(F ∪S\nc∈[q] δc) ≤T #CSP̸=(F).\nProof. We follow the proof lines of Lemma 8, but instead of subtracting the contribution\ncorresponding to configurations in which some ti’s get the same value, we use the disequality\nrelation to restrict the partition function to configurations in which they get distinct values.\nSay that F is symmetric if it is the case that for every arity-k function f ∈F and every\ntuple x ∈[q]k and every permutation π : [q] →[q], f(x1, . . . , xk) = f(π(x1), . . . , π(xk)).\nLet I be an instance of #CSP(F ∪S\nc∈[q] δc) with variable set V . Let Vc be the set of\nvariables v ∈V to which the constraint δc(v) is applied. Assume without loss of generality\nthat the sets Vc are pairwise disjoint. Let Vq = V \\ S\nc∈[q] Vc. We construct an instance I′ of\n#CSP̸=(F). The instance has variables Vq ∪{t0, . . . , tq−1}. Every constraint C of I involving\na function f ∈F corresponds to a constraint C′ of I′. Here C′ is the same as C except that\nvariables in Vc are replaced with tc, for each c ∈[q]. Also, we add a new disequality constraint\nto the new variables t0, . . . , tq−1.\nCase 1. F is symmetric:\nBy construction, Z(I′) = P\ny0,...,yq−1 Z(I′ | σ(t0) = y0, . . . , σ(tq−1) = yq−1), where the sum\nis over all permutations y0, . . . , yq−1 of [q]. By symmetry, the summands are all the same, so\nZ(I′) = q!Z(I′ | σ(t0) = 0, . . . , σ(tq−1) = q −1) = q!Z(I).\nCase 2. F is not symmetric:\nSay that two permutations π1 : [q] →[q] and π2 : [q] →[q] are equivalent if, for every\nf ∈F and every tuple x ∈[q]k, f(π1(x1), . . . , π1(xk)) = f(π2(x1), . . . , π2(xk)). Partition the\npermutations π : [q] →[q] into equivalence classes. Let h be the number of equivalence classes\nand ni be the size of the i’th equivalence class, so n1 + · · · + nh = q!.6 Let {π1, . . . , πh} be\na set of representatives of the equivalence classes with π1 being the identity. We know that\nn1 ̸= q! since F is not symmetric.\nFor a positive integer lwe will now build an instance I′\nlby adding new constraints to I′.\nFor each πi other than π1 we add constraints as follows. Choose a function fi ∈F and a tuple y\nsuch that fi(y1, . . . , yk) ̸= fi(πi(y1), . . . , πi(yk)). If fi(y1, . . . , yk) > fi(πi(y1), . . . , πi(yk)) then\ndefine the k-tuple xi by (xi\n1, . . . , xi\nk) = (y1, . . . , yk).\nOtherwise, let n be the order of the\n6In fact, it can be shown that these equivalence classes are cosets of the symmetry group of f, and hence\nare of equal size, though we do not use this fact here.\n16"},{"paragraph_id":"p22","order":22,"text":"permutation πi and let gr denote fi(πr\ni (y1), . . . , πr\ni (yk)). Since g0 < g1 and gn = g0 there\nexists a ξ ∈{1, . . . , n −1} such that gξ > gξ+1. Let (xi\n1, . . . , xi\nk) = (πξ(y1), . . . , πξ(yk)) so\nfi(xi\n1, . . . , xi\nk) > fi(πi(xi\n1), . . . , πi(xi\nk)).\nLet wij denote fi(πj(xi\n1), . . . , πj(xi\nk)) so, since π1 is the identity, we have just ensured that\nwi1 > wii. Let si = (txi\n1, . . . , txi\nk), and let 0 ≤zi ≤h (i = 2, . . . , h) be positive integers, which\nwe will determine below. Add lzi new constraints to I′\nlwith relation fi and scope si. Let\nλi = Qh\nγ=2 wzγ\nγi . Note that, given σ(t0) = πi(0), . . . , σ(tq−1) = πi(q −1), the contribution to\nZ(I′\nl) for the new constraints is\nh\nY\nγ=2\nfγ(σ(txγ\n1), . . . , σ(txγ\nk))zγl=\nh\nY\nγ=2\nfγ(πi(xγ\n1), . . . , πi(xγ\nk))zγl=\nh\nY\nγ=2\nwzγl\nγ,i ="},{"paragraph_id":"p23","order":23,"text":"h\nY\nγ=2\nwzγ\nγ,i\n l\n= λil.\nSo\nZ(I′\nl) =\nh\nX\ni=1\nni Z( I′ | σ(t0) = πi(0), . . . , σ(tq−1) = πi(q −1) ) λl\ni.\nWe have ensured that λ1 > 0, since wi1 > wii ≥0, so wi1 > 0 for all i = 2, . . . , h. We now\nchoose the zi’s so that λi ̸= λ1 for all i = 2, . . . , h. If wγi = 0 for any γ = 2, . . . , h, we have\nλi = 0 and hence λi ̸= λ1. Thus we will assume, without loss of generality, that wγi > 0 for\nall γ = 2, . . . , h and i = 2, . . . , h′, where h′ ≤h. Then we have\nλi\nλ1\n=\nh\nY\nγ=2\n wγi\nwγ1\n zγ = e\nPh\nγ=2 αγizγ\n(i = 2, . . . , h′),\nwhere αγi = ln(wγi/wγ1). Note that αii < 0, since wii < wi1. We need to find an integer\nvector z = (z2, . . . , zh) so that none of the linear forms Li(z) = Ph\nγ=2 αγizγ is zero, for\ni = 2, . . . , h′.\nWe do this using a proof method similar to the Schwartz-Zippel Lemma.\n(See, for example, [21].) None of the Li(z) is identically zero, since αii ̸= 0. Consider the\ninteger vectors z ∈[h]h−1. At most hh−2 of these can make Li(z) zero for any i, since the\nequation Li(z) = 0 makes zi a linear function of zγ (γ ̸= i). Therefore there are at most\n(h′ −1)hh−2 < hh−1 such z which make any Li(z) zero. Therefore there must be a vector\nz ∈[h]h−1 for which none of the Li(z) is zero, and this is the vector we require.\nNow, by combining terms with equal λi and ignoring terms with λi = 0, we can view\nZ(I′\nl) as a sum Z(I′\nl) = P\ni ciλl\ni where the λi’s are positive and pairwise distinct and\nc1 = n1Z(I′ | σ(t0) = 0, . . . , σ(tq−1) = q −1).\nThus, by Lemma 3.2 of [8] we can interpolate to recover c1. Dividing by n1, we get\nZ(I′ | σ(t0) = 0, . . . , σ(tq−1) = q −1) = Z(I).\nLemma 18. For every F ⊆Fq, #CSP̸=(F) ≤T #CSP(F).\nProof. We use M ̈obius inversion for posets, following the lines of the proof of [2, Theorem 8].7\nConsider the set of partitions of [q].\nLet 0 denote the partition with q singleton classes.\nConsider the partial order in which η ≤θ iffevery class of η is a subset of some class\n7Lov ́asz [15] had previously used M ̈obius inversion in a similar context.\n17"},{"paragraph_id":"p24","order":24,"text":"of θ. Define μ(0) = 1 and for any θ ̸= 0 define μ(θ) = −P\nη≤θ,η̸=θ μ(η). Consider the sum\nP\nη≤θ μ(η). Clearly, this sum is 1 if θ = 0. From the definition of μ, it is also easy to see that\nthe sum is 0 otherwise, since\nX\nη≤θ\nμ(η) = μ(θ) +\nX\nη≤θ,η̸=θ\nμ(η) = 0.\nNow let I be an instance of #CSP̸=(F) with a disequality constraint applied to variables\nt0, . . . , tq−1. Let V be the set of variables of I. Given a configuration σ : V →[q], let θ(σ)\nbe the partition of [q] induced by of (σ(t0), . . . , σ(tq−1)). Thus i and j in [q] are in the same\nclass of θ(σ) iffσ(ti) = σ(tj). We say that a partition η is consistent with σ (written η ≼σ)\nif η ≤θ(σ). Note that η ≼σ means that for any i and j in the same class of η, σ(ti) = σ(tj).\nLet Ωbe the set of configurations σ that satisfy all constraints in I except possibly the\ndisequality constraint. Then Z(I) = P\nσ∈Ωw(σ)1σ, where 1σ = 1 if σ respects the disequality\nconstraint, meaning that θ(σ) = 0, and 1σ = 0 otherwise. By the M ̈obius inversion formula\nderived above,\nZ(I) =\nX\nσ∈Ω\nw(σ)\nX\nη≤θ(σ)\nμ(η).\nChanging the order of summation, we get\nZ(I) =\nX\nη\nμ(η)\nX\nη≤θ\nX\nσ∈Ω:θ(σ)=θ\nw(σ) =\nX\nη\nμ(η)\nX\nσ∈Ω:η≼σ\nw(σ).\nNow note that P\nσ:η≼σ w(σ) is the partition function Z(Iη) of an instance Iη of #CSP(F).\nThe instance Iη is formed from I by ignoring the disequality constraint, and identifying\nvariables in t0, . . . , tq−1 whose indices are in the same class of η. Thus we can compute all\nthe Z(Iη) in #CSP(F). Finally, Z(I) = P\nη μ(η)Z(Iη), completing the reduction.\n18"}],"pages":[{"page":1,"text":"arXiv:0704.3683v2 [cs.CC] 19 Jun 2008\nThe Complexity of Weighted 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\n28 April 2008\nAbstract\nThis paper gives a dichotomy theorem for the complexity of computing the partition\nfunction of an instance of a weighted Boolean constraint satisfaction problem. The prob-\nlem is parameterised by a finite set F of non-negative functions that may be used to\nassign weights to the configurations (feasible solutions) of a problem instance. Classical\nconstraint satisfaction problems correspond to the special case of 0,1-valued functions.\nWe show that computing the partition function, i.e. the sum of the weights of all config-\nurations, is FP#P-complete unless either (1) every function in F is of “product type”, or\n(2) every function in F is “pure affine”. In the remaining cases, computing the partition\nfunction is in P.\n1\nIntroduction\nThis paper gives a dichotomy theorem for the complexity of the partition function of weighted\nBoolean constraint satisfaction problems. Such problems are parameterised by a set F of\nnon-negative functions that may be used to assign weights to configurations (solutions) of\nthe instance. These functions take the place of the allowed constraint relations in classical\nconstraint satisfaction problems (CSPs). Indeed, the classical setting may be recovered by\nrestricting F to functions with range {0, 1}. The key problem associated with an instance\nof a weighted CSP is to compute its partition function, i.e., the sum of weights of all its\nconfigurations. Computing the partition function of a weighted CSP may be viewed a gen-\neralisation of counting the number of satisfying solutions of a classical CSP. Many partition\nfunctions from statistical physics may be expressed as weighted CSPs.\nFor example, the\nPotts model [23] is naturally expressible as a weighted CSP, whereas in the classical frame-\nwork only the “hard core” versions may be directly expressed. (The hard-core version of the\nantiferromagnetic Potts model corresponds to graph colouring and the hard-core version of\nthe ferromagnetic Potts model is trivial — acceptable configurations colour the entire graph\nwith a single colour.) A corresponding weighted version of the decision CSP was investigated\nby Cohen, Cooper, Jeavons and Krokhin [3]. This results in optimisation problems.\n1"},{"page":2,"text":"We use #CSP(F) to denote the problem of computing the partition function of weighted\nCSP instances that can be expressed using only functions from F. We show in Theorem 4\nbelow that if every function f ∈F is “of product type” then computing the partition function\nZ(I) of an instance I can be done in polynomial time. Formal definitions are given later,\nbut the condition of being “of product type” is easily checked — it essentially means that\nthe partition function factors. We show further in Theorem 4 that if every function f ∈F is\n“pure affine” then the partition function of Z(I) can be computed in polynomial time. Once\nagain, there is an algorithm to check whether F is pure affine. For each other set F, we show\nin Theorem 4 that computing the partition function of a #CSP(F) instance is complete for\nthe class FP#P. The existence of algorithms for testing the properties of being purely affine\nor of product type means that the dichotomy is effectively decidable.\n1.1\nConstraint satisfaction\nConstraint Satisfaction, which originated in Artificial Intelligence, provides a general frame-\nwork for modelling decision problems, and has many practical applications. (See, for exam-\nple [18].) Decisions are modelled by variables, which are subject to constraints, modelling\nlogical and resource restrictions. The paradigm is sufficiently broad that many interesting\nproblems can be modelled, from satisfiability problems to scheduling problems and graph-\ntheory problems. Understanding the complexity of constraint satisfaction problems has be-\ncome a major and active area within computational complexity [7, 14].\nA Constraint Satisfaction Problem (CSP) typically has a finite domain, which we will\ndenote by [q] = {0, 1 . . . , q −1} for a positive integer q.1\nA constraint language Γ with\ndomain [q] is a set of relations on [q]. For example, take q = 2. The relation R = {(0, 0, 1),\n(0, 1, 0), (1, 0, 0), (1, 1, 1)} is a 3-ary relation on the domain {0, 1}, with four tuples.\nOnce we have fixed a constraint language Γ, an instance of the CSP is a set of variables\nV = {v1, . . . , vn} and a set of constraints. Each constraint has a scope, which is a tuple of\nvariables (for example, (v4, v5, v1)) and a relation from Γ of the same arity, which constrains\nthe variables in the scope. A configuration σ is a function from V to [q]. The configuration σ\nis satisfying if the scope of every constraint is mapped to a tuple that is in the corresponding\nrelation. In our example above, a configuration σ satisfies the constraint with scope (v4, v5, v1)\nand relation R if and only if it maps an odd number of the variables in {v1, v4, v5} to the\nvalue 1. Given an instance of a CSP with constraint language Γ, the decision problem CSP(Γ)\nasks us to determine whether any configuration is satisfying. The counting problem #CSP(Γ)\nasks us to determine the number of (distinct) satisfying configurations.\nVarying the constraint language Γ defines the classes CSP and #CSP of decision and\ncounting problems.\nThese contain problems of different computational complexities.\nFor\nexample, if Γ = {R1, R2, R3} where R1, R2 and R3 are the three binary relations defined\nby R1 = {(0, 1), (1, 0), (1, 1)}, R2 = {(0, 0), (0, 1), (1, 1)} and R3 = {(0, 0), (0, 1), (1, 0)}, then\nCSP(Γ) is the classical 2-Satisfiability problem, which is in P.\nOn the other hand, there\nis a similar constraint language Γ′ with four relations of arity 3 such that 3-Satisfiability\n(which is NP-complete) can be represented in CSP(Γ′). It may happen that the counting\nproblem is harder than the decision problem. If Γ is the constraint language of 2-Satisfiability\nabove, then #CSP(Γ) contains the problem of counting independent sets in graph, and is\n#P-complete [22], even if restricted to 3-regular graphs [12].\n1 Usually [q] is defined to be {1, 2, . . . , q}, but it is more convenient here to start the enumeration of domain\nelements at 0 rather than 1.\n2"},{"page":3,"text":"Any decision problem CSP(Γ) is in NP, but not every problem in NP can be represented\nas a CSP. For example, the question “Is G Hamiltonian?” cannot naturally be expressed\nas a CSP, because the property of being Hamiltonian cannot be captured by relations of\nbounded size. This limitation of the class CSP has an important advantage. If P ̸= NP,\nthen there are problems which are neither in P nor NP-complete [16]. But, for well-behaved\nsmaller classes of decision problems, the situation can be simpler. We may have a dichotomy\ntheorem, partitioning all problems in the class into those which are in P and those which\nare NP-complete. There are no “leftover” problems of intermediate complexity. It has been\nconjectured that there is a dichotomy theorem for CSP. The conjecture is that CSP(Γ) is\nin P for some constraint languages Γ, and CSP(Γ) is NP-complete for all other constraint\nlanguages Γ. This conjecture appeared in a seminal paper of Feder and Vardi [10], but has\nnot yet been proved.\nA similar dichotomy, between FP and #P-complete, is conjectured for #CSP [2]. The\ncomplexity classes FP and #P are the analogues of P and NP for counting problems. FP\nis simply the class of functions computable in deterministic polynomial time.\n#P is the\nclass of integer functions that can be expressed as the number of accepting computations of\na polynomial-time non-deterministic Turing machine. Completeness in #P is defined with\nrespect to polynomial-time Turing reducibility [17, Chap. 18]. Bulatov and Dalmau [2] have\nshown in one direction that, if #CSP(Γ) is solvable in polynomial time, then the constraints\nin Γ must have certain algebraic properties (assuming P ̸= #P). In particular, they must\nhave a so-called Mal’tsev polymorphism. The converse is known to be false, though it remains\npossible that the dichotomy (if it exists) does have an algebraic characterisation.\nThe conjectured dichotomies for CSP and #CSP are major open problems for computa-\ntional complexity theory. There have been many important results for subclasses of CSP and\n#CSP. We mention the most relevant to our paper here. The first decision dichotomy was\nthat of Schaefer [19], for the Boolean domain {0, 1}. Schaefer’s result is as follows.\nTheorem 1 (Schaefer [19]). Let Γ be a constraint language with domain {0, 1}. The problem\nCSP(Γ) is in P if Γ satisfies one of the conditions below. Otherwise, CSP(Γ) is NP-complete.\n(1) Γ is 0-valid or 1-valid.\n(2) Γ is weakly positive or weakly negative.\n(3) Γ is affine.\n(4) Γ is bijunctive.\nWe will not give detailed definitions of the conditions in Theorem 1, but the interested\nreader is referred to the paper [19] or to Theorem 6.2 of the textbook [7]. An interesting feature\nis that the conditions in [7, Theorem 6.2] are all checkable. That is, there is an algorithm\nto determine whether CSP(Γ) is in P or NP-complete, given a constraint language Γ with\ndomain {0, 1}. Creignou and Hermann [6] adapted Schaefer’s decision dichotomy to obtain a\ncounting dichotomy for the Boolean domain. Their result is as follows.\nTheorem 2 (Creignou and Hermann [6]). Let Γ be a constraint language with domain {0, 1}.\nThe problem #CSP(Γ) is in FP if Γ is affine. Otherwise, #CSP(Γ) is #P-complete.\nA constraint language Γ with domain {0, 1} is affine if every relation R ∈Γ is affine. A\nrelation R is affine if the set of tuples x ∈R is the set of solutions to a system of linear\nequations over GF(2). These equations are of the form v1 ⊕· · · ⊕vn = 0 and v1 ⊕· · · ⊕vn = 1\nwhere ⊕is the exclusive or operator. It is well known (see, for example, Lemma 4.10 of [7])\n3"},{"page":4,"text":"that a relation R is affine iffa, b, c ∈R implies d = a ⊕b ⊕c ∈R.\n(We will use this\ncharacterisation below.) There is an algorithm for determining whether a Boolean constraint\nlanguage Γ is affine, so there is an algorithm for determining whether #CSP(Γ) is in FP or\n#P-complete.\n1.2\nWeighted #CSP\nThe weighted framework of [4] extends naturally to Constraint Satisfaction Problems. Fix\nthe domain [q].\nInstead of constraining a length-k scope with an arity-k relation on [q],\nwe give a weight to the configuration on this scope by applying a function f from [q]k to\nthe non-negative rationals.\nLet Fq = {f : [q]k →Q+ | k ∈N} be the set of all such\nfunctions (of all arities).2 Given a function f ∈Fq of arity k, the underlying relation of f\nis given by Rf = {x ∈[q]k | f(x) ̸= 0}. It is often helpful to think of Rf as a table, with\nk columns corresponding to the positions of a k-tuple.\nEach row corresponds to a tuple\nx = (x1, . . . , xk) ∈Rf. The entry in row x and column j is xj, which is a value in [q].\nA weighted #CSP problem is parameterised by a finite subset F of Fq, and will be\ndenoted by #CSP(F). An instance I of #CSP(F) consists of a set V of variables and a\nset C of constraints. Each constraint C ∈C consists of a function fC ∈F (say of arity kC)\nand a scope, which is a sequence sC = (vC,1, . . . , vC,kC) of variables from V . The variables\nvC,1, . . . , vC,kC need not be distinct. As in the unweighted case, a configuration σ for the\ninstance I is a function from V to [q]. The weight of the configuration σ is given by\nw(σ) =\nY\nC∈C\nfC(σ(vC,1), . . . , σ(vC,kC)).\nFinally, the partition function Z(I) is given, for instance I, by\nZ(I) =\nX\nσ:V →[q]\nw(σ).\n(1)\nIn the computational problem #CSP(F), the goal is to compute Z(I), given an instance I.\nNote that an (unweighted) CSP counting problem #CSP(Γ) can be represented naturally\nas a weighted CSP counting problem.\nFor each relation R ∈Γ, let f R be the indicator\nfunction for membership in R.\nThat is, if x ∈R we set f R(x) = 1.\nOtherwise we set\nf R(x) = 0. Let F = {f R | R ∈Γ}. Then for any instance I of #CSP(Γ), the number of\nsatisfying configurations for I is given by the (weighted) partition function Z(I) from (1).\nThis framework has been employed previously in connection with graph homomorphisms [1].\nSuppose H = (Hij) is any symmetric square matrix H of rational numbers. We view H as\nbeing an edge-weighting of an undirected graph H, where a zero weight in H means that\nthe corresponding edge is absent from H. Given a (simple) graph G = (V, E) we consider\ncomputing the partition function\nZH(G) =\nX\nσ:V →[q]\nw(σ),\nwhere w(σ) =\nY\n{u,v}∈E\nHσ(u)σ(v).\nWithin our framework above, we view H as the binary function h : [q]2 →R, and the problem\nis then computing the partition function of #CSP({h}).\n2We assume 0 ∈N, so we allow non-negative constants.\n4"},{"page":5,"text":"Bulatov and Grohe [4] call H connected if H is connected and bipartite if H is bipartite.\nThey give the following dichotomy theorem for non-negative H.3\nTheorem 3 (Bulatov and Grohe [4]). Let H be a symmetric matrix with non-negative rational\nentries.\n(1) If H is connected and not bipartite, then computing ZH is in FP if the rank of H is at\nmost 1; otherwise computing ZH is #P-hard.\n(2) If H is connected and bipartite, then computing ZH is in FP if the rank of H is at most 2;\notherwise computing ZH is #P-hard.\n(3) If H is not connected, then computing ZH is in FP if each of its connected components\nsatisfies the corresponding conditions stated in (1) or (2); otherwise computing ZH is\n#P-hard.\nMany partition functions arising in statistical physics may be viewed as weighted #CSP\nproblems. An example is the q-state Potts model (which is, in fact, a weighted graph ho-\nmomorphism problem). In general, weighted #CSP is very closely related to the problem of\ncomputing the partition function of a Gibbs measure in the framework of Dobrushin, Lanford\nand Ruelle (see [1]). See also the framework of Scott and Sorkin [20].\n1.3\nSome Notation\nWe will call the class of (rational) weighted #CSP problems weighted #CSP. The sub-class\nhaving domain size q = 2 will be called weighted Boolean #CSP, and will be the main focus\nof this paper. We will give a dichotomy theorem for weighted Boolean #CSP.\nSince weights can be arbitrary non-negative rational numbers, the solution to these prob-\nlems is not an integer in general. Therefore #CSP(F) is not necessarily in the class #P.\nHowever, Goldberg and Jerrum [11] have observed that Z(I) = ̃Z(I)/K(I), where ̃Z is a\nfunction in #P and K(I) is a positive integer computable in FP. This follows because, for all\nf ∈F, we can ensure that f(·) = ̃f(·)/K(I), where ̃f(·) ∈N, by“clearing denominators”. The\ndenominator K(I) can obviously be computed in polynomial time, and it is straightforward\nto show that computing ̃Z(I) is in #P, so the characterisation of [11] follows. The resulting\ncomplexity class, comprising functions which are a function in #P divided by a function in\nFP, is named #PQ in [11], where it is used in the context of approximate counting. Clearly\nwe have\nweighted #CSP ⊆#PQ ⊆FP#P.\nOn the other hand, if Z(I) ∈weighted #CSP is #P-hard, then, using an oracle for computing\nZ(I), we can construct a #P oracle ̃Z(I) as outlined above.\n(Note that Z(I) /∈#P in\ngeneral.) Using this, we can compute any function in FP#P with a polynomial time-bounded\noracle Turing machine. Thus any #P-hard function in weighted #CSP is complete for FP#P.\nWe will use this observation to state our main result in terms of completeness for the class\nFP#P.\nWe make the following definition, which relates to the discussion above. We will say that\nF ⊆Fq simulates f ∈Fq if, for each instance I of #CSP(F ∪{f}), there is a polynomial time\ncomputable instance I′ of #CSP(F), such that Z(I) = φ(I)Z(I′) for some φ(I) ∈Q which is\nFP-computable. This generalises the notion of parsimonious reduction [17] among problems in\n3This is not quite the original statement of the theorem. We have chosen here to restrict all inputs to be\nrational, in order to avoid issues of how to represent, and compute with, arbitrary real numbers.\n5"},{"page":6,"text":"#P. We will use ≤T to denote the relation “is polynomial-time Turing-reducible to” between\ncomputational problems. Clearly, if F simulates f, we have #CSP(F ∪{f}) ≤T #CSP(F).\nNote also that, if ̃f = Kf, for some constant K > 0, then {f} simulates ̃f. Thus there is no\nneed to distinguish between “proportional” functions.\nWe use the following terminology for certain functions. Let χ= be the binary equality\nfunction defined on [q] as follows. For any element c ∈[q], χ=(c, c) = 1 and for any pair (c, d)\nof distinct elements of [q], χ=(c, d) = 0. Let χ̸= be the binary disequality function given by\nχ̸=(c, d) = 1 −χ=(c, d) for all c, d ∈[q].4 We say that a function f is of product type if f can\nbe expressed as a product of unary functions and binary functions of the form χ= and χ̸=.\nWe focus attention in this paper on the Boolean case, q = 2. In this case, we say that a\nfunction f ∈F2 has affine support if its underlying relation Rf, defined earlier, is affine. We\nsay that f is pure affine if it has affine support and range {0, w} for some w > 0. Thus a\nfunction is pure affine if and only if it is a positive real multiple of some (0,1-valued) function\nwhich is affine over GF(2).\n1.4\nOur Result\nOur main result is the following.\nTheorem 4. Suppose F ⊆F2 = {f : {0, 1}k →Q+ | k ∈N}. If every function in F is of\nproduct type then #CSP(F) is in FP. If every function in F is pure affine then #CSP(F) is\nin FP. Otherwise, #CSP(F) is FP#P-complete.\nProof. Suppose first that F is of product type. In this case the partition function Z(I) of\nan instance I with variable set V is easy to evaluate because it can be factored into easy-\nto-evaluate pieces: Partition the variables in V into equivalence classes according to whether\nor not they are related by an equality or disequality function. (The equivalence relation on\nvariables here is “depends linearly on”.) An equivalence class consists of two (possibly empty)\nsets of variables U1 and U2. All of the variables in U1 must be assigned the same value by a\nconfiguration σ of nonzero weight, and all variables in U2 must be assigned the other value.\nVariables in U1∪U2 are not related by equality or disequality to variables in V \\(U1∪U2). The\nequivalence class contributes one weight, say α, to the partition function if variables in U1\nare given value “0” by σ and it contributes another weight, say β, to the partition function\nif variables in U1 are given value “1” by σ. Thus, Z(I) = (α + β)Z(I′), where I′ is the\ninstance formed from I by removing this equivalence class. Therefore, suppose we choose any\nequivalence class and remove its variables. Since F contains only unary, equality or binary\ndisequality constraints, we can also remove all functions involving variables in U1 ∪U2 to give\nF′. Then I′ is of product type with fewer variables, so we may compute Z(I′) recursively.\nSuppose second that F if pure affine. Then Z(I) = Q\nf∈F wkf\nf Z(I′), where {0, wf} is the\nrange of f, kf is the number of constraints involving f in I, and I′ is the instance obtained\nfrom I by replacing every function f by its underlying relation Rf (viewed as a function with\nrange {0, 1}). Z(I′) is easy to evaluate, because this is just counting solutions to a linear\nsystem over GF(2), as Creignou and Hermann have observed [6].\nFinally, the #P-hardness in Theorem 4 follows from Lemma 5 below.\nLemma 5. If f ∈F2 is not of product type and g ∈F2 is not pure affine then #CSP({f, g})\nis #P-hard.\n4A more general disequality function is defined in the Appendix.\n6"},{"page":7,"text":"Note that the functions f and g in Lemma 5 may be one and the same function. So\n#CSP({f}) is #P-hard when f is not of product type nor pure affine. The rest of this article\ngives the proof of Lemma 5.\n2\nUseful tools for proving hardness of #CSP\n2.1\nNotation\nFor any sequence u1, . . . , uk of variables of I and any sequence c1, . . . , ck of elements of the\ndomain [q], we will let Z(I | σ(u1) = c1, . . . , σ(uk) = ck) denote the contribution to Z(I) from\nassignments σ with σ(u1) = c1, · · · , σ(uk) = ck.\n2.2\nProjection\nThe first tool that we study is projection, which is referred to as “integrating out” in the\nstatistical physics literature.\nLet f be a function of arity k, and let J = {j1, . . . , jr} be a size-r subset of {1, . . . , k},\nwhere j1 < · · · < jr.5 We say that a k-tuple x′ ∈[q]k extends an r-tuple x ∈[q]r on J (written\nx′ ⊒J x) if x′ agrees with x on indices in J; that is to say, x′\nji = xi for all 1 ≤i ≤r. The\nprojection g of f onto J is defined as follows. For every x ∈[q]r, g(x) = P\nx′⊒Jx f(x′).\nThe following lemma may be viewed as a weighted version of Proposition 2 of [2], where\nit is proved for the unweighted case. It is expressed somewhat differently in [2], in terms of\ncounting the number of solutions to an existential formula.\nLemma 6. Suppose F ⊆Fq. Let g be a projection of a function f ∈F onto a subset of its\nindices. Then #CSP(F ∪{g}) ≤T #CSP(F).\nProof. Let k be the arity of f and let g be the projection of f onto the subset J of its indices.\nLet I be an instance of #CSP(F ∪{g}). We will construct an instance I′ of #CSP(F) such\nthat Z(I) = Z(I′). The instance I′ is identical to I except that every constraint C of I\ninvolving g is replaced with a new constraint C′ of I′ involving f. The corresponding scope\n(vC′,1, . . . , vC′,k) is constructed as follows. If jlis the l’th element of J, then v′\nC′,jl= vC,l. The\nother variables, vC′,j (j /∈J), are distinct new variables. We have shown that F simulates g\nwith φ(I) = 1.\n2.3\nPinning\nFor c ∈[q], δc denotes the unary function with δc(c) = 1 and δc(d) = 0 for d ̸= c. The\nfollowing lemma, which allows “pinning” CSP variables to specific values in hardness proofs,\ngeneralises Theorem 8 of [2], which does the unweighted case. Again [2] employs different\nterminology, and its theorem is a statement about the full idempotent reduct of a finite\nalgebra. The idea of pinning was used previously by Bulatov and Grohe of [4] in the context\nof counting weighted graph homomorphisms (see Lemma 32 of [4]). A similar idea was used\nby Dyer and Greenhill in the context of counting unweighted graph homomorphisms — in\nthat context, Theorem 4.1 of [8] allows pinning all variables to a particular component of the\ntarget graph H.\n5It is not necessary to choose this particular ordering for J, but it is convenient to do so.\n7"},{"page":8,"text":"Lemma 7. For every F ⊆Fq, #CSP(F ∪S\nc∈[q] δc) ≤T #CSP(F).\nThe proof of Lemma 7 is deferred to the appendix. Since we only use the case q = 2 in\nthis paper, we provide the (simpler) proof for the Boolean case here.\nLemma 8. For every F ⊆F2, #CSP(F ∪{δ0, δ1}) ≤T #CSP(F).\nProof. For x ∈[2]k, let x be the k-tuple whose i’th component, xi, is xi ⊕1, for all i. Say\nthat F is symmetric if it is the case that for every arity-k function f ∈F and every x ∈[2]k,\nf(x) = f(x).\nGiven an instance I of #CSP(F ∪{δ0, δ1}) with variable set V we consider two instances\nI′ and I′′ of #CSP(F). Let V0 be the set of variables v of I to which the constraint δ0(v) is\napplied. Let V1 be the set of variables v of I to which the constraint δ1(v) is applied. We\ncan assume without loss of generality that V0 and V1 do not intersect. (Otherwise, Z(I) = 0\nand we can determine this without using an oracle for #CSP(F).) Let V2 = V \\ (V0 ∪V1).\nThe instance I′ has variables V2 ∪{t0, t1} where t0 and t1 are distinct new variables that are\nnot in V . Every constraint C of I involving a function f ∈F corresponds to a constraint C′\nof I′. C′ is the same as C except that variables in V0 are replaced with t0 and variables\nin V1 are replaced with t1. Similarly, the instance I′′ has variables V2 ∪{t} where t is a new\nvariable that is not in V . Every constraint C of I involving a function f ∈F corresponds to\na constraint C′′ of I′′. The constraint C′′ is the same as C except that variables in V0 ∪V1\nare replaced with t.\nCase 1. F is symmetric:\nBy construction,\nZ(I′) −Z(I′′) = Z(I′ | σ(t0) = 0, σ(t1) = 1) + Z(I′ | σ(t0) = 1, σ(t1) = 0).\nBy symmetry, the summands are the same, so\nZ(I′) −Z(I′′) = 2Z(I′ | σ(t0) = 0, σ(t1) = 1) = 2Z(I).\nCase 2. F is not symmetric:\nLet f be an arity-k function in F and let x ∈[2]k so that\nf(x) > f(x) ≥0. Let s = (tx1, . . . , txk) and let I′\nx be the instance derived from I′ by adding a\nnew constraint with function f and scope s. Similarly, let I′′\nx be the instance derived from I′′\nby adding a new constraint with function f and scope (t, . . . , t). Now\nZ(I′\nx) = Z(I′ | σ(t0) = 0, σ(t1) = 1)f(x) + Z(I′ | σ(t0) = 1, σ(t1) = 0)f(x)\n+ Z(I′ | σ(t0) = 0, σ(t1) = 0)f(0, . . . , 0) + Z(I′ | σ(t0) = 1, σ(t1) = 1)f(1, . . . , 1)\n= Z(I′ | σ(t0) = 0, σ(t1) = 1)f(x) + Z(I′ | σ(t0) = 1, σ(t1) = 0)f(x) + Z(I′′\nx).\nThus we have two independent equations,\nZ(I′\nx) −Z(I′′\nx) = Z(I′ | σ(t0) = 0, σ(t1) = 1)f(x) + Z(I′ | σ(t0) = 1, σ(t1) = 0)f(x),\nZ(I′) −Z(I′′) = Z(I′ | σ(t0) = 0, σ(t1) = 1)\n+ Z(I′ | σ(t0) = 1, σ(t1) = 0)\n,\nin the unknowns Z(I′ | σ(t0) = 0, σ(t1) = 1) and Z(I′ | σ(t0) = 1, σ(t1) = 0). Solving these,\nwe obtain the value of Z(I′ | σ(t0) = 0, σ(t1) = 1) = Z(I).\n8"},{"page":9,"text":"2.4\n#P-hard problems\nTo prove Lemma 5, we will give reductions from some known #P-hard problems. The first of\nthese is the problem of counting homomorphisms from simple graphs to 2-vertex multigraphs.\nWe use the following special case of Bulatov and Grohe’s Theorem 3.\nCorollary 9 (Bulatov and Grohe [4]). Let H be a symmetric 2 × 2 matrix with non-negative\nreal entries. If H has rank 2 and at most one entry of H is 0 then Eval(H) is #P-hard.\nWe will also use the problem of computing the weight enumerator of a linear code. Given a\ngenerating matrix A ∈{0, 1}r×C of rank r, a code word c is any vector in the linear subspace Υ\ngenerated by the rows of A over GF(2). For any real number λ, the weight enumerator of the\ncode is given by WA(λ) = P\nc∈Υ λ∥c∥, where ∥c∥is the number of 1’s in c. The problem of\ncomputing the weight enumerator of a linear code is in FP for λ ∈{−1, 0, 1}, and is known to\nbe #P-hard for every other fixed λ ∈Q (see [23]). We could not find a proof, so we provide\none here. We restrict attention to positive λ, since that is adequate for our purposes.\nLemma 10. Computing the Weight Enumerator of a Linear Code is #P-hard for any fixed\npositive rational number λ ̸= 1.\nProof. We will prove hardness by reduction from a problem Eval(H), for some appropriate H,\nusing Corollary 9. Let the input to Eval(H) be a connected graph G = (V, E) with V =\n{v1, . . . , vn} and E = {e1, . . . , em}. Let B be the n × m incidence matrix of G, with bij = 1\nif vi ∈ej and bij = 0 otherwise. Let A be the (n −1) × m matrix which is B with the row\nfor vn deleted. A will be the generating matrix of the Weight Enumerator instance, with\nr = n −1 and C = m. It has rank (n −1) since G contains a spanning tree. A code word\nc has cj = L\ni∈U bij, where U ⊆V \\ {vn}. Thus cj = 1 if and only if ej has exactly one\nendpoint in U, and the weight of c is λk, where k is the number of edges in the cut U, V \\ U.\nThus WA(λ) = 1\n2ZH(G), where H is the symmetric weight matrix with H11 = H22 = 1 and\nH12 = H21 = λ. The 1\n2 arises because we fixed which side of the cut contains vn. Now H\nhas rank 2 unless λ = 1, so this problem is #P-hard by Corollary 9. Note, by the way, that\nZH(G) is the partition function of the Ising model in statistical physics [5].\n3\nThe Proof of Lemma 5\nThroughout this section, we assume q = 2. The following Lemma is a generalisation of a result\nof Creignou and Hermann [6], which deals with the case in which f is a relation (or, in our\nsetting, a function with range {0, 1}). The inductive technique used in the proof of Lemma 11\n(combined with the follow-up in Lemma 12) is good for showing that #CSP(F) is #P-hard\nwhen F contains a single function. A very different situation arises when #CSP({f}) and\n#CSP({g}) are in FP but #CSP({f, g}) is #P-hard due to interactions between f and g —\nwe deal with that problem later.\nLemma 11. Suppose that f ∈F2 does not have affine support. Then #CSP({f}) is #P-hard.\nProof. Let k be the arity of f, and let us denote the ith component of k-tuple a ∈Rf by ai.\nThe proof is by induction on k. The lemma is trivially true for k = 1, since all functions of\narity 1 have affine support.\n9"},{"page":10,"text":"For k = 2, we note that since Rf is not affine, it is of the form Rf = {(α, β), ( ̄α, β), ( ̄α, ̄β)}\nfor some α ∈{0, 1} and β ∈{0, 1}. We can show that #CSP({f}) is #P-hard by reduction\nfrom Eval(H) using\nH =\n f(0, 0)\nf(0, 1)\nf(1, 0)\nf(1, 1)\n \n,\nwhich has rank 2 and exactly one entry that is 0. Given an instance G = (V, E) of Eval(H)\nwe construct an instance I of #CSP({f}) as follows. The variables of I are the vertices of G.\nFor each edge e = (u, v) of G, add a constraint with function f and variable sequence u, v.\nCorollary 9 now tells us that Eval(H) is #P-hard, so #CSP({f}) is #P-hard.\nSuppose k > 2.\nWe start with some general arguments and notation.\nFor any i ∈\n{1, . . . , k} and any α ∈{0, 1} let f i=α be the function of arity k −1 derived from f by pinning\nthe i’th position to α. That is, f i=α(x1, . . . , xk−1) = f(x1, . . . , xi−1, α, xi+1, . . . , xk). Also,\nlet f i=∗be the projection of f onto all positions apart from position i (see Section 2.2).\nNote that #CSP({f i=α}) ≤T #CSP({f, δ0, δ1}), since f i=α can obviously be simulated by\n{f, δ0, δ1}.\nFurthermore, by Lemma 8, #CSP({f, δ0, δ1}) ≤T #CSP({f}).\nThus, we can\nassume that f i=α has affine support — otherwise, we are finished by induction. Similarly, by\nLemma 6, #CSP(\n \nf i=∗ \n) ≤T #CSP({f}). Thus we can assume that f i=∗has affine support\n— otherwise, we are finished by induction.\nNow, recall that Rf is not affine. Consider any a, b, c ∈Rf such that d = a ⊕b ⊕c /∈Rf.\nWe have 4 cases.\nCase 1:\nThere are indices 1 ≤i < j ≤k such that (ai, bi, ci) = (aj, bj, cj):\nWithout loss of generality, suppose i = 1 and j = 2. Define the function f ′ of arity (k −1) by\nf ′(r2, . . . , rk) = f(r2, r2, . . . , rk). Note that Rf′ is not affine since the condition a⊕b⊕c /∈Rf is\ninherited by Rf′. So, by induction, #CSP({f ′}) is #P-hard. Now note that #CSP({f ′}) ≤T\n#CSP({f}). To see this, note that any instance I1 of #CSP({f ′}) can be turned into an\ninstance I of #CSP({f}) by repeating the first variable in the sequence of variables for each\nconstraint.\nCase 2: There is an index 1 ≤i ≤k such that ai = bi = ci: Since d is not in Rf and\ndi = ai, we find that f i=ai does not have affine support, contrary to earlier assumptions.\nHaving finished Cases 1 and 2, we may assume without loss of generality that we are in\nCase 3 or Case 4 below, where {α, β} ∈{0, 1}, ̄α = 1 −α, ̄β = 1 −β and a′, b′, c′ ∈{0, 1}k−2.\nCase 3:\na = ( ̄α, ̄β, a′), b = ( ̄α, β, b′), c = (α, ̄β, c′): Since Rf1=∗is affine and a, b\nand c are in Rf, we must have either d = (α, β, d′) ∈Rf or e = ( ̄α, β, d′) ∈Rf, where\nd′ = a′ ⊕b′ ⊕c′. In the first case, we are done (we have contradicted the assumption that\nd ̸∈Rf), so assume that e ∈Rf but d ̸∈Rf.\nSimilarly, since Rf2=∗is affine, we may\nassume that g = (α, ̄β, d′) ∈Rf. Since Rf1= ̄α is affine and a, b and e are in Rf, we find\nthat h = a ⊕b ⊕e = ( ̄α, ̄β, c′) ∈Rf. Since Rf2= ̄β is affine and a, c and g are in Rf, we\nfind that i = ( ̄α, ̄β, b′) ∈Rf. Also, since Rf2= ̄β is affine and a, h and i are in Rf, we find\nthat j = ( ̄α, ̄β, d′) ∈Rf. Let f ′(r1, r2) = f(r1, r2, d3, . . . , dk). Since e, g and j are in Rf\nbut d is not, we have ( ̄α, β), (α, ̄β), ( ̄α, ̄β) ∈Rf′, but (α, β) /∈Rf′. Thus, f ′ does not have\naffine support and #CSP({f ′}) is #P-hard by induction. Also, #CSP({f ′}) ≤T #CSP({f})\nby Lemma 8.\nCase 4: a = ( ̄α, α, a′), b = ( ̄α, α, b′), c = (α, ̄α, c′): Since Rf1=∗is affine and a, b and c\nare in Rf but d is not, we have e = ( ̄α, ̄α, d′) ∈Rf. Similarly, since Rf2=∗is affine and a, b\nand c are in Rf but d is not, we have g = (α, α, d′) ∈Rf. Now since Rf1= ̄α is affine and a, b\nand e are in Rf, we have h = ( ̄α, ̄α, c′) ∈Rf. Also, since Rf2=α is affine and a, b and g are in\n10"},{"page":11,"text":"Rf, we have i = (α, α, c′) ∈Rf.\nLet f ′(r1, r2) = f(r1, r2, c3, . . . , ck). If j = ( ̄α, α, c′) ̸∈Rf then f ′ does not have affine\nsupport (since c, h and i are in Rf) so we finish by induction as in Case 3. Suppose j ∈Rf.\nSince Rf1= ̄α is affine and a, b and j are in Rf, we have l= ( ̄α, α, d′) ∈Rf. Let f ′′(r1, r2) =\nf(r1, r2, d3, . . . , dk). Then f ′′ does not have affine support (since e, g and lare in Rf but d\nis not) so we finish by induction as in Case 3.\nLemma 11 showed that #CSP({f}) is #P-hard when f does not have affine support. The\nfollowing lemma gives another (rather technical, but useful) condition which implies that\n#CSP({f}) is #P-hard. We start with some notation. Let f be an arity-k function. For a\nvalue b ∈{0, 1}, an index i ∈{1, . . . , k}, and a tuple y ∈{0, 1}k−1, let yi=b denote the tuple\nx ∈{0, 1}k formed by setting xi = b and xj = yj (j ∈{1, . . . , k} \\ {i}).\nWe say that index i of f is useful if there is a tuple y such that f(yi=0) > 0 and f(yi=1) > 0.\nWe say that f is product-like if, for every useful index i, there is a rational number λi such\nthat, for all y ∈{0, 1}k−1,\nf(yi=0) = λif(yi=1).\n(2)\nIf every position i of f is useful then being product-like is the same as being of product type.\nHowever, being product-like is less demanding because it does not restrict indices that are\nnot useful.\nLemma 12. If f ∈F2 is not product-like then #CSP({f}) is #P-hard.\nProof. We’ll use Corollary 9 to prove hardness, following an argument from [9]. Choose a\nuseful index i so that there is no λi satisfying (2).\nSuppose f has arity k.\nLet A be the 2 × 2k−1 matrix such that for b ∈{0, 1} and\ny ∈{0, 1}k−1, Ab,y = f(yi=b). Let A′ = AAT .\nFirst, we show that Eval(A′) is #P-hard. Note that A′ is the following symmetric 2 × 2\nmatrix with non-negative rational entries.\n \nP\ny A2\n0,y\nP\ny A0,yA1,y\nP\ny A0,yA1,y\nP\ny A2\n1,y\n \n=\n \nP\ny f(yi=0)2\nP\ny f(yi=0)f(yi=1)\nP\ny f(yi=0)f(yi=1)\nP\ny f(yi=1)2\n!\nSince index i is useful, all four entries of A′ are positive. To show that Eval(A′) is #P-hard\nby Corollary 9, we just need to show that its determinant is non-zero. By Cauchy-Schwartz,\nthe determinant is non-negative, and is zero only if λi exists, which have assumed not to be\nthe case. Thus Eval(A′) is #P-hard by Corollary 9.\nNow we reduce Eval(A′) to #CSP({f}). To do this, take an undirected graph G which\nis an instance of Eval(A′). Construct an instance Y of #CSP({f}). For every vertex v of G\nwe introduce a variable xv of Y . Also, for every edge e of G we introduce k −1 variables\nxe,1, . . . , xe,k−1 of Y . We introduce constraints in Y as follows. For each edge e = (v, v′) of G\nwe introduce constraints f(xv, xe,1, . . . , xe,k−1) and f(xv′, xe,1, . . . , xe,k−1) into Y , where we\nhave assumed, without loss of generality, that the first index is useful.\nIt is clear that Eval(A′) is exactly equal to the partition function of the #CSP({f})\ninstance Y .\nFor w ∈Q+, let Uw denote the unary function mapping 0 to 1 and 1 to w. Note that\nU0 = δ0, and U1 gives the constant (0-ary function) 1, occurrences of which leave the partition\nfunction unchanged. So, by Lemma 8, we can discard these constraints since they do not\n11"},{"page":12,"text":"add to the complexity of the problem. Note, by the observation above about proportional\nfunctions, that the functions Uw include all unary functions except for δ1 and the constant 0.\nWe can discard δ1 by Lemma 8, and if the constant 0 function is in F, any instance I where\nit appears as a constraint has Z(I) = 0. So again we can discard these constraints since they\nnot add to the complexity of the problem.\nThus Uw will be called nontrivial if w /∈{0, 1}. Let ⊕k : {0, 1}k →{0, 1} be the arity-k\nparity function that is 1 iffits argument has an odd number of 1s. Let ¬⊕k : {0, 1}k →{0, 1}\nbe the function 1 −⊕k. The following lemma shows that even a simple function like ⊕3 can\nlead to intractable #CSP instances when it is combined with a nontrivial weight function Uλ.\nLemma 13. #CSP(⊕3, Uλ, δ0, δ1) and #CSP(¬⊕3, Uλ, δ0, δ1) are both #P-hard, for any pos-\nitive λ ̸= 1.\nProof. We give a reduction from computing the Weight Enumerator of a Linear Code, which\nwas shown to be #P-hard in Lemma 10. In what follows, it is sometimes convenient to view\n⊕k, δ0, etc., as relations as well as functions to {0, 1}.\nWe first argue that for any k, the relation ⊕k can be simulated by {⊕3, δ0, δ1}.\nFor\nexample, to simulate x1 ⊕· · · ⊕xk for k > 3, take new variables y, z and w and let m = ⌈k/2⌉\nand use x1 ⊕· · · ⊕xm ⊕y and xm+1 ⊕· · · ⊕xk ⊕z and y ⊕z ⊕w and δ0(w).\nSince {⊕3, δ0, δ1} can be used to simulate any relation ⊕k, we can use {⊕3, δ0, δ1} to\nsimulate an arbitrary system of linear equations over GF(2). In particular we can use them\nto simulate the subspace Υ of code words for a given generating matrix A.\nFinally, we can use Uλ to simulate the function which evaluates the weight enumerator on\nΥ. Then, since λ ̸= 0, 1, we can apply Lemma 10 to complete the argument. The same proof,\nwith minor modifications, applies to ¬⊕3.\nLemma 14. Suppose f ∈F2 is not of product type. Then, for any positive λ ̸= 1, there exists\na constant c, depending on f, such that #CSP({f, δ0, δ1, Uλ, Uc}) is #P-hard.\nProof. If f does not have affine support, the result follows by Lemma 11. So suppose f has\naffine support. Consider the underlying relation Rf, viewed as a table. The rows of the table\nrepresent the tuples of the relation. Let J be the set of columns on which the relation is not\nconstant. That is, if i ∈J then there is a row x with xi = 0 and a row y with yi = 1. Group\nthe columns in J into equivalence classes: two columns are equivalent iffthey are equal or\ncomplementary. Let k be the number of equivalence classes. Take one column from each of\nthe k equivalence classes as a representative, and focus on the arity-k relation R induced by\nthose columns.\nCase 1: Suppose R is the complete relation of arity k.\nLet f ∗be the projection of f onto the k columns of R. By Lemma 6,\n#CSP({f ∗}) ≤T #CSP({f}) ≤T #CSP({f, δ0, δ1, Uλ, Uc}).\nWe will argue that #CSP({f ∗}) is #P-hard. To see this, note that every column of f ∗is\nuseful. Thus, if f ∗were product-like, we could conclude that f ∗was of product type. But\nthis would imply that f is of product type, which is not the case by assumption. So f ∗is not\nproduct-like and hardness follows from Lemma 12.\nCase 2: Suppose R is not the complete relation of arity k.\nWe had assumed that Rf is affine. This means that given three vectors, x, y and z, in Rf,\nx ⊕y ⊕z is in Rf as well. The arity-k relation R inherits this property, so is also affine.\n12"},{"page":13,"text":"Choose a minimal set of columns of R that do not induce the complete relation. This exists\nby assumption. Suppose there are j columns in this minimal set. Observe that j ̸= 1 because\nthere are no constant columns in J. Also j ̸= 2, since otherwise the two columns would be\nrelated by equality or disequality, contradicting the preprocessing step. The argument here\nis that on two columns, R cannot have exactly three tuples because it is affine, and having\ntuples x, y and z in would require the fourth tuple x ⊕y ⊕z. But if it has two tuples then,\nbecause there are no constant columns, the only possibilities are either (0, 0) and (1, 1), or\n(0, 1) and (1, 0). Both contradict the preprocessing step, so j ≥3.\nLet R′ be the restriction of R to the j columns. Now R′ of course has fewer than 2j rows,\nand at least 2j−1 by minimality. It is affine, and hence must be ⊕j or ¬⊕j. To see this, first\nnote that the size of R′ has to be a power of 2 since R′ is the solution to a system of linear\nequations. Hence the size of R′ must be 2j−1. Then, since there are j variables, there can\nonly be one defining equation. And, since every subset of j −1 variables induces a complete\nrelation, this single equation must involve all variables. Therefore, the equation is ⊕j or ¬⊕j.\nLet f ′ be the projection of f onto the j columns just identified. Let f ′′ be further obtained\nby pinning all but three of the j variables to 0. Pinning j −3 variables to 0 leaves a single\nequation involving all three remaining variables. Thus Rf′′ must be ⊕3 or ¬⊕3.\nNow define the symmetric function f ′′′ by\nf ′′′(a, b, c) = f ′′(a, b, c)f ′′(a, c, b)f ′′(b, a, c)f ′′(b, c, a)f ′′(c, a, b)f ′′(c, b, a),\nNote that Rf′′′ is ⊕3 or ¬⊕3, since Rf′′ is symmetric and hence Rf′′′ = Rf′′.\nTo summarise: using f and the constant functions δ0 and δ1, we have simulated a function\nf ′′′ such that its underlying relation Rf′′′ is either ⊕3 or ¬⊕3. Furthermore, if triples x and y\nhave the same number of 1s then f ′′′(x) = f ′′′(y).\nWe can now simulate an unweighted version of ⊕3 or ¬⊕3 using f ′′′ and a unary function\nUc, with c set to a conveniently-chosen value. There are two cases. Suppose first that the\naffine support of f ′′′ is ¬⊕3. Then let w0 denote the value of f ′′′ when applied to the 3-tuple\n(0, 0, 0) and let w2 denote f ′′′(0, 1, 1) = f ′′′(1, 0, 1) = f ′′′(1, 1, 0).\nRecall that f ′′′(x) = 0\nfor any other 3-tuple x.\nNow let c = (w0/w2)1/2.\nNote from the definition of f ′′′ that\nw0 and w2 are squares of rational numbers, so c is also rational.\nDefine a function g of\narity 3 by g(α, β, γ) = Uc(α)Uc(β)Uc(γ)f ′′′(α, β, γ). Note that g(0, 0, 0) = w0 and g(0, 1, 1) =\ng(1, 0, 1) = g(1, 1, 0) = c2w2 = w0. Thus, g is a pure affine function with affine support ¬⊕3\nand range {0, w0}. The other case, in which the affine support of f ′′′ is ⊕3, is similar.\nWe have established a reduction from either #CSP(⊕3, Uλ, δ0, δ1) or #CSP(¬⊕3, Uλ, δ0, δ1),\nwhich are both #P-hard by Lemma 13.\nLemma 15. If f ∈F2 is not of product type, then #CSP({f, δ0, δ1, Uλ}) is #P-hard for any\npositive λ ̸= 1.\nProof. Take an instance I of #CSP({f, δ0, δ1, Uλ, Uc}), from Lemma 14, with n variables\nx1, x2, . . . , xn.\nWe want to compute the partition function Z(I) using only instances of\n#CSP({f, δ0, δ1, Uλ}). That is, instances which avoid using constraints Uc. For each i, let mi\ndenote the number of copies of Uc that are applied to xi, and let m = Pn\ni=1 mi. Then we can\nwrite the partition function as Z(I) = Z(I; c) where\nZ(I; w) =\nX\nσ∈{0,1}n\nˆZ(σ)\nY\ni:σi=1\nwmi =\nX\nσ∈{0,1}n\nˆZ(σ)w\nPn\ni=1 miσi,\n13"},{"page":14,"text":"where ˆZ(σ) denotes the value corresponding to the assignment σ(xi) = σi, ignoring constraints\napplying Uc, and w is a variable. So ˆZ(σ) is the weight of σ, taken over all constraints other\nthan those applying Uc. Note also that Z(I; w) is a polynomial of degree m in w. We can\nevaluate Z(I; w) at the point w = λj by replacing each Uc constraint with j copies of a Uλ\nconstraint.\nThis evaluation is an instance of #CSP({f, δ0, δ1, Uλ}). So, using m different\nvalues of j and interpolating, we learn the coefficients of the polynomial Z(I; w). Then we\ncan put w = c to evaluate Z(I).\nLemma 16. Suppose f ∈F2 is not of product type, and g ∈F2 is not pure affine. Then\n#CSP({f, g, δ0, δ1}) is #P-hard.\nProof. If g does not have affine support we are done by Lemma 11. So suppose that g has\naffine support. Since g is not pure affine, the range of g contains at least two non-zero values.\nThe high-level idea will be to use pinning and bisection to extract a non-trivial unary\nweight function Uλ from g. Then we can reduce from #CSP({f, δ0, δ1, Uλ}), which we proved\n#P-hard in Lemma 15.\nLook at the relation Rg, viewed as a table. If every column were constant, then g would\nbe pure affine, so this is not the case. Select a non-constant column with index h. If there\nare two non-zero values in the range of g amongst the rows of Rg that are 0 in column h\nthen we derive a new function g′ by pinning column h to 0.\nThe new function g′ is not\npure affine, since the two non-zero values prevent this.\nSo we will show inductively that\n#CSP({f, g′, δ0, δ1}) is #P-hard. This will give the result since #CSP({f, g′, δ0, δ1}) trivially\nreduces to #CSP({f, g, δ0, δ1}).\nIf we don’t finish this way, or symmetrically by pinning column h to 1, then we know\nthat there are distinct positive values w0 and w1 such that, for every row x of Rg with 0 in\ncolumn h, g(x) = w0 and, for every row x of Rg with 1 in column h, g(x) = w1. Now note\nthat, because the underlying relation Rg is affine, it has the same number of 0’s in column h\nas 1’s. This is because Rg is the solution of a set of linear equations. Adding the equation\nxh = 0 or xh = 1 exactly halves the set of solutions in either case. We now project onto the\nindex set {h}. We obtain the unary weight function Uλ, with λ = w1/w0, on using the earlier\nobservation about proportional functions. This was our goal, and completes the proof.\nLemma 5 now follows from Lemma 8 and Lemma 16, completing the proof of Theorem 4.\nReferences\n[1] G. Brightwell and P. Winkler, Graph homomorphisms and phase transitions, Journal of\nCombinatorial Theory (Series B) 77 (1999), 221–262\n[2] A. Bulatov and V. Dalmau, Towards a dichotomy theorem for the counting constraint\nsatisfaction problem, in Proc. 44th Annual IEEE Symposium on Foundations of Computer\nScience, 2003, pp. 562–573.\n[3] D. Cohen, M. Cooper, P. Jeavons and A. Krokhin, The complexity of soft constraint\nsatisfaction, Artificial Intelligence 170 (2006), 983–1016.\n[4] A. Bulatov and M. Grohe, The complexity of partition functions, Theoretical Computer\nScience 348 (2005), 148–186.\n14"},{"page":15,"text":"[5] B. Cipra, An Introduction to the Ising Model, American Mathematical Monthly 94 (1987),\n937–959.\n[6] N. Creignou and M. Hermann, Complexity of generalized satisfiability counting problems,\nInformation and Computation 125 (1996), 1–12.\n[7] N. Creignou, S. Khanna, M. Sudan, Complexity classifications of Boolean constraint sat-\nisfaction problems, SIAM Press, 2001.\n[8] M. Dyer and C. Greenhill, The complexity of counting graph homomorphisms, Random\nStructures and Algorithms 17 (2000), 260–289.\n[9] M. Dyer, L.A. Goldberg and M. Paterson, On counting homomorphisms to directed acyclic\ngraphs, in Proc. 33rd International Colloquium on Automata, Languages and Program-\nming, Lecture Notes in Computer Science 4051, Springer, 2006, pp. 38–49.\n[10] T. Feder and M. Vardi, The computational structure of monotone monadic SNP and\nconstraint satisfaction: a study through Datalog and group theory, SIAM Journal on\nComputing 28 (1999), 57–104.\n[11] L.A.\nGoldberg\nand\nM.\nJerrum,\nInapproximability\nof\nthe\nTutte\npolynomial,\nhttp://arxiv.org/abs/cs.CC/0605140, 2006.\n[12] C. Greenhill, The complexity of counting colourings and independent sets in sparse\ngraphs and hypergraphs, Computational Complexity 9 (2000), 52–72.\n[13] P. Hell and J. Neˇsetˇril, On the complexity of H-coloring, Journal of Combinatorial\nTheory (Series B) 48 (1990), 92–110.\n[14] P. Hell and J. Neˇsetˇril, Graphs and homomorphisms, Oxford University Press, 2004.\n[15] L. Lov ́asz, Operations with structures, Acta Mathematica Hungarica 18 (1967), 321–328.\n[16] R. Ladner, On the structure of polynomial time reducibility, Journal of the Association\nfor Computing Machinery 22 (1975), 155–171.\n[17] C. Papadimitriou, Computational complexity, Addison-Wesley, 1994.\n[18] F. Rossi, P. van Beek and T. Walsh (Eds.), Handbook of constraint programming, Elsevier,\n2006.\n[19] T. Schaefer, The complexity of satisfiability problems, in Proc. 10th Annual ACM Sym-\nposium on Theory of Computing, ACM Press, 1978, pp. 216–226.\n[20] A. Scott and G. Sorkin, Polynomial constraint satisfaction: a framework for counting\nand sampling CSPs and other problems, http://arxiv.org/abs/cs/0604079.\n[21] J. Schwartz, Fast probabilistic algorithms for verification of polynomial identities, Jour-\nnal of the Association for Computing Machinery 27 (1980), 701–717.\n[22] L. Valiant, The complexity of enumeration and reliability problems, SIAM Journal on\nComputing 8 (1979), 410–421.\n[23] D. Welsh, Complexity: knots, colourings and counting, LMS Lecture Note Series, vol. 186,\nCambridge University Press, 1993.\n15"},{"page":16,"text":"4\nAppendix\nThe purpose of this appendix is to prove Lemma 7 for an arbitrary fixed domain [q]. We\nused only the special case q = 2, which we stated and proved as Lemma 8. However, pinning\nappears to be a useful technique for studying the complexity of #CSP, so we give a proof of\nthe general Lemma 7, which we believe will be applicable elsewhere.\nLemma 7. For every F ⊆Fq, #CSP(F ∪S\nc∈[q] δc) ≤T #CSP(F).\nIn order to prove the lemma, we introduce a useful, but less natural, variant of #CSP.\nSuppose F ⊆Fq. An instance I of #CSP̸=(F) consists of a set V of variables and a set C of\nconstraints, just like an instance of #CSP(F). In addition, the instance may contain a single\nextra constraint C applying the arity-q disequality relation χ̸= with scope (vC,1, . . . , vC,q).\nThe disequality relation χ̸= is defined by χ̸=(x1, . . . , xq) = 1 if x1, . . . , xq ∈[q] are pairwise\ndistinct. That is, if they are a permutation of the domain [q]. Otherwise, χ̸=(x1, . . . , xq) = 0.\nLemma 7 follows immediately from Lemma 17 and 18 below.\nLemma 17. For every F ⊆Fq, #CSP(F ∪S\nc∈[q] δc) ≤T #CSP̸=(F).\nProof. We follow the proof lines of Lemma 8, but instead of subtracting the contribution\ncorresponding to configurations in which some ti’s get the same value, we use the disequality\nrelation to restrict the partition function to configurations in which they get distinct values.\nSay that F is symmetric if it is the case that for every arity-k function f ∈F and every\ntuple x ∈[q]k and every permutation π : [q] →[q], f(x1, . . . , xk) = f(π(x1), . . . , π(xk)).\nLet I be an instance of #CSP(F ∪S\nc∈[q] δc) with variable set V . Let Vc be the set of\nvariables v ∈V to which the constraint δc(v) is applied. Assume without loss of generality\nthat the sets Vc are pairwise disjoint. Let Vq = V \\ S\nc∈[q] Vc. We construct an instance I′ of\n#CSP̸=(F). The instance has variables Vq ∪{t0, . . . , tq−1}. Every constraint C of I involving\na function f ∈F corresponds to a constraint C′ of I′. Here C′ is the same as C except that\nvariables in Vc are replaced with tc, for each c ∈[q]. Also, we add a new disequality constraint\nto the new variables t0, . . . , tq−1.\nCase 1. F is symmetric:\nBy construction, Z(I′) = P\ny0,...,yq−1 Z(I′ | σ(t0) = y0, . . . , σ(tq−1) = yq−1), where the sum\nis over all permutations y0, . . . , yq−1 of [q]. By symmetry, the summands are all the same, so\nZ(I′) = q!Z(I′ | σ(t0) = 0, . . . , σ(tq−1) = q −1) = q!Z(I).\nCase 2. F is not symmetric:\nSay that two permutations π1 : [q] →[q] and π2 : [q] →[q] are equivalent if, for every\nf ∈F and every tuple x ∈[q]k, f(π1(x1), . . . , π1(xk)) = f(π2(x1), . . . , π2(xk)). Partition the\npermutations π : [q] →[q] into equivalence classes. Let h be the number of equivalence classes\nand ni be the size of the i’th equivalence class, so n1 + · · · + nh = q!.6 Let {π1, . . . , πh} be\na set of representatives of the equivalence classes with π1 being the identity. We know that\nn1 ̸= q! since F is not symmetric.\nFor a positive integer lwe will now build an instance I′\nlby adding new constraints to I′.\nFor each πi other than π1 we add constraints as follows. Choose a function fi ∈F and a tuple y\nsuch that fi(y1, . . . , yk) ̸= fi(πi(y1), . . . , πi(yk)). If fi(y1, . . . , yk) > fi(πi(y1), . . . , πi(yk)) then\ndefine the k-tuple xi by (xi\n1, . . . , xi\nk) = (y1, . . . , yk).\nOtherwise, let n be the order of the\n6In fact, it can be shown that these equivalence classes are cosets of the symmetry group of f, and hence\nare of equal size, though we do not use this fact here.\n16"},{"page":17,"text":"permutation πi and let gr denote fi(πr\ni (y1), . . . , πr\ni (yk)). Since g0 < g1 and gn = g0 there\nexists a ξ ∈{1, . . . , n −1} such that gξ > gξ+1. Let (xi\n1, . . . , xi\nk) = (πξ(y1), . . . , πξ(yk)) so\nfi(xi\n1, . . . , xi\nk) > fi(πi(xi\n1), . . . , πi(xi\nk)).\nLet wij denote fi(πj(xi\n1), . . . , πj(xi\nk)) so, since π1 is the identity, we have just ensured that\nwi1 > wii. Let si = (txi\n1, . . . , txi\nk), and let 0 ≤zi ≤h (i = 2, . . . , h) be positive integers, which\nwe will determine below. Add lzi new constraints to I′\nlwith relation fi and scope si. Let\nλi = Qh\nγ=2 wzγ\nγi . Note that, given σ(t0) = πi(0), . . . , σ(tq−1) = πi(q −1), the contribution to\nZ(I′\nl) for the new constraints is\nh\nY\nγ=2\nfγ(σ(txγ\n1), . . . , σ(txγ\nk))zγl=\nh\nY\nγ=2\nfγ(πi(xγ\n1), . . . , πi(xγ\nk))zγl=\nh\nY\nγ=2\nwzγl\nγ,i =\n \nh\nY\nγ=2\nwzγ\nγ,i\n l\n= λil.\nSo\nZ(I′\nl) =\nh\nX\ni=1\nni Z( I′ | σ(t0) = πi(0), . . . , σ(tq−1) = πi(q −1) ) λl\ni.\nWe have ensured that λ1 > 0, since wi1 > wii ≥0, so wi1 > 0 for all i = 2, . . . , h. We now\nchoose the zi’s so that λi ̸= λ1 for all i = 2, . . . , h. If wγi = 0 for any γ = 2, . . . , h, we have\nλi = 0 and hence λi ̸= λ1. Thus we will assume, without loss of generality, that wγi > 0 for\nall γ = 2, . . . , h and i = 2, . . . , h′, where h′ ≤h. Then we have\nλi\nλ1\n=\nh\nY\nγ=2\n wγi\nwγ1\n zγ = e\nPh\nγ=2 αγizγ\n(i = 2, . . . , h′),\nwhere αγi = ln(wγi/wγ1). Note that αii < 0, since wii < wi1. We need to find an integer\nvector z = (z2, . . . , zh) so that none of the linear forms Li(z) = Ph\nγ=2 αγizγ is zero, for\ni = 2, . . . , h′.\nWe do this using a proof method similar to the Schwartz-Zippel Lemma.\n(See, for example, [21].) None of the Li(z) is identically zero, since αii ̸= 0. Consider the\ninteger vectors z ∈[h]h−1. At most hh−2 of these can make Li(z) zero for any i, since the\nequation Li(z) = 0 makes zi a linear function of zγ (γ ̸= i). Therefore there are at most\n(h′ −1)hh−2 < hh−1 such z which make any Li(z) zero. Therefore there must be a vector\nz ∈[h]h−1 for which none of the Li(z) is zero, and this is the vector we require.\nNow, by combining terms with equal λi and ignoring terms with λi = 0, we can view\nZ(I′\nl) as a sum Z(I′\nl) = P\ni ciλl\ni where the λi’s are positive and pairwise distinct and\nc1 = n1Z(I′ | σ(t0) = 0, . . . , σ(tq−1) = q −1).\nThus, by Lemma 3.2 of [8] we can interpolate to recover c1. Dividing by n1, we get\nZ(I′ | σ(t0) = 0, . . . , σ(tq−1) = q −1) = Z(I).\nLemma 18. For every F ⊆Fq, #CSP̸=(F) ≤T #CSP(F).\nProof. We use M ̈obius inversion for posets, following the lines of the proof of [2, Theorem 8].7\nConsider the set of partitions of [q].\nLet 0 denote the partition with q singleton classes.\nConsider the partial order in which η ≤θ iffevery class of η is a subset of some class\n7Lov ́asz [15] had previously used M ̈obius inversion in a similar context.\n17"},{"page":18,"text":"of θ. Define μ(0) = 1 and for any θ ̸= 0 define μ(θ) = −P\nη≤θ,η̸=θ μ(η). Consider the sum\nP\nη≤θ μ(η). Clearly, this sum is 1 if θ = 0. From the definition of μ, it is also easy to see that\nthe sum is 0 otherwise, since\nX\nη≤θ\nμ(η) = μ(θ) +\nX\nη≤θ,η̸=θ\nμ(η) = 0.\nNow let I be an instance of #CSP̸=(F) with a disequality constraint applied to variables\nt0, . . . , tq−1. Let V be the set of variables of I. Given a configuration σ : V →[q], let θ(σ)\nbe the partition of [q] induced by of (σ(t0), . . . , σ(tq−1)). Thus i and j in [q] are in the same\nclass of θ(σ) iffσ(ti) = σ(tj). We say that a partition η is consistent with σ (written η ≼σ)\nif η ≤θ(σ). Note that η ≼σ means that for any i and j in the same class of η, σ(ti) = σ(tj).\nLet Ωbe the set of configurations σ that satisfy all constraints in I except possibly the\ndisequality constraint. Then Z(I) = P\nσ∈Ωw(σ)1σ, where 1σ = 1 if σ respects the disequality\nconstraint, meaning that θ(σ) = 0, and 1σ = 0 otherwise. By the M ̈obius inversion formula\nderived above,\nZ(I) =\nX\nσ∈Ω\nw(σ)\nX\nη≤θ(σ)\nμ(η).\nChanging the order of summation, we get\nZ(I) =\nX\nη\nμ(η)\nX\nη≤θ\nX\nσ∈Ω:θ(σ)=θ\nw(σ) =\nX\nη\nμ(η)\nX\nσ∈Ω:η≼σ\nw(σ).\nNow note that P\nσ:η≼σ w(σ) is the partition function Z(Iη) of an instance Iη of #CSP(F).\nThe instance Iη is formed from I by ignoring the disequality constraint, and identifying\nvariables in t0, . . . , tq−1 whose indices are in the same class of η. Thus we can compute all\nthe Z(Iη) in #CSP(F). Finally, Z(I) = P\nη μ(η)Z(Iη), completing the reduction.\n18"}]},"section_tree":[],"assets":{"figures":[],"tables":[],"images":[]},"math_expressions":{"inline":[],"block":[{"equation_id":"eq1","equation_number":null,"raw_text":"denote by [q] = {0, 1 . . . , q −1} for a positive integer q.1","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq2","equation_number":null,"raw_text":"domain [q] is a set of relations on [q]. For example, take q = 2. The relation R = {(0, 0, 1),","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq3","equation_number":null,"raw_text":"V = {v1, . . . , vn} and a set of constraints. Each constraint has a scope, which is a tuple of","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq4","equation_number":null,"raw_text":"example, if Γ = {R1, R2, R3} where R1, R2 and R3 are the three binary relations defined","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq5","equation_number":null,"raw_text":"by R1 = {(0, 1), (1, 0), (1, 1)}, R2 = {(0, 0), (0, 1), (1, 1)} and R3 = {(0, 0), (0, 1), (1, 0)}, then","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq6","equation_number":null,"raw_text":"bounded size. This limitation of the class CSP has an important advantage. If P ̸= NP,","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq7","equation_number":null,"raw_text":"in Γ must have certain algebraic properties (assuming P ̸= #P). In particular, they must","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq8","equation_number":null,"raw_text":"equations over GF(2). These equations are of the form v1 ⊕· · · ⊕vn = 0 and v1 ⊕· · · ⊕vn = 1","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq9","equation_number":null,"raw_text":"that a relation R is affine iffa, b, c ∈R implies d = a ⊕b ⊕c ∈R.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq10","equation_number":null,"raw_text":"Let Fq = {f : [q]k →Q+ | k ∈N} be the set of all such","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq11","equation_number":null,"raw_text":"is given by Rf = {x ∈[q]k | f(x) ̸= 0}. It is often helpful to think of Rf as a table, with","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq12","equation_number":null,"raw_text":"x = (x1, . . . , xk) ∈Rf. The entry in row x and column j is xj, which is a value in [q].","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq13","equation_number":null,"raw_text":"and a scope, which is a sequence sC = (vC,1, . . . , vC,kC) of variables from V . The variables","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq14","equation_number":null,"raw_text":"w(σ) =","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq15","equation_number":null,"raw_text":"Z(I) =","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq16","equation_number":null,"raw_text":"That is, if x ∈R we set f R(x) = 1.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq17","equation_number":null,"raw_text":"f R(x) = 0. Let F = {f R | R ∈Γ}. Then for any instance I of #CSP(Γ), the number of","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq18","equation_number":null,"raw_text":"Suppose H = (Hij) is any symmetric square matrix H of rational numbers. We view H as","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq19","equation_number":null,"raw_text":"the corresponding edge is absent from H. Given a (simple) graph G = (V, E) we consider","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq20","equation_number":null,"raw_text":"ZH(G) =","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq21","equation_number":null,"raw_text":"where w(σ) =","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq22","equation_number":null,"raw_text":"having domain size q = 2 will be called weighted Boolean #CSP, and will be the main focus","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq23","equation_number":null,"raw_text":"However, Goldberg and Jerrum [11] have observed that Z(I) = ̃Z(I)/K(I), where ̃Z is a","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq24","equation_number":null,"raw_text":"f ∈F, we can ensure that f(·) = ̃f(·)/K(I), where ̃f(·) ∈N, by“clearing denominators”. The","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq25","equation_number":null,"raw_text":"computable instance I′ of #CSP(F), such that Z(I) = φ(I)Z(I′) for some φ(I) ∈Q which is","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq26","equation_number":null,"raw_text":"Note also that, if ̃f = Kf, for some constant K > 0, then {f} simulates ̃f. Thus there is no","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq27","equation_number":null,"raw_text":"We use the following terminology for certain functions. Let χ= be the binary equality","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq28","equation_number":null,"raw_text":"function defined on [q] as follows. For any element c ∈[q], χ=(c, c) = 1 and for any pair (c, d)","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq29","equation_number":null,"raw_text":"of distinct elements of [q], χ=(c, d) = 0. Let χ̸= be the binary disequality function given by","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq30","equation_number":null,"raw_text":"χ̸=(c, d) = 1 −χ=(c, d) for all c, d ∈[q].4 We say that a function f is of product type if f can","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq31","equation_number":null,"raw_text":"be expressed as a product of unary functions and binary functions of the form χ= and χ̸=.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq32","equation_number":null,"raw_text":"We focus attention in this paper on the Boolean case, q = 2. In this case, we say that a","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq33","equation_number":null,"raw_text":"Theorem 4. Suppose F ⊆F2 = {f : {0, 1}k →Q+ | k ∈N}. If every function in F is of","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq34","equation_number":null,"raw_text":"if variables in U1 are given value “1” by σ. Thus, Z(I) = (α + β)Z(I′), where I′ is the","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq35","equation_number":null,"raw_text":"Suppose second that F if pure affine. Then Z(I) = Q","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq36","equation_number":null,"raw_text":"domain [q], we will let Z(I | σ(u1) = c1, . . . , σ(uk) = ck) denote the contribution to Z(I) from","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq37","equation_number":null,"raw_text":"assignments σ with σ(u1) = c1, · · · , σ(uk) = ck.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq38","equation_number":null,"raw_text":"Let f be a function of arity k, and let J = {j1, . . . , jr} be a size-r subset of {1, . . . , k},","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq39","equation_number":null,"raw_text":"ji = xi for all 1 ≤i ≤r. The","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq40","equation_number":null,"raw_text":"projection g of f onto J is defined as follows. For every x ∈[q]r, g(x) = P","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq41","equation_number":null,"raw_text":"that Z(I) = Z(I′). The instance I′ is identical to I except that every constraint C of I","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq42","equation_number":null,"raw_text":"C′,jl= vC,l. The","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq43","equation_number":null,"raw_text":"with φ(I) = 1.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq44","equation_number":null,"raw_text":"For c ∈[q], δc denotes the unary function with δc(c) = 1 and δc(d) = 0 for d ̸= c. The","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq45","equation_number":null,"raw_text":"The proof of Lemma 7 is deferred to the appendix. Since we only use the case q = 2 in","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq46","equation_number":null,"raw_text":"f(x) = f(x).","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq47","equation_number":null,"raw_text":"can assume without loss of generality that V0 and V1 do not intersect. (Otherwise, Z(I) = 0","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq48","equation_number":null,"raw_text":"and we can determine this without using an oracle for #CSP(F).) Let V2 = V \\ (V0 ∪V1).","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq49","equation_number":null,"raw_text":"Z(I′) −Z(I′′) = Z(I′ | σ(t0) = 0, σ(t1) = 1) + Z(I′ | σ(t0) = 1, σ(t1) = 0).","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq50","equation_number":null,"raw_text":"Z(I′) −Z(I′′) = 2Z(I′ | σ(t0) = 0, σ(t1) = 1) = 2Z(I).","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq51","equation_number":null,"raw_text":"f(x) > f(x) ≥0. Let s = (tx1, . . . , txk) and let I′","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq52","equation_number":null,"raw_text":"x) = Z(I′ | σ(t0) = 0, σ(t1) = 1)f(x) + Z(I′ | σ(t0) = 1, σ(t1) = 0)f(x)","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq53","equation_number":null,"raw_text":"+ Z(I′ | σ(t0) = 0, σ(t1) = 0)f(0, . . . , 0) + Z(I′ | σ(t0) = 1, σ(t1) = 1)f(1, . . . , 1)","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq54","equation_number":null,"raw_text":"= Z(I′ | σ(t0) = 0, σ(t1) = 1)f(x) + Z(I′ | σ(t0) = 1, σ(t1) = 0)f(x) + Z(I′′","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq55","equation_number":null,"raw_text":"x) = Z(I′ | σ(t0) = 0, σ(t1) = 1)f(x) + Z(I′ | σ(t0) = 1, σ(t1) = 0)f(x),","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq56","equation_number":null,"raw_text":"Z(I′) −Z(I′′) = Z(I′ | σ(t0) = 0, σ(t1) = 1)","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq57","equation_number":null,"raw_text":"+ Z(I′ | σ(t0) = 1, σ(t1) = 0)","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq58","equation_number":null,"raw_text":"in the unknowns Z(I′ | σ(t0) = 0, σ(t1) = 1) and Z(I′ | σ(t0) = 1, σ(t1) = 0). Solving these,","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq59","equation_number":null,"raw_text":"we obtain the value of Z(I′ | σ(t0) = 0, σ(t1) = 1) = Z(I).","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq60","equation_number":null,"raw_text":"code is given by WA(λ) = P","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq61","equation_number":null,"raw_text":"positive rational number λ ̸= 1.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq62","equation_number":null,"raw_text":"using Corollary 9. Let the input to Eval(H) be a connected graph G = (V, E) with V =","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq63","equation_number":null,"raw_text":"{v1, . . . , vn} and E = {e1, . . . , em}. Let B be the n × m incidence matrix of G, with bij = 1","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq64","equation_number":null,"raw_text":"if vi ∈ej and bij = 0 otherwise. Let A be the (n −1) × m matrix which is B with the row","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq65","equation_number":null,"raw_text":"r = n −1 and C = m. It has rank (n −1) since G contains a spanning tree. A code word","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq66","equation_number":null,"raw_text":"c has cj = L","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq67","equation_number":null,"raw_text":"i∈U bij, where U ⊆V \\ {vn}. Thus cj = 1 if and only if ej has exactly one","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq68","equation_number":null,"raw_text":"Thus WA(λ) = 1","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq69","equation_number":null,"raw_text":"2ZH(G), where H is the symmetric weight matrix with H11 = H22 = 1 and","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq70","equation_number":null,"raw_text":"H12 = H21 = λ. The 1","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq71","equation_number":null,"raw_text":"has rank 2 unless λ = 1, so this problem is #P-hard by Corollary 9. Note, by the way, that","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq72","equation_number":null,"raw_text":"Throughout this section, we assume q = 2. The following Lemma is a generalisation of a result","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq73","equation_number":null,"raw_text":"The proof is by induction on k. The lemma is trivially true for k = 1, since all functions of","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq74","equation_number":null,"raw_text":"For k = 2, we note that since Rf is not affine, it is of the form Rf = {(α, β), ( ̄α, β), ( ̄α, ̄β)}","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq75","equation_number":null,"raw_text":"H =","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq76","equation_number":null,"raw_text":"which has rank 2 and exactly one entry that is 0. Given an instance G = (V, E) of Eval(H)","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq77","equation_number":null,"raw_text":"For each edge e = (u, v) of G, add a constraint with function f and variable sequence u, v.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq78","equation_number":null,"raw_text":"{1, . . . , k} and any α ∈{0, 1} let f i=α be the function of arity k −1 derived from f by pinning","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq79","equation_number":null,"raw_text":"the i’th position to α. That is, f i=α(x1, . . . , xk−1) = f(x1, . . . , xi−1, α, xi+1, . . . , xk). Also,","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq80","equation_number":null,"raw_text":"let f i=∗be the projection of f onto all positions apart from position i (see Section 2.2).","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq81","equation_number":null,"raw_text":"Note that #CSP({f i=α}) ≤T #CSP({f, δ0, δ1}), since f i=α can obviously be simulated by","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq82","equation_number":null,"raw_text":"assume that f i=α has affine support — otherwise, we are finished by induction. Similarly, by","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq83","equation_number":null,"raw_text":"f i=∗","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq84","equation_number":null,"raw_text":") ≤T #CSP({f}). Thus we can assume that f i=∗has affine support","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq85","equation_number":null,"raw_text":"Now, recall that Rf is not affine. Consider any a, b, c ∈Rf such that d = a ⊕b ⊕c /∈Rf.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq86","equation_number":null,"raw_text":"There are indices 1 ≤i < j ≤k such that (ai, bi, ci) = (aj, bj, cj):","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq87","equation_number":null,"raw_text":"Without loss of generality, suppose i = 1 and j = 2. Define the function f ′ of arity (k −1) by","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq88","equation_number":null,"raw_text":"f ′(r2, . . . , rk) = f(r2, r2, . . . , rk). Note that Rf′ is not affine since the condition a⊕b⊕c /∈Rf is","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq89","equation_number":null,"raw_text":"Case 2: There is an index 1 ≤i ≤k such that ai = bi = ci: Since d is not in Rf and","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq90","equation_number":null,"raw_text":"di = ai, we find that f i=ai does not have affine support, contrary to earlier assumptions.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq91","equation_number":null,"raw_text":"Case 3 or Case 4 below, where {α, β} ∈{0, 1}, ̄α = 1 −α, ̄β = 1 −β and a′, b′, c′ ∈{0, 1}k−2.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq92","equation_number":null,"raw_text":"a = ( ̄α, ̄β, a′), b = ( ̄α, β, b′), c = (α, ̄β, c′): Since Rf1=∗is affine and a, b","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq93","equation_number":null,"raw_text":"and c are in Rf, we must have either d = (α, β, d′) ∈Rf or e = ( ̄α, β, d′) ∈Rf, where","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq94","equation_number":null,"raw_text":"d′ = a′ ⊕b′ ⊕c′. In the first case, we are done (we have contradicted the assumption that","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq95","equation_number":null,"raw_text":"Similarly, since Rf2=∗is affine, we may","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq96","equation_number":null,"raw_text":"assume that g = (α, ̄β, d′) ∈Rf. Since Rf1= ̄α is affine and a, b and e are in Rf, we find","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq97","equation_number":null,"raw_text":"that h = a ⊕b ⊕e = ( ̄α, ̄β, c′) ∈Rf. Since Rf2= ̄β is affine and a, c and g are in Rf, we","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq98","equation_number":null,"raw_text":"find that i = ( ̄α, ̄β, b′) ∈Rf. Also, since Rf2= ̄β is affine and a, h and i are in Rf, we find","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq99","equation_number":null,"raw_text":"that j = ( ̄α, ̄β, d′) ∈Rf. Let f ′(r1, r2) = f(r1, r2, d3, . . . , dk). Since e, g and j are in Rf","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq100","equation_number":null,"raw_text":"Case 4: a = ( ̄α, α, a′), b = ( ̄α, α, b′), c = (α, ̄α, c′): Since Rf1=∗is affine and a, b and c","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq101","equation_number":null,"raw_text":"are in Rf but d is not, we have e = ( ̄α, ̄α, d′) ∈Rf. Similarly, since Rf2=∗is affine and a, b","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq102","equation_number":null,"raw_text":"and c are in Rf but d is not, we have g = (α, α, d′) ∈Rf. Now since Rf1= ̄α is affine and a, b","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq103","equation_number":null,"raw_text":"and e are in Rf, we have h = ( ̄α, ̄α, c′) ∈Rf. Also, since Rf2=α is affine and a, b and g are in","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq104","equation_number":null,"raw_text":"Rf, we have i = (α, α, c′) ∈Rf.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq105","equation_number":null,"raw_text":"Let f ′(r1, r2) = f(r1, r2, c3, . . . , ck). If j = ( ̄α, α, c′) ̸∈Rf then f ′ does not have affine","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq106","equation_number":null,"raw_text":"Since Rf1= ̄α is affine and a, b and j are in Rf, we have l= ( ̄α, α, d′) ∈Rf. Let f ′′(r1, r2) =","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq107","equation_number":null,"raw_text":"value b ∈{0, 1}, an index i ∈{1, . . . , k}, and a tuple y ∈{0, 1}k−1, let yi=b denote the tuple","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq108","equation_number":null,"raw_text":"x ∈{0, 1}k formed by setting xi = b and xj = yj (j ∈{1, . . . , k} \\ {i}).","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq109","equation_number":null,"raw_text":"We say that index i of f is useful if there is a tuple y such that f(yi=0) > 0 and f(yi=1) > 0.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq110","equation_number":null,"raw_text":"f(yi=0) = λif(yi=1).","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq111","equation_number":null,"raw_text":"y ∈{0, 1}k−1, Ab,y = f(yi=b). Let A′ = AAT .","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq112","equation_number":null,"raw_text":"y f(yi=0)2","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq113","equation_number":null,"raw_text":"y f(yi=0)f(yi=1)","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq114","equation_number":null,"raw_text":"y f(yi=0)f(yi=1)","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq115","equation_number":null,"raw_text":"y f(yi=1)2","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq116","equation_number":null,"raw_text":"xe,1, . . . , xe,k−1 of Y . We introduce constraints in Y as follows. For each edge e = (v, v′) of G","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq117","equation_number":null,"raw_text":"U0 = δ0, and U1 gives the constant (0-ary function) 1, occurrences of which leave the partition","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq118","equation_number":null,"raw_text":"it appears as a constraint has Z(I) = 0. So again we can discard these constraints since they","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq119","equation_number":null,"raw_text":"itive λ ̸= 1.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq120","equation_number":null,"raw_text":"example, to simulate x1 ⊕· · · ⊕xk for k > 3, take new variables y, z and w and let m = ⌈k/2⌉","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq121","equation_number":null,"raw_text":"Υ. Then, since λ ̸= 0, 1, we can apply Lemma 10 to complete the argument. The same proof,","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq122","equation_number":null,"raw_text":"Lemma 14. Suppose f ∈F2 is not of product type. Then, for any positive λ ̸= 1, there exists","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq123","equation_number":null,"raw_text":"constant. That is, if i ∈J then there is a row x with xi = 0 and a row y with yi = 1. Group","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq124","equation_number":null,"raw_text":"by assumption. Suppose there are j columns in this minimal set. Observe that j ̸= 1 because","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq125","equation_number":null,"raw_text":"there are no constant columns in J. Also j ̸= 2, since otherwise the two columns would be","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq126","equation_number":null,"raw_text":"f ′′′(a, b, c) = f ′′(a, b, c)f ′′(a, c, b)f ′′(b, a, c)f ′′(b, c, a)f ′′(c, a, b)f ′′(c, b, a),","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq127","equation_number":null,"raw_text":"Note that Rf′′′ is ⊕3 or ¬⊕3, since Rf′′ is symmetric and hence Rf′′′ = Rf′′.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq128","equation_number":null,"raw_text":"have the same number of 1s then f ′′′(x) = f ′′′(y).","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq129","equation_number":null,"raw_text":"(0, 0, 0) and let w2 denote f ′′′(0, 1, 1) = f ′′′(1, 0, 1) = f ′′′(1, 1, 0).","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq130","equation_number":null,"raw_text":"Recall that f ′′′(x) = 0","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq131","equation_number":null,"raw_text":"Now let c = (w0/w2)1/2.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq132","equation_number":null,"raw_text":"arity 3 by g(α, β, γ) = Uc(α)Uc(β)Uc(γ)f ′′′(α, β, γ). Note that g(0, 0, 0) = w0 and g(0, 1, 1) =","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq133","equation_number":null,"raw_text":"g(1, 0, 1) = g(1, 1, 0) = c2w2 = w0. Thus, g is a pure affine function with affine support ¬⊕3","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq134","equation_number":null,"raw_text":"positive λ ̸= 1.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq135","equation_number":null,"raw_text":"denote the number of copies of Uc that are applied to xi, and let m = Pn","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq136","equation_number":null,"raw_text":"i=1 mi. Then we can","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq137","equation_number":null,"raw_text":"write the partition function as Z(I) = Z(I; c) where","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq138","equation_number":null,"raw_text":"Z(I; w) =","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq139","equation_number":null,"raw_text":"i:σi=1","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq140","equation_number":null,"raw_text":"wmi =","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq141","equation_number":null,"raw_text":"i=1 miσi,","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq142","equation_number":null,"raw_text":"where ˆZ(σ) denotes the value corresponding to the assignment σ(xi) = σi, ignoring constraints","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq143","equation_number":null,"raw_text":"evaluate Z(I; w) at the point w = λj by replacing each Uc constraint with j copies of a Uλ","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq144","equation_number":null,"raw_text":"can put w = c to evaluate Z(I).","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq145","equation_number":null,"raw_text":"column h, g(x) = w0 and, for every row x of Rg with 1 in column h, g(x) = w1. Now note","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq146","equation_number":null,"raw_text":"xh = 0 or xh = 1 exactly halves the set of solutions in either case. We now project onto the","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq147","equation_number":null,"raw_text":"index set {h}. We obtain the unary weight function Uλ, with λ = w1/w0, on using the earlier","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq148","equation_number":null,"raw_text":"used only the special case q = 2, which we stated and proved as Lemma 8. However, pinning","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq149","equation_number":null,"raw_text":"Suppose F ⊆Fq. An instance I of #CSP̸=(F) consists of a set V of variables and a set C of","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq150","equation_number":null,"raw_text":"extra constraint C applying the arity-q disequality relation χ̸= with scope (vC,1, . . . , vC,q).","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq151","equation_number":null,"raw_text":"The disequality relation χ̸= is defined by χ̸=(x1, . . . , xq) = 1 if x1, . . . , xq ∈[q] are pairwise","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq152","equation_number":null,"raw_text":"distinct. That is, if they are a permutation of the domain [q]. Otherwise, χ̸=(x1, . . . , xq) = 0.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq153","equation_number":null,"raw_text":"c∈[q] δc) ≤T #CSP̸=(F).","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq154","equation_number":null,"raw_text":"tuple x ∈[q]k and every permutation π : [q] →[q], f(x1, . . . , xk) = f(π(x1), . . . , π(xk)).","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq155","equation_number":null,"raw_text":"that the sets Vc are pairwise disjoint. Let Vq = V \\ S","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq156","equation_number":null,"raw_text":"#CSP̸=(F). The instance has variables Vq ∪{t0, . . . , tq−1}. Every constraint C of I involving","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq157","equation_number":null,"raw_text":"By construction, Z(I′) = P","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq158","equation_number":null,"raw_text":"y0,...,yq−1 Z(I′ | σ(t0) = y0, . . . , σ(tq−1) = yq−1), where the sum","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq159","equation_number":null,"raw_text":"Z(I′) = q!Z(I′ | σ(t0) = 0, . . . , σ(tq−1) = q −1) = q!Z(I).","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq160","equation_number":null,"raw_text":"f ∈F and every tuple x ∈[q]k, f(π1(x1), . . . , π1(xk)) = f(π2(x1), . . . , π2(xk)). Partition the","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq161","equation_number":null,"raw_text":"and ni be the size of the i’th equivalence class, so n1 + · · · + nh = q!.6 Let {π1, . . . , πh} be","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq162","equation_number":null,"raw_text":"n1 ̸= q! since F is not symmetric.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq163","equation_number":null,"raw_text":"such that fi(y1, . . . , yk) ̸= fi(πi(y1), . . . , πi(yk)). If fi(y1, . . . , yk) > fi(πi(y1), . . . , πi(yk)) then","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq164","equation_number":null,"raw_text":"k) = (y1, . . . , yk).","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq165","equation_number":null,"raw_text":"i (yk)). Since g0 < g1 and gn = g0 there","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq166","equation_number":null,"raw_text":"k) = (πξ(y1), . . . , πξ(yk)) so","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq167","equation_number":null,"raw_text":"wi1 > wii. Let si = (txi","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq168","equation_number":null,"raw_text":"k), and let 0 ≤zi ≤h (i = 2, . . . , h) be positive integers, which","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq169","equation_number":null,"raw_text":"λi = Qh","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq170","equation_number":null,"raw_text":"γ=2 wzγ","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq171","equation_number":null,"raw_text":"γi . Note that, given σ(t0) = πi(0), . . . , σ(tq−1) = πi(q −1), the contribution to","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq172","equation_number":null,"raw_text":"k))zγl=","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq173","equation_number":null,"raw_text":"k))zγl=","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq174","equation_number":null,"raw_text":"γ,i =","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq175","equation_number":null,"raw_text":"= λil.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq176","equation_number":null,"raw_text":"l) =","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq177","equation_number":null,"raw_text":"i=1","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq178","equation_number":null,"raw_text":"ni Z( I′ | σ(t0) = πi(0), . . . , σ(tq−1) = πi(q −1) ) λl","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq179","equation_number":null,"raw_text":"We have ensured that λ1 > 0, since wi1 > wii ≥0, so wi1 > 0 for all i = 2, . . . , h. We now","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq180","equation_number":null,"raw_text":"choose the zi’s so that λi ̸= λ1 for all i = 2, . . . , h. If wγi = 0 for any γ = 2, . . . , h, we have","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq181","equation_number":null,"raw_text":"λi = 0 and hence λi ̸= λ1. Thus we will assume, without loss of generality, that wγi > 0 for","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq182","equation_number":null,"raw_text":"all γ = 2, . . . , h and i = 2, . . . , h′, where h′ ≤h. Then we have","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq183","equation_number":null,"raw_text":"zγ = e","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq184","equation_number":null,"raw_text":"γ=2 αγizγ","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq185","equation_number":null,"raw_text":"(i = 2, . . . , h′),","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq186","equation_number":null,"raw_text":"where αγi = ln(wγi/wγ1). Note that αii < 0, since wii < wi1. We need to find an integer","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq187","equation_number":null,"raw_text":"vector z = (z2, . . . , zh) so that none of the linear forms Li(z) = Ph","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq188","equation_number":null,"raw_text":"γ=2 αγizγ is zero, for","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq189","equation_number":null,"raw_text":"i = 2, . . . , h′.","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq190","equation_number":null,"raw_text":"(See, for example, [21].) None of the Li(z) is identically zero, since αii ̸= 0. Consider the","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq191","equation_number":null,"raw_text":"equation Li(z) = 0 makes zi a linear function of zγ (γ ̸= i). Therefore there are at most","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq192","equation_number":null,"raw_text":"Now, by combining terms with equal λi and ignoring terms with λi = 0, we can view","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq193","equation_number":null,"raw_text":"l) = P","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq194","equation_number":null,"raw_text":"c1 = n1Z(I′ | σ(t0) = 0, . . . , σ(tq−1) = q −1).","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq195","equation_number":null,"raw_text":"Z(I′ | σ(t0) = 0, . . . , σ(tq−1) = q −1) = Z(I).","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq196","equation_number":null,"raw_text":"Lemma 18. For every F ⊆Fq, #CSP̸=(F) ≤T #CSP(F).","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq197","equation_number":null,"raw_text":"of θ. Define μ(0) = 1 and for any θ ̸= 0 define μ(θ) = −P","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq198","equation_number":null,"raw_text":"η≤θ,η̸=θ μ(η). Consider the sum","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq199","equation_number":null,"raw_text":"η≤θ μ(η). Clearly, this sum is 1 if θ = 0. From the definition of μ, it is also easy to see that","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq200","equation_number":null,"raw_text":"Now let I be an instance of #CSP̸=(F) with a disequality constraint applied to variables","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq201","equation_number":null,"raw_text":"class of θ(σ) iffσ(ti) = σ(tj). We say that a partition η is consistent with σ (written η ≼σ)","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq202","equation_number":null,"raw_text":"if η ≤θ(σ). Note that η ≼σ means that for any i and j in the same class of η, σ(ti) = σ(tj).","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq203","equation_number":null,"raw_text":"disequality constraint. Then Z(I) = P","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq204","equation_number":null,"raw_text":"σ∈Ωw(σ)1σ, where 1σ = 1 if σ respects the disequality","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq205","equation_number":null,"raw_text":"constraint, meaning that θ(σ) = 0, and 1σ = 0 otherwise. By the M ̈obius inversion formula","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq206","equation_number":null,"raw_text":"Z(I) =","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq207","equation_number":null,"raw_text":"Z(I) =","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq208","equation_number":null,"raw_text":"w(σ) =","raw_latex":null,"normalized_latex":null,"display_type":"block_candidate"},{"equation_id":"eq209","equation_number":null,"raw_text":"the Z(Iη) in #CSP(F). Finally, Z(I) = P","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":55767,"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}}