Abstract 1 Introduction 2 Preliminaries 3 Automorphic Polynomials 4 Tools for Reduction 5 Complexity Classifications References

Modular Counting over 3-Element and Conservative Domains

Andrei A. Bulatov Simon Fraser University, Burnaby, Canada Amirhossein Kazeminia University of Oxford, UK
Abstract

In the Constraint Satisfaction Problem (CSP for short) the goal is to decide the existence of a homomorphism from a given relational structure 𝒢 to a given relational structure . If the structure is fixed and 𝒢 is the only input, the problem is denoted CSP(). In its counting version, #CSP(), the task is to find the number of such homomorphisms. The CSP and #CSP have been used to model a wide variety of combinatorial problems and have received a tremendous amount of attention from researchers from multiple disciplines.

In this paper we consider the modular version of the counting CSPs, that is, problems of the form #pCSP() of counting the number of homomorphisms to modulo a fixed prime number p. Modular counting has been intensively studied during the last decade, although mainly in the case of graph homomorphisms. Here we continue the program of systematic research of modular counting of homomorphisms to general relational structures. The main results of the paper include a new way of reducing modular counting problems to smaller domains and a study of the complexity of such problems over 3-element domains and over conservative domains, that is, relational structures that allow to express (in a certain exact way) every possible unary predicate.

Keywords and phrases:
Constraint Satisfaction Problem, Modular Counting
Funding:
Andrei A. Bulatov: This research is supported by a NSERC Discovery Grant.
Amirhossein Kazeminia: UKRI EP/X024431/1.
Copyright and License:
[Uncaptioned image] © Andrei A. Bulatov and Amirhossein Kazeminia; 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/2510.09950
Editors:
Meena Mahajan, Florin Manea, Annabelle McIver, and Nguyễn Kim Thắng

1 Introduction

The Constraint Satisfaction Problem.

In a Constraint Satisfaction Problem (CSP) the goal is to decide the existence of a homomorphism from a given relational structure 𝒢 to a given relational structure , [27]. If the target structure is fixed and only 𝒢 is the input, the problem called a nonuniform CSP and is denoted by CSP(), [27]. CSPs and nonuniform CSPs in particular have been used to model a wide variety of combinatorial problems across many disciplines. The complexity of problems of the form CSP() for finite relational structures has been thoroughly investigated [37, 15, 2, 11, 36, 10, 48].

In the counting version of the CSP, denoted by #CSP (or #CSP() if we are dealing with a nonuniform problem), the goal is to find the number of homomorphisms from a given structure 𝒢 to a given structure , or in the case of a nonuniform problem to a fixed structure . Counting CSPs have received much attention starting from the seminal work of Valiant [46, 45], to the classification of Boolean [21] counting CSPs and those over graphs [22], to the discovery of the algebraic method for such problems [12], to a complexity classification of unweighted counting CSPs [8, 23], to a sequence of results on weighted counting CSPs [24, 13, 32, 18, 20, 19] culminating at a complete characterization of counting CSPs with complex weights by Cai and Chen [17]. In all the research mentioned above the goal is “exact” counting, that is, finding the exact number of (weighted) homomorphisms between relational structures. Approximate counting is another vast area of research that we do not touch in this paper. Statistical Physics often concerns with the problem of computing partition functions that is closely related to counting CSPs. In this paper we consider another variation of counting problems, counting modulo an integer.

The complexity class the Counting CSP 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 (polynomial time) 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 (or polynomial time) reduction is a polynomial time algorithm that solves #A using #B as an oracle.

Modular counting.

While the complexity of and algorithms for exact counting are now well understood, counting modulo an integer has received much attention in the past decade. For an integer k and a relational structure the problem of counting homomorphisms from a given relational structure to modulo k is denoted by #kCSP(). Here (and in almost all papers on the subject) the focus is on prime moduli p.

One of the most important features of relational structures affecting the complexity of the corresponding modular counting CSP is the automorphism group, 𝖠𝗎𝗍(), of . Indeed, it can be easily shown that if π𝖠𝗎𝗍() has order p (or is a p-automorphism), then #pCSP() is equivalent, i.e., parsimoniously interreducible, with #pCSP(π), where π denotes the substructure of induced by the set 𝖥𝗂𝗑(π) of the fixed points of π. Clearly, such a reduction by p-automorphisms can be repeated until the resulting structure is p-rigid, that is, has no p-automorphisms. Such a derivative p-rigid structure is unique up to an isomorphism, as it is shown in [26], and will be denoted by p.

A related problem that will be important in this paper is computing partition functions. Let M be a k×k-matrix with entries from (in the most general case) a semiring 𝕊. Let EVAL(M) denote the problem of computing the function

ZM(G)=φ:V[k](u,v)EM[φ(u),φ(v)]

for a given (di)graph G=(V,E), called the partition function of G. The complexity of EVAL(M) has been extensively studied in Statistical Physics and Theoretical Computer Science, see [47, 4, 14] for some samples. In the case of real or complex matrices the complexity of exact computing of partition functions is well understood [14, 18]. The case of matrices over a finite field that arises from modular counting is wide open and presents challenges that can be glimpsed from the “cancellation phenomenon” observed in [32, 17] and produced by elements of the field of a finite multiplicative order.

Existing results.

A systematic research on modular counting was initiated by Faben in [25], who introduced the complexity classes #pP of problems of counting, modulo p, accepting paths of polynomial time Turing machines. In the same paper he also proved some key hardness results and gave a complexity classification of #pCSP() for 2-element structures into polynomial time solvable and #pP-complete ones. The notion of reduction between modular counting problems is similar to that for exact counting: it is either polynomial time reduction, in the same sense as before, or parsimonious reductions, where the answers to the two instances must be equal modulo p.

Since then most of the effort has been directed at problems #pCSP() where is a graph. Faben and Jerrum [26] investigated the case when p=2 and is a tree, and, apart from classifying the complexity of the problem in this case, they also posed a conjecture stating that if is a p-rigid graph, #pCSP() has the same complexity as the exact counting problem #CSP(). In a series of papers [31, 30, 33, 43, 28, 40] the Faben–Jerrum conjecture was confirmed for a number of graph classes and values of p, and then was proved in full generality by Bulatov and Kazeminia in [16].

While modular counting of graph homomorphisms provides some insight into the more general case, many of the complications do not occur in that case as it was demonstrated in [41]. As we will be using some of the results from this paper, we discuss it in some detail. The first observation is that the more general version of the Faben–Jerrum conjecture is not true for general relational structures: for any prime p there exists a p-rigid structure such that #CSP() is #P-complete, but #pCSP() is polynomial time solvable. This can be fixed to some extent by introducing and exploiting multi-sorted relational structures with a richer structure of automorphisms. We will be using this framework as well, see Section 2.1. Although it is possible to modify the Faben–Jerrum conjecture for general multi-sorted structures in such a way that no counterexample is known so far, there is still little understanding of the general case.

There are two properties of graphs that made the result of [16] possible but fail for general relational structures. One is the structure of automorphisms of direct products of graphs. Due to the results of [35, 16] every automorphism of a direct product of graphs essentially boils down to a combination of automorphisms of the factors and a permutation of the factors. This is no longer true in the general case, even in the case of digraphs, as was demonstrated in [41]. This leads to a failure of the second important property: reductions through primitive positive (pp-) definitions. Let be a relational structure. Recall that a relation (x1,,xk) on H, the base set of , is said to be pp-definable in if there is a first order formula that represents and has the following form

(x1,,xk)=y1,,ymΦ(x1,,xk,y1,,ym),

where Φ is a conjunction of predicates from and equality predicates. If is a p-rigid graph, then the problem #pCSP(+), where + denotes the extension of by adding the predicate , is polynomial time reducible to #pCSP(). Such reductions are known to be a powerful tool in the CSP research, as they allow for the use of polymorphisms, that is, homomorphisms from powers n to , to describe the complexity of constraint problems, see [15, 3]. In particular, the existence of a so-called Mal’tsev polymorphism, that is, a polymorphism m:3 satisfying the equations m(x,y,y)=m(y,y,x)=x, makes it possible to represent solutions to a CSP in a compact form that then in some cases can be used to find their number [11, 23]. In the case of general relational structures pp-definitions no longer give rise to reductions between problems and need to be replaced with their modular counterpart. A relation (x1,,xk) is said to be p-mpp-definable in for a prime p, it can be represented by a formula

(x1,,xk)=py1,,ymΦ(x1,,xk,y1,,ym),

where the requirements on Φ are the same as before, and which is true for certain values of x1,,xk if and only if the number of values of y1,,ym that make Φ(x1,,xk,y1,,ym) true is not divisible by p. Then [41] proves that #pCSP(+) is polynomial time reducible to #pCSP() for any relational structure and any relation p-mpp-definable in .

Unfortunately, p-mpp-definitions cannot be captured by polymorphisms, and overcoming this difficulty will be an ongoing theme of this paper. In some cases, however, polymorphisms of p-mpp-definable relations play an important role. For instance, in [41] it was shown that if the set of 2-mpp-definable relations of a structure has a Mal’tsev polymorphism, then #2CSP() can be solved in polynomial time.

Our contribution.

In this paper we build upon the results of [41] to obtain a complexity classification of #pCSP() for two classes of structures . We start with a new version of an automorphism and the corresponding rigidity condition.

A binary polymorphism f of a relational structure is said to be an automorphic polynomial if for every aH, f(a,x) is a permutation of H. If, for a prime p, for any aH, f(a,x) is the identity mapping or a permutation of order p, and f(a,x) is a permutation of order p for at least one aH, f is said to be a p-automorphic polynomial. The existence of a p-automorphic polynomial allows one to reduce a modular counting CSP to a CSP over a smaller structure even when the structure is p-rigid, see Example 12. For a complete version of the following result see Proposition 10 and Corollary 11.

Proposition 1.

Let a relational structure have a p-automorphic polynomial f. Then there is f such that the domain of f has smaller cardinality than and #pCSP() is polynomial time reducible to #pCSP(f). Moreover, if satisfies some additional conditions, f can be chosen such that #pCSP() and #pCSP(f) are polynomial time equivalent.

In order to prove Proposition 1, given an instance (V,𝒞) of #pCSP() we find permutations of the domain that are specific for each variable from V, have order p, and such that they map every tuple of every constraint to a tuple from the same constraint (so-called consistent permutations). These permutations allow us to reduce the domain to a smaller structure (in terms of the cardinality of the domain), because similar to automorphisms the elements that are shifted by the permutations can be eliminated from the problem. On the other hand, let aH be an element such that f(a,x) is a permutation of order p. Then, if the permutations above do not exist, it implies that the element a cannot be a part of any solution, and therefore can be eliminated. Consistent permutations are found by constructing a derivative CSP, whose domain is the symmetric group on H, and the CSP itself is an instance of a Mal’tsev CSP over that group [11, 5].

Recall that a unary relation pp-definable in a structure is said to be a subalgebra of . In the case of modular counting we use p-subalgebras, that is, unary relations p-mpp-definable in . The two types of relational structures we consider here are

  • 3-element structures, which are the next step after a similar result for 2-element structures from [25], and

  • p-conservative structures, i.e., structures such that every possible unary relation is a p-subalgebra.

The same types of the CSP have been major milestones in the study of the decision problem, see [6, 7, 1, 9]. They introduced several key ideas that were then used to obtain a dichotomy theorem for the general CSP.

In this paper in both cases our complexity classification is incomplete. The remaining difficulty is the complexity of modular partition functions. When p=2 every partition function has a 0-1 matrix, and therefore can be treated as the problem of counting homomorphism to a graph or a bipartite graph. The complexity of this problem is known, see, [16]. If p3 this is no longer possible and the structure of matrices of partition functions becomes more intricate, requiring methods from finite fields. To give the reader a better idea of the difficulties with modular partition functions, recall [8, 23] that in the case of exact counting a necessary and sufficient condition for the problem #CSP() to be solvable in polynomial time is that the structure is strongly balanced. It means that there is a way to associate integer matrices to relations pp-definable in , and these matrices must have rank at most 1. In fact, the complexity of #CSP is determined by the complexity of EVAL(M), for the matrices M defined as above. That balancedness is necessary for #pCSP() being solvable in polynomial time is no longer true, and this is due to the fact that the modular version of EVAL(M) can be polynomial time solvable even if M does not have rank 1. Some partial results have been obtained in [39].

Let and p denote the set of all relations that are, respectively, pp-definable and p-mpp-definable in . In the case of exact counting a necessary condition for tractability of #CSP() is the existence of a Mal’tsev polymorphism of , mentioned above. No similar property has been known to be true for modular counting. The two main results of this paper claim that for 3-element and p-conservative structures if p has no Mal’tsev polymorphism then #pCSP() is #pP-hard. If a Mal’tsev polymorphism exists then we identify certain cases, in which the problem is polynomial time solvable.

Theorem 2.

Let be a p-conservative structure and p a prime. If p does not have a Mal’tsev polymorphism then #pCSP() is #pP-hard. Otherwise, if p=2 then #2CSP() is solvable in polynomial time.

In order to state the result for 3-element structures let f be the structure from Proposition 1 constructed from using a p-automorphic polynomial f. Note that if is a 3-element structure, f has at most 2 elements.

Theorem 3.

Let be a 3-element structure and p a prime. If one of the following conditions holds:

  1. (a)

    has a p-automorphic polynomial f and fp has a Mal’tsev polymorphism, or

  2. (b)

    does not have a p-automorphic polynomial, p has a Mal’tsev polymorphism, and p=2,

then #pCSP() is solvable in polynomial time. If

  1. (1)

    has a p-automorphic polynomial f and fp does not have a Mal’tsev polymorphism, or

  2. (2)

    does not have a p-automorphic polynomial and p does not have a Mal’tsev polymorphism,

then #pCSP() is #pP-complete.

Since f has at most 2 elements, the cases when has a p-automorphic polynomial can be dealt with using an extension of the results by Faben [25], see Proposition 20.

Apart from the introduction of p-automorphic polynomials, the main technical contribution of the paper is the following. The property of relations with a Mal’tsev polymorphism that makes Mal’tsev polymorphisms useful is rectangularity. A relation (at least binary) is said to be rectangular if for any partition of the coordinate set of into two nonempty parts for any tuples 𝐚,𝐛 from the first part and 𝐜,𝐝 from the second part, if (𝐚,𝐜),(𝐛,𝐜),(𝐛,𝐝), then (𝐚,𝐝). If a structure has a Mal’tsev polymorphism then any relation is rectangular, a property that is sometimes referred to as strong rectangularity. It is the lack of rectangularity that often makes a counting CSP hard, as it was shown in [12]. In the case of modular counting a similar result is also true, although highly nontrivial, provided a non-rectangular relation is in , see [16]. The major difficulty though has been to obtain hardness from non-rectangular relations in . Here we found a way to use p instead, while still using a Mal’tsev polymorphism, although in a different manner than in other versions of counting.

2 Preliminaries

Let [n] denote the set {1,2,,n}. Let Hn be the direct product of the set H with itself n times and H1××Hn the direct product of sets H1,,Hn. We denote the members of Hn and H1××Hn using bold font, 𝐚Hn, 𝐚H1××Hn. The i-th entry of 𝐚 is denoted by 𝐚[i]. For I={i1,,ik}[n], we write prI𝐚 for the tuple (𝐚[i1],,𝐚[ik]), and for a relation Hn or H1××Hn, we define prI={prI𝐚𝐚}. The arity of , denoted by ar(), is defined to be n, the length of the tuples in . For 𝐚H1××Hs, s[n], let 𝖤𝗑𝗍(𝐚)={𝐛Hs+1××Hn|(𝐚,𝐛)}, and by #𝖾𝗑𝗍(𝐚) we denote the cardinality of 𝖤𝗑𝗍(𝐚). (Note that we will often use the notation 𝖤𝗑𝗍 in a more general sense, when 𝐚prI for a set I[n] that is not necessarily of the form I=[s].) For a prime p we denote the cardinality of 𝖤𝗑𝗍(𝐚) mod p by #𝗉𝖾𝗑𝗍(𝐚). Moreover, 𝗉𝗋Ip denotes the set {prI𝐚𝐚 and #𝗉𝖾𝗑𝗍(prI𝐚)0}. Often, we treat relations H1××Hn as predicates :H1××Hn{0,1}.

2.1 Relational structures

We begin by introducing multi-sorted sets. Let H={Hi}i[k] be a collection of sets. We assume that the sets H1,,Hk are disjoint. 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 [k] is a collection of relational symbols. A symbol σ is assigned a positive integer , the arity of the symbol denoted ar(), 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 contains finitely many finite domains, and σ is 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 types are called similar.

Let =({Hi}i[k];1,,) be a relational structure. We use 𝖲𝗉() to denote its spectrum, that is, an infinite sequence (n1,n2,) where nj is the number of domains of cardinality j. If the structure is finite, 𝖲𝗉() is essentially a finite sequence, and we will truncate it by removing the trailing zeroes. Let denote the colexicographic order on the set of such sequences: (n1,,nk)(n1,,n), nk,n0 if and only if either the sequences are equal, or k<, or for some i[k], ni<ni and nj=nj for j{i+1,,k}.

Let 𝒢, be similar multi-sorted structures with signature σ. A homomorphism φ from 𝒢 to is a mapping φ:GH such that for any σ with type (i1,,i), if 𝒢(a1,,a) is true for (a1,,a)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 𝗁𝗈𝗆(𝒢,). 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 𝖠𝗎𝗍(). Let π be an automorphism of . By 𝖥𝗂𝗑(π) we denote the collection {𝖥𝗂𝗑(πi)}i[k] of sets of fixed points of the πi’s. For 𝒬Hi1××Hi, we use π(𝒬) to denote the set {π(𝐚)𝐚𝒬}, where π(𝐚)=(πi1(𝐚[1]),,πi(𝐚[])). For a prime number p we say that π has order p or is a p-automorphism if π has order p in 𝖠𝗎𝗍(). In other words, each of the πi’s is either the identity mapping or has order p, and at least one of the πi’s is not the identity mapping. The structure is said to be p-rigid if it has no p-automorphisms.

Proposition 4 ([41]).

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 for any structure 𝒢 similar to it holds that 𝗁𝗈𝗆(𝒢,)=𝗁𝗈𝗆(𝒢,p).

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 . 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.

2.2 The CSP and Modular Counting

There are two standard formulations of the Constraint Satisfaction Problem (CSP). Let=({Hi}i[k];1,,) be a multi-sorted relational structure. The problem CSP() asks, given a relational structure 𝒢=({Gi}i[k];1𝒢,,𝒢) similar to whether there exists a homomorphism φ from 𝒢 to .

The other standard definition does not involve relational structures. Let H={H}i[k] be a multi-sorted domain and Γ a set of multi-sorted relations over H, called a constraint language. An instance 𝒫=(V,τ,𝒞) of CSP(Γ) consists of:

  • a finite set of variables V,

  • a type function τ:V[k] assigning each variable a sort,

  • a finite set of constraints 𝒞, where each constraint is a pair 𝐬, with Γ of arity m and 𝐬=(v1,,vm) a tuple of variables whose sorts match the type of .

A solution is a mapping φ:Vi[k]Hi such that for all vV, φ(v)Hτ(v), and for every constraint 𝐬,, the tuple (φ(v1),,φ(vm)) belongs to .

For a structure =({Hi}i[k];1,,), let Γ={1,,}. It is well known, see e.g. [27] and [3], that the problems CSP() and CSP(Γ) can be easily translated into each other. The same holds for the counting versions #CSP() and #CSP(Γ), as well as the modular counting versions #pCSP() and #pCSP(Γ). The conversion procedure is as follows. Given an instance 𝒢 of CSP() with signature σ, construct an instance 𝒫=(V,τ,𝒞) of CSP(Γ) by setting V=i[k]Gi, with the type function τ induced by the sorts of 𝒢, and for every relation σ and tuple 𝐬𝒢, include the constraint 𝐬, in 𝒞. Conversely, for a finite constraint language Γ={1,,} over H we can construct a structure Γ=(H,1,,) with an appropriately selected signature. Then any instance of CSP(Γ) can be transformed into an instance of CSP(Γ) by reversing this construction. This correspondence naturally extends to the counting and modular counting versions.

2.3 Expansions of Relational Structures and the CSP

A (multi-sorted) relational structure =(H;1,,), H={Hi}i[k], is an expansion of a relational structure =(H;1,,), if and i=i for i[]. It will be convenient to denote by +{+1,,} or just + if =+1. Several types of expansions are often used in the context of the CSP.

Let =({i}i[k];1,,) 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 CHi,a={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 CHi,a, aHi,i[k].

Proposition 5 ([41]).

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

  1. (1)

    #pCSP(=) is polynomial time reducible to #pCSP();

  2. (2)

    Let be p-rigid. Then #pCSP(𝖼) is polynomial time reducible to #pCSP().

Observe that if a relational structure contains all the constant relations, in particular, any structure of the form 𝖼, it is obviously rigid, as every automorphism should respect every CHi,a and map a to a, and therefore also p-rigid for any p.

Using Proposition 4 we may assume that all the structures we are dealing with are p-rigid. Then, by Proposition 5(2) we may assume they contain all the constants, that is, =𝖼. We will use this assumption from now on.

Primitive-positive definitions play a central role in the CSP research. It has been proved in multiple circumstances that expanding a relational structure with pp-definable relations does not change the complexity of the corresponding CSP. This has been proved for the decision CSP in [37, 15], the exact counting CSP [12], and in certain cases (where relational structures are expansions of graphs) [16] of modular counting CSP. The reader is referred to [3] for details about primitive positive definitions and their use in the study of the CSP.

Let be a multi-sorted relational structure with the base set H. A 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 . Every variable in Φ is 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).

The set of all pp-definable relations in the (multi-sorted) relational structure is denoted by .

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 modulo p by #𝗉𝖾𝗑𝗍Φ(𝐚).

As was shown in [41], pp-definitions are not always compatible with modular counting in the sense that will be made precise later. The concept of pp-definitions adapted to modular counting is that of modular pp-definitions, or p-mpp-definitions, where p is the modulus for counting. For a prime number p the p-modular quantifier p is interpreted as follows

(x1,,xk)= py1,,ysΦ(x1,,xk,y1,,ys) is true
#𝖾𝗑𝗍Φ(x1,,xk)0(modp). (1)

A primitive positive formula that uses p-modular quantifiers instead of regular ones is called a p-modular primitive positive (or p-mpp for short). The relation it defines is said to be p-mpp-definable, and the definition itself is called a p-mpp-definition. The set of all p-mpp-definable relations in is denoted by p. Note that modular quantifiers are not as robust as regular ones. In particular, px,y and pxpy may result in a different predicate. The same is of course true for more complicated applications of modular quantifiers, so, one needs to be extra careful with p-mpp-definitions.

If for the p-mpp-definition (1) #𝗉𝖾𝗑𝗍Φ(𝐚)=1 for all 𝐚, the p-mpp definition is said to be strict. By Proposition 5.6 from [16] if has a p-mpp-definition, it has a strict p-mpp definition.

Proposition 6 ([41]).

Let be a be a σ-structure (single- or multi-sorted), and p a prime. Let be a relation that is p-mpp-definable in . Then #pCSP(+) is polynomial time reducible to #pCSP(). In particular, if is conjunctive definable in (that is, s=0 in (1) and the specific value of p is irrelevant), #pCSP(+) is polynomial time reducible to #pCSP().

Let =({Hi}i[k];1,,m) be a multi-sorted relational structure. A subset AHi is called a subalgebra (of sort i) if it is pp-definable in as a unary relation. If A is p-mpp-definable in , it is said to be p-subalgebra. In other words, A is a p-subalgebra if there exists a relation 𝒬(x) p-mpp-definable in , such that aA if and only if 𝒬(a).

2.4 Polymorphisms and Automorphisms of Products

We will also use polymorphisms of relational structures and constraint languages. Let =(H:1,,), H={Hi}i[k] be a multi-sorted relational structure. An r-ary polymorphism f of is a homomorphism f:r. In other words, a collection of mappings f={fi}i[k], fi:HirHi, such that for every j, j[], with type (i1,,is), for any 𝐚1,,𝐚rj

(fi1(𝐚1[1],𝐚2[1],,𝐚r[1]),,fis(𝐚1[s],𝐚2[s],,𝐚r[s]))j.

If this condition for j holds, f is also said to be a polymorphism of j. For a constraint language Γ over H the definition of a polymorphism is essentially the same: f is a polymorphism of Γ if it is a polymorphism of every relation from Γ.

Let H={Hi}i[k] be a multi-sorted set. A collection of mappings {eis,r}i[k], s[r], is said to be the s’th r-ary projection if eis,r(a1,,ar)=as for all a1,,arHi and i[k]. Projections are polymorphisms of any relation, structure, or constraint language.

A particular type of polymorphisms plays an outsized role in counting CSP research. A ternary polymorphism m of a multi-sorted relational structure =(H;1,,), H={Hi}i[k], (a constraint language Γ over H) is said to be Mal’tsev if for every i[k] the mapping mi satisfies the equations mi(x,y,y)=mi(y,y,x)=x. If has a Mal’tsev polymorphism, the set of solutions of any instance 𝒢 of CSP() admits a compact representation by a set of solutions whose number is linear in the size of G, see, [11, 23]. Under certain conditions this allows to solve #CSP() in polynomial time.

One other concept that we will refer to in this paper is the rectangularity. A binary relation H1×H2 is called rectangular if (a,c),(a,d),(b,c) implies (b,d) for any a,bH1,c,dH2. A relation Hi1××Hin for n2 is rectangular if for every I[n], the relation R is rectangular when viewed as a binary relation, a subset of prI×pr[n]I. A relational structure is strongly rectangular if every relation of arity at least 2 is rectangular. The following lemma provides a connection between strong rectangularity and Mal’tsev polymorphisms and was first observed in [34] although in a different language.

Lemma 7 ([34], see also [23]).

A relational structure is strongly rectangular if and only if it has a Mal’tsev polymorphism.

We introduce a modular version of this concept, strongly p-rectangular structures. A relational structure is said to be strongly p-rectangular, if every p is rectangular. It is shown in [41] that a relational structure can be strongly rectangular, but not strongly p-rectangular.

Also, it was shown in [41] that if a relational structure is strongly 2-rectangular and admits a Mal’tsev polymorphism, then the corresponding modular counting CSP problem modulo 2 is tractable. This result highlights the algorithmic significance of Mal’tsev polymorphisms: their presence enables efficient algorithms, while their absence plays a central role in establishing hardness.

Theorem 8 ([41, 42]).

Let be a 2-rigid, strongly 2-rectangular multi-sorted relational structure, and 2 has a Mal’tsev polymorphism. Then #2CSP() can be solved in time O(n5).

Another part polymorphisms will be playing in this paper is their connection to automorphisms of powers of structures. Let be a multi-sorted structure with the base set H={Hi}i[k] and r its direct power. A mapping f:rr of r to itself is a collection of mappings {fi}i[k]:HirHir each of which can also be represented as fi=(fi1,,fir), where fij:HirHi. Rearranging these mapping we obtain collections fj={fij}i[k], j[r], where each fj is a mapping of Hr to H. The following lemma is straightforward from the definitions.

Lemma 9.

In the notation above f is a homomorphism of r to itself if and only if fj is a polymorphism of for every j[r].

Clearly, f is an automorphism of r if and only if the fj are such that f is bijective.

3 Automorphic Polynomials

In this section we introduce a new automorphism-like construction that allows one to reduce #pCSP() to a CSP over a smaller structure that we will extensively use in the future. A binary polymorphism f of a (multi-sorted) relational structure =({Hi}i[k];1,,) is said to be an automorphic polynomial if for any domain Hi of and any aHi, fi(a,x) viewed as a mapping from Hi to Hi is a permutation of Hi. If, for a prime p, for any domain Hi and any aHi, fi(a,x) is the identity mapping or a permutation of order p, and fi(a,x) is a permutation of order p for at least one domain Hi and at least one aHi, f is said to be a p-automorphic polynomial.

Let =({Hi}i[k],1,,) and f its p-automorphic polynomial. Let also i[k] and aHi be such that fi(a,x) is a permutation of Hi of order p. Then a structure is constructed as follows:

  • The domains are the same as those of , except Hi. The domain Hi is replaced with two domains: Hi=Hi{a} and Hi′′=HiB, where B is the union of all nontrivial orbits of fi(a,x).

  • Every relation j containing i in its type is replaced with j and j′′ that are obtained from j by replacing Hi with Hi (respectively Hi′′) restricting to tuples that do not contain a (respectively, do not contain elements from B).

We repeat this construction for every Hi and aHi such that fi(a,x) is a permutation of Hi of order p. The resulting structure is denoted f.

Proposition 10.

Suppose that a relational structure has a p-automorphic polynomial f and f is as above. Then 𝖲𝗉(f)𝖲𝗉() and #pCSP() is polynomial time reducible to #pCSP(f).

Proof (sketch).

Let =({Hi}i[k],1,,). The first claim of the proposition is obvious, so we focus on the second claim. We will construct an auxiliary problem from an instance 𝒫=(V,τ,𝒞) of #pCSP(). Let C=𝐬C,jC be a constraint in 𝒫 and 𝖲𝗒𝗆(jC) the symmetric group on jC as a set. We introduce an instance s(𝒫) with domains 𝖲𝗒𝗆(jC), constraints that are derivative from the constraints of 𝒫 and will allow us to conclude that either the p-automorphic polynomial f can be used to reduce 𝒫 to a problem with smaller domains that are parts of f, or that 𝒫 does not have solutions that are equal to certain elements of the domains and therefore, again, can be reduced to a problem with smaller domains.

More precisely, s(𝒫)=(V,τ,𝒞) is constructed as follows.

  • V={vCC=𝐬C,jC𝒞} and the domain of vCV is 𝖲𝗒𝗆(jC), that is, τ(vC)=jC;

  • for any constraints C1,C2𝒞, Cq=𝐬Cq,jCq such that 𝐬C1[s]=𝐬C2[t] for some s,t, introduce the constraint (vC1,vC2),𝒮stuv𝒞, where u=jC1,v=jC2,

    𝒮stuv={(φ1,φ2) φq𝖲𝗒𝗆(jCq),q{1,2}, and φ1(𝐚1)[s]=φ2(𝐚2)[t]
    for any 𝐚1jC1,𝐚2jC2 such that 𝐚1[s]=𝐚2[t]}.

For an instance 𝒫=(V,τ,𝒞) of CSP(), a collection {φCC𝒞} of permutations φC:jCjC is said to be a consistent collection of permutations if for any C1,C2, Cq=𝐬Cq,jCq, q{1,2} and any 𝐚1jC1,𝐚2jC2 such that pr𝐬C1𝐬C2𝐚1=pr𝐬C1𝐬C2𝐚2 it holds that pr𝐬C1𝐬C2φC1(𝐚1)=pr𝐬C1𝐬C2φC2(𝐚2). It can be shown that each solution of s(𝒫) provides a collection φ={φC}C𝒞 of consistent permutations for 𝒫.

Finding solutions to s(𝒫) can also be done in polynomial time, because as every 𝖲𝗒𝗆(j) is a group, we can introduce a Mal’tsev operation m={mj}i[] on the collection of 𝖲𝗒𝗆(j), j[], as follows: mj(x,y,z)=xy1z, where multiplication and inverse are as in the group 𝖲𝗒𝗆(j). Then for any u,v[] and any s[ar(u)],t[ar(v)] such that the types of the corresponding coordinates match, the mapping m is a polymorphism of 𝒮stuv. By the results of [11] for any instance 𝒫 of #pCSP() the problem s(𝒫) can be solved in polynomial time. Moreover, for any C0=𝐬0,j0𝒞 and φ0𝖲𝗒𝗆(j0), we can verify in polynomial time whether or not there is a consistent collection of mappings φ={φC}C𝒞 such that φC0=φ0. With that in mind the following transformation of 𝒫 can be performed in polynomial time.

Now, let be constructed as explained before the proposition. Let C0=𝐬0,j0𝒞 be such that for some v𝐬0 the type of v is Hi, say, 𝐬0[s]=v, and there is 𝐚j0 with 𝐚[s]=a. If there are no such C0 and 𝐚, then Hi can be either completely eliminated or it can be reduced by removing a from it. Thus, 𝒫 itself can be considered as an instance of #pCSP(). Otherwise let φ0𝖲𝗒𝗆(j0) be given by φ0(𝐱)=f(𝐚,𝐱). It is possible to verify whether or not there exists a solution φ of s(𝒫) such that φC0=φ0. If such a solution exists, Hi can be reduced by eliminating all the nontrivial orbits of fi(a,x), since for any solution ψ of 𝒫 with ψ(v) belonging to such an orbit, the mappings φ(ψ),φ2(ψ),,φp1(ψ) are also different solutions of 𝒫 and together they contribute 0 modulo p into the number of solutions of 𝒫. Suppose such a solution does not exist. As is easily seen, if there is a solution ψ of 𝒫 such that ψ(𝐬0)=𝐚, then the mappings φC𝖲𝗒𝗆(jC), C=𝐬,jC𝒞, given by φC(𝐱)=f(ψ(𝐬),𝐱), form a solution of s(𝒫) with φC0=φ0. Therefore, there is no such solution ψ and the tuple 𝐚 can be removed from j0. Repeating this procedure for every 𝐚j0 with 𝐚[s]=a we can either reduce the domain of v by eliminating nontrivial orbits of fi(a,x), or by eliminating a. In both cases after applying this transformation to all constraints of 𝒫 we obtain an instance of #pCSP().

Finally, repeating this construction for every Hi and aHi such that fi(a,x) is a permutation of Hi of order p we arrive to an instance the required problem #pCSP(f).

While Proposition 10 may help to prove that #pCSP() is solvable in polynomial time, in order to prove hardness we also need the reverse reduction, which exists only under additional assumptions. The case we need is the following.

Corollary 11.

Let be a 3-element single-sorted structure such that there is a 2-automorphic polynomial f of and for aH the mapping f(a,x) is a permutation of H of order 2. Then, if {a} and H{a} are 2-subalgebras of , the structure f from Proposition 10 can be chosen such that #pCSP() and #pCSP(f) are polynomial time interreducible.

Proof.

In order to prove Corollary 11 we only need to show that the problem #pCSP(f) is polynomial time reducible to #pCSP(). Let j be a relation of of arity r. Then

j=j({a}××{a})andj′′=j((H{a})××(H{a})).

Since {a} and H{a} are 2-subalgebras of , the relations j,j′′ are p-mpp-definable in . The result follows from Proposition 6.

Example 12.

Let =(H;,CH,a,aH), where H={0,,p1,p,p+1} for some prime p, is the binary relation H2{(0,p),,(p1,p)}, and CH,a is the constant relation {(a)}. Since any automorphism of must preserve CH,a for each aH, the structure is rigid. However, it has a p-automorphic polynomial f given by

f(p,i)=f(p+1,i)=i+1(modp), for i{0,,p1}, and
f(x,y)=y otherwise.

If we now apply Proposition 10, the problem #pCSP() can be reduced to #pCSP(f), where f is a multisorted structure with domains {p,p+1}, {0,,p1}, and the 1-element domains. The relations of f are all trivial, and so #pCSP(f) is polynomial time solvable.

4 Tools for Reduction

This section introduces the main technical tools used in our reductions. First, we define indicator problems and explain how the existence of a Mal’tsev polymorphism relates to the presence of a specific predicate in the set of all (multi-sorted) pp-definable relations. Then, we apply all the constructions and tools that we developed in this section to two special classes of relational structures: p-conservative and three-element structures.

4.1 Indicator Problem and Indicator Obstruction

In this section, we show that in many cases, if a relational structure is not strongly p-rectangular, then there is a rectangularity obstruction of a very specific kind. Recall that ([38]) for a (multi-sorted) relational structure =({Hi}i[k];1,,), the ternary indicator problem 3() is an instance of CSP() that characterizes the ternary polymorphisms of .

  • The set of variables V is the set H(3)=H13Hk3 of all triples over the domains of , i.e., for each triple 𝐚=(𝐚[1],𝐚[2],𝐚[3])Hi3, the set V contains a variable x𝐚 with domain Hi.

  • For every s-ary relation j of type (i1,,is) from and for any tuples 𝐚1,,𝐚sH(3), where each 𝐚q=(𝐚q[1],𝐚q[2],𝐚q[3])Hiq3, we include the constraint (x𝐚1,,x𝐚s),j in the instance 3() if for every t[3], the tuple (𝐚1[t],,𝐚s[t]) belongs to j. That is, the projection of the sequence (𝐚1,,𝐚s) onto each coordinate t[3] is a tuple in j.

As is easily seen, every solution of 3() defines a ternary multi-sorted operation {fi}i[k] with fi:Hi3Hi.

Example 13.
  1. (a)

    Let 1 be a relational structure with only one domain H={0,1} and one (binary) relation ={(0,1),(1,0)},. Then 3(1) contains 8 variables x000,x001,x010,x011,x100,x101,x110,x111, that is, all possible triples of elements of , and the constraints are imposed on every pair (xabc,xdef) such that (a,d),(b,e),(c,f). In this case this means all pairs of “dual” variables of the form (xabc,x¬a¬b¬c). Thus, the constraints are

    (x000,x111),,(x001,x110),,(x010,x101),,(x011,x100),.
  2. (b)

    For a structure 2 let the domain H be the same set {0,1}, but the only binary relation is given by 𝒬={(0,0),(0,1),(1,0)}. The set of variables of 3(2) is the same as before, but the constraints are very different. As is easily seen, the constraints in this case are

    (x000,x000),𝒬(x000,x001),𝒬(x000,x010),𝒬(x000,x011),𝒬(x000,x100),𝒬(x000,x101),𝒬(x000,x110),𝒬(x000,x111),𝒬(x001,x000),𝒬(x001,x010),𝒬(x001,x100),𝒬(x001,x110),𝒬(x010,x000),𝒬(x010,x001),𝒬(x010,x100),𝒬(x010,x101),𝒬(x100,x000),𝒬(x100,x001),𝒬(x100,x010),𝒬(x100,x011),𝒬(x011,x000),𝒬(x011,x100),𝒬(x101,x000),𝒬(x101,x010),𝒬(x110,x000),𝒬(x110,x001),𝒬(x111,x000),𝒬

Lemma 14 ([38]).

For a (multi-sorted) relational structure , a ternary (multi-sorted) operation on the domains of is a solution of 3() if and only if it is a ternary polymorphism of .

We will call the set of all solutions of 3() the indicator predicate Υ3(). It is not difficult to see that Υ3() is conjunctive-definable in . Indeed, let 𝒞 be the set of all constraints as defined above in 3(). Then we define the indicator predicate as the conjunction of all those constraints

Υ3()(𝐱)=𝐬,j𝒞j(𝐬),

where 𝐱 is the tuple consisting of all variables x(a,b,c) indexed by triples (a,b,c)H(3).

We now define certain coordinate sets used to analyze Υ3(). Let

I={(a,b,b)a,bHi,i[k]},J={(b,b,a)a,bHi,i[k],ab}.

Note that the diagonal triples (a,a,a) are included in I. Enumerate these sets asI={(a1,b1,b1),,(aN,bN,bN)}, J={(c1,c1,d1),,(cM,cM,dM)}, and define tuples

𝐚=(a1,,aN),𝐛=(b1,,bN),𝐜=(c1,,cM),𝐝=(d1,,dM).

Then 𝐚,𝐛prIΥ3(), and 𝐜,𝐝prJΥ3(). Also,

(𝐚,𝐜),(𝐛,𝐜),(𝐛,𝐝)prIJΥ3().

Moreover, admits a Mal’tsev polymorphism if and only if (𝐚,𝐝)prIJΥ3().

Indeed, this condition tests whether the tuple (𝐚,𝐝), which represents applying the Mal’tsev term coordinate-wise to the elements of each triple from IJ, belongs to the projection of the relation Υ3(). That is, since (𝐚,𝐜),(𝐛,𝐜),(𝐛,𝐝)prIJΥ3(), the closure under a Mal’tsev polymorphism would imply that the corresponding output tuple, (𝐚,𝐝), must also be in the relation. So, its membership characterizes whether such a polymorphism exists.

Example 15.

Let us reconsider the structures 1,2 from Example 13 and their indicator problems. The following tables contain all the solutions of 3(1) and 3(2), that is, the tuples of Υ3(1),Υ3(2). The rows are labeled with the variables of 3(1),3(2).

Υ3(1):Υ3(2):
x0000000000011111111x0010011001100110011x0100101010101010101x0110110100100011110x1001001011011100001x1011010101010101010x1101100110011001100x1111111111100000000x000000000000x001001001000x010010000100x011011000x100100000010x101101000x110110000x11111101

Every column in these tables represents a ternary polymorphism of 1,2, respectively. Note that the first three polymorphisms in both cases are the projections, their values equal the first, second, and third component of the triple representing the label of variables of the indicator problem. Projections are polymorphisms of every structure, and therefore are always solutions of the indicator problem.

The relation Υ3(1) contains every polymorphism f(x,y,z) satisfying the condition f(¬x,¬y,¬z)=¬f(x,y,z), also known as the condition of self-duality. The relation Υ3(2) cannot be described by such a simple condition. The stars in the table for Υ3(2) mean that no matter what values are in these positions, the tuple belongs to Υ3(2).

The sets I1=I2={000,011,100,111} are equal in this case and so are J1=J2={001,110}. The special tuples 𝐚1,𝐛1,𝐜1,𝐝1 and 𝐚2,𝐛2,𝐜2,𝐝2 are also equal, as they are restrictions of the tuples corresponding to the same projections. Specifically,

𝐚1=𝐚2=(0,0,1,1),𝐛1=𝐛2=(0,1,0,1),𝐜1=𝐜2=(0,1),𝐝1=𝐝2=(1,0).

As was observed, the presence of a Mal’tsev polymorphism is equivalent to the conditions

(𝐚1,𝐝1)prI1J1Υ3(1),(𝐚2,𝐝2)prI2J2Υ3(2),

that is (0,0,1,1,1,0)prI1J1Υ3(1),prI2J2Υ3(2). It is not difficult to see that such a tuple exists in prI1J1Υ3(1), but not in prI2J2Υ3(2).  

While Υ3() characterizes the ternary polymorphisms of , we now define a construction that characterizes the ternary polymorphisms of p.

Note that every polymorphism of p is also a polymorphism of . For any ternary polymorphism f of that is not a polymorphism of p, there exists a relation 𝒬fp such that f fails to preserve 𝒬f. Let p be the expansion of by all such relations p=+{𝒬ff𝖯𝗈𝗅3()𝖯𝗈𝗅3(p)}. The following lemma is straightforward.

Lemma 16.

Let be a (multi-sorted) relational structure. Then

  1. 1.

    Υ3() is conjunctive-definable in ,

  2. 2.

    Υ3(p) is p-mpp-definable in .

If p does not have a Mal’tsev polymorphism, then p also does not have a Mal’tsev polymorphism. Therefore, (𝐚,𝐜),(𝐛,𝐜),(𝐛,𝐝)prIJΥ3(p) and (𝐚,𝐝)prIJΥ3(p).

A relation prIJΥ3(p) such that (𝐚,𝐜),(𝐛,𝐜),(𝐛,𝐝) and (𝐚,𝐝) will be called a p-indicator rectangularity obstruction. Clearly, if p has no Mal’tsev polymorphism, prIJΥ3(p) itself is a p-indicator rectangularity obstruction. However, it may not be p-mpp-definable in . A relational structure is said to admit a p-indicator rectangularity obstruction if there exists a p-indicator rectangularity obstruction that is p-mpp-definable in .

Recall that for a multisorted structure with domains H1,,Hk we use H(3) to denote H13Hk3. An important ingredient in our construction is the study of automorphisms of (3) that fix certain structured tuples. Specifically, those of the form (a,b,b) and (b,b,a). We refer to such automorphisms as M-automorphisms, with “M” standing for Mal’tsev.

The motivation for working with (3) comes from the need to apply our reduction tools in a higher-dimensional setting. While every automorphism of (3) induces a polymorphism of via its coordinate projections, the converse does not hold: not every collection of polymorphisms arises as projections of a single automorphism of (3). The notion of M-automorphisms captures precisely those symmetries of (3) that preserve the key tuples required for our connection to Mal’tsev polymorphisms. This connection will become essential later.

Let 𝐱=(xi)i(3) be the tuple of variables indexed by the elements of H(3). For a subset K(3), we use the notation 𝐱K to denote the subtuple (xi)iK, that is, the variables whose indices belong to K. The next lemma identifies conditions sufficient for to admit a p-indicator rectangularity obstruction. Define E=H(3)(IJ) and m=ar(Υ3()).

Lemma 17.

Let (𝐱|H(3)K)=𝐱|KΥ3(p)(𝐱)Φ(𝐱|K), where KE, and Φ is a conjunction of unary predicates on variables from K such that (𝐚,𝐜),(𝐛,𝐜),(𝐛,𝐝)prIJ. Let also yEK and let

B1=pry𝖤𝗑𝗍(𝐚,𝐜),B2=pry𝖤𝗑𝗍(𝐛,𝐜),B3=pry𝖤𝗑𝗍(𝐜,𝐝).

If B1×B2×B3 contains a triple that is a fixed point of every M-automorphism of (p)3 then there is a p-mpp-definable relation 𝒬prH(3)(K{y}) in +{}p such that (𝐚,𝐜),(𝐛,𝐜),(𝐛,𝐝)prIJ𝒬, and

|pry(𝖤𝗑𝗍𝒬((𝐚,𝐜)))|,|pry(𝖤𝗑𝗍𝒬((𝐛,𝐜)))|,|pry(𝖤𝗑𝗍𝒬((𝐛,𝐝)))|0(modp).

Starting from Υ3(p) by repeated application of Lemma 17 we can obtain a relation prIJΥ3(p), which is a p-indicator rectangularity obstruction.

4.2 Conservative and 3-Element Structures

In this section we use the results of Sections 3 and 4.1 to essentially show that in the case of a p-conservative and 3-element structure (single-sorted in the latter case) either there is a Mal’tsev polymorphism of p or admits a p-indicator rectangularity obstruction. The latter will later be used to prove the hardness of the corresponding modular counting problem.

Recall that a multi-sorted relational structure =({Hi}i[k];1,,m) is said to be p-conservative if for every i[k] and every subset AHi, the set A is p-mpp-definable in (as a unary relation).

Theorem 18.

Let be a p-conservative structure. Then either p has a Mal’tsev polymorphism, or admits a p-indicator rectangularity obstruction and therefore is not strongly p-rectangular.

Proof (sketch).

We assume that p has no Mal’tsev polymorphism. By Lemma 16, it suffices to show that Υ3(p) p-mpp-defines a p-indicator rectangularity obstruction.

Let z1,,zL be an ordering of the variables from the set E. We prove by induction that for any q[L], there exists a relation 𝒬qprIJEqΥ3(p), where Eq={zq,,zL}, such that (𝐚,𝐜),(𝐛,𝐜),(𝐛,𝐝)prIJ𝒬q. Note that 𝒬L+1 is the desired p-indicator rectangularity obstruction. For the base case, let 𝒬1=Υ3(p), which satisfies the required condition, since E1={z1,,zL}.

Now suppose the statement holds for some q and that 𝒬q is the corresponding relation. Consider the variable zqEq, and let its domain be Hi. Define the sets B1,B2,B3Hi as the sets of values appearing at coordinate zq in the extensions of (𝐚,𝐜), (𝐛,𝐜), and (𝐛,𝐝), respectively, within 𝒬q, i.e.,

B1=przq𝖤𝗑𝗍𝒬q(𝐚,𝐜),B2=przq𝖤𝗑𝗍𝒬q(𝐛,𝐜),B3=przq𝖤𝗑𝗍𝒬q(𝐛,𝐝).

Let D be a minimal set of representatives for B1, B2, and B3; clearly, |D|3. Let 𝒬=𝒬q(𝐱IJEq)D(zq). We then consider several cases depending on the cardinality of D and use Lemma 17 to show that zq can be quantified away from 𝒬 via applying a p-modular quantifier to it.

Next, we assume to be a 3-element (single-sorted) structure (H,1,,), where H={0,1,2}. The main result of this section is the following theorem.

Theorem 19.

Let be a 3-element structure. Then one of the following three options holds

  1. (1)

    p has a Mal’tsev polymorphism and therefore is strongly p-rectangular;

  2. (2)

    admits a p-indicator rectangularity obstruction;

  3. (3)

    p=2 and has a p-automorphic polynomial f, there is aH such that f(a,x) is a permutation of order 2, and H{a} is a p-subalgebra of .

Proof (idea).

In this case we follow the same approach as in the proof of Theorem 18, except in some cases it is not possible to show that zq can be quantified away from 𝒬. The reason for that is M-automorphisms of (p)3 that act nontrivially on B1×B2×B3. So, we prove that whenever such an M-automorphism is present, has a p-automorphic polynomial. This is done by a large case analysis using the Universal Algebra Calculator [29].

5 Complexity Classifications

We start this section with an (incomplete) complexity classification of #pCSP(), where is a p-conservative structure. The missing case is p>2 and p has a Mal’tsev polymorphism. The gap is due the lack of understanding of the complexity of partition functions over nontrivial finite fields. It is a highly nontrivial problem that requires a separate study, see [39] for some partial results.

We start with proving hardness for structures whose domains are 2-element. The proposition below generalizes the results of Faben [25] to multisorted CSPs.

Proposition 20.

Let be a multi-sorted relational structure, all of whose domains contain at most 2 elements. The problem #pCSP() is solvable in polynomial time if and only if p has a Mal’tsev polymorphism. Otherwise it is #pP-hard.

Proof (idea).

If p does not have a Mal’tsev polymorphism, by Theorem 18 a p-indicator rectangularity obstruction is p-mpp-definable in . We start with the obstruction and then recursively quantify away coordinates of by applying p-modular quantifiers (which requires significant care) until we obtain a binary non-rectangular relation, for which hardness is known by [25].

Now, suppose that p has a Mal’tsev polymorphism. It is known that if a single-sorted 2-element relational structure has a Mal’tsev polymorphism then it also has the operation xyz as a polymorphism [44], where is addition modulo 2. This means that for every domain Hi of there is a polymorphism mi of p that acts like xyz if Hi is equipped with addition modulo 2. The main step of the proof is to show that all the mi can be chosen the same. Therefore CSP() can be represented by a system of linear equations modulo 2, for which the exact number of solutions can be found.

Theorem 21.

Let be a conservative structure and p a prime. If p does not have a Mal’tsev polymorphism then #pCSP() is #pP-hard. If 2 has a Mal’tsev polymorphism then #2CSP() is solvable in polynomial time.

Proof.

The second statement of the theorem follows from Theorem 8. For the first statement, by Theorem 18 a p-indicator rectangularity obstruction is p-mpp-definable in . Recall that (𝐚,𝐜),(𝐛,𝐜),(𝐛,𝐝), while (𝐚,𝐝). As is conservative, for every vI (vJ), Hiv={𝐚[v],𝐛[v]} (Hiv={𝐜[v],𝐝[v]}) is a p-subalgebra of . Set

(𝐱|IJ)=(𝐱|IJ)vIJHiv(𝐱v).

The relation still contains (𝐚,𝐜),(𝐛,𝐜),(𝐛,𝐝) and does not contain (𝐚,𝐝). By Proposition 20 #pCSP() is #pP-hard.

Next, we consider the case when is a 3-element structure.

Theorem 22.

Let be a 3-element structure and p a prime. If one of the following conditions holds:

  1. (a)

    has a p-automorphic polynomial f and fp has a Mal’tsev polymorphism, or

  2. (b)

    does not have a p-automorphic polynomial, p has a Mal’tsev polymorphism, and p=2,

then #pCSP() is solvable in polynomial time. Also, if

  1. (1)

    has a p-automorphic polynomial f and fp does not have a Mal’tsev polymorphism, or

  2. (2)

    does not have a p-automorphic polynomial and p does not have a Mal’tsev polymorphism,

then #pCSP() is #pP-complete.

Proof (idea).

If has a p-automorphic polynomial then p=2, and the result follows from Corollary 11 and Proposition 20. If p has a Mal’tsev polymorphism and p=2, the result follows from Theorem 8. Therefore, we assume that p has no Mal’tsev polymorphism and does not have a p-automorphic polynomial. By Theorem 19 a p-indicator rectangularity obstruction is p-mpp-definable in . We prove that it is possible to p-mpp-define a binary non-rectangular relation showing that #pCSP() is #pP-complete. Unlike the case of p-conservative structures, it is not possible to restrict with arbitrary subsets of H, because they may not be p-subalgebras. We therefore use an approach similar to that in the proof of Theorem 21, except every possible combination of p-subalgebras of is considered separately.

References

  • [1] Libor Barto. The dichotomy for conservative constraint satisfaction problems revisited. In LICS 2011, pages 301–310, 2011. doi:10.1109/LICS.2011.25.
  • [2] Libor Barto and Marcin Kozik. Constraint satisfaction problems solvable by local consistency methods. J. ACM, 61(1):3:1–3:19, 2014. doi:10.1145/2556646.
  • [3] 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.
  • [4] 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.
  • [5] Christoph Berkholz and Martin Grohe. Limitations of algebraic approaches to graph isomorphism testing. In ICALP 2015, volume 9134 of LNCS, pages 155–166. Springer, 2015. doi:10.1007/978-3-662-47672-7_13.
  • [6] Andrei A. Bulatov. A dichotomy theorem for constraint satisfaction problems on a 3-element set. J. ACM, 53(1):66–120, 2006. doi:10.1145/1120582.1120584.
  • [7] Andrei A. Bulatov. Complexity of conservative constraint satisfaction problems. ACM Trans. Comput. Log., 12(4):24:1–24:66, 2011. doi:10.1145/1970398.1970400.
  • [8] Andrei A. Bulatov. The complexity of the counting constraint satisfaction problem. J. ACM, 60(5):34:1–34:41, 2013. doi:10.1145/2528400.
  • [9] Andrei A. Bulatov. Conservative constraint satisfaction re-revisited. J. Comput. Syst. Sci., 82(2):347–356, 2016. doi:10.1016/J.JCSS.2015.07.004.
  • [10] Andrei A. Bulatov. A dichotomy theorem for nonuniform CSPs. In FOCS, pages 319–330, 2017. doi:10.1109/FOCS.2017.37.
  • [11] 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.
  • [12] 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.
  • [13] Andrei A. Bulatov, Martin E. Dyer, Leslie Ann Goldberg, Markus Jalsenius, Mark Jerrum, and David Richerby. The complexity of weighted and unweighted #CSP. J. Comp. Syst. Sci., 78(2):681–688, 2012. doi:10.1016/J.JCSS.2011.12.002.
  • [14] 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.
  • [15] 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.
  • [16] Andrei A. Bulatov and Amirhossein Kazeminia. Complexity classification of counting graph homomorphisms modulo a prime number. In STOC, pages 1024–1037, 2022. doi:10.1145/3519935.3520075.
  • [17] Jin-Yi Cai and Xi Chen. Complexity of counting CSP with complex weights. J. ACM, 64(3), 2017. doi:10.1145/2822891.
  • [18] Jin-yi Cai, Xi Chen, and Pinyan Lu. Graph homomorphisms with complex values: A dichotomy theorem. In ICALP 2010, volume 6198 of LNCS, pages 275–286. Springer, 2010. doi:10.1007/978-3-642-14165-2_24.
  • [19] Jin-Yi Cai, Xi Chen, and Pinyan Lu. Nonnegative weighted #CSP: An effective complexity dichotomy. SIAM J. Comput., 45(6):2177–2198, 2016. doi:10.1137/15M1032314.
  • [20] Jin-Yi Cai, Pinyan Lu, and Mingji Xia. The complexity of complex weighted Boolean #CSP. J. Comput. Syst. Sci., 80(1):217–236, 2014. doi:10.1016/J.JCSS.2013.07.003.
  • [21] Nadia Creignou and Miki Hermann. Complexity of generalized satisfiability counting problems. Inf. Comput., 125(1):1–12, 1996. doi:10.1006/INCO.1996.0016.
  • [22] Martin Dyer and Catherine 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.
  • [23] 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.
  • [24] Martin E. Dyer, Leslie Ann Goldberg, and Mark Jerrum. The complexity of weighted Boolean #CSP. SIAM J. Comput., 38(5):1970–1986, 2009. doi:10.1137/070690201.
  • [25] John Faben. The complexity of counting solutions to generalised satisfiability problems modulo k, 2008. arXiv:0809.1836.
  • [26] John Faben and Mark Jerrum. The complexity of parity graph homomorphism: an initial investigation. arXiv preprint arXiv:1309.4033, 2013. arXiv:1309.4033.
  • [27] 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.
  • [28] Jacob Focke, Leslie Ann Goldberg, Marc Roth, and Stanislav Zivny. Counting homomorphisms to K4-minor-free graphs, modulo 2. CoRR, abs/2006.16632, 2020. arXiv:2006.16632.
  • [29] Ralph Freese and Emil Kiss. Universal algebra calculator. Available at http://uacalc.org/.
  • [30] 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.
  • [31] 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.
  • [32] Leslie Ann Goldberg, Martin Grohe, Mark Jerrum, and Marc Thurley. A complexity dichotomy for partition functions with mixed signs. SIAM J. Comput., 39(7):3336–3402, 2010. doi:10.1137/090757496.
  • [33] 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.
  • [34] J. Hagemann and A. Mitschke. On n-permutable congruences. Algebra Universalis, 3:8–12, 1973.
  • [35] Richard Hammack, Wilfried Imrich, and Sandi Klavzar. Handbook of Product Graphs, Second Edition. CRC Press, Inc., USA, 2nd edition, 2011.
  • [36] Pawel M. Idziak, Petar Markovic, Ralph McKenzie, Matthew Valeriote, and Ross Willard. Tractability and learnability arising from algebras with few subpowers. SIAM J. Comput., 39(7):3023–3037, 2010. doi:10.1137/090775646.
  • [37] 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.
  • [38] P.G. Jeavons, D.A. Cohen, and M. Gyssens. How to determine the expressive power of constraints. Constraints, 4:113–131, 1999. doi:10.1023/A:1009890709297.
  • [39] Amirhossein Kazeminia. Complexity of Modular Counting. PhD thesis, Simon Fraser University, 2025.
  • [40] Amirhossein Kazeminia and Andrei A Bulatov. Counting homomorphisms modulo a prime number. In MFCS, volume 138 of LIPIcs, pages 59:1–59:13, 2019. doi:10.4230/LIPIcs.MFCS.2019.59.
  • [41] Amirhossein Kazeminia and Andrei A. Bulatov. Modular counting CSP: reductions and algorithms. In STACS 2025, volume 327 of LIPIcs, pages 60:1–60:18, 2025. doi:10.4230/LIPIcs.STACS.2025.60.
  • [42] Amirhossein Kazeminia and Andrei A. Bulatov. Modular counting CSP: reductions and algorithms. CoRR, abs/2501.04224, 2025. doi:10.48550/arXiv.2501.04224.
  • [43] 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.
  • [44] Emil L. Post. The two-valued iterative systems of mathematical logic, volume 5 of Annals Mathematical Studies. Princeton University Press, 1941.
  • [45] Leslie Valiant. The complexity of computing the permanent. Theor. Comput. Sci., 8:189–201, 1979. doi:10.1016/0304-3975(79)90044-6.
  • [46] Leslie Valiant. The complexity of enumeration and reliability problems. SIAM J. on Comput., 8(3):410–421, 1979. doi:10.1137/0208032.
  • [47] Dominic J.A. Welsh. The computational complexity of some classical problems from statistical physics. Oxford Univ. Press, 1990.
  • [48] Dmitriy Zhuk. A proof of the CSP dichotomy conjecture. J. ACM, 67(5):30:1–30:78, 2020. doi:10.1145/3402029.