# The complexity of general-valued CSPs seen from the other side

General-valued constraint satisfaction problems (VCSPs) are generalisations of CSPs dealing with homomorphisms between two valued structures. We study the complexity of structural restrictions for VCSPs, that is, restrictions defined by classes of admissible left-hand side valued structures. As our main result, we show that for VCSPs of bounded arity the only tractable structural restrictions are those of bounded treewidth modulo valued equivalence, thus identifying the precise borderline of tractability. Our result generalises a result of Dalmau, Kolaitis, and Vardi [CP'02] and Grohe [JACM'07] showing that for CSPs of bounded arity the tractable restrictions are precisely those with bounded treewidth modulo homomorphic equivalence. All the tractable restrictions we identify are solved by the well-known Sherali-Adams LP hierarchy. We take a closer look into this hierarchy and study the power of Sherali-Adams for solving VCSPs. Our second result is a precise characterisation of the left-hand side valued structures solved to optimality by the k-th level of the Sherali-Adams LP hierarchy.

## Authors

• 6 publications
• 11 publications
• 28 publications
• ### Phase Transition of Tractability in Constraint Satisfaction and Bayesian Network Inference

There has been great interest in identifying tractable subclasses of NP ...
10/19/2012 ∙ by Yong Gao, et al. ∙ 0

• ### Complexity of Inference in Graphical Models

It is well-known that inference in graphical models is hard in the worst...
06/13/2012 ∙ by Venkat Chandrasekaran, et al. ∙ 0

• ### PTAS for Sparse General-Valued CSPs

We study polynomial-time approximation schemes (PTASes) for constraint s...
12/23/2020 ∙ by Balázs F. Mezei, et al. ∙ 0

• ### Lifting Structural Tractability to CSP with Global Constraints

A wide range of problems can be modelled as constraint satisfaction prob...
07/06/2013 ∙ by Evgenij Thorstensen, et al. ∙ 0

• ### The tractability of CSP classes defined by forbidden patterns

The constraint satisfaction problem (CSP) is a general problem central t...
03/08/2011 ∙ by David A. Cohen, et al. ∙ 0

• ### Valued Authorization Policy Existence Problem: Theory and Experiments

Recent work has shown that many problems of satisfiability and resilienc...
06/10/2021 ∙ by Jason Crampton, et al. ∙ 0

• ### Fractional homomorphism, Weisfeiler-Leman invariance, and the Sherali-Adams hierarchy for the Constraint Satisfaction Problem

Given a pair of graphs A and B, the problems of deciding whether there e...
07/07/2021 ∙ by Silvia Butti, et al. ∙ 0

##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Introduction

### 1.1 Constraint Satisfaction Problems

The homomorphism problem for relational structures is a fundamental computer science problem: Given two relational structures and over the same signature, the goal is to determine the existence of a homomorphism from to (see, e.g., the book by Hell and Nešetřil on this topic [35]). The homomorphism problem is known to be equivalent to the evaluation problem and the containment problem for conjunctive database queries [12, 37], and also to the constraint satisfaction problem (CSP) [23]

, which originated in artificial intelligence

[43] and provides a common framework for expressing a wide range of both theoretical and real-life combinatorial problems.

For a class of relational structures, we denote by CSP(, ) the restriction of the homomorphism problem in which the input structure belongs to and the input structure is arbitrary (these types of restrictions are known as structural restrictions). Similarly, by CSP(, ) we denote the restriction of the homomorphism problem in which the input structure is arbitrary and the input structure belongs to .

Feder and Vardi initiated the study of CSP(, ), also known as non-uniform CSPs, and famously conjectured that, for every fixed finite structure , either CSP(, ) is in PTIME or CSP(, ) is NP-complete. For example, if is a clique on vertices then CSP(, ) is the well-known -colouring problem, which is known to be in PTIME for and NP-complete for . Most of the progress on the Feder-Vardi conjecture (e.g., [6, 3, 36, 10, 2]) is based on the algebraic approach [9], culminating in two recent (affirmative) solutions to the Feder-Vardi conjecture obtained independently by Bulatov [7] and Zhuk [52].

Note that CSP(, ) is only interesting if is an infinite class of structures as otherwise CSP(, ) is always in PTIME. (This is, however, not the case for CSP(, ) as we have seen in the example of -colouring.) Freuder observed that CSP(, ) is in PTIME if consists of trees [25] or, more generally, if it has bounded treewidth [26]. Later, Dalmau, Kolaitis, and Vardi showed that CSP(, ) is solved by -consistency, a fundamental local propagation algorithm [16], if is of bounded treewidth modulo homomorphic equivalence, i.e., if the treewidth of the cores of the structures from is at most , for some fixed  [15]. Atserias, Bulatov, and Dalmau showed that this is precisely the class of structures solved by -consistency [1]. In [32], Grohe proved that the tractability result of Dalmau et al. [15] is optimal for classes of bounded arity: Under the assumption that FPT W[1], CSP(, ) is tractable if and only if has bounded treewidth modulo homomorphic equivalence.

### 1.2 General-valued Constraint Satisfaction Problems

General-valued Constraint Satisfaction Problems (VCSPs) are generalisations of CSPs which allow for not only decision problems but also for optimisation problems (and the mix of the two) to be considered in one framework [14]. In the case of VCSPs we deal with valued structures. Regarding tractable restrictions, the situation of the non-uniform case is by now well-understood. Indeed, assuming the (now proved) Feder-Vardi conjecture, it holds that for any fixed valued structure , either VCSP(, ) is in PTIME or VCSP(, ) is NP-complete [41, 39].

For structural restrictions, it is a folklore result that VCSP(, ) is tractable if is of bounded treewidth; see, e.g. [4]. So is the fact that the -st level of the Sherali-Adams LP hierarchy [48] solves VCSP(, ) to optimality if the treewidth of all structures in is at most . (We are not aware of any reference for this fact. For certain special problems, it is discussed in [5]. For the extension complexity of such problems, see [38].) However, unlike the CSP case, the precise borderline of polynomial-time solvability and the power of fundamental algorithms (such as the Sherali-Adams LP hierarchy) for VCSP(, ) is still unknown. Understanding these complexity and algorithmic frontiers for VCSP(, ) is the main goal of this paper.

### 1.3 Contributions

We study the problem VCSP(, ) for classes of valued structures and give three main results.

#### (1) Complexity classification

As our first result, we give (in Theorem 19) a complete complexity classification of VCSP(, ) and identify the precise borderline of tractability, for classes of bounded arity. A key ingredient in our result is a novel notion of valued equivalence and a characterisation of this notion in terms of valued cores. More precisely, we show that VCSP(, ) is tractable if and only if has bounded treewidth modulo valued equivalence. This latter notion strictly generalises bounded treewidth and it is strictly weaker than bounded treewidth modulo homomorphic equivalence. Our proof builds on the characterisation by Dalmau et al. [15] and Grohe [32] for CSPs. We show that the newly identified tractable classes are solvable by the Sherali-Adams LP hierarchy.

Our second result (Theorem 29) gives a precise characterisation of the power of Sherali-Adams for VCSP(, ). In particular, we show that the -st level of the Sherali-Adams LP hierarchy solves VCSP(, ) to optimality if and only if the valued cores of the structures from have treewidth modulo scopes at most and the overlaps of scopes are of size at most . The proof builds on the work of Atserias et al. [1] and Thapper and Živný [51], as well as on an adaptation of the classical result connecting treewidth and brambles by Seymour and Thomas [47].

#### (3) Search VCSP

Our first two results are for the VCSP in which we ask for the cost of an optimal solution. It is also possible to define the VCSP as a search problem, in which one is additionally required to return a solution with the optimal cost. A complete characterisation of tractable search cases in terms of structural properties of (a class of structures) is open even for CSPs and there is some evidence that the tractability frontier cannot be captured in simple terms.111In particular, [8, Lemma 1] shows that a description of tractable cases of SCSP(, ), which is the search variant of CSP(, ) defined in Section 6, would imply a description of tractable cases of CSP(, ). Building on our first two results as well as on techniques from [50], we give in Section 6 a characterisation of the tractable cases for search VCSP(, ) in terms of tractable core computation (Theorem 41).

In addition to our main results, we provide in Section 7 tight complexity bounds for several problems related to our classification results, e.g., deciding whether the treewidth is at most modulo valued equivalence, deciding solvability by the -th level of the Sherali-Adams LP hierarchy, and deciding valued equivalence for valued structures. These results have interesting consequences to database theory, specifically, to the evaluation and optimisation of conjunctive queries over annotated databases. In particular, we show that the containment problem of conjunctive queries over the tropical semiring is in NP, thus improving on the work of [40], which put it in .

### 1.4 Related work

In his PhD thesis [21], Färnqvist studied the complexity of VCSP(, ) and also some fragments of VCSPs (see also [22, 20]). He considered a very specific framework that only allows for particular types of classes

’s to be classified. For these classes, he showed that only bounded treewidth gives rise to tractability (assuming bounded arity) and asked about more general classes. In particular, decision CSPs do

not fit in his framework and Grohe’s classification [32] is not implied by Färnqvist’s work. In contrast, our characterisation (of all classes ’s of valued structures) gives rise to new tractable cases going beyond those identified by Färnqvist. Moreover, we can derive both Grohe’s classification and Färnqvist’s classification directly from our results, as explained in Section 4.

It is known that Grohe’s characterisation applies only to classes of bounded arity, i.e., when the arities of the signatures are always bounded by a constant (for instance, CSPs over digraphs) and fails for classes of unbounded arity. In this direction, several hypergraph-based restrictions that lead to tractability have been proposed (for a survey see, e.g. [28]). Nevertheless, the precise tractability frontier for CSP(, ) is not known. The situation is different for fixed-parameter tractability: Marx gave a complete classification of the fixed-parameter tractable restrictions CSP(, ), for classes of structures of unbounded arity [42]. In the case of VCSPs, Gottlob et al. [29] and Färnqvist [20] applied well-known hypergraph-based tractable restrictions of CSPs to VCSPs.

## 2 Preliminaries

We assume familiarity with relational structures and homomorphisms. Briefly, a relational signature is a finite set of relation symbols , each with a specified arity . A relational structure over a relational signature (or a relational -structure, for short) is a finite universe together with one relation for each symbol . A homomorphism from a relational -structure (with universe ) to a relational -structure (with universe ) is a mapping such that for all and all tuples we have . We refer the reader to [35] for more details.

We use to denote the set of nonnegative rational numbers with positive infinity, i.e. . As usual, we assume that for all , , and , for all .

#### Valued structures

A signature is a finite set of function symbols , each with a specified arity . A valued structure over a signature (or valued -structure, for short) is a finite universe together with one function for each symbol . We define to be the set of all pairs such that and . The set of positive tuples of is defined by . If are valued structures, then denote their respective universes.

For simplicity we assume a straightforward table encoding for valued structures, which means that the interpretation of a symbol in a valued structure is encoded as a collection of triples . However, it follows directly from our proofs that the exact same results hold for the more compact positive encoding, which represents by the set . In particular, the size of a valued -structure is roughly

 |A|=|σ|+|A|+∑(f,x)∈tup(A)log|σ|+ar(f)log|A|+|enc(fA(x))|

where denotes a reasonable encoding for elements . (For instance, we can encode as a sequence of two nonnegative integers and , with the convention that if and only if .)

#### VCSPs

We define Valued Constraint Satisfaction Problems (VCSPs) as in [49]. An instance of the VCSP is given by two valued structures and over the same signature . For a mapping , we define

 cost(h)=∑(f,x)∈tup(A)fA(x)fB(h(x)).

The goal is to find the minimum cost over all possible mappings . We denote this cost by .

For a class of valued structures (not necessarily over the same signature), we denote by VCSP(, ) the class of VCSP instances such that . We say that VCSP(, ) is in PTIME, the class of problems solvable in polynomial time, if there is a deterministic algorithm that solves any instance of VCSP(, ) in time . We also consider the parameterised version of VCSP(, ), denoted by -VCSP(, ), where the parameter is . We say that -VCSP(, ) is in FPT, the class of problems that are fixed-parameter tractable, if there is a deterministic algorithm that solves any instance of -VCSP(, ) in time , where is an arbitrary computable function. The class W[1], introduced in [18], can be seen as an analogue of NP in parameterised complexity theory. Proving W[1]-hardness of -VCSP(, ) (under an fpt-reduction, formally defined in Section 4.1) is a strong indication that -VCSP(, ) is not in FPT as it is believed that FPT W[1]. We refer the reader to [24] for more details on parameterised complexity.

#### Treewidth of a valued structure

The notion of treewidth (originally introduced by Bertelé and Brioschi [4] and later rediscovered by Robertson and Seymour [44]) is a well-known measure of the tree-likeness of a graph [17]. Let be a graph. A tree decomposition of is a pair where is a tree and is a function that maps each node to a subset of such that

1. ,

2. for every , the set induces a connected subgraph of , and

3. for every edge , there is a node with .

The width of the decomposition is . The treewidth of a graph is the minimum width over all its tree decompositions.

Let be a relational structure over relational signature . Its Gaifman graph (also known as primal graph), denoted by , is the graph whose vertex set is the universe of and whose edges are the pairs for which there is a tuple and a relation symbol such that appear in and . We define the treewidth of to be .

Let be a valued -structure. Note that if is the left-hand side of an instance of the VCSP, the only tuples relevant to the problem are those in . Hence, in order to define structural restrictions and in particular, the notion of treewidth, we focus on the structure induced by . Formally, we associate with the signature a relational signature that contains, for every , a relation symbol of the same arity as . We define to be the relational structure over with the same universe of such that if and only if . We let the treewidth of be .

###### Remark 1.

Observe that, in the VCSP, we allow infinite costs not only in but also in the left-hand side structure . This allows us to consider the VCSP as the minimum-cost mapping problem between two mathematical objects of the same nature. Intuitively, mapping the tuples of to infinity ensures that those are logically equivalent to hard constraints, as any minimum-cost solution must map them to tuples of cost exactly in . Thus, decision CSPs, which are -valued VCSPs, are a special case of our definition and all our results also apply to CSPs.

## 3 Equivalence for valued structures

We start by introducing the notion of valued equivalence that is crucial for our results.

###### Definition 2.

Let be valued -structures. We say that improves , denoted by , if for all valued -structures .

When two valued structures improve each other, we call them equivalent. (In Section 1, we used the term “valued equivalence”. In the rest of the paper, we drop the word “valued” unless needed for clarity.)

###### Definition 3.

Let be valued -structures. We say that and are equivalent, denoted by , if and .

Hence, two valued -structures and are equivalent if they have the same optimal cost over all right-hand side valued structures. Observe that equivalence implies homomorphic equivalence of and . Indeed, whenever is not homomorphic to , we can define a valued -structure as follows: and have the same universe , and for every and , if , and otherwise. Note that (as the identity mapping has cost ), but , and hence, . As the following example shows, the converse does not hold in general.

###### Example 4.

Consider the valued -structures and from Figure 1, with , where and are binary and unary function symbols, respectively. In Figure 1, is represented by the numbers labelling the nodes, and is represented as follows: pairs receiving cost are depicted as edges, while all remaining pairs are mapped to . Observe that and are homomorphically equivalent. However, they are not (valued) equivalent. Indeed, consider the valued -structure with same universe as such that (i) for every , if , otherwise , and (ii) . It follows that and , and thus .

In the rest of the section, we give characterisations of equivalence in terms of certain types of homomorphisms and (valued) cores. We conclude with a useful characterisation of bounded treewidth modulo equivalence in terms of cores. In order to keep the flow uninterrupted, we defer some of the proofs from this section to Appendix A.

### 3.1 Inverse fractional homomorphisms

A homomorphism between two relational structures is a structure-preserving mapping. A fractional homomorphism between two valued structures played an important role in [49]

. Intuitively, it is a probability distribution over mappings between the universes of the two structures with the property that the expected cost is not increased

[49]. In this paper, we will need a different but related notion of inverse fractional homomorphism. For sets and , we denote by the set of all mappings from to .

###### Definition 5.

Let be valued -structures. An inverse fractional homomorphism from to is a function with such that for each we have

 ∑g∈BAω(g)fA(g−1(x))≤fB(x),

where . We define the support of to be the set .

The following result relates improvement and inverse fractional homomorphisms. The proof is based on Farkas’ Lemma.

###### Proposition 6.

Let be valued -structures. Then, if and only if there exists an inverse fractional homomorphism from to .

Let us remark that an inverse fractional homomorphism from to is actually a distribution over the set of homomorphisms from to , i.e., every is a homomorphism from to . Indeed, for every , where and , it must be the case that . Hence, . In view of Proposition 6, this offers another explanation of the fact that equivalence implies homomorphic equivalence (of the positive parts).

### 3.2 Cores

Appropriate notions of cores have played an important role in the complexity classifications of left-hand side restricted CSPs [32], right-hand side restricted CSPs [9, 7, 52], and right-hand side restricted VCSPs [50, 39]. In this paper, we will define cores around inverse fractional homomorphisms. The proofs of some of the propositions are deferred to the appendix.

For two valued -structures and , we say that that an inverse fractional homomorphism from to is surjective if every is surjective.

###### Definition 7.

A valued -structure is a core if every inverse fractional homomorphism from to is surjective.

Next we show that equivalent valued structure that are cores are in fact isomorphic.

###### Definition 8.

Let be valued -structures. An isomorphism from to is a bijective mapping such that for all . If such an exists, we say that and are isomorphic.

###### Proposition 9.

If , are core valued -structures such that , then and are isomorphic.

We now introduce the central notion of a core of a valued structure and show that every valued structure has a unique core (up to isomorphism). In order to do so, we need to state some properties of inverse fractional homomorphisms. The next proposition highlights a key property shared by all mappings that belong to the support of an inverse fractional homomorphism from a valued structure to itself: for every right-hand side valued structure , the composition of and a minimum-cost mapping from to is always a minimum-cost mapping from to .

###### Proposition 10.

Let be a valued -structure and be a mapping. Suppose there exists an inverse fractional homomorphism from to such that . Then, for every valued -structure and mapping such that , .

Next we introduce the “image valued structure” of , where is a mapping from a valued structure to itself. When belongs to a inverse fractional homomorphism from to itself, Proposition 10 allows us to show that and the image of are actually equivalent.

###### Definition 11.

Let be a valued -structure, and be a mapping. We define to be the valued -structure over universe such that , for all and .

###### Proposition 12.

Let be a valued -structure and be a mapping. Suppose there exists an inverse fractional homomorphism from to such that . Then, .

Now we are ready to define cores and prove their existence.

###### Definition 13.

Let be valued -structures. We say that is a core of if is a core and .

###### Proposition 14.

Every valued structure has a core and all cores of are isomorphic. Moreover, for a given valued structure , it is possible to effectively compute a core of and all cores of are over a universe of size at most .

###### Proof.

Let be a valued structure. To see that there is always a core for , we can argue inductively. If is a core itself we are done. Otherwise, there is a non-surjective mapping for some inverse fractional homomorphism from to itself. By Proposition 12, . If is core we are done. Otherwise, we repeat the process. As in each step the size of the universe strictly decreases, at some point we reach a valued structure that is a core, and in particular, a valued structure that is a core of . Uniqueness follows directly from Proposition 9. From the argument described above, it follows that the universe of any core of has size at most , and also that we can compute a core from

, as each step in the above-mentioned process is computable. Indeed, by solving a suitable linear program, it is possible to decide whether a valued structure is a core, and in the negative case, compute a non-surjective mapping

for some inverse fractional homomorphism from the valued structure to itself (see Appendix A.5 for a detailed proof). ∎

Proposition 14 allows us to speak about the core of a valued structure. It follows then that equivalence can be characterised in terms of cores: and are equivalent if and only if their cores are isomorphic.

We conclude with a technical characterisation of the property of being a core that will be important in the paper. Intuitively, it states that every non-surjective mapping from a core to itself is suboptimal with respect to a fixed weighting of the tuples of .

###### Proposition 15.

Let be a valued -structure. Then, is a core if and only if there exists a mapping such that for every non-surjective mapping ,

 ∑(f,x)∈tup(A)fA(x)c(f,x)<∑(f,x)∈tup(A)fA(x)c(f,g(x)).

Moreover, such a mapping is computable, whenever is a core.

###### Example 16.

Let and be the valued -structures depicted in Figure 1. Recall that , where is a -valued binary function (represented by edges) and is unary (represented by node labels). Also, the elements of are denoted by , where and indicate the corresponding row and column of the grid, respectively (for readability, only is depicted in Figure 1). We claim that is the core of . Indeed, since is a relational core, it follows that is a core. To see that , let be the mapping that maps all elements in the -th diagonal of (first diagonal is , second diagonal is , and so on) to . Assigning gives an inverse fractional homomorphism from to , and thus by Proposition 6.

Conversely, consider the mappings ,,,,, from to that map to , , , , and , respectively. We define the distribution , , , , and . Then, we have

 ∑kω′(gk)μA′(g−1k(aij))=⎧⎪ ⎪ ⎪⎨⎪ ⎪ ⎪⎩(2×1/3+4×1/12)×1if aij∈{a11,a33}(1/3+2×1/12)×2if aij∈{a12,a21,a23,a32}(1/3)×3if aij∈{a13,a31}(4×1/12)×3if aij=a22

and hence for all , . It follows that is an inverse fractional homomorphism from to . Therefore, and is the core of . In particular, is not a core. As we explain later in Example 23, it is possible to modify (more precisely, ) so that it becomes a core.

### 3.3 Treewidth modulo equivalence

In this section we show an elementary property of cores that is crucial for our purposes: the treewidth of the core of a valued structure is the lowest possible among all structures equivalent to .

###### Proposition 17.

Let be a valued -structure and be its core. Then, .

###### Proof.

Since treewidth is preserved under relational substructures, it suffices to show that is a substructure of , i.e., there is an injective homomorphism from to . Let and be inverse fractional homomorphisms from to , and from to , respectively. Pick any mapping . As observed at the end of Section 3.1, has to be a homomorphism from to . It suffices to show that is injective. Towards a contradiction, suppose is not injective and define as

 ω′∘ω(h)=∑h1:A′↦A,h2:A↦A′h2∘h1=hω(h1)ω′(h2).

Observe that is an inverse fractional homomorphism from to . Pick any . It follows that is not injective and . In particular, is not surjective. This contradicts the fact that is a core. ∎

We conclude Section 3 with the following useful characterisation of “being equivalent to a bounded treewidth structure” in terms of cores.

###### Proposition 18.

Let be a valued -structure and . Then, the following are equivalent:

1. There is a valued -structure such that and has treewidth at most .

2. The treewidth of the core of is at most .

###### Proof.

(2) (1) is immediate. For (1) (2), let be of treewidth at most such that . Let and be the cores of and , respectively. Since , and are isomorphic, by Proposition 9. By Proposition 17, the treewidth of is at most , and so is the treewidth of . ∎

## 4 Complexity of Vcsp(C, −)

Let be a class of valued structures. We say that has bounded arity if there is a constant such that for every valued -structure and , we have that . Similarly, we say that has bounded treewidth modulo equivalence if there is a constant such that every is equivalent to a valued structure with . The following is our first main result.

###### Theorem 19 (Complexity classification).

Assume FPT W[1]. Let be a recursively enumerable class of valued structures of bounded arity. Then, the following are equivalent:

1. VCSP(, ) is in PTIME.

2. -VCSP(, ) is in FPT.

3. has bounded treewidth modulo equivalence.

###### Remark 20.

Although Grohe’s result [32] for CSPs looks almost identical to Theorem 19, we emphasise that his result involves a different type of equivalence. In Grohe’s case, the equivalence in question is homomorphic equivalence whereas in our case the equivalence in question involves improvement (cf. Definition 3). As we will explain later in this section, Grohe’s classification follows as a special case of Theorem 19.

###### Remark 21.

As in [32], we can remove the condition in Theorem 19 of being recursively enumerable, by assuming a stronger hypothesis than FPT W[1] regarding non-uniform complexity classes.

Note that by Proposition 18, a class has bounded treewidth modulo equivalence if and only if the class given by the cores of the valued structures in has bounded treewidth. This notion strictly generalises bounded treewidth, as illustrated in Example 22. Consequently, Theorem 19 gives new tractable cases.

###### Example 22.

Consider the signature , where and are binary and unary function symbols, respectively. For , let be the valued -structure with universe such that (i) if , , and ; otherwise , and (ii) , for all . Also, for , let be the valued -structure with universe such that (i) if ; otherwise , and (ii) , for , and , for . The structures and from Figure 1 correspond to and , respectively; informally is a crisp directed grid of size with a unary function with weight applied to each element. Generalising the reasoning behind Example 16, we argue in Appendix B that for each the valued structure is the core of . Since , the class has bounded treewidth modulo equivalence. However, has unbounded treewidth as the Gaifman graphs in correspond to the class of (undirected) grids, which is a well-known family of graphs with unbounded treewidth (see, e.g. [17]). We also describe in Appendix B how to alter the definition of to obtain a class of finite-valued structures (taking on finite values in ) that has bounded treewidth modulo equivalence but Gaifman graphs of unbounded treewidth.

It is worth noticing that bounded treewidth modulo equivalence implies bounded treewidth modulo homomorphic equivalence (of the positive parts), but the converse is not true in general, as the next example shows. Therefore, Theorem 19 tells us that the tractability frontier for VCSP(, ) lies strictly between bounded treewidth and bounded treewidth modulo homomorphic equivalence.

###### Example 23.

For , let be the valued -structure from Example 22. Let be the valued -structure with the same universe as , i.e., , such that and is defined as follows. Let be the first diagonals of starting from the bottom left corner (see Figure 2 for an illustration of ). For , let be the top-left to bottom-right enumeration of . In particular, , , and . Fix an integer such that . The values assigned by to , and are , and , respectively, and for , with , is . All remaining elements in receive cost . Figure 2 depicts the case of .

Let . Note first that is homomorphically equivalent to the relational structure over relational signature (recall the definition of from Section 2), whose universe is , and . Since , for all , it follows that has bounded treewidth modulo homomorphic equivalence. We claim that has unbounded treewidth modulo (valued) equivalence. It suffices to show that is a core, for all . In order to prove this, we apply Proposition 15. Fix and define such that (i) if ; otherwise , and (ii) , for all . Note that . Next we show that if satisfies that , then is the identity mapping. Using Proposition  15, this implies that is a core.

Let such that . The mapping must satisfy the following two conditions: (a) is a homomorphism from to (otherwise ), and (b) for every , , otherwise . We can argue inductively, and show that is the identity over , for all . Note that condition (a) implies that is the identity over the remaining elements in , as required. For , we have that by condition (a). For , note that (a) implies that . By condition (b), . To see that , suppose by contradiction that , then condition (a) implies that , which violates (b). For the case , recall that is the above-defined enumeration of . Since is the identity over and by condition (a), we have that is the identity over . As and , conditions (a) and (b) imply that and , as required.

To conclude this example we note that the class of valued -structures where each is derived from by setting , and for all is an example of a finite-valued class of structures that has bounded treewidth modulo homomorphic equivalence but unbounded treewidth modulo equivalence.

#### Corollaries of the complexity classification

We can obtain the classification for CSPs of Dalmau et al. [15] and Grohe [32] as a special case of Theorem 19. Indeed, we can associate with a relational -structure a valued -structure such that (i) , (ii) and have the same universe , and (iii) if , then , otherwise , for every and . For a class relational structures, we define the class of valued structures . It is not hard to check that, when is of bounded arity, CSP(,) reduces in polynomial time to VCSP(,) and vice versa. Hence, a classification of CSP(,), for ’s of bounded arity, is equivalent to a classification of VCSP(,). Finally, note that has bounded treewidth modulo homomorphic equivalence if and only if has bounded treewidth modulo (valued) equivalence. This implies the known CSP classification from [15] and [32].

In his PhD thesis [21], Färnqvist also considered the complexity of VCSP(, ). However, he considered a different definition of the problem, that we denote by VCSP(, ). Formally, for a relational -structure , let be the valued -structure such that (i) , (ii) and have the same universe , and (iii) for every and , we have that and , for all . For a class of relational structures , VCSP(, ) is precisely the problem VCSP(, ), where . It was shown in [21] that for a class of relational structures of bounded arity, VCSP(, ) is tractable if and only if has bounded treewidth. This result follows directly from Theorem 19 as every valued structure in a class of the form is a (valued) core, and hence, bounded treewidth modulo equivalence boils down to bounded treewidth.

Intuitively, VCSP(, ) restricts VCSP only based on the (multiset of) tuples appearing in the structures from . In contrast, our definition of VCSP(, ) considers directly the structures in . This allows us for a more fine-grained analysis of structural restrictions, and in particular, provides us with new tractable classes beyond bounded treewidth. Indeed, as Example 22 illustrates, we can find simple tractable classes of valued structures with unbounded treewidth.

Finally, let us note that since Theorem 19 applies to all valued structures, it in particular covers the finite-valued VCSP, where all functions are restricted to take finite values in , and hence the tractability part of Theorem 19 directly applies to the finite-valued case. The hardness part also applies to the finite-valued case. Indeed, the right-hand side structure constructed in the reduction of Proposition 24 is actually finite-valued. Therefore, Theorem 19 also gives a classification for finite-valued VCSPs. Moreover, Examples 22 and 23 demonstrate that already for finite-valued structures the tractability frontier is strictly between bounded treewidth and bounded treewidth modulo homomorphic equivalence.

The rest of this section is devoted to proving the hardness part of Theorem 19, i.e., the implication (2) (3). The tractability part of Theorem 19 (implication (3) (1)) is established in Section 5. In particular, it will follow from Theorem