A complexity dichotomy for hypergraph partition functions

We consider the complexity of counting homomorphisms from an $r$-uniform hypergraph $G$ to a symmetric $r$-ary relation $H$. We give a dichotomy theorem for $r>2$, showing for which $H$ this problem is in FP and for which $H$ it is #P-complete. This …

Authors: Martin Dyer, Leslie Ann Goldberg, Mark Jerrum

A complexit y dic hotom y for h yp ergraph partiti on functions ∗ Martin Dy er Sc ho ol of Computing Univ ersity of Leeds Leeds LS2 9JT, UK Leslie Ann Go ldb erg Departmen t of Computer Science, Univ ersity of Liverpo ol, Liv erp o ol L 69 3BX, UK Mark Jerrum Sc ho ol of Mathematical Sciences , Queen Mary , Univers it y of London Mile End Ro ad, London E1 4NS, UK No v ember 15, 2018 Abstract W e consider the complexit y of coun ting homomorphisms from a n r -uniform hyperg raph G to a symmetric r -a ry r elation H . W e give a dichotom y theorem for r > 2, showing for which H this pro blem is in FP and for which H it is #P -co mplete. This genera lis es a theorem of Dyer and Greenhill (2000 ) for the case r = 2, which cor r esp onds to counting gra ph homomor phisms. Our dic hoto my theorem extends to the cas e in which the relation H is weigh ted, and the goal is to compute the p artition function , which is the sum of weigh ts of the homomorphisms . This problem is motiv ated by statistical physics, where it arises as computing the partition function for pa rticle mo dels in which ce rtain combinations o f r sites interact symmetrically . In the weigh ted case, our dichotom y theorem generalis e s a re s ult of Bula tov and Gr ohe (20 05) fo r graphs, where r = 2. When r = 2, the p olynomia l time cases of the dichotom y cor resp ond simply to rank-1 w eights. Surprisingly , fo r all r > 2 the p olynomial time cas e s of the dichotom y have rather more s tr ucture. It turns out that the weights must b e super impo sed on a combinatorial structure defined b y solutions o f a n e q uation over an Ab elian gr oup. Our result a lso g ives a dichotom y for a closely related co nstraint satisfaction problem. 1 In tro duction W e consider the complexit y of coun ting homomorphisms f rom an r -un if orm h yp ergraph G to a symmetric r -ary relation H . W e will giv e a dichotom y theorem for r > 2, sho w ing that count ing is in p olynomial time for certain H and is #P -complete for th e remainder. Moreo v er our dichoto m y is effe ctive , meaning that there is an algorithm that tak es H as input and determines whether the counting p r oblem is p olynomial time solv able or whether it is #P -complete. This generalises a theorem of Dy er and Greenh ill [10] for the case r = 2, wh ich corresp onds to count ing graph homomorphisms or H -colourings. ∗ P artly funded by the EPSRC grant “The complexity of counting in constraint satisfaction problems”. Some of the work was done while th e authors w ere visiting the “Com b inatorics and St atistical Mechanics” programme of th e Isaac Newton In stitute for Mathematical S ciences, Un ivers ity of Cambridge. 1 Our dichoto m y extends to th e case in wh ich the relation H is weigh ted, and w e wish to compute the p artition function , whic h is the s u m of w eigh ts of all homomorphisms. Here our dichot om y theorem extends a r esu lt of Bulato v and Grohe [4] for the case of graphs, r = 2. In the graph dic hotom y , the p olynomial time cases corresp ond simply to w eigh ts wh ic h form rank-1 matrices. Surp r isingly , for all r > 2, the p olynomial time solv able cases are more structured . It turns out that the weig ht s m ust b e sup erimp osed on a com b inatorial s tr ucture defi ned b y solutions of an equation o ver an Ab elian group . W e note that this already app ears in a disguised form in the case r = 2. Th e bipartite case, whic h has no ob vious analogue for r > 2, corresp onds to the equation α 1 + α 2 = 1 o ver the group Z 2 . A motiv ation for considering this question comes f rom statistica l physic s. Id entifying V ( G ) with a set of sites and D with a set of q spins , the qu an tit y that we w ish to compute, Z g ( G ), can b e view ed as the partition function of a statistical physics mo del in whic h certain sets of r sites in teract symmetrically , and their int eraction con trib u tes to the Hamiltonian of the system. Th e partition function then giv es the normalising constan t for the Gibbs distribution of the system. The sets of r interacti ng sites are the edges of G . (Sometimes, an edge of size greater than 2 is referred to as a “h yp eredge”, but we d o not use that terminology here.) Clearly , the sites in an edge should b e distinct, although their spins need not b e. In this application, the edges wo uld usually represent sets of sites w h ic h are in close physical pr o x im ity . 1.1 Notation and definitions An r -unif orm hyp er gr aph G w as defin ed by Berge [1] to b e a system of subsets of a set V ( G ), wh er e n = | V ( G ) | , in which eac h s u bset has cardinalit y r . The elemen ts of V ( G ) are the vertic es of the h yp ergraph , and the su bsets are its e dges . Th en E ( G ) d enotes the e dge set of G . Let M = | E ( G ) | . Note that the edges of G are distinct s ets, otherwise the set system is a multihyp er gr aph . Note also that the edges are sets, not multisets , otherwise the multiset system has b een called a hyp er gr aph with multiplicities [12]. Note that “ r -uniform h yp ergrap h with m ultiplicities” is syn on ymous with “symmetric r -ary relation”. A lo op is th en a (m ultiset) edge in which all r v ertices are the same [12]. Therefore a simple gr aph G = ( V , E ) (having no lo ops or p ar al lel e dges ) is a 2-un iform hyp ergraph, a graph with p arallel edges is a 2-uniform m ultih yp er grap h , and a graph with lo ops is a 2-uniform h yp ergraph w ith m ultiplicities, or a symmetric binary relation. Let D b e a finite set with q = | D | . W e w ill assume q ≥ 2, since the cases q ≤ 1 are trivial. F or some r ≥ 3, we consider a sym m etric r -ary fu nction g with domain D and cod omain a set of real n umbers. The co domain w e will c ho ose is the set of n onnegativ e algebraic num b ers, Q ≥ 0 . Th us Q denotes th e fi eld of all algebraic n umbers, and w e let Q > 0 denote th e p ositiv e num b ers in Q . Our principal reason for this choi ce is that arithmetic op erations and comparisons on suc h num b ers can b e carried out exact ly on a T u ring mac hine. S ee, for example, [6]. Moreo ve r, since our analysis is en tirely concerned with p olynomial equations, it is n atural to work in Q , whic h is th e algebraic closure of the rational field Q . Giv en a sym metric fun ction g : D r → Q ≥ 0 and an r -u niform h yp er grap h G as input, the partition function asso ciated with g is Z g ( G ) = X σ : V ( G ) → D Y ( u 1 ,...,u r ) ∈ E ( G ) g ( σ ( u 1 ) , . . . , σ ( u r )) . (1) Eval ( g ) is the problem of computing Z g ( G ), giv en th e input G . Eac h c h oice f or the function g leads to a computatio nal pr oblem whic h we will call Eval ( g ), and w e ma y ask ho w the computational 2 complexit y of Eval ( g ) v aries with g . W e m ay view (1) as th e ev aluation of a m u ltiv ariate p olynomial function of the weights g ( x ) ( x ∈ D r ). If there are N different irrational w eights ξ 1 , ξ 2 , . . . ξ N , w e can p erf orm the necessary computations in the field Q ( ξ 1 , ξ 2 , . . . ξ N ). It is kn o w n th at this field is equiv alen t to Q ( θ ) for a single algebraic num b er θ , the p rimitiv e elemen t, and an algorithm to determine θ exists. W e do n ot need to consid er the efficiency of this algorithm, sin ce N is a constan t. Th e standard repr esen tation of a n u m b er in Q ( θ ) is a constan t degree p olynomial in θ w ith rational coefficien ts. Arithmetic op erations in Q ( θ ) can b e carried out in this repr esen tation. F or d etails, see [6 ]. W e assume that g is pre-pr o cessed so th at all w eigh ts are giv en in this stand ard represent ation. Some of our in termediate reductions seemingly r equire computing in larger algebraic num b er fields. T his is tru e ev en if all original w eights are rational, and justifies our c h oice of Q as the codomain of g . W e will su pp ose, w ithout furth er commen t, that the necessary algebraic num b ers are adj oined to Q ( θ ) as required. In an y case, w e compute only in num b ers fields which ha v e constant d egree ov er Q . Despite this increase in field size during our redu ctions, we will sho w that the resulting algorithm for the p olynomial time solv able cases can p erform its computations en tirely within Q ( θ ). Note that the exact representa tion in Q ( θ ) can also b e used to compute in FP any p olynomial num b er of bits of the binary expans ion of Z g ( G ), if this is required. It is easy to b ound the num b er of d ifferen t monomials w h ic h occur in (1). Su pp ose there are K nonzero weig h ts, for some 0 ≤ K ≤  q r  . Then the p olynomial (1) has at most  M + K − 1 K − 1  = O ( M K − 1 ) monomial terms, whic h is p olynomial in the size of the input. Eac h monomial can b e computed exactly in FP , working in the field Q ( θ ). The co efficien t of eac h monomial is an intege r, w hic h is easily seen to b e computable in # P . The nondeterministic T u ring mac hin e guesses σ : V ( G ) → D , computes th e term in (1) as a monomial in the we igh ts and accepts if it is the c h osen monomial. Therefore Z g ( G ) can b e computed exactly in FP #P as an elemen t of Q ( θ ). Consequ en tly , sh o wing that Z g ( G ) is #P -hard implies that it is complete for FP #P . W e mak e use of this ob s erv ation b elo w. It will b e helpfu l to describ e a c onstr aint satisfaction pr oblem which is closely related to Eval ( g ). An instance I of # CSP ( g ) consists of a set V ( I ) = { v 1 , . . . , v n } of variables and a m ultiset E ( I ) of c onstr aints . Eac h constrain t has a sc op e , ( u 1 , . . . , u r ), whic h is a tup le of r v ariables. The partition function Z g ( I ) is giv en b y Z g ( I ) = X σ : V ( I ) → D Y ( u 1 ,...,u r ) ∈ E ( I ) g ( σ ( u 1 ) , . . . , σ ( u r )) . (2) Th us, eve ry instance G of Eval ( g ) can b e viewe d as an instance of # CSP ( g ) by taking the vertic es as v ariables and the edges as constrain t scop es. The v alue of the partition f unction that gets output is the same in b oth cases. Thus, w e ha v e a trivial p olynomial time reduction from Eval ( g ) to # CSP ( g ). The opp osite is not necessarily true, b ecause a constrain t scop e ( u 1 , . . . , u r ) of an instance I of # CSP ( g ) migh t not b e an edge – the same v ariable might app ear more than once amongst u 1 , . . . , u r . Also, th e same scop e migh t app ear more than once in E ( I ). So an instance I of # CSP ( g ) might n ot b e a pr op erly-formed ins tance of Eval ( g ). In fact, I is a m ultih yp ergraph with multiplicit ies in general, r ather than a hyp ergraph. Neve rtheless, our m ain r esult applies also to the pr oblem # CS P ( g ) — see Corollary 3. W e note th at b oth the Eval ( g ) and the # CS P ( g ) problems hav e b een studied extensive ly . 3 The problem # CS P ( g ) ma y b e generalised to the case in w h ic h th e p arameter g is rep laced by a set of functions Γ. If Γ is a set of fun ctions (of v arious arities) f r om D to Q ≥ 0 , then # CS P (Γ) is the problem of computing th e partition function of an instance I in whic h eac h constraint with r -ary scop e sp ecifies a particular r -ary function fr om Γ w hic h should b e applied to the scop e in the partition function. See [4] or [9] for fu rther details. If the functions in Γ are n ot r equired to hav e an y additional prop erties, lik e symmetry or giv en arit y , # CSP (Γ) is actually no more general th an # CSP ( g ), at least from the viewp oin t of computational complexit y . It can b e s ho wn th at the tw o problems h a ve the same complexit y under p olynomial time redu ctions [5]. Note, ho we v er, that the reduction from # CSP (Γ) to # CSP ( g ) giv en in [5] do es not pr eserv e symm etry . So th is equiv alence do es not p ermit us to r eplace a family Γ of symmetric functions b y a single symmetric fu nction g . This h olds ev en in the simplest p ossible case in which Γ has t w o unary functions. Hence, restricted to symmetric fu nctions, # CSP (Γ) m a y b e a m ore general problem than # CSP ( g ), but we do n ot consider it fu rther here. 1.2 Previous w ork The computational complexit y of p r oblems of th e type we consid er here wa s first inv estigated by Dy er and Greenhill [10], wh o examined the complexit y of Eval ( g ) in the sp ecial case in w hic h r = 2 and g : D 2 → { 0 , 1 } , so g is equiv alen t to a symmetric relation on D . This is the problem of coun ting homomorphisms from an input simple graph G to a fixed (un d irected) graph H , p ossibly with loop s , where the function g rep resen ts th e adj acency matrix of H . They sho wed that th ere is a p olynomial time algorithm when eac h connected comp onent of H is either a complete un lo op ed bipartite graph or a complete lo op ed graph . In all other cases the coun ting problem Eval ( g ) is #P -complete. More generally , Bulato v and Grohe [4 ] considered the complexit y of # CSP ( g ) when g is a symmetric binary fun ction on D . If the input is a simp le graph G , we can think of this as counting w eigh ted homomorphisms from G to an undir ected graph H with nonnegativ e edge weigh ts. The fu nction g is equiv alen t to the w eigh ted adjacency matrix A of H . I f H is conn ected, then we sa y that the matrix A is “connected”, otherwise the “connected comp onents” of A corresp ond to the conn ected comp onent s of the graph H . Sim ilarly , we sa y that A is b ipartite if and only if H is b ipartite. In this setting, Bulato v and Grohe [4] established the f ollo wing imp ortan t theorem, wh ic h is cen tr al to our analysis. Theorem 1 (Bulato v and Groh e) . L et A b e a symmetric matrix with non-ne gative r e al entries. (1) If A is c onne cte d and not bi p artite, then Eval ( A ) is in p olynomial time if the r ow r ank of A is at most 1; otherwise Eval ( A ) is # P -har d. (2) If A is c onne cte d and bip artite, then Eval ( A ) is in p olynomial time if the r ow r ank of A i s at most 2; otherwise Eval ( A ) is #P -har d. (3) If A is not c onne cte d, then Eval ( A ) is in p olynomial time i f e ach of its c onne cte d c omp onents satisfies the c orr esp onding c ondition state d in (1) or (2); otherwise Eval ( A ) is #P -har d. Although T heorem 1 is stated for r eal n u m b ers, we w ill make use of it on ly in the case of the algebraic num b ers, sin ce it is not clear to us ho w it extends to the mo dels of real computation discussed in [4]. W e p refer to work entirely in the stand ard T urin g machine mo del of computation, though there ma y wel l b e mo dels of real compu tation in wh ich Theorem 1 is v alid. F or algebraic 4 n umbers, w h ic h includ e the r ationals, all the arithmetic op erations and comparisons required in our reductions, and those of [4], can b e carried out exactly in the T uring machine mo del. In the unw eighte d case of # CSP (Γ), wh ere all functions in Γ h a ve co domain { 0 , 1 } , Bu lato v [2] has recen tly shown that there is a dic h otom y b et w een those Γ for w h ic h # CSP (Γ) is p olynomial time solv able, and th ose f or which it is #P -complete. The dic hotomy can b e extended to the case in whic h all f unctions in Γ hav e co domain Q ≥ 0 , th e n onnegativ e r ational n um b er s , using p olynomial time redu ctions [5]. Ho wev er, the reductions inv olv ed d o not seem to extend to functions with co domain Q ≥ 0 . Establishing the existence of a dic hotom y for # CSP (Γ) is a ma j or b reakthrough. Nev ertheless, the tec hn iques of [2] shed v ery little light on wh ic h Γ ren der # CSP (Γ) p olynomial time solv able, and w hic h Γ render it #P -h ard . In the current state of knowledge, Bulato v’s dic hotom y [2] is not effectiv e, and its decidabilit y is an op en qu estion. 1.3 The new results Our main theorem, Theorem 2, giv es a dic hotom y for th e case in which Γ co nt ains a sin gle symmetric function g . F or this problem, w e iden tify a s et of functions g for which Eval ( g ) is computable in FP , and we s h o w that, for ev ery other fun ction g , Eval ( g ) is complete for FP #P . W e examine b oth Eval ( g ) and # CS P ( g ) in this setting, and giv e an explicit dichot om y theorem in b oth cases, extending the theorems of Dy er and Greenhill [10] and Bulato v and Grohe [4] to r > 2. In the r > 2 case, the pr oblem Eval ( g ) can b e understo od as ev aluating sums of weigh ted homomorphisms from an inp ut hyp ergraph G to a fixed weig h ted hyp ergraph with multiplicities H . The we igh ts of edges in H are r epresen ted by th e function g . As in the r = 2 case, there is a dic h otom y , but this time some n on trivial algebraic structur e is in v olv ed in the classification. The p olynomial time solv able cases ha ve r ank-1 we igh ts as b efore, but this time, these weigh ts are sup erimp osed on a com binatorial structure defined by solutions to an equation o v er an Ab elian grou p . In particular, Eval ( g ) is p olynomial time solv able if and only if eac h connected piece of the domain factors as the cartesian pro du ct of t w o sets A and [ s ]. Th en, for any α 1 , . . . , α r ∈ A and i 1 , . . . , i r ∈ [ s ], the v alue of g (( α 1 , i 1 ) , . . . , ( α r , i r )) is equal to 0 u nless ( α 1 , . . . , α r ) is a solution to an equation in an Ab elian group with domain A . In that case, th e v alue g (( α 1 , i 1 ) , . . . , ( α r , i r )) is just the pro du ct of some p ositiv e we igh ts λ i 1 , . . . , λ i r . A “connected piece” of the domain is defined as follo ws: t wo elemen ts z and z ′ are link ed if there are some z 2 , . . . , z r − 1 suc h that g ( z , z 2 , ..., z r − 1 , z ′ ) > 0. I n general, t wo elemen ts z and z ′ are connected if there is a sequence of c elemen ts z 1 , . . . , z c with z = z 1 and z ′ = z c suc h that eac h pair ( z i , z i +1 ) is link ed. See Theorem 2 for details. In fact, it tur n s out that there is only one wa y to factor the connected comp onen t of the domain in to A and [ s ] (see Theorem 4). Th us, there is a straigh tforw ard algo rithm that tak es g and determines whether Eval ( g ) is in FP or is #P -hard. See Sections 7 and 8. Our r esult is in a similar spirit to the result of Kl ´ ıma, Larose and T esson [11] w hic h giv es a dic hotom y for the problem of counting the n u m b er of solutions to a system of equations ov er a fixed semigroup. Although our application is rather differen t, parts of our pro of draw in spiration from the pro of of their theorem. 5 2 The main theorem F or 1 ≤ k ≤ r , we w ill define f [ k ] ( z 1 , . . . , z k ) = X z k +1 ,...,z r ∈ D g ( z 1 , . . . , z r ) . Note that f [ k ] is symmetric and that f [ r ] ( z 1 , . . . , z r ) = g ( z 1 , . . . , z r ). Let R [ k ] = { ( z 1 , . . . , z k ) : f [ k ] ( z 1 , . . . , z k ) > 0 } b e the relation und erlying f [ k ] . W e will view relations either as su bsets of D k or as fun ctions D k → { 0 , 1 } according to con v enience. T o a void trivialities, we assume that R [1] is the complete relation, i.e., that all elemen ts of D participate in the relation; if not, an equiv alen t problem can b e formed by simply remo ving the non-participating elemen ts from D . F or any k < r w e ha v e f [ k ] ( z 1 , . . . , z k ) = P z k +1 ∈ D f [ k +1] ( z 1 , . . . , z k +1 ) so if k ≥ 2 then ( z 1 , z 2 ) ∈ R [2] is equiv alen t to “there exist z 3 , . . . , z k suc h th at ( z 1 , . . . , z k ) ∈ R [ k ] ”. Let ≡ b e the equiv alence relation whic h is the tran s itiv e, reflexiv e closure of R [2] . The domain D is p artitioned in to equ iv alence classes (“connected comp onents”) D = D 1 ∪ · · · ∪ D m b y ≡ . W e will u se the follo win g notation: W e w ill let ℓ r an ge o ver [ m ], and use it to refer to a particular connected comp onent D ℓ . When app lied to an y fun ction as a su bscript, it denotes the restriction of that fun ction to the relev an t connected comp onen t. F or example, f [ k ] ℓ : ( D ℓ ) k → Q ≥ 0 denotes the restriction of f [ k ] to the ℓ th conn ected comp onent D ℓ . Likewise, g ℓ is th e restriction of g to D ℓ . Giv en th e d efi nition of ≡ , it is clear that f [ k ] = f [ k ] 1 ⊕ · · · ⊕ f [ k ] m (meaning th at f [ k ] ( z 1 , . . . , z k ) = 0 unless z 1 , . . . , z k are all in th e s ame connected comp onent). W e can now state the main theorem. Theorem 2. L et g : D r → Q ≥ 0 b e a symmetric function with arity r ≥ 3 and c onne cte d c omp onents D 1 , . . . , D m as ab ove. If g satisfies the fol lowing c onditions, for al l ℓ ∈ [ m ] , then Eval ( g ) is in FP . Otherwise, Eval ( g ) is c omplete for F P #P . Mor e over, the dichotomy i s effe ctive. • Ther e i s a set A ℓ and a p ositive inte ger s ℓ , such that D ℓ is the Cartesian pr o duct of A ℓ and [ s ℓ ] (which we write as D ℓ ∼ = A ℓ × [ s ℓ ] ). • Ther e ar e p ositive c onstants { λ ℓ,i : i ∈ [ s ℓ ] } and a r elation S ℓ ⊆ A ℓ such that, for α 1 , . . . , α r ∈ A ℓ and i 1 , . . . , i r ∈ [ s ℓ ] , g ℓ (( α 1 , i 1 ) , . . . , ( α r , i r )) = λ ℓ,i 1 · · · λ ℓ,i r S ℓ ( α 1 , . . . , α r ) . • Ther e is an Ab elian g r oup ( A ℓ , +) and an e quation α 1 + · · · + α r = a (for some element a ∈ A ℓ ) which defines S ℓ in the sense that ( α 1 , . . . , α r ) ∈ S ℓ if and only if α 1 + · · · + α r = a . The algorithm u sed in the p olynomial time solv able cases of Th eorem 2 still w orks if the instance is a CSP ins tance rather than a h yp ergraph . Thus, w e ha v e the follo wing corollary . Corollary 3. L et g : D r → Q ≥ 0 b e a symmetric function with arity r ≥ 3 and c onne cte d c omp onents D 1 , . . . , D m as ab ove. If g satisfies the c onditions i n The or em 2 for al l ℓ ∈ [ m ] , then # CSP ( g ) is in FP . Otherwise, # CSP ( g ) i s c omplete f or FP #P . Mor e over, the dichotomy is e ffe ctive. Some of the #P -hardn ess pr o ofs in the pro of of Theorem 2 could b e simplified if we allo w ed ourselves a general CSP instance rather than a hyp ergraph, but we refrain from using this simplification in order to obtain the strongest-p ossible r esult (that is, to obtain Theorem 2 rather than ju st Corollary 3). 6 3 A restatemen t of the main theorem W e introdu ce some fu rther notation and restate the main theorem more compactly . Along the wa y w e gather more in formation, e.g., ab out the factorization D ℓ ∼ = A ℓ × [ s ℓ ]. W e define the equiv alence relation ∼ k on D as f ollo ws: z 1 ∼ k z ′ 1 iff there is a λ in Q > 0 suc h that, for all z 2 , . . . , z k ∈ D , f [ k ] ( z 1 , z 2 , . . . , z k ) = λf [ k ] ( z ′ 1 , z 2 , . . . , z k ). Note th at ∼ k refines ∼ k − 1 . Also, ∼ 2 refines ≡ since, for an y z 1 , z ′ 1 ∈ D , z 1 ∼ 2 z ′ 1 implies that there exists z 2 satisfying R [2] ( z 1 , z 2 ) and R [2] ( z ′ 1 , z 2 ), which in tu rn implies z 1 ≡ z ′ 1 . Let [ x ] [ k ] = { y : y ∼ k x } b e the equiv alence class of x und er ∼ k . Cho ose a un ique r epresen tativ e ¯ x [ k ] ∈ [ x ] [ k ] . Thus ¯ x [ k ] = ¯ y [ k ] if and only if x ∼ k y . Let A [ k ] =  ¯ x [ k ] : x ∈ D  . Let A [ k ] ℓ denote the restriction of A [ k ] to D ℓ so A [ k ] ℓ =  ¯ x [ k ] : x ∈ D ℓ  . Note that R [ k ] is consistent with ∼ k in the sense that R [ k ] ( z 1 , . . . , z k ) = R [ k ] ( ¯ z [ k ] 1 , . . . , ¯ z [ k ] k ), so we can quotien t R [ k ] b y ∼ k to get a relation S [ k ] = R [ k ] / ∼ k on A [ k ] . Note that S [ k ] is just the restriction of R [ k ] to A [ k ] . Also, S [ k ] ℓ is the restriction of R [ k ] ℓ to A [ k ] ℓ . Supp ose k is in the range 2 ≤ k ≤ r . W e say that g is k - f actoring if the follo wing conditions h old for ev ery ℓ ∈ [ m ]. 1. T h ere is a p ositiv e int eger s [ k ] ℓ suc h that D ℓ is the C artesian pro du ct of A [ k ] ℓ and [ s [ k ] ℓ ] (whic h w e write as D ℓ ∼ = A [ k ] ℓ × [ s [ k ] l ]). 2. T h ere are p ositiv e constan ts { λ [ k ] ℓ,i : i ∈ [ s [ k ] ℓ ] } such that, for α 1 , . . . , α k ∈ A [ k ] ℓ and i 1 , . . . , i k ∈ [ s [ k ] ℓ ], f [ k ] ℓ (( α 1 , i 1 ) , . . . , ( α k , i k )) = λ [ k ] ℓ,i 1 · · · λ [ k ] ℓ,i k S [ k ] ℓ ( α 1 , . . . , α k ) . If g is k -factoring then w e say that g is k -e quational if, for ev ery ℓ ∈ [ m ], there is an Ab elian group ( A [ k ] ℓ , +) an d an equation α 1 + · · · + α k = a (for some elemen t a ∈ A [ k ] ℓ ) which d efines S [ k ] ℓ in the sense that ( α 1 , . . . , α k ) ∈ S [ k ] ℓ if and only if α 1 + · · · + α k = a . Our main theorem (T h eorem 2) can b e restated as f ollo ws: Theorem 4. L et g : D r → Q ≥ 0 b e a symmetric function with arity r ≥ 3 . If g is r -f actoring and r - e quational then Eval ( g ) is in F P . Otherwise, Eval ( g ) is c omplete f or FP #P . Mor e over, the dichotomy is effe ctive . Before proving Theorem 4, w e prov e that it is equiv alen t to Th eorem 2 . First, it is easy to see that if g satisfies the conditions of Theorem 4 (that is, it is r -factoring and r -equational) then it also satisfies the conditions of Theorem 2 (taking A ℓ to b e A [ r ] ℓ , s ℓ to b e s [ r ] ℓ , and λ ℓ,i to b e λ [ r ] ℓ,i ). The other direction is a little less ob vious . Supp ose that g satisfies the cond itions of Theorem 2. Fix any ℓ ∈ [ m ]. F rom the first condition of Theorem 2, we ha v e D ℓ ∼ = A ℓ × [ s ℓ ]. Consider any α, α ′ ∈ A ℓ and an y i, i ′ ∈ [ s ℓ ]. W e will argue that ( α, i ) ∼ r ( α ′ , i ′ ) if and only if α = α ′ . First, supp ose α = α ′ . Then, for any α 2 , . . . , α r ∈ A ℓ and i 2 , . . . , i r ∈ [ s ℓ ], the second condition of Theorem 2 giv es g ℓ (( α, i ) , ( α 2 , i 2 ) , . . . , ( α r , i r )) = λ ℓ,i λ ℓ,i 2 · · · λ ℓ,i r S ℓ ( α, α 2 , . . . , α r ) and g ℓ (( α ′ , i ′ ) , ( α 2 , i 2 ) , . . . , ( α r , i r )) = λ ℓ,i ′ λ ℓ,i 2 · · · λ ℓ,i r S ℓ ( α, α 2 , . . . , α r ) , 7 so, by the d efinition of ∼ r , ( α, i ) ∼ r ( α ′ , i ′ ). Next, su pp ose ( α, i ) ∼ r ( α ′ , i ′ ). Then there is a p ositiv e constan t λ su c h that, for any α 2 , . . . , α r ∈ A ℓ and i 2 , . . . , i r ∈ [ s ℓ ], λ ℓ,i λ ℓ,i 2 · · · λ ℓ,i r S ℓ ( α, α 2 , . . . , α r ) = λλ ℓ,i ′ λ ℓ,i 2 · · · λ ℓ,i r S ℓ ( α ′ , α 2 , . . . , α r ) . W e conclude that, for an y α 2 , . . . , α r ∈ A ℓ , S ℓ ( α, α 2 , . . . , α r ) = S ℓ ( α ′ , α 2 , . . . , α r ). By the third condition in T heorem 2, we conclude th at α = α ′ . W e hav e no w shown that ( α, i ) ∼ r ( α ′ , i ′ ) if and only if α = α ′ . This implies that w e can tak e the set A [ r ] ℓ of uniqu e representa tiv es to b e A ℓ and we can take s [ r ] ℓ to b e s ℓ . Then, taking λ [ r ] ℓ,i to b e λ ℓ,i , g is r -factoring and r -equational (so it satisfies the conditions of Theorem 4). So we conclud e that the tw o theorems are equiv alent. No w th at w e hav e sho wn that Th eorem 4 is equ iv alent to Theorem 2, the rest of the pap er will fo cus on pro ving Theorem 4. The ca se r = 2 is that of we igh ted gr aph h omomorphism, which w as analysed b y Bulato v and Grohe [4]. Theorem 4 is true also w h en r = 2. In this situation, it could b e view ed as a restatemen t of their result. Note, how ev er, that “2-equatio nal” is a restricted notion that places seve re constrain ts on the group s ( A [2] ℓ , +) that can arise. In deed the only p ossib ilities that are consisten t with the connectivit y relation ≡ are the 2-elemen t group C 2 (“bipartite comp onent”) and the trivial group (“non-bipartite comp onen t”). It will follo w from th e pro of of Theorem 4 (assuming that #P 6⊆ FP) that a symm etric function g of arity r ≥ 3 that is r -factoring and r -equational is k -factoring and k -equational for all 2 ≤ k < r . In fact, the Ab elian group s ( A [ k ] ℓ , +) will all b e trivial for k < r : non-trivial group structure is only p ossible at the top level. As a fi rst step in the pro of of T h eorem 4 , we v erify that n on-trivial group structure is only p ossible at th e top lev el. Lemma 5. L et g : D r → Q ≥ 0 b e a symmetric f unction with arity r ≥ 3 . If g is k -factoring and k -e quational for some k < r then f or every ℓ ∈ [ m ] ther e ar e p ositive c onstants { λ [ k ] ℓ,i : i ∈ D ℓ } such that, for i 1 , . . . , i k ∈ D ℓ , f [ k ] ℓ ( i 1 , . . . , i k ) = λ [ k ] ℓ,i 1 · · · λ [ k ] ℓ,i k . Pr o of. g is k -factoring so D ℓ ∼ = A [ k ] ℓ × [ s [ k ] l ] and, for α 1 , . . . , α k ∈ A [ k ] ℓ and i 1 , . . . , i k ∈ [ s [ k ] ℓ ], f [ k ] ℓ (( α 1 , i 1 ) , . . . , ( α k , i k )) = λ [ k ] ℓ,i 1 · · · λ [ k ] ℓ,i k S [ k ] ℓ ( α 1 , . . . , α k ) . No w consider α 1 , . . . , α k +1 ∈ A [ k ] ℓ and i 1 , . . . , i k +1 ∈ [ s [ k ] ℓ ]. If f [ k +1] ℓ (( α 1 , i 1 ) , . . . , ( α k +1 , i k +1 )) > 0 then f [ k ] ℓ (( α 1 , i 1 ) , . . . , ( α k − 1 , i k − 1 ) , ( α k , i k )) > 0 and f [ k ] ℓ (( α 1 , i 1 ) , . . . , ( α k − 1 , i k − 1 ) , ( α k +1 , i k +1 )) > 0 . So since g is k -equational, α 1 + · · · + α k − 1 + α k = α 1 + · · · + α k − 1 + α k +1 = a so α k = α k +1 . By symmetry , α 1 = · · · = α k +1 . 8 No w if (( α, i ) , ( β , j )) ∈ R [2] then there exist α 2 , . . . , α k and i 2 , . . . , i k suc h that f [ k +1] (( α, i ) , ( β , j ) , ( α 2 , i 2 ) , . . . , ( α k , i k )) > 0 . Th us, α = β . T aking the tr an s itiv e closure, w e note that if ( α, i ) and ( β , j ) are b oth in D ℓ then α = β . Hence | A [ k ] ℓ | = 1 so D ℓ = [ s [ k ] ℓ ]. Our strategy for pro ving Theorem 4 is now as follo ws. Supp ose Eval ( g ) is not #P -hard. W e pro v e, for k = 2 , 3 , . . . , r in turn, that g is k -factoring and k -equational. F or k = 2 this follo ws straigh tforwardly f rom Theorem 1. The ind u ctiv e step fr om k to k + 1 is where the wo rk lies, bu t Lemma 5 pla ys a role. Ultimate ly , we dedu ce that g is r -factoring and r -equational. Con v ersely , if g is r -factoring and r -equational, the partition function Z g ma y b e compu ted in p olynomial time using existing algorithms for coun ting solutions to systems o ver Ab elian groups, and hence Eval ( g ) is p olynomial time solv able. 4 Preliminaries An easy observ ation that will b e f r equen tly us ed in the rest of this pap er is th e follo wing. Lemma 6. If Eval ( f [ k ] ) is #P -har d, for some 2 ≤ k < r , then so is Eval ( g ) . Pr o of. An instance of Eval ( f [ k ] ) is a k -uniform hyp ergraph. Simp ly pad eac h edge e = ( u 1 , . . . , u k ) to size r b y adding r − k fresh vertice s as follo ws: ( u 1 , . . . , u k , z e k +1 , . . . , z e r ). It is easy to verify that this is a p olynomial time redu ction from Eval ( f [ k ] ) to Eval ( g ). Another easy observ ation is that the partition function Z g ( G ) factorises if G is not connected. So w e ma y assu me henceforth that th e instance hyp ergraph G is connected. F or z ∈ D let λ ′ [ k ] z b e defin ed so that, for all z 2 , . . . , z k ∈ D , f [ k ] ( z , z 2 , . . . , z k ) = λ ′ [ k ] z f [ k ] ( ¯ z [ k ] , z 2 , . . . , z k ) . (Recall fr om the definition of ∼ k that λ ′ [ k ] z do es n ot dep end on z 2 , ..., z k .) Th en, by symmetry , w e ha v e f [ k ] ( z 1 , . . . , z k ) = λ ′ [ k ] z 1 · · · λ ′ [ k ] z k f [ k ] ( ¯ z [ k ] 1 , . . . , ¯ z [ k ] k ) . (3) Define ˜ f [ k ] ( z 1 , z ′ 1 ) = X z 2 ,...,z k ∈ D f [ k ] ( z 1 , z 2 , . . . , z k ) f [ k ] ( z ′ 1 , z 2 , . . . , z k ) . Let e R [ k ] b e the (sym metric) binary relation underlying ˜ f [ k ] . It will turn out that e R [ k ] and ∼ k coincide when g is not # P -hard. F or the pu rp oses of this p ap er, a symmetric relation R ⊂ A k is said to b e a L atin hyp er cub e if, f or all α 1 , . . . , α k − 1 ∈ A , there exists a unique α k ∈ A such that ( α 1 , . . . , α k ) ∈ R . Note that symmetry implies similar statemen ts with the α i s p erm uted. This d efi nition sp ecialise s to the familiar notion of Latin square if w e tak e k = 3 and think of α 1 , α 2 and α 3 as r anging o v er ro ws , column s and sym b ols, r esp ectiv ely . F or k > 3 it is consistent w ith the existing, if less familiar, notion of Latin ( k − 1) -h yp ercub e. W e u se the follo wing interp olation result, wh ich is [10, Lemma 3.2] 9 Lemma 7. L et η 1 , . . . , η m b e known distinct nonzer o c onstants Supp ose that we know values Z 1 , . . . , Z m such that Z p = P m ℓ =1 γ ℓ η p ℓ for 1 ≤ p ≤ m . The c o efficients γ 1 , . . . , γ m c an b e eval- uate d in p olynomial time. Lemma 7 has the f ollo wing consequen ce, s ince if we ha v e η i = η j b elo w w e can combine γ i and γ j in to γ i + γ j . Corollary 8. L et η 1 , . . . , η m b e known nonzer o c onstants Supp ose that we know values Z 1 , . . . , Z m such that Z p = P m ℓ =1 γ ℓ η p ℓ for 1 ≤ p ≤ m . The value Z 0 = P m ℓ =1 γ ℓ c an b e c ompute d in p olynomial time. As menti oned earlier, the base case ( k = 2) in the pro of of Theorem 4 will follo w from the resu lt of Bulato v an d Grohe [4 ]. Th ey examined the complexit y of # CSP ( g ) and there is n o immediate p olynomial time reduction from # CSP ( g ) to Eval ( g ). The n ext lemma pro vides suc h a reduction for the case th at w e requir e. Lemma 9. Supp ose h : D 2 → Q ≥ 0 has c onne cte d c omp onents D 1 , . . . , D ℓ , and underlying r ela- tion R h . Supp ose also that R h has no bip artite c omp onents. If the r e striction h ℓ of h to any c omp onent D ℓ is not r ank 1, then Eval ( h ) is #P -har d. Pr o of. Let I b e an instance of # CSP ( h ). View I as a multigraph with p ossible lo ops and parallel edges. F orm the graph G as the “2-stretc h” of I ; that is to sa y , sub divide eac h edge of I b y in tro ducing a n ew v ertex. Note that G is a simp le graph without lo ops. Define the sym m etric function h (2) : D 2 → Q ≥ 0 b y h (2) ( x, y ) = P z ∈ D h ( x, z ) h ( y , z ). Note that Z h ( G ) = Z h (2) ( I ), and hence # CSP ( h (2) ) redu ces to Eval ( h ). Supp ose Eval ( h ) is not #P -hard. Then # CSP ( h (2) ) is not #P -h ard. By [4, Th m 1(1)], h (2) , view ed as a matrix, is a direct sum of rank-1 matrices; i.e., eac h h (2) ℓ has r an k 1. But eac h h (2) ℓ is the “Gram matrix” of h ℓ (the p r o duct of h ℓ , view ed as a matrix, and its transp ose), and it is a elemen tary fact that the r an k of a matrix and its corresp onding Gram matrix are equal [13]. T h us, for all ℓ , the restrictions h ℓ of h to D ℓ are rank 1. 5 F actoring Lemma 10. L et g : D r → Q ≥ 0 b e a symmetric function with arity r ≥ 3 . Either Eval ( f [2] ) is #P -har d (which implies that Eval ( g ) i s # P -har d) or g is 2 -factoring and 2 -e quational. Pr o of. First, n ote that R [2] has no bipartite comp onen ts: If ( z 1 , z 2 ) ∈ R [2] then there is a z 3 suc h that ( z 1 , z 2 , z 3 ) ∈ R [3] . By th e symmetry of f [3] , we fi nd that ( z 1 , z 3 ) and ( z 2 , z 3 ) are also in R [2] , so the comp onent con taining z 1 and z 2 is not bip artite. No w, by [4] (using Lemma 9), f [2] ℓ has rank 1. Thus, there are p ositiv e constan ts { µ z : z ∈ D } suc h that, for ev ery ℓ ∈ [ m ] and ev ery z 1 , z 2 in D ℓ , the follo wing holds. f [2] ℓ ( z 1 , z 2 ) = µ z 1 µ z 2 . (4) W e conclude that all elemen ts in D ℓ are related by ∼ 2 , so | A [2] ℓ | = 1. Thus, we can tak e s [2] ℓ = | D ℓ | and λ [2] ℓ,z = µ z and the trivial equation (since | A [2] ℓ | = 1). 10 The parenthetica l claim in the statemen t of this lemma and subsequent ones comes from L emma 6. Lemma 11. L e t g : D r → Q ≥ 0 b e a symmetric function with arity r ≥ 3 . L et k b e an inte ger in { 3 , . . . , r } . Supp ose that g is ( k − 1) -factor ing and ( k − 1) -e quational. Either Eval ( f [ k ] ) is #P -har d (which implies that Eval ( g ) is # P -har d), or al l the fol lowing hold: (i ) ther e ar e p ositive c onstants { λ [ k ] z : z ∈ D } such that f [ k ] ( z 1 , . . . , z k ) = λ [ k ] z 1 · · · λ [ k ] z k R [ k ] ( z 1 , . . . , z k ) , (ii) for every c onne cte d c omp onent ℓ ∈ [ m ] , the r elation S [ k ] ℓ is a L atin hyp er cub e, and (iii) f or every ℓ ∈ [ m ] , the sum P z ∈ [ α ] [ k ] λ [ k ] z is indep endent of α ∈ A [ k ] ℓ . Pr o of. Assume Eval ( f [ k ] ) is not #P -hard. Fix ℓ ∈ [ m ] and z 1 , z ′ 1 ∈ D ℓ . By th e Cauch y-Sc hw arz inequalit y ,  X z 2 ,...,z k ∈ D ℓ f [ k ] ℓ ( z 1 , z 2 , . . . , z k ) f [ k ] ℓ ( z ′ 1 , z 2 , . . . , z k )  2 ≤ X z 2 ,...,z k ∈ D ℓ f [ k ] ℓ ( z 1 , z 2 , . . . , z k ) 2 X z 2 ,...,z k ∈ D ℓ f [ k ] ℓ ( z ′ 1 , z 2 , . . . , z k ) 2 , i.e., ˜ f [ k ] ℓ ( z 1 , z ′ 1 ) 2 ≤ ˜ f [ k ] ℓ ( z 1 , z 1 ) ˜ f [ k ] ℓ ( z ′ 1 , z ′ 1 ) , (5) with equalit y pr ecisely when z 1 ∼ k z ′ 1 . Note that the difference b et ween the righ t-hand-side and the left-hand-side in Equation (5) can b e seen as a 2 by 2 d eterminan t. No w Eval ( ˜ f [ k ] ) ≤ Eval ( f [ k ] ) since ˜ f [ k ] ( u, v ) can b e simulated b y a pair of constrain ts f [ k ] ( u, w 2 , . . . , w k ) f [ k ] ( v , w 2 , . . . , w k ) using n ew v ariables w 2 , . . . , w k , so Eval ( ˜ f [ k ] ) is not #P -hard. e R [ k ] has no bipartite comp on ents since it is r eflexiv e, so by [4 ] and L emma 9, ˜ f [ k ] decomp oses int o a sum of rank-1 blo c ks. When z 1 6∼ k z ′ 1 w e hav e strict in equalit y in (5 ), which imp lies ˜ f [ k ] ℓ ( z 1 , z ′ 1 ) = X z 2 ,...,z k ∈ D f [ k ] ( z 1 , z 2 , . . . , z k ) f [ k ] ( z ′ 1 , z 2 , . . . , z k ) = 0 , (6) since otherwise ˜ f [ k ] w ould not d ecomp ose in to r ank 1 blo c ks. So for eac h c h oice of canonical represent ativ es α 2 , . . . , α k in A [ k ] ℓ there is at m ost one representati v e α 1 ∈ A [ k ] ℓ suc h th at f ℓ [ k ] ( α 1 , . . . , α k ) > 0. There is at least one such representa tiv e α 1 since, by Lemma 5, f [ k − 1] ℓ ( α 2 , . . . , α k ) = λ [ k − 1] ℓ,α 2 · · · λ [ k − 1] ℓ,α k , and the λ [ k − 1] ℓ,α j v alues are p ositiv e. Th is is part (ii) of the lemma. Recall th e definition of λ ′ [ k ] z from Equation (3). F or α ∈ A [ k ] ℓ , let ¯ λ α denote th e sum ¯ λ α = P z ∈ [ α ] [ k ] λ ′ [ k ] z . S imilarly , let ¯ µ α = P z ∈ [ α ] [ k ] λ ℓ,z [ k − 1] . Fix z 2 , . . . , z k ∈ D ℓ . By Lemma 5, λ [ k − 1] ℓ,z 2 · · · λ [ k − 1] ℓ,z k = f [ k − 1] ℓ ( z 2 , . . . , z k ) = X z 1 ∈ D ℓ f [ k ] ℓ ( z 1 , . . . , z k ) = X z 1 ∈ D ℓ λ ′ [ k ] z 1 · · · λ ′ [ k ] z k f [ k ] ℓ ( ¯ z [ k ] 1 , . . . , ¯ z [ k ] k ) = ¯ λ α 1 λ ′ [ k ] z 2 · · · λ ′ [ k ] z k f [ k ] ℓ ( α 1 , ¯ z [ k ] 2 , . . . , ¯ z [ k ] k ) , 11 where α 1 is the un ique represen tativ e in A [ k ] ℓ suc h th at f [ k ] ( α 1 , ¯ z [ k ] 2 , . . . , ¯ z [ k ] k ) > 0. S o for fix ed α 2 , . . . , α k ∈ A [ k ] ℓ , there is a represent ativ e α 1 ∈ A [ k ] ℓ suc h that ¯ µ α 2 · · · ¯ µ α k = X z 2 ∈ [ α 2 ] [ k ] · · · X z k ∈ [ α k ] [ k ] λ [ k − 1] ℓ,z 2 · · · λ [ k − 1] ℓ,z k = X z 2 ∈ [ α 2 ] [ k ] · · · X z k ∈ [ α k ] [ k ] ¯ λ α 1 λ ′ [ k ] z 2 · · · λ ′ [ k ] z k f [ k ] ℓ ( α 1 , . . . , α k ) = ¯ λ α 1 · · · ¯ λ α k f [ k ] ℓ ( α 1 , . . . , α k ) . Since we ha ve a Latin h yp ercub e (Part (ii) of the lemma), an y of α 1 , . . . , α k is determined by the other k − 1 of them. Th us, w e can deriv e a similar equalit y omitting any other ¯ µ α i on the left-hand-side. Now the right-hand-side of the ab o v e equalit y is symmetric in the α j ’s, and the left- hand-side has exactly one α j missing, so by symmetry we conclude ¯ µ α 1 = · · · = ¯ µ α k and, fu r ther, ¯ µ α j is constant for α j ∈ A [ k ] ℓ . Moreo ver, ¯ λ α 1 · · · ¯ λ α k f [ k ] ℓ ( α 1 , . . . , α k ) is constan t on representa tiv es α 1 , . . . , α k ∈ A [ k ] ℓ with f [ k ] ℓ ( α 1 , . . . , α k ) > 0. Th at is, for an y s et of k represent ativ es α ′ 1 , α ′ 2 , . . . , α ′ k ∈ A [ k ] ℓ with f [ k ] ℓ ( α ′ 1 , . . . , α ′ k ) > 0, the v alue of that expression ¯ λ α ′ 1 · · · ¯ λ α ′ k f [ k ] ℓ ( α ′ 1 , . . . , α ′ k ) is the same. No w d efine λ [ k ] x = c ℓ λ ′ [ k ] x / ¯ λ [ x ] [ k ] , w here c ℓ is a constant, dep ending only on ℓ , to b e determin ed b elo w. Then, wh enev er f [ k ] ℓ ( z 1 , . . . , z k ) > 0, f [ k ] ℓ ( z 1 , . . . , z k ) = λ ′ [ k ] z 1 · · · λ ′ [ k ] z k f [ k ] ℓ ( ¯ z [ k ] 1 , . . . , ¯ z [ k ] k ) = c − k ℓ λ [ k ] z 1 · · · λ [ k ] z k ¯ λ [ z 1 ] [ k ] · · · ¯ λ [ z k ] [ k ] f [ k ] ℓ ( ¯ z [ k ] 1 , . . . , ¯ z [ k ] k ) . But c − k ℓ ¯ λ [ z 1 ] [ k ] · · · ¯ λ [ z k ] [ k ] f [ k ] ℓ ( ¯ z [ k ] 1 , . . . , ¯ z [ k ] k ) is in dep end en t of z 1 , . . . , z k (assuming, as we are, that f [ k ] ℓ ( z 1 , . . . , z k ) > 0), so, b y appropriate c h oice of c ℓ , f [ k ] ℓ ( z 1 , . . . , z k ) = λ z 1 [ k ] · · · λ z k [ k ] R [ k ] ℓ ( z 1 , . . . , z k ) . The choic e of comp onent D ℓ w as arb itrary , so a similar statemen t holds for f [ k ] o ver its wh ole range, as r equired b y part (i) of the lemma. Finally , X z ∈ [ α ] [ k ] λ [ k ] z = c ℓ X z ∈ [ α ] [ k ] λ ′ [ k ] z / ¯ λ α = c ℓ , establishing part (iii). Lemma 12. L e t g : D r → Q ≥ 0 b e a symmetric function with arity r ≥ 3 . L et k b e an inte ger in { 3 , . . . , r } . Supp ose that g is ( k − 1) -factoring and ( k − 1) -e quational. Su pp ose ther e ar e p ositive c onstants { λ [ k ] z : z ∈ D } such that f [ k ] ( z 1 , . . . , z k ) = λ [ k ] z 1 · · · λ [ k ] z k R [ k ] ( z 1 , . . . , z k ) . Either Eva l ( f [ k ] ) is #P -har d (which implies that Eval ( g ) is #P -har d), or, for every ℓ ∈ [ m ] , the multiset { λ [ k ] z : z ∈ [ α ] [ k ] } is indep endent of the choic e of α ∈ A [ k ] ℓ . Pr o of. In p reparation for the pro of, consider th e u nary constraint U ( x ) applied to a v ariable x and defined as follo ws: T ak e k − 1 new v ariables x 2 , . . . , x k then add the constr aint f [ k ] ( x, x 2 , . . . , x k ). 12 The r esulting unary relation U ( x ) will b e us ed in the reduction that follo ws. F or any ℓ ∈ [ m ] and α ∈ A [ k ] ℓ , let n ℓ = | A [ k ] ℓ | an d c ℓ = P z ∈ [ α ] [ k ] λ [ k ] z (whic h, by Lemma 11, is indep enden t of the c hoice of α ∈ A [ k ] ℓ ). F or an y z 1 ∈ D ℓ , U ( z 1 ) = X z 2 ,...,z k ∈ D ℓ f [ k ] ℓ ( z 1 , . . . , z k ) = X z 2 ,...,z k ∈ D ℓ λ [ k ] z 1 · · · λ [ k ] z k R [ k ] ℓ ( z 1 , . . . , z k ) = X α 2 ,...,α k ∈ A [ k ] ℓ :( ¯ z [ k ] 1 ,α 2 ,...,α k ) ∈ R [ k ] ℓ X z 2 ∈ [ α 2 ] [ k ] ,...,z k ∈ [ α k ] [ k ] λ [ k ] z 1 · · · λ [ k ] z k = λ [ k ] z 1 X α 2 ,...,α k ∈ A [ k ] ℓ :( ¯ z [ k ] 1 ,α 2 ,...,α k ) ∈ R [ k ] ℓ  X z 2 ∈ [ α 2 ] [ k ] λ [ k ] z 2  · · ·  X z k ∈ [ α k ] [ k ] λ [ k ] z k  = λ [ k ] z 1 n k − 2 ℓ c k − 1 ℓ , where the fin al equalit y uses part (ii) of Lemm a 11. The idea of the pro of is to u s e U to “p o we r u p” vertex w eigh ts λ [ k ] z . In this w a y w e disco v er that not only is P z ∈ [ α ] [ k ] λ [ k ] z indep en d en t of α ∈ A [ k ] ℓ , but so also is P z ∈ [ α ] [ k ] ( λ [ k ] z ) j for any p ositiv e in teger j . This implies that the m ultiset of weigh ts on an equiv alence class [ α ] [ k ] is indep enden t of α ∈ A [ k ] ℓ . F or z 1 , . . . , z k ∈ D ℓ and j ≥ 1, define ψ z 1 = ( λ [ k ] z 1 n k − 2 ℓ c k − 1 ℓ ) j − 1 λ [ k ] z 1 and h [ j ] ℓ ( z 1 , . . . , z k ) = ψ z 1 · · · ψ z k R [ k ] ℓ ( z 1 , . . . , z k ) . Let h [ j ] = h [ j ] 1 ⊕ · · · ⊕ h [ j ] m . W e will giv e a redu ction f rom Eval ( h [ j ] ) to Eval ( f [ k ] ). Su pp ose G = ( V , E ) is a k -uniform hyp ergraph (an inp ut to Eval ( h [ j ] )). F or j ≥ 1, the hyp ergraph G [ j ] is obtained from G as follo ws: for eac h vertex v in G of degree d v , ad d ( k − 1) ( j − 1) d v new vertice s and ( j − 1) d v new edges, eac h one inciden t at v and at k − 1 of th e new vertic es. Th en Z h [ j ] ℓ ( G ) = X σ : V → D ℓ Y ( u 1 ,...,u k ) ∈ E h [ j ] ℓ ( σ ( u 1 ) , . . . , σ ( u k )) = X σ : V → D ℓ Y ( u 1 ,...,u k ) ∈ E ψ σ ( u 1 ) · · · ψ σ ( u k ) R [ k ] ℓ ( σ ( u 1 ) , . . . , σ ( u k )) = X σ : V → D ℓ Y v ∈ V ( λ [ k ] σ ( v ) n k − 2 ℓ c k − 1 ℓ ) ( j − 1) d v Y ( u 1 ,...,u k ) ∈ E λ [ k ] σ ( u 1 ) · · · λ [ k ] σ ( u k ) R [ k ] ℓ ( σ ( u 1 ) , . . . , σ ( u k )) = X σ : V → D ℓ Y v ∈ V ( λ [ k ] σ ( v ) n k − 2 ℓ c k − 1 ℓ ) ( j − 1) d v Y ( u 1 ,...,u k ) ∈ E f [ k ] ℓ ( σ ( u 1 ) , . . . , σ ( u k )) = Z f [ k ] ℓ ( G [ j ] ) . Th us (for conn ected G ) Z h [ j ] ( G ) = X ℓ ∈ [ m ] Z h [ j ] ℓ ( G ) = X ℓ ∈ [ m ] Z f [ k ] ℓ ( G [ j ] ) = Z f [ k ] ( G [ j ] ) , 13 so Eval ( h [ j ] ) ≤ Eval ( f [ k ] ). Assume Eval ( f [ k ] ) is not #P -hard. Then Eval ( h [ j ] ) is n ot #P -hard for an y j ≥ 1. Recall from the statemen t of the lemma that g is ( k − 1)-factoring and ( k − 1)- equational. Then from Lemma 11 part (iii), X z ∈ [ α ] [ k ] ψ z = ( n k − 2 ℓ c k − 1 ℓ ) j − 1 X z ∈ [ α ] [ k ] ( λ [ k ] z ) j is indep enden t of α ∈ A [ k ] ℓ for all j ≥ 1. Th is can only o ccur if the multiset { λ [ k ] z : z ∈ [ α ] [ k ] } is indep en d en t of α ∈ A [ k ] ℓ . W e will u se the follo wing corollary of Lemmas 10, 11 and 12. Corollary 13. L e t g : D r → Q ≥ 0 b e a symmetric fu nction with arity r ≥ 3 . L et k b e an inte ger i n { 3 , . . . , r } . Supp ose that g is ( k − 1) -factor ing and ( k − 1) -e quational. Either Eval ( f [ k ] ) is # P -har d (which implies that Eva l ( g ) is #P -har d), or g is k - factoring. Pr o of. By Lemma 11 p art (i) there are p ositiv e constant s { λ [ k ] z : z ∈ D } suc h that f [ k ] ( z 1 , . . . , z k ) = λ [ k ] z 1 · · · λ [ k ] z k R [ k ] ( z 1 , . . . , z k ) . Fix an y ℓ ∈ [ m ]. By Lemma 12, th e multi set { λ [ k ] z : z ∈ [ α ] [ k ] } is ind ep endent of the choice of α ∈ A [ k ] ℓ Let s [ k ] ℓ b e the size of this multiset. Th en D ℓ ∼ = A [ k ] ℓ × [ s [ k ] ℓ ] giving condition (1) in the definition of k -factoring. Also, if the elemen t z ∈ D ℓ corresp onds to the i ’th elemen t of the ∼ k class [ z ] [ k ] then the v alue λ [ k ] z just d ep ends up on i (and on ℓ ) — it is in dep end en t of the equiv alence class [ z ] [ k ] . W e denote th is v alue as λ [ k ] ℓ,i . T hus, for α 1 , . . . , α k ∈ A [ k ] ℓ and i 1 , . . . , i k ∈ [ s [ k ] ℓ ], f [ k ] ℓ (( α 1 , i 1 ) , . . . , ( α k , i k )) = λ [ k ] ℓ,i 1 · · · λ [ k ] ℓ,i k R [ k ] ℓ ( α 1 , . . . , α k ) , giving condition (2) in the defin ition of k -factoring. Lemma 14. L e t g : D r → Q ≥ 0 b e a symmetric function with arity r ≥ 3 . L et k b e an inte ger in { 3 , . . . , r } . Supp ose that g is k -factoring. Then, for every ℓ ∈ [ m ] , Z f [ k ] ℓ ( G ) = Λ [ k ] ℓ ( G ) Z S [ k ] ℓ ( G ) , wher e Λ [ k ] ℓ ( G ) = Y v ∈ V ( G ) X i ∈ [ s [ k ] ℓ ] ( λ [ k ] ℓ,i ) d v . (7) Pr o of. F or G = ( V , E ), Z f [ k ] ℓ ( G ) = X σ : V → A [ k ] ℓ ,τ : V → [ s [ k ] ℓ ] Y ( u 1 ,...,u k ) ∈ E f [ k ] ℓ (( σ ( u 1 ) , τ ( u 1 )) , . . . , ( σ ( u k ) , τ ( u k ))) = X σ : V → A [ k ] ℓ ,τ : V → [ s [ k ] ℓ ] Y ( u 1 ,...,u k ) ∈ E λ [ k ] ℓ,τ ( u 1 ) · · · λ [ k ] ℓ,τ ( u k ) S [ k ] ℓ ( σ ( u 1 ) , . . . , σ ( u k )) = X σ : V → A [ k ] ℓ  Y ( u 1 ,...,u k ) ∈ E S [ k ] ℓ ( σ ( u 1 ) , . . . , σ ( u k ))  X τ : V → [ s [ k ] ℓ ] Y v ∈ V  λ [ k ] ℓ,τ ( v )  d v  = Z S [ k ] ℓ ( G ) Λ [ k ] ℓ ( G ) . 14 Lemma 15. L e t g : D r → Q ≥ 0 b e a symmetric function with arity r ≥ 3 . L et k b e an inte ger in { 3 , . . . , r } . Supp ose that g is ( k − 1) -factor ing and ( k − 1) -e quational. Either Eval ( f [ k ] ) is # P -har d (which implies that Eva l ( g ) is #P -har d), or Eval ( S [ k ] ) ≤ Eval ( f [ k ] ) . Pr o of. Supp ose th at G is a connected k -uniform h yp ergraph. F or any p ositiv e in teger, p , let G 1 , . . . , G p b e copies of G . Let { v j 1 , . . . , v j n } b e the vertices of G j . Construct G [ p ] b y taking the union of G 1 , . . . , G p along with n ( k − 1) p new vertice s and 2 np new edges: F or eac h i ∈ [ n ], t ∈ [ k − 1] and j ∈ [ p ] we add a vertex u j i,t . Th en we add edges ( u j i, 1 , . . . , u j i,k − 1 , v j i ) and ( u j i, 1 , . . . , u j i,k − 1 , v ( j mo d n )+1 i ). No w by Corollary 13 , g is k -factoring, so D ℓ ∼ = A [ k ] ℓ × [ s [ k ] ℓ ]. By Lemma 14, Z f [ k ] ( G [ p ] ) = X ℓ ∈ [ m ] Λ [ k ] ℓ ( G [ p ] ) Z S [ k ] ℓ ( G [ p ] ) . (8) W e n o w lo ok at the constituen t parts of the right-hand-side of Equation (8). First, Z S [ k ] ℓ ( G [ p ] ) = X σ : V ( G [ p ] ) → A [ k ] ℓ Y ( w 1 ,...,w k ) ∈ E ( G [ p ] ) S [ k ] ℓ ( σ ( w 1 ) , . . . , σ ( w k )) . By P art (ii) of Lemma 11, S [ k ] ℓ is a Latin h y p ercub e. So, giv en the v alues σ ( v j 1 ) , . . . , σ ( v j n ), the v alues σ ( u j i, 1 ) , . . . , σ ( u j i,k − 2 ) (for i ∈ [ n ]) can b e chosen arbitrarily from A [ k ] ℓ . Then there is exactly one c hoice for eac h σ ( u j i,k − 1 ) so that ( σ ( u j i, 1 ) , . . . , σ ( u j i,k − 1 ) , σ ( v j i )) ∈ S [ k ] ℓ . Then for j < n to hav e ( σ ( u j i, 1 ) , . . . , σ ( u j i,k − 1 ) , σ ( v ( j mod n )+1 i )) ∈ S [ k ] ℓ w e must hav e σ ( v j +1 i ) = σ ( v j i ). (If j = n th en ( σ ( u j i, 1 ) , . . . , σ ( u j i,k − 1 ) , σ ( v ( j mod n )+1 i )) ∈ S [ k ] ℓ just ensur es v 1 i = v n i so it adds n o new constrain t.) Thus, Z S [ k ] ℓ ( G [ p ] ) = X σ : V ( G 1 ) → A [ k ] ℓ Y ( w 1 ,...,w k ) ∈ E ( G 1 ) S [ k ] ℓ ( σ ( w 1 ) , . . . , σ ( w k ))   A [ k ] ℓ   n ( k − 2) p =   A [ k ] ℓ   n ( k − 2) p Z S [ k ] ℓ ( G ) . Also, using d Γ ( w ) to denote the degree of verte x w in hyp ergraph Γ, Λ [ k ] ℓ ( G [ p ] ) = Y w ∈ V ( G [ p ] ) X h ∈ [ s [ k ] ℓ ]  λ [ k ] ℓ,h  d G [ p ] ( w ) =    Y i ∈ [ n ] X h ∈ [ s [ k ] ℓ ]  λ [ k ] ℓ,h  d G ( v i )+2    p    Y i ∈ [ n ] Y t ∈ [ k − 1] X h ∈ [ s [ k ] ℓ ]  λ [ k ] ℓ,h  2    p , 15 where the fir st factor on the r igh t-hand-side is the p ro du ct ov er v er tices v j i and the second factor is the pr o duct o ver vertic es u j i,t . So Z f [ k ] ( G [ p ] ) is equal to X ℓ ∈ [ m ]  Y i ∈ [ n ] X h ∈ [ s [ k ] ℓ ]  λ [ k ] ℓ,h  d G ( v i )+2  p  Y i ∈ [ n ] Y t ∈ [ k − 1] X h ∈ [ s [ k ] ℓ ]  λ [ k ] ℓ,h  2  p   A [ k ] ℓ   n ( k − 2) p Z S [ k ] ℓ ( G ) . W e can n ow use Corollary 8 with Z p = Z f [ k ] ( G [ p ] ), γ ℓ = Z S [ k ] ℓ ( G ) and η ℓ =  Y i ∈ [ n ] X h ∈ [ s [ k ] ℓ ]  λ [ k ] ℓ,h  d G ( v i )+2  Y i ∈ [ n ] Y t ∈ [ k − 1] X h ∈ [ s [ k ] ℓ ]  λ [ k ] ℓ,h  2    A [ k ] ℓ   n ( k − 2) . Let us tak e sto ck. Su p p ose g is not #P -hard and that g is ( k − 1)-factoring and ( k − 1)-equational. W e know b y Corollary 13 that g is k -factoring, and by P art (ii) of L emma 11 that the v arious relations S [ k ] ℓ are Latin hyp er cu b es. The final step, the sub j ect of the follo wing section, is to sho w that the latter hav e additional structur e, namely that they are defin ed by equatio ns o ver an Ab elian groups. It will follo w that g is k -equational. 6 Constrain t satisfaction and Ab elian group equations Let S b e an arit y- k relation on a ground s et A . Recall our earlier discussion, in S ection 1, on the relation b et ween Eva l ( S ) and # CS P ( S ). E very instance G of Eval ( S ) can b e v iewed as an instance of # CSP ( S ) by taking the v ertices as v ariables and the ed ges as constrain t scop es. Ho w ev er, we noted that the con v erse is n ot true, since an instance I of # CSP ( S ) migh t not b e a pr op erly-formed instance of Eval ( S ). Nev ertheless, by cop yin g v ariables, w e can view an in s tance I of # CSP ( S ) as b eing a k -uniform h yp ergraph G , together with some binary equalit y constrain ts on v ariables. F or v ariables U and W , the constraint = ( U, W ) is satisfied if and only if σ ( U ) = σ ( W ) . The follo w ing lemma shows that, in our setting, these equalit y constraints do n ot add an y real p o w er - they can b e implemented b y in terp olation. Lemma 16. L et S = S 1 ⊕ · · · ⊕ S m b e a symmetric k -ary r elation on a g r ound set A , such that e ach S ℓ is a L atin hyp er cub e . Then # CSP ( S ) ≤ Eval ( S ) . Pr o of. F or ℓ ∈ [ m ], let A ℓ b e the ground set of S ℓ . Let I b e an instance of # CSP ( S ) compr ising a connected hyp ergraph G with vertices { v 1 , . . . , v n } and ν equalit y constrain ts. Note that this is without loss of generalit y – an instance I ma y b e represent ed as a h yp er grap h G together with equalit y constrain ts in which equalit y is only applied to v ariables in the same connected comp onent of G . F or a p ositiv e integ er p , construct a hyp ergraph G [ p ] b y com bining G with ν p ( k − 1) new v ertices and 2 ν p new edges: F or j ∈ [ p ] and i ∈ [ ν ] add vertic es u j i, 1 , . . . , u j i,k − 1 . If the i ’th equalit y constrain t is = ( v s , v t ) then add the 2 p edges ( v s , u j i, 1 , . . . , u j i,k − 1 ) and ( v t , u j i, 1 , . . . , u j i,k − 1 ) for j ∈ [ p ]. No w, s u pp ose w e are give n the v alues σ ( v 1 ) , . . . , σ ( v n ) in A ℓ . By the Latin hypercub e pr op ert y , we can h a v e ( σ ( v s ) , σ ( u j i, 1 ) , . . . , σ ( u j i,k − 1 )) ∈ S and ( σ ( v t ) , σ ( u j i, 1 ) , . . . , σ ( u j i,k − 1 )) ∈ S only if σ ( v s ) = 16 σ ( v t ). In that case, there are | A ℓ | k − 2 c h oices for σ ( u j i, 1 ) , . . . , σ ( u j i,k − 1 ). So Z S ( G [ p ] ) = X ℓ ∈ [ m ] Z S ℓ ( I ) | A ℓ | ( k − 2) p . W e can n ow use Corollary 8. The f ollo wing lemma establishes the alge braic structure of the S ℓ , using a result of Bulato v and Dalmau [3]. The pr o of itself has sim ilarities to that of P´ alfy’s theorem [14] (see, for example, [7 ]). Lemma 17. Supp ose k ≥ 3 . L et S = S 1 ⊕ · · · ⊕ S m b e a symmetric k -ary r elation on a gr ound set A such that, for e ach ℓ ∈ [ m ] , S ℓ is a L atin hyp er cub e. Supp ose Eval ( S ) is not #P - har d. Then for e ach ℓ ∈ [ m ] , the r elation S ℓ is define d by an e quation over an Ab elian gr oup G ℓ = h A ℓ , + i as fol lows: for some element a ∈ A ℓ , ( α 1 , . . . , α k ) ∈ S ℓ if and only if α 1 + · · · + α k = a . Pr o of. Supp ose Eval ( S ) is not #P -hard. Fix ℓ ∈ [ m ], and fix an y element a ℓ ∈ A ℓ and den ote it b y 0. If ( α, β , γ , 0 , . . . , 0) ∈ S ℓ w e will write γ = α · β . Then we w ill call ( α, β , γ ) a triple and denote the set of triples b y T ℓ . W e will call ( α, β , γ , 0 , . . . , 0) ∈ S ℓ the corresp onding p adde d triple . F or giv en α and β , the existence and uniqueness of γ in a padd ed trip le follo ws d ir ectly from the fact that S ℓ is a Latin hyper cu b e. Thus we ma y regard α · β as a binary op eration on A ℓ , and hence A ℓ = h A ℓ , ·i is an algebra. By symm etry , the binary op eration of A ℓ is commuta tiv e, and satisfies the identit y α · ( α · β ) = β for all α, β ∈ A ℓ . Ho wev er, the op eration is not n ecessarily asso ciativ e. By Lemma 16, # CS P ( S ) ≤ Eval ( S ), so # CS P ( S ) is not #P -hard. Thus, by [3], there is a Mal’tsev p olymorph ism ϕ ( α, β , γ ) on A whic h preserves S . Recall that a Mal’tsev op eration ϕ : A 3 → A is an y function whic h satisfies the identities ϕ ( α, β , β ) = ϕ ( β , β , α ) = α for all α, β ∈ A . W e ma y use ϕ to calc ulate, as follo w s. Eac h line of a table is a triple in T ℓ , and the Mal’tsev p olymorphism implies that the b ottom line is also a tr iple in T ℓ , using the fact that ϕ (0 , 0 , 0) = 0 in the padded triples (which follo ws from the Mal’tsev pr op ert y). Thus α γ α · γ β γ β · γ γ β β · γ ϕ ( α, β , γ ) β α · γ and hence ϕ ( α, β , γ ) = β · ( α · γ ) is a term of the algebra A ℓ . W e ha v e ϕ ( α, β , γ ) = β · ( α · γ ) = β · ( γ · α ) = ϕ ( γ , β , α ) , so ϕ is a s ymmetric Mal’tsev op eration (in the sense that it is symmetric in th e fi rst and third argumen ts). Define a new binary op eration + on A ℓ b y α + β = ϕ ( α, 0 , β ) = 0 · ( α · β ). It follo ws imm ed iately that + is commutat iv e. Hence 0 + α = α + 0 = 0 · ( α · 0) = ϕ ( α, 0 , 0) = α, so 0 is an iden tit y for +. Denote 0 · 0 b y 0 2 , and d efine − α by α · 0 2 . Then ( − α ) + α = α + ( − α ) = 0 · ( α · ( α · 0 2 )) = 0 · (0 2 ) = 0 · (0 · 0) = 0 , so − α is an inv erse for α . As usual, we w rite α − β for α + ( − β ). 17 W e h a ve α 0 2 α · 0 2 0 0 2 0 β β · 0 0 α + β β · 0 α · 0 2 so α + β = ( β · 0) · ( α · 0 2 ) and since + is comm utativ e, α + β = β + α = ( α · 0) · ( β · 0 2 ). Then α · 0 β · 0 2 α + β 0 2 0 0 γ · 0 0 γ ϕ ( α · 0 , 0 2 , γ · 0) β · 0 2 ( α + β ) + γ Therefore, since ϕ is symmetric in its first and th ir d arguments, ( α + β ) + γ = ϕ ( α · 0 , 0 2 , γ · 0) · ( β · 0 2 ) = ϕ ( γ · 0 , 0 2 , α · 0) · ( β · 0 2 ) = ( γ + β ) + α = α + ( γ + β ) = α + ( β + γ ) . The op eration + is therefore associativ e, and hence the alge bra G ℓ = h A ℓ , + , − , 0 i is an Ab elian group. Hence, since − X is defin ed to b e X · 0 2 and α − 0 2 = − ( − α + 0 2 ), w e ha v e, for any α, β ∈ A ℓ , α − 0 2 0 2 − α + 0 2 0 0 2 0 0 2 β − β α β − α − β + 0 2 where we used the fact that, b y d efinition, ϕ ( x, 0 , y ) = x + y . Thus α · β = − α − β + 0 2 . , and it follo ws that T ℓ =  ( α, β , − α − β + 0 2 ) ∈ A 3 ℓ : α, β ∈ A ℓ  =  ( α, β , γ ) ∈ A 3 ℓ : α + β + γ = 0 2 in G ℓ  . (9) In particular, ( α, − α, 0 2 ) ∈ T ℓ for all α ∈ A ℓ , and h ence (0 , 0 , 0 2 ) ∈ T ℓ . It follo w s fur ther that ϕ ( α, β , γ ) = β · ( α · γ ) = − β − ( α · γ ) + 0 2 = − β − ( − α − γ + 0 2 ) + 0 2 = α − β + γ , so the Mal’tsev op eration is the term α − β + γ in the Ab elian group G ℓ . No w assume b y induction that the conclusion of the lemma is true for an y S of arit y less than k . It is true for arit y 3 by (9), since then, for an y ℓ ∈ [ m ], S ℓ = T ℓ . F or larger k , supp ose ( α 1 , α 2 , . . . , α k ) ∈ S ℓ is arbitrary . Then, u sing the Mal’tsev op eration and padding the trip les ( α 1 , − α 1 , 0 2 ), (0 , 0 , 0 2 ), w e hav e α 1 α 2 α 3 α 4 · · · α k α 1 − α 1 0 2 0 · · · 0 0 0 0 2 0 · · · 0 0 α 1 + α 2 α 3 α 4 · · · α k No w the ( k − 1)-ary relation S ′ ℓ = { ( α ′ 2 , α ′ 3 , . . . , α ′ k ) ∈ A k − 1 ℓ : (0 , α ′ 2 , α ′ 3 , . . . , α ′ k ) ∈ S ℓ } is symmetric and has the same Mal’t sev op eration as S ℓ . Th us w e can define the same Ab elian group G ℓ , and by ind uction we will h a ve S ′ ℓ = { ( α ′ 2 , α ′ 3 , . . . , α ′ k ) ∈ A k − 1 ℓ : P k j =2 α ′ j = a ′ in G ℓ } , 18 for some a ′ ∈ A ℓ . But w e hav e sho w n that, for all ( α 1 , α 2 , α 3 , . . . , α k ) ∈ S ℓ , w e ha v e ( α 1 + α 2 , α 3 . . . , α k ) ∈ S ′ ℓ . Th us, since G ℓ is an Ab elian group, S ℓ = { ( α 1 , α 2 , α 3 , . . . , α k ) ∈ A k ℓ : P k j =1 α j = a in G ℓ } , where a = a ′ , completing the induction and th e pro of. 7 Pro of of Th eorem 4 Pr o of. Let g : D r → Q ≥ 0 b e a symmetric function with arit y r ≥ 3. First, su pp ose that g is r -factoring and r -equational. Then app lying Lemm a 14 with k = r , w e find that, for conn ected G , Z g ( G ) = X ℓ ∈ [ m ] Λ [ r ] ℓ ( G ) Z S [ r ] ℓ ( G ) . (10) No w since g is r -equational, S [ r ] ℓ is d efined by an equation ov er an Ab elian group ( A [ r ] ℓ , +). No w, b y [11, Lemm a 13], Eval ( S [ r ] ℓ ) is p olynomial time s olv able: T he Ab elian group is a d irect pr o duct of cyclic group s of prime p o w er. F or eac h of these cyclic groups, we ju st need to count the solutions to a system of linear equations o ver the field Z p and this can b e done in p olynomial time (see [11]). Th us, Eva l ( S [ r ] ℓ ) is in FP . T o sho w that Eval ( g ) is in FP , it remains to show that Λ [ r ] ℓ ( G ), as d efined in (7), can b e computed in FP . This is immediate o ver the num b er field Q ( θ , λ [ r ] ℓ, 1 , . . . , λ [ r ] ℓ,s ℓ ). In Section 8, we s ho w that it can ev en b e computed in FP ov er the num b er fi eld Q ( θ ). Supp ose n o w that Eval ( g ) is not #P -hard . Then by Lemma 10, g is b oth 2-facto ring and 2- equational. Next supp ose that, for some k ∈ { 3 , . . . , r } , g is ( k − 1)-factoring and ( k − 1)-equational. Since Eval ( g ) is not #P -hard, w e kno w that Eval ( f [ k ] ) is not #P -hard. By Corollary 13, g is k - factoring. Supp ose, for cont radiction, that g is not k -equational. By P art (ii) of Lemma 11, eac h S [ k ] ℓ is a Latin h yp ercub e, so by Lemm a 17, Eval ( S [ k ] ) is #P -h ard. By Lemma 15, Eval ( f [ k ] ) is #P -h ard, giving the contradict ion. S o g is k -equational. By indu ction, g is r -factoring and r -equational. It remains to consider th e effectiv eness of the dic hotom y . F or this, w e must show that there is an algorithm that determines whether g is r -factoring and r -equational. This is nearly identica l to a pro of that the d ichoto m y in Theorem 2 is effectiv e, how ev er th e notation is simpler in the latte r con text, so we pro vide this pro of next. Lemma 18. The dichotomy in The or em 2 is effe ctive. Pr o of. W e m ust show that there is an algorithm that determin es whether the conditions in The- orem 2 are satisfied. The connected comp onents D 1 , . . . , D m can easily b e determin ed . Then, for eac h ℓ ∈ [ m ], there are a constan t num b er of p ossibilities for the decomp ositions D ℓ ∼ = A ℓ × [ s ℓ ] ( ℓ ∈ [ m ]) whic h can all b e c hec ked, if necessary . Th en , for the third condition, there are only a finite n u m b er of p ossibilities for the group structur e, corresp onding to the factorisatio ns of | A ℓ | . Again, these can all b e chec k ed to see if an y defines S ℓ , for eac h ℓ ∈ [ m ]. F or the s econd condition, for eac h ℓ ∈ [ m ], w e n eed to decide the satisfiabilit y of a sys tem of the form g (( α 1 , i 1 ) , . . . , ( α r , i r )) = λ ℓ,i 1 · · · λ ℓ,i r for all ( α 1 , . . . , α r ) ∈ S ℓ and i 1 , . . . , i r ∈ [ s ℓ ] . (11) 19 Th us we hav e λ ℓ,i = g (( α 1 , i ) , . . . , ( α r , i )) 1 /r for all ( α 1 , . . . , α r ) ∈ S ℓ and i ∈ [ s ℓ ] , (12) and hence (11) is equiv alen t to the system g (( α 1 , i 1 ) , . . . , ( α r , i r )) r = r Y j =1 g (( α 1 , i j ) , . . . , ( α r , i j )) for all ( α 1 , . . . , α r ) ∈ S ℓ and i 1 , . . . , i r ∈ [ s ℓ ], whic h can b e decided in constan t time by computation in the num b er field Q ( θ ). 8 Computation of Z g ( G ) in Q ( θ ) Observe that (7), (10) and (12 ) s eem together to imply that, in the p olynomial time computable cases, we must compute Z g ( G ) in th e num b er field Q ( θ , λ 1 , 1 , . . . , λ 1 ,s 1 , . . . , λ m, 1 , . . . , λ m,s m ), where, for ℓ ∈ [ m ] and i ∈ [ s ℓ ], λ ℓ,i = λ [ r ] ℓ,i is an r th ro ot of one of the original w eigh ts. This seems anomalous, since Z g ( G ) is actually an elemen t of Q ( θ ). W e conclude b y sh o w in g that th e computation of Z g ( G ) can b e done en tirely within Q ( θ ), as might b e hop ed. T o do this, we m ust exp and the expressions Λ [ r ] ℓ ( G ) = Y v ∈ V ( G ) s ℓ X i =1 ( λ ℓ,i ) d v . T o simp lify the text, we drop the subscrip t ℓ in the rest of this section, writing s f or s ℓ and λ i for λ ℓ,i and Λ [ r ] for Λ [ r ] ℓ . T hus, w e wish to exp and Λ [ r ] ( G ) = Y v ∈ V ( G )  s X i =1 λ d v i  . The exp onents of λ i ( i ∈ [ s ]) in the monomials of the expansion of Λ [ r ] ( G ) are giv en by X v ∈ V ( G ) δ v,i d v , where s X i =1 δ v,i = 1 and δ v,i ∈ { 0 , 1 } ( i ∈ [ s ] , v ∈ V ( G )) . (13) Recall that M denotes the num b er of edges of G . Thus there are O ( M s ) p ossib le monomials in the λ i , and the inte ger co efficien t of eac h monomial Q s i =1 λ M i i are give n by computing th e num b er of solutions to sys tems of equations of the form X v ∈ V ( G ) δ v,i d v = M i , where s X i =1 δ v,i = 1 and δ v,i ∈ { 0 , 1 } ( i ∈ [ s ] , v ∈ V ( G )) . (14) This can b e don e f or all 0 ≤ M i ≤ r M ( i ∈ [ s ]) in O ( nM s ) time by dynamic programming. An easy coun ting argumen t sh ows that P v ∈ V ( G ) d v = r M , so this returns a nonzero co efficien t for the monomial Q s i =1 λ M i i only if P s i =1 M i = r M . Thus, in fact, there are at most  r M + s − 1 s − 1  = O ( M s − 1 ) 20 suc h monomials, wh ic h is clearly p olynomial in the input size. Th us w e can compu te in FP a represen tation of Λ [ r ] ( G ) as a m ultiv ariate p olynomial with monomials Q s i =1 λ M i i suc h th at P s i =1 M i = r M an d M i ≥ 0 ( i ∈ [ s ]). W e can express eac h su c h monomial in terms of the original wei gh ts, as follo ws. Let r ij ( i ∈ [ s ] , j ∈ [ M ]) b e nonnegativ e int egers such that P s i =1 r ij = r ( j ∈ [ M ]) and P M j =1 r ij = M i ( i ∈ [ s ]). Suc h num b ers alw a ys exist, though they will usually b e far from unique, and can b e computed in O ( M ) time. Th ey are the en tries of a c ontingency table with r o w totals M i ( i ∈ [ s ]) and column totals r ( j ∈ [ M ]). See, for example, [8]. No w eac h column r ij ( j ∈ [ M ]) can b e interpreted as an r -multiset { i 1 j , . . . , i r j } ⊆ [ s ], where i ∈ [ s ] app ears with m ultiplicit y r ij . T hus, c ho osing any ( α 1 , . . . , α r ) ∈ S , we ha ve s Y i =1 λ M i i = M Y j =1 s Y i =1 λ r ij i = M Y j =1  λ i 1 j · · · λ i r j  = M Y j =1 g (( α 1 , i 1 j ) , . . . , ( α r , i r j )) , using (11) . This can b e computed in O ( M ) time in Q ( θ ), s o Z g ( G ) can b e ev aluated in O ( M s ) time. The most demanding p art of the compu tation seems to b e the O ( nM s ) time needed to determine the relev an t monomials b y d y n amic programming. Bu t clearly all computations can b e done in FP , and by working en tirely within Q ( θ ). References [1] C. Berge, Gr aphes et hyp er gr aphes , Duno d, P aris, 1970. [2] A. Bulato v, Th e complexit y of the coun ting constraint satisfaction problem, in Automa ta, L anguages and Pr o gr amming, 35th Internat ional Col lo quium (ICALP 2008) Part 1 , Lecture Notes in Computer S cience 5125 , Sp ringer, 2008, pp . 646–661. [3] A. Bulato v and V. Dalmau, T o w ards a d ichoto m y theorem for the counting constrain t satis- faction problem, Information and Computation 205 (2007), 651–678. [4] A. Bulat o v and M. Grohe, The co mplexit y of partition functions, The or etic al Computer Scienc e 348 (2005), 148–186 . [5] A. Bulato v, M. Dyer, L. Goldb er g and M. Jerru m, p ersonal comm unication. [6] H. Cohen, A c ourse in c omputatio nal algebr aic numb e r the ory , Graduate T exts in Mathematics 138 , Sprin ger V erlag, Berlin, 1993. [7] K. Deneck e and S. Wismath, U niversal algebr a and applic ations in the or etic al c omputer scienc e , Chapman and Hall/CR C, London, 2002. [8] P . Diaconis and A. Gangolli, Rectangular arrays with fi xed margins, in Discr ete pr ob ability and algorithms (D. Aldous, P . V araiya, J. Sp encer and J. S teele, eds.), IMA V olumes on Mathematics and its Applications 72 , Sp ringer V erlag, New Y ork, 1995, p p. 15–41 . [9] M. Dy er, L. Goldb erg and M. Jerrum, The complexit y of weig h ted Bo olean # CSP , SIAM Journal on Computing , to ap p ear. [10] M. Dyer and C. Greenhill, The complexit y of counting graph homomorph isms, R andom Struc- tur es and Algorithms 17 (2000), 260–28 9. 21 [11] O. Kl ´ ıma, B. L arose and P . T esson, Systems of equations o v er finite semigroups and the #CSP dic hotom y conjecture, in M athematic al F oundations of Computer Scienc e, 31st Internat ional Symp osium (MFCS 2006) , Lecture Notes in Compu ter Science 4162 , Sp ringer, 2006, p p. 584– 595. [12] C. Lange and G. Ziegler, On generalized Kn eser hypergrap h colorings, Journal of Combinato- rial The ory A 114 (2007 ), 159–166. [13] L. Mirsk y , An intr o duction to line ar algebr a , Do v er , New Y ork, 1990. [14] P . P´ alfy , Unary p olynomials in algebras I, Algebr a Universalis 18 (1984), 262–273. 22

Original Paper

Loading high-quality paper...

Comments & Academic Discussion

Loading comments...

Leave a Comment