Testing Assignments to Constraint Satisfaction Problems

# Testing Assignments to Constraint Satisfaction Problems

Hubie Chen
Univ. País Vasco and IKERBASQUE
E-20018 San Sebastián, Spain
hubie.chen@ehu.es
Matt Valeriote
McMaster University
matt@math.mcmaster.ca
Supported by a grant from the Natural Sciences and Engineering Research Council of Canada
Yuichi Yoshida
National Institute of Informatics
Chiyoda-ku, Tokyo 101-8430, Japan
and
Preferred Infrastructure, Inc.
Bunkyo-ku, Tokyo 113-0033, Japan
yyoshida@nii.ac.jp
Supported by JSPS Grant-in-Aid for Young Scientists (B) (No. 26730009), MEXT Grant-in-Aid for Scientific Research on Innovative Areas (24106003), and JST, ERATO,Kawarabayashi Large Graph Project.
###### Abstract

For a finite relational structure , let denote the CSP instances whose constraint relations are taken from . The resulting family of problems has been considered heavily in a variety of computational contexts. In this article, we consider this family from the perspective of property testing: given an instance of a CSP and query access to an assignment, one wants to decide whether the assignment satisfies the instance, or is far from so doing. While previous works on this scenario studied concrete templates or restricted classes of structures, this article presents comprehensive classification theorems.

Our first contribution is a dichotomy theorem completely characterizing the structures such that is constant-query testable:

• If has a majority polymorphism and a Maltsev polymorphism, then is constant-query testable with one-sided error.

• Else, testing requires a super-constant number of queries.

Let denote the extension of to instances which may include existentially quantified variables. Our second contribution is to classify all structures in terms of the number of queries needed to test assignments to instances of , with one-sided error. More specifically, we show the following trichotomy:

• If has a majority polymorphism and a Maltsev polymorphism, then is constant-query testable with one-sided error.

• Else, if has a -ary near-unanimity polymorphism for some , and no Maltsev polymorphism then is not constant-query testable (even with two-sided error) but is sublinear-query testable with one-sided error.

• Else, testing with one-sided error requires a linear number of queries.

## 1 Introduction

### 1.1 Background

In property testing, the goal is to design algorithms that distinguish objects satisfying some predetermined property from objects that are far from satisfying . More specifically, for , an algorithm is called an -tester for a property , if given an input , it accepts with probability at least if the input satisfies , and it rejects with probability at least if the input is -far from satisfying . Roughly speaking, we say that is -far from if we must modify at least an -fraction of to make satisfy . When , we simply call it an -tester. A tester is called a one-sided error tester if it always accepts when satisfies . In contrast, a standard tester is sometimes called a two-sided error tester. As one motivation of property testing is to design algorithms that run in time sublinear in the input size, we assume query access to the input, and we measure the efficiency of a tester by its query complexity. We refer to [18, 27, 28] for surveys on property testing.

In constraint satisfaction problems (for short, s), one is given a set of variables and a set of constraints imposed on the variables, and the task is to find an assignment of the variables that satisfies all of the given constraints. By restricting the relations used to specify constraints, it is known that certain restricted versions of the CSP coincide with many fundamental problems such as SAT, graph coloring, and solvability of systems of linear equations. To formally define these restricted versions of the CSP (and hence, these problems), we consider relational structures , where is a finite set and consists of a finite set of finitary relations over . In this context, is sometimes referred to as a constraint language over and as a template. Then, we define to be those instances of the CSP whose constraint relations are taken from . In recent years, computational aspects of have been heavily studied, in the decision setting [21, 10, 3, 5], in counting complexity [11, 15], in computational learning theory [21, 14], and in optimization and approximation [26, 29, 13, 30, 31]. See also the survey by Barto [4] for an overview of this line of research.

In this paper, we consider the problem family from the perspective of property testing, in particular, we consider the task of testing assignments to CSPs. Relative to a relational structure , an input consists of a tuple , where is an instance of with weights on the variables, is an error parameter, and is an assignment to . In the studied model, the tester has full access to and query access to , that is, a variable can be queried to obtain the value of . In this sense, assignment testing lies in the massively parameterized model [25]. We say that is -far from satisfying if one must modify at least an -fraction of (with respect to the weights) to make a satisfying assignment of , and we say that is -close otherwise. It is always assumed that has a satisfying assignment as otherwise we can immediately reject the input (in this context, one does not care about time complexity). The objective of assignment testing of CSPs is to correctly decide whether is a satisfying assignment of or is -far from being so with probability at least . When does not satisfy but is -close to satisfying , we can output anything.

In assignment testing, we say that the query complexity of a tester is constant/sublinear/linear if it is constant/sublinear/linear in the number of variables of an instance. The main problem addressed in this paper is to reveal the relationship between a relational structure and the number of queries needed to test and a related problem class .

### 1.2 Contributions

While previous works on testing assignments to the problems studied concrete templates or restricted classes of structures, this article presents comprehensive classification theorems.

The first contribution of this paper is a dichotomy theorem that completely characterizes the constant-query testable CSPs. Before describing our characterization, we introduce the algebraic notion of a polymorphism which is key to the description and obtention of our results. Let be an -ary relation on a set . A (-ary) operation is said to be a polymorphism of (or is preserved by ) if for any set of -tuples , the tuple also belongs to . An operation is a polymorphism of a relational structure if it is a polymorphism of each of its relation. We define the algebra of , denoted by , to be the pair , where is the set of all polymorphisms of .

###### Definition 1.1.

Let be a nonempty set. A majority operation on is a ternary operation such that for all , . A Maltsev operation on is a ternary operation such that for all , . For , an operation is a -ary near unanimity operation on if for all , ,

 n(b,a,a,…,a)=n(a,b,a,…,a)=⋯=n(a,a,…,a,b)=a.

(Note that a majority operation is a -ary near-unanimity operation.)

###### Theorem 1.2.

Let be a relational structure. The following dichotomy holds.

• If has a majority polymorphism and a Maltsev polymorphism, then is constant-query testable (with one-sided error).

• Else, testing requires a super-constant number of queries.

This theorem generalizes characterizations of constant-query testable List -homomorphisms [33] and Boolean CSPs [7] to general CSPs. In Section 3 we will describe the particularly nice structure of relations over templates that have majority and Maltsev polymorphisms and use this to prove the theorem. For the moment, let us consider a number of example templates to which the positive result of this theorem applies.

###### Example 1.3.

The template over the Boolean domain whose only relation is has both majority and Maltsev polymorphisms. Note that coincides with the graph 2-coloring problem.

More generally, the template over a finite domain where each relation is a bijection on has both majority and Maltsev polymorphisms, and instances of for such templates coincide with instances of the problem which is the subject of the unique games conjecture [23].

###### Example 1.4.

Another class of finite structures that have both majority and Maltsev polymorphisms are those that have a discriminator operation as a polymorphism. On a set the discriminator operation is the operation such that if then and if , . From this definition, it is immediate that is a Maltsev operation on , and that is a majority operation on . Any finite product of finite fields will have a discriminator term operation ([12]) and so any finite relational structure whose relations are compatible with the operations of such a ring will have majority and Maltsev polymorphism.

###### Example 1.5.

For a prime number, let be the field of size , and let be the ring . Then as noted in Example 1.4, has a discriminator term operation. Let be the structure with domain and set of relations consisting of intersections of the following binary relations on : For , 3, or 5,

• ,

• For , ,

• For , ,

So relations in can express that pairs of elements in are congruent modulo 2, 3, or 5 in the corresponding coordinate and/or that a certain coordinate is equal to some fixed value. These relations are invariant under the discriminator term operation of and so according to Theorem 1.2, has constant query complexity.

Examples of structures that satisfy the first condition of Theorem 1.2 but that do not have a discriminator operation as a polymorphism can be derived from finite Heyting algebras.

###### Example 1.6.

Consider the five-element Heyting algebra presented in [20, Figure 1]. (Heyting algebras are bounded distributive lattices that also have a binary “implication” operation; they serve as algebraic models of propositional intuitionistic logic.) This algebra has universe ; the two equivalence relations and that partition into blocks and (respectively) are preserved by the operations of the algebra. Since has majority and Maltsev term operations (the operations and respectively), then the structure has majority and Maltsev polymorphisms. The only other non-trivial binary relation on that is definable by a primitive-positive formula over is .

###### Example 1.7.

Bulatov and Marx provide yet another example of a structure having both a majority and a Maltsev polymorphism, in [9, Example 1.1].

We next consider existentially quantified CSPs (s for short). The difference between CSPs and s is that, in an instance of , existentially quantified variables may appear. So, an instance of may be defined as a primitive positive formula (pp-formula) over a relational structure. Primitive positive formulas are known as conjunctive queries in the database theory literature; they are arguably the most heavily studied class of database queries, and the problem can be associated with the problem of conjunctive query evaluation.

For a relational structure , we define to be the collection of instances of whose constraint relations are taken from . Our second contribution is to provide a complete classification of all structures in terms of the number of queries needed to test assignments of instances of with one-sided error:

###### Theorem 1.8.

Let be a relational structure. Then, the following trichotomy holds.

• If has a majority polymorphism and a Maltsev polymorphism, then is constant-query testable with one-sided error.

• Else, if has a -ary near-unanimity polymorphism for some , and no Maltsev polymorphism then is not constant-query testable (even with two-sided error) but is sublinear-query testable with one-sided error.111 We remark that the combination of having a -ary near unanimity polymorphism for some and a Maltsev polymorphism is equivalent to having majority and Maltsev polymorphisms [12].

• Else, testing with one-sided error requires a linear number of queries.

Let us point out that the problem families and exhibit the same dichotomy for constant-query testability, and in particular the positive result there is robust with respect to the introduction of quantifiers. An implication of Theorem 1.8 is this: if the dichotomy for sublinear-query testability for was not the same as that for , then the positive result for that dichotomy would not enjoy this robustness property, and hence such a positive result would have to crucially exploit the absence of quantifiers. Hence Theorem 1.8 reveals information about the form of a potential trichotomy for .

A special feature of templates that have a -ary near-unanimity polymorphism is that any relation that is definable by a pp-formula over can be decomposed into a number of -ary relations that are also pp-definable over .

###### Example 1.9.

Consider the relational structure over the Boolean domain whose only relation is . This structure is readily verified to have a majority polymorphism (note that over the Boolean domain, there is indeed a unique majority operation), and does not have a Maltsev polymorphism: for any Maltsev operation , it holds that applying to the tuples , which are in the relation , yields , which are not in the relation . Thus, Theorem 1.8 implies that is not constant-query testable but is sublinear-query testable with one-sided error.

###### Example 1.10.

We can generalize the previous example as follows. Let be any finite set of size greater than or equal to , and consider the dual discriminator operation defined as follows: is equal to if , and is equal to otherwise. Consider the relational structure with universe and the following relations: each unary relation; each graph of a permutation (on ); and, each two-fan relation. Here, a two-fan relation is a binary relation such that there exist elements where . It is straightforward to verify that is a majority polymorphism of . On the other hand, let be arbitrary elements, and consider the relation . The relation is a two-fan relation and so is a relation of , but does not have a Maltsev polymorphism; we argue this as follows. Let be an element of distinct from , and let be an element of distinct from . We have that the tuples are in , but if we apply any Maltsev polymorphism to them, we obtain which is not in . The structure thus does not have a Maltsev polymorphism; we obtain by Theorem 1.8 that is not constant-query testable but is sublinear-query testable with one-sided error.

### 1.3 Proof outline

We now describe outlines of our proofs of Theorems 1.2 and 1.8.

##### A has majority and Maltsev polymorphisms ⇒∃CSP(A) is constant-query testable.

We first look at (1) of Theorem 1.2 and 1.8. As s are a generalization of s, it suffices to consider s. Let be an input of the assignment testing of . First, we preprocess so that it becomes -consistent (see Section 2 for the formal definition). Using the 2-consistency of and the majority polymorphism of we can assume that for each variable of , the set of allowed values for forms a domain that is the universe of an algebra that is a factor (i.e., a homomorphic image of a subalgebra) of , the algebra of polymorphisms of . Also, we can assume that for each pair of variables , of there is a unique binary constraint of with scope and constraint relation , with the universe of some subalgebra of . Furthermore these are the only constraints of .

In order to test whether satisfies , we use three types of reductions: a factoring reduction, a splitting reduction, and an isomorphism reduction. Each reduction produces an instance and an assignment such that satisfies if satisfies , and is -far from satisfying if is -far from satisfying . For simplicity, we focus on how we create a new instance here.

The objective of the factoring reduction is to factor, for each variable of , the domain by any congruence of (i.e., an equivalence relation on that is compatible with the operations of ) for which none of the constraint relations of distinguish between -related values of .

After ensuring that all of the domains of cannot be factored, we then employ a splitting reduction to ensure that for each variable of the algebra is subdirectly irreducible, i.e., cannot be represented as a subdirect product of non-trivial algebras. For any variable for which can be represented as a subdirect product of non-trivial algebras and we replace the variable by the new variables and and the domain by the domains and . For any other variable of , we “split” the constraint relation (and its inverse ) into two relations and that are together equivalent to the original one. We then add these two new relations (and their inverses) to , along with , now regarded as a binary relation from the variable to .

After performing the splitting reduction and the factoring reduction, we next define a binary relation  on the set of variables of such that if and only if the constraint relation is the graph of an isomorphism from to . Using 2-consistency and the fact that the domains of are subdirectly irreducible and cannot be factored, it follows that, unless is trivial, the relation will be a non-trivial equivalence relation. Within each -class, the domains are isomorphic via the corresponding constraint relations of , and this allows us to produce an isomorphism-reduced instance by restricting to a set of variables representing each of the -classes.

After performing this isomorphism reduction, the resulting instance may have domains which can be further factored, allowing us to apply the factoring reduction to produce a smaller instance. We show that if we reach a point at which none of the three reductions can be applied, the instance must be trivial, either having just a single variable, or for which for all variables . We also show that this point will be reached after applying the reductions at most -times.

In Section 3, we will see how these reductions work on the template in Example 1.5.

##### CSP(A) is constant-query testable ⇒A has majority and Maltsev polymorphisms.

Now we look at (2) of Theorem 1.2 and the hardness part of (2) of Theorem 1.8. As s are a generalization of s, it suffices to consider s. We show that if does not have these two types of polymorphisms, then we cannot test with a constant number of queries. We use that having these two types of polymorphisms is equivalent to having a Maltsev polymorphism and that the variety of algebras generated by is congruence meet semidistributive [19]. The paper [24] provides a characterization of this condition in terms of the existence of two special polymorphisms of . When the variety generated by is not congruence meet semidistributive, then it can be easily shown from [7, 33] that testing requires a linear number of queries. When does not have a Maltsev polymorphism, then we can reduce to , where the structure has a binary non-rectangular relation. Then, by replacing the -SAT relations with this binary non-rectangular relation, we can reuse the argument for showing a super-constant lower bound for -SAT in [17] to obtain a super-constant lower bound for .

##### A has a (k+1)-ary near-unanimity polymorphism, for some k≥2⇒∃CSP(A) is sublinear-query testable.

Now we consider the testability part of (2) of Theorem 1.8. It is known that, if has a -ary near unanimity polymorphism, then is sublinear-query testable with one-sided error in the unweighted case [7]. We slightly modify their argument so that we can handle weights.

##### ∃CSP(A) is sublinear-query testable with one-sided error ⇒A has a (k+1)-ary near unanimity polymorphism, for some k≥2.

Finally, we consider (3) of Theorem 1.8. We use that has a -ary near unanimity polymorphism for some if and only if the variety of algebras generated by is congruence meet semidistributive and congruence modular [19, 2]. We already mentioned that if this variety is not congruence meet semidistributive then is not sublinear-query testable (even with two-sided error). To complete the argument we show that if the variety is not congruence modular then, by building on ideas developed in [14], we can reduce the problem of testing assignments of a circuit in monotone to . Note that majority functions are in monotone  [32], and we can easily show a linear lower bound for one-sided error testers that test assignments of majority functions. Hence, we get a linear lower bound for .

### 1.4 Related work

Assignment testing of CSPs was implicitly initiated by [17]. There, it was shown that 2-CSPs are testable with queries and require queries for any fixed . On the other hand, -SAT [6], -LIN [6], and Horn SAT [7] require queries to test.

The universal algebraic approach was first used in [33] to study the assignment testing of the list -homomorphism problem. For graphs , , and list constraints , we say that a mapping is a list homomorphism from to with respect to the list constraints if for any and for any . Then, the corresponding assignment testing problem, parameterized by a graph , is the following: The input is a tuple , where is a (weighted) graph, are list constraints, is a mapping given as a query access, and is an error parameter. The goal is testing whether is a list -homomorphism from or -far from being so, where -farness is defined analogously to testing assignments of CSPs. It was shown in [33] that the algebra (or the variety) associated with the list -homomorphism characterizes the query complexity, and that list -homomorphism is constant-query (resp., sublinear-query) testable if and only if is a reflexive complete graph or an irreflexive complete bipartite graph (resp., a bi-arc graph).

Testing assignments of Boolean CSPs was studied in [7], and in that paper relational structures were classified into three categories: (i) structures for which is constant-query testable, (ii) structures for which is not constant-query testable but sublinear-query testable, and (iii) structures for which is not sublinear-query testable. They also relied on the fact that algebras (or varieties) can be used to characterize query complexity.

### 1.5 Open problems

Theorem 1.2 characterizes relational structures on general domains for which is constant-query testable. Obtaining a characterization for the sublinear-query testable case is a tantalizing open problem. The main obstacle of this is that we obtained (3) of Theorem 1.8 by reducing the problem of testing assignments of monotone circuits to s. If we do not allow existentially quantified variables, then the number of variables blows up polynomially in the reduction, and a linear lower bound for monotone circuits does not imply a linear lower bound for CSPs.

Theorem 1.8 provides a trichotomy for s in terms of the number of queries needed to test with one-sided error. Obtaining a similar trichotomy for two-sided error testers is also an interesting open problem. Again the obstacle is that we reduce from the problem of testing assignments of monotone circuits. It is not clear whether this problem is hard even for two-sided error testers.

### 1.6 Organization

Section 2 introduces the basic notions used throughout this paper. We show the constant-query testability of s with majority and Maltsev polymorphisms in Section 3. Super-constant lower bounds of CSPs without majority or Maltsev polymorphisms is discussed in Section 4. We give a sublinear-query tester for s having a -ary near unanimity polymorphism, for some , in Section 5. In Section 6, we show that, when there is no -ary near unanimity polymorphism for any , testing s with one-sided error requires a linear number of queries.

## 2 Preliminaries

For an integer , let denote the set .

##### Constraint satisfaction problems

For an integer , a -ary relation on a domain is a subset of . A constraint language on a domain is a finite set of relations on . A (finite) relational structure, or simply a structure consists of a non-empty set and a constraint language on .

For a structure , we define the problem as follows. An instance consists of a set of variables , a set of constraints , and a weight function with . Here, each constraint is of the form , where are variables, is a relation in and is the arity of . An assignment for is a mapping , and we say that is a satisfying assignment if satisfies all the constraints, that is, for every constraint .

For a structure , we define the problem as follows. An instance consists of a set of free variables , a set of existentially quantified variables , a set of constraints , and a weight function with . Constraints are imposed on . An assignment for is a mapping , and we say that is a satisfying assignment if there exists an extension of such that for every constraint .

##### Algebras and Varieties:

Let be an algebra. A set is a subuniverse of if for every operation restricted to has image contained in . For a nonempty subuniverse of an algebra , is the restriction of to . The algebra , where is a subalgebra of . Algebras are of the same type if they have the same number of operations and corresponding operations have the same arities. Given algebras of the same type, the product is the algebra with the same type as and with universe and operations computed coordinate-wise. A subalgebra of is a subdirect product of and if the projections of to and to are both onto. An equivalence relation on is called a congruence of an algebra if is a subalgebra of . The collection of congruences of an algebra naturally forms a lattice under the inclusion ordering, and this lattice is called the congruence lattice of the algebra. Given a congruence on , we can form the homomorphic image , whose elements are the equivalence classes of and the operations are defined so that the natural mapping from to is a homomorphism. An operation on a set is idempotent if for all , an algebra is idempotent if each of its operations is, and a class of algebras is idempotent if each of its members is. We note that if is idempotent, then for any congruence of , the -classes are all subuniverses of .

A variety is a class of algebras of the same type closed under the formation of homomorphic images, subalgebras, and products. For any algebra , there is a smallest variety containing , denoted by and called the variety generated by . It is well known that any variety is generated by an algebra and that any member of is a homomorphic image of a subalgebra of a power of .

Many important properties of the algebras in a variety can be correlated with properties of the congruence lattices of it member algebras. In this work we consider several congruence lattice conditions for varieties, including congruence modularity, congruence distributivity, congruence meet semidistributivity, and congruence permutability. Details of these conditions can be found in [19] and more details on the basics of algebras and varieties can be found in [12].

### 2.1 Assignment problems

An assignment problem consists of a set of instances, where each instance has associated with it a set of variables , a domain for each variable , and a weight function with . An assignment of is a mapping defined on with for each variable . Each instance of an assignment problem has associated with it a notion of a satisfying assignment. For two assignments and for , we define their distance as . We define , where is over all satisfying assignments of . Then, for , we say that an assignment for is -far from satisfying if . In the assignment testing problem corresponding to an assignment problem, we are given an instance of the assignment problem and a query access to an assignment for , that is, we can obtain the value of by querying . Then, we say that an algorithm is a tester for the assignment problem if it accepts with probability at least when is a satisfying assignment of , and rejects with probability at least when is -far from satisfying . The query complexity of a tester is the number of queries to .

We can naturally view and as assignment problems: for each instance on a set of (free) variables , the associated assignments are the mappings from to , and the notion of satisfying assignments is as described above. Note that an input to the assignment testing problem corresponding to or to is a tuple , where is an instance of or , respectively, is an error parameter, and is an assignment to . In order to distinguish from the tuple , we always call the former instance and the latter input.

#### 2.1.1 Gap-preserving local reductions

We will frequently use the following reduction when constructing algorithms as well as showing lower bounds.

###### Definition 2.1 (Gap-preserving local reduction).

Given assignment problems and , there is a (randomized) gap-preserving local reduction from to if there exist a function and constants satisfying the following: given a -instance of with variable set and an assignment for , there exist a -instance with variable set and an assignment for such that the following hold:

1. .

2. If is a satisfying assignment of , then is a satisfying assignment of .

3. For any , if , then holds, where the probability is over internal randomness.

4. Any query to can be answered by making at most queries to .

A linear reduction is defined to be a gap-preserving local reduction for which the function , , and .

###### Lemma 2.2 ([33]).

Let and be assignment problems. Suppose that there exists an -tester for with query complexity for any , where is the number of variables in the given instance of , and that there exists a gap-preserving local reduction from to with a function and . Then, there exists an -tester for with query complexity for any , where is the number of variables in the given instance of . In particular, linear reductions preserve constant-query and sublinear-query testability.

As another application of gap-preserving local reductions, the following fact is known.

###### Lemma 2.3 (Lemma 6.4 and 6.5 of [33]).

Let be relational structures. If the relations of are preserved by the operations of some finite algebra in , then is constant-query testable if is constant-query testable.

In the proof of Lemma 2.3, the only obstacle that prevents linear reductions is that the number of variables blows up by introducing new variables for each constraint. However, we can get rid of this obstacle by replacing them with existentially quantified variables and we get the following.

###### Lemma 2.4.

Let be relational structures. If the relations of are preserved by the operations of some finite algebra in , then there exists a linear reduction from to . In particular, is constant-query (resp., sublinear-query) testable if is constant-query (resp., sublinear-query) testable.

#### 2.1.2 (k+1)-ary near unanimity polymorphisms

Let be an instance of . A partial solution of on a set of variables is a mapping that satisfies every constraint where and is the projection of to . Here denotes the subtuple of consisting of those entries of that belong to , and we consider the coordinate positions of indexed by variables from . Instance is said to be -consistent if for any -element set and any any partial solution on can be extended to a partial solution on . It is well known that, for any constant , any instance can be transformed to a -consistent instance in polynomial time without changing the set of satisfying assignments. See [22] for more details.

Let be a relational structure with a -ary near unanimity polymorphism, and let be a -consistent instance of . Because of the existence of a -ary near unanimity polymorphism, we can assume that every constraint is -ary. Hence, we can write . Further, we can say that, for any set of size , any partial assignment with can be extended to a satisfying assignment for the whole instance [16]. This property is called the -Helly property. We call a subset of variables of size violated with respect to an assignment if .

As an application of gap-preserving local reductions, we observe that if a relational structure has a -ary near unanimity polymorphism for some , then testing can be reduced to .

###### Lemma 2.5.

Let be a relational structure with a -ary near unanimity polymorphism for some . Then, there is a linear reduction from to .

###### Proof.

Let be a -consistent instance of . Then, we consider the instance and the assignment .

If satisfies , then also satisfies because the constraints of are also constraints of .

Suppose that is -close to satisfying and let be a satisfying assignment of with . Then, we define . Note that satisfies because there is no violated constraint caused by , and from the -Helly property, we can always extend it to a satisfying assignment for the whole instance. Hence, is -close to .

To summarize, this reduction is a gap-preserving local reduction with , , and . ∎

## 3 Constant-Query Testability

In this section, assume that is a structure that has a majority polymorphism and a Maltsev polymorphism . It is known, [12], that this is equivalent to the variety generated by the algebra being congruence distributive and congruence permutable and also to having a -ary near unanimity polymorphism for some and a Maltsev polymorphism. This means that for each algebra , the lattice of congruences of satisfies the distributive law and that for each pair of congruences and of , the relations and are equal. Such varieties are also said to be arithmetic.

An important feature of (and in fact of any congruence distributive variety generated by a finite algebra) is that every subdirectly irreducible member of has size bounded by  ([12]). We will make use of the fact that an algebra is subdirectly irreducible if and only if the intersection of all of its non-trivial congruences is non-trivial. This is equivalent to the algebra having a smallest non-trivial congruence. In this section, we will show that is constant-query testable. Some of the ideas found in this section were inspired by the paper [9].

We first note that, since has a majority operation, that is, a -ary near unanimity operation, as a polymorphism, it suffices to consider by Lemma 2.5.

For our analysis, it is useful to introduce for a variety . An instance of is of the form . Each is the domain of an algebra, denoted by , in , and each constraint in is of the form , where is the domain of a subalgebra of . In particular, is also the domain of an algebra in . The definitions of -consistency and an assignment testing problem naturally carry over to instances of .

Let be an instance of . Since is arithmetic, we can assume that each constraint in is binary [1]. Hence, we also write

 I=(V,{Ax}x∈V,{Rxy}(x,y)∈V2,w)

or simply . Moreover, we can assume that is -consistent because the set of satisfying assignments does not change after making -consistent. For , is the equality relation on the set , and for distinct variables , denotes the (unique) binary constraint relation from to . We always have for any . We note that by 2-consistency, it follows that for distinct variables and , the relation is subdirect in . Throughout the remainder of this section, we will assume that any instance of considered will be 2-consistent and has only binary constraints.

Since is assumed to be congruence permutable ( then for any , the binary relation is rectangular, that is, implies . As noted in Lemma 2.10 of [9], this is equivalent to being a thick mapping. This means that there are congruences of and of such that modulo the congruence on , the relation is the graph of an isomorphism from to and such that for all and , if and only if . In this situation, we say that is a thick mapping with respect to , and . For future reference, we note that if for some variables , the congruence then the relation is the graph of a surjective homomorphism from to .

### 3.1 A factoring reduction

Let be an instance of and for each let , a congruence of . We say that is prime if is the equality congruence and factorable otherwise. Roughly speaking, if is not prime, then we can factor by without changing the problem, because no constraint of distinguishes values within any -class. Formally, we define the factoring reduction as in Algorithm 1.

Let be an input of and let . It is clear that since the instance of is assumed to be 2-consistent then the instance will also be 2-consistent. Furthermore, the sizes of the domains of are no larger than the sizes of the domains of . Now we show that the factoring reduction is a linear reduction.

###### Lemma 3.1.

Let be an input of and let . If is testable with queries, then is testable with queries.

###### Proof.

We show that the factoring reduction is a linear reduction. Let and be the original instance and the reduced instance, respectively.

Note that and we can determine the value of by querying .

If satisfies , then also satisfies . Suppose that is -close to satisfying and let be a satisfying assignment of with . Then, we define to be any assignment for such that for , is taken to be an arbitrary element in the -class . Then, satisfies and .

To summarize, the factoring reduction is a gap-preserving local reduction with , , and . ∎

### 3.2 Reduction to instances with subdirectly irreducible domains

In this section, we provide a reduction that produces instances whose domains are all subdirectly irreducible. Suppose that is a subdirect product of two algebras , from and that is a subdirect product of and for some . We can project the relation onto the factors of to obtain two new binary relations from to and from to , respectively:

 R1 ={(a1,b)∣there is some (a1,c2)∈A with ((a1,c2),b)∈R}, R2 ={(a2,b)∣there is some (c1,a2)∈A with ((c1,a2),b)∈R}.

The following shows that the relation can be recovered from the relations , , and (considered as a relation from to ).

###### Lemma 3.2.

For all , , and , the following are equivalent:

• , and .

###### Proof.

One direction of this claim follows by construction. For the other, suppose that , and . Then there are elements , for , 2, with , , , . Since is subdirect in and then there is some with . Applying the majority term of coordinate-wise to the tuples , , and from we produce the tuple , as required. ∎

Lemma 3.2 allows us to split a domain of an instance of into subdirectly irreducible domains. Formally, we define the splitting reduction as in Algorithm 2.