for Patterns: An Algebra of Labelled Graphs

. A pattern is a generic instance of a binary constraint satisfaction problem (CSP) in which the compatibility of certain pairs of variable-value assignments may be unspeciﬁed. The notion of forbidden pattern has led to the discovery of several novel tractable classes for the CSP. However, for this ﬁeld to come of age it is time for a theoretical study of the algebra of patterns. We present a Galois connection between lattices composed of sets of forbidden patterns and sets of generic instances, and investigate its consequences. We then extend patterns to augmented patterns and exhibit a similar Galois connection. Augmented patterns are a more powerful language than ﬂat (i.e. non-augmented) patterns, as we demonstrate by showing that, for any k ≥ 1, instances with tree-width bounded by k cannot be speciﬁed by forbid-ding a ﬁnite set of ﬂat patterns but can be speciﬁed by a ﬁnite set of augmented patterns. A single ﬁnite set of augmented patterns can also describe the class of instances such that each instance has a weak near-unanimity polymorphism of arity k (thus covering all tractable language classes).We investigate the power of forbidding augmented patterns and discuss their potential for describing new tractable classes.


Introduction
The CSP (Constraint Satisfaction Problem) is a classical abstract framework for the modelling of finite-domain constrained assignment problems [8,32]. Although first inspired by applications in computer vision and artificial intelligence, it's generic nature has allowed it to become a programming paradigm in its own right used in, for example, scheduling, product configuration, planning and bioinformatics. It is well known that the CSP is NP-complete and remains so even when restricted to binary constraints since all instances have an equivalent dual instance which is binary [22,40].
An interesting avenue of theoretical research on CSPs consists in the characterisation of tractable subproblems defined by placing a restriction on the type of constraints that can occur (the constraint language) and again it is known that it is possible to limit attention to languages of binary relations [5,10]. A major advance towards the recent characterisation of tractable constraint languages [3,41] was the algebraic approach based on the study of pointwise closure operations of constraint relations, known as polymorphisms, and the identities satisfied by these polymorphisms [1,4]. Of particular interest is the Galois connection between (sets of) polymorphisms and (sets of) relations [27]. In parallel, tractable subproblems of the CSP based on restrictions on the (hyper)-graph of constraint scopes (the constraint (hyper)graph) were also characterised [26].
In order to define new classes, we need to go beyond placing restrictions on constraint languages or on the structure of the constraint (hyper)-graph. A natural way of defining sets of instances is to consider properties of the microstructure of binary CSP instances [30]. A pattern can be seen as a partial microstructure (i.e. a binary CSP instance in which the compatibility of some assignments may be left undefined) or, more abstractly, as a graph with vertices labelled by names of variables and edges which may be positive or negative. Defining sets of binary CSP instances by forbidding patterns has led to the discovery of novel tractable classes [9,18]. For example, in each of the following cases, forbidding a simple 3variable pattern defines a tractable class of binary CSP instances which strictly generalises a known tractable class: -The Broken-Triangle Property (BTP) [16] includes all instances whose constraint graph is a tree. It has also led to the discovery of interesting reduction operations [14] and has been extended in different ways to define larger tractable classes [12,[35][36][37]. -The Joint-Winner Property (JWP) [17] includes all CSP instances defined by a single All-Different constraint [38] together with arbitrary unary constraints. -The Extended Max-Closed (EMC) class [19] includes all binary max-closed instances [29]. The stable marriage problem [31] is just one example of a class of problems that can be expressed as binary max-closed CSPs [25]. -The T 4 pattern [15] generalises the ZOA language class [13] which is itself a generalisation of 2SAT. Three other patterns have also recently been shown to define tractable classes that generalise 2SAT [7].
In this paper we initiate the study of the underlying theory of forbidden (sets of) patterns, an essential foundation on which to build a characterisation of all tractable classes defined by forbidden (sets of) patterns. We begin by studying what we call flat patterns before studying augmented patterns with extra structure, such as partial orders on variables or domain values. Adding such structure is not only essential to define certain hybrid classes such as BTP [16] and EMC [19], but, as we will show in Sect. 6, also allows us to define (families of) polymorphisms [28] and bounded tree-width [20] within the same framework.
For both flat and augmented patterns, we exhibit a Galois connection between sets of patterns and sets of instances. In each case, we investigate the tractability consequences of the Galois connection, including the possibility of defining new tractable classes by combination of known tractable classes via the lattice operations. We notably show that tractable classes form a sublattice.

Definitions and Notation
We assume that there is a countable collection of variables X and a countable domain D of values. A variable-value pair (x, a), representing the assignment of value a ∈ D to variable x ∈ X , is known as a point. A flat pattern (or simply a pattern) P = A P , ρ P is a subset A P of X ×D equipped with a (partial) function ρ P from the pairs of points (x, a), (y, b) of P such that x = y to {negative, positive}. Thus P consists of a set of variable-value assignments (x, a) together with a set of negative and positive edges representing the compatibility of pairs of assignments. In figures we represent negative edges by dashed lines, positive edges by solid lines and points corresponding to assignments to the same variable are grouped into ovals. Three patterns P 1, P 2, P 3 are shown in Fig. 1.
We give a recursive definition of connectedness. Two points (x, a), (y, b) in a pattern P are connected if x = y or ρ P ((x, a), (y, b)) ∈ {negative, positive} or if (x, a), (y, b) are both connected to some point (z, c) of P . Clearly, each pattern has a decomposition into connected components according to this definition of connectedness.
A completely specified binary CSP instance (or simply an instance) is a pattern I = A I , ρ I in which the function ρ I is total, i.e. the compatibility of each pair of variable-value assignments (to distinct variables) is specified. Given an instance I on n variables, a solution to I is a clique of positive edges of size n, which corresponds to a pairwise-compatible assignment of values to variables. The question associated with an instance is the existence of a solution. An instance I is arc consistent if for all points (x, a) of I and all variables y = x of I, (x, a) has a support at y, i.e. ∃b ∈ D such that {(x, a), (y, b)} is a positive edge in I.
A pattern P = A P , ρ P occurs in pattern Q = A Q , ρ Q if there is a mapping f from A P to A Q which respects variables, maps negative edges to negative edges and positive edges to positive edges, i.e.
We use the notation P → Q to denote that P occurs in pattern Q (and P Q if it does not). It is easy to see from its definition that occurrence is transitive: P → Q and Q → R implies P → R. We consider two patterns P, Q to be equivalent if P → Q and Q → P : we write P ≈ Q. For example, patterns P 1 and P 2 in Fig. 1 are equivalent; we notably have P 1 → P 2 since (x, a), (y, b) can both map to (z, c). Clearly, we have P 2 → P 3, and then, by transitivity, P 1 → P 3. For simplicity of presentation, throughout this paper, we will talk about patterns rather than equivalence classes of patterns.
Each pattern P defines a corresponding set of instances in which P does not occur. For example, the pattern P 3 of Fig. 1 defines a set of instances which includes all binary CSP instances with Boolean domains, since if P 3 → I then the points (v, d), (v, e), (v, f ) must map to three distinct values for the same variable in I, due to the positive and negative edges in P 3.
Note that in previous work, it has sometimes been convenient to assume that when P occurs in Q, distinct variables of P map to distinct variables of Q [11,15,19]. However, to establish a Galois connection for flat patterns, we require a looser definition of occurrence in which two or more variables of P may map to the same variable in Q. To impose the stricter definition of occurrence (inducing an injective mapping of variables of P ), it suffices, for each pair of distinct variables x, y, to add two new points (x, a), (y, b) to A P and an extra dummy positive edge between points (x, a), (y, b) in P ; this prevents x, y mapping to the same variable in Q (and only changes the semantics of P in a trivial way). A more elegant solution (in order to impose an injective mapping of variables) is to augment the patterns with a not-equal-to relation between variables which is possible in the framework of augmented patterns discussed in Sect. 6.
We consider sets S of patterns. These sets will usually be finite, indeed, often a singleton. When forbidden, a set S of patterns defines a set of instances (those sets of instances in which none of the patterns in S occurs). Such sets T of instances are hereditary in the sense that (I ∈ T ) ∧ (I ⊆ I) =⇒ (I ∈ T ), where I ⊆ I means (A I ⊆ A I ) ∧ (ρ I = ρ I | A I ). Many, but not all, classes of interest are hereditary. For example, for any k, the set of instances whose tree-width is bounded by k is hereditary. On the other hand, the set of instances which is arc-consistent is not hereditary, since a value which has a support at another variable in an instance I will not necessarily have a support in I ⊂ I. Thus forbidden flat patterns alone cannot express any class of instances which requires arc consistency (or a higher level of consistency) [36]. Nevertheless, we will see in Sect. 6 how a combination of augmented patterns and filters on instances provides a very expressive language in which to define classes on instances, allowing us to express such classes of instances.
In order to obtain a Galois connection we consider sets of generic instances, where a generic instance can be viewed as a partially-specified instance and is, in fact, again just a pattern. However, the lattice structure on sets of patterns is different depending on whether we view these patterns as partially-specified instances or as forbidden sub-instances. When defining tractability of sets of generic instances we filter instances keeping only those that are completely specified.

Definition 1. A set T of generic instances is tractable if there is a polynomialtime algorithm which decides all completely-specified instances in T . A set S of forbidden patterns is tractable if the corresponding set of instances in which none of the patterns in S occur is tractable.
To define lattices of (sets of) instances and (sets of) patterns, we also require the following operation on patterns: if P, Q are patterns, then P + Q is a single pattern consisting of (copies of) the two patterns P and Q (without any common points and without any edges between P and Q). We call this the juxtaposition of the two patterns P and Q. Observe that P + P ≈ P (since P + P → P follows from the definition of occurrence which allows us to map the two copies of P to P ). If S 1 , S 2 are sets of patterns, then S 1 + S 2 is the set of patterns We also require another operation on pairs of patterns, which can be seen as the greatest lower bound of the two patterns. If P, Q are patterns, then P × Q is a single pattern built by forming the juxtaposition of all patterns R such that (R → P ) ∧ (R → Q). We say that such patterns R are common factors of P and Q. We only include patterns R which are maximal in the sense that there is no R ≈ R such that R → R and (R → P ) ∧ (R → Q). Observe that including only maximal R, ensures that we have P ×P ≈ P . The operation × is illustrated in Fig. 2. In this example, the patterns P and Q have only two maximal common factors (modulo the equivalence relation ≈) and P × Q is the juxtaposition of these two common factors. Note that P 1 and P 2 (shown in Fig. 1) are both common factors of P and Q, but since P 1 ≈ P 2 we only need to include one of these patterns in P × Q. If S 1 , S 2 are sets of patterns, then S 1 × S 2 is the set of The following lemmas provide a logical interpretation of the + and × operations on patterns.  Proof. By contraposition, it suffices to show that P → I 1 × I 2 if and only if P → I 1 ∧ P → I 2 . If P → I 1 ∧ P → I 2 , then P is a common factor of I 1 and I 2 and hence P → I 1 × I 2 . On the other hand, if P → I 1 × I 2 , then, due to the lack of edges between the connected components of I 1 × I 2 , P must be the juxtaposition of patterns P 1 , . . . , P r where for each i = 1, . . . , r, P i → R i for some R i which is one of the connected components of I 1 × I 2 . Each connected component R i of I 1 × I 2 satisfies R i → R i for some common factor R i of I 1 and I 2 . By transitivity of the occurrence relation and by definition of I 1 × I 2 , we have P i → I 1 and P i → I 2 (for i = 1, . . . , r) and hence P → I 1 and P → I 2 .

The Two Lattices
Let P be the set of all patterns and I be the set of all generic instances. Let T be the set of all subsets of I. Let S be the set of all subsets of P. In this section we show that S and T have lattice structures with partial orders based on notions of occurrence. Although P = I, S and T are distinct since they do not have the same partial order.
We require two different definitions of occurrence of one set of patterns in another, depending on whether the sets of patterns are considered as forbidden patterns or sets of generic instances. For It follows directly from their definitions that and ↔ are equivalence relations. Let T be the set of all equivalence classes (according to ↔) of sets of generic instances. Let S be the set of all equivalence classes (according to ) of sets of forbidden patterns.
It is not difficult to see that → is a partial order on T and that is a partial order on S. It follows that T and S both have a lattice structure [2,21]. The following proposition shows that the set T has a lattice structure with meet and join operations × and ∪, whereas the set S has a lattice structure with meet and join operations + and ∪.
(3) T 1 → T 2 means that ∀I ∈ T 1 , ∃J ∈ T 2 such that I → J, so I is a common factor of I and J and hence The following lemmas are not essential for the lattice structure of S and T , but will be useful later.

Lemma 4. For all sets of patterns
If we consider that S 1 ≤ S 2 if S 2 S 1 , then the minimal element in the lattice S is the empty set of patterns and the maximal element is {P ∅ } where P ∅ is the pattern containing no points or edges. If we consider that T 1 ≤ T 2 if T 1 → T 2 then the minimal element of T is the empty set of patterns and the maximal element is the set of all patterns.
The two lattices S and T are both distributive, as shown by the following proposition.
Proof. These follow immediately from the definitions.

The Galois Connection
The Galois connection is based on two functions f : S → T and g : T → S, defined as follows. Proof. The functions f, g, applied to equivalence classes of S and T define a Galois connection between S and T if ∀S ∈ S, ∀T ∈ T , . This corresponds to (T → f (S)) ⇔ (g(T ) S), which holds because (T → f (S)) and (g(T ) S) are both equivalent to ∀P ∈ S, ∀I ∈ T , P I. We therefore have a Galois connection between S and T .
We now study this Galois connection in more detail.
It follows that P ∈ g(T 1 ) since otherwise we would have some I 1 ∈ T 1 such that P → I 1 and some I 2 ∈ T 2 such that P → I 1 → I 2 which contradicts P I 2 .
We immediately have the following corollary.

Proposition 4. For any patterns
Proof. Suppose f (S 1 ) = f (S 2 ). Then ∀I, (∀P ∈ S 1 , P I) ⇔ (∀P ∈ S 2 , P I). This is equivalent to ∀I, (∃P ∈ S 1 , P → I) ⇔ (∃P ∈ S 2 , P → I). It follows, by setting I = P ∈ S 2 , that ∀P ∈ S 2 , ∃P ∈ S 1 such that P → P , and hence S 1 S 2 . By setting I = P ∈ S 1 , by a symmetrical argument, we obtain S 2 S 1 , and hence S 1 S 2 . Now suppose that S 1 S 2 . Then, by Proposition 3, we can deduce that It is important to observe that T includes sets of partially-specified instances. If we considered only sets of completely-specified instances in T , then Proposition 4 would not hold. For example, consider S 1 and S 2 shown in Fig. 3. It is easy to see that we do not have S 1 S 2 , even though S 1 and S 2 define the same set of completely-specified instances when forbidden, namely those instances which have only positive edges or only negative edges. They do not define the same set of generic instances, since, for example, the single pattern Q ∈ S 2 is in f (S 1 ) but not f (S 2 ).

Proposition 5. For any patterns
Proof. Suppose g(T 1 ) = g(T 2 ). Then ∀P , (∀I ∈ T 1 , P I) ⇔ (∀I ∈ T 2 , P I). This is equivalent to ∀P , (∃I ∈ T 1 , P → I) ⇔ (∃I ∈ T 2 , P → I)). Setting P = I ∈ T 1 , we obtain ∀I ∈ T 1 , ∃I ∈ T 2 such that I → I , and hence T 1 → T 2 . Setting P = I ∈ T 2 , by a symmetrical argument, we obtain T 2 → T 1 , and hence We now show to what extent the lattice structure of S and T is preserved via the mappings f and g. .
The lattice structure and Theorems 2 and 3 are illustrated in Fig. 4.
Theorems 4 and 5 are illustrated in Fig. 5.

Definition 2.
A set T of patterns is downward-closed if for all patterns P, Q, In the case of upward-closed sets of forbidden patterns and/or downwardclosed sets of generic instances, the lattices, and the corresponding Galois connection, become simpler as the following proposition shows. In this case the two lattices become lattices of sets with meet and join operations ∩ and ∪. In practice, however, we are generally interested in small sets of forbidden patterns which cannot be upward-closed (otherwise they would be infinite).
Proof. ∀P + Q ∈ S 1 + S 2 , we have P → P + Q and Q → P + Q. By the upward closedness of both S 1 and S 2 , it follows that P + Q ∈ S 1 ∩ S 2 . Thus S 1 ∩ S 2 S 1 + S 2 . By Lemma 4, we have S 1 + S 2 S 1 ∩ S 2 .

Tractability Consequences of the Galois Connection
In this section we show that tractable sets of patterns form a sublattice of S.
Recall that we say that T ∈ T is tractable if there is a polynomial-time algorithm to decide all completely-specified instances in T . We consider that incompletely-specified instances (i.e. generic instances with at least one pair of points not joined by a (positive or negative) edge) can be recognised as such in polynomial time and hence do not affect the tractability of T . A consequence of this is that it is not true that T 1 → T 2 ∧ (T 2 tractable) ⇒ T 1 tractable. For example, T 2 could be trivially tractable because it contains no completelyspecified instance even when T 1 is the set of all binary CSP instances. However, we have the following important result.
Proof. Let T 1 = f (S 1 ) and T 2 = f (S 2 ), where T 1 → T 2 . By Proposition 3, we have g(T 2 ) ⊆ g(T 1 ) and so by Lemma 3, g(T 1 ) g(T 2 ). By definition of the functions f and g, we have f (g(f (S))) = f (S) for all S, and so f (g(T 1 )) = f (S 1 ) and f (g(T 2 )) = f (S 2 ). It follows from Proposition 4 that S 1 g(T 1 ) and S 2 g(T 2 ). Thus S 1 g(T 1 ) g(T 2 ) S 2 . By transitivity of , we have S 1 S 2 and, by Proposition 3, It follows that if T 2 is tractable, then so is T 1 .
This means that it may be possible to classify the complexity of all classes f (S) for all finite sets S ∈ S. Indeed we conjecture that there is a P/NP-complete dichotomy. This has already been proved for sets of patterns containing only negative edges [9].
The following proposition tells us that the tractable sets of patterns form a sub-lattice of S.
We can observe that the finite sets of S form a sublattice of S since S 1 +S 2 and S 1 ∪ S 2 are finite if S 1 , S 2 are finite. It follows that the finite tractable sets of S form a sublattice. We are particularly interested in finite sets of patterns, since detecting the absence of finite sets of patterns can be achieved in polynomial time, whereas testing the absence of an infinite set of patterns may not even by computable. We can observe that there are infinite sets of patterns S such that f (S) is tractable but for no finite subset S of S is f (S ) tractable, e.g. acyclic instances that can be defined by forbidding cycles of all lengths but by no finite set of flat patterns [11].

Augmented Patterns: Motivation
We can make the language of patterns much richer by adding relations to patterns (and possibly quantifying over these relations). A flat pattern (the kind of pattern we have studied up to now in this paper) has only the binary relations of compatibility between points (positive edges), incompatibility between points (negative edges) and the equivalence relation between points corresponding to assignments to the same variable (represented in figures by ovals representing its equivalence classes). Suppose that we add a new relation, such as an ordering or a colouring of the points of the pattern. We call this an augmented pattern. In this section, we motivate the study of augmented patterns by showing that they can be used to define interesting tractable classes that cannot be defined using flat patterns. Examples of such augmented patterns are a pattern in which we add an ordering between points (the new relation is binary) or a colouring of points (in which case the new relation is unary). For these new relations to be meaningful, they must satisfy the basic properties of, for example, orderings or colourings. To impose this we can replace a single pattern P by a set of patterns, one being the augmented pattern P and the others designed in such a way as to impose the required properties of the new relation.
Consider a binary relation R < . Each of the following three statements can be seen as an augmented pattern involving only the relation R < : By forbidding these three patterns, we impose that R < is an irreflexive, antisymmetric relation with no length-3 cycles. In the following we only consider instances in which R < is total in the sense that for all distinct a, b, we have a). It is easy to see that this implies that R < is a strict total order (since, in particular, forbidding pattern (3) corresponds to transitivity). From now on, for notational convenience, we use the operator < instead of the relation R < , i.e. we write a < b instead of R < (a, b). If we also forbid the augmented pattern shown in Fig. 6(a), then we not only impose an order on the points of an instance, but we also impose that there is a corresponding order on the variables which is consistent with this order on the points. If we also forbid the augmented pattern in Fig. 6(b), then we are saying that there is a total ordering of the variables of the instance such that each variable is constrained by at most one previous variable in this order. The set of completely-specified instances with a total ordering on its points in which none of these five augmented patterns occurs corresponds exactly to the set of instances whose constraint graph is acyclic. It is well known that this class of binary CSP instances is tractable since it is solved by arc consistency [22]. Recall that no finite set of forbidden flat patterns defines the set of acyclic instances [11]. This example demonstrates the power of augmented patterns compared to flat patterns, since acyclicity can be defined by forbidding a set of just five augmented patterns.
In fact, for any fixed k ≥ 1, we can define the class of instances with treewidth bounded by k using a finite set of augmented patterns. We saw above that the patterns (1), (2), (3) together with the pattern shown in Fig. 6(a) effectively allows us to impose an order on variables. Apart from this variable-order relation, we also introduce another binary relation IE (for Induced Edge between two variables in the constraint graph) which, using the same idea as in Fig. 6(a), is also effectively a relation on variables. For simplicity of presentation, in the following, we apply < and IE to variables rather than points. We also require the relation IE and we will consider only those instances in which IE and IE cover all pairs of variables. To ensure that IE is the complement of IE we forbid the augmented pattern The semantics of the induced-edge relation IE is given by the following rules: 1. IE is symmetric. 2. If there is a negative edge between variables x and y, then IE (x, y). 3. If x < z, y < z, IE (x, z) and IE (y, z), then IE (x, y).
These rules can easily be coded using forbidden augmented patterns involving <, IE and IE . Symmetry is coded by the forbidden pattern Rule 2, above, can be imposed by forbidding the augmented pattern shown in Fig. 7. Rule 3 can be coded by the forbidden pattern: In order to impose a bound of k on the tree-width of the constraint graph, there must exist a total variable order and relations IE , IE (x, y) (that cover all pairs of variables) such that the following augmented pattern does not occur: This corresponds to a well-known characterisation of graphs with bounded treewidth as subgraphs of k-trees [22,24]. This example illustrates the fact that we need to apply a filter to the set of instances I defined by forbidding a set of augmented patterns. In this case, the filter is that I is completely specified, < is a total order on variables and IE , IE form a cover. When defining tractability of augmented patterns, we are only concerned in deciding instances satisfying the filter. Another example which motivates the use of augmented patterns is the study of tractable languages. All known tractable constraint languages are defined by the existence of a polymorphism (a pointwise closure operation) which guarantees tractability [27]. Indeed, tractability is guaranteed by the identities satisfied by the polymorphism [4]. The existence of a polymorphism satisfying any given set of identities can be stated in terms of a forbidden augmented pattern. Indeed, an augmented pattern can enforce the fact that the constraints of the instance must all have a polymorphism f and other patterns can enforce the identities that f must satisfy. By existentially quantifying over f we can then define the class of all instances whose constraints all have some majority polymorphism f , for example, or all of whose constraints have a Siggers polymorphism [39].
We illustrate this for weak near-unanimity polymorphisms, given their importance in the characterisation of tractable languages [3,41]. A binary CSP instance I has the k-ary polymorphism f : D k → D if for all binary relations R of I we have ∀ (a 1 , b 1 ), . . . , (a k , b k ) ∈ R, (f (a 1 , . . . , a k ), f(b 1 , . . . , b k )) ∈ R. The first step to expressing the fact that a binary CSP instance has the k-ary polymorphism f is to forbid the augmented pattern POLY k (f ) shown in Fig. 8 for the case k = 4. A weak near-unanimity operation is a function f : D k → D satisfying the  identities f (b, a, . . . , a) = f (a, b, a, . . . , a) = . . . = f (a, . . . , a, b). These identities are equivalent to forbidding each of the following augmented patterns (f (b, a, . . . , a) = c) ∧ (f (a, b, a, . . . , a) a, a, b, a, . . . , a) . . . For some fixed k, after forbidding these augmented patterns (the polymorphism pattern POLY k (f ) as illustrated in Fig. 8 together with the above patterns corresponding to the identities of a weak near-unanimity polymorphism of arity k), we obtain a set of instances. We then have to apply a filter so that we only keep those instances I = A I , ρ I in which f is a total function and such that all domains are closed under f , i.e. for all x ∈ X and for all a 1 , . . . , a k ∈ D such that (x, a i ) ∈ A I (i = 1, . . . , k), we have ( x, f (a 1 , . . . , a k )) ∈ A I . This example again illustrates the fact that tractability of augmented patterns depends on the existence of a polynomial-time algorithm to decide instances satisfying the corresponding filter.
Another motivating example involves a colouring of points. Suppose that both S 1 and S 2 are tractable sets of flat patterns. Then we know that S 1 + S 2 defines the tractable class of instances in which either S 1 does not occur or S 2 does not occur. The number of patterns in S 1 +S 2 is (in the worst case) quadratic in the size of S 1 and S 2 . We can give a set of augmented patterns which is linear in the size of S 1 and S 2 as follows. We augment each pattern in S 1 by colouring all its points red and each pattern in S 2 by colouring all its points green. We then add a pattern consisting of two points, one red and the other green. The set of instances for which there is a 2-colouring of its points in which none of these augmented patterns occurs is exactly the set of instances in f (S 1 ) ∪ f (S 2 ).

Augmented Patterns: Definitions
An augmented pattern is simply a flat pattern together with a conjunction of atomic formulas such as R i (p 1 , . . . , p ai ) where each R i is a relation (of arity a i ) and p 1 , . . . , p ai are points. An augmented pattern P occurs in another augmented pattern Q if there is a mapping from P to Q which corresponds to the occurrence of the flat version of P in the flat version of Q and which also preserves the new relation(s) R i . The new relation(s) R i may, for example, correspond to an order. As an example, the augmented pattern in Fig. 9(a) does not occur in the augmented pattern in Fig. 9(b) since the variable order is not preserved. On the other hand, the pattern P 1 in Fig. 1 does occur in Fig. 9(b) since there is no variable order in P 1 to preserve.
As a starting point, we can consider instances augmented with one or more new relation(s). In other words we consider structured instances (e.g. instances with an order on the variables). As usual, in order to establish a Galois connection, we have to consider the lattice of all generic instances including partiallyspecified instances (partial in the sense that certain pairs of points are joined by neither a negative nor a positive edge or the new relations do not form a cover, e.g. the variable order is only partial). The operations × and + and the functions f and g are defined as for sets of flat patterns. In particular, in P + Q there is no relation (e.g. no variable ordering) between the copies of P and Q in P + Q. The two lattice structures and the Galois connection between them follow from exactly the same arguments as for flat patterns. However, our aim is to consider the existential quantification of the relations (variable ordering, polymorphism, colouring) associated with a (set of) augmented pattern(s). As an example of an augmented pattern, consider the broken-triangle pattern (BTP) [16] shown in Fig. 9(a). We associate with this pattern all instances for which there is some variable ordering for which BTP does not occur. It turns out that, in the case of BTP, it is decidable in polynomial time whether such a variable ordering exists [16]. In general, each structured instance (e.g. an instance with new relations such as a variable ordering) has a corresponding flat version in which the new relations are forgotten, and our aim is to establish a Galois connection between sets of flat instances and augmented patterns.
We would like to establish a Galois connection between the set of sets of flat generic instances T and the set of sets of augmented patterns which we denote by S A . However, this does not seem possible. Instead we present in Sect. 8 a Galois connection between T and Σ A the set of sets of sets of augmented patterns. Each σ ∈ Σ A is a set of the form {S 1 , S 2 , . . .} where each S i ∈ S A is a set of patterns. Observe that since every element S of S A has a corresponding singleton element {S} in Σ A , we can consider Σ A as an extension of S A . We extend our definition of from S A to Σ A as follows: σ 1 σ 2 if ∀S 2 ∈ σ 2 , ∃S 1 ∈ σ 1 such that S 1 S 2 . We define Σ A to be the set of equivalence classes with respect to the equivalence relation in Σ A .
We first have to understand the lattice structure of Σ A , ≤ , where σ 1 ≤ σ 2 if and only if σ 2 σ 1 . The meet and join operations of this lattice are the operations + and ∪. This follows from the following lemmas.
We fix a relational signature. Indeed, for simplicity of presentation, in the following we assume that there is a single new relation Rel of a fixed arity a (which could be the cartesian product of several relations). We denote by REL the set of all possible functions from the set of (flat) instances to the set of relations of arity a. Thus, given a flat instance I ∈ I and a function Rel ∈ REL, I, Rel(I) is an augmented version of I (e.g. the instance I with an ordering on its variables). We can now define occurrence of a set S ∈ S A of augmented patterns in an instance I ∈ I as ∀Rel ∈ REL, ∃P A ∈ S such that P A → I, Rel(I) . Hence, S does not occur in I if ∃Rel ∈ REL such that ∀P A ∈ S, P A I, Rel(I) .
Thus occurrence of a set S of augmented patterns depends on a single quantification over REL. This is the reason why we need to consider sets of sets of augmented patterns to obtain a Galois connection.

A Galois Connection for Augmented Patterns
In order to establish a Galois connection between Σ A and T , we require the following functions F : Σ A → T and G : T → Σ A .

G(T ) = {S ∈ S A | ∀I ∈ T, ∃Rel ∈ REL such that ∀P ∈ S, P I, Rel(I) }
To give a concrete example to illustrate the definition of F , if S contains patterns which when forbidden impose that Rel is a partial order on the variables, then F ({S}) only contains instances equipped with a partial order on their variables. As in the case of BTP, we may want to impose a total order on the variables. F ({S}) contains many instances which are either incompletely specified or for which Rel is not total; such instances can be recognised (and filtered out) in polynomial time and thus are irrelevant for deciding whether S is tractable or not, but are essential for the Galois connection. This is analogous to the Galois connection for flat pattern where f (S) included incompletely-specified instances.
Given a set of instances T , there may be more than one way of describing T using forbidden augmented patterns. For example, let S 1 be the set of augmented patterns imposing a partial order on variables (as described in Sect. 6) together with the pattern BTP shown in Fig. 9(a), and let S 2 be identical to S 1 except that BTP is replaced by the pattern in Fig. 9(b). It is easy to see that F ( Theorem 6. The functions F and G define an antitone Galois connection between Σ A and T . Proof. To show that we have an antitone Galois connection between Σ A and T , it suffices to show that ∀σ ∈ Σ A , ∀T ∈ T , T ≤ F (σ) ⇔ σ ≤ G(T ). This corresponds to (T → F (σ)) ⇔ (G(T ) σ). By definition, T → F (σ) if and only if ∀I T ∈ T , ∃I ∈ I with I T → I and such that ∀S ∈ σ, ∃Rel ∈ REL such that ∀P ∈ S, P I, Rel(I) . Thus T → F (S) if and only if ∀I T ∈ T , ∀S ∈ σ, ∃Rel ∈ REL such that ∀P ∈ S, P I, Rel(I) . On the other hand, G(T ) σ if and only if ∀S ∈ σ, ∃S ∈ S A with S S and such that ∀I ∈ T , ∃Rel ∈ REL such that ∀P ∈ S , P I, Rel(I) . Thus
The Galois connection is similar to the Galois connection between T and S, as demonstrated by the following results.
The lattice structure of Σ A and Theorems 7 and 8 are illustrated in Fig. 10. Proof. G(T 1 × T 2 ) = {S ∈ S A | ∀I ∈ T 1 × T 2 , ∃Rel ∈ REL such that ∀P ∈ S, P I, Rel(I) } = {S ∈ S A | ∀I 1 ∈ T 1 , ∀I 2 ∈ T 2 , ∃Rel ∈ REL such that ∀P ∈ S, P I 1 × I 2 , Rel(I 1 × I 2 ) }. Now, for any Rel ∈ REL, I 1 , Rel(I 1 ) × I 2 , Rel(I 2 ) → I 1 × I 2 , Rel(I 1 × I 2 ) . Thus P I 1 × I 2 , Rel(I 1 × I 2 ) implies P I 1 , Rel(I 1 ) × I 2 , Rel(I 2 ) which (by an immediate extension of Lemma 2 to augmented patterns) is equivalent to (P I 1 , Rel(I 1 ) ) ∨ (P I 2 , Rel(I 2 ) ). It follows from the above that G(T 1 × T 2 ) ⊆ {S ∈ S A | ∀I 1 ∈ T 1 , ∀I 2 ∈ T 2 , ∃Rel ∈ REL such that (P I 1 , Rel(I 1 ) ) ∨ (P I 2 , Rel(I 2 ) )}. But, the latter is equal to {S ∈ S A | (∀I 1 ∈ T 1 , ∃Rel ∈ REL such that (P I 1 , Rel(I 1 ) )) ∨ (∀I 1 ∈ T 2 , ∃Rel ∈ REL such that P In order to show G(T 1 ) ∪ G(T 2 ) ⊆ G(T 1 × T 2 ), and hence to complete the proof, without loss of generality, we only need to show G(T 1 ) ⊆ G(T 1 × T 2 ). Consider S ∈ G(T 1 ). We have ∀I 1 ∈ T 1 , ∃Rel 1 ∈ REL such that ∀P ∈ S, P I 1 , Rel 1 (I 1 ) . Therefore, for all common factors I of I 1 and I 2 , ∃Rel ∈ REL such that ∀P ∈ S, P I, Rel(I) . Indeed, we can clearly choose Rel = Rel 1 for each such I. Now I 1 × I 2 is the juxtaposition of copies of such common factors I. These copies are comprised of disjoint sets of points. For each such copy of a common factor I composing I 1 × I 2 , there is a corresponding version of Rel 1 (I) which we denote by Rel I (I). The relations Rel I (I) are disjoint (since within I 1 × I 2 each common factor I is comprised of disjoint sets of points). Let R be the relation which is the union of all these Rel I (I). Then ∃Rel ∈ REL such that Rel(I 1 × I 2 ) = R. Now ∀P ∈ S, P I 1 × I 2 , Rel(I 1 × I 2 ) . Therefore S ∈ G(T 1 × T 2 ) which completes the proof.
Theorems 9 and 10 are illustrated in Fig. 11.   Fig. 11. The function G from T to ΣA In order to define tractability of sets of augmented patterns we must apply a filter to instances so that we only consider completely-specified instances with a certain property. Examples of filters include the property that an ordering relation is total or that two relations (such as the relations IE and IE that we introduced in Sect. 6) form a cover of all pairs of assignments to distinct variables. For example, in the case of BTP, we are only interested in instances equipped with a total ordering on the variables, since the pattern shown in Fig. 9(a) trivially does not occur on variables which are not ordered. This leads to the following definition of tractability. Definition 3. Let F be a property of instances I ∈ I that can be verified in polynomial time. We say that σ ∈ Σ A is tractable (with respect to the filter F) if there is a polynomial-time algorithm to decide the set of completely-specified instances in F (σ) (which satisfy the filter F). In particular, we say that S ∈ S A is tractable (w.r.t. F) if {S} is tractable (w.r.t. F). Proposition 9. The tractable elements of Σ A form a sublattice. Furthermore, the tractable sets of augmented patterns form a join semi-lattice of S A .

Discussion and Conclusion
In this paper we have initiated the study of the Galois connection between lattices of sets of forbidden patterns and sets of instances. The consequences of this Galois connection for expressibility and tractability questions remains largely unexplored. However, we have shown that the tractable sets of patterns form a sub-lattice.
Augmented patterns provide a rich language in which we can define many interesting classes of instances in a concise form, notably by adding an order on the variables or the values. We have seen that both bounded treewidth and the existence of a polymorphism satisfying a set of identities can be expressed using augmented patterns (together with a filter on the set of instances). This leads to an orthogonal question of the tractability of the recognition of classes defined by augmented patterns. For example, given a binary CSP instance, it is NPhard to determine whether there exists an ordering of the values under which all relations are max-closed [25]. On the other hand, it is tractable to decide whether the relations have a conservative Mal'tsev polymorphism [6]. Determining the tractability frontier of this meta-problem is an open question for augmented patterns. As we have pointed out, the recognition problem is always tractable for finite sets of flat patterns.
It is natural to ask whether the Feder-Vardi dichotomy [23] (for classes of CSP instances defined by finite languages of constraint relations) generalises to classes of CSP instances defined by augmented patterns. However, we know that no such P/NP-hard dichotomy can exist by the work on lifted patterns by Kun and Nešetřil [33] and by Ladner's theorem [34]. It is an open question whether classes of CSP instances defined by forbidding flat patterns exhibit a dichotomy in the following sense: all finite sets of patterns are either tractable or NP-complete. We conjecture that this is true.