# Dichotomies for classes of homomorphism problems involving unary functions

# Dichotomies for classes of homomorphism problems involving unary functions

### as Feder

∗

### ,

### 268 Waverley St., Palo Alto, CA 94301, U.S.A.

### Florent Madelaine

†

### ,

### Iain A. Stewart

‡

### ,

### Department of Computer Science, University of Durham,

### Science Labs, South Road, Durham DH1 3LE, U.K.

### October 16, 2002

## Abstract

We study non-uniform constraint satisfaction problems where the underlying signature contains constant and function symbols as well as relation symbols. Amongst our results are the following. We establish a dichotomy result for the class of non-uniform constraint satisfaction problems over the signature consisting of one unary function symbol by showing that every such problem is either complete for

L

, via very restricted logical reductions, or trivial (depending upon whether the template function has a fixed point or not). We show that the class of non-uniform constraint satisfaction problems whose templates are structures over the signature

λ

2 consisting of two unary function symbols reflects the full computational significance of the class of non-uniform constraint satisfaction problems over relational structures. We prove a dichotomy result for the class of non-uniform constraint satisfaction problems where the template is a λ

2

-structure with the property that

∗ e-mail: [email protected]

† e-mail: [email protected] Much of this work was undertaken whilst at the University of Leicester.

‡ e-mail: [email protected] Much of this work was undertaken whilst at the

University of Leicester.

1

the two unary functions involved are the reverse of one another, in that every such problem is either solvable in polynomial-time or NP-complete. Finally, we extend some of our results to the situation where instances of non-uniform constraint satisfaction problems come equipped with lists of elements of the template structure which restrict the set of allowable homomorphisms.

## 1 Introduction

Constraint satisfaction problems consist of finding assignments of values to variables subject to constraints on the values which can be simultaneously assigned to certain specified subsets of variables [21]. They are of great importance in computer science and artificial intelligence, and have strong links with database theory, combinatorics and universal algebra. For example, the general constraint satisfaction problem is nothing other than the conjunctive-query containment problem from database theory and the homomorphism problem from combinatorics [2]; and there is a strong link between the tractability of constraint satisfaction problems and the study of the closure of relations under certain operations in universal algebra [14].

This diversity has meant that the study of these constraint satisfaction problems has progressed on a number of different fronts and according to different motivations.

Our formulation of constraint satisfaction involves the existence of a homomorphism from one finite structure to another, and in this paper we are concerned with the computational complexity of constraint satisfaction problems when the structures involved are restricted. The general constraint satisfaction problem , CSP, has: as its instances pairs of finite structures

(A, B) over the same signature; and as its yes-instances instances (A, B) for which there is a homomorphism from A to B. The general constraint satisfaction problem is trivially in NP (non-deterministic polynomial-time) and is easily shown to be NP-complete (via polynomial-time many-one reductions); and it is usual to restrict the problem so that all finite structures come from some specific class of finite structures or, further, so that the second component, the template, of any instance is some fixed finite structure.

The former problems are called uniform constraint satisfaction problems, as the two structures in an instance can be arbitrarily drawn from the given class of structures, whilst the latter problems are called non-uniform constraint satisfaction problems, as the second structure in an instance must be a given fixed structure (rather than thinking of instances of non-uniform constraint satisfaction problems as pairs of finite structures (A, T ), with T

2

fixed, we simply think of them as finite structures A, with yes-instances those instances A for which there exists a homomorphism to T ). The computational complexity of these restricted problems is then studied with the ultimate goal being a classification as to the conditions under which a (uniform or non-uniform) constraint satisfaction problem has a given computational complexity.

There are two outstanding and well-known results which illustrate this attempt at classification. The first was established by Schaefer [19] who completely classified the complexity of a non-uniform constraint satisfaction problem when the template is a finite structure whose domain consists of two elements, i.e., the template is a Boolean structure. He showed that if the template belongs to one of six specific classes of Boolean structures then the non-uniform constraint satisfaction problem is solvable in polynomialtime, otherwise it is NP-complete. Note the dichotomy here: a non-uniform constraint satisfaction problem with a Boolean template is either in P (deterministic polynomial-time) or is NP-complete (recall that, in general, if P 6=

NP then there is an infinite collection of distinct classes of polynomial-time equivalent problems between P and NP: see [10], for example). The second result is due to Hell and Neˇsetˇril [11] who showed that if all structures involved are finite undirected graphs (without self-loops) then the non-uniform constraint satisfaction problem is solvable in polynomial-time if the template is bipartite, otherwise it is NP-complete (again, note the dichotomy).

It is with such dichotomy results that we are concerned in this paper.

Apart from those established by Hell and Neˇsetˇril and by Schaefer, there are many others, of one flavour or another: see [1, 3, 4, 5, 7, 8, 9, 17, 18] for a selection. Let us discuss some of these results further as they have a direct bearing on our contributions and provide much of our motivation.

Perhaps the focal paper as regards the classification of non-uniform constraint satisfaction problems is [9] for it was in that paper that Feder and

Vardi (inspired by the results of Hell and Neˇsetˇril and of Schaefer) posed the question of whether it might be the case that every non-uniform constraint satisfaction problem is solvable in polynomial-time or NP-complete.

In more detail, Feder and Vardi essentially: considered the relationship between the class of non-uniform constraint satisfaction problems and a logic,

MMSNP, embodying essential characteristics of constraint satisfaction; considered sub-classes of non-uniform constraint satisfaction problems which reflect the full computational significance of the whole class; and studied requirements for tractability as regards non-uniform constraint satisfaction problems. It is the second of these investigations which is particularly relevant to our studies; and key is Feder and Vardi’s result that the problem of

3

deciding whether the class of non-uniform constraint satisfaction problems over relational structures has a dichotomy is equivalent to that of deciding whether the class of non-uniform constraint satisfaction problems involving digraphs has a dichotomy (we later make precise our definitions of classes such as these and of our notion of equivalence: indeed, definitions of all concepts mentioned here are defined in full later on). That is, the (sub-)class of non-uniform constraint satisfaction problems consisting of the class of non-uniform constraint satisfaction problems involving digraphs reflects the full computational significance of the class of non-uniform constraint satisfaction problems over relational structures (in fact, Feder and Vardi also provided other even more restricted classes of non-uniform constraint satisfaction problems involving digraphs which reflect the full computational significance of the class of relational non-uniform constraint satisfaction problems, e.g., the class where the template digraph is necessarily balanced).

Whilst Feder and Vardi’s question as to whether the class of non-uniform constraint satisfaction problems exhibits a dichotomy is still unanswered, significant partial positive results have been proven, notably, though not always, for classes where the template is a digraph of a particular type (we refer the reader to Feder and Vardi’s equivalence result mentioned above).

For example, in [5] it was proven that the class of non-uniform constraint satisfaction problems where the template is a digraph in the form of an oriented cycle has a dichotomy. Furthermore, the search for a classification of non-uniform constraint satisfaction problems has resulted in the study of a number of related concepts. For example, if every instance A of some non-uniform constraint satisfaction problem comes complete with a list U u of elements of the template T , for every element u ∈ |A|, then the problem of deciding whether there is a homomorphism ϕ from A to T with the additional property that for every element u ∈ |A|, ϕ(u) ∈ U u

, is known as a list homomorphism problem. It has been proven that every list homomorphism problem where the template is a reflexive undirected graph (that is, every vertex has a self-loop) is solvable in polynomial-time, if the template is an interval graph, and NP-complete otherwise [6]. If the template is an irreflexive undirected graph (that is, no vertex has a self-loop) then the list homomorphism problem is solvable in polynomial-time, if the complement of the template is a circular arc graph of clique cover number 2, and NPcomplete otherwise [7]. Finally, if the template is a general undirected graph

(that is, a vertex may or may not have a self-loop) then it is still the case that the list homomorphism problem is either solvable in polynomial-time or NP-complete [8].

All of the results mentioned above concern non-uniform constraint satis-

4

faction problems over relational structures. Our study in this paper is essentially of non-uniform constraint satisfaction problems where the underlying signature contains constant and function symbols as well as relation symbols; and our results can be summarized as follows. After presenting basic definitions and concepts in Section 2, in Section 3 we consider the class of non-uniform constraint satisfaction problems over a signature consisting of one unary function symbol. We show a dichotomy in that every such problem is either complete for L (deterministic log-space), via very restricted logical reductions, or trivial (depending upon whether the template function has a fixed point or not). In Sections 4 and 5, we consider the class of non-uniform constraint satisfaction problems over a signature λ

2 consisting of two unary function symbols, as well as over signatures consisting of a mix of constant, function and relation symbols. Amongst other results, we show that the class of non-uniform constraint satisfaction problems whose templates are

λ

2

-structures reflects the full computational significance of the class of nonuniform constraint satisfaction problems over relational structures; and we establish similar results when the template is even further restricted. In Section 6, we prove a dichotomy result for the class of non-uniform constraint satisfaction problems where the template is a λ

2

-structure with the property that the two unary functions involved are the reverse of one another. Finally, in Section 7 we extend some of our results to the situation where instances of non-uniform constraint satisfaction problems come equipped with lists.

In particular: we show that any list homomorphism problem where the template consists of a single unary function is solvable in polynomial-time; and we prove that there is a dichotomy result for the class of list homomorphism problems where the template consists of an arbitrary number of unary functions (the complexity of such a list homomorphism problem is determined by whether the template admits a choice majority function, similarly to as in [6, 7, 8]).

## 2 Basic definitions

A signature consists of a finite collection of constant symbols, function symbols and relation symbols, and each function and relation symbol has an associated arity. A finite structure A over the signature σ, or σ-structure, consists of a finite set |A|, the domain or universe, together with a constant c

A

(resp. function f

A

, relation R

A

) for every constant symbol c (resp.

function symbol f , relation symbol R) of σ, with functions and relations being of the appropriate arity (we often dispense with superscripts in the

5

names of our constants, functions and relations when it is clear as to which structure we are dealing with). The size of a structure A is the size of the domain and is denoted |A| also. A structure is relational if it is over a signature consisting entirely of relation symbols (which we refer to as a relational signature

).

A homomorphism ϕ : A → B from a σ-structure A to a σ-structure B is a map ϕ : |A| → |B| such that:

• any constant of A is mapped to the corresponding constant of B;

• if f is a function symbol of arity a then f

A

(u

1

, u

2

, . . . , u a

) = v ⇒ f

B

(ϕ(u

1

), ϕ(u

2

), . . . , ϕ(u a

)) = ϕ(v), for all u

1

, u

2

, . . . , u a

, v

∈ |A|;

• if R is a relation symbol of arity b then

R

A

(u

1

, u

2

, . . . , u b

) holds ⇒ R

B

(ϕ(u

1

), ϕ(u

2

), . . . , ϕ(u b

)) holds, for all u

1

, u

2

, . . . , u b

∈ |A|.

If there exists a homomorphism from A to B then we write A → B.

Let C be a class of finite structures. The uniform constraint satisfaction problem

CSP

C has: as its instances pairs (A, B) of structures from C over the same signature; and as its yes-instances those instances (A, B) for which there exists a homomorphism from A to B. The size of an instance (A, B) is |A| + |B|. If all structures in C are over the same signature and T ∈ C then the non-uniform constraint satisfaction problem CSP

C

(T ) has: as its instances structures A ∈ C; and as its yes-instances those instances A for which there exists a homomorphism from A to T . The size of an instance

A is |A|. If C is the class of all σ-structures and T is a σ-structure then we abbreviate CSP

C

(T ) by CSP(T ). We should add that the individual tractability of an infinite collection of non-uniform constraint satisfaction problems {CSP

C

(T ) : T ∈ C} does not automatically yield the tractability of the uniform constraint satisfaction problem CSP

C

; for it may be the case that the size of the template, whilst a constant in a non-uniform problem, might play an exponential role in some time bound (see [15] for an examination of this issue).

We shall be involved with problems solvable in L and complete for this complexity class. As regards completeness, the notion of reduction we work with comes from finite model theory and is the quantifier-free projection.

6

Before giving a definition of a quantifier-free projection, we present an example of a quantifier-free projection from one problem to another. As it turns out, we will need this actual reduction later on. The reader is referred to, for example, [12, 13, 20] for more on quantifier-free projections and other logical reductions (especially [13]), and their relevance as low-resource reductions: we only sketch the issues here.

Let the signature σ

2++ consist of the binary relation symbol E and the two constant symbols c and d. We can think of a σ

2++

-structure as a digraph, possibly with self-loops, with two designated vertices (which may be identical). The problem DTC

0,1 has: as its instances the class of σ

2++

structures which, when considered as digraphs with self-loops, have the property that every vertex has out-degree at most 1; and as its yes-instances those instances with the property that there is a path in the digraph from the vertex c to the vertex d. The problem DTC

1 has: as its instances the class of σ

2++

-structures which, when considered as digraphs with self-loops, have the property that every vertex has degree exactly 1; and as its yes-instances those instances with the property that there is a path in the digraph from the vertex c to the vertex d.

We shall derive four quantifier-free formulae over the signature σ

2++ and we shall use our formulae to describe, given an instance A of DTC

0,1

, an instance ρ(A) of DTC

1

: the first formula will define the vertex set of ρ(A); the second formula will describe the edge relation of our instance; and the third and fourth formulae will describe the source and target vertices.

The domain of ρ(A) is |A|

2

. We assume that, regardless of the signature, we always have a binary relation succ at our disposal that is always interpreted as a successor relation on the domain of any structure, i.e., as a relation of the form:

{(i j

, i j +1

) : j = 0, 1, . . . , n − 1}, when the domain of a structure of size n is {i

0

, i

1

, . . . , i n− 1

}, and also two constant symbols, 0 and max, that are always interpreted as the least and greatest elements, respectively, of the successor relation succ (more of this successor relation later). Let us suppose for simplicity that the elements of |A| are {0, 1, . . . , n − 1} and abbreviate ‘succ(u, w)’ by ‘w = u + 1’. The vertices of {(u, w) : w = 0, 1, . . . , n − 1} will form a path

(u, 0), (u, 1), . . . , (u, n − 1) in ρ(A), with a self-loop at (u, n − 1), except that:

• if (u, w) is an edge of E

A

, where u 6= w, then there is no edge

((u, w), (u, w + 1)) in ρ(A) nor self-loop ((u, n − 1), (u, n − 1)), if

7

w

= n − 1, but there is an edge ((u, w), (w, 0)) in ρ(A); and

• if (u, u) is an edge of E

A then there is no edge ((u, u), (u, u + 1)) in

ρ

(A) but there is a self-loop ((u, u), (u, u)).

The source vertex of ρ(A) is the vertex (c

A

, 0) and the target vertex is

(d

A

,

0). It is easy to see that an instance A of DTC

0,1 is a yes-instance if, and only if, the instance ρ(A) is a yes-instance of DTC

1 u

6= w, there is an edge (u, w) in E

A

(as whenever if, and only if, there is a path from vertex (u, 0) to vertex (w, 0) in ρ(A)).

The formulae ψ as follows:

0

, ψ

E

, ψ c and ψ d describing the above construction are

ψ

0

(x

1

, x

2

) ≡ x

1

= x

1

ψ

E

(x

1

, x

2

, y

1

, y

2

) ≡ (x

1

= y

1

∧ y

2

= x

2

+ 1 ∧ ¬E(x

1

, x

2

))

∨(x

1

= y

1

∧ x

2

= y

2

= max ∧ ¬E(x

1

, max

))

∨(x

1

6= x

2

∧ y

1

= x

2

∧ y

2

= 0 ∧ E(x

1

, x

2

))

∨(x

1

= x

2

∧ x

1

= y

1

∧ x

2

= y

2

∧ E(x

1

, x

2

))

ψ c

(x

1

, x

2

) ≡ x

1

= c ∧ x

2

= 0

ψ d

(x

1

, x

2

) ≡ x

1

= d ∧ x

2

= 0

The formula ψ

0

|A|

2

(x

1

, x

2

) tells us that the vertex set of ρ(A) is the whole of

(it might have restricted the vertex set to be some appropriately defined subset of |A|

2 but in this case didn’t); and ψ

E

, ψ c and ψ d describe the edge relation, the source vertex and the target vertex of ρ(A), respectively.

So, we can say that DTC

1

DTC

0,1 is a quantifier-free first-order translation of

(as the defining formulae are quantifier-free first-order); but we can actually say more. Note that the above formula ψ

E

_

{(α i

∧ β i

) : i = 1, 2, . . . , k}, is of the following form: for some k ≥ 1, where:

• each α i is a conjunction of atoms and negated atoms not involving any relation or function symbols of the underlying signature (σ

2++ illustration above); in the

• the α i

’s are mutually exclusive, i.e., for any valuation on the variables

(and constants) of any α i both α i and α j hold; and α j

, where i 6= j, it is not the case that

• each β i is an atom or a negated atom (over the underlying signature).

8

Indeed, the formulae ψ c more, ψ

0 and ψ d are trivially of this form too; and, furtheris a quantifier-free first-order formula not involving any relation or function symbols of the underlying signature. Hence, there is a quantifierfree projection from the problem DTC

0,1 proven in [20] that DTC

0,1 to the problem DTC

1

. It was is complete for L via quantifier-free projections; and consequently DTC

1 is also complete for L via quantifier-free projections.

Quantifier-free projections are so called because the defining formulae are quantifier-free first-order and any ‘bit’ of a target instance, e.g., edge of

ρ (A), above, depends only upon at most one ‘bit’ of the source structure, e.g.

, edge of A, above. They are extremely restricted reductions between problems and can easily be translated into other restricted circuit-based or model-based reductions, e.g., logtime-uniform NC

1

-reductions, used in complexity theory (see [12]). The (built-in) successor relation and the two associated constants give us an ordering of our data which often enables us to model machine-based computations where all data (such as input strings and instantaneous descriptions) is ordered.

We have one final remark: in our example above, we used quantifierfree first-order formulae to describe an edge relation and two constants.

We can equally well use such formulae to describe functions by treating an m

-ary function f as an (m + 1)-ary relation R f where for any elements u

1

, u

2

, . . . , u m

, there exists exactly one w such that R f

(u

1

, u

2

, . . . , u m

, w

) holds (constants, i.e., 0-ary functions, are described in this way too).

## 3 One unary function

In this section we show that the class of non-uniform constraint satisfaction problems with template a unary function has a dichotomy: such a problem is either L-complete (via quantifier-free projections) or trivial.

Let λ

1 be the signature consisting of one unary function symbol f . The decision problem Hom-Alg

1 is the problem CSP

C

, where C is the class of all

λ

1

-structures (we introduce the notation Hom-Alg, here and in what follows, to accentuate the algebraic aspect of function symbols).

Let A be a λ

1

-structure and let σ

2

= hEi, where E is a binary relation symbol (so, σ

2

-structures are digraphs, possibly with self-loops). The digraph of A is the σ

2

The proof of the following lemma is trivial.

Lemma 1 Let

A and B be λ

1

˙

-structures. Then

A → B if, and only if,

9

Proposition 2 The problem Hom-Alg

1 is in L.

Proof

By Lemma 1, we can assume that we are given pairs of digraphs of unary functions as instances rather than pairs of unary functions.

consists of a collection of connected components where each component is a directed cycle, which may have any length greater than 0 (and so may be a self-loop), some of whose vertices are roots of in-trees (our notion of connectivity in a digraph is with respect to the underlying undirected graph).

These components can be visualized as in Fig. 1. We call these components cycles with pendant in-trees

. We define the length of a cycle with pendant in-trees as the length of the directed cycle.

.

.

.

directed cycle

..

..

..

.

.

..

..

in-trees an in-tree a directed cycle with pendant in-trees

Figure 1. The components of the digraph of a unary function.

Suppose that there is a homomorphism taking some connected component

A

0

A to a connected component B

0 0 is a cycle with pendant in-trees of length γ then B

0 must be a cycle with pendant in-trees of length

δ where δ divides γ. Furthermore, if A

0 and B

0 are cycles with pendant in-trees of lengths γ and δ, respectively, and δ divides γ then there is a homomorphism from A

0 to B

0

. Hence, the following is a necessary and

This condition can easily be verified using O(log n) space. For example, we can ascertain whether a vertex u lies on the cycle of a cycle with pendant

10

n moves (when u doesn’t lie on a cycle) or after we have returned to u (when u does lie on a cycle). By counting as we walk, we obtain the length of the checking to see whether they lie on the cycle of a cycle with pendant inin-trees then we can check whether the length of this cycle divides c. Hence, the problem Hom-Alg

1

∈ L.

Proposition 3 The problem Hom-Alg

1 jections ).

is L-hard

(via quantifier-free pro-

Proof

Let A be an instance of DTC the unary function f

A

1

(and so is a σ

2 as follows. The domain of f

A

-structure). Define is |A|

2

× {0, 1} and:

• if c = d then:

– f

A

((u, w, b)) = (c, c, 0), for all (u, w, b) ∈ |A|

2

× {0, 1};

• if c 6= d then:

– if (u, w) ∈ E where u 6= d, w 6= c and u 6= w then f

A

((u, u, 0)) =

(u, w, 0) and f

A

((u, w, 0)) = (w, w, 0)

– if (u, u) ∈ E where u 6= d then f

A

((u, u, 0)) = (u, u, 1) and f

A

((u, u, 1)) = (u, u, 0)

– f

A

((d, d, 0)) = (c, c, 0)

– for any element (u, w, b) ∈ |A|

2

× {0, 1} \ {(d, c, 0)} for which f

A

((u, w, b)) is still undefined, define f

A

((u, w, b)) = (d, c, 0), and define f

A

((d, c, 0)) = (d, c, 1).

Essentially, apart from the trivial case where c = d, the digraph of f

A obtained from the digraph whose edge relation is E as follows: is

• take a copy of the digraph (with self-loops) whose edge relation is E, and replace any edge emanating from vertex d with the edge (d, c); and

• replace every edge (u, w), apart from the edge (d, c), by a pair of edges

(u, e u,w

) and (e u,w

, w

), where e u,w is a new vertex.

11

Other vertices are actually introduced in the formal constructive process

(defined above), with two of these vertices being (d, c, 0) and (d, c, 1). The construction is completed by introducing edges from all vertices, apart from

(d, c, 0), to (d, c, 0); and also an edge from (d, c, 0) to (d, c, 1). Now define the function g

A to have domain {0, 1} and to be such that g

A

(0) = 1 and g

A

(1) = 0. We claim that A ∈ DTC

1 if, and only if, (f

A

, g

A

) 6∈ Hom-Alg

The trivial case is straightforward (note that if the digraph of f

A

1

.

has a self-loop then there is not a homomorphism from f

A to g

A

): so suppose henceforth that c 6= d. Suppose that there is a path in the digraph whose edge relation is E from vertex c to vertex d. Then in the digraph of f

A

, there is a odd length cycle with pendant in-trees of length greater than 1.

Hence, there is no homomorphism from f

A to g

A

.

Suppose that there is not a path in the digraph whose edge relation is

E from vertex c to vertex d. Then all components of the digraph of f

A are even length cycles with pendant in-trees. Hence, there is a homomorphism from f

A to g

A

.

The construction of the unary functions f

A and g

A from A can easily be described by quantifier-free projections (see, e.g., [20] for concrete illustrations of logical formulae describing translations between problems) and so the result follows as DTC

1 is L-complete via quantifier-free projections.

The following is now immediate from Propositions 2 and 3.

Theorem 4 The problem Hom-Alg

1 jections ).

is L-complete

(via quantifier-free pro-

The problem Hom-Alg

1 is uniform in the sense that any unary function can appear as either the first or second component of an instance. We obtain non-uniform versions of Hom-Alg

1 by fixing the second component. The problem Hom-Alg

1

(T ), for some λ

1

-structure T , is the problem CSP(T ).

The following is immediate from the proofs of Propositions 2 and 3.

Theorem 5 Let

T be the λ

1

-structure corresponding to the unary function f whose domain is

{0, 1} and f (0) = 1 and f (1) = 0. The problem Hom-

Alg

1

(T ) is L-complete (via quantifier-free projections).

Hence, not only is the uniform problem Hom-Alg

1

L

-complete, there are also non-uniform problems Hom-Alg

1

(T ) that are L-complete (moreover, even when T has only two elements).

Actually, we can say more about non-uniform problems of the form Hom-

Alg

1

(T ). Whilst the proof of Proposition 3 is such that the template has a

12

digraph that is a cycle of length 2, we can actually replace this template with any λ

1

-structure T so long as the digraph of T has a cycle of pendant in-trees of lengths δ

1

, δ

2

, . . . , δ k

, for some k > 0. Adopting the terminology of the proof of Proposition 3 and with reference to this proof, in our construction process when we replace an edge of the digraph of f

A with a path of 2 edges, instead we replace the edge with a path of δ

1

δ

2

. . . δ k edges. So, if there is a path in the digraph whose edge relation is E from vertex c to vertex d then the digraph of f

A has a cycle with pendant in-trees of length γ.δ

1

δ

2

. . . δ k

+1, for some γ ≥ 1, and all other cycles with pendant in-trees (if there are any) have lengths divisible by δ

1

δ

2

. . . δ k

. Also, if there is no such path in the digraph whose edge relation is E then the digraph of f

A is such that every cycle with pendant in-trees has length divisible by δ

1

δ

2 obtain the following corollary.

. . . δ k

. Hence, we

Corollary 6 Let

T be any λ

1

-structure that is without a fixed point. The problem Hom-Alg

1

(T ) is L-complete (via quantifier-free projections).

Trivially, if the λ

1

-structure T has a fixed point then Hom-Alg

1

(T ) consists of every λ

1 where f

T

1

-structure and is identical to the problem Hom-Alg

1

(T

1

), is the function whose domain has one element. Note that whereas the ‘trivial’ cases of Hom-Alg

1

(T ) are identical to Hom-Alg

1

(T

1

), so there is an analogous remark to be made about Hell and Neˇsetˇril’s dichotomy: the

‘trivial’ cases, here the cases where the problem is solvable in polynomialtime, are identical to the case where the template graph consists of a solitary edge.

## 4 Two unary functions

We now consider the class of non-uniform constraint satisfaction problems with template two unary functions. Let λ

2 be the signature consisting of the two unary function symbols f and g. We define the decision problem

Hom-Alg

2 to be the problem CSP

C

, where C is the class of pairs of λ

2

structures; and for any λ

2

-structure T , we define the problem Hom-Alg

2

(T ) to be the problem CSP(T ). Our main result in this section is that whether this class of problems has a dichotomy is at least as hard as whether the class of non-uniform constraint satisfaction problems with template an arbitrary relational structure has a dichotomy; where by ‘dichotomy’ we mean that every such problem is either in P or complete for NP via polynomial-time

13

Turing-reductions (we actually prove the converse result later). We then go on to prove a restricted version of this result.

In future, for brevity, we shall refer to whether the class of non-uniform constraint satisfaction problems with template two unary functions has a dichotomy as the problem ∆(λ

2

), and do likewise for other similar problems. For example, whether the class of non-uniform constraint satisfaction problems with template an arbitrary relational structure has a dichotomy is the problem ∆(σ : σ relational); and whether the class of non-uniform constraint satisfaction problems with template a digraph has a dichotomy is the problem ∆(σ

2

). We denote the fact that the problem ∆(λ

2

) is at least as hard as ∆(σ : relational), for example, by ∆(σ : relational) ≤ ∆(λ

2

).

Remark 7

From now on, whenever we talk about a dichotomy, we mostly mean whether every problem is either in P or is complete for NP via polynomial-time Turing-reductions. We reserve the notation ‘NP-complete’ to mean complete for NP via polynomial-time (many-one) reductions. Most dichotomy results, notably those due to Schaefer and to Hell and Neˇsetˇril mentioned in the Introduction, are such that every problem is in P or is

NP

-complete. If a problem is NP-complete then it is complete for NP via polynomial-time Turing-reductions but it is unknown whether the converse is true. Furthermore, all reductions in Section 5 of [9], where various dichotomy problems over relational signatures are considered, involve polynomial-time reductions; and so the resulting dichotomy problems therein are with respect to P and NP-completeness via polynomial-time reductions (as opposed to

P and NP-completeness via polynomial-time Turing-reductions as it is for us in this paper).

We shall begin by detailing a transformation of a σ

2

-structure G, which we regard as a simple digraph with vertex set V (G) and edge set E(G) (and possibly with self-loops), into a λ

2

-structure λ

2

(G). The λ

2

-structure λ

2

(G) is defined as follows.

• The domain of λ

2

(G) consists of:

{1, 2, 3, 4} ∪ {v u

: u ∈ |G|} ∪ {e u,w

: u, w ∈ |G| are such that

E

G

(u, w) holds}.

• f (1) = 2, f (2) = 1, f (3) = 2, f (4) = 1, g(1) = 4, g(2) = 3, g(3) = 4 and g(4) = 3 in λ

2

(G).

• If v u

∈ |λ

2

(G)| then f (v u

) = 3 and g(v u

) = 1 in λ

2

(G).

14

• If e u,w

∈ |λ

2

(G)| then f (e u,w

) = v u and g(e u,w

) = v w in λ

2

(G).

The λ

2

-structure λ

2

(G) can be visualized in Fig. 2.

1 2

3

4

*e u,w*

.

.

.

.

.

.

.

.

.

*u*

.

.

.

.

.

.

*w g f*

Figure 2. The λ

2

-structure λ

2

(G).

Consider an arbitrary λ

2

-structure F.

We write the digraph (resp.

graph

) F to denote the digraph (resp. graph) with vertex set |F| where there is a directed (resp. undirected) edge (x, y) if, and only if, either f (x) = y or g(x) = y in F (unlike in the previous section, we no longer take the trouble to differentiate between a λ

2

-structure and the digraph it describes). The f -digraph (resp. f -graph) of F is the subdigraph (resp.

subgraph) of the digraph (resp. graph) F obtained by retaining only the edges resulting from the unary function f (the g-digraph and the g-graph of

F are defined similarly).

The λ

2

-structure F is bipartite if it is bipartite as a graph, and connected if it is connected as a graph. A neighbour of a vertex x in the digraph F is any vertex y for which there is an edge (x, y) or (y, x).

Lemma 8 Let

G and H be σ

2

-structures. Then

G → H if, and only if,

λ

2

(G) → λ

2

(H).

Proof

Suppose that ψ : G → H. Define the map ϕ : |λ

2

(G)| → |λ

2

(H)| as follows:

• ϕ(i) = i, for any i ∈ {1, 2, 3, 4};

• ϕ(v u

) = v

ψ (u)

, for any v u

∈ |λ

2

(G)|; and

15

• ϕ(e u,w

) = e

ψ (u),ψ(w)

, for any e u,w

∈ |λ

2

(G)|.

It is straightforward to check that the map ϕ is a homomorphism.

Conversely, suppose that ϕ : λ

2

(G) → λ

2

(H) is a homomorphism. In both λ

2

(G) and λ

2

(H), the elements 1 and 2 are the only elements x for which f (f (x)) = x; so, in particular, ϕ(1) ∈ {1, 2}. If v u g

λ

2

(G)

(v u

) = 1; and so ϕ(1) = ϕ(g

λ

2

(H)

(v u

)) = g

λ

2

(H)

(ϕ(v u

∈ |λ

2

(G)| then

)) 6= 2, because 2 is not the image of any element of |λ

2

(H)| under g. Hence, ϕ(1) = 1; and consequently ϕ(2) = 2, ϕ(3) = 3 and ϕ(4) = 4.

If v

, w u

∈ |H|.

(G)| then g

λ

2

(G)

(v u

) = 1. Hence, g

λ

2

(H)

(ϕ(v u

)) = 1, with the result that ϕ(v f

λ

2

(G) and g

(e u,w

λ

2

(H)

) = v u

(ϕ(e u,w u

) = v and g

λ

2

(G)

)) = ϕ(v w u

′

, for some u

(e u,w

) = v w

′

∈ |H|. If e

. Hence, f u,w

λ

2

(H)

∈ |λ

(ϕ(e u,w

2

(G)| then

)) = ϕ(v u

)

), with the result that ϕ(e u,w

,w

′

, for some u

′ ′

∈ |λ

2

) = e u

′

Define the map ψ : |G| → |H| by ψ(u) = u

′

, where ϕ(v u

) = v u

′

, for each u

∈ |G|. Consider u, w ∈ |G| such that E

G

(u, w) holds. By above, ϕ(e u,w

) = e u

′

,w

′

, for some e u

′

,w

′

∈ |λ

2

(H)|. By above, f

λ

2

(H)

(ϕ(e u,w

)) = ϕ(v u

) = v

ψ (u) and g

λ

2

(H)

(ϕ(e u,w

)) = ϕ(v w

) = v

ψ (w)

. Hence, u

′

= ψ(u) and w

′

= ψ(w), with E

H

(ψ(u), ψ(w)) holding. Consequently, ψ is a homomorphism.

Proposition 9 Let

H be a σ

2

-structure. There is a polynomial-time Turingreduction from Hom-Alg

2

(λ

2

(H)) to CSP (H).

Proof

Let F be a λ

2

-structure. Since λ

2

(H) is bipartite, there exists no homomorphism from F to λ

2

(H) unless F is also bipartite; so let us assume that F is bipartite (with some unique bipartition). We may also assume that F is connected, as otherwise we deal with each connected component in turn.

Colour the elements of |F| black or white according to the side of the bipartition they lie on. If there exists a homomorphism ϕ from F to λ

2

(H) then there are two possibilities: all the elements coloured black are mapped to 2, 4 or an element corresponding to a vertex of H, and all the elements coloured white are mapped to 1, 3 or an element corresponding to an edge of H; or all the elements coloured black are mapped to 1, 3 or an element corresponding to an edge of H, and all the elements coloured white are mapped to 2, 4 or an element corresponding to a vertex of H. We start with the first possibility (and subsequently handle the second possibility in exactly the same way).

Let H

1 be the digraph, i.e., σ

2

-structure, having a single vertex ν and a single edge ǫ = (ν, ν). Since there is a homomorphism from H to H

1

, the

16

proof of Lemma 8 yields that there is a homomorphism τ from λ

2

(H) to

λ

2

(H

1

), given by:

• τ (i) = i, for i ∈ {1, 2, 3, 4};

• τ (v u

) = ν, for u ∈ |H|; and

• τ (e u,w

) = ǫ, for e u,w

∈ {e u,w

: u, w ∈ |H| and E

H

(u, w) holds}.

Suppose that ϕ is a homomorphism from F to λ

2

(H). The homomorphism

τ ϕ enables us to label every element of F, in the natural way, with an element of {1, 2, 3, 4, ν, ǫ}.

Our strategy in developing our algorithm (to satisfy the statement of the theorem) is essentially to initially label every element x of |F| with a set of elements of {1, 2, 3, 4, ν, ǫ} so that each element might constitute a legitimate value for τ ϕ(x), via any resulting homomorphism ϕ, and then to reason so that we can reduce these label sets and:

• either obtain an element with an empty label set, in which case a homomorphism ϕ cannot exist; or

• obtain a collection of digraphs whereby answers as to whether these digraphs are in CSP(H) will enable us to ascertain whether there exists a homomorphism ϕ.

Consider the f -digraph of F. This is of the form of a disjoint union of directed cycles with pendant in-trees. For each element x in this f -digraph, define δ f

(x) to be the length of the longest walk whose end-point is the element x (note that we allow elements to be repeated on a walk). So, in particular, if x is an element in a directed cycle then δ f

(x) = ∞. For each element x of our f -digraph, consider the possible label set Λ(x) of x. There are a number of possibilities.

(1) If δ f

(x) > 1 and x is coloured black then Λ(x) ⊆ {2}.

(2) If δ f

(x) = 1 and x is coloured black then Λ(x) ⊆ {2, ν}.

(3) If δ f

(x) = 0 and x is coloured black then Λ(x) ⊆ {2, 4, ν}.

(4) If δ f

(x) > 2 and x is coloured white then Λ(x) ⊆ {1}.

(5) If δ f

(x) ∈ {1, 2} and x is coloured white then Λ(x) ⊆ {1, 3}.

(6) If δ f

(x) = 0 and x is coloured white then Λ(x) ⊆ {1, 3, ǫ}.

17

Suppose that we are in Case (3). There are two further cases: either there exists some y such that g

F

(y) = x or there doesn’t. In the first case, the value 2 cannot lie in Λ(x); and in the second case, we may as well remove the value 4 from Λ(x), as we could amend any corresponding homomorphism ϕ so that ϕ(x) = 2.

Suppose that we are in Case (6). There are two further cases: either there exists some y such that g

F

(y) = x or there doesn’t. In the first case, the value ǫ cannot lie in Λ(x); and in the second case, we may as well remove the value 3 from Λ(x), as we could amend any corresponding homomorphism ϕ so that ϕ(x) = 1.

So, the result is that every element x of |F| can be labelled with one of the following sets:

{1}, {2}, {2, ν}, {4, ν}, {1, 3}, {1, ǫ}.

We can consider some connected g-digraph within F in exactly the same way. Defining δ g with respect to this connected g-digraph rather than a connected f -digraph yields a number of possibilities.

(1) If δ g

(x) > 1 and v is coloured black then Λ(x) ⊆ {4}.

(2) If δ g

(x) = 1 and x is coloured black then Λ(x) ⊆ {4, ν}.

(3) If δ g

(x) = 0 and x is coloured black then Λ(x) ⊆ {2, 4, ν}.

(4) If δ g

(x) > 2 and x is coloured white then Λ(x) ⊆ {3}.

(5) If δ g

(x) ∈ {1, 2} and x is coloured white then Λ(x) ⊆ {1, 3}.

(6) If δ g

(x) = 0 and x is coloured white then Λ(x) ⊆ {1, 3, ǫ}.

Suppose that we are in Case (3). There are two further cases: either there exists some y such that f

F

(y) = x or there doesn’t. In the first case, the value 4 cannot lie in Λ(x); and in the second case, we may as well remove the value 2 from Λ(x), as we could amend any corresponding homomorphism ϕ so that ϕ(x) = 4.

Suppose that we are in Case (6). There are two further cases: either there exists some y such that f

F

(y) = x or there doesn’t. In the first case, the value ǫ cannot lie in Λ(x); and in the second case, we may as well remove the value 3 from Λ(x), as we could amend any corresponding homomorphism ϕ so that ϕ(x) = 1.

18

So, the result is that every element x of |F| can be labelled with one of the following sets:

{3}, {4}, {2, ν}, {4, ν}, {1, 3}, {1, ǫ}.

Note that evaluating the two analyses above might result in an element labelled by the empty set. If this is so then there can exist no homomorphism ϕ

(from F to λ

2

(H) where all the elements coloured black are mapped to

2, 4 or an element corresponding to a vertex of H, and all the elements coloured white are mapped to 1, 3 or an element corresponding to a edge of

H). Hence, we may assume that every element of F is labelled with one of the following sets:

{1}, {2}, {3}, {4}, {ν}, {ǫ}, {2, ν}, {4, ν}, {1, 3}, {1, ǫ}

(note that our evaluation of the two analyses might enable us to deduce that

Λ(x) = {ν} or {ǫ}).

Recall our λ

2

-structure λ

2

(H

1

) (with domain {1, 2, 3, 4, ν, ǫ}). Abbreviate f and g in λ

2

(H

1

) by f

1 and g

1

, respectively; and for any set S ⊆

{1, 2, 3, 4, ν, ǫ}, define f

1

(S) = {f

1

(i) : i ∈ S} and g

1

(S) = {g

1

Suppose that x, y ∈ |F| (where possibly x = y) and f

F

(i) : i ∈ S}.

(x) = y. Then any label set of y must be contained in f

1 with Λ(y) ∩ f

1

(Λ(x)). Hence, we can replace Λ(y)

(Λ(x)). The same can be said if x, y ∈ |F| and g

F

(x) = y.

We now repeatedly perform the above modification until either we obtain stability or an element with an empty label set. If we obtain an element with an empty label set then there can be no homomorphism ϕ: otherwise, there is still a chance that such a homomorphism ϕ exists.

We can now delete any element x of |F| that is labelled with the set {1}

(resp. {2}, {3}, {4}) as if the homomorphism ϕ exists then: the value of ϕ at x is necessarily 1 (resp. 2, 3, 4); and this will be consistent with any resulting value of ϕ at any neighbouring element in the digraph F. Hence, let us assume: that every element of |F| is labelled with one of the sets

{ν}, {ǫ}, {2, ν}, {4, ν}, {1, 3} and {1, ǫ}; and that the resulting digraph F is connected (as otherwise we deal with the connected components one-byone).

We shall now prove the following claim: if F is such that every element is labelled either {ν} or {ǫ} then there is a homomorphism from F to λ

2

(H) which takes every element of |F| to an appropriate (w.r.t. its label set) element of |λ

2

(H)| if, and only if, there is a homomorphism from the following digraph H

′ to H:

• the vertex set of H

′ is {x : x ∈ |F| is labelled {ν}}; and

19

• for every x, y ∈ |H

′

|, there is an edge (x, y) if, and only if, there is an element z ∈ |F| labelled {ǫ} such that f

F

(z) = x and g

F

(z) = y.

Suppose that ψ : F → λ

2 label sets). Let x ∈ |H

′

(H) (where the homomorphism respects the

|. So, x ∈ |F| and is labelled {ν}. Hence, ψ(x) = v u for some u ∈ |H|. Define ϕ : |H

′

| → |H| by ϕ(x) = u.

,

Suppose that (x, y) is an edge of the digraph H

′

. Hence, ψ(x) = v u and

ψ

(y) = v w

, for some u, w ∈ |H|. By definition, there is z ∈ |F| labelled {ǫ} such that f

F

(z) = x and g

F

(z) = y. So, f

λ

2

(H)

(ψ(z)) = ψ(x) = v u g

λ

2

(H)

(ψ(z)) = ψ(y) = v w

; and by the definition of λ

2 of the digraph H. Hence, ϕ : H

′

→ H.

and

(H), (u, w) is an edge

Conversely, suppose that ϕ : H

′

→ H. Let x ∈ |F| be labelled {ν}; so, x

∈ |H

′

|. Define ψ(x) = v ϕ (x) f

F

∈ |λ

2

(H)|. Let z ∈ |F| be labelled {ǫ}; so,

(z) = x, for some x with x labelled {ν}, and g

F

(z) = y, for some y with y labelled {ν}. Define ψ(z) = e ϕ (x),ϕ(y)

Suppose that f

F

∈ |λ

2

(H)|.

(z) = x; and so z is labelled {ǫ} and x is labelled

{ν}. We have that f

λ

2

(H)

(ψ(z)) = f

λ

2

(H)

(e ϕ

(x),ϕ(y)

), for some y ∈ |F|; and so f

λ

2

(H)

(ψ(z)) = v ϕ (x) g

F

= ψ(x). A similar argument for the case when

(z) = y yields that ψ : F → λ

2

(H), and so we have proved our claim.

Let us return to the situation prior to the statement of our claim. Suppose that x ∈ |F| is labelled with either {ν} or {ǫ}. As F is connected, this effectively fixes every label set to consist of at most one element, and we can remove elements from |F| labelled {1}, {2}, {3} or {4} (as above).

The above claim yields the result (note that we did not require F to be connected to prove our claim).

Alternatively, suppose that there does not exist an element x ∈ |F| labelled with either {ν} or {ǫ}. Choose some element x ∈ |F| and remove one element from Λ(x). This effectively forces every other label set to have size at most one, and we can remove elements from |F| labelled {1}, {2},

{3} or {4} (as above). Removing the alternative element from Λ(x) results in a similar scenario. Regardless, the above claim yields the result.

Hence, we obtain the main theorem of this section.

Theorem 10 For any σ

2

-structure

H, the problem CSP (H) is polynomialtime Turing-equivalent to the problem Hom-Alg

2

(λ

2

(H)). Thus, any nonuniform constraint satisfaction problem where the template is a relational structure is polynomial-time Turing-equivalent to a non-uniform constraint satisfaction problem where the template is a λ

2

-structure of the form λ

2

(H), for some σ

2

-structure

H.

20

Proof

The first part of the theorem follows immediately from Lemma 8 and Proposition 9. The second part follows from Theorem 10 of [9].

Essentially, Theorem 10 tells us that ∆(σ : relational) ≤ ∆(λ

2

) and that

∆(σ

2

) ≤ ∆(λ

2

) ([9] tells us that ∆(σ : relational) ≤ ∆(σ

2

) and ∆(σ

2

) ≤

∆(σ : relational), i.e., that ∆(σ

2

) ≡ ∆(σ : relational)).

We can obtain a yet more restricted version of Theorem 10, in terms of the structure λ

2

(H).

A matching is a unary function h such that h(x) 6= x and h(h(x)) = x, for all x. Let F be a λ

2

-structure. We shall define a λ

2

-structure µ(F) that is bipartite and where the function g in µ(F) is a matching. The domain of µ(F) consists of two disjoint copies of |F|; so, for every element x

∈ |F|, there are two elements x

1

, x

2

∈ |µ(F)| (the former we call an index-1 element, the latter an index-2 element). We define g(x

1

) = x

2 g

(x

2

) = x

1 in µ(F). Also, if f (x) = y in F then we define f (x

1

) = y

2 and in

µ

(F); and if g(x) = y in F then we define f (x

2

) = y

1 in µ(F).

Suppose that we construct the structure µ(F) from the structure F.

We can undo the construction of µ(F) to get not only F but also the λ

2

structure F s

, by swapping the indices 1 and 2 on the corresponding pairs of elements of µ(F). So, for example, if f (x

1

) = y

2 in µ(F) then g(x) = y in

F s

; that is, F s is F with f and g swapped.

Lemma 11 For any λ

2

-structures

F and F

′

:

• if F → F

′ then µ

(F) → µ(F

′

); and

• if F is connected and µ(F) → µ(F

′

) then either F → F

′ or

F s

→ F

′

.

Proof ϕ

(x)

1 with f

Suppose that ϕ : F → F and ψ(x

2 and so f

F

µ

(F

′

)

. Let x

(x) = y. Thus, f

(ψ(x

) = ϕ(x)

1

2

)) = ψ(y

2

F

′

1

′

. Define ψ : |µ(F)| → |µ(F

, y

2

∈ |µ(F)| be such that f

(φ(x)) = φ(y), and so f

). The other case for f and the fact that ψ preserves g

µ (F )

µ

(F )

µ

(F

′

)

′

)| by ψ(x

µ (F )

(φ(x)

1

(x

1

1

) =

) = y

2

) = φ(y)

2 is handled similarly, is trivial. Hence, ψ : µ(F) → µ(F

′

).

;

,

Suppose that F is connected and that ψ : µ(F) → µ(F

′

).

Define ϕ

: |F| → |F

′

| by ϕ(x) = y

′ well-defined). Suppose that f if {ψ(x

1

F

), ψ(x

2

)} = {y

(x) = y; and so f

′

1

, y

µ (F )

′

2

} (note that ϕ is

(x

1

) = y

2

. Hence, f

µ

(F

′

)

(ψ(x

1

)) = ψ(y

2

). There are two possibilities: every index-1 element of

µ

(F) is mapped under ψ to an index-1 element of µ(F

′

); or every index-1 element of µ(F) is mapped under ψ to an index-2 element of µ(F

′

) (this is because F is connected). Suppose that {ψ(x

1

), ψ(x

2

)} = {x

′

1

, x

′

2

} and

21

{ψ(y

1

), ψ(y

2

)} = {y over, whether f ilarly, if g

F

F

′

(x

′

1

′

, y

′

2

}. Thus, either f

) = y

′ or g

F

′

(x) = y then either g

F

(x

′

′

) = y

(x

′

F

′

′

) = y

′

(x

′

) = y

′ or g

F

′

(x

′

) = y

′

. Moreis independent of x and y. Simor f

F

′

(x

′

) = y

′

. Consequently, either F → F

′ or F s

→ F

′

.

Corollary 12 For any σ

2

-structure

H, the problem CSP (H) is polynomialtime Turing-equivalent to the problem Hom-Alg

2

(µ(λ

2

(H))).

Thus, any non-uniform constraint satisfaction problem where the template is a relational structure is polynomial-time Turing-equivalent to a non-uniform constraint satisfaction problem where the template is a λ

2

-structure of the form

µ (λ

2

(H)), for some σ

2

-structure

H.

Proof

Let F be a λ

2 form µ(F

′

-structure. We shall transform F so that F is of the

) and where F → µ(λ

2

(H)) if, and only if, either F

′

→ λ

2

(H) or

F

′ s

→ λ

2

(H).

We may assume that F is connected (otherwise we work with each connected component in turn) and bipartite (otherwise we define F

′ to be any λ

2

-structure not in Hom-Alg

F → µ(λ

2

2

(µ(λ

2

(H)))). If there is a homomorphism

(H)) then, for any element x ∈ |F|, the elements x and g

F

(g

F

(x)) must map to the same element of |µ(λ

2 elements x and g

F

(g

F

(H))|. Thus, we can identify the

(x)) in F as a single element x. Of course, this may result in f

F or g

F being multiple-valued at x, and if this is the case then we identify the two values of f

F or the two values of g

F

. Note that there is a homomorphism from the amended F to µ(λ

2

(H)) if, and only if, there is a homomorphism from the original F to µ(λ

2

(H)) (a homomorphism from a multiple-valued F must respect all functional identities). We iterate this process until we can go no further. Eventually, we obtain that F is connected and bipartite, and that g

F is a matching.

We may pair up elements x

1 and x

2 for which g

F

(x

1

) = x

2 and g

F

(x

2

) = x

1 so that all elements indexed by 1 (resp. 2) are on the same side of the bipartition of F. Hence, F = µ(F

′ each pair (x

1

, x

2

); f

F

(x) = y if f

F

By Lemma 11, F → µ(λ

2

′

) where: F

(x

1

) = y

2

′ has a single element x for

; and g

F

′

(x) = y if g

(H)) if, and only if, either F

′

→ λ

2

F

(x

2

) = y

1

(H) or F

′ s

→

.

λ

2

(H). So, by Proposition 9, there is a polynomial-time Turing-reduction from Hom-Alg

2

(µ(λ

2

(H))) to CSP(H).

Conversely suppose that G is a σ

2

-structure. Let G

∗ be the disjoint union of G and H. We shall show that G → H if, and only if, µ(λ

2

µ

(λ

2

(H

∗

)).

Suppose that G → H. Then G

∗

→ H and λ

2

(G

∗

(G

∗

)) →

(H) by Lemma 8.

So, µ(λ

2

(G

∗

)) → µ(λ

2

(H)) by Lemma 11.

) → λ

2

22

λ

2

Conversely, suppose that µ(λ

(G

∗

) s

→ λ

2

2

(G

∗

)) → µ(λ

2

(H)). As λ

2 nected, we can apply Lemma 11 to obtain that either λ

2

(H). In the former case, we get that G

∗

(G

∗

(G

∗

) is con-

) → λ

2

(H) or

→ H by Lemma 8. In the latter case, we get that λ

2

(G

∗

) → λ

2

(H) s

. However, if we denote by H s the digraph H where all edges are reversed then it is straightforward to see that λ

2

(H) s

= λ

2

(H s

); and so by Lemma 8, G

∗

→ H s and thus H → H s

.

If ψ : H → H s then the same map ψ is a homomorphism from H s

Thus, composing homomorphisms gives us that G

∗ to H.

→ H. Hence, there is a polynomial-time reduction from CSP(H) to Hom-Alg

2 result follows.

(µ(λ

2

(H))), and the

Essentially, Corollary 12 tells us that ∆(σ : relational) ≤ ∆(λ

2 bipartite, g a matching). Thus, if we wish to establish dichotomy results for

: non-uniform constraint satisfaction problems with template a λ

2

-structure, but without resolving ∆(σ : σ relational), then we need to restrict the templates beyond being bipartite with one of the unary functions a matching.

We shall consider restricted structures later in this paper.

## 5 Constants, unary functions and relations

In this section we prove what amounts to the converse of Theorem 10. We then go on to examine the complexity of problems of the form Hom-Alg

2

(T ) for certain elementary λ

2

-structures T .

Theorem 13

Let

B be some σ-structure where σ consists of constant symbols, unary function symbols and relation symbols.

There exists a relational signature σ

′ and a σ

′

-structure

B

′ such that CSP

(B) and CSP(B

′

) are polynomial-time equivalent.

Proof

R i

Let σ = hc

1

, . . . , c k

, f

1

, . . . , f l

, R

1

, . . . , R m i, where each c i

(resp. f i

,

) is a constant (resp. unary function, relation) symbol; and let σ

′

= hC

1

, . . . , C k

, F

1 bol and each F

, . . . , F i l

, R

1

, . . . , R m i, where each C i is a unary relation symis a binary relation symbol. Define the σ

′

-structure B

′ as follows:

• |B

′

| = |B|;

• for each i ∈ {1, 2, . . . , k}, C i

B

′

= {c

B i

};

• for each i ∈ {1, 2, . . . , l} and for any u, w ∈ |B

′

|, F i

B

′

(u, w) holds if, and only if, f i

B

(u) = w; and

23

• for each i ∈ {1, 2, . . . , m}, R

B i

′

= R

B i

.

Suppose that A

′ is a σ

′

-structure. Suppose further than C

′ some i ∈ {1, 2, . . . , k}: so I = {i : C i

A

Add a new element to the domain of A

′ i

A

′

= ∅, for

= ∅ where 1 ≤ i ≤ k} is non-empty.

and for every i ∈ I, set the relation

C i of the amended structure to consist of the set containing only this new element (keep all the other relations as they are). Clearly, the amended structure A

′

CSP(B

′ is in CSP(B

′

) if, and only if, the original structure A

′

). Hence, we assume that every relation C i

A

′ is in

, for i ∈ {1, 2, . . . , k}, is non-empty.

We shall now amend A

′ so that in the amended structure, A

′′

, for every i

∈ {1, 2, . . . , l} and for every u ∈ |A

′′

|, there is at least one w ∈ |A

′′ that F i

A

′′

(u, w) holds. We begin by defining the σ

′

-structure B

′ p

| such as follows:

• |B

′ p

| = |B

′

| p

, where |B

′

| contains p elements;

• for every i ∈ {1, 2, . . . , k}, C i

B

′ p

= ∅;

• for every i ∈ {1, 2, . . . , l} and for any ¯

¯

∈ |B

′ p and only if, v j

= f

B

(u j

|, F i

B

′ p

), for every j ∈ {1, 2, . . . , p}; and

(¯ v ) holds if,

• for every i ∈ {1, 2, . . . , m}, R i

B

′ p

= ∅.

Let ¯ ∈ |B

′ p

| be such that all components of ¯ are distinct, and let w ∈ |B

′

|.

Then w appears as some coordinate in ¯ : w.l.o.g. assume that w appears as the first coordinate. Define the map ϕ w v

: |B

′ p

| → |B

′

| as: ϕ w v

(¯ ) = u

1

.

It is straightforward to verify that ϕ w v chosen element of |B

′ p ment of |B

′

|.

is a homomorphism from B

Observe that there exists a homomorphism from B

′ p to B

′

′ p to B

′ which maps any

| whose coordinates are all distinct to any chosen ele-

.

We construct the σ

′

-structure A

′′ as follows. First, fix some element

¯ ∈ |B

′ p

| for which all the components are distinct. Define:

• |A

′′

| = |A

′

| × |B

′ p

|;

• for each i ∈ {1, 2, . . . , k}, C

′

C i

A

(w) holds; i

A

′′

((w, ¯ )) holds if, and only if, ¯ = ¯ and

• for each i ∈ {1, 2, . . . , l} and for any (w

F

F i

A i

A

′′

′

((w

1

,

¯

1

), (w

2

,

¯

2 v

1

(w

1

, w

2

) holds) or (w

1

= w

2 and F i

B

′ p

(¯

1

, ¯

1

2

, ¯

1

), (w

2

, ¯

2

) ∈ |B

= ¯

2

) holds); and

= ¯

′′

|, and

24

• for every i ∈ {1, 2, . . . , m} and for any (w

|A v

2

′′

|, R

A i

′′

((w v a

1

,

¯

1

= ¯

), (w

2

,

¯ and R

2

A

′ i

), . . . , (w

(w

1

, w

2 a

,

¯ a

, . . . , w

1 a

,

¯

1

), (w

2

,

¯

2

), . . . , (w a

,

¯ v a

1

) ∈

=

) holds (where a is the arity of R i

).

The structure A

′′ can be depicted in Fig. 3, where the relations C i and R are omitted and an arrow labelled i from one vertex to another denotes that i the associated pair of vertices is in the binary relation F i substructure of A

′′ induced by the set of elements |A

′

. Note that the

| × {¯ } is isomorphic to A

′

.

form (*w*, *v*)

*i i j i i j j*

copies of B*'*

*p*

Figure 3. The σ

′

-structure A

′′

.

Suppose that there is a homomorphism from A

′ to B

′

. Then this homomorphism can be extended to a homomorphism of A

′′ to B

′ by utilizing the observation at the end of the paragraph in which the construction of B

′ p detailed. Conversely, if there is a homomorphism from A

′′ to B

′ is then the restriction of this map to the set of elements |A

′

|×{¯ } yields a homomorphism from A

C i

A

′′

Suppose that w

1

(w

′

2 to B

′

. So, A

′

∈ CSP(B

, w

2

∈ |A

′′

′

) if, and only if, A

| are such that w

1

′′

6= w

2

∈ CSP(B

′

).

and both C i

A

′′

(w

1

) and

) hold, for some i ∈ {1, 2, . . . , k}. The structure obtained from A

′′ by identifying w

1 and w

2 is such that there is a homomorphism to B only if, there is homomorphism from A

′′ to B

′

(as B

′

′ if, and has been derived from

B by ‘converting’ the constants and functions into relations mirroring these constants and functions). Suppose that w

1 w

3 and both F i

A

′′

(w

1

, w

2

) and F i

A

′′

(w

1

, w

3

, w

2

, w

3

∈ |A

′′

| are such that w

2

6=

) hold, for some i ∈ {1, 2, . . . , l}.

25

The structure obtained from A is a homomorphism to B

′

′′ by identifying w

2 and w

3 is such that there if, and only if, there is homomorphism from A

′′ to B

′

. By repeatedly identifying vertices (if necessary) as above, we may assume that A

′′ one element in C is such that: for every i ∈ {1, 2, . . . , k}, there is exactly i

A

′′

; and for every i ∈ {1, 2, . . . , l} and for every w there is exactly one element w

2

∈ |A

′′

| such that F i

A

′′ let A be the σ-structure obtained from A

′′

(w

1

, w

2

1

∈ |A

′′

|,

) holds. Finally, in the natural way. Clearly,

A

′′

∈ CSP(B from A

′

′

) if, and only if, A ∈ CSP(B). Moreover, A can be constructed in time polynomial in the size of A

′

.

Conversely, let A be a σ-structure. Let A

′ be the σ

′

-structure obtained from A in the natural way. Clearly, A ∈ CSP(B) if, and only if, A

′

∈

CSP(B

′

); and A

′ can be constructed from A in time polynomial in the size of A. The result follows.

A corollary of Theorems 10 and 13 is that ∆(σ : relational) ≡ ∆(λ

2

).

Now let us turn to non-uniform constraint satisfaction problems CSP(T ) where the λ

2

-structure T is bipartite and where the g-digraph is a single directed cycle. For any such λ

2

-structure T , let us define a λ

3 where λ

3 consists of the unary function symbols f , g

1 and g

2

, with the property that both g

1 and g

2 are matchings. Let T

1 and T

2 form the bipartition g

T

1

(g

T

(x

1

)) = x

1

; if x

2

T is |T |; if x

∈ T

2 then g

T

2

1

∈ T

1

(x

2

) = g

T then g

T

1

(x

2

(x

1

) = g

), with g

T

2

(g

T

T

(x

1

), with

(x

2

)) = x

2

; and f is defined identically to f

T

. The problem Hom-Alg

3

Theorem 14 Let

T be a λ

2

-structure that is bipartite and whose g-digraph is a directed cycle. The problem Hom-Alg

2

(T ) is polynomial-time Turingequivalent to the problem Hom-Alg

λ

2

3

-structure

T with the property that Hom-Alg

2

(T ) is complete for NP via polynomial-time Turing-reductions.

Proof

Let S be a λ

3

-structure. We may clearly assume that S is bipartite

(as otherwise S 6∈ Hom-Alg

3 connected component in turn). Furthermore, just as we did in the proof of Corollary 12, we may assume that g

S

1 and g

S

2 are matchings. Fix some element u ∈ |S|. First, we shall ascertain (using an oracle for Hom-Alg whether there is a homomorphism from S to ˜

2

(T ))

T where u is mapped to an element of T

1 looking for a homomorphism mapping u to an element of T

2

).

We begin by constructing a λ

2

-structure F u

. Begin with the domain |S|

26

exists) takes u to an element of T

1

. As S is connected and bipartite, we can now determine which side of the bipartition every element of |S| is mapped to. If w ∈ |S| maps to T

1 then we define g

F u define g

F u

(w) = g

S

2

(w). The function f

F u

(w) = g

S

1

(w); otherwise we is identical to f

S

. Trivially, ϕ is

1 if, and only if, ϕ is a homomorphism from F u that g

S

1 and g

S

2 are matchings.

to T mapping u to an element of T

For every v ∈ T

1

, form the structure F u

+ T v

1

(recall by taking disjoint copies of F u and T and identifying the elements u ∈ |F u

| and v ∈ |T |. Note that this yields a ‘structure’ where the functions f and g have multiple values; and any homomorphism from F u

+ T v to T , say, must respect all functional identities (as in the proof of Corollary 12).

Suppose that F u

→ T where u is mapped to an element v ∈ T

1

. Then

F u

+ T v

→ T . Conversely, suppose that ψ : F u

+ T v

→ T , for some v ∈ T

1

.

Suppose further that the element u of F u

+ T v

(that is, the element resulting from the identification) is mapped under ψ to an element of T

2

. Thus, ψ restricted to the copy of T in F u

+ T v is a homomorphism of T to T taking every element of T

1 to T

2 and vice versa. Hence, by composing maps we get that there is a homomorphism of F and so F u u

+ T v to T taking u to an element of T

1

;

→ T where u is mapped to an element of T

1

. Hence, F u

→ T where u is mapped to an element of T

1 if, and only if, F u

+ T v

→ T , for some v ∈ T

1

.

Just as we did in the proof of Corollary 12, we resolve the multiple values of any F u

+ T v by repeatedly identifying any multiple values until the functions f and g become single-valued. We denote the resulting λ

2

structure by F u

(T v

). Just as in Corollary 12, there is a homomorphism from

F u

+ T v to T if, and only if, there is a homomorphism from F u

(T v

) to T .

Hence, there is a polynomial-time Turing-reduction from Hom-Alg

3

Hom-Alg

2

(T ).

Conversely, let F be a λ

2

-structure. Again, we can assume that F is connected and bipartite. We proceed as we did above and fix some element u

∈ |F|. We shall ascertain whether there is a homomorphism from F to

T where u is mapped to an element of T

1

. This time, we construct a λ

3

structure S g f

S u

1

S u

(w) = g u

F

. If w ∈ |F| maps to an element of T

1 in T then we define

(w); otherwise we define that g is identical to f

F

S u

2

(w) = g

F

(w). The function

. This only partially defines the functions g

1 and g

2 of

S u

. Nevertheless, it is straightforward to see that there is a homomorphism

F to T where u is mapped to an element of T

1 homomorphism S u if, and only if, there is a

T where u is mapped to an element of T

1

. However, by proceeding as we did in the proof of Theorem 13 (where we built the

27

structure A call it S u

′′ from A

′ and B

′

), from S also, where the functions g

1 u and g

T we can build a λ

3

-structure,

2 are fully defined and where: there is a homomorphism from the partially defined S u mapped to an element of T

1 the fully defined S u if, and only if, there is a homomorphism from

T where u is mapped to an element of T

1

.

Let v ∈ T

1

. Just as we did above, we can form the structure S u

+ ˜ v by

T |. Again, the functions g

1 and g

2 of S u

+ ˜ v may have multiple values and again we use our process of identification to yield the structure S u

T v

). Reasoning as above yields that there is a polynomial-time Turing-reduction from Hom-Alg

By Corollary 12, there exists a bipartite λ

2

2

(T ) to Hom-Alg

-structure F

′

3 for which the function g is a matching and for which Hom-Alg

2

(F

′

) is complete for NP via polynomial-time Turing reductions. Define the bipartite λ

3 from F

′ by setting: |S| = |F such that the g there exists a λ

2

S

1

′

|; f

S

-graph and the g

S

2

= f

F

′

; g

S

1

F

′

-graph form a single cycle. By above,

-structure F such that: the g

= g

F

; and g

S

2

-structure S is a matching

-digraph is a directed cycle;

2

(F) and Hom-Alg

3

(S) are polynomial-time Turingequivalent.

An instance of the problem Hom-Alg

2

(F lem Hom-Alg

3

(S) where the function g

2

′

) is an instance of the probis not defined. As above, we can modify this instance so that g

2 is defined and there is a homomorphism from this amended instance to S if, and only if, there is a homomorphism from the original instance to S. Hence, Hom-Alg

3

(S) is complete for NP via polynomial-time Turing-reductions; and so Hom-Alg

2

NP via polynomial-time Turing-reductions.

(F) is complete for

Theorem 14 is a general result that relates non-uniform constraint satisfaction problems with templates λ

2

-structures in which one of the unary functions is a cycle with non-uniform constraint satisfaction problems with templates λ

3

-structures in which two of the unary functions are matchings.

It also tells us that even when we restrict our template T in the problem

Hom-Alg

2

(T ) so that it is bipartite and its g-digraph is a directed cycle, the resulting problem can still be complete for NP via polynomial-time

Turing-reductions (note that we make no statement as regards the degree of difficulty of the problem ∆(λ

2

: bipartite, g-digraph a directed cycle)). In fact, we can restrict the size of T to be as small as possible and, further, obtain a complete problem for NP via polynomial-time reductions.

Corollary 15 There exist λ

2

-structures

T and ˆ

28

• |T | = 3, the g-digraph is a directed cycle, the f -digraph is connected and Hom-Alg

2

(T ) is NP-complete; and

T | = 6, the g-digraph is a directed cycle, the f -digraph is connected,

T is bipartite and Hom-Alg

2

Proof Define the λ

2

-structure T to have: domain {0, 1, 2}; function f defined as f

T

(0) = 1, f

T

(1) = 0 and f

T

(2) = 0; and function g

T

T defined as g

T

(0) = 1, g

T

(1) = 2 and g possible values for (f

T

T

(x), f

(2) = 0. Note that for any element x ∈ |T |, the

T

(g

T

(x)), f

T

(g

T

(g

T

(x)))) are (1, 0, 0), (0, 1, 0) and (0, 0, 1), when x is 0, 2 and 1, respectively.

Consider the problem 1-in-3-SAT, defined over the signature σ

3

= hRi, where R is a relation symbol of arity 3: an instance is a σ

3

-structure A, which is viewed as a collection of clauses of 3 distinct boolean variables via

{X i

, X j

, X k

} is a clause if, and only if, R

A

(i, j, k) holds, where i 6= j 6= k 6= i ; and a yes-instance is an instance for which there is a truth assignment making exactly one of the 3 boolean variables in each clause true. This problem is NP-complete [19].

C

1

Suppose we are given an instance A of 1-in-3-SAT where the clauses are

, C

2

, . . . , C f and g over m over the boolean variables X

1

, X

2

, . . . , X n

. Define functions

{1, 2, . . . , m} ∪ { ˙1, ˙2, . . . , ˙n} ∪ S, where S is as yet undefined, as follows. For each: i ∈ {1, 2, . . . , m}: if clause C i

= {X a (i)

, X b (i)

, X c (i)

} then define f and g such that f (i) = ˙ b (i); and f (g(g(i))) = ˙

The set S is chosen so as to facilitate these conditions. In more detail,

S = {r i

, s i

: i = 1, 2, . . . , m} and for each i = 1, 2, . . . , m:

• g(i) = r i

; f (r i

• g(r i

) = s i

; f (s i

) = ˙ and f (u) = u and g(u) = u, for any as yet undefined u. Denote by F the

λ

2

-structure whose functions f and g are as defined above.

Suppose that ϕ : {X

1

, X

2

, . . . , X n

} → {0, 1} is a satisfying truth assignment for the instance A of 1-in-3-SAT. Define the function ψ from

{1, 2, . . . , m} ∪ { ˙1, ˙2, . . . , ˙n} ∪ S to {0, 1, 2} as follows.

29

• For each i ∈ {1, 2, . . . , m}:

– if (ϕ(X a

(i)

), ϕ(X b

(i)

), ϕ(X c

(i)

)) = (1, 0, 0) then ψ(i) = 0;

– if (ϕ(X a (i)

), ϕ(X b (i)

), ϕ(X c (i)

)) = (0, 1, 0) then ψ(i) = 2;

– if (ϕ(X a

(i)

), ϕ(X b

(i)

), ϕ(X c

(i)

)) = (0, 0, 1) then ψ(i) = 1.

• For each i ∈ {1, 2, . . . , m}:

– ψ

(r i

) = g

T

(ψ(i));

– ψ

(s i

) = g

T

(g

T

(ψ(i))).

• For each j ∈ {1, 2, . . . , n}, ψ(˙j) = ϕ(X j

).

We claim that ψ is a homomorphism from F to T .

Suppose that the truth assignment ϕ is such that

(ϕ(X a

(i)

), ϕ(X b

(i)

), ϕ(X c

(i)

)) = (1, 0, 0).

Consider the identity f

F

(i) = a

˙

T

(ψ(i)) = f

T

(0) = 1; and

ψ ( ˙ a

(i)

) = 1. Similarly, all other functional identities can be so verified. A similar analysis follows should the truth assignment ϕ be such that (ϕ(X a (i)

), ϕ(X b (i)

), ϕ(X c (i)

)) is (0, 1, 0) or (0, 0, 1). Thus, ψ : F → T .

Conversely, suppose that ψ : F → T . Define the truth assignment ϕ : {X

1

, X

2

, . . . , X n

} → {0, 1} by:

• ϕ(X a

(i)

) = 1 if ψ(i) = 0, and 0 otherwise;

• ϕ(X b

(i)

) = 1 if ψ(i) = 2, and 0 otherwise;

• ϕ(X c (i)

) = 1 if ψ(i) = 1, and 0 otherwise.

The map ϕ is clearly well-defined and a satisfying truth assignment for the instance A. Hence, Hom-Alg

2

(T ) is NP-complete.

Let A be an arbitrary λ

2

-structure. Define the λ

2

-structure ˆ

A| = {x : x ∈ |A|} ∪ {ˆ : x ∈ |A|};

• if f

A

(x) = y then f (x) = ˆ and f (ˆ ) = y, for x ∈ |A|; and

• if g

A

(x) = y then g (x) = ˆ and g (ˆ ) = y, for x ∈ |A|.

30

For any x ∈ |A|, ˆˆ denotes the element x.

Suppose that ψ : A → T . Define the map ˆ : | ˆ and ˆ x

) =

ψ

ˆ

T | by ˆ

A| be such that f

(x) = ψ(x)

(x) = y. Then either x ∈ |A| and y = ˆ u

, for some u ∈ |A|, and f

A

(u) = y ∈

|A|. In the former case, as ˆ (x) = ψ(x) ∈ |T |, we have that f

ˆ

ˆ

ψ

ˆ

ψ

(ˆ

ψ

(y). In the latter case, f

A

( ˆ (x)) =

(u) = y ∈ |A|; and so f

T

(ψ(u)) = ψ(y). Thus, f ( ˆ (ˆ )) = ˆ (y); that is, f ( ˆ ψ (y). The case for when g

ˆ

: ˆ

Conversely, suppose that ˆ : ˆ

(x) = y is identical; and so we have maps elements of |A| to elements of |T |; and when ˆ maps elements of

{ˆ : x ∈ |A|} to elements of |T |. Let us consider the first case. Define

ψ

: |A| → |T | by ψ(x) = ˆ (x). Let x, y ∈ |A| be such that f

A

(x) = y. So, f

(ˆ ) = y and f

Thus, f

T

( ˆ (ˆ )) = ˆ (y). But f (x) = ˆ

(ψ(x)) = ψ(y). The situation when g

A and so f ( ˆ (x)) = ˆ

(x) = y is similar.

(ˆ ).

Alternatively, when ˆ x : x ∈ |A|} to elements of

|T |, we define ψ(x) =

ˆ

ˆ

A

(x) = y. So, f

ˆ

ˆ

(x) = ˆ

ψ

(ˆ and f (ˆ

But as ˆ x ) ∈ |T |, f

) = y, with f

( ˆ

ψ x )) =

ˆ

ˆ

(x) 6∈ |T |, f

( ˆ (x)) = ˆ (ˆ ) and f x ); and so

(

ˆ

ˆ

ˆ

ˆ x ) = ˆ (y) with ψ(y) =

ψ

(x); so f

T

( ˆ (ˆ )) = ˆ (y).

(

ˆ

ˆ

ψ

(ˆ ) with f

T

(ψ(x)) = ψ(y). The situation when g

A

(x) = y is similar. Hence,

ψ

: A → T and consequently, Hom-Alg

2 follows.

We stated prior to Corollary 15 that this corollary was optimal in terms

Lemma 16 Let ˆ

2

-structure of size

4 whose g-digraph is a directed cycle. The problem Hom-Alg

2

Proof

Let ˆ

2

-structure of size 4, with domain {0, 1, 2, 3}, and whose g-digraph is the directed cycle (0, 1, 2, 3). Let A be an arbitrary

λ

2

-structure. Without loss of generality, we may assume that A is connected

(otherwise we handle each connected component separately). Furthermore, tion of T every element of |A| must map to under ϕ (if we can determine, in

31

polynomial-time, whether such a homomorphism exists then this will clearly suffice to yield the result).

We shall build a set of clauses, C, corresponding to A, each clause consisting of 2 Boolean literals. The underlying set of Boolean variables is

{X v

: v ∈ |A|}. For every instantiation g

A

(v, w), where v, w ∈ |A|, include clauses in C as follows.

(a) If ϕ(v) ∈ {0, 2} then include the clauses {¬X v

, X w

} and {X v

,

¬X w

} in C.

(b) If ϕ(v) ∈ {1, 3} then include the clauses {¬X v

,

¬X w

} and {X v

, X w

} in C.

Suppose that ψ is a satisfying truth assignment for the resulting set of clauses

C . Suppose further that v is such that ϕ(v) ∈ {0, 2} (resp. ϕ(v) ∈ {1, 3}): if ψ(X v

) is true then we interpret this as dictating that ϕ(v) = 0 (resp.

ϕ

(v) = 1); and if ψ(X v

) is f alse then we interpret this as dictating that ϕ

(v) = 2 (resp. ϕ(v) = 3). If g

A

(v, w) holds then the fact that ψ is a satisfying truth assignment ensures that g (ϕ(v), ϕ(w)) holds. Extending C by similarly including clauses for every instantiation of the form f

A

(v, w) yields that if the resulting set of clauses C is satisfiable then there is homomorthen this homomorphism can be translated, using our interpretation above, into a satisfying truth assignment for C. Thus, the problem Hom-Alg

2 can be reduced, in polynomial-time, to the problem of whether a collection of clauses of size 2 is satisfiable, which is well-known to be solvable in polynomial-time (see, for example, [16]). The result follows.

## 6 Reversing problems

We have seen so far that even restrictions of the problem ∆(λ

2

) can be as hard to resolve as the (very general) problem ∆(σ : σ relational). In this section, we prove a dichotomy result for the class of non-uniform constraint satisfaction problems with template a pair of unary functions one of which is the reverse of the other.

Recall that the digraph of a unary function, f , say, consists of a directed cycle with pendant in-trees. Suppose that the unary function g is such that its digraph is obtained from that of f by reversing the directions of the edges of the directed cycle and leaving all other edges as they are. Then we say that g is the reverse of f . If T is a λ

2 of g

T then the problem Hom-Alg

2

-structure for which f

T is the reverse

(T ) is called a reversing problem.

32

When the unary functions f and g are the reverse of one another, for any element u on the directed cycle in the digraph of f (or g), define the height of u to be the length of the longest path ending at u but so that no element on this path apart from u lies on the directed cycle (there are similarities between the height of u and the values δ f

(u) and δ g

(u) from the proof of

Proposition 9).

Theorem 17

The problem CSP (T ) can be solved in polynomial-time when

T is a structure over a signature containing only constant symbols and unary function symbols, so long as

:

(a) every unary function of T has a digraph that is a disjoint union of directed cycles ;

(b) there is one unary function symbol in the signature; or

(c) there are two unary function symbols, f and g, in the signature, and the functions f

T and g

T are the reverse of one another such that the corresponding directed cycles, (t

0

, t

1 length

4 and either :

, t

2

, t

3

) and (t

3

, t

2

, t

1

, t

0

), have

– the height of each t i is at most 1; or

– t

0 and t

2 have height at most

2 and t

1 and t

3 have height

0.

Proof

(a) Let T be over the signature σ consisting of a number of unary function symbols and constant symbols, where every unary function has a digraph that is a disjoint union of directed cycles. Let A be a σ-structure and fix some element u ∈ |A|. Suppose that there is a homomorphism ϕ : A → T taking u to t, for some t ∈ |T |. This fixes the value (under ϕ) of each element in the connected component of the digraph A containing u

; and it is straightforward to check whether the resulting map is indeed a homomorphism (of this connected component of the digraph A: how we consider A as a digraph, and the notion of connected component, should be clear given the definitions prior to Lemma 8). We do this for each element t

∈ |T | and for each connected component of A to obtain our polynomialtime algorithm.

(b) Let T and A be over the signature σ consisting of one function symbol and a number of constant symbols. The σ-structures A and T are both disjoint unions of directed cycles with pendant in-trees (with possibly additional constants). We take each directed cycle with pendant in-trees in A in turn. Fix some element u ∈ |A| which lies on the directed cycle

33

of some directed cycle with pendant in-trees B. Suppose that there is a homomorphism ϕ : B → T taking u to t, for some t ∈ |T | (and so t must lie on the cycle of some directed cycle with pendant in-trees in T ). This fixes the value of each element in the directed cycle of B. Let us assume that such a partial homomorphism exists. If there are no constants lying on the pendant in-trees in B then it is trivial to determine whether ϕ can extended to a homomorphism of B to T (see the proof of Proposition 2).

Suppose that c

B is a constant lying on some pendant in-tree in B such that in the path from the constant to the root of the in-tree (that is, the element on both the in-tree and the directed cycle) there are no other constants. The map ϕ must take c

B to c

T and whether this is possible can easily be verified. Moreover, if this is possible then the image of every element of

|B| on the path in B from c

B to the root of the pendant in-tree is fixed. If there are no other constants lying on some pendant in-tree in B then the map ϕ can trivially be extended to a homomorphism of B to T .

Let us suppose that d

B is some other constant lying on some pendant in-tree in B such that in the path p from d

B to an element of |B| for which the value under ϕ has already been set, there are no other constants. The map ϕ must take d

B to d

T and whether this is possible can easily be verified.

Moreover, if this is possible then the image of every element of |B| on the path p in B is fixed. We continue similarly with other constants in B until either we obtain a homomorphism of B to T or we show that one cannot exist. We repeat the above for each element t ∈ |T | and for each directed cycle with pendant in-trees of A to obtain our polynomial-time algorithm.

(c) Let T be over the signature σ consisting of the unary function symbols f and g and a number of constant symbols. Suppose further that f

T and g

T are the reverse of one another where the corresponding directed cycles are (t

0

, t

1

, t

2

, t

3

) and (t

3

, t

2

, t

1

, t

0

), respectively, and the height of each t i is at most 1. Let A be some σ-structure and let B be the connected component of the digraph A containing some fixed element u ∈ |A| which lies on a cycle in the digraph A (B may also have some constants). Suppose that there is a homomorphism ϕ : A → T taking u to t i

, for some i ∈ {0, 1, 2, 3}.

Either such a ϕ can easily be verified not to exist or the values under ϕ of the elements of |B| with non-zero in-degree are fixed. Let us assume that such a partial homomorphism exists.

Take elements v, w ∈ |B| of in-degree 0. As to whether the partial homomorphism ϕ can be extended to |B| ∪ {v} is independent from whether the partial homomorphism ϕ can be extended to |B| ∪ {w}, since the values ϕ

(f

B

(v)), ϕ(g

B

(v)), ϕ(f

B

(w)) and ϕ(g

B

(w)) are fixed. Hence, we can efficiently verify whether the homomorphism ϕ exists. We repeat the above for

34

each element t i

, for i = 0, 1, 2, 3 (with u fixed), and for each connected component of A (with suitably chosen fixed element) to obtain our polynomialtime algorithm.

Now suppose that instead of every t i i

= 0, 1, 2, 3, t

0 and t

2 having height at most 1 in T , for have height at most 2 and t

1 and t

3 have height 0.

Let A be some σ-structure, and let B be the connected component of the digraph A containing some fixed element u ∈ |A| which lies on a cycle in the digraph A (B may also have some constants). Suppose that there is a homomorphism ϕ : A → T taking u to t i

, for some i ∈ {0, 1, 2, 3}. Either such a ϕ can easily be verified not to exist or the values under ϕ of many of the elements of |B| are effectively fixed (using simple reasoning, like if ϕ (v) = t

1 and f

B

(w) = v then ϕ(w) = t

0

). Let us assume that such a partial homomorphism exists.

Let F ⊆ |B| be the set of elements whose values under ϕ are fixed. Note that given v, v

′

, v

′′

∈ |B| \ F , it cannot be the case that v, v

′ and v

′′ are all distinct and (v, v

′

) and (v

′

, v

′′

) are edges in the digraph B (as this would mean that the value ϕ(v

′′

) is effectively fixed). So, partition |B| \ F into the disjoint sets: L

1 g

B

, consisting of those elements v for which either f

(v) is in F ; and L

2

B

(v) or

, consisting of those elements v for which neither f

B

(v) nor g

B

(v) is in F .

Suppose that v ∈ L

1

. Note that either f

B

(v) 6∈ F or g

B

(v) 6∈ F (as otherwise the value of ϕ(v) would effectively be fixed). Suppose, for example, that f

B

(v) ∈ F . Then it must be the case that ϕ(f

B

(v)) ∈ {t

0

, t

2

}. If ϕ

(f

B

(v)) = t

0 then ϕ(v) must either be t

3 or in the pendant in-tree with root t

0

(where there is an edge (ϕ(v), t

0

) in the digraph T ); and if ϕ(f

B

(v)) = t

2 then ϕ(v) must either be t

1 or in the pendant in-tree with root t

2

(where there is an edge (ϕ(v), t

2

) in the digraph T ). In the former case, label v with the set {t

3

, p

0

}; and in the latter case, with the set {t

1

, p

2

}. Do likewise for every element of L

1

: the label sets are drawn from {t

3

, p

0

}, {t

1

, p

2

}, {t

3

, p

2

} and {t

1

, p

0

}. Note that this process might even enable us to deduce that the partial homomorphism ϕ cannot be extended to a full homomorphism

(assume in the following that this is not the case).

As B must necessarily be bipartite if there is a homomorphism to T , we may assume that there are no functional relationships between the elements of L

1

. Hence, we may assume that in the digraph B, there is an edge from every element of L

1 to an element of L

2

. In the same vein, we may assume that there are no functional relationships between elements of L

2

; and so both f

B

(v) and g

B

(v) are in L

1

, for every element v ∈ L

2

.

We shall now construct a conjunction π of clauses of at most 2 literals

(over a set of boolean variables) in such a way that π is satisfiable if, and only

35

if, the partial homomorphism ϕ can be extended to a full homomorphism from B to T . Suppose that the element v ∈ L

{t

3

, p

0

}, for example. Then the clauses

1 is labelled with the set

{t v

3

, p v

0

} and {¬t v

3

,

¬p v

0

} are clauses in the conjunction; and we add clauses likewise for every labelling of every element of L

1

. Note that any truth assignment satisfying both

{t v

3

, p v

0

} and {¬t v

3

,

¬p v

0

} makes exactly one of t v

3 and p interpret as meaning that element v is mapped to t

3 v

0 true ; which we will or an element in the pendant in-tree with root t

0

(where there is an edge (ϕ(v), t

0

)).

Let v ∈ L

1 and g

B be such that, for example, v is labelled with the set {t

(v) = w, where w ∈ L

2

. Include in π the clauses

3

, p

0

}

{¬t v

3

, t w

2

}, {¬p v

0

, t w

0

}, {t w

2

, t w

0

} and {¬t w

2

,

¬t w

0

} to reflect the facts that: if v maps to t

3 then w must map to t

2

; if v maps to an element in the pendant in-tree with root t

0

(ϕ(v), t

0

)) then w must map to t

0

(where there is an edge

; and v must map to either t

0 or t

2

. Do likewise for every edge in the digraph B from an element of L

1 to an element of L

2

.

Let v ∈ L

2 be such that, for example, g

B

(v) = w, where w ∈ L is labelled with the set {t

3

, p

0

}. Include in π the clauses

1 and w

{¬t w

3

, t v

0

}, {¬p w

0

, q v

0

}, {t v

0

, q v

0

} and {¬t v

0

,

¬q v

0

} to reflect the facts that: if w maps to t

3 then v must map to t to an element in the pendant in-tree with root t

0

0

; if w maps

(where there is an edge

(ϕ(v), t

0

)) then v must map to an element in the pendant in-tree with root t

0

(where there is a path of length 2 to the root t either t

0

0

); and v must map to or an element in the pendant in-tree with root t

0

(where there is a path of length 2 to the root t

0

). Do likewise for every edge in the digraph

B from an element of L

2 to an element of L

1

.

Finally, if the pendant in-tree in T with root t

0

(resp. t

2

) has height

0 then assign every boolean variable of the form p v

0 q t v

2

2 q v

2 and q v

0

(resp. p

) the value f alse; and if the pendant in-tree in T with root t

) has height 1 then assign every boolean variable of the form q

0 v

0 v

2 and

(resp.

(resp.

) the value f alse (this restricts the maps allowed). Denote the resulting conjunction by π.

Let s

0 be an element in T in the pendant in-tree with root t

0 for which

(s

0

, t

0

) is an edge in the digraph T (if such an element exists); and let r

0

36

be an element in T in the pendant in-tree with root t

0 for which (r

0 an edge in the digraph T (if such an element exists). Nodes s

2

, s and r

2

0

) is are defined likewise.

Suppose that there is a satisfying truth assignment of π. Interpreting this truth assignment as described above, except that if p v

0

(p v

2

, q v

0

, q v

2

) is set at true under this assignment then map the element v to the element s

0

(resp. s

2

, r

0

, r

2

), yields an extension of our partial homomorphism ϕ which obeys all functional dependencies in B, i.e., a homomorphism from B to T .

Conversely, suppose that there is an extension of our partial homomorphism ϕ to a homomorphism from B to T . Then there exists an extension of our partial homomorphism ϕ to a homomorphism ϕ

′ from B to T so that all elements of |B| \ F that are mapped to an element of |T | \ {t

0

, t

1

, t

2

, t

3

} are mapped to one of the elements of {s

0

, s

2

, r

0

, r

2

} (this is because the constants in B and T have to real role to play as to whether an extension of ϕ exists or not). Consequently, such a homomorphism ϕ

′ immediately translates into a satisfying truth assignment of π. As the satisfiability problem for clauses of size at most 2 is solvable in polynomial-time (see, for example, [16]), as to whether there is a homomorphism from B to T , taking u to t i

, can be decided in polynomial-time. We repeat the above for each element t i

, for i

= 0, 1, 2, 3 (with u fixed), and for each connected component of A (with suitably chosen fixed element) to obtain our polynomial-time algorithm.

It turns out that the reversing problems not covered by Theorem 17 are

NP

-complete (via polynomial-time reductions).

Theorem 18 The problem Hom-Alg

2

(T ), where f

T and g

T are the reverse of one another, is NP-complete if one of the following conditions holds :

(a) the directed cycles (t

0 ing to f

T and g

T

, t

1

, . . . , t l−

1

) and (t l−

1

, respectively, are such that t

, t l−

2

0

, . . . , t

0 has height

) correspond-

1 and either l

= 3 or l ≥ 5;

(b) the directed cycles (t

0 and g

T

, t

1

, t

2

, t

3

) and (t

, respectively, are such that t

0

3

, t

2

, t

1

, t

0 has height

) corresponding to f

3; or

T

(c) the directed cycles (t

0 and g

T

, t

1

, t

2

, t

3

) and (t

, respectively, are such that t

0

3

, t

2

, t

1

, t has height

0

) corresponding to f

2 and t

1

T has height at least 1.

Proof

(a) Consider the retract problem for an undirected cycle of length l

, RETCYC(l) for short, where: an instance is an undirected graph G and a

37

subgraph H, a cycle of length l; and a yes-instance is an instance for which there is a homomorphism ϕ from G to H such that ϕ(u) = u, for every vertex of the cycle C. This problem is known to be NP-complete when l = 3 or when l ≥ 5 (the case for cycles of odd length is a special case of the proof of the main result in [11]; and the case for cycles of even length at least 6 can be found in [5]). We shall describe a polynomial-time reduction from

RETCYC(l) to Hom-Alg

2

(T ).

Let (G, H) be an instance of RETCYC(l). We shall construct a λ

2

structure F corresponding to (G, H). Actually, our structure F will be only partially defined; but by proceeding as we did in the proof of Theorem 13, we can obtain a fully defined λ

2

-structure for which there is a homomorphism to T if, and only if, there is a homomorphism from the partially defined structure to T . Take a set S of elements isomorphic to the vertex set of G.

For every element of s ∈ S, introduce l additional elements u and define f (u s i

) = u s

(i+1)mod l s

0

, u s

1

, . . . , u s l−

1

, for each l ∈ {0, 1, . . . , l − 1}. Furthermore, define f (s) = u s

0

(all elements so introduced are distinct). Note that this has the effect that in any homomorphism from the eventual structure F to

T , every element so far introduced must map to t i which f

T

(t) = g

T

(t) = t i or to some element t for

, for some i ∈ {0, 1, . . . , l − 1}.

Let u and v be distinct elements of S. We now detail three constructions to be subsequently used in order to obtain our eventual structure F. Note that in each of these constructions, we introduce additional elements into the domain of F. Using the above construction, we may clearly assume that in any homomorphism from the eventual structure F to T , every such element introduced must map to t i or to some element t for which f

T

(t) = g

T

(t) = t i

, for some i ∈ {0, 1, . . . , l − 1}.

Construction 1 By add the α-edge (u, v) we mean introduce additional elements u

′ and v

′ to |F| and define that g

F

(u

′

) = u, g

F

(v

′

) = v and f

F

(u

′

) = v

′

. This ensures that in any homomorphism from the eventual structure F to T , u and v must map to some t i if t i and t j

, respectively, where: has height 0 then j = (i + 1) mod l is the only possibility; and if t has non-zero height then both j = (i − 1) mod l and j = (i + 1) mod l i are possibilities. Furthermore, any i and j are viable (subject to the above constraints).

Construction 2 Consider the directed cycle (t

0 sponding to f

T

, t

1

, . . . , t l− 1

) in T (corre-

). Suppose that there is a path of length r in this cycle from t i such that some element t case then we say that t i j on this path has height 1. If this is the can r-see an element of height 1. Let r be the smallest non-negative integer with the property that every t i can r-see an

38

element of height 1 but, if r 6= 0, there is some element t j

(r − 1)-see an element of height 1. If r > 0 then fix j

0 which cannot as some index for which t j

0 cannot (r − 1)-see an element of height 1.

By add the β-edge (u, v) we mean introduce additional elements so that there is a path of (r + 1) α-edges from u to some (new) element w, followed by a path of r g-edges from w to v (a g-edge is just a pair of elements u

′ and v

′ for which g

F

(u

′

) = v

′

, and similarly for an f -edge: if r = 0 then u = w).

This ensures that in any homomorphism from the eventual structure F to

T , it is possible for u to map to any t t

(i+1)mod l i and for v to map to t

(i−1)mod l

: furthermore, these are the only two possibilities if i = j that any i and j are viable (subject to the above constraints).

0 and

. Note

Construction 3 By add the γ-edge (u, v) we mean introduce additional sets of elements Γ p so that for every p ∈ {0, 1, . . . , l − 1}: there is an f -edge from a new element u p

0

(new) element w p to u; there is a path of p f -edges from u to some

; followed by a β-edge (w p

, x p

), where x p is a new element; followed by a path of p g-edges from x p a new element v p

0 to v; and there is an f -edge from to v (the different sets Γ p of new elements introduced are disjoint). It is certainly the case that there is a homomorphism from any

γ

-edge to T ; and our construction ensures that in any homomorphism from the eventual structure F to T , u and v must map to some elements t i t j

. However, we can say more.

and

Suppose that u and v map to elements t i and t j

, respectively, in some eventual homomorphism ϕ from the eventual structure F to T . Consider the distinguished element t j

0 w p

∈ Γ p must map to t j

0

. There exists a value p so that the element via ϕ; and consequently, from above, x p must map to either t

(j

0

− 1)mod l or t

(j

0

+1)mod l

, with both these values possible. Thus, v must map to either t

(i−1)mod l or t

(i+1)mod l

, with both these values possible.

That is, either j = (i − 1) mod l or j = (i + 1) mod l; and any i and j are viable (subject to the above constraints).

We now extend F using these constructions (recall that F’s current state is as it was prior to the descriptions of our constructions). For every pair of elements u, v ∈ S for which (u, v) is an undirected edge of G \ H, add the γ-edge (u, v) to F (to be more specific, add either the γ-edge (u, v) or the γ-edge (v, u)). The fact that there is a homomorphism of G to H fixing each vertex of H if, and only if, there is a homomorphism from F to T , is immediate from our constructions; and this, allied with the fact that F can be constructed from (G, H) in polynomial-time, yields the result.

(b) Consider some instance A of the problem 1-in-3-SAT; that is, a collection C

1

, C

2

, . . . , C m of subsets of {X

1

, X

2

, . . . , X n

} of size 3. We shall

39

describe an instance F of Hom-Alg

2 the theorem.

(T ), where T is as in the statement of

There are elements c

0

, c

1

, c

2 and c

3 in |F| for which: f

F

(c

0

) = c

1

; f

F

(c

1

) = c

2

; f

F

(c

2

) = c

3

; and f

F

(c

3

) = c

0

.

There are elements d

0

, d

1 and d

2 for which: f

F

(d

0

) = d

1

; f

F

(d

1

) = d

2

; and f

F

(d

2

) = g

F

(d

2

) = c

0

.

In particular, we may assume that any eventual homomorphism from F to

T must map c

0 to t

0

.

For every i ∈ {1, 2, . . . , m}, there is an element C i elements so that f

F g

F f

F

(C i

) = c

0 in |F| as well as other

(all nodes so introduced are distinct).

This has the effect that in any eventual homomorphism from F to T , the element C i must be mapped to:

(1) an element not in the directed cycle in T but for which in the digraph

T there is a path of length 3 to t the directed cycle apart from t

0

;

0 where no element on this path is in

(2) an element not in the directed cycle in T but for which in the digraph

T there is an edge to t

0

; or

(3) the element t

3

.

For every j ∈ {1, 2, . . . , n}, introduce an element X j to |F|. Fix an ordering on the Boolean variables in each clause in A. If clause C i

= {X i

1

, X i

2

, X i

3

} then introduce additional elements so that: f

F f

F g

F

(C i

) = X i

1

; f

F f

F f

F f

F f

F

(C i

) = X i

2

; and g

F f

F g

F f

F g

F

(C i

) = X i

3

(again, all nodes so introduced are distinct). Note that the resulting λ

2

structure F is partially defined. This does not create any difficulties as, again, by proceeding as we did in the proof of Theorem 13, we can obtain a fully defined λ

2

-structure for which there is a homomorphism to T if, and only if, there is a homomorphism from the partially defined structure to T .

Let ϕ be a homomorphism from F to T ; and let C i

= {X i

1

, X i

2

, X i

3

} be a clause of A, for some i ∈ {1, 2, . . . , m}. From above, there are three different possibilities for ϕ(C i not the clause C i in case (2), (ϕ(X i

1 of A). In case (1), (ϕ(X i

1

), ϕ(X i

2

) (here, C i

), ϕ(X i

3

)) = (t refers to the element C

2

, t

0

), ϕ(X

, t

0 i

2

), ϕ(X i

3 i of |F| and

)) = (t

0

, t

2

, t

); and in case (3), (ϕ(X i

0

1

);

),

40

ϕ

(X i

2

), ϕ(X i

3

)) = (t

0

, t

0

, t

2

). Interpreting t satisfying truth assignment for A.

0 as true and t

2 as f alse yields a

Conversely, if there is a satisfying truth assignment for A then applying reasoning similar to that above yields a homomorphism from F to T . As F can be constructed in polynomial-time, the result follows.

(c) Consider some instance A of the problem 1-in-3-SAT; that is, a collection C

1

, C

2

, . . . , C m of subsets of {X

1 describe an instance F of Hom-Alg

2

(T ), where T is as in the statement of the theorem.

, X

2

, . . . , X n

} of size 3. We shall

There are elements c

0

, c

1

, c

2 and c

3 for which f

F

(c

0

) = c

1

; f

F

(c

1

) = c

2

; f

F

(c

2

) = c

3

; and f

F

(c

3

) = c

0

.

There are elements d

0

, d

1 and d

2 for which f

F

(d

0

) = d

1

; f

F

(d

1

) = g

F

(d

1

) = c

0

; and f

F

(d

2

) = g

F

(d

2

) = c

1

.

In particular, we may assume that any eventual homomorphism from F to

T must map c

0 to t

0

.

For every i ∈ {1, 2, . . . , m}, there is an element C i elements so that g

F f

F

(C i

) = c

0 in |F| as well as other

(all nodes so introduced are distinct). This has the effect that in any eventual homomorphism from F to T , the element

C i must be mapped to:

(1) an element not in the directed cycle in T but for which in the digraph

T there is a path of length 2 to t

0 the directed cycle apart from t

0

; where no element on this path is in

(2) an element not in the directed cycle in T but for which in the digraph

T there is an edge to t

1

; or

(3) the element t

0

.

For every j ∈ {1, 2, . . . , n}, introduce an element X j into |F|. Fix an ordering on the Boolean variables in each clause in A. If clause C i

{X i

1

, X i

2

, X i

3

} then introduce additional elements so that:

= g

F g

F

(C i

) = X i

1

; f

F f

F f

F f

F

(C i

) = X i

2

; and f

F g

F

(C i

) = X i

3

(again, all nodes so introduced are distinct). Note that the resulting λ

2

structure F is partially defined. This does not create any difficulties as, again, by proceeding as we did in the proof of Theorem 13, we can obtain a

41

fully defined λ

2

-structure for which there is a homomorphism to T if, and only if, there is a homomorphism from the partially defined structure to T .

Let ϕ be a homomorphism from F to T ; and let C i

= {X i

1

, X i

2

, X i

3

} be a clause of A, for some i ∈ {1, 2, . . . , m}. From above, there are three different possibilities for ϕ(C i in case (2), (ϕ(X i

1 ϕ

(X i

2

), ϕ(X i

3

)) = (t

2

). In case (1), (ϕ(X

), ϕ(X

, t

0

, t i

2

0

), ϕ(X i

3

)) = (t

0

). Interpreting t

, t

0 i

1

0

), ϕ(X

, t

2 i

2

), ϕ(X as true and t

2 i

3

)) = (t

0

, t

2

, t

); and in case (3), (ϕ(X i

0

1

);

), as f alse yields a satisfying truth assignment for A.

Conversely, if there is a satisfying truth assignment for A then applying reasoning similar to that above yields a homomorphism from F to T . As F can be constructed in polynomial-time, the result follows.

An immediate corollary from Theorems 17 and 18 is the following dichotomy result.

Corollary 19 Every reversing problem is either solvable in polynomial-time or NP-complete.

Proof Consider some reversing problem Hom-Alg

2

(T ). Let l denote the length of the directed cycles corresponding to the unary functions f

T and g

T

.

If l = 1 or l = 2 then f

T and g

T are identical; and part (b) of Theorem 17 yields that our reversing problem is solvable in polynomial-time.

If l = 3 or l ≥ 5 and, further, every element on the directed cycles corresponding to f

T and g

T has height 0 then part (a) of Theorem 17 yields that our reversing problem is solvable in polynomial-time.

If l = 3 or l ≥ 5 and, further, some element on the directed cycles corresponding to f

T and g

T has height greater than 0 then part (a) of

Theorem 18 yields that our reversing problem is NP-complete.

If l = 4 then part (c) of Theorem 17 and parts (b) and (c) of Theorem 18 cover all other cases.

## 7 Adding lists

Consider some structure T . A list in T is a unary relation over |T | (describing a set of elements of |T |). In this section we consider the addition of a list or lists to templates. We shall show that some of our results can be extended when the templates are augmented with lists.

We begin with some definitions. Let H be some digraph. A choice majority function χ is a ternary function on |H| with the property that if

χ (x, y, z) = w and χ(x

′

, y

′

, z

′

) = w

′ then:

42

(i ) if (x, x

′

), (y, y

′

) and (z, z

′

) are edges of H then (w, w

′

) is too;

(ii ) w ∈ {x, y, z}; and

(iii ) if two out of x, y and z are equal to the same value v then w = v.

We can define a choice majority function for structures over arbitrary relational signatures in a similar way (we only remark that every one of the structures relations must satisfy condition (i ) of the definition). A crucial result in what follows will be Theorem 25 of [9] where it is proven that if T is a relational structure which admits a choice majority function then the problem CSP(T ) is uniformly polynomial-time solvable.

Let H be a digraph. We say that H is levelled if we can assign a nonnegative integer lev(v) to each vertex v so that for every edge (u, v) of H, lev

(u) = lev(v) + 1. We call lev(v) the level of v. We say that a levelled digraph is orderly levelled if every vertex v can be assigned an integer ord(v), the order , so that: if u and v are distinct vertices then ord(u) 6= ord(v); and if (u, v) and (u

′

, v

′

) are edges of H with lev(u) = lev(u

′

) and ord(u) < ord(u

′

) then ord(v) ≤ ord(v

′

). We say that a digraph H is almost orderly levelled if there exists an orderly levelled digraph H

′ such that H is obtained from H

′ by identifying two vertices u and v in H

′

, where: u is the unique vertex of

H

′ with lev(u) = 0; and if lev(v) = m, with m > 0, then v has the smallest order from all vertices of level m.

We begin by considering the problem CSP(T ), where T is over the signature consisting of one unary function symbol and an arbitrary number of unary relation symbols; that is, an extension of the scenario studied in

Section 3 (recall that in the absence of any unary relation symbols, CSP(T ) is in L). Actually, the consideration of such a problem CSP(T ) is really an extension of the scenario in part (b) of Theorem 17, as a constant can be modelled as a unary relation containing exactly one element.

Referring to the proof of Theorem 17, one can easily verify that the proofs of parts (a) and (c) of that theorem hold when the signature contains, in addition, an arbitrary number of unary relation symbols (in brief, the proofs of (a) and (c) are based around a systematic construction of a homomorphism, where the homomorphism is incrementally constructed according to ‘deterministic’ reasoning, and the presence of lists just rules out some potential homomorphisms). However, the proof of part (b) of

Theorem 17 does not hold when there are unary relation symbols present.

Nevertheless, it turns out that there is an alternative proof of the analogue to part (b) of Theorem 17 when there are unary relation symbols present.

Theorem 20 Let

H be a digraph.

43

(a) If H is almost orderly levelled then H admits a choice majority function.

(b) If H is the digraph of a unary function f then each connected component of

H is almost orderly levelled.

Consequently, if

T is a σ-structure where σ consists of a unary function and an arbitrary number of unary relations then the problem CSP

(T ) can be solved uniformly in polynomial-time.

Proof

(a) Let H

′ from H

′ be an orderly levelled digraph such that H is obtained by identifying the vertices u and v of H

′

, where u is the unique vertex of level 0, and where lev(v) = m > 0 and v has the smallest order from all vertices of level m. Let us order the set of pairs {(lev(v), ord(v)) : v is a vertex of H

′

} lexicographically. Furthermore, we refer to the sets of vertices whose levels differ by a multiple of m as layers.

Define the function χ(x, y, z) as follows.

(1) If x, y and z are in three different layers then χ(x, y, z) = x.

(2) If exactly two of x, y and z are in different layers then χ(x, y, z) is the value from this pair of values occurring first in the list x, y, z.

(3) If x, y and z are in the same layer then χ(x, y, z) is the value w out of {x, y, z} for which (lev(w), ord(w)) is neither the minimum nor the maximum out of {(lev(x), ord(x)), (lev(y), ord(y)), (lev(z), ord(z))}.

For any triple of vertices (x, y, z) of H

′

, define the type of (x, y, z) as (1), (2) or (3), according to the definition of χ.

We shall now verify that χ is a choice majority function (clearly, it suffices to verify condition (i ) of the definition). Let (x, x

′

), (y, y

′

) and

(z, z

′

) be edges of H

′

. First, note that the type of (x, y, z) is identical to the type of (x

′

, y

′

, z

′

); and that if (x, y, z) and (x

′

, y

′

, z

′

) have type (1) or (2) then trivially (ϕ(x, y, z), ϕ(x

(x, y, z) and (x

′

, y

′

, z

′

′

, y

′

, z

′

)) is an edge of H

′

. Suppose that both

) have type (3). Consider, for example, (x, x

′

) and

(y, y

′

). Suppose that (lev(x), ord(x)) ≤ (lev(y), ord(y)). If lev(x) < lev(y) then trivially lev(x

′

) < lev(y

′

), with (lev(x

′

), ord(x

′

)) < (lev(y

′

), ord(y

′ lev

(x) = lev(y) and ord(x) < ord(y) then, by definition, ord(x

′

) ≤ ord(y

′

), with (lev(x

′

), ord(x

′

)) ≤ (lev(y

′

), ord(y

′

)). If

)). Consequently, (lev(x), ord(x)) ≤

(lev(y), ord(y)) implies that (lev(x

′

), ord(x

′

)) ≤ (lev(y

′

), ord(y

′

)), and so

(χ(x, y, z), χ(x

′

, y

′

, z

′

)) is an edge of H

′

. Thus, χ is a choice majority function for H

′

.

44

Finally, u and v are the two smallest elements of the layer to which they belong, with respect to the lexicographic level/order ordering. Hence, when u and v are identified (to obtain H from H

′

) the above argument applies; and we obtain a choice majority function for H.

(b) Assume that H is connected. Let x be any vertex of H belonging to the unique cycle in the digraph H, which has length m ≥ 1, say, and let y

= f (x) (note that y may be identical to x). Define the digraph H

′ by including a new vertex x

′

, removing the edge (x, y) and including the edge

(x

′

, y ). So, x

′ has in-degree 0 and x has out-degree 0 in H

′

; and H

′ is an in-tree with root x. Define lev(z) to be the depth of any vertex z in the in-tree H

′

(rooted at x); and define ord(z) to be the order z is visited in a breadth-first search of H

′ x

′ starting at the root x, taking care to ensure that has the least order of all vertices whose level is m, where m is the length of the unique cycle. Thus, H

′ is orderly levelled and H is almost orderly levelled.

Now, consider some instance F of the problem CSP(T ), where T is a

σ

-structure and σ consists of a unary function f and an arbitrary number of unary relations. Suppose, for the moment, that the digraphs F and T are both connected (that is, the digraphs described by f

F and f

T are both connected). Let F

1

λ

1 and T

1 be the restrictions of F and T to the signature

= hf i, respectively. By (a) and (b), T

1 is almost orderly levelled and

T

1 admits a choice majority function. By Theorem 25 of [9], if any digraph

H admits a choice majority function then the problem CSP(H

′

), where H

′ is H augmented with an arbitrary number of lists, can be solved in time polynomial in the size of an instance of the problem and also the size of

H. Hence, as to whether there is a homomorphism from F

1 determined in time polynomial in |F

1

| and |T

1

|.

to T

1 can be

There is a homomorphism from F to T if, and only if, there is a homomorphism from every connected component of F to some connected component of T . Thus, we obtain that the problem CSP(T ) can be solved in time polynomial in both the size of the instance and the size of T .

Note that even though we have shown, in Section 3, that Hom-Alg

1

(T ) is in L, we do not know whether the analogous problem where lists are present is in L: all we have been able to show is that it is in P.

The fact that the proof of part (c) of Theorem 17 holds in the presence of lists, and the trivial observation that the proof of Theorem 18 holds in the presence of lists, yield the following corollary.

Corollary 21 Let

T be a structure over the signature consisting of two unary function symbols and an arbitrary number of unary relation symbols,

45

where the two functions of

T are the reverse of one another. The problem

CSP

(T ) is either solvable in polynomial-time or NP-complete. That is, every reversing problem with lists is either solvable in polynomial-time or

NP

-complete.

Note that Theorem 20 can be applied to other classes of digraphs. An unbalanced oriented cycle is a cycle with each edge oriented in some direction but which is not a levelled digraph. It was shown in [5] that unbalanced oriented cycles are almost orderly levelled digraphs. Thus, Theorem 20 and the result from [9] cited in the proof of Theorem 20 yield the following corollary.

Corollary 22 Let

T be a structure over the signature consisting of a binary relation symbol and an arbitrary number of unary relation symbols, where the digraph described by the binary relation is an unbalanced oriented cycle.

The problem CSP

(T ) can be solved uniformly in polynomial-time.

We end this section by considering constraint satisfaction problems with a template T , over some signature σ, but where any instance of the problem is a σ-structure A augmented with a list U u of elements of |T |, for every element of u ∈ |A|. Such an instance is a yes-instance if there exists a homomorphism ϕ : A → T for which ϕ(u) ∈ U u

, for every u ∈ |A|. Essentially, the lists attached to A restrict the set of potential homomorphisms. We denote the above problem by CSP(T + all lists).

A digraph H is N -free if it does not have vertices x, x

′

, y and y

′

, with x

6= x

′ and y 6= y

′

, such that (x, y), (x, y

′

) and (x

′

, y

′

) are edges of H.

Theorem 23 Let

T be over a structure σ which consists of the binary relation symbols H

1

, H

2

, . . . , H r

, where r

≥ 1.

(a) If T admits a choice majority function then the problem CSP (T + all lists ) can be solved in polynomial-time.

(b) If the digraph described by H i

T is N -free, for all i

∈ {1, 2, . . . , r}, and

T does not admit a choice majority function then the problem

CSP

(A + all lists) is NP-complete.

Furthermore, every digraph associated with a unary function is N -free. Consequently, if

T

′ is a structure over the signature consisting of the unary function symbols f

1

, f

2

, . . . , f r then the problem CSP

(T

′

+ all lists) is either solvable in polynomial-time or NP-complete.

46

Proof

(a) This follows immediately from Theorem 25 of [9].

(b) Suppose that for each i ∈ {1, 2, . . . , r}, the digraph described by H i

T is N -free. We shall now define a particular σ-structure F with attached lists

(henceforth, when we refer to F we shall mean F with these attached lists).

The domain of F consists of {(u, v, w) : u, v, w ∈ |T |}.

• If u, v, w ∈ |T | are all distinct then the list associated with the element

(u, v, w) of |F|, that is, U

(u,v,w)

, is defined as {u, v, w}.

• If u, v, w ∈ |T | are such that at least two of {u, v, w} are identical, with this value being x, then the list associated with the element (u, v, w) of |F|, that is, U

(u,v,w)

, is defined as {x}.

• For each i ∈ {1, 2, . . . , r}, if u, v, w, u

′

, v

′

, w

′

∈ |T | then ((u, v, w),

(u

′

, v

′

, w

′

)) ∈ H i

F that if ((u, v, w), (u

′ if, and only if, (u, u

′

, v

′

, w

′

)) ∈ H i

F

), (v, v

′

), (w, w

′

) ∈ H i

T

(note then, since H i

T is N -free, the only pairs in H i

T where the first component is in {u, v, w} and the second component is in {u

′

, v

′

, w

′

} are (u, u

′

), (v, v

′

) and (w, w

′

)).

The construction of F is such that there is a correspondence between the set of homomorphisms from F to T and the set of choice majority functions admitted by T . To see this, note that the list associated with any element

(u, v, w) ∈ |F| contains the potential images of the element (u, v, w) under some choice majority function (see conditions (ii ) and (iii ) of the definition of a choice majority function); and the relations H

F

1

, H

F

2

, . . . , H

F r ensure that condition (i ) of the definition of a choice majority function is adhered to.

There is a straightforward algorithm to determine whether there is a homomorphism from F to T ; and consequently whether T admits a choice majority function. We think of H

F

1

, H

F

2

, . . . , H

F r as describing digraphs super-imposed on the same set of vertices: so, let us denote the resulting underlying undirected graph by G. Our algorithm can be described as a repeated application of the procedure below (until it can no longer be applied).

Take some (u, v, w) ∈ |F|, where u, v and w are all distinct. If there is a path of (undirected) edges in G from (u, v, w) to some vertex (v

′

, v

′

, u

′

)

(resp. (v

′

, u

′

, v

′

), (u

′

, v

′

, v

′

)), where u

′

6= v

′ and where each vertex on the path apart from the last is such that all components are distinct, then remove the element w (resp. v, u) from U

(u,v,w)

.

The algorithm is such that if some list U

(u,v,w) becomes empty, through repeated applications of the above procedure, then the algorithm outputs

47

that no homomorphism exists; otherwise the output is that a homomorphism does exist.

If our algorithm responds that no homomorphism exists then we must verify whether this is truly the case.

There is clearly a sub-tree of G

(not necessarily induced) consisting of three paths from a vertex (u, v, w), where u, v and w are all distinct, to vertices (v

0

, v

0

, u

0

), (v

1

, u

1

, v

1

) and

(u

2

, v

2

, v

2

), where u i

6= v i

, for i = 0, 1, 2, and where these paths may have vertices in common. Any homomorphism ϕ from F to T must be such that ϕ ((v

0

, v

0

, u

0

)) = v

0

; and so if (u

′

, v

′

, w

′

) is the penultimate vertex on the path from (u, v, w) to (v

0

, v

0

, u

0 it cannot be the case that ϕ((u

′

) (hence, u

, v

′

, w

′

)) = w

′

′

, v

′ and w

′ are all distinct) then

, as this would imply that either

(v

′

(u

0

, v

0

, w

′

), (w

′

, u

0

) and (w

) and (v

0

, w

′

′

, v

0

) are in H i

F

) are in H i

F

, for some i ∈ {1, 2, . . . , r}, or (v

0

, v

′

),

, for some i ∈ {1, 2, . . . , r} (and so contradict the fact that the digraph described by each H i

F is N -free). Reasoning similarly back up the path to vertex (u, v, w) yields that it cannot be the case that ϕ((u, v, w)) = w. Analogous arguments for the paths from (u, v, w) to

(v

1

, u

1

, v

1

) and (u

2

, v

2

, v

2

) yield that the algorithm’s response is correct.

Conversely, suppose that our algorithm responds that a homomorphism exists. Then, on termination of our algorithm, the list associated with every vertex is non-empty. Let (u, v, w), (u

′

, v

′

, w

′

) ∈ |F| be such that u, v and w are all distinct and u

′

, v

′ and w

′ are all distinct. Clearly: u 6∈ U

(u,v,w) and only if, u w

6∈ U

(u,v,w)

′

6∈ U

(u ′

,v

′

,w

′ )

; v 6∈ U

(u,v,w) if, and only if, w

′

6∈ U

(u

′

,v

′

,w

′

) if, and only if, v

′

6∈ U

(u ′

,v

′

,w

′ ) if,

; and

. Thus, define the function ϕ from

|F| to T as follows. If (u, v, w) ∈ |F| then define ϕ((u, v, w)) as the first element (with respect to the order u, v, w) from U

(u,v,w) on termination.

This function ϕ is well-defined and, by construction of F, a homomorphism from F to T . Hence, our algorithm correctly determines whether there exists a homomorphism from F to T .

Now suppose that T does not admit a choice majority function. From above, there is a σ-structure H corresponding to the undirected tree in G, alluded to above, which consists of three paths from a vertex (w

0

, w

1

, w

2

), where w

0

, w

1 and w

2 are all distinct (and were formerly called u, v and w), to vertices x

0 u i

= (v

0

, v

0

, u

0

), x

1

= (v

1

, u

1

, v

1

) and x

2

= (u

2

, v

2

, v

2

), where

6= v i

, for i = 0, 1, 2. Amend H so that the list associated with element x

0

(resp. x

1

, x

2

) is {u

0

, v

0

} (resp. {u

1

, v

1

}, {u

2

, v

2

}).

Lemma 24

(a) If ϕ : H → T then:

– ϕ

(x

0

) = u

0

, ϕ

(x

1

) = v

1 and ϕ

(x

2

) = v

2

;

– ϕ

(x

0

) = v

0

, ϕ

(x

1

) = u

1 and ϕ

(x

2

) = v

2

; or

48

– ϕ

(x

0

) = v

0

, ϕ

(x

1

) = v

1 or ϕ

(x

2

) = u

2

.

(b) There exist homomorphisms ϕ : H → T extending the partial maps:

– ϕ

(x

0

) = u

0

, ϕ

(x

1

) = v

1 and ϕ

(x

2

) = v

2

;

– ϕ

(x

0

) = v

0

, ϕ

(x

1

) = u

1 and ϕ

(x

2

) = v

2

; and

– ϕ

(x

0

) = v

0

, ϕ

(x

1

) = v

1 or ϕ

(x

2

) = u

2

.

Proof

(a) Suppose that ϕ : H → T . If ϕ(x i

) = v i

, for some i ∈ {0, 1, 2}, then by arguing as we did above when we proved our algorithm correct, ϕ ((w

0

, w

1

, w

2

)) 6= w i

. Without loss of generality, suppose that ϕ(x

0

) = u

0

.

Let (u

′

, v

′

, w

′

) be the penultimate vertex on the path in G from (w

0

, w

1

, w

2

) to (v

0

H i

F

, v

0

, u

0

). As ϕ is a homomorphism and the digraph described by each is N -free (see also the parenthetical remark made in the definition of

F, above), we must have that ϕ((u

′

, v

′

, w

′

)) = w

′

. Reasoning similarly back up the path to (w

0

, w

1

, w

2

) yields that ϕ((w

0

, w

1

, w

2

)) = w

2

. Hence, again by reasoning as we did when we proved our algorithm correct, we must have that ϕ(x

1

) = v

1 and ϕ(x

2

) = v

2

.

(b) Without loss of generality, suppose that ϕ is a partial map from |H| to |T | such that ϕ(x

(u

′

, v

′

, w

′

0

) = u

0

, ϕ(x

1

) of |H|, define ϕ((u

′

, v

′

) = v

1

, w

′ and ϕ(x

2

)) = w

′

) = v

2

. For any element

. By arguing as we have done previously, this yields a homomorphism ϕ : H → T .

Now, consider the following σ-structure K elements {p i

1

0

. Take the distinct set of

, q i

, z i

: i = 0, 1, 2} and disjoint copies of H as follows.

• For each i ∈ {0, 1, 2}, include a copy of H by identifying the elements: p i and x

0

; q i and x

1

; and z i and x

2

.

• For each i ∈ {0, 1, 2}, include a copy of H by identifying the elements: p

3.

i and x

0

; q i−

1 and x

1

; and z i−

2 and x

2

, where subtraction is modulo

• The list associated with element z

0 is {u

2

}, with all other lists being as in H (and so, for example: the list associated with p

{u

0

, v

0

}; the list associated with q associated with z

1 and z

2 is {u

2

, v

0

2

, q

1

}).

and q

2

0

, p

1 and p

2 is is {u

1

, v

1

}; and the list

Rename the element p

1 with the name y

0 and the element q

2 with the name y

1

. The construction of K

1

0 can be visualized as in Fig. 4.

Lemma 25 (a) If ϕ : K

1

0

→ T then:

49

– ϕ

(y

0

) = u

0 and ϕ

(y

1

) = u

1

; or

– ϕ

(y

0

) = v

0 and ϕ

(y

1

) = v

1

.

(b) There exist homomorphisms ϕ : K

1

0

→ T extending the partial maps:

– ϕ (y

0

) = u

0 and ϕ (y

1

) = u

1

; and

– ϕ

(y

0

) = v

0 and ϕ

(y

1

) = v

1

.

Proof

Throughout we reason as we did earlier and in Lemma 24 but with respect to the different copies of H, which are composed to form K

1

0 using Lemma 24.

, and

*q*

0

*p*

0

*z*

0

*y*

0

*= p*

1

*q*

1 copies of H

*z*

1

*p*

2

*y*

1

*= q*

2

Figure 4. The σ-structure K

1

0

.

*z*

2

(a) Suppose that ϕ : K

1

0

→ T . As ϕ(z

0

) = u

2

, we must have that ϕ (q

1

) = v

1 and ϕ(p

2

) = v

0

(by considering the copy of H corresponding to p

2

, q

1 and z

0

). Also, ϕ(q

0

H corresponding to p

0

, q

0

) = v

1 and z

0 and ϕ(p

).

0

) = v

0

(by considering the copy of

Suppose that ϕ(y

0

) = u

0

. Thus, ϕ(z

1

) = v

2 and ϕ(z

2

) = v

2

. Hence, ϕ (y

1

) = u

1

.

Suppose that ϕ(y

0

) = v

0

. Thus, ϕ(z

1

) = u

2 ϕ

(z

2

) = u

2

).

and ϕ(y

1

) = v

1

(and

(b) Follows by extending the partial maps of part (a) to homomorphisms of K

1

0 to T using Lemma 24.

50

There is an analogous result to Lemma 25 except where: the σ-structure is K

2

1

; the elements of T are {u

1 are y

1 and y

2

, respectively.

, v

1

, u

2

, v

2

}; and the distinguished elements

Let A be an instance of 1-in-3-SAT; that is, a collection of clauses

C

1

, C

2

, . . . , C m of 3 Boolean variables over the set {X

1

, X

2

, . . . , X n

}. Construct the σ-structure B (where every element has an associated list) as follows.

• For every i ∈ {1, 2, . . . , n}, there are elements X i

0

, X i

1 and X i

2

.

• For every i ∈ {1, 2, . . . , n}, introduce a copy of K

1

0 identifying X i

0 with y

0 and X i

1 with y

1

(resp. X i

1 with y

(resp. K

1 and X i

2

2

1

) by with y

2

).

• For every j ∈ {1, 2, . . . , m}, if C j copy of H by identifying X

0 j

0

= {X with x

0

, X j

0

1 j

1

, X j

1

, X j

2

} then introduce a with x

1 and X

2 j

2 with x

2

.

All elements and copies so introduced are distinct (apart from where they are identified) and the lists at each element are inherited from the particular copies of H, K

1

0 and K

2

1

.

The σ-structure B can be visualized as in Fig. 5 where we show the portion of B corresponding to a clause

{X j

0

, X j

1

, X j

2

}.

copy of H

...

*X*

0

*j*

0

...

...

*X*

1

*j*

0

*X*

2

*j*

0 copy of K

*X*

0

*j*

1

1

0

*X*

1

*j*

1

*X*

2

*j*

1

*X*

0

*j*

2

*X*

copy of K

2

1

1

*j*

2

*X*

2

*j*

2

...

Figure 5. The σ-structure B.

Suppose that A is a yes-instance of 1-in-3-SAT; and so there is a satisfying truth assignment ψ, making exactly one variable in every clause true. If, for some i ∈ {1, 2, . . . , n}: ψ(X and ϕ(X i

2

) = u

2 i

) = true then set ϕ(X i

0

; otherwise set ϕ(X i

0

) = v

0

, ϕ(X i

1

) = u

) = v

1

0

, ϕ(X and ϕ(X i

2 i

1

) = u

) = v

2

1

.

Lemmas 24 and 25 yield that the partial map ϕ can be extended to a homomorphism from B to T . Conversely, suppose that there is a homomorphism ϕ from B to T . If, for some i ∈ {1, 2, . . . , n}: ϕ(X ϕ (X i

2

) = u

2 then define ψ(X i

) = true; and if ϕ(X i

0 i

0

) = u

0

, ϕ(X

) = v

0

, ϕ(X i

1 i

1

) = u

1 and

) = v

1 and

51

ϕ

(X i

2

) = v

2 then define ψ(X i

) = f alse (by Lemma 25, this truth assignment ψ is well defined). By Lemma 24, ψ is a satisfying truth assignment.

Consequently part (b) of the theorem follows.

Every vertex in the digraph of a unary function has out-degree 1; and so such a digraph is N -free. The result follows.

Note that, from Theorem 23, whether the problem CSP(T

′

+ all lists) is solvable in polynomial-time or NP-complete is solely determined by whether

T has a choice majority function or not.

## Acknowledgement

The second two authors would like to thank Eric Allender for a useful discussion and guidance.

## References

[1] A.A. Bulatov, A.A. Krokhin and P. Jeavons, Constraint satisfaction problems and finite algebras, Proceedings of 27th International Colloquium on Automata, Languages and Programming, ICALP’

00 (ed. U.

Montanari, J.D.P. Rolim and E. Welzl), Lecture Notes in Computer

Science Vol. 1853, Springer-Verlag, Berlin (2000) 272–282.

[2] A.K. Chandra and P.M. Merlin, Optimal implementation of conjunctive queries in relational databases, Proceedings of 9th ACM Symposium on

Theory of Computing

(1977) 77–90.

[3] J. Diaz, M. Serna and D.M. Thilikos, The complexity of restrictive

H

-coloring, Discrete Applied Mathematics, to appear.

[4] M. Dyer and C. Greenhill, The complexity of counting graph homomorphisms, Random Structures and Algorithms 17 (2000) 260–289.

[5] T. Feder, Classification of homomorphisms to oriented cycles and of kpartite satisfiability, SIAM Journal of Discrete Mathematics 14 (2001)

471–480.

[6] T. Feder and P. Hell, List homomorphisms to reflexive graphs, Journal of Combinatorial Theory (Series B ) 72 (1998) 236–250.

[7] T. Feder, P. Hell and J. Huang, List homomorphisms and circular-arc graphs, Combinatorica 19 (1999) 487–505.

52

[8] T. Feder, P. Hell and J. Huang, Bi-arc graphs and the complexity of list homomorphisms, Journal of Graph Theory, to appear.

[9] T. Feder and M. Vardi, The computational structure of monotone monadic SNP and constraint satisfaction: a study through Datalog and group theory, SIAM Journal of Computing 28 (1998) 57–104.

[10] M.R. Garey and D.S. Johnson, Computers and Intractability: A Guide to the Theory of NP-Completeness , Freeman (1979).

[11] P. Hell and J. Neˇsetˇril, On the complexity of H-colouring, Journal of

Combinatorial Theory (Series B ) 48 (1990) 92–110.

[12] N. Immerman and S. Landau, The complexity of iterated multiplication, Information and Computation 116 (1995) 103–116.

[13] N. Immerman, Descriptive Complexity, Springer-Verlag (1998).

[14] P.G. Jeavons, D.A. Cohen and J.K. Pearson, Constraints and universal algebra, Annals of Mathematics and Artificial Intelligence 24 (1998)

51–67.

[15] P.G. Kolaitis and M.Y. Vardi, Conjunctive-query containment and constraint satisfaction, Proceedings of 17th ACM Symposium on Principles of Database Systems (1998) 205–213.

[16] C.H. Papadimitriou, Computational Complexity, Addison Wesley, 1994.

[17] A. Puricella and I.A. Stewart, A generic greedy algorithm, partiallyordered graphs and NP-completeness, Proceedings of 27th International

Workshop on Graph-Theoretic Concepts in Computer Science, WG’ 01

(ed. A. Brandstaedt and V.B. Le), Lecture Notes in Computer Science

Vol. 2204, Springer-Verlag, Berlin (2001) 306-316.

[18] A. Puricella and I.A. Stewart, Greedy algorithms, H-colourings and a complexity-theoretic dichotomy, Theoretical Computer Science, to appear.

[19] T.J. Schaefer, The complexity of satisfiability problems, Proceedings of

10th ACM Symposium on Theory of Computing (1978) 216–226.

[20] I.A. Stewart, Completeness of path-problems via logical reductions, Information and Computation 121

(1995) 123-134.

53

[21] E.P.K. Tsang, Foundations of Constraint Satisfaction, Academic Press

(1993).

54

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

### Related manuals

advertisement