# A dichotomy theorem for the general minimum cost homomorphism problem

## Abstract

In the constraint satisfaction problem (), the aim is to find an assignment of values to a set of variables subject to specified constraints. In the minimum cost homomorphism problem (), one is additionally given weights for every variable and value , and the aim is to find an assignment to the variables that minimizes . Let denote the problem parameterized by the set of predicates allowed for constraints. is related to many well-studied combinatorial optimization problems, and concrete applications can be found in, for instance, defence logistics and machine learning. We show that can be studied by using algebraic methods similar to those used for CSPs. With the aid of algebraic techniques, we classify the computational complexity of for all choices of . Our result settles a general dichotomy conjecture previously resolved only for certain classes of directed graphs, [Gutin, Hell, Rafiey, Yeo, European J. of Combinatorics, 2008].

Rustem Takhanov

g-rusta@ida.liu.se takhanov@mail.ru

## 1Introduction

Constraint satisfaction problems () are a natural way of formalizing a large number of computational problems arising in combinatorial optimization, artificial intelligence, and database theory. This problem has the following two equivalent formulations: (1) to find an assignment of values to a given set of variables, subject to constraints on the values that can be assigned simultaneously to specified subsets of variables, and (2) to find a homomorphism between two finite relational structures and . Applications of s arise in the propositional logic, database and graph theory, scheduling and many other areas. During the past 30 years, and its subproblems has been intensively studied by computer scientists and mathematicians. Considerable attention has been given to the case where the constraints are restricted to a given finite set of relations , called a constraint language [5]. For example, when is a constraint language over the boolean set with four ternary predicates , , , we obtain 3-SAT. This direction of research has been mainly concerned with the computational complexity of as a function of . It has been shown that the complexity of is highly connected with relational clones of universal algebra [17]. For every constraint language , it has been conjectured that is either in P or NP-complete [8].

In the minimum cost homomorphism problem (), we are given variables subject to constraints and, additionally, costs on variable/value pairs. Now, the task is not just to find any satisfying assignment to the variables, but one that minimizes the total cost.

was introduced in [15] where it was motivated by a real-world problem in defence logistics. The question for which directed graphs the problem is polynomial-time solvable was considered in [12]. In this paper, we approach the problem in its most general form by algebraic methods and give a complete algebraic characterization of tractable constraint languages. From this characterization, we obtain a dichotomy for , i.e., if is not polynomial-time solvable, then it is NP-hard. Of course, this dichotomy implies the dichotomy for directed graphs.

In Section 2, we present some preliminaries together with results connecting the complexity of with conservative algebras. The main dichotomy theorem is stated in Section 3 and its proof is divided into several parts which can be found in Sections 4-8. The NP-hardness results are collected in Section 4 followed by the building blocks for the tractability result: existence of majority polymorphisms (Section 5) and connections with optimization in perfect graphs (Section 6). Section 7 introduces the concept of *arithmetical deadlocks* which lay the foundation for the final proof in Section 8. In Section 9 we reformulate our main result in terms of relational clones. Finally, in Section 10 we explain the relation of our results to previous research and present directions for future research.

## 2Algebraic structure of tractable constraint languages

Recall that an optimization problem is called NP-hard if some NP-complete language can be recognized in polynomial time with the aid of an oracle for . We assume that .

First, we will state some standard definitions from universal algebra.

For a constraint language , let denote the set of operations preserving all predicates in . Throughout the paper, we let denote a finite domain and a constraint language over . We assume the domain to be finite.

First-order formulas involving only conjunction and existential quantification are often called *primitive positive (pp) formulas*. For a given constraint language , the set of all predicates that can be described by pp-formulas over is called the *closure* of and is denoted by .

For a set of operations on , let denote the set of predicates preserved under the operations of . Obviously, is a relational clone. The next result is well-known [3].

Theorem ? tells us that the Galois closure of a constraint language is equal to the set of all predicates that can be obtained via pp-formulas from the predicates in .

Since any predicate from can be viewed as a pp-formula with predicates in , an input formula to can be represented on the form , where and is a first-order formula involving only predicates in , equality, and conjunction. Obviously, this formula is equivalent to . can be considered as an instance of with variables where weights will remain the same and for additional variables we define . By solving with the described input, we can find a solution of the initial problem. It is easy to see that the number of added variables is bounded by a polynomial in . So this reduction can be carried out in polynomial time. Finally, can be reduced polynomially to because an equality constraint for a pair of variables is equivalent to identification of these variables.

The previous theorem tells us that the complexity of is basically determined by , i.e., by . That is why we will be concerned with the classification of sets of operations for which is a tractable constraint language.

In the following theorem, we show that we only need to consider a very special type of algebras, so called *conservative* algebras.

Let the first-order formula , where , and weights be an instance of . We assume without loss of generality that , when . Let and define a new formula and weights

Then, using an oracle for , we can solve

Suppose that is satisfiable and is a satisfying assignment. It is easy to see that the part of the measure that corresponds to the added values is equal to 0 and the measure cannot be greater than . If is any assignment that does not satisfy , then we see that this part of measure cannot be 0, and hence, is greater or equal to . This means that the minimum in the task is achieved on satisfying assignments of and any such assignment minimize the part of the measure that corresponds to the initial weights, i.e., .

If is not satisfiable, then either is not satisfiable or . Using an oracle for , we can easily check this.

Consequently, is polynomial-time reducible to .

Let . If a function preserves the predicate , then .

## 3Structure of tractable conservative algebras

Let be an arbitrary conservative function and . Define the function , such that , i.e. the restriction of to the set . Throughout this paper we will consider a conservative algebra . For every , let . Then denotes an algebra . We assume that is closed under superposition and variable change and contains all projections, i.e., it is *a functional clone*, because closing the set under these operations does not change the set .

Sometimes we will consider clones as algebras and to describe them we will use the terms (conservativeness, tractability, NP-hardness) defined for algebras. All tractable clones, in case , can be easily found using well-known classification of boolean clones [23].

In the proof of this theorem we will need the following definition.

Let us identify all maximal tractable constraint languages in the boolean case using Post‘s classification [23]. From Theorems ?, ?, ? we conclude that every maximal tractable constraint language corresponds to some conservative functional clone. In the case , there is a countable number of conservative clones: we list them below according to the table on page 76 [22]. For every row, the closure of the predicates given is equal to the set of all predicates preserved under the functions of the corresponding clone.

where .

The class is tractable, since it contains only two simple unary predicates and . As we will see later, it cannot be maximal since it is included in other tractable constraint languages.

Let us prove that is tractable. By Theorem ?, it is equivalent to polynomial solvability of , because the class is the closure of this set of predicates. A proof of this statement can be found in [19]. We will give it for completeness.

Obviously, is equivalent to the following boolean linear programming task, sets and integer weights given as an input:

Let us prove that the polyhedron which is given by the same equalities and inequalities as previous, but with replaced by , is integer. Suppose it is not integer and is its extreme point where is not equal to 0 or 1. Let us define as the minimum of three values , , and two vectors and : if and , , otherwise. It is easy to see that points and are also in polyhedron, and . This contradicts the extremeness of .

Since the polyhedron is integer we can solve in polynomial time by standard linear programming algorithms. Consequently, is tractable.

Now let us prove that is tractable, i.e. is polynomial-time solvable.

Let an instance of this problem be the sets and integer weights . By we denote the set of assignments of variables that satisfy the input formula, i.e. such that and .

The graph where can be decomposed into connected components , where . Such a decomposition can be made in steps. If among these components there is a graph with an odd cycle, then, obviously, . Otherwise, the optimization task can be reduced to subtasks for every component. I.e., if for some component , then , otherwise:

But , and a straightforward algorithm solves every subtask. So, is tractable.

We first now show that the classes in the table, except , and , are NP-hard. Since,

we see that , , and , , .

We first prove that is NP-hard. Suppose an instance of this problem consists of an undirected graph where each vertex is considered as a variable. For each pair of variables , we require their assignments to satisfy or . It is easy to see that for any such assignment , the set is independent in the graph . Furthermore, for any independent set in the graph , is a satisfying assignment. If we define for , then is equivalent to finding a maximum independent set. This implies that is NP-hard, since finding independent sets of maximal size is an NP-hard problem. The case is analogous.

Therefore, , , , , , , , are NP-hard, too.

It remains to prove NP-hardness of . We show that using an algorithm for as an oracle, we can solve Max-CUT in polynomial time.

Let be a graph and introduce variables . A system of equations can be viewed as an instance of . It is easy to see that arbitrary boolean vector defines a single solution of the system. Vector can be considered as the cut and the value is equal to the doubled cost of the cut. Then Max-CUT is polynomially reduced to solving .

Only two classes and are left as candidates for maximality. Since they are not included in each other, they are both maximal.

Suppose we are given a constraint language which is not contained in and . Then, is not contained in and , either. Since is a boolean conservative relational clone, then, by previous lemma, it is NP-hard. By Theorems ? and ?, we conclude that is NP-hard.

The bases in the clones are and and the theorem follows from Lemma ?.

Every 2-element subalgebra of a tractable algebra must be tractable, which motivates the following definition.

Since for every two-element subset , , then is tractable. Assume without loss of generality that . From Theorem ?, we get that or . is a pair of different commutative conservative functions and .

In general, the necessary local conditions are not sufficient for tractability of a conservative clone. Let and .

Suppose . By we mean and . For example, means that .

Introduce an undirected graph without loops where and . The core result of the paper is the following.

The proof of this theorem will be given in two steps. Firstly, in the following section, we will prove NP-hardness of when is not bipartite. The final sections will be dedicated to the polynomial-time solvable cases.

## 4NP-hard case

In this section, we will prove that if a set of functions satisfies the necessary local conditions and (as defined in the previous section) is not bipartite, then is NP-hard. Let and denote the predicates and , where . We need the following lemmas.

Before proving Lemma ?, we need to introduce some concepts from graph theory. All graphs are assumed to be undirected and without loops. We will be interested in the complexity of finding independent sets of maximal size in classes of graphs. Let a finite number of graphs be given and let denote the set of graphs that has no induced subgraphs isomorphic to one of .

The following theorem has been proved by Alekseev[1].

Let be a cycle of length .

First, we will prove NP-hardness of finding maximum independent sets in a graph homomorphic to , i.e. three-partite graph, following [13]. An instance consists of a graph and a partitioning into three independent sets.

Let be a class of graphs with degrees not greater than 3. This class can be characterized by forbidden subgraphs — it is sufficient to forbid graphs with 5 vertices that has a vertex connected with 4 others. Obviously, every such graph is connected and if it is a tree it has 4 leaves. By Theorem ? we conclude that finding maximum independent sets is NP-hard in the class .

From Brooks’ theorem[4], we have that every graph in , besides the complete graph on 4 vertices, is three-partite. The required partition can be constructed in polynomial time by an algorithm of Lovasz[21]. Therefore, the problem of finding maximum independent sets in a three-partite graph is NP-hard even if a partition is given.

The case when can be reduced to every odd case . Let a three-partite graph be given. We will define it in the following form: , where . Transform as follows: for each edge , add vertices to the graph, delete the edge , and add edges . The obtained graph is, obviously, homomorphic to .

Let denote the independence numbers of and respectively. It is easy to see that . We prove that we actually have equality there. Note that intersection of any maximum independent set of and contains not less than , and not more than elements. In the first case(), we can delete all elements from the independent set and replace them by , while not destroying independency. In the second case(), either or are always in the independent set. Again, we delete from it. In the case where was in the independent set originally, we replace the deleted elements by and otherwise by . As a result, we obtain independent set of with the same cardinality as initially. This operation can be done with all pairs . It is easy to see that intersection of the obtained set with is an independent set in and it has cardinality . Consequently, and the constructed intersection is a maximum independent set in . The steps of construction can be carried in polynomial time. Thus, by finding a maximum independent set in , we can easily reconstruct that of . This means that the maximum independent set problem in a three-partite graph is polynomial-time reducible to the maximum independent set problem in a graph homomorphic to (with given homomorphism).

We show that finding a maximum independent set in a graph homomorphic to can be reduced to where .

Suppose the task is to find a maximum independent set in a graph homomorphic to , which, for convenience, will be given in the following form: , where denotes . We consider every vertex as a variable and require values of variables to satisfy the constraint . The set of satisfying assignments is denoted by . It is easy to see that

Therefore, the task

is equivalent to finding a maximum independent set in the graph . I.e., it is equivalent to the problem with an instance consisting of the defined constraints on the variables and weights . Consequently, is NP-hard.

We begin by constructing functions such that . The symbol means that either , or is a projection.

Since , we have . Moreover, by the definition of , we have . By defining , we see that .

Suppose . We prove that in this case . Since the predicate consists of three pairs, it is not preserved by some function of arity two or three. Let us consider these two cases:

I. A function of arity two does not preserve if (for some appropriate permutation of variables):

Then which contradicts that .

II. A function of arity three does not preserve if (for some appropriate permutation of variables):

Then, , since, otherwise, we can find and construct the following term . This contradicts that . Suppose instead that , i.e., there is a function of arity two that does not preserve . If does not preserve , then it does not preserve either , or . Since , we get a contradiction in both cases via the same argument as in case I.

For binary predicates , let . Obviously, if , then , too.

Since is not bipartite, we can find a shortest odd cycle in it, i.e. a sequence , such that . Here, denotes .

By Lemma ?, there is a cyclic sequence such that is either equal to or equal to . Note that all predicates cannot be of the second type: otherwise, we have which contradicts that .

If the sequence contains a fragment , , , then these predicates can be replaced by:

Let us replace , , by in the sequence . We have , since otherwise the predicate is not preserved. Hence, we can delete two vertices in the cycle . This contradicts that this sequence is the shortest among odd sequences. Therefore, such a fragment does not exist.

If the sequence contains a fragment , , , then these predicates can be replaced by:

As in the previous case, we obtain a contradiction. Consequently, we have an odd sequence . By Lemma ?, this class of predicates is NP-hard.

## 5Existence of the majority operation

The necessary local conditions tell that every two-element subalgebra of a tractable algebra contains certain operations. The simplest algebras over a domain that satisfy these conditions are the following: where are conservative commutative operations such that for every , and where is a conservative arithmetical operation, i.e. . This leads us to the following definitions.

Let denote a partitioning of the bipartite graph . Then, for every , there is a function . Let us prove by induction that for every , there is a .

The base of induction is obvious. Let be given. By the induction hypothesis, there are