Abstract 1 Introduction 2 Preliminaries 3 Structural Properties for Counting 4 Rigitity and Multi-sorted Structures 5 An Algorithm for Parity 6 Hardness and Automorphisms of Direct Products of Structures 7 Binarization References

Modular Counting CSP: Reductions and Algorithms

Amirhossein Kazeminia Simon Fraser University, Burnaby, Canada Andrei A. Bulatov Simon Fraser University, Barnaby, Canada
Abstract

The Constraint Satisfaction Problem (CSP) is ubiquitous in various areas of mathematics and computer science. Many of its variations have been studied including the Counting CSP, where the goal is to find the number of solutions to a CSP instance. The complexity of finding the exact number of solutions of a CSP is well understood (Bulatov, 2013, and Dyer and Richerby, 2013) and the focus has shifted to other variations of the Counting CSP such as counting the number of solutions modulo an integer. This problem has attracted considerable attention recently. In the case of CSPs based on undirected graphs Bulatov and Kazeminia (STOC 2022) obtained a complexity classification for the problem of counting solutions modulo p for arbitrary prime p. In this paper we report on the progress made towards a similar classification for the general CSP, not necessarily based on graphs.

We identify several features that make the general case very different from the graph case such as a stronger form of rigidity and the structure of automorphisms of powers of relational structures. We provide a solution algorithm in the case p=2 that works under some additional conditions and prove the hardness of the problem under some assumptions about automorphisms of the powers of the relational structure. We also reduce the general CSP to the case that only uses binary relations satisfying strong additional conditions.

Keywords and phrases:
Constraint Satisfaction Problem, Modular Counting
Funding:
Andrei A. Bulatov: NSERC Discovery Grant.
Copyright and License:
[Uncaptioned image] © Amirhossein Kazeminia and Andrei A. Bulatov; licensed under Creative Commons License CC-BY 4.0
2012 ACM Subject Classification:
Theory of computation Problems, reductions and completeness
; Theory of computation Constraint and logic programming
Related Version:
Full Version: https://arxiv.org/abs/2501.04224 [29]
Editors:
Olaf Beyersdorff, Michał Pilipczuk, Elaine Pimentel, and Nguyễn Kim Thắng

1 Introduction

Counting problems in general have been intensively studied since the pioneering work by Valiant [34, 33]. One of the most interesting and well studied problems in this area is the Counting Constraint Satisfaction Problem (#𝖢𝖲𝖯), which provides a generic framework for a wide variety of counting combinatorial problems that arise frequently in multiple disciplines such as logic, graph theory, and artificial intelligence. The counting 𝖢𝖲𝖯 also allows for generalizations including weighted CSPs and partition functions [2, 7] that yield connections with areas such as statistical physics, see, e.g. [27, 32]. While the complexity of exact counting solutions of a 𝖢𝖲𝖯 is now well-understood [13, 3, 14, 12], modular counting such as finding the parity of the number of solutions remains widely open.

Homomorphisms and the Constraint Satisfaction Problem.

The most convenient way to introduce CSPs is through homomorphisms of relational structures. A relational signature σ is a collection of relational symbols each of which is assigned a positive integer, the arity of the symbol. A relational structure with signature σ is a set H and an interpretation of each σ, where is a relation or a predicate on H whose arity equals that of . The set H is said to be the base set or the universe of . We will use the same letter for the base set as for the structure, only in the regular font. A structure with signature σ is often called a σ-structure. Structures with the same signature are called similar.

Let 𝒢, be similar structures with signature σ. A homomorphism from 𝒢 to is a mapping φ:GH such that for any σ, say, of arity r, if 𝒢(a1,,ar) is true for a1,,arG, then (φ(a1),,φ(ar)) is also true. The set of all homomorphisms from 𝒢 to is denoted 𝖧𝗈𝗆(𝒢,). The cardinality of 𝖧𝗈𝗆(𝒢,) is denoted by 𝗁𝗈𝗆(𝒢,). A homomorphism φ is an isomorphism if it is bijective and the inverse mapping φ1 is a homomorphism from to 𝒢. A homomorphism of a structure to itself is called an endomorphism, and an isomorphism to itself is called an automorphism.

Following Feder and Vardi [17], in a 𝖢𝖲𝖯, the goal is, given similar relational structures 𝒢,, to decide whether there is a homomorphism from 𝒢 to . The restricted problem in which is fixed and only 𝒢 is given as an input is denoted by 𝖢𝖲𝖯(). The complexity of such problems is well understood [4, 35].

Counting CSP.

In the (exact) Counting 𝖢𝖲𝖯 the goal is to find the number 𝗁𝗈𝗆(𝒢,) of homomorphisms from a structure 𝒢 to a similar structure . Restricted versions of the Counting CSP can be introduced in the same way as for the decision one. In the counting version of 𝖢𝖲𝖯() denoted #𝖢𝖲𝖯() the goal is to find 𝗁𝗈𝗆(𝒢,) for a given structure 𝒢as an input.

The complexity class the Counting 𝖢𝖲𝖯 belongs to is #P, the class of problems of counting accepting paths of polynomial time nondeterministic Turing machines. There are several ways to define reductions between counting problems, but the most widely used ones are parsimonious reductions and Turing reductions. A parsimonious reduction from a counting problem #A to a counting problem #B is an algorithm that, given an instance I of #A produces (in polynomial time) an instance I of #B such that the answers to I and I are equal. A Turing reduction is a polynomial time algorithm that solves #A using #B as an oracle. Completeness in #P is then defined in the standard way. This paper and all the papers we cite predominantly use Turing reductions.

A complexity classification of counting 𝖢𝖲𝖯s of the form #𝖢𝖲𝖯() was obtained by Bulatov [3] and was further improved and simplified by Dyer and Richerby [14]. Bulatov’s proof makes heavy use of techniques of universal algebra. Dyer and Richerby’s proof, on the other hand, uses combinatorial and structural properties of relational structures. The more general version of the counting CSP, the weighted CSP, has also been thoroughly studied. Cai and Chen [10] obtained a complexity classification for weighted CSP, where each homomorphism has a complex weight. One of the main features of counting with complex weights is the phenomenon of cancellation, when complex weights of homomorphisms cancel each other rather than add up. This, of course, never happens in exact unweighted counting problems, but is frequently encountered in modular counting.

Modular Counting.

Another natural variation of counting problems is counting modulo some integer. In this paper we consider the problem of computing the number of solutions of a 𝖢𝖲𝖯 modulo a prime number p. If a relational structure is fixed, this problem is denoted #p𝖢𝖲𝖯(). More precisely, in #p𝖢𝖲𝖯() the objective is, given a relational structure 𝒢, to find the number of homomorphisms from 𝒢 to modulo p.

There are several complexity classes related to modular counting. The more established type of classes is 𝖬𝗈𝖽kP, the class of problems of deciding whether the number of accepting paths of a polynomial time nondeterministic Turing machine is not divisible by k, [11, 25]. In particular, if k=2 then 𝖬𝗈𝖽kP is the class P. However, problems of counting accepting paths naturally belong to classes of the form #kP, introduced by Faben in [15] that contain problems of counting accepting paths modulo k. The standard notion of reduction is again Turing reduction. Faben in [15] studied the basic properties of such classes, in particular, he identified several #kP-complete problems.

In the case of the 𝖢𝖲𝖯, the research has mostly been focused on graph homomorphisms. The only exceptions we are aware of are a result of Faben [15], who characterized the complexity of counting the solutions of a Generalized Satisfiability problem modulo an integer, and a generalization of [15] to problems with weights by Guo et al. [21]. The study of modular counting of graph homomorphisms has been much more vibrant.

Before discussing the existing results on modular counting and the results of this study, we need to mention some features of the automorphism group of a relational structure. The automorphisms of a relational structure form a group with respect to composition denoted 𝖠𝗎𝗍(). The order of an automorphism π𝖠𝗎𝗍() is the smallest number k such that πk is the identity permutation. An element aH is a fixed point of π𝖠𝗎𝗍() if π(a)=a. The set of all fixed points of π is denoted by 𝖥𝗂𝗑(π).

A systematic study of counting homomorphisms in graphs was initiated by Faben and Jerrum in [15]. They observed that the automorphism group 𝖠𝗎𝗍(), particularly the automorphisms of order p, plays a crucial role in the complexity of the problem #p𝖧𝗈𝗆(). This insight extends to relational structures, as discussed in [9]. Specifically, for a homomorphism φ from a relational structure 𝒢 to , composing φ with an automorphism from 𝖠𝗎𝗍() yields another homomorphism from 𝒢 to . Thus, any automorphism of acts on the set 𝖧𝗈𝗆(𝒢,) of all homomorphisms from 𝒢 to . If 𝖠𝗎𝗍() contains an automorphism π of order p, the size of the orbit of φ is divisible by p unless πφ=φ, making this orbit contribute 0 modulo p to the total homomorphism count from 𝒢 to . If πφ=φ, the range of φ lies within the set of fixed points 𝖥𝗂𝗑(π) of π. This observation motivates the following construction: let π denote the substructure of induced by 𝖥𝗂𝗑(π). We write p there exists π𝖠𝗎𝗍() such that is isomorphic to π. Furthermore, we write p if there exist structures 1,,k such that is isomorphic to 1, is isomorphic to k, and 1p2ppk.

Relational structures without order p automorphisms will be called p-rigid.

Lemma 1 ([9, 16]).

Let be a relational structure and p a prime. Then

  1. (a)

    Up to an isomorphism there exists a unique p-rigid structure p such that pp.

  2. (b)

    For any relational structure 𝒢 it holds that 𝗁𝗈𝗆(𝒢,)𝗁𝗈𝗆(𝒢,p)(modp).

By Lemma 1 it suffices to determine the complexity of #p𝖢𝖲𝖯() for p-rigid structures .

The existing results on modular counting.

As we mentioned before, the research in modular counting 𝖢𝖲𝖯s has mostly been aimed at counting graph homomorphisms. The complexity of the problem #p𝖧𝗈𝗆(H) of counting homomorphism to a fixed graph H modulo a prime number p has received significant attention in the last ten years. Faben and Jerrum in [16] posed a conjecture that up to order p automorphism reduction p the complexity of this problem is the same as that for exact counting. More precisely, they conjectured that #p𝖧𝗈𝗆(H) is solvable in polynomial time if and only if 𝖧𝗈𝗆(Hp) is. By the result of Dyer and Greenhill [13] #p𝖧𝗈𝗆(H) is solvable in polynomial time if and only if every connected component of Hp is a complete graph with all loops present or a complete bipartite graph. Therefore, proving that if a p-rigid H does not satisfy these conditions then #p𝖧𝗈𝗆(H) is #pP-hard suffices to confirm the conjecture of Faben and Jerrum. Over several years the hardness of #p𝖧𝗈𝗆(H) was established for various graph classes [16, 22, 19, 20, 28, 18, 31]. Finally, it was proved for arbitrary graphs in [9].

Theorem 2 ([9]).

For any prime p and any graph H the problem #p𝖧𝗈𝗆(H) is solvable in polynomial time if and only if 𝖧𝗈𝗆(Hp) is solvable in polynomial time. Otherwise it is #pP-complete.

Our Results.

In this paper we begin a systematic study of the problem #p𝖢𝖲𝖯() for general relational structures . Note that to the best of our knowledge, it is the first paper attempting at such a general modular counting problem. The ultimate goal is to obtain a complexity classification similar to Theorem 2 for arbitrary relational structures. The full version of the paper can be found in [29].

The contribution of the paper is twofold. First, we analyse the existing techniques such as those from [9], and the methods used in exact counting [3, 14, 10], and their applicability to the general case. We conclude that few of them work. More specifically, Theorem 2 asserts that the complexity of modular counting for p-rigid graphs is the same as of exact counting. We, however, suggest a relational structure, a digraph 𝒯p, that is p-rigid, its exact counting problem is hard, but modular counting is easy, see Example 18. Another important ingredient of the proof of Theorem 2 is a structural theorem on automorphisms of products of graphs [24]. No such result exists for products of relational structures. Moreover, in Example 18 in Section 6 we suggest an example (again, a digraph) showing that nothing similar to such a structural result can be true. Some of the standard techniques in counting CSPs involve properties of relations and relational structures such as rectangularity, permutability, balancedness, the presence of a Mal’tsev polymorphism. In the case of exact counting these concepts are closely related to each other and make efficient algorithms possible. Unfortunately, these concepts are of little help for modular counting. We introduce their modular equivalents, but then a series of examples show that no tight connections are possible in this case. This makes algorithm design very difficult.

On the positive side, we obtain some results to somewhat remedy the situation. The first step is to convert the problem into a richer framework of multi-sorted relational structures and CSPs. The main idea is, given a CSP instance 𝒢, to try to identify the possible images of each vertex of 𝒢, and then treat vertices with different ranges as having different types and map them to different disjoint domains. In Section 4 we call this process refinement and propose two types of refinement, one is based on local propagation techniques, and the other on solving the decision version of the problem. The main benefit of using multi-sorted structures and CSPs is the richer structure of their automorphisms. This often allows stronger reductions than single-sorted structures do. In particular, if the digraph 𝒯p mentioned above is subjected to this process, it results in a multi-sorted structure that is no longer p-rigid, the corresponding reduced structure is very simple and can easily be solved. We are not aware of any examples of a structure whose multi-sorted refinement is p-rigid, but that would give rise to an easy modular counting problem.

In the next line of research we follow the approach of [9] to expand the relational structure by adding relations to that are primitive positive (pp-)definable in , that is, relations that can be derived from the relations of using equality, conjunction and existential quantifiers. However, expanding the general relational structure by pp-definable relations does not work as well as for graphs. To overcome this obstacle, we introduce a new form of expansion which uses p-modular quantifiers instead of regular existential quantifiers. The semantics of a p-modular quantifier is “there are non-zero modulo p values of a variable” rather than “there exists at least one value of a variable” as the regular existential quantifier asserts. Every relational structure is associated with a relational clone that consists of all relations pp-definable in . The new concept gives rise to new definitions of pp-formulas and relational clones. If regular existential quantifiers in pp-formulas are replaced with p-modular quantifiers, we obtain p-modular primitive positive formulas (p-mpp-formulas, for short). Then, similar to pp-definitions, a relation is said to be p-mpp-definable in a structure if there is a p-mpp-formula in expressing . The p-modular clone p associated with is the set of all relations p-mpp-definable in . We show in Theorem 10 (see also Theorem 7) that, similar to the result of Bulatov and Dalmau [6], expanding a structure by a p-mpp-definable relation does not change the complexity of the problem #p𝖢𝖲𝖯().

Theorem 3.

Let p be a prime number and a p-rigid relational structure. If is p-mpp-definable in , then #p𝖢𝖲𝖯(+) is polynomial time reducible to #p𝖢𝖲𝖯().

In the remaining part of the paper we identify a number of conditions under which it is possible to design an algorithm or to prove the hardness of the problem. One such case is #2𝖢𝖲𝖯() when satisfies both 2-rectangularity and the usual strong rectangularity conditions (or, equivalently, has a Mal’tsev polymorphism). It starts with applying the known techniques [5, 14] to find a concise representation or a frame of the set of solutions of a given CSP. However, such a representation cannot be used directly to find the parity of the number of solutions. The algorithm performs multiple recomputations of the frame to exclude the parts that produce an even number of solutions. Unfortunately, this algorithm does not generalize to larger p even under very strong assumptions, because the structure of finite fields start playing a role.

While studying the structure of automorphisms of products of relational structures such as 𝖠𝗎𝗍(n) may be a difficult problem, in Section 7 we make a step forward by reducing the class of structures for which such structural results are required. More precisely, for any relational structure =(H;1,,k) we construct its binarization b() whose relations are binary and rectangular. This makes such structures somewhat closer to graphs and the hope is that it will be easier to study the structure of 𝖠𝗎𝗍(b()n) than 𝖠𝗎𝗍(n) itself. We prove that and b() share many important properties.

Theorem 4.

Let be a relational structure. Then is strongly rectangular (p-strongly rectangular, p-rigid, has a Mal’tsev polymorphism) if and only if b() is strongly rectangular (p-strongly rectangular, p-rigid, has a Mal’tsev polymorphism).

2 Preliminaries

Let [n] denote the set {1,2,,n}. Let Hn be the Cartesian product of the set H with itself n times and H1××Hn the Cartesian product of sets H1,,Hn. We denote the members of Hn and H1××Hn using bold font, 𝐚Hn, 𝐚H1××Hn. The i-th element of 𝐚 is denoted by 𝐚[i] or 𝐚i.

For I={i1,,ik}[n] we use 𝗉𝗋I𝐚 to denote (𝐚i1,,𝐚ik); and for H1××Hn we use 𝗉𝗋I to denote {𝗉𝗋I𝐚𝐚}. For 𝐚Hs by #𝖾𝗑𝗍(𝐚) we denote the number of assignments 𝐛Hns such that (𝐚,𝐛). (Note that the order of elements in 𝐚 and 𝐛 and might differ, hence we slightly abuse the notation here.) We denote the number of assignments mod p by #𝗉𝖾𝗑𝗍(𝐚). Moreover, 𝗉𝗋Ip denotes the set {𝗉𝗋I𝐚|𝐚 and #𝗉𝖾𝗑𝗍(𝗉𝗋I𝐚)0}. Often, we treat relations H1××Hn as predicates :H1××Hn{0,1}.

2.1 Multi-Sorted Sets and Relational Structures

We begin with introducing multi-sorted or typed sets. Let H={Hi}i[k]={H1,,Hk} be a collection of sets. We will assume that the sets H1,,Hk are disjoint.

The cardinality of a multi-sorted set H equals |H|=i[k]|Hi|. A mapping φ between two multi-sorted sets G={Gi}i[k] and H={Hi}i[k] is defined as a collection of mappings φ={φi}i[k], where φi:GiHi, that is, φi maps elements of the sort i in G to elements of the sort i in H. A mapping φ={φi}i[k] from {Gi}i[k] to {Hi}i[k] is injective (bijective), if for all i[k], φi is injective (bijective).

A multi-sorted relational signature σ over a set of types {1,,k} is a collection of relational symbols, a symbol σ is assigned a positive integer , the arity of the symbol, and a tuple (i1,,i)[k], the type of the symbol. A multi-sorted relational structure with signature σ is a multi-sorted set {Hi}i[k] and an interpretation of each σ, where is a relation or a predicate on Hi1××Hi. The multi-sorted structure is finite if H and σ are finite. All structures in this paper are finite. The set H is said to be the base set or the universe of . For the base set we will use the same letter as for the structure, only in the regular font. Multi-sorted structures with the same signature and type are called similar.

Let 𝒢, be similar multi-sorted structures with signature σ. A homomorphism φ from 𝒢 to is a collection of mappings φi:GiHi, i[k], from G to H such that for any σ with type (i1,,i), if 𝒢(a1,,a) is true for (a1,,ar)Gi1××Gi, then (φi1(a1),,φi(a)) is true as well. The set of all homomorphisms from 𝒢 to is denoted 𝖧𝗈𝗆(𝒢,). The cardinality of 𝖧𝗈𝗆(𝒢,) is denoted by 𝗁𝗈𝗆(𝒢,). For a multi-sorted structure , the corresponding counting CSP, #p𝖢𝖲𝖯(), is the problem of computing 𝗁𝗈𝗆(𝒢,) modulo a prime number p for a given structure 𝒢. A homomorphism φ is an isomorphism if it is bijective and the inverse mapping φ1 is a homomorphism from to 𝒢. If and 𝒢 are isomorphic, we write 𝒢. A homomorphism of a structure to itself is called an endomorphism, and an isomorphism to itself is called an automorphism. As is easily seen, automorphisms of a structure form a group denoted 𝖠𝗎𝗍().

The direct product of multi-sorted σ-structures ,𝒢, denoted ×𝒢 is the multi-sorted σ-structure with the base set H×G={Hi×Gi}i[k], the interpretation of σ is given by ×𝒢((a1,b1),,(ak,bk))=1 if and only if (a1,,ak)=1 and 𝒢(b1,,bk)=1. By we will denote the th power of , that is, the direct product of copies of .

For a prime number p we say that π has order p if π is not the identity in 𝖠𝗎𝗍() and has order p in 𝖠𝗎𝗍(). In other words, each of the πj’s is either the identity mapping or has order p, and at least one of the πj’s is not the identity mapping. Structure is said to be p-rigid if it has no automorphism of order p. Similar to regular relational structures we can introduce reductions of multi-sorted structures by their automorphisms of order p.

A substructure of induced by a collection of sets {Hi}i[k], where HiHi is the relational structure given by ({Hi}i[k];1,,m), where j=j(Hi1××Hi) and (i1,,i) is the type of j. By 𝖥𝗂𝗑(π) we denote the collection {𝖥𝗂𝗑(πi)}j[k] of sets of fixed points of the πi’s. Let π denote the substructure of induced by 𝖥𝗂𝗑(π). We write p if there is π𝖠𝗎𝗍() of order p such that is isomorphic to π. We also write p if there are structures 1,,t such that is isomorphic to 1, is isomorphic to t, and 1p2ppt. Let also p be a p-rigid structure such that pp.

Proposition 5.

Let be a multi-sorted structure and p a prime. Then up to an isomorphism there exists a unique p-rigid multi-sorted structure p such that pp. Moreover, for any relational structure 𝒢 it holds 𝗁𝗈𝗆(𝒢,)𝗁𝗈𝗆(𝒢,p)(modp).

The proof of Proposition 5 follows the same lines as the analogous statement in the single-sorted case.

We complete this section with a definition of polymorphisms. Let Hn be a relation over a set H. A k-ary polymorphism of is a mapping f:HkH such that for any choice of 𝐚1,,𝐚k, it holds that f(𝐚1,,𝐚k) (computed component-wise). The mapping f is a polymorphism of a (single-sorted) relational structure =(H,1,,m) if it is a polymorphism of each relation 1,,m. In the multi-sorted case the definitions are a bit more complicated. Let H1××Hn be a multi-sorted relation. Instead of a single mapping we consider a family of mappings f={fi}i[n], fi:HikHi. The family f is said to be a polymorphism of if it satisfies the same condition: for any choice of 𝐚1,,𝐚k, it holds that f(𝐚1,,𝐚k), only in this case the mapping fi is applied in the ith coordinate position, i[n]. A polymorphism of a multi-sorted structure =({Hi}i[q];1,,m) is again a family f={fi}iq:HikHi such that for each j[m], f (or rather its appropriate subfamily) is a polymorphism of j. For a complete introduction into polymorphisms the reader is referred to [1].

The following special type of polymorphisms often occurs in the study of counting CSPs. For a set H a mapping φ:H3H is said to be a Mal’tsev operation if for any a,bH it satisfies the conditions f(a,a,b)=f(b,a,a)=b. In the multi-sorted case a family f={fi}i[n] is Mal’tsev, if every fi is Mal’tsev. A Mal’tsev operation (or a family of operations) that is a polymorphism of a relation or a relational structure is said to be a Mal’tsev polymorphism of or .

2.2 Expansion of relational structures

One of the standard techniques when studying constraint problems is to identify ways to expand the target relational structure or constraint language with additional relations without changing the complexity of the problem.

Let be a relational structure with signature σ and = its expansion by adding a binary relational symbol = interpreted as =H, the equality relation on H. The following reduction is straightforward.

Lemma 6 ([9]).

For any relational structure and any prime p, #p𝖢𝖲𝖯(=)T#p𝖢𝖲𝖯().

A constant relation over a set H is a unary relation Ca={a}, aH. For a relational structure by 𝖼 we denote the expansion of by all the constant relations Ca, aH. Theorem 7 was proved for exact counting in [6], for modular counting of graph homomorphisms in [16, 19, 20], and for general modular counting CSP in [9].

Theorem 7 ([9]).

Let be a p-rigid σ-structure. Then #p𝖢𝖲𝖯(𝖼) is polynomial time reducible to #p𝖢𝖲𝖯().

Lemma 6 and Theorem 7 can be generalized to the multi-sorted case. Let ={i}i[k] be a multi-sorted structure with signature σ and = its expansion by adding a family of binary relational symbols =Hi (one for each type) interpreted as the equality relation on Hi, i[k].

A constant relation over a set {Hi}i[k] is a unary relation Ca={a}, aHi,i[k] (such a predicate can only be applied to variables of type i). For a structure by 𝖼 we denote the expansion of by all the constant relations Ca, aHi,i[k].

Theorem 8.

Let be a multi-sorted relational structure and p prime.

  1. (1)

    #p𝖢𝖲𝖯(=) is Turing reducible to #p𝖢𝖲𝖯();

  2. (2)

    Let be p-rigid. Then #p𝖢𝖲𝖯(𝖼) is Turing reducible to #p𝖢𝖲𝖯().

Yet another way to expand a relational structure is by primitive positive definable (pp-definable for short) relations. Primitive-positive definitions have played a major role in the study of the CSP. It has been proved in multiple circumstances that expanding a structure with pp-definable relations does not change the complexity of the corresponding CSP. This has been proved for the decision CSP in [26, 8] and the exact Counting CSP [6]. The reader is referred to [1] for details about pp-definitions and their use in the study of the CSP.

Conjunctive definitions are a special case of pp-definitions that do not use quantifiers. Let be a structure with signature σ. A conjunctive formula Φ over variables {x1,,xk} is a conjunction of atomic formulas of the form (y1,,y), where σ is an (-ary) symbol and y1,,y{x1,,xk}. A k-ary predicate 𝒬 is conjunctive definable by Φ if (a1,,ak)𝒬 if and only if Φ(a1,,ak) is true.

Lemma 9 ([9]).

Let be a relational structure with signature σ, be conjunctive definable in , and + denote the expansion of by a predicate symbol that is interpreted as the relation in . Then #p𝖢𝖲𝖯(+)T#p𝖢𝖲𝖯().

We now extend the concept of primitive-positive definability to the multi-sorted case. Let be a multi-sorted relational structure with the base set H. As before primitive positive (pp-) formula in is a first-order formula y1,,ysΦ(x1,,xk,y1,,ys), where Φ is a conjunction of atomic formulas of the form z1=Hz2 or (z1,,z), z1,,z{x1,,xk,y1,,ys}, and is a predicate of . However, every variable in Φ is now assigned a type τ(xi),τ(yj) in such a way that for every atomic formula z1=Hz2 it holds that τ(z1)=τ(z2), and for any atomic formula (z1,,z) the sequence (τ(z1),,τ(z)) matches the type of . We say that pp-defines a predicate 𝒬 if there exists a pp-formula such that

𝒬(x1,,xk)=y1,,ysΦ(x1,,xk,y1,,ys).

For 𝐚 by #𝖾𝗑𝗍Φ(𝐚) we denote the number of assignments 𝐛Hτ(y1)××Hτ(ys) to y1,,ys such that Φ(𝐚,𝐛) is true. We denote the number of such assignments mod p by #𝗉𝖾𝗑𝗍Φ(𝐚).

While when is a graph it is possible to prove a statement similar to Lemma 9 for pp-definable relations [9], we will later see that it is unlikely to be true for general relational structures.

Finally, for a relational structure (single- or multi-sorted) denotes the relational clone of , that is, the set of all relations pp-definable in

2.3 Modular Expansion of Relational Structures

We follow the approach of [9] by expanding the relational structure by adding pp-definable relations, but doing in a manner friendly to modular counting.

We introduce a new form of expansion which is using p-modular quantifiers instead of regular existential quantifiers. The semantics of a p-modular quantifier is “there are non-zero modulo p values of a variable” rather than “there exists at least one value of a variable” as the regular existential quantifier asserts. The new concept gives rise to new definitions of pp-formulas. If regular existential quantifiers in pp-formulas are replaced with p-modular quantifiers, we obtain p-modular primitive positive formulas (p-mpp-formulas, for short). The p-modular quantifier is denoted p, and so p-mpp-formulas have the form

py1,,y1py1++s1+1,,ykΦ(z1,,zm).

Note the more complicated form of the quantifier prefix: modular quantification is not as robust as the regular one and quantifying variables away in groups or one-by-one may change the result. For example, let ={(1,0,0),(1,1,0),(1,1,1),(2,2,2)} be a relation on {0,1,2}. Then formulas 3y3z(x,y,z) and 3y,z(x,y,z) define sets {1,2} and {2}, respectively.

Every relational structure is associated with a relational clone that consists of all relations pp-definable in . Then, similar to pp-definitions, a relation is said to be p-mpp-definable in a structure if there is a p-mpp-formula in expressing . The p-modular clone p associated with is the set of all relations p-mpp-definable in . Similar to the result of Bulatov and Dalmau [6], expanding a structure by a p-mpp-definable relation does not change the complexity of the problem #p𝖢𝖲𝖯().

Theorem 10.

Let be a be a σ-structure, and p a prime. Let be a relation that is defined by R(x1,,xk)=py1,,yΦ(x1,,xk,y), then #p𝖢𝖲𝖯(+) is polynomial time reducible to #p𝖢𝖲𝖯().

3 Structural Properties for Counting

3.1 Rectangularity, Permutability, and Friends

The key properties of relational structures heavily exploited in [3, 14, 10] to obtain characterizations of the complexity of exact counting are rectangularity, balancedness, congruence permutability, and the presence of a Mal’tsev polymorphism. Indeed, according to [14] #𝖢𝖲𝖯() is polynomial time solvable if and only if is strongly balanced. However, in order for the solution algorithm to work, it requires a Mal’tsev polymorphism to be applied over and over again to construct a frame, that is, a compact representation of the set of solutions, [3, 14].

Using modular pp-definitions, we can modify these properties’ definitions accordingly to obtain the properties of strong p-rectangularity, p-balancedness, and p-permutability. Modular-pp-definitions preserve the complexity of modular problems, however, they destroy the connections between the concepts above.

𝒑-Rectangularity.

Recall that a binary relation H1×H2 is said to be rectangular if (a,c),(a,d),(b,c) implies (b,d) for any a,bH1,c,dH2. A relation H1××Hn for n2 is rectangular if for every I[n], the relation R is rectangular when viewed as a binary relation, a subset of 𝗉𝗋I×𝗉𝗋[n]I. A relational structure is strongly rectangular if every relation of arity at least 2 is rectangular. Finally, a relational structure is said to be strongly p-rectangular, if every p is rectangular.

𝒑-Balancedness.

An n-by-m matrix M is said to be a rank-1 block matrix if by permuting rows and columns it can be transformed to a block-diagonal matrix (not necessarily square), where every nonzero diagonal block has rank at most 1. Note that the rank can also be computed in p, in which case we use the term rank-1 block matrix modulo p.

Let (x,y,z) be a ternary relation, a subset of H1×H2×H3. We call balanced if the matrix 𝖬|H1|×|H2|, where 𝖬[x,y]=|{zH3:(x,y,z)}| such that xH1 and yH2 is a rank-1 block matrix. It is p-balanced if 𝖬 is a rank-1 block matrix modulo p. A relation of arity n>3 is balanced if every representation of as a ternary relation, a subset of Hk×H×Hnk, is balanced. Similarly, A relation on H of arity n>3 is p-balanced if every representation of as a ternary relation, a subset of Hk×H×Hnk, is p-balanced.

A relational structure is called strongly balanced if every relation is balanced. Similarly, a relational structure is called strongly p-balanced if every relation p is p-balanced.

𝒑-Permutability.

A congruence of a relational structure is an equivalence relation θ on H that is pp-definable in . More generally, let be a k-ary relation. A congruence of is a 2k-ary relation pp-definable in that is an equivalence relation on . We denote the set of all congruences of (of ) by 𝖢𝗈𝗇() (respectively, by 𝖢𝗈𝗇()). By we denote the product of binary relations: (a,b)𝒬 if and only if there is c such that (a,c) and (c,b)𝒬. We say is congruence permutable if for all α,β𝖢𝗈𝗇(), where , it holds that αβ=βα.

Congruence p-permutability is defined as follows: A p-congruence of or of p is an equivalence relation on H or , respectively, that is p-mpp-definable in . We denote the set of all p-congruences of () by 𝖢𝗈𝗇p() (𝖢𝗈𝗇p()). By p we denote the product of binary relations: (a,b) 

p 
𝒬
if and only if the number of elements c such that (a,c) and (c,b)𝒬 is not a multiple of p. We say that is congruence p-permutable if for all α,β𝖢𝗈𝗇p(), where p, we have α 

p 
β
=β 

p 
α
. Figure 1 demonstrates the connection between congruence permutabililty, strong rectangularity, the existence of a Mal’tsev polymorphism, strong balancedness and their modular counterparts. A collection of statements and examples proving these connections or lack thereof will be given in the full version of the paper. Below we give one such example showing that the existence of a Mal’tsev polymorphism does not guarantee 2-rectangularity.

(a) Congruence Permutability, Strong Rectangularity, and Mal’tsev polymorphism are equavalent (See [23, 14, 3]). Also, Strong Balancedness implies Strong Rectangularity(See [14]).
(b) The only connection that is preserved for the modular case is Congruence p-Permutability implies Strong p-rectangularity. Also, Strong 2-rectangularity is equivalence to Strong 2-Balancedness.
Figure 1: The connection between 4 properties is shown above. Figure (1(a)) shows the connection for the exact counting. Figure (1(b)) shows the the connection for the modular counterparts.
Example 11.

Let H={0,1,2}, p=2, and =(H;), where is the following ternary relation, (triples are written vertically), ={(0,0,0),(0,1,1),(1,0,1),(1,0,2),(1,1,0)}. As is easily see, 2z(x,y,z) is the relation {(0,0),(0,1),(1,1)}, which is not rectangular, and so, is not strongly 2-rectangular. We now show that is strongly rectangular by presenting a Mal’tsev polymorphism of . Let f(x,y,z)=x+y+z, where addition is modulo 2, is an operation on {0,1}. For 𝐚=(a1,a2,a3)H3, let also 𝐚{0,1}3 denote the triple obtained by replacing 2’s with 1’s. Then let g(x,y,z) be given by

g(𝐚)={2,if 𝐚{(2,a,a),(a,a,2)aH},f(𝐚)otherwise.

It is straightforward that g is a Mal’tsev operation and is a polymorphism of .

4 Rigitity and Multi-sorted Structures

We start with applying a well-known framework of multi-sorted relational structures to modular counting. While multi-sorted structures is a standard tool in the study of decision CSPs, it usually only used to simplify arguments and streamline algorithms. Here we use this framework in a more fundamental way, to strengthen the main (hypothetical) tractability condition.

The classification result in Theorem 2 asserts that #p𝖧𝗈𝗆(H) for a p-rigid graph H is hard whenever the exact counting problem is hard. In the following example, we briefly show that this is no longer the case for general relational structures.

Example 12.

Let p be a prime number and Tp={0,,p1,p,p+1}. A relational structure 𝒯p has the base set Tp and predicates ,C0,,Cp+1, where Ca is the constant relation {(a)} and =Tp2{(0,p),,(p1,p)}. The structure 𝒯p is p-rigid as it contains all the constant relations and every automorphism must preserve them, implying that every element of Tp is a fixed point. By [4, 35] the decision 𝖢𝖲𝖯(𝒯p) is solvable in polynomial time, while the exact counting problem #𝖢𝖲𝖯(𝒯p) is #P-complete by [6], as it does not have a Mal’tsev polymorphism and is not rectangular (see below). However, if 𝒢 is a structure similar to 𝒯p and there is a homomorphism φ:𝒢𝒯p such that some vertex v of 𝒢 is mapped to a{0,,p1} then, unless v is bound by Ca, the mapping that differs from φ only at v by sending it to any b{0,,p1} is also a homomorphism. Since |{0,,p1}|=p, this means that the elements 0,,p1 can be effectively eliminated from 𝒯p, and the resulting structure is somewhat trivial. Therefore #p𝖢𝖲𝖯(𝒯p) can be solved in polynomial time.

We introduce a different concept of rigidity that is stronger than the one used before. In particular, it will explain the tractability of the problem from Example 12.

While Proposition 5 allows one to reduce CSPs over non-p-rigid structures, it is sometimes possible to go further and reduce a CSP to one with a richer structure, and a richer set of automorphisms. Let =({Hi}i[k];1,,m) be a multi-sorted relational structure. We say that a structure 𝒢 is a refinement of if it satisfies the following conditions:

  1. (a)

    𝒢=({Gi}i[q];𝒬1,,𝒬t), where the Gi’ are pairwise disjoint,

  2. (b)

    for every i[q], there is an injective mapping ξi:GiHi for some i[k],

  3. (c)

    for every j[t] there is j[m] with jHi1××Hi and 𝒬j={(a1,,a)Gi1××Gi(ξi1(a1),,ξi(a))j}, where Gir is such that ξir(Gir)Hir𝗉𝗋rj.

Condition (a) is required because the domains of a multi-sorted structure have to be disjoint. Condition (b) basically says that Gi consists of copies of some elements of Hi. Condition (c) amounts to saying that 𝒬jj, except it uses copies of the elements of . In the notation of item (c) we use ξ(a1,,a) to denote (ξi1(a1),,ξi(a)), we use ξ(𝒬j) to denote {ξ(a1,,a)(a1,,a)𝒬j}, and ξ1(j) for {(a1,,a)Gi1××Giξ(a1,,a)j}.

It is possible that while is p-rigid, its refinement is not and Proposition 5.

In order to relate refinement structures with reductions between counting problems we introduce two special types of refinement. First of all, we will need an alternative approach to pp-definitions based on homomorphisms, see [17, 30].

Lemma 13 ([17, 30]).

A predicate (x1,,xk) is pp-definable in a multi-sorted structure containing the equality predicate if and only if there exists a similar structure 𝒢 containing vertices x1,,xk such that for any (a1,,ak) it holds that (a1,,ak) if and only if there is a homomorphism from 𝒢 to that maps xi to ai, i[k]. We will say that 𝒢 defines R in .

Let =({Hi}i[k];1,,m) be a multi-sorted relational structure. The Gaifman graph of is the graph G()=(V,E), where V=i[k]Hi and (a,b)E if and only if there is j[m] and 𝐚j such that 𝐚[s]=a,𝐚[t]=b for some coordinate positions s,t of j. The structure has treewidth d if G() has treewidth d.

We say that a refinement 𝒢=({Gi}i[q];𝒬1,,𝒬t) of is width d definable if for every i[q] there is a structure 𝒢i of treewidth at most d that defines ξi(Gi) in . In a similar way, we say that 𝒢 is a definable refinement if for every i[q] the set ξi(Gi) is pp-definable in . Finally, we say that 𝒢 is the full width d definable refinement (respectively, full definable refinement) if it satisfies the following conditions.

  1. (1)

    It is a width d definable refinement (respectively, a definable refinement).

  2. (2)

    For every unary relation U definable in by a structure of treewidth at most d (respectively, pp-definable unary relation) there is i[q] such that ξi(Gi)=U.

  3. (3)

    For every relation S obtained from some relation j by restricting it to domains definable by structures of width d (respectively by pp-definable domains), there is 𝒬j such that ξ(𝒬j)=S.

Since the original domains Hi, i[k], have trivial pp-definitions, they (or rather their copies) are always among the Gj’s, and copies of the original relations are also among the 𝒬j’s, although they may be over different, smaller domains than the i’s.

Next, we extend refinements to CSP instances. Let 𝒢=({Gi}i[q];𝒬1,,𝒬t) be a refinement of and 𝒫=(V,𝒞) an instance of 𝖢𝖲𝖯(). Recall that every variable vV is assigned a sort σ(v)[k]. Let σ:V[q] be such that ξσ(v):Gσ(v)Hσ(v) for each vV. The instance 𝒫σ=(V,𝒞σ) is said to be a refinement for 𝒢 of 𝒫 with the sort function σ if it satisfies the following two conditions

  1. (a)

    every vV is assigned the sort σ(v);

  2. (b)

    for every C=𝐬,𝒞, 𝐬=(v1,,v), it holds that ξσ(v)(Gσ(vi))𝗉𝗋i, i[], and there is C=𝐬,ξ1()𝒞σ.

The refinement 𝒫σ is lossless if for every solution φ of 𝒫 the mapping ξ1φ is a solution of 𝒫σ. Suppose 𝒢 is full pp-definable. The refinement 𝒫σ is minimal lossless if it is lossless and for each vV, σ(v) is minimal (with respect to inclusion of ξσ(v)(Gσ(v)) in the original domain). If 𝒢 is full of treewidth d, the definition is bit more complicated. The instance 𝒫 can also be viewed as a structure with vertex set V and such that the solutions of 𝒫 are exactly the homomorphisms from to , see [17]. Then 𝒫σ is minimal lossless of width d if it is lossless and for every vV, ξσ(v)(Gσ(v)) is minimal with respect to inclusion among unary relations defined by a structure 𝒢v of treewidth d with a designated variable x and such that there is a homomorphism from 𝒢i to mapping x to v. In fact, a minimal lossless of width d structure 𝒫σ is produced from 𝒫 by applying an appropriate local propagation algorithm [30].

Proposition 14.

Let be a multi-sorted relational structure.

  1. (1)

    Let 𝒢 be the full width d definable refinement of . For any instance 𝒫 of 𝖢𝖲𝖯(), its minimal lossless refinement of width d for 𝒢 can be found in polynomial time.

  2. (2)

    Let be a relational structure containing all the constant relations and such that 𝖢𝖲𝖯() is solvable in polynomial time, and 𝒢 the full definable refinement of . Then for any instance 𝒫 of 𝖢𝖲𝖯(), its minimal lossless refinement for 𝒢 can be found in polynomial time.

5 An Algorithm for Parity

In this section we outline an algorithm that solves #2𝖢𝖲𝖯(), that is, finds the parity of the number of homomorphisms to , provided the structure satisfies some additional conditions.

Theorem 15.

Let be a 2-rigid, strongly 2-rectangular, and 2 has a Mal’tsev polymorphism111Note that the latter condition does not follow from having a Mal’tsev polymorphism, because 2-mpp-definitions do not preserve polymorphisms.. Then #2𝖢𝖲𝖯() can be solved in time polynomial time.

In order to prove Theorem 15 we apply some of the existing techniques such as compact representations of relations with a Mal’tsev polymorphism, but in a novel way that is very different from its original use.

Frames and Witness Functions.

Suppose that is an n-ary relation with a Mal’tsev polymorphism φ. For each i[n] we define the following relation i on 𝗉𝗋i: aib if there exist tuples 𝐱Hi1 and 𝐲a,𝐲bHni such that (𝐱,a,𝐲a) and (𝐱,b,𝐲b). For the case i=1, we have a1b for all a,b𝗉𝗋1 because they share the common empty prefix ε. The relations i will be called frame relations. The following observations are straightforward corollaries of the rectangularity of and were used in [14].

Lemma 16 (Folklore).

Let be a relation with a Mal’tsev polymorphism.

  1. (1)

    i is an equivalence relation for all i[n].

  2. (2)

    If aib and 𝐱 with 𝐱i=a, then there is a 𝐲 with 𝐲i=b and 𝗉𝗋[i1]𝐱=𝗉𝗋[i1]𝐲.

A mapping ω:[n]×HHn{} is called a witness function of if

  1. (i)

    For any i[n] and aH𝗉𝗋i, ω(i,a)=;

  2. (ii)

    For any i[n] and a𝗉𝗋i, ω(i,a) is a witness for (i,a), i.e., 𝗉𝗋iω(i,a)=a;

  3. (iii)

    For any i[n] and a,b𝗉𝗋i with aib, we have 𝗉𝗋[i1]ω(i,a)=𝗉𝗋[i1]ω(i,b).

A witness function ω provides a concise representation of . Let F={ω(i,a)i[n],a𝗉𝗋i}. Such a set of tuples is called a frame of . A witness function (or a frame) can be found in polynomial time given a conjunctive definition (i.e. a CSP instance) of a relation in a relational structure with a Mal’tsev polymorphism. This is the property that makes them essential for solving CSPs. The following transformations of frames can be performed in polynomial time.

Proposition 17 ([5, 14]).

Let be a relational structure with a Mal’tsev polymorphism and a relation has a conjunctive definition (x1,,xn)=i[m]i(xi1,,xit) in .

  1. (1)

    A frame and a witness function for can be computed in O(mn4).

  2. (2)

    Let I[n]. Given a frame F for , a frame for (x1,x2,,xn)(sICas(xs)) (i.e., xs is the constant asH, sI) can be constructed in O(n3) time.

  3. (3)

    Given a frame F for , a frame for 𝒬(x1,x2,xn1)=y(x1,,xn1,y), can be constructed in O(n) time.

Overview of the algorithm.

The exact counting algorithm in [14] first finds a frame of a conjunctive defined relation (a.k.a. the set of solutions of a CSP instance), and then uses the frame and the condition of balancedness to compute the number of solutions. Unfortunately, this approach does not work in our case, because according to the results of Section 3.1 the property of 2-balancedness that we need here does not correlate well with the existence of a Mal’tsev polymorphism. We therefore choose a different approach.

Let be a structure satisfying the conditions of Theorem 15 and 2. Since 2 has a Mal’tsev polymorphism, a frame for can be computed in polynomial time by Proposition 17(1). Suppose that is n-ary. It is not hard to see that

|||2y(x1,,xn1,y)|(mod2).

Therefore, if it is possible to find a frame of ~=2y(x1,,xn1,y), we could repeat this process n1 times eventually obtaining a unary relation such that ||||(mod2) and then just count the elements in using its frame. Unfortunately, it is not that straightforward, because Proposition 17(3) does not work for modular quantifiers. Instead, we use a more convoluted method.

Let 𝖯𝖠𝖱(𝐱,y)=(𝐱,y)(2z(𝐱,z)). This relation contains essentially the same tuples as ~, except it also keeps their extensions to the last coordinate position. This means that ~=y𝖯𝖠𝖱(𝐱,y), and if we know a frame of 𝖯𝖠𝖱(𝐱,y), a frame of ~ can be found by Proposition 17(3). Finding a frame for 𝖯𝖠𝖱(𝐱,y) is the crux of the algorithm.

Finding a frame for 𝗣𝗔𝗥𝓡(𝐱,𝒚).

Let i and ω be frame relations and a witness function (a frame) of the relation found in the previous step. Let i denote the collection of the equivalence classes of i, and i={i,1,,i,i}, i,j𝗉𝗋i, where j[i]. We often refer to these classes as frame classes. By i,ω, and i, i[n], we denote yet unknown frame relations, witness function, and frame classes of 𝖯𝖠𝖱 (clearly, the number of classes in i may differ from that of i).

First, we observe that by definition a tuple (𝐱,a) belongs to 𝖯𝖠𝖱 if and only if there is a class n,sn, s[n], such that an,s and |n,s|1(mod2). This makes finding n and ω(n,) easy, they are just restrictions of n and ω(n,) on the union of odd classes from n. For k[n1] and a𝗉𝗋k we use Proposition 17(2) to find a witness function ωka and frame classes ika of (x1,x2,,xn)Ca(xk). We examine n,ska for s[|nka|]. We check whether there exists s[|nka|] such that |n,ska|1mod2. If we find such an s, we select bn,ska and set ω(k,a)=ωka(n,b). By construction 𝗉𝗋kω(k,a)=𝗉𝗋kωka(n,b)=a, and by the observation above ω(k,a)𝖯𝖠𝖱. Finally, in order to check whether for some b𝗉𝗋k it holds that akb it suffices to complete the following steps. Use use Proposition 17(2) to compute a witness function ω′′ and frame classes of

(x1,,xn)Cb(xk)(s=1k1Cds(xs)),

where (d1,,dn)=ωka(k,a). It can be shown that akb if and only if there exists t[|n′′|] such that |n,t′′|1(mod2).

This completes the outline of the algorithm.

6 Hardness and Automorphisms of Direct Products of Structures

Another crucial component of Theorem 2 is the structure of automorphisms of direct products of graphs [24]. It essentially asserts that every automorphism of a direct product H1××Hn can be thought of as a composition of a permutation of factors in the product and automorphisms of those factors. In the following example we show that this breaks down already for digraphs.

Example 18.

let =(V,E) be a directed graph where V={a,b,c,d} with (directed) edge set E={(b,a),(b,c),(c,d)}. This digraph is rigid. However, the automorphism group of 2, see Figure 2, has a complicated structure. As is easily seen 2 has a large number of automorphisms of order 2 and 3, not all of which have a simple representation mentioned above.

Figure 2: The structure of and 2.

In [9] one of the important applications of the structural theorem for automorphisms of graph products is that it allows one to prove that #p𝖧𝗈𝗆(+), where + denotes the expansion of by a relation pp-definable in , is polynomial time reducible to #p𝖧𝗈𝗆(). The example above indicates that this result may no longer be true for general relational structures.

Next, we explore what implications of a structural result similar to that in [24] that is used in [9] about 𝖠𝗎𝗍(n) can be. A rectangularity obstruction is a violation of the rectangularity or p-rectangularity property, that is, a (n-ary) relation pp- or p-mpp-definable in a structure , k[n], and tuples 𝐚,𝐛𝗉𝗋[k],𝐜,𝐝𝗉𝗋[n][k] such that (𝐚,𝐜),(𝐚,𝐝),(𝐛,𝐝), but (𝐛,𝐜). A generalized rectangularity obstruction are the relation and sets A1,1,A1,2𝗉𝗋[k], A2,1,A2,2𝗉𝗋[n][k] such that A1,1A1,2=, A2,1A2,2=, and any 𝐚A1,1,𝐛A1,2,𝐜A2,1,𝐝A2,2 form a rectangularity obstruction.

At the first glance, if such an obstruction exists, it should be possible to prove the hardness of #p𝖢𝖲𝖯(). Indeed, can be viewed as a bipartite graph 𝖪, whose parts of the bipartition are 𝗉𝗋[k] and 𝗉𝗋[n][k], and as the rectangularity obstruction shows, this graph is not complete bipartite implying that #𝖧𝗈𝗆(𝖪) is #P-complete. However, the hardness of #p𝖧𝗈𝗆(𝖪) also involves the requirement that 𝖪 is p-rigid. p-rigidity is achieved by restricting the problem to induced subgraphs of 𝖪 as in Lemma 1. However, such a subgraph may avoid the (generalized) rectangularity obstruction rendering it useless.

The obstruction A1,1,A1,2𝗉𝗋[k], A2,1,A2,2𝗉𝗋[n][k] is said to be protected in if, after applying a p-reduction to under a sequence of p-automorphisms from 𝖠𝗎𝗍(), for the resulting relation ~ it holds that 𝗉𝗋[k]~A1,1,𝗉𝗋[k]~A1,2, 𝗉𝗋[n][k]~A2,1,𝗉𝗋[n][k]~A2,2. In fact, Theorem 4.2 [9] implies, although implicitly, that any p-rigid graph that is not a complete bipartite graph contains a protected rectangularity obstruction. One case of a protected rectangularity obstruction is when it is protected in 𝖪, that is, survives p-reductions of 𝖪 itself. In this case we say that the obstruction is graph-protected.

Proposition 19.

Let be a (multi-sorted) relational structure and p a prime number. If has a graph protected generalized rectangularity obstruction modulo p, #p𝖢𝖲𝖯() is #pP-complete.

We consider a special case of graph-protected generalized rectangularity obstructions, standard hardness gadgets, that have to satisfy the additional condition A1,1A1,2=𝗉𝗋[k],A2,1A2,2=𝗉𝗋[n][k]. It is can be proved that a standard hardness gadget is indeed a graph-protected obstruction.

Standard hardness gadgets provide a fairly limited condition for the hardness of #p𝖢𝖲𝖯(). In fact, it is possible to prove that #p𝖢𝖲𝖯() is #pP-complete whenever has any protected rectangularity obstruction, not necessarily a standard gadget. However, it cannot be done using Theorem 2 as a black box, and is outside of the scope of this paper.

7 Binarization

While studying the structure of 𝖠𝗎𝗍(k) for a relational structure and an integer k may be a difficult problem, in this Section we make a step forward by reducing the class of structures for which such a characterization is required. In particular, we show that it suffices to obtain a characterization for structures with only binary rectangular relations. More precisely, for any relational structure =(H;1,,k) we construct its binarization b() as follows. The structure b() is multi-sorted, and the domains are the relations 1,,k viewed as sets of tuples, thus, b() has k domains. For every pair i,j[k] (i,j are allowed to be equal) and any s[i],t[j], where i,j are the arities of i,j, the structure b() contains a binary relation 𝒬stij={(𝐚,𝐛)𝐚i,𝐛j,𝐚[s]=𝐛[t]}. We show that and b() share many important properties.

Theorem 20.

Let be a relational structure. Then is strongly rectangular (p-strongly rectangular, p-rigid, has a Mal’tsev polymorphism) if and only if b() is strongly rectangular (p-strongly rectangular, p-rigid, has a Mal’tsev polymorphism).

In addition to Theorem 20 every relation of b() is binary and rectangular. This makes such structures somewhat closer to graphs and the hope is that it will be easier to study the structure of 𝖠𝗎𝗍(b()n) than 𝖠𝗎𝗍(n) itself.

References

  • [1] Libor Barto, Andrei Krokhin, and Ross Willard. Polymorphisms, and how to use them. In Dagstuhl Follow-Ups, volume 7. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2017. doi:10.4230/DFU.VOL7.15301.1.
  • [2] Alexander I. Barvinok. Combinatorics and Complexity of Partition Functions, volume 30 of Algorithms and combinatorics. Springer, 2016. doi:10.1007/978-3-319-51829-9.
  • [3] Andrei A. Bulatov. The complexity of the counting constraint satisfaction problem. J. ACM, 60(5):34:1–34:41, 2013. doi:10.1145/2528400.
  • [4] Andrei A. Bulatov. A dichotomy theorem for nonuniform CSPs. In Chris Umans, editor, FOCS, pages 319–330, 2017. doi:10.1109/FOCS.2017.37.
  • [5] Andrei A. Bulatov and Víctor Dalmau. A simple algorithm for Mal’tsev constraints. SIAM J. Comput., 36(1):16–27, 2006. doi:10.1137/050628957.
  • [6] Andrei A. Bulatov and Víctor Dalmau. Towards a dichotomy theorem for the counting constraint satisfaction problem. Information and Computation, 205(5):651–678, 2007. doi:10.1016/J.IC.2006.09.005.
  • [7] Andrei A. Bulatov and Martin Grohe. The complexity of partition functions. Theor. Comput. Sci., 348(2-3):148–186, 2005. doi:10.1016/J.TCS.2005.09.011.
  • [8] Andrei A. Bulatov, Peter Jeavons, and Andrei A. Krokhin. Classifying the complexity of constraints using finite algebras. SIAM J. Comput., 34(3):720–742, 2005. doi:10.1137/S0097539700376676.
  • [9] Andrei A. Bulatov and Amirhossein Kazeminia. Complexity classification of counting graph homomorphisms modulo a prime number. In STOC, pages 1024–1037. ACM, 2022. doi:10.1145/3519935.3520075.
  • [10] Jin-Yi Cai and Xi Chen. Complexity of counting CSP with complex weights. J. ACM, 64(3), June 2017. doi:10.1145/2822891.
  • [11] Jin-yi Cai and Lane A. Hemachandra. On the power of parity polynomial time. In Burkhard Monien and Robert Cori, editors, STACS, volume 349 of Lecture Notes in Computer Science, pages 229–239. Springer, 1989. doi:10.1007/BFB0028987.
  • [12] Víctor Dalmau and Peter Jonsson. The complexity of counting homomorphisms seen from the other side. Theor. Comput. Sci., 329(1-3):315–323, 2004. doi:10.1016/J.TCS.2004.08.008.
  • [13] M. Dyer and C. Greenhill. The complexity of counting graph homomorphisms. Random Structures and Algorithms, 17:260–289, 2000. doi:10.1002/1098-2418(200010/12)17:3/4\%3C260::AID-RSA5\%3E3.0.CO;2-W.
  • [14] Martin Dyer and David Richerby. An effective dichotomy for the counting constraint satisfaction problem. SIAM J. on Comp, 42(3):1245–1274, 2013. doi:10.1137/100811258.
  • [15] John Faben. The complexity of counting solutions to generalised satisfiability problems modulo k, 2008. arXiv:0809.1836.
  • [16] John Faben and Mark Jerrum. The complexity of parity graph homomorphism: an initial investigation. arXiv preprint arXiv:1309.4033, 2013. arXiv:1309.4033.
  • [17] Tomás Feder and Moshe Y. Vardi. The computational structure of monotone monadic SNP and constraint satisfaction: A study through datalog and group theory. SIAM J. Comput., 28(1):57–104, 1998. doi:10.1137/S0097539794266766.
  • [18] Jacob Focke, Leslie Ann Goldberg, Marc Roth, and Stanislav Zivný. Counting homomorphisms to k4-minor-free graphs, modulo 2. In Dániel Marx, editor, SODA, pages 2303–2314. SIAM, 2021. doi:10.1137/1.9781611976465.137.
  • [19] Andreas Göbel, Leslie Ann Goldberg, and David Richerby. Counting homomorphisms to square-free graphs, modulo 2. ACM Transactions on Computation Theory (TOCT), 8(3):1–29, 2016. doi:10.1145/2898441.
  • [20] Andreas Göbel, J. A. Gregor Lagodzinski, and Karen Seidel. Counting homomorphisms to trees modulo a prime. In MFCS, volume 117, pages 49:1–49:13, 2018. doi:10.4230/LIPICS.MFCS.2018.49.
  • [21] Heng Guo, Sangxia Huang, Pinyan Lu, and Mingji Xia. The Complexity of Weighted Boolean #CSP Modulo k. In STACS), volume 9, pages 249–260, 2011. doi:10.4230/LIPICS.STACS.2011.249.
  • [22] Andreas Göbel, Leslie Ann Goldberg, and David Richerby. The complexity of counting homomorphisms to cactus graphs modulo 2. ACM Trans on Comp Th, 6(4):1–29, 2014. doi:10.1145/2635825.
  • [23] J. Hagemann and A. Mitschke. On n-permutable congruences. Algebra Universalis, 3:8–12, 1973.
  • [24] Richard Hammack, Wilfried Imrich, and Sandi Klavzar. Handbook of Product Graphs, Second Edition. CRC Press, Inc., USA, 2nd edition, 2011.
  • [25] Ulrich Hertrampf. Relations among mod-classes. Theor. Comput. Sci., 74(3):325–328, 1990. doi:10.1016/0304-3975(90)90081-R.
  • [26] Peter Jeavons. On the algebraic structure of combinatorial problems. Theoretical Computer Science, 200(1-2):185–204, 1998. doi:10.1016/S0304-3975(97)00230-2.
  • [27] Mark Jerrum and Alistair Sinclair. Polynomial-time approximation algorithms for the Ising model. SIAM J. Comput., 22(5):1087–1116, 1993. doi:10.1137/0222066.
  • [28] Amirhossein Kazeminia and Andrei A Bulatov. Counting homomorphisms modulo a prime number. In MFCS. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2019.
  • [29] Amirhossein Kazeminia and Andrei A. Bulatov. Modular counting csp: Reductions and algorithms, 2025. arXiv:2501.04224.
  • [30] Phokion G Kolaitis. Constraint satisfaction, complexity, and logic. In Hellenic Conference on Artificial Intelligence, pages 1–2. Springer, 2004. doi:10.1007/978-3-540-24674-9_1.
  • [31] J. A. Gregor Lagodzinski, Andreas Göbel, Katrin Casel, and Tobias Friedrich. On counting (quantum-)graph homomorphisms in finite fields of prime order. CoRR, abs/2011.04827, 2021. arXiv:2011.04827.
  • [32] E.H. Lieb and A.D. Sokal. A general Lee-Yang theorem for one-component and multicomponent ferromagnets. Communications in Mathematical Physics, 80(2):153–179, 1981.
  • [33] L. Valiant. The complexity of computing the permanent. Theoretical Computing Science, 8:189–201, 1979. doi:10.1016/0304-3975(79)90044-6.
  • [34] L. Valiant. The complexity of enumeration and reliability problems. SIAM Journal on Computing, 8(3):410–421, 1979. doi:10.1137/0208032.
  • [35] Dmitriy Zhuk. A proof of the CSP dichotomy conjecture. J. ACM, 67(5):30:1–30:78, 2020. doi:10.1145/3402029.