Tractable Combinations of Temporal CSPs

The constraint satisfaction problem (CSP) of a first-order theory T is the computational problem of deciding whether a given conjunction of atomic formulas is satisfiable in some model of T. We study the computational complexity of CSP$(T_1 \cup T_2)$ where $T_1$ and $T_2$ are theories with disjoint finite relational signatures. We prove that if $T_1$ and $T_2$ are the theories of temporal structures, i.e., structures where all relations have a first-order definition in $(Q;<)$, then CSP$(T_1 \cup T_2)$ is in P or NP-complete. To this end we prove a purely algebraic statement about the structure of the lattice of locally closed clones over the domain $Q$ that contain Aut$(Q;<)$.


Introduction
Deciding the satisfiability of formulas with respect to a given theory or structure is one of the fundamental problems in theoretical computer science. One large class of problems of this kind are Constraint Satisfaction Problems (CSPs). For a finite relational signature τ , the CSP of a τ -theory T , written CSP(T ), is the computational problem of deciding whether a given finite set S of atomic τ -formulas is satisfiable in some model of T . A general goal is to identify theories T such that CSP(T ) can be solved in polynomial time.
Many theories that are relevant in program verification and automated deduction are of the form T 1 ∪ T 2 where the signatures of T 1 and T 2 are disjoint; satisfiability problems of the form CSP(T 1 ∪ T 2 ) are also studied in the field of Satisfiability Modulo Theories (SMT). If we already have a decision procedure for CSP(T 1 ) and for CSP(T 2 ), then, under certain conditions, we can use these decision procedures to construct a decision procedure for CSP(T 1 ∪T 2 ) in a generic way. Most results in the area of combinations of decision procedures concern decidability, rather than polynomial-time decidability; see for example [Ghi04, TR03, BGN + 06, Rin96]. We are particularly interested in polynomial-time decidability and the borderline to NP-hardness. The seminal result in this direction is due to Greg Nelson and Derek C. Oppen, who provided a criterion assuring that satisfiability of conjunctions of atomic and negated atomic formulas can be decided in polynomial time [NO79,Opp80]. The work R mix := (a 1 , a 2 , a 3 ) ∈ Q 3 | (a 1 = a 2 ) ∨ (a 3 < a 1 ∧ a 3 < a 2 ) = (a 1 , a 2 , a 3 ) ∈ Q n | a 3 ≥ min(a 1 , a 2 ) ⇒ a 1 = a 2 . Theorem 1.3. Let A be a countably infinite ω-categorical structure with finite relational signature and without algebraicity. If A can prevent crosses, then CSP(Th(Q; <, R mix ) ∪ Th(A)) is NP-hard.
Examples of ω-categorical structures without algebraicity and with cross prevention can be found in Section 6.
Our third contribution is the algebraic cornerstone of this article, which is a result about the definability of R mix . If R is a temporal relation, then −R denotes the dual of R, which is the temporal relation {(a 1 , . . . , a n ) ∈ Q n | (−a 1 , . . . , −a n ) ∈ R}. The dual of an operation f : Q n → Q is defined by (x 1 , . . . , x n ) → −f (−x 1 , . . . , −x n ). Hence, for any temporal relation R and any operation f on Q, the operation f preserves R if and only if the dual of f preserves the dual of R. The functions min, min, mx and ll will be explained in Section 2.5.
Theorem 1.4. Let A be a first-order expansion of (Q; <) with a finite relational signature such that min, mi, mx, ll or one of their duals is a polymorphism of A. Then the following are equivalent: • A does not have a binary injective polymorphism.
• R mix or its dual −R mix has a primitive positive definition in A.
Theorem 1.4 characterises the first-order expansions of (Q; <) among the polynomialtime tractable cases in the dichotomy of Bodirsky and Kára (see Theorem 2.9) whose first-order theory does not satisfy the weakened tractability conditions by Nelson and Oppen because = is not independent from their theory (see Section 2.3 for the definition).
1.2. Significance of the Result in Universal Algebra. Theorem 1.4 is of independent interest in universal algebra; for an introduction to the universal-algebraic concepts that appear in this section we refer the reader to Section 2.2. Theorem 1.4 can be seen as a result about locally closed clones on a countably infinite domain B that are highly set-transitive. A permutation group G on a set B is said to be highly set-transitive if for all finite subsets S 1 and S 2 of B of equal size there exists a permutation in G that maps S 1 to S 2 . An operation clone on a set B is said to be highly set-transitive if it contains a highly set-transitive permutation group.
It can be shown that the highly set-transitive locally closed clones are precisely the polymorphism clones of temporal structures (possibly with infinitely many relations), up to a bijection between B and Q [BK09]. These objects form a lattice: the meet of two clones is the intersection of the clones and the join can be obtained as the polymorphism clone of all relations preserved by both of the clones (see, e.g., Section 6.1 in [Bod21]). Similarly, as the lattice of clones over the set {0, 1} plays a fundamental role for studying finite algebras (it has been classified by Post [Pos41]), the lattice of locally closed highly set-transitive clones over Q is of fundamental importance for the study of locally closed clones in general. This lattice is of size 2 ω even if we restrict our attention to closed clones that contain all permutations [BCP10]. However, the lower parts of the lattice appears to be more structured and amenable to classification. We pose the following question.
Question 1.5. Are there only countably many locally closed highly set-transitive clones over a fixed countably infinite set that do not contain a binary injective operation? Question 1.5 has a positive answer in the case that the clone contains all permutations of the base set [BCP10]. Theorem 2.6 below shows that answering Question 1.5 can be split into finitely many cases, depending on whether the clone contains a constant operation, or whether it preserves one out of a finite list of temporal relations. Theorem 1.4 shows that in case 1 of Theorem 2.9, we can even focus on clones that preserve the relation R mix or its dual.
1.3. Outline of the Article. We first recall some basic concepts from model theory in Section 2.1. Then, the classical Nelson-Oppen conditions for obtaining polynomial-time decision procedures for combined theories are presented in Section 2.3; a slight generalisation of their results can be found in Section 3. We then define the model-theoretic notion of a generic combination of two structures with disjoint relational signatures in Section 2.4, which plays a crucial role in our proof. The reason is that we may apply universal algebra to study the complexity of CSPs of structures but not of theories. Basic universal-algebraic concepts are introduced in Section 2.2. Our results build on the classification of the temporal CSPs that can be solved in polynomial time [BK09], which we present along with other known facts about temporal structures in Section 2.5.
The proof of Theorem 1.4 is organised as follows. The difficult direction is to find a primitive positive definition of R mix in A if A is not preserved by a binary injective polymorphism. If Pol(A) contains mi, then the proof is easier if ≤ is primitively positively definable in the structure A. If the relation ≤ is not primitively positively definable in A, then a certain operation mix is a polymorphism of A. We discuss mix in Section 4 and use results thereof in Section 5.1 to show the primitive positive definability of R mix in A.
The case that Pol(A) contains mx but not mi is treated in Section 5.2, and the case that Pol(A) contains min but neither mi nor mx is treated in Section 5.3. All of these partial results are put together in Section 5.4.
Finally, Section 6 uses our definability dichotomy theorem (Theorem 1.4) to prove the complexity dichotomy for combinations of temporal CSPs.
2.1. Model Theory. A relational signature is a set of relation symbols, each endowed with a natural number, stating its arity. Let τ be relational signature. A τ -structure A consists of a set A, the domain of A, and a relation R ⊆ A k for each R ∈ τ of arity k. We use the notation A = (A; R 1 , . . . , R n ) for relational structures with finite signature. A τ -formula is atomic if it is of the form x 1 = x 2 , ⊥ (the logical "false"), or R(x 1 , . . . , x n ) for R ∈ τ of arity n where x 1 , . . . , x n are variables. A literal is either an atomic formula or a negated atomic formula. A τ -formula is primitive positive (pp) if it is of the form ∃x k , x k+1 , . . . , x . φ(x 1 , . . . , x ) where φ is a conjunction of atomic τ -formulas and k ≥ 1 is allowed to be larger than , in which case all variables are unquantified. A τ -formula is existential positive if it is a disjunction of primitive positive formulas; note that every first-order formula which does not contain negation or universal quantification is equivalent to such a formula. A τ -theory is a set of first-order τ -sentences, i.e., τ -formulas without free variables. For a τ -strucutre A the (first-order) theory of A, denoted by Th(A), is the set of all first-order τ -sentences that hold in A. If T is a τ -theory and A a τ -structure, then A is a model for T , written A |= T , if all sentences in T hold in A. In particular A |= Th(A).
The CSP of a τ -structure A, written CSP(A), is the computational problem of deciding, given a conjunction of atomic τ -formulas, whether or not the conjunction is satisfiable in A. More generally, the CSP of a τ -theory T , written CSP(T ), is the computational problem of deciding whether a given conjunction of atomic τ -formulas is satisfiable in some model of T . Note that CSP(A) and CSP(Th(A)) are the same problem. Let A be a relational τ -structure and B a relational σ-structure with τ ⊆ σ.
If A is a τ -structure and φ(x 1 , . . . , x n ) is a τ -formula with free variables x 1 , . . . , x n , then the relation defined by φ is the relation {(a 1 , . . . , a n ) ∈ A n | A |= φ(a 1 , . . . , a n )}. We say that a relation is primitively positively definable in A if there is a primitive positive formula that defines R in A. First-order and existential positive definability are defined analogously. Notice that a definition of a relation R via a formula φ in the above way also yields a bijection between coordinates of tuples of R and the free variables of φ. We will use this bijection implicitly whenever we say that t ∈ R satisfies a formula on the free variables of φ.
If A can be obtained from B by deleting relations from B, then A is called a reduct of B, and B is called an expansion of A. If the signature of A equals τ , then the reduct A of B is also denoted by B τ . An expansion B of A is called first-order expansion if all relations in B have a first-order definition in A. The expansion of A by a relation R is denoted by (A; R). As usual, Aut(A) denotes the set of all automorphisms of A, i.e., isomorphisms from A to A. For k ∈ N and a ∈ A k , the set Aut(A)a := {(α(a 1 ), . . . , α(a k )) | α ∈ Aut(A)} is called the orbit of a.
The theory of (Q; <), or any first-order expansion thereof, has the remarkable property of ω-categoricity, that is, it has only one countable model up to isomorphism (see, e.g., [Hod97]). The class of ω-categorical relational structures can be characterised by the following theorem.
Theorem 2.1 Engeler, Ryll-Nardzewski, Svenonius, see [Hod97], p. 171. Let A be a countably infinite structure with countable signature. Then, the following are equivalent: (1) A is ω-categorical; (2) for all n ≥ 1 every orbit of n-tuples is first-order definable in A; (3) for all n ≥ 1 there are only finitely many orbits of n-tuples.
For instance, the projection of arity n to the i-th coordinate, denoted by π n i , preserves every relation over A. For a set S of relations over A we define Pol(S) as the set of all operations on A that preserve all relations in S. We define Pol(A) as Pol(S) where S is the set of all relations of A. Unary polymorphisms are also called endomorphisms of A; the set of all endomorphisms is denoted by End(A).
For a set S of functions on a set A we define Inv(S) ('invariants of S') as the set of all finitary relations over A which are preserved by all functions in S.
Theorem 2.2 [BN06], Theorem 4. Let A be a countable ω-categorical relational structure. Then a relation R over A is preserved by the polymorphisms of A if and only if R has a primitive positive definition in A.
As a consequence of Theorem 2.2, we may go back and forth between the existence of certain polymorphisms and the primitive positive definability of certain relations. Furthermore, Theorem 2.2 implies that the set of polymorphisms of an ω-categorical relational structure A fully captures the complexity of CSP(A).
One of the central notions of universal algebra is that of a clone. A set of operations on a common domain is a clone if it contains all projections and is closed under composition of functions. Thus, if we fix the domain, an arbitrary intersection of clones is again a clone. Therefore, given a set of operations F over a common domain, there is a unique minimal clone F containing F , which we call the clone generated by F . For a clone F on domain A we will also need the local closure of F, denoted by F, which is the smallest clone which contains F and for any n ∈ N and g : A n → A the following holds: If for all finite S ⊆ A there exists f S ∈ F such that f S | S n = g| S n then g ∈ F. If F = F, then F is locally closed. It is easy to show that Pol(A) is always a locally closed clone for any relational structure A. Nelson and Oppen. In this section we recall the classical conditions of Nelson and Oppen on theories T 1 and T 2 with disjoint signatures that guarantee the polynomial-time tractability of CSP(T 1 ∪ T 2 ). Their condition can be found in [NO79,Opp80] and [BS01] and are the following:

The Conditions of
• Both theories T 1 and T 2 must be stably infinite, i.e., whenever a finite set of literals S is satisfiable in a model of the theory, then there is also an infinite model of the theory where S is satisfiable. • Both theories must be convex, i.e., if we choose a finite set of literals S such that for all i ∈ [n] there exist a model of the theory where S ∪{x i = y i } is satisfiable, then there exists a model of the theory where S ∪{x 1 = y 1 , . . . , x n = y n } is satisfiable. • For i = 1 and i = 2 there exist polynomial-time decision procedures to decide whether a finite set of τ i -literals is satisfiable in some model of T i . The theorem of Nelson and Oppen states that if T 1 and T 2 satisfy these three conditions, then there exists a polynomial-time procedure that decides whether a given set of literals over the signatures of T 1 and T 2 is satisfiable in a model of T 1 ∪ T 2 . Note that this decision problem is in general not equal to CSP(T 1 ∪ T 2 ), as S is restricted to atomic formulas in the latter. Nelson and Oppen always allow relations of the form x = y in the input, which we would like to avoid, because there are first-order expansions A of (Q; <) with a polynomial-time tractable CSP where adding the relation = to A makes the CSP hard, as the following examples shows.
Example 2.3. Let A be the temporal structure (Q; <, R min ≤ ) where R min ≤ is the relation defined by φ(x, y, z) := x ≥ y ∨ x ≥ z. Then CSP(A) is in P by Theorem 2.9 below because A is preserved by min. But CSP(A; =) is NP-hard by Theorem 2.9 because (A; =) is neither preserved by a constant operation, mi, mx, min, nor by their duals.
An analysis of the correctness proof of the algorithm of Nelson and Oppen yields that the set of literals in the definition of convexity can be replaced by a set of atomic formulas if the input of the decision problem is restricted to a set of atomic formulas, i.e., we only require that = is independent from T 1 and T 2 (see Definition 3.1). Independence of =, stably infinite theories, tractable CSPs and the presence of = in the signature of T 1 and T 2 is what we refer to as the weakened conditions of Nelson and Open. Furthermore, Nelson and Oppen did not require that the signature is purely relational. However, this difference is rather a formal one, because a function can be represented by its graph and nested functions can be unnested in polynomial time by introducing new existentially quantified variables for nested terms. In Section 3 we will prove a tractability criterion which is slightly stronger than the criterion of Nelson and Oppen with weakened conditions. 2.4. Generic Combinations. In the context of combining decision procedures for CSPs, the notion of generic combinations has been introduced in [BG20]. However, others have studied such structures before (for instance in [Cam90,KPT05,BPP15,LP15]).
Definition 2.4. Let A 1 and A 2 be countably infinite ω-categorical structures with disjoint relational signatures τ 1 and τ 2 . A countable model A of Th(A 1 ) ∪ Th(A 2 ) is called a generic combination of A 1 and A 2 if for any k ∈ N and any a, b ∈ A k with pairwise distinct coordinates All generic combinations of A 1 and A 2 are isomorphic (Lemma 2.8 in [BG20]), so we will speak of the generic combination of two structures, and denote it by A 1 * A 2 .
By definition, the τ i reduct of A := A 1 * A 2 is a model of Th(A i ), which is ω-categorical, and therefore, A τ i ∼ = A i for i = 1 and i = 2. Hence, we may assume without loss of generality that A 1 , A 2 , and A have the same domain. It is an easy observation that an instance φ 1 ∧ φ 2 of CSP(T 1 ∪ T 2 ), where φ i is a τ i -formula, is satisfiable if and only if for i = 1 and i = 2 there exist models A i of T i with |A 1 | = |A 2 | such that φ i is satisfiable in A i and the satisfying assignments of φ 1 and φ 2 identify exactly the same variables. Therefore, the fact that CSP(A) = CSP(Th(A 1 ) ∪ Th(A 2 )) easily follows from Aut(A τ 1 )a ∩ Aut(A τ 2 )b = ∅ and ω-categoricity of A 1 and A 2 .
A structure A has no algebraicity if every set defined by a first-order formula over A with parameters from A is either contained in the set of parameters or infinite. The following proposition characterises when generic combinations of ω-categorical structures exist.
Theorem 2.5 Proposition 1.1 in [BG20]. Let A 1 and A 2 be countably infinite ω-categorical structures with disjoint relational signatures. Then A 1 and A 2 have a generic combination if and only if either both A 1 and A 2 do not have algebraicity or one of A 1 and A 2 does have algebraicity and the other structure is preserved by all permutations.
2.5. Temporal Structures. A relation with a first-order definition over (Q; <) is called temporal. An example of a temporal relation is the relation Betw from the introduction. A temporal structure is a relational structure A with domain Q all of whose relations are temporal. The structure (Q; <) is homogeneous, i.e., every order-preserving map between two finite subsets of Q can be extended to an automorphism of (Q; <). Therefore, the orbit of a tuple in A is determined by identifications and the ordering among the coordinates. It follows from Theorem 2.1 that all temporal structures are ω-categorical.
2.5.1. Polymorphisms of Temporal Structures. One of the fundamental results in the proof of the complexity dichotomy for temporal CSPs, Theorem 2.6 below, also plays an important role for combinations of temporal CSPs. To understand Theorem 2.6 and for later use, we define the relations Cycl, Betw, and Sep: Theorem 2.6 Bodirsky and Kára [BK09], Theorem 20. Let A be a temporal structure. Then at least one of the following cases applies. • A has a constant endomorphism; • One of the relations <, Cycl, Betw, or Sep has a primitive positive definition in A. • A is preserved by all permutations of Q.
We introduce several notions that are needed to describe the polynomial-time tractable temporal CSPs from [BK09]. However, as opposed to [BK09] we flip the roles of 0 and 1 in the following definition because in this way the resulting systems of equations are homogeneous (see Theorem 2.11 (4) below; we follow [BPR20]).
Definition 2.7. For a tuple t ∈ Q n we define the min-indicator function χ : For an n-ary relation R we define Let min denote the binary minimum operation on Q. For any fixed endomorphisms α, β, γ of (Q; <) which satisfy α(a) < β(a) < γ(a) < α(a + ) for every a ∈ Q and every ∈ Q with > 0, the binary operation mi on Q is defined by The intuition behind this definition is best explained through illustrations; for such illustrations, additional explanation, and the argument why such functions do exist we refer the reader to [BK09] or [Bod21]; the same applies to the operations that are introduced in this section. For α, β satisfying the same conditions, mx is the binary operation on Q defined by Theorem 2.8 [BPR20], Lemma 4.1 and Theorem 5.2. We have Moreover, every temporal structure B preserved by mx either admits a primitive positive definition of X or is preserved by a constant operation or by min.
Let ll be an arbitrary binary operation on Q such that ll(a, b) < ll(a , b ) if and only if • a ≤ 0 and a < a , or • a ≤ 0 and a = a and b < b , or • a, a > 0 and b < b , or • a > 0 and b = b and a < a . Let lex : Q 2 → Q be an arbitrary operation that induces the lexicographic order on Q 2 (just like ll if the first argument is not positive). Let pp : Q 2 → Q be an arbitrary operation such that pp(a, b) ≤ pp(a , b ) if and only if either • a ≤ 0 and a ≤ a , or • 0 < a, 0 < a and b ≤ b holds. Notice that the functions mi, mx, pp, ll, their duals, and lex are not uniquely specified by their definitions. They rather specify a unique weak linear order on Q 2 . By Observation 10.2.3 in [Bod12], any two functions in Pol(Q; <) which generate the same weak linear order on Q 2 are equivalent with respect to containment in subclones of Pol(Q; <). Hence, we may assume the following additional properties for convenience: • mx(0, 0) = 1 and mx(1, 0) = 0, • mi(0, 0) = 0, mi(1, 0) = 1, mi(0, 1) = 2, mi(1, 1) = 3, • ll(0, 0) = 0, ll(1, 0) = 1, ll(2, 0) = 2, ll(3, 0) = 3 and ll(1, 1) = 4. The polymorphisms we presented are connected by the following inclusions (see [BK09] or Chapter 12 in [Bod21]). For m ∈ {min, mi, mx} and l ∈ {ll, dual-ll} we have 2.5.2. Complexity of Temporal CSPs. We can now state the complexity dichotomy for temporal CSPs.
Theorem 2.9 [BK09], Theorem 50. Let A be a temporal structure with finite signature. Then one of the following applies: (1) A is preserved by min, mi, mx, ll, the dual of one of these operations, or by a constant operation. In this case CSP(A), is in P.
In our proofs, we also need some intermediate results from [BK09]. In particular, we use the ternary temporal relation introduced in Definition 3 in [BK09]: T 3 is preserved by pp, but by none of the polymorphisms listed in item (1) of Theorem 2.9 and therefore CSP(Q; T 3 ) is NP-complete.
Theorem 2.10 [BK09], Lemma 36. Let A be a first-order expansion of (Q; <) preserved by pp. Then either T 3 has a primitive positive definition in A, or A is preserved by mi, mx, or min.

Known Syntactic Descriptions of Temporal Relations.
We also need syntactic descriptions for temporal relations preserved by the operations introduced in the previous sections.
(2) min if and only if R can be defined by a conjunction of formulas of the form (3) mi if and only if R can be defined by a conjunction of formulas of the form (4) mx if and only if R can be defined by a conjunction of {<}-formulas φ(x 1 , . . . , x n ) for which there exists a homogeneous system Ax = 0 of linear equations over GF 2 such that for every t ∈ Q n t satisfies φ if and only if Aχ(t) = 0.
In this case, there exists a homogeneous system Ax = 0 of linear equations over GF 2 with solution space χ 0 (R). (5) ll if and only if R can be defined by a conjunction of formulas of the form where the clause x 1 = · · · = x m may be omitted.
Note that the relation R mix can equivalently be written as Theorem 2.11 then implies that R mix is preserved by min and mi. To see that R mix is also preserved by mx, note that χ 0 (R mix ) = {(1, 1, 1), (1, 1, 0), (0, 0, 1), (0, 0, 0)}, which is the solution space of the linear equation x 1 = x 2 , and R mix contains all triples over Q whose min-tuple satisfies x 1 = x 2 . Every temporal relation can be defined by a quantifier-free {<}-formula φ and one may assume that φ is written in conjunctive normal form (CNF) We say that φ is in reduced CNF if we cannot remove any disjunct φ ,i from φ without altering the defined relation. If φ is in reduced CNF, then for any ∈ [k] and i ∈ I there exists t ∈ R that satisfies φ ,i and does not satisfy any other disjunct φ ,j for j ∈ I \ {i}. We use the symbols ≤, =, ≥, > as the usual shortcuts, for x < y ∨ x = y, etc. Clearly, every formula is equivalent to a formula in reduced CNF. Remarkably, the syntactic form in 2 is preserved by removing literals; hence, in 2 we may assume without loss of generality that the definition of R is additionally reduced.
2.6. Known Relational Generating Sets. Many important temporal structures A can also be described elegantly and concisely by specifying a finite set of temporal relations such that the temporal relations of A are precisely those that have a primitive positive definition in A. Note that such a finite set might not exist even if A contains all relations that are primitively positively definable in A. We need such a result for the temporal structure that contains all temporal relations preserved by pp.

Polynomial-Time Tractable Combinations
The following definition already appeared in [Bod21] and [BJR02] and is closely related to the convexity condition of Nelson and Oppen. The key difference to convexity of T is that we consider conjunctions of atomic formulas instead of conjunctions of literals.
Definition 3.1. Let T be a τ -theory. We say that = is independent from T if for any The following is easy to see (see, e.g., [Bod21]).
Proposition 3.2. For every structure A with a binary injective polymorphism, = is independent from Th(A). Nelson and Oppen require that both theories are stably infinite. We will make a weaker assumption captured by the following notion.
Definition 3.3. Let T 1 and T 2 be theories with signatures τ 1 and τ 2 , respectively. We say that T 1 and T 2 are cardinality compatible if for all for i ∈ [2] and all conjunctions φ i (x 1 , . . . , x n ) of atomic τ i -formulas, such that {∃x 1 , . . . , x n . φ i } ∪ T i has a model, there are models of {∃x 1 , . . . , x n . φ 1 } ∪ T 1 and {∃x 1 , . . . , x n . φ 2 } ∪ T 2 of equal cardinality. Clearly, if T 1 and T 2 are stably infinite, then they are also cardinality compatible. Contrary to stably infinite theories where we require that we can choose the cardinality of the models to be countably infinite, the definition of cardinality compatibility also allows theories with finite models only. We also allow theories where some formulas are only satisfiable in finite models while others have infinite models, as the following example shows.
Example 3.4. Let T be the theory {∀x, y (¬Q(x) ∨ x = y)} whose signature only contains the unary relation symbol Q. There is an infinite model for T where Q is empty. However, if φ is the formula Q(x), then all models for T ∪{φ} have exactly one element and this element is contained in Q. Hence, T is not stably infinite, but cardinality compatible with itself.
The sufficient conditions for polynomial-time tractability of CSP(T 1 ∪ T 2 ) given in the following theorem are slightly weaker than those by Nelson and Oppen. Theorem 3.5. Let T 1 and T 2 be cardinality compatible theories with finite, disjoint relational signatures and polynomial-time tractable CSPs. If = is independent from both T 1 and T 2 and = has an ep-definition in both T 1 and T 2 , then CSP(T 1 ∪ T 2 ) is polynomial-time tractable.
Proof. Let τ 1 and τ 2 be the signatures of T 1 and T 2 , respectively. Let S be a set of atomic τ 1 ∪ τ 2 -formulas with free variables among x 1 , . . . , x n . Then we may partition S into S 1 and S 2 such that S i is a set of τ i -formulas and S = S 1 ∪ S 2 . Without loss of generality, we may assume that all variables occur in both S 1 and S 2 (this can also be attained by introduction of dummy constraints like If, for a fixed tuple (x k , x l ), the answer is 'unsatisfiable' for all disjuncts of φ i , then we replace all occurrences of x l in S 1 and in S 2 by x k . We iterate this procedure until no more replacements are made. If S 1 or S 2 is unsatisfiable in all models of T 1 , T 2 respectively thereafter, we return 'unsatisfiable'. Otherwise, we return 'satisfiable'.
To prove that this algorithm is correct, notice that if S i ∪{D(x k , x l )} is unsatisfiable for all disjuncts D of φ i , then clearly S i ∪{x k = x l } is not satisfiable. Moreover, if S 1 or S 2 is unsatisfiable, then their union is unsatisfiable as well. Hence, the substitutions done by the algorithm do not change the satisfiability of S 1 ∪ S 2 in models of T 1 ∪ T 2 . Let us therefore assume that after the substitution process both S 1 and S 2 are satisfiable in some model of T 1 and T 2 , respectively. Without loss of generality we may assume that the variables x 1 , . . . , x m remain in S 1 and in S 2 . Furthermore, we know that S i ∪{x k = x l } is satisfiable for all k = l with k, l ≤ m and both i ∈ {1, 2}. Therefore, where σ(s i ) denotes σ(s i (y 1 ), . . . , s i (y k )) and y 1 , . . . , y k denote the variables in σ. By the cardinality compatibility of T 1 and T 2 , we may assume that M 1 and M 2 have the same cardinality. Therefore, there exists a bijection f : M 1 → M 2 between their domains such that f (s 1 (x k )) = s 2 (x k ) for all k ∈ [m]. With this bijection we define a τ 1 ∪ τ 2 structure M which is a model of T 1 ∪ T 2 via R M := R M 1 for R ∈ τ 1 , and a ∈ R M if and only if f (a) ∈ R M 2 for R ∈ τ 2 . This is well-defined, because the signatures of T 1 and T 2 are disjoint and because s 1 and s 2 are both injective. It is easy to verify that M is a model of T 1 ∪ T 2 and M |= σ∈S 1 σ(s 1 ) ∧ σ∈S 2 σ(s 1 ) and hence, the original instance is satisfiable.
The number of calls to the decision procedures for T 1 and T 2 is bounded by the number of pairs (x k , x l ) multiplied by the maximal number of rounds of substitutions and the number of disjuncts in φ 1 and φ 2 . Hence, the runtime of the algorithm is in O(n 3 ). Notice that the tractability result by Nelson and Oppen can be obtained as a special case of Theorem 3.5 when we consider theories which are stably infinite and where the set of atomic formulas is closed under negation. The following example shows that our condition covers strictly more cases already for combinations of temporal CSPs.
Example 3.6. For i = 1 and i = 2, let (Q; < i , ≤ i ) be a structure where < i denotes the usual strict linear order on the rational numbers, and ≤ i denotes the corresponding weak linear order. Let T i := Th(Q; < i , ≤ i ). Note that the relation = does not have a primitive positive definition in (Q; < i , ≤ i ); however, it has the existential positive definition x < 1 y ∨ y < 1 x. It is well-known that CSP(Q; < i , ≤ i ) can be solved in polynomial time [VKvB89] and that = is independent from T i [BJR02]. Then T 1 and T 2 satisfy the conditions from Theorem 3.5 but do not satisfy the conditions of Nelson and Oppen. 4. The Operation mix A certain temporal structure plays an important role in our proof; it contains the set of all temporal relations preserved by an operation, which we call mix, and which is similar to the polymorphisms mi and mx. We also present an equivalent description of these relations in terms of syntactically restricted quantifier-free {<}-formulas (Theorem 4.5).
Lemma 4.2. The locally closed clone generated by mix and Aut(Q; <) contains mi.
The relation R mix has the generalisation R mix n of arity n ≥ 3 defined as follows.
R mix n := (a 1 , . . . , a n ) ∈ Q n | min(a 3 , . . . , a n ) ≥ min(a 1 , a 2 ) ⇒ a 1 = a 2 (4.1) Note that R mix n (x 1 , . . . , x n ) has the following definition in CNF φ mix n (x 1 , . . . , x n ) := x 1 ≥ x 2 ∨ i∈{3,...,n} which is both of the form described in item 2 and of the form described in 3 in Theorem 2.11. Hence, R mix n is preserved by min and by mi. Also note that R mix = R mix 3 and that R mix (a, b, c) is equivalent to R mi (a, b, c) ∧ R mi (b, a, c) where The relation R mix n is also preserved by mx; we first prove this for R mix 3 . Lemma 4.3. For every n ≥ 3, the relation R mix n has a primitive positive definition in (Q; <, R mix ).

Proof.
A primitive positive definition of R mix n can be obtained inductively by the observation that R mix n (x 1 , . . . , x n ) is equivalent to the following formula.
Every tuple t ∈ R mix n satisfies (4.2): if t satisfies x 1 = x 2 or if t satisfies x n < min(x 1 , x 2 ), choose h = x 1 ; if t satisfies x i < min(x 1 , x 2 ) for some i ∈ {3, . . . , n − 1}, choose h = x 2 . Conversely, suppose that t ∈ Q n satisfies (4.2). If t satisfies x 1 = h, then t satisfies x 1 = x 2 = h or x n < x 1 ∧ x n < x 2 and therefore R mix n . The case that t satisfies x 2 = h is analogous. If t satisfies x n < h ∧ x n < x 2 and x i < x 1 ∧ x i < h for some i ∈ {3, . . . , n}, then it also satisfies min(x i , x n ) < min(x 1 , x 2 ) and hence t satisfies R mix n . Lemma 4.4. For every n ≥ 3, the operation mix preserves R mix n . Proof. To prove that mix preserves R mix n it suffices prove that mix preserves R mix due to Lemma 4.3 and Theorem 2.2. Suppose for contradiction that there are t 1 , t 2 ∈ R mix such that t 3 := mix(t 1 , t 2 ) ∈ R mix . Then t 3 must satisfy (x < y ∧ x ≤ z) ∨ (y < x ∧ y ≤ z). Without loss of generality we may assume that t 3 satisfies the first disjunct. As t 3 [x] is minimal in t 3 , the coordinate x must be minimal in either t 1 or t 2 . Assume the coordinate x is minimal in t 1 ; the case with t 2 can be proven analogously. Then t 1 satisfies x = y because t 1 ∈ R mix . If t 2 satisfies x = y then t 3 satisfies x = y, contrary to our assumptions. This implies that t 2 ∈ R mix satisfies z < min(x, y).

Theorem 4.5. A temporal relation is preserved by mix if and only if it has a definition by a conjunction of clauses of the form
and φ mix n (x 1 , x 2 , x 3 , . . . , x n ) for n ≥ 3. (4.4) Proof. Let R be a temporal relation preserved by mix. Due to Lemma 4.2, the relation R is also preserved by mi. By Theorem 2.11 case 3 the relation R can be defined by a conjunction φ of clauses of the form x > y i for n, m ∈ N (4.5) where the literal x ≥ y can be omitted. Let U φ be the set of clauses in φ which do have a literal of the form x ≥ y and which cannot be paired with another clause such that their conjunction is of the form φ mix k for some k. Without loss of generality, we may assume that φ is chosen such that |U φ | is minimal and such that no literal of the form x = z j can be replaced by x > z j without altering the relation defined by φ. If U φ is empty, then we are done. Suppose towards a contradiction that U φ contains a clause C := x ≥ y ∨ n 1 x = z i ∨ m 1 x > y i . Consider the new formulas φ 1 , . . . , φ n+3 obtained from φ by replacing C by, respectively, φ mix 2+n+m (x, y, z 1 , . . . , z n , y 1 , . . . , y m ), (4.8) or φ mix 2+n+m (z i , y, z 1 , . . . , z i−1 , x, z i+1 , . . . , z n , y 1 , . . . , y m ) for some i ∈ [n]. (4.9) Note that φ j implies φ for each j ∈ [n + 3]. Also note that if φ is equivalent to φ j we found a contradiction to our choice of φ because either |U φ j | < |U φ | or we can replace a literal of the form x = z j . This implies the existence of tuples t 1 , . . . , t n+3 ∈ R that do not satisfy φ 1 , . . . , φ n+3 , respectively. We start the analysis of these tuples with the special case n = 0. In this case we get • a tuple t 1 ∈ R that does not satisfy Clause (4.6). Since t 1 ∈ R it must satisfy U , and hence it satisfies x = y ∧ m i=1 x ≤ y i ; • a tuple t 3 ∈ R that does not satisfy Clause (4.8), i.e., t 3 satisfies x > y ∧ m i=1 y ≤ y i .  But then there exist α, β ∈ Aut(Q; <) such that t := mix(α(t 3 ), β(t 1 )) does not satisfy C.
The automorphisms α and β have nothing to do with α and β from the definition of mix, and their behaviour is illustrated in Table 1. The automorphism α maps the coordinate of t 3 corresponding to x in C to some value greater 0. Likewise for the other entries of Table 1. Therefore, t does not satisfy φ, contradicting the assumption that R is preserved by mix. If n ≥ 1 the tuples are as follows: • t 1 does not satisfy Clause (4.6), i.e., t 1 satisfies does not satisfy Clause (4.9) for i = 1, i.e., t 4 satisfies One of the following cases must apply: (1) R contains t 4,z 1 satisfying ψ z 1 := y > z 1 ∧ x > z 1 ∧ n j=2 z j ≥ z 1 ∧ m j=1 y j ≥ z 1 ; (2) R contains t 4,xz 1 satisfying ψ xz 1 := y > z 1 ∧ x = z 1 ∧ n j=2 z j ≥ z 1 ∧ m j=1 y j ≥ z 1 ; (3) R contains t 4,y satisfying ψ y := z 1 > y ∧ x > y ∧ n j=2 z j ≥ y ∧ m j=1 y j ≥ y; (4) R contains t 4,xy satisfying ψ xy := z 1 > y ∧ x = y ∧ n j=2 z j ≥ y ∧ m j=1 y j ≥ y. Using suitable automorphisms α 1 , . . . , α 6 ∈ Aut(Q; <), we deduce the following (see Table 2): • in case (1) there is also t 4,y ∈ R satisfying ψ y , so we are also in case (3); • in case (2) there is also t 4,y ∈ R satisfying ψ y , so we also in case (3); • in case (3) the tuple t * := mix(t 4,y , t 1 ) ∈ R does not satisfy C, a contradiction. • in case (4) there is also t 4,z 1 ∈ R satisfying ψ z 1 , so we are also in case (3). Hence, in each case we reached a contradiction, which shows that the assumption that U φ is non-empty must be false.
It remains to show that conjunctions of clauses of the form (4.3) and (4.4) are preserved by mix. It suffices to verify that every relation defined by a single clause of this form is preserved by mix. For the clauses of the form (4.4) we have already shown this in Lemma 4.4. Let S be the relation defined by n i=1 x = z i ∨ m i=1 x > y i . Suppose for contradiction that there exist t 1 , t 2 ∈ S such that t 3 := mix(t 1 , t 2 ) ∈ S. Then t 3 must satisfy x = z 1 = · · · = z n ∧ m i=1 x ≤ y i . Therefore, either t 1 or t 2 must satisfy C := x = z 1 = · · · = z n > y j for some j, because mix is only constant on a set of pairs if one coordinate is constant and the other coordinate is bigger or equal to the first one. Without loss of generality we may assume that t 1 satisfies C with j = 1.

Primitive Positive Definability of the Relation R mix
In this section we prove the following theorem.
Theorem 5.1. Let A be a first-order expansion of (Q; <) that is preserved by pp. Then R mix has a primitive positive definition in A if and only if A is not preserved by ll.
The proof of this results is organised as follows. If the relation T 3 is primitively positively definable in A, then so is R mix (Proposition 5.11). Otherwise, Theorem 2.10 implies that A is preserved by mi, mx, or min. It therefore suffices to treat first-order expansions A of (Q; <) that are • preserved by mi (Section 5.1), • preserved by mx but not by mi (Section 5.2), and finally • preserved by min but not by mi and not by mx (Section 5.3). 5.1. Temporal Structures Preserved by mi. In this section we prove Theorem 5.1 for first-order expansions A of (Q; <) that are preserved by mi (Proposition 5.6). For this purpose, it turns out to be highly useful to distinguish whether the relation ≤ has a primitive positive definition in A or not. If yes, then the statement can be shown directly (Proposition 5.2). Otherwise, A is preserved by the operation mix from Section 4 (Proposition 5.4). Then the syntactic normal form for temporal relations preserved by mix from Section 4 can be used to show the statement.
Proposition 5.2. Let A be a first-order expansion of (Q; ≤) which is preserved by mi but not by ll. Then R mi and R mix have a primitive positive definition in A. Proof. Let R be a relation of A which is not preserved by ll. As R is preserved by mi, Theorem 2.11 3 implies that R can be defined by a conjunction φ of clauses of the form We may assume that the literals x > y 1 , . . . , x > y m cannot be removed from such clauses without changing the relation defined by the formula. As R is not preserved by ll, Theorem 2.11 5 implies that φ must contain a conjunct C of the form However, if this is possible for all C with m ≥ 1, then R is preserved by ll, contradiction. So we may suppose that there exists a tuple t 1 ∈ R and j ∈ [m] such that For the sake of notation, we assume that j = 1. As the literal x > y 1 can not be removed from C without changing the relation defined by φ, there is a tuple t 2 ∈ R such that We may assume that x, y, y 1 , . . . , y m , z 1 , . . . , z n refer to the first 2 + m + n coordinates of R, in that order. Choose k ∈ N such that 2 + m + n + k is the arity of R and let u 1 , . . . , u k , y , z be fresh variables. The following is a primitive positive definition of R mi in A: ψ(x, y , z) := ∃y, y 1 , y 2 , . . . , y m , z 1 , . . . , z n , u 1 , . . . , u k y ≤ y ∧ z ≤ y 1 ∧ R(x, y, y 1 , . . . , y m , z 1 , . . . , z n , u 1 , . . . , To see this, first note that the quantifier-free part of ψ implies that x ≥ y ∨ x > y 1 , and hence that x ≥ y ∨ x > z. Conversely, choose (a, b, c) ∈ R mi . If a ≥ b then choose α ∈ Aut(Q; <) such that α(t 1 [x]) = a and α(t 1 [y 1 ]) ≥ c and set y = b and z = c. This is possible because . Then α(t 1 ) provides values for y, y 1 , . . . , u k which satisfy all conjuncts of ψ: the conjunct R(x, y, y 1 , . . . ) is satisfied because α(t 1 ) ∈ R, and for the other conjuncts this is immediate. Hence, ψ(a, b, c) holds. If a > c then choose α ∈ Aut(Q; <) such that α(t 2 [x]) = a, α(t 2 (y)) ≥ b and α(t 2 [y 1 ]) = c, y = b and z = c. This is possible because t 2 [y] > t 2 [x] > t 2 [y 1 ]. Then α(t 2 ) provides values for y, y 1 , . . . , u k which satisfy all conjuncts of ψ: the conjunct R(x, y, y 1 , . . . ) is satisfied because α(t 2 ) ∈ R and for the other conjuncts this is immediate.
The following proposition is similar to Proposition 10.5.13 in [Bod12].
Proposition 5.4. Let A be a temporal structure preserved by pp such that ≤ does not have a primitive positive definition in A. Then A is preserved by mix.
Proof. Let R be a k-ary relation of A and r, s ∈ R. We have to show that t := mix(r, s) is in R. Let α, β, γ ∈ End(Q; <) be from the definition of mix. Let v 1 < · · · < v l be the shortest sequence of rational numbers such that Observe that M 1 , . . . , M l is a partition of [k] and therefore defines a partition on {t 1 , . . . , t k }. Furthermore, for each i ∈ M j either v j = r i ≤ s i or v j = s i ≤ r i holds. This defines a partition of M j into three parts: Let α 1 , . . . , α l ∈ Aut(Q; <) be such that α j (v j ) = 0 for all j ∈ [l]. By Lemma 5.3 there is a binary f ∈ Pol(A) satisfying (5.1). For each j ∈ [l] we define u j := pp f (α j r, α j s), pp(α j s, α j r) It is easy to verify that for all i ∈ M j and w, w > 0 pp(1, 0)), if i ∈ M β j then u j i = pp(f (0, 0), pp(0, 0)) = pp(2, pp(0, 0)), and if i ∈ M γ j then u j i = pp(f (w, 0), pp(0, w )) = pp(0, 0).
In particular, u j is constant on each of M α j , M β j , M γ j and u j i > u j i for i ∈ M α j and i ∈ M β j . We apply f again to obtain z j := f (α j r, β j u j ) where β j ∈ Aut(Q; <) is such that β j (pp(2, pp(0, 0))) = 0. Then we get for all i ∈ M j and w > 0 that if i ∈ M α j then z j i = f (0, w) = 1, if i ∈ M β j then z j i = f (0, 0) = 2, and if i ∈ M γ j then z j i = f (w, e) < f (0, e ) = 0 for some e < e < 0. x y z i z j =i t := α 1 (t y,i ) 2 1 0 ≥ 1 t c := α 2 (t c ) 1 1 ≥ 1 ≥ 1 mix(t , t c ) 3 5 1 ≥ 3 Table 3: Calculation for Claim 2 (Case 2) in the proof of Proposition 5.5.
Thus, we found z 1 , . . . , z l ∈ R such that for all i ∈ M β j , i ∈ M α j , and i ∈ M γ j we have z j i > z j i > z j i . Take any j, j ∈ [l] such that j < j and choose i ∈ M β j and i ∈ M j . Then v j = r i = s i < v j = min(s i , r i ) and therefore z j i < z j i because f , pp, and all automorphisms preserve <. Therefore, we can apply Lemma 10.5.3 in [Bod12] to z 1 , . . . , z l which yields the existence of a tuple t * ∈ R with satisfies t * i < t * i if and only if there exists j < j such that i ∈ M j , i ∈ M j , and z j i < z j i . However, this is the same ordering that t satisfies and hence, t ∈ R.
Proposition 5.5. Let A be a first-order expansion of (Q; <) preserved by mix but not by ll.
Then R mix has a primitive positive definition in A.
Proof. Let R be a relation in A that is not preserved by ll. Lemma 4.5 implies that R can be defined by conjunctions of clauses the form (4.3) and (4.4). As R is not preserved by ll, any such definition must include at least on clause of the form (4.4). Consider a clause of the form (4.4), written in CNF φ mix Claim 1. Suppose that the literal x ≥ y can be replaced by x > y in C x without changing the relation defined by φ. Then we can also replace the literal y ≥ x by y > x in C y without changing the relation defined by φ.
The assumption implies that if x ≥ y is satisfied by a tuple t ∈ R then either t satisfies x > y, or t satisfies x = y and there exists i such that t satisfies x > z i . In the first case t satisfies y > z j (in order to satisfy C y ) and hence t still satisfies φ after replacing y ≥ x by y > x in C y . In the second case, t satisfies y = x > z i and thus again satisfies C y after the same replacement.
Claim 2. Suppose that for some i ∈ [n], the literal x > z i can be removed from C x without changing the relation defined by φ. Then y > z i can be removed from C y without changing the relation defined by φ.
Case 1: All tuples t ∈ R satisfy x ≤ z i , i.e., x > z i is never true. If there is t ∈ R such that t satisfies y > z i , then t also satisfies y > x. Hence, we can also remove y > z i from C y without altering the relation defined by the formula.
Case 2: There exists t ∈ R where x > z i holds. Suppose for contradiction that there exists a tuple t y,i ∈ R which does not satisfy C y after deletion of y > z i in C y . Then x y z k z i α 1 (t c ) 0 0 > 0 0 α 2 (t x,i ) 1 2 ≥ 1 0 t c := mix(α 1 (t c ), α 2 (t x,i )) 1 1 > 2 2 Table 4: Calculation of t c in the proof of Proposition 5.5.
As we already know that literal replacement can be applied to C (Claim 1), we can assume that no literal in φ can be replaced. Therefore, there exists t c ∈ R such that Then there exist α 1 , α 2 ∈ Aut(Q; <) such that mix(t y,i , t c ) satisfies y > x∧x > z i ∧ j =i z j ≥ x (see Table 3), contradicting the assumption that we can remove x > z i .
Claims 1 and 2 imply that we may assume without loss of generality that the literal x ≥ y cannot be replaced by x > y, that the literal x > z i cannot be removed from C x and, symmetrically, that y > z i cannot be removed from C y without changing the relation defined by φ. Hence, there are t c , t x,i , t y,i ∈ R such that for all 1 ≤ i ≤ n and t y,i satisfies z i < y < x ∧ j =i y ≤ z j .
Now we apply automorphisms and mix to t c , t x,i , and t y,i to prove that R contains tuples with more specific properties. We first prove that R must contain a tuple t * c satisfying x < z i .
Choose t c as above such that the number m of indices j ∈ [n] such that t c satisfies x < z j is maximal. If m = n, then t c satisfies (5.2) and hence satisfies the requirements for t * c . Otherwise, there exists i ∈ [n] such that t c satisfies x = z i ; this case will lead to a contradiction. Choose automorphisms α 1 , α 2 ∈ Aut(Q; <) such that α 1 (t c ) satisfies x = 0 and α 2 (t x,i ) satisfies z i = 0. Then satisfies z i > x and x = y (see Table 4). Moreover, if k ∈ [n] is such that α 1 (t c ) satisfies x < z k then t c satisfies x < z k as well. Hence, the number m of indices j ∈ [n] such that t c satisfies x < z j is at least m + 1, a contradiction to the choice of t c . Our next goal is to prove the existence of t * x,i , t * y,i ∈ R such that t * x,i satisfies z i < x < y ∧ j =i y < z j and t * y,i satisfies z i < y < x ∧ j =i x < z j .
Table 5: Calculation of t * x,i and t * y,i in the proof of Proposition 5.5.
To show that ψ defines R mix , first notice that t * x,1 , t * y,1 , and t * c satisfy ψ and that ψ implies x ≥ y ∨ x > z 1 and y ≥ x ∨ y > z 1 because all disjuncts of C x and C y involving z 2 , . . . , z n do not hold. This in turn implies that the set of orbits of (x, y, z 1 ) in tuples that satisfy ψ is contained in R mix . It follows that if (a, b, c) satisfies ψ , then either a = b, or there exists z 1 such that c < z 1 < min(a, b), so (a, b, c) ∈ R mix .
Conversely, let (a, b, c) be in R mix . If a = b and we may choose α ∈ Aut(A) such that Hence, α(t * x,1 ) shows that (a, b, c) satisfies ψ . The argument for c < b < a works with t * y,1 in an analogous way. Now we are ready to prove the main result of this subsection.
Proposition 5.6. Let A be a first-order expansion of (Q; <) which is preserved by mi, but not by ll. Then R mix has a primitive positive definition in A.
Proof. If ≤ is primitively positively definable in A, then Proposition 5.2 yields that R mix is primitively positively definable in A. If ≤ is not primitively positively definable in A then Proposition 5.4 yields that A is preserved by mix. In this case Proposition 5.5 implies that R mix is primitively positively definable. 5.2. Temporal Structures Preserved by mx. In this section we consider first-order expansions of (Q; <) that are preserved by mx. We distinguish the cases whether X is primitively positively definable in A or not. Theorem 2.8 implies that if X is not primitively positively definable in A, then A is also preserved by min. So we first consider the situation that A is preserved by both mx and min. For R ⊆ Q n , t = (t 1 , . . . , t n ) ∈ R and I = {i 1 , . . . , i l } ⊆ [n] we write π I (t) for the tuple (t i 1 , . . . , t i l ) where i 1 < i 2 < · · · < i l and π I (R) for the relation {π I (t) | t ∈ R}.
Proposition 5.7. Let A be a first-order expansion of (Q; <) that is preserved by mx and min. Then A is preserved by mi.
Proof. Let R be a relation in A. The proof proceeds by induction on the arity n of R. For n = 1, or if R is empty, there is nothing to be shown. Suppose that the statement holds for all relations of arity less than n and that R is not empty. For every I ⊆ [n] we fix a homogeneous system A R I x = 0 of Boolean linear equations with solution space χ 0 (π I (R)), which exists due to case 4 in Theorem 2.11. As R is preserved by min, the Boolean maximum operation preserves χ 0 (π I (R)). Furthermore, the solution space of a system of homogeneous linear equations over GF 2 is also preserved by the operation (x, y, z) → x + y + z mod 2 (because it is a subspace of GF 3 2 ), we get that χ 0 (π I (R)) is also preserved by min because min(x, y) = max(x, y) + x + y mod 2. For every pair t, t ∈ R we want to show that mi(t, t ) ∈ R. If min(t) = min(t ), we consider the set S : and distinguish two cases: (1) If S = ∅ then χ(mi(t, t )) = min(χ(t), χ(t )) ∈ χ(R).
Thus, there exists a tuple c ∈ R with χ(c) = χ(mi(t, t )). Let I := {i | χ(c)[i] = 1} and observe that I is non-empty. By induction hypothesis, the statement holds for π [n]\I (R) and we have π [n]\I (mi(t, t )) = mi(π [n]\I (t), π [n]\I (t )) ∈ π [n]\I (R). Therefore, there exists r ∈ R with π [n]\I (mi(t, t )) = π [n]\I (r). We can apply an automorphism of (Q; <) to r to obtain a tuple r ∈ R where all entries are positive. We can also apply an automorphism to c to obtain a tuple c ∈ R so that its minimal entries are 0 and for every other entry i ∈ [n] \ I it holds that c [i] > r [i]. Then mx(c , r ) yields a tuple in R which is minimal at the coordinates in I and all other coordinates are ordered like the coordinates in r, i.e., mx(c , r ) is equal to mi(t, t ) under an automorphism. Hence, mi(t, t ) ∈ R, i.e., R is preserved by mi.
Proposition 5.8. Let A be a first-order expansion of (Q; <) that is preserved by mx but not by mi. Then R mix is primitively positively definable in A.
Proof. First suppose that X is primitively positively definable in A. It is easy to check that ∃h X(z, z, h) ∧ X(x, y, h) primitively positively defines R mix (x, y, z), and hence R mix is primitively positively definable in A. Otherwise, if X is not primitively positively definable in A, then Theorem 2.8 implies that A is also preserved by min, and hence by mi by Proposition 5.7, which contradicts our assumptions. 5.3. Temporal Structures Preserved by min. This section treats first-order expansions of (Q; <) that are preserved by min but not by mi and mx. We first show that we may assume that ≤ has a primitive positive definition in A. Lemma 5.9. Let A be a first-order expansion of (Q; <) which is preserved by pp and does not admit a primitive positive definition of ≤. Then A is preserved by mi or by mx.
Proof. By Theorem 2.2 there exists an f ∈ Pol(A) that does not preserve ≤. As ≤ is a union of two orbits of Aut(Q; <) = Aut(A), there is a binary polymorphism f of A that does not preserve ≤ by Lemma 10 in [BK09]. As A is also preserved by pp, Lemma 35 in [BK09] implies that A is preserved by an operation providing min-intersection closure or min-xor closure. Then A is preserved by mi or by mx by Proposition 27 and Proposition 29 in [BK09], respectively.
Proposition 5.10. Let A be a first-order expansion of (Q; <) preserved by min but not by mi and not by mx. Then R min ≤ , R mi , and R mix have a primitive positive definition in A. Proof. Let R be a relation of A that is not preserved by mi and let n be the arity of R. As R is preserved by min, it is definable by a conjunction φ of formulas where each conjunct is of the form as described in Theorem 2.11 2. Furthermore, there must be a clause C in φ that is not preserved by mi. By Theorem 2.11 3 C is of the form x > x 1 ∨ · · · ∨ x > x ∨ x ≥ y 1 ∨ · · · ∨ x ≥ y k with k > 1. Furthermore, we can assume that φ is in reduced CNF. Hence, there exist tuples t 1 , t 2 ∈ R witnessing that the literals x ≥ y 1 and x ≥ y 2 cannot be replaced by x > y 1 and by x > y 2 , respectively, i.e., Let z 1 , . . . , z m be all the variables from φ that do not occur in C. Without loss of generality, we may assume that the coordinates of R are in the following order: x, x 1 , . . . , x , y 1 , . . . , y k , z 1 , . . . , z m . As A is not preserved by mx, Lemma 5.9 implies that ≤ has a primitive positive definition in A; so we may assume that ≤ is among the relations of A. We claim that R min ≤ can be defined over A by the primitive positive formula φ(x, u, v) given as follows.
∃z 1 , . . . , z m , x 1 , . . . , x , y 1 , . . . , y k R(x, x 1 , . . . , x , y 1 , . . . , y k , z 1 , . . . , z m ) To prove the claim, let (a, b, c) ∈ R min ≤ . Assume that a ≥ b. There exists α ∈ Aut(A) such that t 1 := α(t 1 ) satisfies t 1 [x] = a and t 1 [y 2 ] > max(a, c). Now we extend t 1 by two coordinates, named u and v such that t 1 [u] = b and t 1 [v] = c. Then π {x,u,v} (t 1 ) = (a, b, c) and t 1 satisfies the quantifier-free part of φ. Therefore, φ(a, b, c) holds. The case where a ≥ c holds is handled analogously using t 2 instead of t 1 . Now suppose that (a, b, c) satisfies φ(x, u, v) and let t * be any tuple which satisfies the quantifier-free part of φ such that π {x,u,v} (t * ) = (a, b, c). Then t * satisfies C, and hence t * satisfies x ≥ y 1 ∨ x ≥ y 2 . Therefore, t * satisfies x ≥ u ∨ x ≥ v, i.e., t ∈ R min ≤ . It is easy to check that the formula ∃h (φ(x, h, y) ∧ h > z) is a primitive positive definition of R mi in A. Therefore, R mix is primitively positively definable in A as well (see note below Theorem 2.11).
5.4. Definability Dichotomy. In this section we prove Theorem 5.1, following the strategy outlined earlier, and subsequently we prove Theorem 1.4 Proposition 5.11. A temporal relation has a primitive positive definition in (Q; T 3 ) if and only if it is preserved by pp.
Proof. By Theorem 2.12, it suffices to prove that the relations =, R min ≤ , and S mi are primitively positively definable in (Q; T 3 ). Clearly, x ≤ y is equivalent to ∃z. T 3 (x, y, z) and x = y is equivalent to ∃z. T 3 (z, x, y). We claim that the following primitive positive formula defines R min ≤ in (Q; T 3 , ≤). φ(x, y, z) := ∃x , y , z T 3 (x , y , z ) ∧ x ≥ x ∧ y ≤ y ∧ z ≤ z Suppose that (a, b, c) ∈ R min ≤ holds. By the symmetry of the second and third argument in R min ≤ we may assume that a ≥ b holds. Choose a = b such that b ≤ a = b ≤ a holds and c > max(a , b , c). Then T 3 (a , b , c ) ∧ a ≥ a ∧ b ≤ b ∧ c < c holds and therefore (a, b, c) satisfies φ. For the converse direction, suppose for contradiction that (a, b, c) is not in R min ≤ but φ(a, b, c) holds. Then we have a < b ∧ a < c. The quantifier-free part of φ implies x ≤ a < b ≤ y and therefore x = z < y . However, c ≤ z = x ≤ a follows, contradicting a < c.
Finally, we claim that the formula ψ(x, y, z) := ∃u, v T 3 (x, u, v) ∧ (u = y) ∧ (v ≥ z) defines S mi . If (a, b, c) satisfies ψ we either have a = u = b or a = v ≥ c. Therefore (a, b, c) satisfies S mi . If (a, b, c) satisfies S mi we have two cases. If a = b, we choose u = a and v > max(c, a). Then b = a = u < v and v > c holds and therefore ψ(a, b, c) holds. If c ≤ a holds, then we choose v = a and u > max(a, b). Then c ≤ a = v < u = b holds, i.e., ψ(a, b, c) holds.
Proof of Theorem 5.1. =⇒: Suppose that R mix has a primitive positive definition in A.
Then A is not preserved by ll because R mix is not preserved by lex: consider for instance lex((0, 0, 1), (2, 3, 0)), which is in the same orbit as (0, 1, 2) and therefore not in R mix . ⇐=: Suppose that A is not preserved by ll. If the relation T 3 is primitively positively definable in A, then so is R mix by Proposition 5.11 because R mix is preserved by pp and we are done. Otherwise, Theorem 2.10 implies that A is preserved by mi, mx, or min. If A is preserved by mi, then R mix is primitively positively definable in A by Proposition 5.6. If A is preserved by mx but not by mi, then R mix is primitively positively definable in A by Proposition 5.8. If A is preserved by min but neither by mi nor by mx, then A primitively positively defines R mix by Proposition 5.10.
Proof of Theorem 1.4. Suppose that A does not have a binary injective polymorphism. Then A is preserved by min, mi, mx, or their duals. Therefore, A is preserved by pp or dual-pp by the inclusions presented in Section 2.5.1. If A is preserved by pp, then Theorem 5.1 implies that R mix is primitively positively definable in A. If A is preserved by dual-pp, the dual of A, i.e., the structure obained from A by substituting all relations by their duals, has pp • If R equals Betw 2 we claim that is a primitive positive definition of x = y. Again we give an equivalent expression which helps to verify the claim: ∃u, v ((x < 2 u < 2 v < 2 y) ∨ (y < 2 v < 2 u < 2 x)) ∧ (x < 1 u < 1 v) ∧ (y < 1 u) . In the latter, it is clear that x = y always holds and that all distinct x, y satisfy the formula. • If R equals Cycl 2 we claim that is a primitive positive definition of x = y. A case analysis of Cycl 2 (x, u, v) yields that the given formula is equivalent to ∧ (x < 1 u < 1 v) ∧ (y < 1 u) .

Conclusion and Outlook
Our results show that there are two temporal relations, namely R mix and its dual, with the property that every first-order expansion of (Q; <) where the weakened Nelson-Oppen conditions do not apply, i.e., = is not independent from their theory, can define one of these relations primitively positively. We also showed that CSP(Th(Q; R mix , <) ∪ Th(A)) is NP-hard for structures A that satisfy the fairly weak assumption of cross prevention and have a generic combination with (Q; <). These results can be used to prove a complexity dichotomy for combinations of temporal CSPs: they are either in P or NP-complete. Our results also motivate the following conjecture, which remains open in general.
Conjecture 7.1. Let A 1 and A 2 be countably infinite ω-categorical structures without algebraicity that are not preserved by all permutations and that have the cross prevention property. If • CSP(A i ) is in P and A i has a binary injective polymorphism for both i = 1 and i = 2, or • A i has a constant polymorphism for both i = 1 and i = 2, then CSP(Th(A 1 ) ∪ Th(A 2 )) is in P. Otherwise, CSP(Th(A 1 ) ∪ Th(A 2 )) is NP-hard.