The Journal of Symbolic Logic Volume 81, Number 4, December 2016

THE REDUCTS OF THE HOMOGENEOUS BINARY BRANCHING C-RELATION

MANUEL BODIRSKY, PETER JONSSON, AND TRUNG VAN PHAM

Abstract. Let (L; C ) be the (up to isomorphism unique) countable homogeneous structure carrying a binary branching C-relation. We study the reducts of (L; C), i.e., the structures with domain L that are first-order definable in (L; C). We show that up to existential interdefinability, there are finitely many such reducts. This implies that there are finitely many reducts up to first-order interdefinability, thus confirming a conjecture of Simon Thomas for the special case of (L; C). We also study the endomorphism monoids of such reducts and show that they fall into four categories.

§1. Introduction. A structure r is called homogeneous (or sometimes ultrahomo-geneous in order to distinguish it from other notions of homogeneity that are used in adjacent areas of mathematics) if every isomorphism between finite substructures of r can be extended to an automorphism of r. Many classical structures in mathematics are homogeneous such as (Q; <), the random graph, and the homogeneous universal poset.

C-relations are central for the structure theory of Jordan permutation groups [1-3, 34]. They also appear frequently in model theory. For instance, there is a substantial literature on C-minimal structures which are analogous to o -minimal structures but where a C-relation plays the role of the order in an o -minimal structure [28, 36]. In this article we study the universal homogeneous binary branching C-relation (L; C ). This structure is one of the fundamental homogeneous structures [3, 24, 35] and can be defined in several different ways—we present two distinct definitions in Section 3. We mention that (L; C ) is the up to isomorphism unique countable C-relation which is existential positive complete in the class of all C-relations—see [9] for the notion of existential positive completeness.

If r has a finite relational signature (as in the examples mentioned above), then homogeneity implies that r is œ-categorical, that is, every countable model of the first-order theory of r is isomorphic to r. A relational structure A is called a reduct of r if A and r have the same domain and every relation in A has a first-order definition (without parameters) in r. It is well known that reducts of œ-categorical structures are again œ-categorical [31]. Two reducts A1 and A2 are

Received August 18, 2014.

2010 Mathematics Subject Classification. 03C07, 03C98, 20B27, 08A35, 05C55, 03C05. Key words and phrases. omega-categoricity, first-order reducts, tree-like structures, C-relation, homogeneous structures, model-completeness, endomorphism monoids.

© 2016, Association for Symbolic Logic 0022-4812/16/8104-0003 DOI:10.1017/jsl.2016.37

said to be first-order interdefinable if A1 is first-order definable in A2, and vice versa. Existential and existential positive1 interdefinability are defined analogously.

It turns out that several fundamental homogeneous structures with finite relational signatures have only finitely many reducts up to first-order interdefinability. This was shown for (Q; <) by Cameron [22] (and, independently and in somewhat different language, by Frasnay [27]), by Thomas for the the random graph [43], by Junker and Ziegler for the expansion of (Q; <) by a constant [32], by Pach, Pinsker, Pluhar, Pongracz, and Szabo for the homogeneous universal poset [40], and by Bodirsky, Pinsker and Pongracz for the random ordered graph [17]. Thomas has conjectured that all homogeneous structures with a finite relational signature have finitely many reducts [43]. In this paper, we study the reducts of (L; C) up to first-order, and even up to existential and existential positive interdefinability. Our results for reducts up to first-order interdefinability confirm Thomas' conjecture for the case of (L; C).

Studying reducts of «-categorical structures has an additional motivation coming from permutation group theory. We write S« for the group of all permutations on a countably infinite set. The group S« is naturally equipped with the topology of pointwise convergence. By the fundamental theorem of Engeler, Ryll-Nardzewski, and Svenonius, the reducts of an «-categorical structure r are one-to-one correspondence with the closed subgroups of S« that contain the automorphism group of r. The automorphism groups of «-categorical structures are important and well-studied groups in permutation group theory, and classifications of reducts up to firstorder interdefinability shed light on their nature. Indeed, all the classification results mentioned above make extensive use of the group-theoretic perspective on reducts.

Let us also mention that reducts of (L; C) are used for modeling various computational problems studied in phylogenetic reconstruction [13,20,21,29, 39,42]. When r is such a structure with a finite relational signature, then the constraint satisfaction problem (CSP) for the template r is the problem to decide for a finite structure A with the same signature as r whether there exists a homomorphism from A to r or not. For example, the CSP for (L; C) itself has been called the rooted triple consistency problem and it is known to be solvable in polynomial time by a nontrivial algorithm [4,13,29]. Other phylogeny problems that can be modeled as CSPs for reducts of (L; C) are the NP-complete quartet consistency problem [42] and the NP-complete forbidden triples problem [20]. To classify the complexity of CSPs of reducts of an «-categorical structure, a good understanding of the endo-morphism monoids of these reducts is important; for example, such a strategy has been used successfully in [12,16,19]. In this paper, we show that the endomorphism monoids of (L;C) fall into four categories. In [10] the authors give a full complexity classification for CSPs for reducts of (L;C) and make essential use of this result.

§2. Results. We show that there are only three reducts of (L; C) up to existential interdefinability (Corollary 2.3). In particular, there are only three reducts of (L; C) up to first-order interdefinability. The result concerning reducts up to firstorder interdefinability can also be shown with a proof based on known results on

1A first-order formula is existential if it is of the form 3*1,... ,xm . y where y is quantifier-free, and existential-positive if it is existential and does not contain the negation symbol —.

Jordan permutation groups (Section 4). However, we do not know how to obtain our stronger statement concerning reducts up to existential interdefinability using Jordan group techniques.

Our proof of Corollary 2.3 uses Ramsey theory for studying endomorphism monoids of reducts of (L; C). More specifically, we use a Ramsey-type result for C-relations which is a special case of Miliken's theorem [37]. We use it to show that endomorphisms of reducts of (L; C) must behave canonically (in the sense of Bodirsky and Pinsker [14]) on large parts of the domain and this enables us to perform a combinatorial analysis of the endomorphism monoids. This approach provides additional insights which we describe next.

Assume that Г is a homogeneous structure with a finite relational signature whose age2 has the Ramsey property (all examples mentioned above are reducts of such a structure). Then, there is a general approach to analyzing reducts up to first-order interdefinability via the transformation monoids that contain Aut(r) instead of the closed permutation groups that contain Aut(r). This Ramsey-theoretic approach has been described in [14]. We write wm for the transformation monoid of all unary functions on a countably infinite set. The monoid wm is naturally equipped with the topology of pointwise convergence and the closed submonoids of wm that contain Aut(r) are in one-to-one correspondence with the reducts of Г considered up to existential positive interdefinability. We note that giving a complete description of the reducts up to existential positive interdefinability is usually difficult. For instance, already the structure (N; =) admits infinitely many such reducts [8]. However, it is often feasible to describe all reducts up to existential interdefinability; here, the Random Graph provides a good illustration [15]. In this paper, we show that it is feasible to describe all reducts of (L; C) up to existential positive interdefinability. In particular, we show that the reducts of (L; C) fall into four categories. An important category is when a reduct Г of (L; C) has the same endomorphisms as the reduct (L; Q). This reduct is a natural D-relation which is associated to (L; C) (see Section 3.4), and its known complexity allows us to derive the complexity of the CSP for a large class of the reducts of (L; C). Those four categories are stated in the following main result of our paper.

Theorem 2.1. Let Г be a reduct of (L; C). Then one of the following holds.

1. Г has the same endomorphisms as (L; C),

2. Г has a constant endomorphism,

3. Г is homomorphically equivalent to a reduct of (L; =), or

4. Г has the same endomorphisms as (L; Q).

We use this result to identify in Corollary 2.3 below the reducts of (L; C) up to existential interdefinability. The proof of Corollary 2.3 is based on a connection between existential and existential positive definability on the one hand, and the endomorphisms of A on the other hand.

Proposition 2.2 (Proposition 3.4.7 in [6]). For every ю-categorical structure Г, it holds that

2The age of a relational structure Г is the set of finite structures that are isomorphic to some substructure of Г.

• a relation R has an existential positive definition in r if and only if R is preserved by the endomorphisms of r and

• a relation R has an existential definition in r if and only if R is preserved by the embeddings of r into r.

Corollary 2.3. Let r be a reduct of (L; C). Then r is existentially interdefinable with (L; C), with (L; Q), or with (L;=).

Our result has important consequences for the study of CSPs for reducts of (L; C). To see this, note that when two structures r and A are homomorphically equivalent, then they have the same CSP. Since the complexity of CSP(r) has been classified for all reducts r of (L; =) (see Bodirsky and Kara [11]) and since CSP(r) is trivial if r has a constant endomorphism, our result shows that we can focus on the case when r has the same endomorphisms as (L; C) or (L; Q). This kind of simplifying assumptions have proven to be extremely important in complexity classications of CSPs: examples include Bodirsky and Kara [12] and Bodirsky and Pinsker [16].

This article is organized as follows. The structure (L; C) is formally defined in Section 3. We then show (in Section 4) how to classify the reducts of (L; C) up to first-order interdefinability by using known results about Jordan permutation groups. For the stronger classification up to existential definability, we investigate transformation monoids. The Ramsey-theoretic approach works well for studying transformation monoids and will be described in Section 5. The main result is proved in Section 6.

§3. Preliminaries. We will now present some important definitions and results. We begin, in Section 3.1, by providing a few preliminaries from model theory. Next, we define the universal homogeneous binary branching C-relation (L; C). There are several equivalent ways to do this and we consider two of them in Sections 3.2 and 3.3, respectively. The first approach is via Frai'sse-amalgamation and the second approach is an axiomatic approach based on Adeleke and Neumann [3]. In Section 3.4, we also give an axiomatic treatment of an interesting reduct of (L; C). In Section 3.5, we continue by introducing an ordered variant of the binary branching C-relation [23] which will be important in the later sections.

3.1. Model theory. We follow standard terminology as, for instance, used by Hodges [31]. Let t be a relational signature (all signatures in this paper will be relational) and r a T-structure. When R e t, we write Rr for the relation denoted by R in r; we simply write R instead of Rr when the reference to r is clear. Let r1 and r2 be two T-structures with domains D1 and D2, respectively, and let f: D1 ^ D2 be a function. If t = (t1,...,tk) e (D1)k, then we write f (t) for (f (t1),...,f (tk)), i.e., we extend single-argument functions pointwise to sequences of arguments. We say that f preserves R iff f (t) e Rr2 whenever t e Rr1. If X C D1 and R e t is a k-ary relation, then we say that f preserves R on X if f (t) e Rr2 whenever t e Rr n Xk .If f does not preserve R (on X), then we say that f violates R (on X).

A function f: D1 ^ D2 is an embedding of r1 into r2 if f is injective and has the property that for all R e t (where R has arity k) and all t e (D1)k, we have f (t) e Rr2 if and only if t e Rri.

A substructure of a structure r is a structure A with domain S = DA C Dr and Ra = Rr n Sn for each «-ary R e t; we also write r[S] for A. The intersection

A of two r-structures r, r' is the structure with domain Dr n Dr and relations Ra = Rr n Rr for all R e r; we also write r n r' for A.

Let r1, r2 be r-structures such that A = r1 n r2 is a substructure of both r1 and r2. A r-structure A' is an amalgam of r1 and r2 over A if for i e {1,2} there are embeddings fi of ri to A' such that f 1(a) = f2(a) for all a e DA. We assume that classes of structures are closed under isomorphism. A class A of r-structures has the amalgamation property if for all A, r1, r2 e A with A = r1 n r2, there is a A' e A that is an amalgam of r1 and r2 over A. A class of finite r-structures that has the amalgamation property, is closed under isomorphism and closed under taking substructures is called an amalgamation class.

A relational structure r is called homogeneous if all isomorphisms between finite substructures can be extended to automorphisms of r. A class K of r-structures has the joint embedding property if for any r, r' e K, there is A eK such that r and r' embed into A. An amalgamation class has the joint embedding property since it always contains an empty structure. The following basic result is known as Frai'sse's theorem.

Theorem 3.1 (see Theorem 6.1.2 in Hodges [31]). Let A be an amalgamation class with countably many nonisomorphic members. Then there is a countable homogeneous r-structure r such that A is the class of structures that embeds into r. The structure r, which is unique up to isomorphism, is called the Fraisse-limit of A.

3.2. The structure (L; C): Fraiisse-amalgamation. We will now define the structure (L; C) as the Fraisse-limit of an appropriate amalgamation class. We begin by giving some standard terminology concerning rooted trees. Throughout this article, a tree is a simple, undirected, acyclic, and connected graph. A rooted tree is a tree T together with a distinguished vertex r which is called the root of T. The vertices of T are denoted by V(T). The leaves L(T) of a rooted tree T are the vertices of degree one that are distinct from the root r. In this paper, a rooted tree is often drawn downward from the root.

For u,v e V(T), we say that u lies below v if the path from u to r passes through v. We say that u lies strictly below v if u lies below v and u = v. All trees in this article will be rooted and binary, i.e., all vertices except for the root have either degree 3 or 1, and the root has either degree 2 or 0. A subtree of T is a tree T' with V(T') C V(T) and L(T') C L(T). If the root of T' is different from the root of T, the subtree is called proper subtree. The youngest common ancestor (yca) of a nonempty finite set of vertices S C V(T) is the (unique) node w that lies above all vertices in S and has maximal distance from r.

Definition 3.2. The leaf structure of a binary rooted tree T is the relational structure (L(T); C) where C (a, bc) holds in C if and only if yca({b, c}) lies strictly below yca({a, b,c}) in T. We call T the underlying tree of the leaf structure.

We mention that the definition of C-relation on binary rooted trees can also be obtained from the relation \ on trees with a distinguished leaf [23]. The slightly nonstandard way of writing the arguments of the relation C has certain advantages that will be apparent in forthcoming sections.

Definition 3.3. For finite nonempty S1,S2 C L(T), we write S1\S2 if neither of yca(S1) and yca(S2) lies below the other. For sequences of (not necessarily

distinct) vertices x1,...,xn and y1,...,ym we write x1,...,xn\y1,...,ym if {x1,.. .,xn } \{y1, . . .,ym }.

In particular, xy\z (which is the notation that is typically used in the literature on phylogeny problems) is equivalent to C (z, xy); it will be very convenient to have both notations available. Note that if xy|z then this includes the possibility that x = y; however, xy\z implies that x = z and y = z. Hence, for every triple x, y, z of leaves in a rooted binary tree, we either have xy\z, yz\x, xz\y, or x = y = z. Also note that x1,...,xn \y1 ,...,ym if and only if xixj\yk and xi \ykyi for all i, j < n and k,l < m. The following result is known but we have been unable to find an explicit proof in the literature. Hence, we give a proof for the convenience of the reader.

Proposition 3.4. The class C of allfinite leaf structures is an amalgamation class.

Proof. Arbitrarily choose B1,B2 eC such that A = B1 n B2 is a substructure of both B1 and B2. We inductively assume that the statement has been shown for all triples (A, B1, B2) where D(B1) U D(B2) is a proper subset of D(B1) U D(B2).

Let T1 be the rooted binary tree underlying B1 and T2 the rooted binary tree underlying B2. Let B1 eC be the substructure of B1 induced by the vertices below the left child of T1 and B2 e C be the substructure of B1 induced by the vertices below the right child of T1. The structures B2 and B| are defined analogously for B2.

First consider the case when there is a vertex u that lies in both B1 and B2 and a vertex v that lies in both Bj and B2. We claim that in this case no vertex w from B22 can lie inside B1. Assume the contrary and note that w is either in B1, in which case we have uw\v in B1, or in B2, in which case we have u\vw in B1. But since u,v,w are in A, this contradicts the fact that uv\w holds in B2. Let C' eC be the amalgam of B1 and B2 over A (which exists by the inductive assumption) and let T' be its underlying tree. Consider a tree T with root r, T' as its left subtree, and the underlying tree of B22 as its right subtree. It is straightforward to verify that the leaf structure of T is in C and that it is an amalgam of B1 and B2 over A.

The above argument can also be applied to the cases where the role of B1 and B2, or the role of B1 with B2, or the role of B2 with B| are exchanged. Hence, the only remaining essentially different case we have to consider is when D (B1) U D (B\) and D (B2) U D(B|) are disjoint. In this case, it is straightforward to first amalgamate B1 with B2 and B2 with Bf to obtain the amalgam of B1 and B2; the details are left to the reader. H

We write (L; C) for the Fraisse-limit of C. Obvious reducts of (L; C) are (L; C) itself and (L; =). To define a third reduct, consider the 4-ary relation Q(xy, uv) with the following first-order definition over (L; C):

(xy\u A xy\v) V (x\uv A y\uv). This relation is often referred to as the quartet relation [42].

3.3. The structure (L; C): an axiomatic approach. The structure (L; C) that we defined in Section 3.2 is an important example of a so-called C-relation. This concept was introduced by Adeleke and Neumann [3] and we closely follow their definitions

in the following. A ternary relation C С X3 is said to be a C-relation on X if the following conditions hold:

C1. Va,b,c (C(a,bc) ^ C(a,cb)),

C2. Уа,Ь,с (C(a, bc) ^-C(b,ac)),

C3. У a, b, c, d (C (a,bc) ^ C (a,dc) V C (d,bc)),

C4. ya,b (a = b ^ C(a,b,b)).

A C-relation is called proper if it satisfies two further properties:

C5. ya,b 3c (C(c,ab)),

C6. ya,b (a = b ^ 3c(c = b Л C(a,bc))).

These six axioms do not describe the Fraisse-limit (L; C) up to isomorphism. To completely axiomatize the theory of (L; C), we need two more axioms.

C7. ya,b,c (C(c,ab) ^ 3e (C(c,eb) Л C(e,ab))),

C8. ya,b,c ((a = b V a = c V b = c) ^ (C(a,bc) V C(b,ac) V C(c,ab))).

C-relations that satisfy C7 are called dense and C-relations that satisfy C8 are called binary branching. Note that C1-C8 are satisfiable since (L; C) is a countable model of C1-C8.

We mention that the structure (L; C) is existential positive complete within the class of all C-relations, as defined in [9]: for every homomorphism h of (L; C) into another C-relation and every existential positive formula ф(х1,...,хп) and all p1,...,pn G L such that ф(h (p1),... ,h(pn)) holds we have that ф(р1,..., pn) holds in (L; C), too. It is also easy to see that every existential positive complete C-relation must satisfy C7 and C8. These facts about existential positive completeness of (L; C) are not needed in the remainder of the article, but together with Lemma 3.8 below they demonstrate that the structure (L; C) can be seen as the (up to isomorphism unique) generic countable C-relation.

The satisfiability of C1-C8 can also be shown using the idea of constructing C-relations in [5, p. 123]. Let F be the set of functions f: (0, то) ^ {0,1}, where (0, то) denotes the set of positive rational numbers with the standard topology, such that the following conditions hold.

• There exists a G (0, то) such that f (x) = 0 for every x G (0,a).

• f has finitely many points of discontinuity and for each point b of discontinuity, there exists e G (0,b) such that f (x) = f (b) for every x G (b — t,b).

For every f,g G F such that f = g, let pref(f, g) denote the interval (0,c) such that f (x) = g(x) for every x G (0,c), and f (c) = g(c). If f = g, let pref(f, g) := (0, то). Note that c is a point of discontinuity of either f or g. We define a relation C on F by C (f,gh )if pref (f, h) С pref (g, h). We can easily verify that (F; C) is a countable model of C1-C8.

We will now prove (in Lemma 3.8) that there is a unique countable model of C1-C8 up to isomorphism. It suffices to show that if Г is a countable structure with signature {C} satisfying C1-C8, then Г is isomorphic to (L; C). To do so, we need a number of observations (Lemmas 3.5, 3.6, and 3.7).

The following consequences of C1-C8 are used in the proofs without further notice.

Lemma 3.5 (C-consequences). Let C denote a C-relation. Then

1. yx,y,z, t ((C(x,yz) Л C(x,yt)) ^ C(x,zt)),

2. Wx,y,z, t ((C(x,zt) Л C(z,xy)) ^ (C(t,xy) Л C(y,zt))), and

3. yx, y, z, t ((C(z, xy) Л C(y, xt)) ^ (C(z, yt) Л C(z, xt))).

Proof. We prove the first consequence. The others can be shown analogously. Assume to the contrary that C (x,zt) does not hold. By applying C3 to x,y,z, t, we get that C(t,yz) and C2 implies that C(z, yt) does not hold. By applying C3 to x, y,t,z, it follows that C (x, zt) holds and we have a contradiction. Л

For two subsets Y,Z of X, we write C (Y,Z) if

1. C (y, z1z2) for arbitrary y G Y and z1 ,z2 G Z, and

2. C (z, y 1 y2) for arbitrary y1 ,y2 G Y and z G Z.

Lemma 3.6. Let C be a ternary relation on a countably infinite set X that satisfies C1-C8. Then for every finite subset Y of X of size at least 2 there are two nonempty subsets A,B of Y such that A U B = Y and C(A, B).

Proof. We prove the lemma by induction on \ Y |. Clearly, the claim holds if \Y\ = 2 so we assume that the lemma holds when \ Y\ = k — 1 for some k > 2. Henceforth, assume \ Y\ = k. Arbitrarily choose y G Y and let Y' = Y\{y}. By the induction hypothesis, there are two nonempty subsets A', B' of Y' such that A' U B' = Y' and C (A',B' ).Pick a' G A' and b' G B'. One of the following holds.

• C(y,a'b'). Arbitrarily choose c,d G Y'. We show that C(y,cd) holds. If c,d G A', then we have C(y,a'b'), C(b',a'c), and C(b',a'd). It follows immediately from Lemma 3.5 that C(y,cd). Analogously, C(y,cd) holds if c,d G B'. It remains to consider the case c G A',d G B'. Here, we have C(y, a'b'), C(b', a'c), and C(a', b'd). Once again, it follows from Lemma 3.5 that C(y, cd) holds. By setting A = {y} and B = A' U B', the lemma of the lemma follows.

• C(b',ya'). We first show that for arbitrary a'' G A' and b'' G B', we have C(b'',a''y). This follows from Lemma 3.5 and the fact that C(b',ya'),C(b',a'a''), and C(a',b'b'') hold. We can now show that for arbitrary b'',b''' G B', we have that C(y,b''b''') holds. This follows from Lemma 3.5 and the fact that C(b',a'y), C(a',b'b''), and C(a',b'b''') hold. This implies that C(A' U {y}, B') and we have proved the induction step by setting A = A' U {y} and B = B'.

• C(a', yb'). This case can be proved analogously to the previous case: we get that A = A' and B = B' U {y}.

The case distinction is exhaustive because of C8. Л

We would like to point out an important property of maps that preserve C.

Lemma 3.7. Let e: X ^ L for X С L be a function that preserves C. Then e is injective and preserves the relation {t G L3: t / C}.

Proof. Clearly, e preserves the binary relation {(x,y) G L2 : x = y} = {(x, y) : 3z.C(x,y,z)}, and so e is injective. Arbitrarily choose u1,u2,u3 G L such that u1 \u2u3 does not hold. If \{u1,u2,u3}\ = 1 then e(u1)\e(u2)e(u3) does not hold and there is nothing to show. If \{u1,u2,u3}\ =2 then by C4 either u1 = u2 or u1 = u3, and e(u1)\e(u2)e(u3) does not hold. If \{u1,u2, u3}\ = 3 then by C6 we have either

u2\u1u3, or u3\u1u2. It follows that e(u2)\e(u1)e(u3) or e(u3)\e(u1 )e(u2). In both cases, e(u1)\e(u2)e(u3) does not hold by C2. H

We will typically use the contrapositive version of Lemma 3.7 in the sequel. This allows to draw the conclusion a\bc under the assumption e(a)\e(b)e(c).

Lemma 3.8. Let r be a countable structure with signature {C } that satisfies C1-C8. Then r is isomorphic to (L; C).

Proof. It is straightforward (albeit a bit tedious) to show that (L; C) satisfies C1-C8. It then remains to show that if r1 and r2 are two countably infinite {C}-structures that satisfy C1-C8, then the two structures are isomorphic. Let X1,X2 denote the domains of r1 and r2, respectively. This can be shown by a back-and-forth argument based on the following claim.

Claim: Let A be a nonempty finite subset of X1 and let f denote a map from A to X2 that preserves C. Then for every a e X1, the map f can be extended to a map g from A U{a } to X2 that preserves C.

It follows from Lemma 3.7 that f also preserves {(x,y,z) : — C(x,yz)}.Weprove the claim by induction on \A\. Clearly, we are done if a e A or \A\ = 1. Hence, assume that a g A and \A\ >2. Let A1 ,A2 be subsets of A such that A1 U A2 = A and C(A1,A2), which exist due to Lemma 3.6. Note that C(f (A1),f(A2)) holds in (X2; C). Pick a1 e A1 and a2 e A2. We construct the map g in each of the following three cases.

• C(a, a1a2). We claim that C({a}, A) holds. Arbitrarily choose u,v e A. Then either C(ua1,a2) or C(a1,a2u) by the choice of a1 and a2. Similarly, either C(va1,a2) or C(a1,a2v). So there are four cases to consider; we only treat the case C(ua1,a2) and C(a1,va2) since the other cases are similar or easier. Now, C (ua1,a2) and C (a1a2, a) imply that C (a, ua1) by item 3 of Lemma 3.5. Similarly, we have C(a, va2). Now C(a1a2, a) and two applications of item 1 of Lemma 3.5 give C (uv, a), which proves the subclaim.

It follows from C5 that there exists an a' e X2 such that C(a', f(a1)f (a2)). Once again, we obtain C({a'},f(A)) as a consequence of Lemma 3.5. This implies that the map g: A U {a} ^ X2, defined by g\A = f and g(a) = a', preserves C .

• C (a2, aa1). It follows from Lemma 3.5 that C ({a}UA1,A2) holds. We consider the following cases.

\A1\ = 1. There exists a' e X2 such that C(f (a2),a'f (a1)) by C6, and Lemma 3.5 implies that C({f (a1),a'},f (A2)) holds. Since we also have C({a, a1},A2), the map g: A U{a}^X2 defined by g\A = f and g(a) = a', preserves C .

\A2 \ = 1. This case can be treated analogously to the previous case. \A1\ > 2 and \A2\ > 2. Let B1 ,B2 be nonempty such that C(B1 ,B2) and A1 = B1 U B2. Arbitrarily choose b1 e B1,b2 e B2. The following cases are exhaustive by C8.

- C(a, b1b2). It is a direct consequence of C7 that there exists an a' e X2 such that both C({f (a2)}, {f(b1),f(b2),a'}) and C(a',f(b1)f(b2)) hold. Furthermore, Lemma 3.5 implies that C({a},A1),C({a} U A1,A2),

C({a'},f (A1)),and C({a'}Uf (A1),f(A2)). Hence, themap g: AU{a} ^ X2, defined by g\A = f and g(a) = a', preserves C.

- C(b2, ab1). By assumption we know that \A2\ > 2, and since A1 U A2 = A it follows that \A1 U {a}\ < \A\. Hence, by the induction hypothesis there exists a map h: A1 U {a} ^ X2 such that h\A1 = f \A1 and h preserves C on A1 U {a}. Since h preserves C on A1 U {a}, we see that C(h(b2),h(a)h(b1)), and consequently that C (f (b2),h(a)f(b1)) holds. Since both C (A1 ,A2)and C(f (A1),f (A2)) hold, it follows from Lemma 3.5 that C({a}U A1,A2) and C ({h (a )}Uf (A1),f(A2))hold. This implies that themap g: A U{a } ^ X2, defined by g\Alu{a} = h,g A = f \a2, preserves C.

- C (b1,ab2). The proof is analogous to the case above.

• C (a1,aa2). The proof is analogous to the case when C (a2, aa1).

The case distinction is exhaustive because of C8. H

3.4. The reduct (L; Q). The reduct (L; Q) of (L; C) can be treated axiomatically, too. A 4-ary relation D is said to be a D-relation on X if the following conditions hold:

D1. Va,b,c,d (D(ab,cd) ^ D(ba,cd) A D(ab,dc) A D(cd,ab)), D2. Va,b,c,d (D(ab,cd) ^ -D(ac,bd)), D3. Va,b,c,d,e (D(ab,cd) ^ D(eb,cd) V D(ab,ce)), D4. Va,b,c ((a = c A b = c) ^ D(ab,cc)). A D-relation is called proper if it additionally satisfies the following condition: D5. For pairwise distinct a, b, c there is d e X \{a, b, c} with D (ab, cd). As with (L; C), it is possible to axiomatize the theory of (L; Q) by adding finitely many axioms.

D6. Va,b,c,d(D(ab,cd) ^ 3e(D(eb,cd)AD(ae,cd)AD(ab,ed)AD(ab,ce))), D7. Va,b,c,d (\{a,b,c,d}\ > 3 ^ (D(ab,cd) V D(ac,bd) V D(ad,bc))). D-relations satisfying D6 are called dense, and D-relations satisfying D7 are called binary branching.

We will continue by proving that if two countable structures with signature {D} satisfy D1-D7, then they are isomorphic. For increased readability, we write

D (xyz, uv) when D(xy,uv) A D(xz,uv) A D (yz,uv), and we write D (xy, zuv) when D(xy, zu) A D (xy, zv) A D (xy, uv). One may note, for instance, that D(xy, zuv) is equivalent to D(xy, uvz).

Lemma 3.9 (D-consequences). If D is a D-relation, then

• Vx, y, z, u, v ((D(xy, zu) A D(xy, zv)) ^ D(xy, uv)), and

• Vx, y, z, u, v (D(xy, zu) ^ (D(xyv, zu) V D(xy, zuv))).

Proof. We prove the first item. ByapplyingD1 andD3to D (xy,zu) A D(xy,zv), we get that

(D(yv, uz) V D(xy, uv)) A (D(yu, vz) V D(xy, uv)).

If D (xy, uv) does not hold, then D (yv, uz) A D (yu, vz) must hold. However, this immediately leads to a contradiction via D2: D(yu, vz) ^ —D(yv, uz).

To prove the second item, assume that D(xy, zu) holds and arbitrarily choose v. By D3, we have D(vy, zu) V D(xy, zv). Assume that D(vy, zu) holds; the other case

can be proved in a similar way. By definition D(xyv, zu) if and only if D (xy, zu) A D(xv, zu) A D(yv, zu). We know that D(xy, zu) holds and that D(vy, zu) implies D(yv,zu) via D1. It remains to show that D(xv,zu) holds, too. By once again applying D1, we see that D(zu, yx) A D (zu, yv). It follows that D(zu, xv) holds by the claim above and we conclude that D(xv, zu) holds by D1. H

Lemma 3.10. Let e: X ^ L for X C L be a function that preserves Q. Then e is injective and preserves the relation {q e L4: q e Q}.

Proof. The proof is very similar to the proof of Lemma 3.7 and is left to the reader. H

We will typically use the contrapositive version of Lemma 3.10 in the sequel. This allows to draw the conclusion Q(ab,cd) under the assumption

Q(e (a )e (b ),e(c )e(d)).

Lemma 3.11. Let D be a 4-ary relation on a countably infinite set X that satisfies D1-D7. Then (X; D) is isomorphic to (L; Q), and homogeneous.

The proof of Lemma 3.11 is based on Lemma 3.8 and the idea of rerooting at a fixed leaf to create a C-relation from a D-relation. The idea of rerooting was already discussed in [23].

Proof. It is straightforward to verify that (L; Q) satisfies D1-D7. Let (X1; D) and (X2; D) be two countably infinite sets that satisfy D1-D7, let Y1 be a finite subset of X1, and a an embedding of the structure induced by Y1 in (X; D) into (X2,D). We will show that a can be extended to an isomorphism between (X1; D) and (X2,D). This can be applied to (X1; D) = (X2; D) = (L; Q) and hence also shows homogeneity of (L; Q).

Arbitrarily choose c e Y1. We define a relation C on X/ := X1 \{c} as follows: for every (x, y,z) e (X{)3, let (x, y,z) e C if and only if D (cx, yz) holds. Similarly, we define a relation C on X2' := X2 \ {a(c)} as follows: for every (x, y, z) e (X')3, let (x,y,z) e C if and only if D (a(c)x,yz) holds.

One can verify that both (X', C) and (X2', C) satisfies C1-C8. It follows from Lemma 3.8 that (X{; C) and (X2'; C) are isomorphic to (L; C), and it follows from homogeneity of (L; C) that the restriction of a to Y1 \{c} can be extended to an isomorphism a' between (X'; C) and (X2'; C).

We conclude the proof by showing that the map P: X1 ^ X2, defined by P (c) := a(c) and P\X/ = a', is an isomorphism between (X1; D) and (X2; D). Arbitrarily choose x, y,u,v e X1 satisfying D(xy, uv). By Lemma 3.10 it is sufficient to show that D (P(x)P(y), P(u)P(v)). Clearly, we are done if x, y, u, v are not pairwise distinct, or if c e {x, y, u,v}, so assume otherwise. By Lemma 3.9 we have D(xyc, uv) or D (xy, cuv). In the former case, it follows from the definition of C on X^ and X2' that D(a(x)a(c),a(u)a(v)) and D(a(y)a(c), a(u)a(v)). Lemma 3.9 implies that D(a(x)a(y),a(u)a(v)), which is equivalent to D(P(x)P(y), P(u)P(v)). The case that D(xy, cuv) can be shown analogously to the previous case. H

CoROLLARy 3.12. There exists an operation rer e Aut(L; Q) that violates C.

Proof. It follows from Lemma 3.11 that Aut(L; Q) is 3-transitive. Since Aut(L; C) is 2-transitive, but not 3-transitive, it follows that Aut(L; C) = Aut(L; Q). Since Aut(L; C) C Aut(L; Q), there is rer e Aut(L; Q) which violates C. H

The name rer may seem puzzling at first sight: it is short-hand for rerooting. The choice of terminology will be clarified Section 4.

3.5. Convex orderings of C-relations. In the proof of our main result, it will be useful to work with an expansion (L; C, — ) of (L; C) by a certain linear order

— on L. We will next describe how this linear order is defined as a Frai'sse-limit. A linear order — on the elements of a leaf structure (L; C) is called convex if for all x,y,z G L with x — y — z we have that either xy\z or that x\yz (but not xz\y). The concept of convex linear order was already discussed in [23] and in [30, p. 162].

Proposition 3.13. Let (L(T); C) be the leaf structure of a finite binary rooted tree T and arbitrarily choose a G L(T). Then there exists a convex linear order — of L(T) whose maximal element is a. In particular, every leaf structure can be expanded to a convexly ordered leaf structure.

Proof. Perform a depth-first search of T, starting at the root, such that vertices that lie above a in T are explored latest possible during the search. Let - be the order on L(T) in which the vertices have been visited during the search. Clearly,

— is convex and a is its largest element. Л

Proposition 3.14. The class C' of all finite convexly ordered leaf structures is an

amalgamation class and its Frai'sse-limit is isomorphic to an expansion (L; C, -—) of (L; C) by a convex linear ordering -—. The structure (L; C, —) is described uniquely up to isomorphism by the axioms C1-C8 and by the fact that — is a dense and unbounded linear order which is convex with respect to (L; C).

Proof. The proof that C' is an amalgamation class is similar to the proof of Proposition 3.4. The Frai'sse-limit of C' clearly satisfies C1-C8, it is equipped with a convex linear order, and all countable structures with these properties are in fact isomorphic; this can be shown by a back-and-forth argument. By Lemma 3.8, the structure obtained by forgetting the order is isomorphic to (L; C) and the statement follows. Л

By the classical result of Cantor [25], all countable dense unbounded linear orders are isomorphic to (Q; <), and hence Proposition 3.14 implies that (L; —) is isomorphic to (Q; <).

§4. Automorphism groups of reducts. We will now show that the structure (L; C) has precisely three reducts up to first-order interdefinability. Our proof uses a result by Adeleke and Neumann [2] about primitive permutation groups with primitive Jordan sets. The link between reducts of (L; C) and permutation groups is given by the theorem of Engeler, Ryll-Nardzewski, and Svenonius, which we briefly recall in Section 4.1. We continue in Section 4.2 by presenting some important lemmata about functions that preserve Q but violate C. With these results in place, we finally prove the main result of this section in Section 4.3.

4.1. Permutation group preliminaries. Our proof will utilize links between homogeneity, ю-categoricity, and permutation groups so we begin by discussing these central concepts. A structure Г is ю-categorical if all countable structures that satisfy the same first-order sentences as Г are isomorphic (see, e.g., Cameron [24] or Hodges [31]). Homogeneous structures with finite relational signatures are ю-categorical, so the structure (L; C) is ю-categorical. Moreover, all structures

FiguRE 1. Illustration of the three orbits of triples (a,b,c) with pairwise distinct entries of Aut(L; C).

with a first-order definition in an «-categorical structure are «-categorical (see again Hodges [31]). This implies, for instance, that (L; Q) is «-categorical.

The fundamental theorem by Engeler, Ryll-Nardzewski, and Svenonius is a characterization of «-categoricity in terms of permutation groups. When G is a permutation group on a set X, then the orbit of a fc-tuple t is the set {a(t) \ a e G }. We see that homogeneity of (L; C) implies that Aut(L; C) has precisely three orbits of triples with pairwise distinct entries; an illustration of these orbits can be found in Figure 1. We now state the Engeler-Ryll-Nardzewski-Svenonius theorem and its proof can be found in, for instance, Hodges [31].

ThEOREM 4.1. A countable relational structure r is «-categorical if and only if the automorphism group of r is oligomorphic, that is, if for each k > 1 there are finitely many orbits of k-tuples under Aut(r). A relation R has a first-order definition in an «-categorical structure r if and only if R is preserved by all automorphisms of r.

This theorem implies that a structure (L; R1 ,R2,...) is first-order definable in (L; C) if and only if its automorphism group contains the automorphisms of (L; C).

Automorphism groups G of relational structures carry a natural topology, namely the topology of pointwise convergence. Whenever we refer to topological properties of groups it will be with respect to this topology. To define this topology, we begin by giving the domain X of the relational structure the discrete topology. We then view G as a subspace of the Baire space XX which carries the product topology; see, e.g., Cameron [24]. A set of permutations is called closed if it is closed in the subspace Sym(X) of XX, where Sym(X) is the set of all bijections from X to X. The closure of a set of permutations P is the smallest closed set of permutations that contains P and it will be denoted by P. Note that P equals the set of all permutations f such that for every finite subset A of the domain there is a g e P such that f (a) = g (a) for all a A.

We write (P) for the smallest permutation group that contains a given set of permutations P. Note that the smallest closed permutation group that contains a set of permutations P equals (P). It is easy to see that a set of permutations G on a set X is a closed subgroup of the group of all permutations of X if and only if G is the automorphism group of a relational structure [24].

We need some terminology from permutation group theory and we mostly follow Bhattacharjee, Macpherson, Moller, and Neumann [5]. A permutation group G on a set X is called

• k-transitive if for any two sequences a1,...,a/c and b1,...,b/c of k distinct points of X there exists g in G such that g (a,) = b, for all 1 < i < k,

• transitive if G is 1-transitive,

abc bac cab

• highly transitive if it is k-transitive for all natural numbers k,

• primitive if it is transitive and all equivalence relations that are preserved by all operations in G are either the equivalence relation with one equivalence class or the equivalence relation with equivalence classes of size one.

The following simple fact illustrates the link between model theoretic and permutation group theoretic concepts.

Proposition 4.2. For an automorphism group G of a relational structure r with domain D, the following are equivalent.

• G is highly transitive.

• G equals the set of all permutations of D.

• r is a reduct of (D;=).

The pointwise stabilizer at Y c X of a permutation group G on X is the permutation group on X consisting of all permutations a e G such that a(y) = y for all y e Y .A subset X' of X is said to be a Jordan set (for G in X) if \X '\ > 1 and the pointwise stabilizer H of G at X \ X' is transitive on X'.

If the group G is (k + 1)-transitive and X' is any cofinite subset with \X \ X'\ = k, then X' is automatically a Jordan set. Such Jordan sets will be said to be improper while all other will be called proper. We say that the Jordan set X' is k-transitive if the pointwise stabilizer H is k-transitive on X'. The permutation group G on the set X is said to be a Jordan group if G is transitive on X and there exists a proper Jordan set for G in X. The main result that we will use in Section 4.3 is the following.

Theorem 4.3 (Note 7.1 in Adeleke and Neumann [2]). If G is primitive and has 2-transitive proper Jordan sets, then G is either highly transitive or it preserves a C- or D-relation on X.

Note that Aut(L; C) is 2-transitive by homogeneity and that 2-transitivity implies primitivity. The following proposition shows that Theorem 4.3 applies in our setting.

Proposition 4.4. For two arbitrary distinct elements a,b e L, the set S := {x e L : ax\b } is a 2-transitive proper primitive Jordan set of Aut(L; C).

Proof. The pointwise stabilizer of Aut(L; C) at L \ S acts 2-transitively on S; this can be shown via a simple back-and-forth argument. H

4.2. The rerooting lemma. We will now prove some fundamental lemmata concerning functions that preserve Q. They will be needed to prove Theorem 4.11 which is the main result of Section 4. They will also be used in subsequent sections: we emphasize that these results are not restricted to permutations. The most important lemma is the rerooting lemma (Lemma 4.9) about functions that preserve Q and violate C. The following notation will be convenient in the following.

Definition 4.5. We write x1 ...xn : y1 ...ym if Q(xixj,ykyl )forall i,j < n and

k, i < m.

Lemma 4.6. Let A1,A2 C L be such that A1 \A2 and let f: A1 U A2 — L be a function that preserves Q and satisfies f (A1)\f (A2). Then f also preserves C.

Proof. Since A1 \A2, we have A1 U A2 > 2. Clearly, the claim of lemma holds if \A1 U A2 \ = 2. It remains to consider the case \A1 U A2 \ >3. Let a1,a2,a3 e A1 U A2 be three distinct elements such that a1 a2\a3 .Wehaveto verify that f (a1)f (a2) \f (a3) and we do this by considering four different cases.

• a1,a2 e A1 and a3 e A2. In this case, since f (A1)\f (A2), we have in particular that f (af (a2)\f (as).

• a1,a2 e A2 and a3 e A1. Analogous to the previous case.

• a1, a2, a3 e A1. Let b e A2. Clearly a1a2 : a3b, and f (a1)f (a2) : f (a3)f (b) since f preserves Q. Moreover, we have f (a1)f (a2)f (a3)\f (b), and thus f (a1)f(a2)\f (a3).

• a1 ,a2,a3 e A2. Analogous to the previous case.

Since we have assumed that A1 \A2, these cases are in fact exhaustive. One may, for instance, note that if a1,a3 e A1 and a2 e A2, then a1a3\a2 which immediately contradicts that a1a2\a3. H

Lemma 4.7. Let A C L be finite of size at least two and let f: A ^ L be a function which preserves Q. Then there exists a nonempty B C A such that the following conditions hold:

• f (B)\f (A \ B),

• B\x for all x e A \ B.

Proof. Let B1,B2 be nonempty such that B1 U B2 = A and f (B1)\f (B2). We see that B1,B2 is a partitioning of A since f (B1)\f(B2) implies B1 n B2 = 0. If B1\x for all x e B2, then we can choose B = B1 and we are done. Otherwise there are u,v e B1 and w e B2 such that u\vw. We claim that in this case x\B2 for all x e B1. Since f preserves Q on A and f (u)f (v) : f (w )f(x) holds for every x e B2, we have uv : wx by Lemma 3.10. Therefore u\wx and v\wx hold. This implies that u\B2 holds. Let w', w'' be two arbitrary elements from B2 and u' an arbitrary element from B1. We thus have f (w')f(w'') : f (u')f (u) and, once again by Lemma 3.10, we have uu' : w'w''. This implies u\w'w'' and consequently u'\w'w''. Hence, u'\B2 for arbitrary u' e B2. H

We will now introduce the idea of c-universality. This seemingly simple concept is highly important throughout the article and it will be encountered in several different contexts.

DEFinrnon 4.8. Arbitrarily choose c e L. A set A C L \{c} is called c-universal if for every finite U C L and for every u e U, there exists an a e Aut(L; C) such that a(u) = c and a(U) C A U {c}.

We continue by presenting the rerooting lemma which identifies permutations g of L that preserve Q and can be used for generating all automorphisms of (L; Q) when combined with Aut(L; C). The idea is based on the following observation: the finite substructures of (L; C) provide information about the root of the underlying tree whereas the finite substructures of (L; Q) only provide information about the underlying unrooted trees. Intuitively, we use the function g to change the position of the root in order to generate all automorphisms of (L; Q).

Lemma 4.9 (Rerooting Lemma). Arbitrarily choose c e L and assume that A C L \ {c} is c-universal. If g is a permutation of L that preserves Q on A U {c} and satisfies g(A)\g(c), then

Aut(L; Q) C (Aut(L; C) U {£».

Proof. Arbitrarily choose f e Aut(L; Q) and let X be an arbitrary finite subset of L. We have to show that (Aut(L; C) U {g}) contains an operation e such that

e(x) = f (x) for all x e X. This is trivial when \X\ = 1 so we assume that \X\ > 2. By Lemma 4.7, there exists a nonempty proper subset Y of X such that f (Y )\f(X \ Y) and Y\x for all x e X \ Y. By the homogeneity of (L; C), we can choose an element c' e L \ X such that c '\Y and (Y U{c '})\x for all x e X \ Y .By c-universality, there exists an a e Aut(L; C) such that a(X U {c'}) C A U {c} and a(c') = c. Let h := g o a. Note that h preserves Q on X and that h is a permutation. We continue by proving a particular property of h.

CLAIM. h(Y)\h(X \ Y).

To prove this, we first show that h(y1)h(y2)\h(y3) for every y1,y2 e Y and y3 e X \ Y. We have y1y2 : y3c' by the choice of c' and this implies that h(y1)h(y2) : h(y3)h(c'). Since a(X) C A, it follows from the definition of h that h(y!),h(y2),h(y3) e g(A). Since g(c)\g(A) and a(yi) e A for every i e {1,2, 3}, we have g(c)\h(y1)h(y2)h(y3). Since h(c') = g(c) and h(y1)h(y2) : h(y3)h(c'), it follows that h (y1)h(y2)\h(y3). In the same vein, we show that h (y1)\h(y2)h (y3) for every y1 e Y and y2,y3 e X \ Y .In this case, we have y1c' : y2y3 by the choice of c' and this implies h(y1)h(c') : h(y2)h(y3). Since h(c') = g(c) and g(c)\h(y1 )h (y2)h(y3), we see that h(y1)\h(y2)h (y3).

Let P: h(X) — f (X) be defined by P(x) = f (h-1(x)). Note that h-1 is well-defined since h is an injective function. Since both h and f preserve Q, we have that P preserves Q by Lemma 3.10.

Note that P (h (Y ))\P (h(X \ Y)) since P (h (x)) = f (x) and we have assumed that f (Y )\f (X \ Y). Hence, the conditions of Lemma 4.6 apply to P for A1 := h (Y) and A2 := h (X \ Y) if we use the claim above. It follows that P preserves C. By the homogeneity of (L; C), there exists an y e Aut(L; C) that extends P. Then e := y o h has the desired property. H

Observe the following important consequence of Lemma 4.9.

Corollary 4.10. Assume f e Aut(L; Q) violates C. Then

(Aut(L; C) U {/}) = Aut(L; Q).

Proof. The relation Q is first-order definable over (L; C) so Aut(L; C) C Aut(L; Q). Furthermore, f preserves Q and it follows that

(Aut(L; C) U {f}) C Aut(L; Q).

For the converse, choose f e Aut(L; Q) such that there are a1,a2,a3 e L with a1\a2a3 and f (a1)f (a2)\f (a3). Let A = {x \ xa1 : a2a3}. We will show that f (A)\f (a3). Let x,y e A be arbitrary. Since f preserves Q, we have f (x)f (a1) : f (a2)f (a3) and f (y)f (a1) : f (a2)f (a3). It follows from the condition f (a1)f(a2)\f (a3) that

f (x)f(a{)\f (a2) A f (x)fM\f (a3) A f (y)f (a1)\f(a2) A f (y)f (a1)\f(a3).

Since f (x)f (a1)\f (a3) A f (y)f (a1)\f (a3), we have f (x)f (y)\f (a3). Thus f (A)\f (a3).

Clearly, A is a3-universal. Applying Lemma 4.9 to c = a3 we have

Aut(L; Q) C (Aut(L; C) U {f }). H

4.3. Automorphism group classification. We are now ready to prove the main result concerning automorphism groups of the reducts of (L; C).

ThEOREM 4.11. Let G be a closed permutation group on the set L that contains Aut(L; C). Then G is either Aut(L; C), Aut(L; Q), or Aut(L; =).

Proof. Because G satisfies the conditions of Theorem 4.3, it is either highly transitive or it preserves a C- or D-relation. If G is highly transitive, then G equals Aut(L; =) by Proposition 4.2. Assume instead that G preserves a C-relation C'. We begin by making an observation.

Claim 0. All tuples (o, p, q) e C' withpairwise distinct entries satisfy o\pq.

Suppose for contradiction that p\oq. Then, (o, p, q) is in the same orbit as (q, p, o) in Aut(L; C) and therefore also in G. Since C' is preserved by G, we have C '(q,p,o) which contradicts C2. Similarly, it is impossible that q\op. Thus, the only remaining possibility is o\pq since C satisfies C8.

Arbitrarily choose a,b,c e L such that a\bc and some a e G .If \{a, b,c }\ = 2, then (by 2-transitivity of Aut(L; C)) we have that (a(a),a(b),a(c)) is in the same orbit as (a,b,c) of Aut(L; C). Consequently, (a(a),a(b),a(c)) e C. Suppose instead that \{a, b,c} \ = 3. Observe that C' contains a triple with pairwise distinct entries. Arbitrarily choose two distinct elements u, v L. Axiom C6 implies that there exists a w e L such that C '(u, vw) and w = v .In fact, we also have w = u since otherwise C'(u,vu) which is impossible due to C2 and C4. In particular, it follows that u\vw and therefore (u, v,w) is in the same orbit as (a, b,c )inAut(L; C). It follows that (a, b, c) e C'. Since G preserves C' we have C'(a(a),a(b)a(c)). By Claim 0, a(a)\a(b)a(c). We conclude that a preserves C and that G = Aut(L; C).

Finally, we consider the case when G preserves a D-relation D. We begin by making three intermediate observations.

Claim 1. Every tuple (a, b,c,d) e D with pairwise distinct entries satisfies ab : cd.

Suppose for contradiction that ac : bd. Then either ac\b A ac\d or a\bd A c\bd by the definition of relation Q. In the first case, (a,b,c,d) is in the same orbit as (c, b, a, d) in Aut(L; C) so (c, b, a, d) e D. Axiom D1 implies that (a, d,b,c) e D and this contradicts D2. If a\bd A c\bd, then we can obtain a contradiction in a similar way. Finally, the case when ad : bc can be treated analogously. It follows that ab : cd since Q satisfies D7.

Claim 2. D contains a tuple (o, p,q,r) with pairwise distinct entries such that op\qr holds.

Let u,v,w e L be three distinct elements such that uv\w. There is an x e L \ {u, v, w} such that D(uv, wx) by D5. Claim 1 immediately implies that uv : wx. We consider the following cases.

• uv\wx. There is nothing to prove in this case.

• uvw\x. Choose y e L be such that y = w and uv\yw. It follows from D3 that D (uv, yw) or D (yv, wx). The second case is impossible since yv : wx does not hold. We see that (u, v,y,w) e D and we are done.

• uv\x and uvx\w. One may argue similarly as in the previous case by choosing y e L \ {u, v, w, x} such that uv\yx and observe that (u, v, x,w) e D by D1.

Claim 3. D contains a tuple (a,b,c,d) with pairwise distinct entries such that ab\c A abc\d.

It follows from Claim 2 that there exists a tuple (o, p, q, r) with pairwise distinct entries such that op\qr holds. Choose s e L such that opqr\s holds. Axiom D3 implies that D(sp, qr) or D (op, qs). We are done if the second case holds. If the first case holds, then we have D (qr, ps) by D1 and we are once again done.

Now, we show that every f e G preserves Q. Arbitrarily choose a1,a2, a3, a4 e L such that a1a2 : a3a4. We show that (a1,a2,a3,a4) e D (and, consequently, that (f (a1),f(a2),f(a3),f(a4)) e D) by an exhaustive case analysis. Claim 2 implies that D contains a tuple (o, p, q, r) with pairwise distinct entries and op\qr. Consequently, D contains all tuples in the same orbit as (o, p, q, r) in Aut(L; C).

If a1,a2,a3, a4 are pairwise distinct and satisfy a1a2\a3a4, then (a1,a2,a3,a4) e D by Claim 1. Similarly, if a1,a2,a3,a4 are pairwise distinct and satisfy a1a2\a3 and a1a2a3\a4, then Claim 3 implies that (a1 ,a2,a3,a4) e D. If a2\a3a4 and a1 \a2a3a4, then (a1 ,a2,a3,a4) e D by D1. If a1a2a4\a3 and a1a2\a4, orif a1 \a3a4 and a2\a1a3a4, then (a1, a2, a3, a4) e D by D1. If a3 = a4, a1 = a3, a2 = a3,then (a1, a2, a3, a4) e D by D4. The only remaining possibility to satisfy a1a2 : a3a4 is that a1 = a2, a3 = a1, a4 = a1. In this case, (a1 ,a2,a3,a4) e D by D4 and D1. Hence, in all cases we have (a1 ,a2,a3,a4) e D and, consequently, (f (a1)f (a2),f(a3)f (a4)) e D.

We can now conclude this part of the proof. If f (a1),f(a2),f(a3),f(a4) are pairwise distinct, then f (a1)f(a2) : f (a3)f(a4) by Claim 1. Otherwise, one of the following cases hold:

• f (aO = f (a2), f (a3) = f (aO, and f (a4) = f (aO,

• f (a3) = f (a4), f (aO = f (a3), and f (a1) = f (a4), or

• f (aO = f(a2)and f (^3) = f M.

In all three cases, we have that f (a1)f (a2) : f (a3)f (a4) and G C Aut(L; Q). If G = Aut(L; C), then we are done. Otherwise, pick one f e G \ Aut(L; C). Corollary 4.10 asserts that

(Aut(LTC7u{7T) = Aut(L; Q) C G,

and it follows that G = Aut(L; Q). H

The following is an immediate consequence of Theorem 4.11 in combination with Theorem 4.1.

Corollary 4.12. Let r be a reduct of (L; C). Then r is first-order interdefinable with (L; C), (L; Q), or (L;=).

Proof. Since r is a reduct of (L; C), Aut(r) is a closed group that contains Aut(L; C) and therefore equals Aut(L; C), Aut(L; Q), or Aut(L;=) by Theorem 4.11. Theorem 4.1 implies that r is first-order interdefinable with (L; C), with (L; Q), or with (L;=). H

Corollary 4.12 will be refined to a classification up to existential interdefinability in the forthcoming sections.

§5. Ramsey theory for the C-relation. To analyze endomorphism monoids of reducts of (L; C), we apply Ramsey theory; a survey on this technique can be found in Bodirsky and Pinsker [14]. The basics of the Ramsey approach are presented in

Section 5.1 and we introduce the important concepts of canonicity and the ordering property in Sections 5.2 and 5.3, respectively. We would like to mention that none of the results from the previous sections that use the theory of Jordan permutation groups is needed in the subsequent parts.

We will frequently use topological methods when studying transformation monoids. The definition of the topology of pointwise convergence for transformations monoids is analogous to the definition for groups: the closure F of F C Ll is the set of all functions f e LL with the property that for every finite subset A of L, there is a g & F such that f(a) = g(a) for all a £ A. A set of functions is closed if F = F. We write (F) for the smallest transformation monoid that contains F. The smallest closed transformation monoid that contains a set of functions F equals (F). The closed transformation monoids are precisely those that are endomorphism monoids of relational structures. We say that a function f is generated by a set of operations F is f is in the smallest closed monoid that contains F. A more detailed introduction to these concepts can be found in Bodirsky [6].

5.1. Ramsey classes. Let r, A be finite r-structures. We write (D for the set of all substructures of A that are isomorphic to r. When r, A, © are r-structures, then we write © — (A)|T if for all functions x: (©) —{1,...,r} there exists A' e (A) such that x is constant on ).

Definition 5.1. A class of finite relational structures C that is closed under isomorphisms and substructures is called Ramsey if for all r, A eC and arbitrary k > 1, there exists a © eC such that A embeds into © and © — (A)r.

A homogeneous structure r is called Ramsey if the class of all finite structures that embed into r is Ramsey. We refer the reader to Kechris, Pestov, and Todorcevic [33] or Nesetril [38] for more information about the links between Ramsey theory and homogeneous structures. An example of a Ramsey structure is (D;=)—the fact that the class of all finite structures that embed into (D; = ) is Ramsey can be seen as a reformulation of Ramsey's classical result [41].

The Ramsey result that is relevant in our context (Theorem 5.2) is a consequence of a more powerful theorem due to Miliken [37]. The theorem in the form presented below and a direct proof of it (found with Diana Piguet) can be found in Bodirsky [7]. We mention that a weaker version of this theorem (which was shown by the academic grand-father of the first author of this article [26]) has been known for a long time.

Theorem 5.2 (see Bodirsky [7] or Miliken [37]). The structure (L; C, —) is Ramsey.

We also need the following result.

Theorem 5.3 (see Bodirsky, Pinsker and Tsankov [18]). If r is homogeneous and Ramsey, then every expansion of r by finitely many constants is Ramsey, too.

5.2. Canonical functions. The typical usage of Ramsey theory in this article is for showing that the endomorphisms of r behave canonically on large parts of the domain; this will be formalized below. A wider introduction to canonical operations can be found in Bodirsky [6] and Bodirsky and Pinsker [14]. The definition of canonical functions given below is slightly different from the one given in [6] and [14]. It is easy to see that they are equivalent, though.

DEFinmon 5.4. Let r, A be structures and let S be a subset of the domain D of r. A function f: r ^ A is canonical on S as a function from r to A if for all s1,...,s„ e S and all a e Aut(r), there exists a pP e Aut(A) such that

f (a(si ))= p (f (si)) for all i e {1,...,n}.

In Definition 5.4, we might omit the set S if S = D is clear from the context. Note that a function f from r to A is canonical if and only if for every k > 1 and every t e Dk, the orbit of f (t) in Aut(A) only depends on the orbit of t in Aut(r).

Example 5.5. Write x >- y if y — x. The structure (L; C, >-) is isomorphic to (L; C, —); let — be such an isomorphism. Note that — is canonical as a function from (L; C, —) to (L; C, —).

When r is Ramsey, then the following theorem allows us to work with canonical endomorphisms of r. It can be shown with the same proof as presented in Bodirsky, Pinsker, and Tsankov [18].

ThEOREM 5.6. Let r, A denote finite relational structures such that r is homogeneous and Ramsey while A is w-categorical. Arbitrarily choose a function f: r ^ A. Then, there exists a function

g G {a\fa2 : a\ G Aut(A),a2 G Aut(r)} that is canonical as a function from r to A.

Note that expansions of homogeneous structures with constant symbols are again homogeneous. We obtain the following by combining the previous theorem and Theorem 5.3.

Corollary 5.7. Let r, A denote finite relational structures such that r is homogeneous and Ramsey while A is w-categorical. Arbitrarily choose a function f : r ^ A and elements c1,...,cn of r. Then, there exists a function

g e {a1fa2 : a1 e Aut(A), a2 e Aut(r, c1,..., cn)} that is canonical as a function from (r, c1,...,cn) to A.

5.3. The ordering property. Another important concept from Ramsey theory that we will exploit in the forthcoming proofs is the ordering property. We will next prove that the class of ordered leaf structure has this property.

Definition 5.8 (See Kechris, Pestov, and Todorcevic [33] or Nesetril [38]). Let C' be a class of finite structures over the signature t U {—}, where — denotes a linear order, and let C be the class of all T-reducts of structures from C'. Then C' has the ordering property if for every A1 e C there exists a A2 e C such that for all expansions Aj e C' of A1 and A2 e C' of A2 there exists an embedding of Aj into A2,.

Proposition 5.9. Let r be a homogeneous relational T-structure with domain D and suppose that r has an w-categorical homogeneous expansion r' with signature t U {—} where — denotes a linear order. Then, the following are equivalent.

• the class C' offinite structures that embed into r' has the ordering property and

• for every finite X C D there exists a finite Y C D such that for every P e Aut(r) there exists an a e Aut(r') such that a(X) C P(Y).

Proof. First suppose that C' has the ordering property and let X C D be finite. Let A1 be the structure induced by X in r. Then, there exists A2 e C such that

for all expansions A1 e C' of A1 and for all expansions A2 e C' of A2, there exists an embedding of A1 into A2. Since every structure in C' can be embedded into r', we may assume that A2 is a substructure of r' with domain Y. Arbitrarily choose P e Aut(r). Then, there exists an embedding from the structure induced by X in r' to the structure induced by P (Y) in r'. By homogeneity of r', this embedding can be extended to an automorphism a of r' which has the desired property.

For the converse direction, let A1 be the r-reduct of an arbitrary structure from C' and let n denote the cardinality of A1. Since r' is «-categorical, there is a finite number m of orbits of n-tuples. Hence, there exists a set Z of cardinality n • m such that for every embedding e of A1 into r, there exists an automorphism a of r' such that the image of a o e is a subset of Z. By assumption, there exists a set Y C D such that for every P e Aut(r), there exists an a e Aut(r') and a(Z) C P(Y). Let A2 be the structure induced by Y in r. Now, let A1 = (A1, —) and arbitrarily choose A2 = (A2, —) e C'. By the choice of Z, there is an embedding f of A1 into the substructure induced by Z in r'. Since r' embeds all structures from C', we can assume that A2 is a substructure of r'. By homogeneity of r, there is a P e Aut(r) that maps A2 to A2. By the choice of Y, there exists an a e Aut(r') such that a(Z) C P(Y). Now, a o f is an embedding of A1 into A2 which concludes the proof. H

Theorem 5.10. The class of all ordered leaf structures has the ordering property.

Proof. By Proposition 5.9, it is sufficient to show that for every finite X C L, there exists a finite Y C L such that for every P e Aut(L; C) there exists an a e Aut(L; C, —) satisfying a(X) C P(Y). Let X be an arbitrary finite subset of L, let Z = X U-X (where — is defined as in Example 5.5), and let A be the structure induced by Z in (L; C, —). Let r be the structure induced by a two-element subset of L in (L; C, —). The exact choice is not important since all such structures are isomorphic. Since (L; C, —) is Ramsey by Theorem 5.2, there exists a leaf structure © such that © — (A)r. Let Y be the domain of ©.

Now, choose some P e Aut(L; C) arbitrarily. Define the following 2-coloring of (©): suppose that x,y e Y satisfy x — y. Color the copy of r induced by {x, y} red iff P (x) — P (y) and blue otherwise. Then, there exists a copy A' of A in © such that all copies of r in A' have the same color. If the color is red, clearly there is an automorphism a e Aut(L; C, —) such that a(X) C P(A') C Y. If the color is blue, then there is also an automorphism a e Aut(L; C, —) such that a(X) C P(A') C Y since Z also contains —X. H

§6. Endomorphism monoids of reducts. In this section we prove the remaining results that were stated in Section 2. We start with a description of the basic idea how to use the Ramsey theoretic tools introduced in the previous section. In our proof, we can exclusively focus on analyzing injective endomorphisms, because of a fundamental lemma which we describe next. Since (L; C) has a 2-transitive automorphism group, all reducts r of (L; C) also have a 2-transitive automorphism group. We can thus apply the following result.

Lemma 6.1 (see, e.g., Bodirsky [6]). Let r be a relational structure with a 2-transitive automorphism group. If r has a noninjective endomorphism, then it also has a constant endomorphism.

Let r be a reduct of (L; C). Suppose that r has an endomorphism e that does not preserve C, i.e., there is (o,p,q) e C such that (e (o),e(p),e(q)) e C .If e is not injective, then r also has a constant endomorphism by Lemma 6.1. In this case, the third item in Theorem 2.1 applies and we are done. So suppose in the following that e is injective. By Theorem 5.2, the structure (L; C, —) is Ramsey. Hence, Corollary 5.7 implies that {e} U Aut(L; C) generates an injective function f that equals e on o, p, q and therefore still violates C, but is canonical as a function from (L; C, —, o, p, q) to (L; C, —).

As we have noted above, a canonical function f from r to A induces a function from the orbits of k-tuples in Aut(r) to the orbits of k-tuples in Aut(A); we will refer to those functions as the behavior of f. There are finitely many behaviors of canonical injections from (L; C, —,o,p,q) to (L; C, —): since the pre-image is homogeneous in a ternary language with three constants, their number is bounded by the number of functions from O6 ^ O3, where Ok denotes the set of orbits of k-tuples of distinct elements in (L; C, —). The function s: k ^ \Ok \ is well-known in combinatorics (see Sloane's Integer Sequence A001813 and see [23] for various enumerative results for leaf structures on trees), and we have s(n) = (2n)!/n!. In particular, s(3) = 12 and s(6) = 30240. So the number of canonical behaviors of functions from (L; C, —,o,p,q) to (L; C, —) is bounded by 1230240. For every function with one of those behaviors, we prove that r must be as described in items 3 and 4 of Theorem 2.1. Since 1230240 is a somewhat large number of cases, the way we treat these cases in the following is important. We then repeat the same strategy for the structure (L; Q) but here we have to expand with four constants, that is, we analyze canonical functions from (L; C, —,c1 ,...,c4) ^ (L; C, —).

In the following, several arguments hold for the expansion of (L; C, —) by any finite number of constants c = (c1 ,...,cn). The following equivalence relation plays an important role.

Definition 6.2. Let c = (c1,...,cn) e Ln. Then Ec denotes the equivalence relation defined onL\{c1,...,cn} by

The equivalence classes of Ec are called cones (of (L; C, c)). We write Sca for the cone that contains a e L \{c1,..., cn}.

Note that each cone induces in (L; C, —) a structure that is isomorphic to

(L; C, —).

In Sections 6.1-6.3 we study the behavior of canonical functions with zero, one, and two constants, respectively. Finally, in Section 6.4, we put the pieces together and prove Theorem 2.1 and Corollary 2.3.

6.1. Canonical behavior without constants. In this section we analyze the behavior of canonical functions from (L; C, — )to (L; C, —). In particular, we discuss possible behaviors on cones (Corollary 6.7) and close with a useful lemma (Lemma 6.12) that shows that when a reduct r of (L; C) is preserved by functions with certain behaviors, then r is homomorphically equivalent to a reduct of (L;=).

Definition 6.3. Let A C L and e: L — L a function. Then we say that e has on A the behavior

id if for all x,y,z e A with xy\z we have that e(x )e(y)\e(z).

lin if for all x,y,z e A with x — y — z we have that e(x)\e(y)e(z).

nil if for all x,y,z e A with x — y — z we have that e(x)e(y)\e(z).

In this case, we will also say that e behaves as id, lin, or nil on A, respectively. When f behaves as lin on A = L, then we do not mention A and simply say that f behaves as lin; we make the analogous convention for all other behaviors that we define. We first prove that functions with behavior lin and nil really exist.

Lemma 6.4. There are functions from L — L which preserve — and have the behavior lin and nil.

Proof. A function f with behavior lin can be constructed as follows. Let v1,v2,... be an enumeration of L. Inductively suppose that there exists a function f: {v1,.. .,vn} — L such that for all x,y,z e {v1,...,vn} with x — y — z it holds that f (x)\f (y)f (z) and f (x) — f (y) — f (z). This is clearly true for n =1. We prove that f has an extension f' to vn+1 with the same property. Let W1,..., wn+1 be such that {w1,..., wn+1} = {v1,..., vn+1} and W1 — ■■■ — wn+1. We consider the following cases.

• vn+1 = w1. There exists a c e L such that c \f (w2)f (w3) (see axiom C4). Note that if n = 1, then let c be such that c = f (w2). Pick c such that c — f (w2), and define f '(vn+1) = c.

• vn+1 = wi for i e {2,...,n — 1}. There exists a c e L such that f (wi-1)\cf (w;'+1) and c\f (wi+1)f(wi+2) (see Axiom C7). Pick c such that f (w—1) — c — f (wi+1), and define f '(vn+1) = c.

• vn+1 = wn.Thereexistsa c e L such that c = f (wn+1)and f (wn-1)\f (wn+1)c (see Axiom C6). Pick c such that f (wn-1) — c — f (wn+1), and define f'(vn+1) = c.

• vn+1 = wn+1. There exists a c e L such that c = f (wn) and f (wn-1)\f (wn)c (see Axiom C6). Pick c such that f (wn) — c, and define f '(vn+1) = c.

The function defined on all of L in this way has the behavior lin. The existence of a function with behavior nil can be shown analogously. H

The functions lin and nil constructed in Lemma 6.4 preserve the linear order —. In general, a function f : L — L with the same behavior as lin or nil may not preserve —. However, together with Aut(L; C) it generates a function that preserves — and has the same behavior as lin or nil, respectively. In the following, we will use lin and nil also to denote the functions with behavior lin and nil that have been constructed in Lemma 6.4; whether we mean the behavior or the function lin and nil will always be clear from the context. As we see in the following proposition, the two functions are closely related.

Proposition 6.5. Aut(L; C) U {nil} generates lin, and Aut(L; C) U {lin} generates nil.

Proof. Let n > 1 and arbitrarily choose t e Ln. Then — nil(—t) and lin(t) induce isomorphic substructures in (L; C, —), and by the homogeneity of (L; C, —) there is an a e Aut(L; C, —) such that a(— nil( —t)) = lin(t). It follows that

lin G (Aut(L; C) U {nil}}. The fact that Aut(L; C) U {lin} generates nil can be shown in the same way. H

The following lemma classifies the behavior of canonical injective functions from (L; C, —) to (L; C, —) on sufficiently large subsets of L.

Lemma 6.6. Let S C L be a set that contains four elements x, y, u, v such that xy\uv, and let f: D ^ D be injective and canonical on S as a function from (L; C, —) to (L; C, — ). Then f behaves as id, lin, or nil on S.

Proof. Since f is canonical on S as a function from (L; C, —) to (L; C, —), it either preserves or reverses the order — on S. We focus on the case that f preserves

— on S, since the order-reversing case is analogous. Without loss of generality, we assume that x — y — u — v. Since f preserves —, we have f (x) — f (y) — f (u) — f (v). The following cases are exhaustive.

• f (x)f(y)\f (u) and f(y)f(u)\f (v). By canonicity, f behaves as nil on S.

• f (x)f(y)\f (u) and f(y)\f (u)f (v). By canonicity, f behaves as id on S.

• f (x)\f (y)f (u) and f(y)\f (u)f (v). By canonicity, f behaves as lin on S.

• f (x)\f (y)f (u) and f (y)f (u)\f(v). By canonicity, f (x)\f (y)f (v) and f (x) f (u)\f (v). It is easy to see that those conditions are impossible to satisfy over (L; C). H

Corollary 6.7. Let c e Ln for n > 0, let S be a cone of (L; C, c), and let f: L ^ L be an injection that is canonical on S as a function from (L; C, —,c) to (L; C, — ). Then f behaves as id, lin, or nil on S.

Proof. Note that f is on S canonical as a function from (L; C, —) to (L; C, —); also note that every cone contains elements x, y, u, v such that xy\uv. Hence, the statement follows from Lemma 6.6. H

We finally show that if r is preserved by lin, then r is homomorphically equivalent to a reduct of (L; = ); this will be a consequence of the stronger Lemma 6.12 below.

Definition 6.8. For a1,a2,...,ak e L, k > 2, we write Nil(a1,a2,...,ak) if a1 — a2 — • •• — ak and a1a2 ... ai_1 \ai for all i e {2,..., k}.

Observe that for all a1,...,ak e L such that a1 — ••• — ak we have Nil(nil(a1,..., ak)) (recall from Section 3.1 that we apply functions to tuples componentwise). Also observe that all k-tuples in Nil lie in the same orbit of k-tuples.

Lemma 6.9. Let a1,...,ak e L be such that Nil(a1,...,ak). Then for every p e {1,...,k} there is an e e (Aut(L; C) U{nil}) such that Ni\(e(ap,a1,.. .,ap-1,ap+1 ,ap+2 ,...,ak)).

Proof. By Proposition 3.13 and the homogeneity of (L; C) there exists an a e Aut(L; C) such that a(ap) — a(az) — a(a2) — ••• — a(ap-1) — a(ap+1)

— ••• — a(ak); see Figure 2. Define e := nil oa. By the observation above we have Nil(e(ap, a1,a2,..., ap-1, ap+1, ap+2, ...,ak)), as desired. H

Lemma 6.10. Let a1,...,ak e L be such that Nil(a1 ,...,ak). Then for any p e {1, 2,...,k — 1}, there is an e e (Aut(L; C) U{nil}) such that e (ap) = ap+1, e(ap+1) = ap, and e(ai) = ai for every i e {1,...,k}\{p, p + 1}.

Proof. By the homogeneity of (L; C) there is an a e Aut(L; C) such that a(ap+1) — a(ap) — a(ap_0 — ••• — a(a2) — a(a\) — a(ap+2) — a(ap+3)

— ••• — a(ak); see Figure 3. Let zi := nil(a(ai)) for i e {1,2,...,k}. Clearly,

a, a2 ap aM dk a(ap) a(a,) a(a2) a(aM) a(dk)

Figure 2. Illustration of the re-ordering of Lemma 6.9.

a, a2 ap a^, a^ ak., ak a(a,„,) a(ap) a(a2)a(a,) afa^) a(aM) a(ak)

FiguRE 3. Illustration of the re-ordering of Lemma 6.10.

we have Nil(zp+1,zp,zp-1,...,z2,z1 ,zp+2,zp+3,...,zk). Starting with the tuple (zp+i, zp, zp-1 ,...,z2,z1, zp+2, zp+3, ...,zk) we repeatedly apply Lemma 6.9 to the resulting tuple at the positions p := 3,4,...,p — 1 in this order. In this way, we obtain in the first step an e1 g M := (Aut(L; C) U {nil}} such that

Nil(e1 (zp-1, zp+1 ,zp,zp-2, . . . ,z2,z1,zp+2 ,zp+3,... ,zk)).

In the second step, we obtain an e2 G M such that

Nil(e2(zp-2,zp-1,zp+1 ,zp,zp-3, . . . ,z2,z1, zp+2 ,zp+3,... ,zk)).

In the i -th step, we obtain an et G M such that

Nil( e, (zp-i,zp-i+1 ,. . . ,zp-2,zp-1,zp+1 ,zp,zp-i-1,.. .,z2,z1 ,zp+2 ,zp+3,.. .,zk)).

For i = p — 1, we therefore obtain an e' G M such that

Nil(e'(z1 ,z2, . . .,zp-2,zp-1,zp+1 , zp, zp+2,.. .,zk)).

Define f := e'◦ niloa and observe that Nil(f (a1,a2,...,ap-1,ap+1,ap,ap+2, ..., ak)). Therefore, f (a1,..., ap-1, ap+1, ap, ap+2,..., ak) and (a1, a2,..., ak) are in the same orbit in (L; C), and there is y G Aut(L; C) such that y(f (ap, ap+1)) = (ap+1 ,ap) andy (f(ai)) = ai for all i g{1,... ,k}\{p,p + 1}.Thene := y o f g M has the desired property. H

We write Sk for the symmetric group on {1 ,...,k}.

Lemma 6.11. Let (x1,x2,...,xk), (y1 ,...,yk) e Nil, and arbitrarily choose S e Sk. Then there exists an e e M := (Aut(L; C) U {nil}) such that e(x,) = yS(i).

Proof. By Lemma 6.10, for each p e {1,2,...,k — 1} there is an ep e M such that ep (xp) = xp+1, ep (xp+1) = xp, and ep (x,) = xi for all i e{1,...,k}\{p, p + 1}. Since Sk is generated by the transpositions (1,2), (2, 3),...,(k — 1,k), it follows that there exists e' e ({ep : 1 < p < k}) C M such that e'(xi) = xS(i) for all i e {1,..., k}. By the homogeneity of (L; C), there exists an a e Aut(L; C) such that a(xi) = yi for all i e {1,..., k}. Then e := a o e' satisfies e(x,) = yS(i). H

We can finally prove the announced result.

Lemma 6.12. Let r be a reduct of (L; C). Let c e Ln and suppose that r has an endomorphism behaving as lin on a cone of (L; C, c ). Then r is homomorphically equivalent to a reduct of (L; =).

Proof. Recall that each cone S of (L; C,c) induces in (L; C, —) a structure that is isomorphic to (L; C, —). Let e be an endomorphism of r that behaves as lin on S and arbitrarily choose a finite set A C L. By the homogeneity of (L; C, —) there are automorphisms a, P of (L; C, —) such that lin(x) = a(e(P(x))) for all x e A. Since End(r) is closed we have that lin e End(r) and nil e End(r) by Proposition 6.5.

Our proof has two steps: we first prove that the structure A induced by D := nil(L) is isomorphic to a reduct of (Q; <) and then we prove in the next step that A is in fact isomorphic to a reduct of (L; =). Clearly, this implies the statement since r and A are homomorphically equivalent. Let r be the signature of r. We first show that for every R e r, the relation RA has a first-order definition in (D; — ). The relation Rr has a first-order definition 0 in (L; C). An atomic subformula C (x; yz) of 0 holds in A if and only if y — z — x, z — y — x or y = z A x = y. Hence, if we replace in 0 all occurrences of C(x; yz) by y — z — x V z — y — x V (y = z A x = y), we obtain a formula that defines RA over (D; — ). Since (L; —) is isomorphic to (Q; <) and nil preserves —, it follows that (D; —) is isomorphic to (Q; <), too. Hence, A is isomorphic to a reduct of (Q; <).

To show that A is isomorphic to a reduct of (L;=), let X be a finite subset of D and a be a permutation of D .By Proposition 4.2 and the fact that End(A) is a closed subset of Dd, it suffices to find an e e End(A) such that e(x) = a(x) for all x e X. Since X C nil(L), the elements of X can be enumerated by x1,...,xn such that Nil(x1,... ,xn). Since a(X) C D = nil(L), there is a y e Sn such that Nil(a(xy(1)),.. .,a(xy(n))). We apply Lemma 6.11 to (x1,...,xn), (y1,...,yn) := (a(xy (1)),... ,a(xy (n))), and S = y-1, and obtain an f e End(r) such that f (x,) = ys(i) = a(xyy-1(i)) = a(x,) for all i e{1,... ,k}. The restriction of nil of to D is an endomorphism f' of A. Since nil preserves — and A is a reduct of (D; —) which is isomorphic to (Q; <), we have that (a(x1),...,a(xn)) = (f(x1),...,f(xn)) and (f '(x1),... ,f'(xn)) lie in the same orbit in A. Hence, there exists an P e Aut(A) such that P (f'(x,)) = a(x,) for all i e {1,...,n}, and P o f' is an endomorphism of A as required. H

6.2. Canonical behavior with one constant. In this section we study the behavior of canonical functions from (L; C, —, c1) to (L; C, —). Some important behaviors are introduced in Definition 6.13. We then show in Sections 6.2.1-6.2.3 that when a

function f has some of those behaviors on a c-universal set, then {f }U Aut(L; C) generates lin or End(L; Q). Finally, Section 6.2.4 classifies behaviors of canonical functions from (L; C, — ,c1) to (L; C, —).

Definition 6.13. Let c e L and A C L \ {c}. Let e: L ^ L be a function such that

1. for any a e A we have that e(c)\e(A n Sca),

2. for any a e A, e preserves C on A n SI, and

3. for any a,b e A we have either SI = Sc or e(A n SI)\e(A n Sc).

Then we say that e has on A the behavior

idc iff for all x,y,z e A with x\yzc and y\zc we have that e(x)\e(y)e(z)e(c) and e(y)\e(z)e(c).

cutc iff for all x,y,z e A with x\yzc and y\zc we have that e(x)e(y)e(z)\e(c) and e(x)\e(y)e(z).

rerc iff for all x,y,z e A with x\yzc and y\zc we have that e(x)e(y)e(z)\e(c) and e(x)e(y)\e(z).

rerc iff for all x,y e A with x\yc we have that e (y )\e(x)e(c).

6.2.1. The behavior cutc. Recall that a set A C L\{c } is called c-universal if for any finite U C L and u e U, there is a e Aut(L; C) such that a(u) = c and a(U) C A U{c }. In this section we prove that for all c e L, functions with behavior cutc on a c-universal set together with Aut(L; C) generate lin. This follows from the following more general fact.

Lemma 6.14 (Cut Lemma). Let Aut( L; C) C M C Ll be such that for any finite U C L and u e U, there exists g e M that behaves as cutu on U \ {u}. Then M generates nil and lin.

Proof. By Proposition 6.5, it suffices to show that M generates nil. We show that for all k and all x1 ,...,xk e L there is an f e (M) such that f (xi) = nil(xi) for all i < k. We prove this by induction on k. Clearly, the claim holds for k = 1 so assume that k > 1. Suppose without loss of generality that x1 — x2 — ••• — xk. We inductively assume that there is an f' e (M) such that f'(xi) = nil(xi) for all i < k. Let U := f '({x1,... ,xk}) and u := f'(xk). By assumption, there exists a g e M that behaves as cutu on U \{u}.

Set f'' = g o f'. We claim that f ''(x1) • • • f''(xi)\f''(xi+1) for all 1 < i < k. For i < k — 1, this follows from the inductive assumption that f '(x1) • • • f '(xi )\f'(xi+1), and the assumption that g behaves as cutu on U \{u} and in particular preserves C on U \ {u}. For i = k — 1, note that that g(u)\g(U \ {u}) since g behaves as cutu on U \ {u}, and f ''(x1),... ,f''(xi) C g(U \ {u}). Therefore, f ''(x1) • • • f ''(xk_1)\f''(xk) which concludes the proof of the claim.

Since nil(x1) • • •nil(xi)\ nil(xi+1) for all 1 < i < k, the homogeneity of (L; C) implies that there exists an a e Aut(L; C) C M such that a(f ''(xi)) = nil(xi) for all i < k. Then f := a o f'' e (M) has the desired property which concludes the proof. H

Corollary 6.15. Let c e L,let A C L \{c } be c-universal, andlet g be a function that behaves as cutc on A. Then {g}U Aut(L; C) generates lin.

Proof. The c -universality of A implies that for every finite U C L and u e U there exists an a e Aut(L; C) such that a(U \ {u}) C A and a(u) = c. Then g o a behaves as cutu on U and the statement follows from Lemma 6.14. H

6.2.2. The behavior rerc. We will next prove that for all c e L, functions with behavior rerc on a c-universal set together with Aut(L; C) generate End(L; Q). We need the following lemmas in some later proofs.

Lemma 6.16. Arbitrarily choose X C L and c e X .If f: L — L preserves Q on every 4-element subset of X that contains c, then f preserves Q on all of X.

Proof. Let a1,a2,a3,a4 e X be such that a1a2 : a3a4. We show f (a1)f (a2) : f (a3) f (a4). It is easy to see that this holds if a1 ,a2,a3, a4 are not pairwise distinct and it holds by assumption when c e {a1,a2, a3, a4}. Suppose that this is not the case. Then a1a2c : a3a4or a1a2 : ca3a4. The latter case can be treated analogously to the former so we assume that a1a2c : a3a4. In particular, a1c : a3a4 and a2c : a3a4 so f (a1)f (c) : f (a3)f (a4) and f (a2)f(c) : f (a3)f (a4). It follows from Lemma 3.9 that f (a1)f (a2) : f (a3)f (a4) as desired. H

Lemma 6.17. Let A C L\{c} and f : L — L be such that f behaves as rerc on A. Then f preserves Q on A U {c }.

Proof. By Lemma 6.16 it suffices to show that f preserves Q on {x,y,z,c } ,where x, y, z are pairwise distinct elements in A. The following cases are essential.

• xyz\c.

It follows from Items 1 and 2 of Definition 6.13 that f (x )f (y )f (z )\f (c) and f preserves C on {x,y,z}. This implies that (x,y,z,c) and (f (x),f(y),f(z),f(c)) are in the same orbit of Aut(L; C). Thus f preserves

Q on {x, y, z, c}.

• xy\zc.

Clearly, we have xy : zc. It follows from Item 1 of Definition of 6.13 that f (x)f(y)\f (c). It follows from Item 3 of Definition 6.13 that f (x )f(y)\f (z). This implies that f(x)f (y) : f(z)f(c). Thus f preserves Q on {x,y,z,c}.

• x\yzc A yz\c.

Clearly, we have xc : yz. It follows from Item 1 of Definition 6.13 that f (y)f (z )\f (c). It follows from Item 3 of Definition 6.13 that f (x)\f (y)f (z). This implies that f(y)f(z) : f (x)f (c). Thus f preserves Q on {x,y,z,c}.

• x\yzc A y\zc.

Clearly, we have xy : zc. By the definition of rerc that f (x )f(y)f(z)\f (c)A f (x)f(y)\f (z). This implies that f (x)f(y) : f (z)f (c). Thus f preserves Q

on {x, y, z, c}.

The other cases can be obtained from the above cases by exchanging the roles of

x, y, z. H

The following generation lemma is flexible and will be useful later.

Lemma 6.18 (Rerooting Lemma, general form). Let Aut(L; C) C M C Ll be such that for any finite U C L and u e U there exists g e M that behaves as reru on U \ {u}. Then M generates End(L; Q).

Proof. We follow almost literally the proof of Lemma 4.9 (the rerooting lemma). Arbitrarily choose f e End(L; Q) and let A be an arbitrary finite subset of L.

We have to show that (M) contains an operation e such that e(x) = f (x) for all x e A. This is trivial when \A \ = 1 so we assume that \A\ >2. By Lemma 4.7, there exists a nonempty proper subset B of A such that f (B)\f (A \ B) and B\a for all a e A \ B .By the homogeneity of (L; C) we can choose an element c e L \ A such that c\B and (B U {c})\a for all a e A \ B. By assumption, there exists a g e M such that g behaves as rerc on A. By Lemma 6.17, g preserves Q on A.

We claim that g(B)\g(A \ B). First, we show that g(b1)g(b2)\g(a) for every b1,b2 e B and a e A \ B .By the choice of c we have b1b2 : ac. Since g preserves Q on A, we have g(bjg(b2) : g(a)g(c). Since g(c)\g(b{)g(b2)g(a), we have g(b1)g(b2)\g(a). Next, we show that g(b)\g(a1)g(a2) for every b e B and a1 ,a2 e A \ B .By the choice of c we have bc : a1 a2. Since g preserves Q on A, we have g(b)g(c) : g(a^g(a2). Since g(c)\g(b)g(a^g(a2), we haveg(b)\g(aOg(a2).

Let P: g(A) ^ f (A) be defined by P(x) = f (g-1(x)) for all x e g(A). Since both g and f preserve Q, we have that P preserves Q by Lemma 3.10. Since P(g(B))\P(g(A \ B)), the conditions of Lemma 4.6 apply to P for A1 := g(B) and A2 := g(A \ B), and hence P preserves C. By the homogeneity of (L; C), there exists an y e Aut(L; C) C M that extends P. Then e := y o g e (M) has the desired property. H

Corollary 6.19. Let c e L, let A C L\{c } be c-universal, and let g be a function that behaves as rerc on A. Then {g} U Aut(L; C) generates End(L; Q).

Proof. We claim that the conditions of Lemma 6.18 apply to M := ({g}U Aut(L; C)). Let U C L be finite and arbitrarily choose u e U .By c -universality of A there exists an a e Aut(L; C) such that a(U) C A and a(u) = c. Since g behaves as rerc on a(U), the function g o a behaves as reru on U. By Lemma 6.18 ({g} U Aut(L; C)) generates End(L; Q), and so does {g} U Aut(L; C). H

By Lemma 6.17, a function with behavior rerc on A preserves Q on A. We now characterize the situation where a function preserving Q behaves as rerc.

Lemma 6.20. Let X be a subset of L, arbitrarily choose a e X, and let f: L ^ L be a function that preserves Q on X and has the property that f (a )\f (X \{a }). Then f preserves C on X n Sa for every x e X \{a}, and for any x, y e X \ {a} either Sax = Sya or f(X n Sax )\f (X n Sy).

Proof. Arbitrarily choose x e X \{a} and pick pairwise distinct elements u,v,w e X n Sa. By C8 we can assume that uv\w. Clearly, aw : uv and it follows that f (a)f (w) : f (u)f (v). Since f(a)\f (u)f (v)f(w) by the assumptions on f, we have f (w)\f (u)f (v). This concludes the proof of the first assertion of the lemma.

To show the remaining assertion, let x,y e X \{a} and assume that S a = Sy. We claim that f (X n S^)\f (y). It suffices to show that f (x')f (x)\f(y) for any x' e X n Sa. Clearly, we have ay : xx' and, consequently, f (a)f (y) : f (x)f (x'). Since f (a)\f(x)f (x')f (y), it follows that f (x)f (x')\f(y). This concludes the proof of the claim. Similarly, it can be shown that f (x)\f (X n Sy). To complete the argument, arbitrarily choose x1,x2 e X n Sa and y1,y2 e X n Sy. The claim implies that f (x1)f (x)\f (y) and f (x2)f(x)\f (y). Similarly, f(x )\f (y1)f(y)and f (x)\f (y2)f (y) because f (x)\f (X n Say). This implies that f (xf (x2)\f (y1)f (y2), and, consequently, f (X n Sxa)\f (X n Sa). H

CoROLLARy 6.21. Let X be a subset of L, arbitrarily choose a e X, and let f : L — L be a function such that f (a )\f (X \{a }). Then f behaves as rera on X if and only iff preserves Q on X.

Proof. By Lemma 6.17 if f behaves as rera on X then f preserves Q on X. Conversely, suppose that f preserves Q on X. By Lemma 6.20, it remains to show that for x,y,z e X \ {a} such that x\yza A y\za we have f (a)\f(x)f (y)f (z) A f (z)\f(x)f (y). Clearly, we have xy : za and f (x)f(y) : f (z)f (a). Since f (a)\f(x)f (y)f (z), it follows that f (x)f (y)\f (z). H

6.2.3. The behavior rerc. We finally study functions with behavior rerc on a c -universal set. We need the following lemma for the proof of the next important lemma.

Lemma 6.22. Let c e L and A C L\{c } be a c-universal set. Let f : L — L be a function that behaves as rerc on A. Then f preserves Q on A.

Proof. Let x, y, z, t be elements in A such that xy : zt. It suffices to show that f (x) f (y) : f (z) f (t). Without loss of generality we assume that xy\z A xy\t. The following cases are exhaustive.

• c\xy.

We will show that f(x )f (y)\f (z). If xyz\c holds, then by Item 2 of Definition 6.13 we have f (x)f(y)\f (z). If xy\zc holds, then by the definition of rerc, we have f (z)\f (x)f (c) and f (z)\f (y)f (c). It follows that f (x)f(y)\f (z). If z\xyc holds, by Item 3 of Definition 6.13, we have f (x)f(y)\f (z). These cases are exhaustive, thus f (x)f(y)\f (z). By the same arguments we have f (x)f(y)\f (t). Thus f(x)f (y) : f (z)f (t).

• -c\xy.

We consider the case cx\y. The case cy\x are proved similarly. Since xy\z and xy\t, it follows that cxy\z and cxy\t. By the definition of rerc, we have f (c)f (z)\f (x) A f (c)f(z)\f (y) A f (c)f(t)\f(x) A f (c)f (t)\f (y). It follows from f (c)f(z)\f (x) A f (c)f (t)\f (x) that f (z)f (t)\f (x). It follows from f (c)f (z)\f (y) A f (c)f (t)\f (y) that f (z)f (t)\f (y). This implies that f (z)f (t)\f (x) A f (z)f (t)\f (y). Thus f (x)f(y) : f (z)f (t). h

Lemma 6.23. Let c e L, let A C L \ {c} be c-universal, and let g: L — L be a function that behaves as rerc on A. Then {g}U Aut(L; C) generates lin.

Proof. The proof has two steps. We first show that {g} U Aut(L; C) generates End(L; Q), and then prove that {g} U End(L; Q) generates lin.

For the first step it suffices to showthat ({g} U Aut(L; C)} satisfies the conditions of Lemma 6.18. Let U be a nonempty finite subset of L and arbitrarily choose an element u e U. Let c' e L be such that c' = u and for every v e U \ {u} we have uc'\v. Since A is c-universal, there is an a e Aut(L; C) such that a(U) C A and a(c') = c. Arbitrarily choose two members v1,v2 of U \{u}. By the choice of c' we have that either uc'\v1 A uc'v1 \v2, uc'\v2 A uc'v2\v1, or v1v2\uc'. Since a preserves C and g behaves as rerc on A, it follows that g(a(v1))g(a(v2))\g(a(u)) in each of the three cases. This implies that g(a(U\{u}))\g(a(u)). By Lemma 6.22, g preserves Q on A so g o a preserves Q on U. By Corollary 6.21 the function g o a behaves as reru on U. This concludes the first step.

To show that {g} U End(L; Q) generates lin, we use Lemma 6.14. Let U C L be finite and arbitrarily choose u e U.Letv e L be such that U\v .Bythec-universality of A there is an a e Aut(L; C) such that a(U U{v }) C A U{c } and a(u) = c. Since for every x e U \ {u} we have ca(x)\a(v), it follows that g(c)g(a(v))\g(a(x)) for every x e U\{u}. This property together with the homogeneity of (L; Q) allows us to choose P e Aut(L; Q) such that P(g(c))P(g(a(v)))\P(g(a(U \ {u}))). Let h = P o g o a. Since g behaves as rerc on A, it follows from Lemma 6.22 that g preserves Q on A, therefore g preserves Q on a({v} U U \ {u}). This implies that h preserves Q on {v} U U \ {u}. Since v\U \ {u}, h(v)\h(U \ {u}), and h preserves Q on {v} U U \ {u}, it follows from Lemma 4.6 that h preserves C on U \ {u}. Since h(u) = P(g(c)), we have that h(u)\h(U \ {u}). It follows that h behaves as cutu on U. H

6.2.4. Classification of behaviors with one constant. The main result of this section is Lemma 6.26 below, which can be seen as a classification of canonical functions from (L; C, — ,c) to (L; C, —). We first need two lemmata about c -universal sets.

Lemma 6.24. Choose c e L andlet A C L\{c } bea c-universal set. Then for every finite subset X of L there is an a e Aut(L; C, —) such that a(X) C A anda(X)\c.

Proof. Recall that the class of all ordered leaf structures has the ordering property (Theorem 5.10). By the formulation of the ordering property from Proposition 5.9, there exists a finite subset Y of L such that for every P e Aut(L; C) there exists a a e Aut(L; C, —) such that a(X) C P (Y). Let y e L be such that y \Y holds. Since A is c-universal, there exists a y e Aut(L; C) such that y(y) = c and y (Y) C A. By the choice of Y there exists an a e Aut( L; C, —) such that a(X) C y (Y) C A. Since y(Y)\c, we have a(X)\c which concludes the proof. H

Lemma 6.25. Let c e L, andlet A be a subset ofL such that A C{x e L : x — c} or A C {x e L : c — x}, and A is c-universal. Let e: L ^ L be an injective function that is canonical as a function from (L; C, —,c) to (L; C) and preserves C on A n SI for every a e A. Then

• for every a e A we have e(c)\e(A n Sc), and

• for every a,b e A we have either S c = Sc or e(A n S c)\e(A n Sc).

Proof. To prove the first assertion of the lemma, it suffices to prove that for arbitrary x,y e A satisfying xy\c we have e(x )e (y )\e(c). Assume for contradiction that there are x1,x2 e A such that x1x2\c and e(x1)\e(x2)e(c). Let x3 e L be such that x1 = x3 A x1x3\x2 holds. By Lemma 6.24 there is an a e Aut(L; C, —) such that a({x1,x2,x3}) C A and a({x1,x2,x3})\c. For i e {1, 2, 3} let x' := a(xi). The pairs (x1,x2), (x',x2), and (x3, x'2) are in the same orbit of Aut(L; C, — ,c): we have x1 — x2 if and only if x[ — x'2 since a preserves —. Further, x' — x2 if and only if x3 — x2 by convexity of — since x1x3\x2 holds and a preserves C. Moreover, it holds that x1x2\c by assumption, and x[x'2\c and x'3x2\c by the properties of a. In case that A C {x e L : x — c} we have x1,x2,x3,x',x2, x3 — c, otherwise we have c — x1,x2,x3,x' ,x2, x3. By the homogeneity of (L; C, —,c) we conclude that (x1,x2), (x',x2), and (x3,x2) are indeed in the same orbit of Aut(L; C, —, c).

By the canonicity of e, we have that e(x')\e(x2)e(c) and e(x3)\e(x2)e(c). Since e preserves C on Sx n A, we have e(x')e(x3)\e(x2) which implies that e(x')e(x3)\e(x2)e(c). Since

x' x2 x3 \ c and x' ,x2, x3 are pairwise distinct, it follows

that either (x',x'3) or (x3,x1) is in the same orbit as (x',x2) in Aut(L; C, — ,c). If (x' ,x3) and (x' ,x2) are in the same orbit in Aut(L; C, —,c), then by the canonicity of e, (e(x'), e(x3), e(c)) and (e(x[), e(x2), e(c)) are in the same orbit in Aut(L; C). This is impossible since e(x')e(x3)\e(x2)e(c). The case (x3,x1) and (x',x2) are in the same orbit of Aut(L; C, — ,c ) is proved similarly. The first assertion of the lemma therefore follows.

It remains to show the second assertion of the lemma. We consider the case A C{x e L : x — c}. The case A C{x e L : c — x} is argued similarly. We need the two following claims.

ClAiM 1. For any x1,x2,x3 e A satisfying x1\x2x3c and x2x3\c we have e(x0\e(x2)e(x3).

Proof of ClAiM 1. For a contradiction we assume that e(x1)e(x2)\e(x3). Let y1 ,...,y5 e A be pairwise distinct such that y1\y2y3y4y5c, y2y3y4y5\c, and y2y3\y4y5. It follows from the convexity of — that y1 — yi for i e {2,...,5}. Since y2y3\y4y5, we have either yi — yj for i e {2,3} and j e {4,5}, or yi — yj for i e {4,5} and j e {2, 3}. Without loss of generality we assume that y2 — y3 — y4 — y5. If x2 — x3, then the tuples (x1,x2,x3), (y1 ,y2,y4), and (y1,y4, y5) are in the same orbit of Aut(L; C, —,c). Thus e(y1)e(y2)\e(y4) and e(y1)e(y4)\e(y5). Since e preserves C on A n Scyi and since {y2, y3,y4,y5} C A n Scyi, we have e(y2)\e(y4)e(y5). These conditions are impossible to satisfy over (L; C). If x3 — x2 then we consider the three tuples (x1 ,x3,x2), (y1 ,y2,y3), and (y1 ,y3,y4) that lie in the same orbit of Aut(L; C, —,c) and proceed analogously. H

ClAiM 2. For any x1 ,x2,x3 e A satisfying x1x2\x3c we have e(x1 )e(x2)\e(x3).

This claim can be shown similarly as for the claim above by choosing five distinct elements y1 ,...,y5 such that y1y2y3y4\y5c and y1y2\y3y4.

Let a,b e A such that Sca = S£. This condition implies that ca\b or cb\a. We consider the case ca\b. The case cb\a is argued similarly. By the definition of cones, we have Sc\S£, thus A n Sc \A n Sjj .Let x, y e A n Sc and z,t e A n Sjj be arbitrary. It follows from ca\b A xya \ c A ztb \ c that z\xyc A xy\c A t\ xyc A xy\c A zt\xc A zt\yc. It follows from Claim 1 that e(z)\e(x)e(y) A e(t)\e(x)e(y), and it follows from Claim 2 that e(z)e(t)\e(x) A e(z)e(t)\e(y). Thus e(x)e(y)\e(z)e(t). The second assertion follows. H

Lemma 6.26. Let c e L, and let A be a subset ofL such that A C{x e L : x — c} or A C {x e L : c — x}, and A is c-universal. Let e: L — L be an injective function that is canonical on A as a function from (L; C, —,c) to (L; C, —). Then {e} U Aut(L; C) generates lin or e behaves on A as idc or rerc.

Proof. We consider the case A C {x e L : x — c}. The case A C {x e L : c — x} is argued similarly. The canonicity of e implies that either

• e(x) — e(y) for all x,y e A such that xy\c and x — y, or

• e(y) — e(x) for all x,y e A such that xy\c and x — y.

If the second case applies, we continue the proof with — o e instead of e. Thus we assume in the following that the first case applies.

Since A is c-universal, there is an a e A such that Sca n A contains four distinct elements x,y,u,v satisfying xy\uv. The function e is canonical on Sca n A as a function from (L; C, —) to (L; C, —). Lemma 6.6 shows that e behaves as id, lin,

or nil on Sac n A. The canonicity of e implies that e has the same behavior on all sets of the form SI n A for x e A.

If e behaves as lin on all those sets, then we show that Aut(L; C) U {e} generates lin. Let X be a finite subset of L. By Lemma 6.24 there is an a e Aut(L; C, —) such that a(X) C A and a(X)\c. Since e behaves as lin on a(X) and a preserves —, the function e o a behaves as lin on X. This implies that {e} U Aut(L; C) generates lin.

If e behaves as nil on all sets of the form Sxc n A for x e A, then by the same argument it can be shown that {e}U Aut(L; C) generates nil, and therefore lin by Proposition 6.5. We therefore assume in the following that e preserves C on each set of the form Sc n A, x e A. Lemma 6.25 implies that the preconditions of the behaviors are satisfied (Definition 6.13). Let u,v e A be such that u\vc. Clearly, we have u — v. By C8, the following cases are exhaustive.

1. e(u)\e(v)e(c). Let x,y,z e A be such that x\yzc and y\zc. Clearly, we have x — y — z — c. Since (x, y) and (y, z) are in the same orbit of Aut(L; C, —,c) as (u,v), we have e(x)\e(y)e(c) and e(y)\e(z)e(c) implying that e(x)\e(y)e(z)e(c). Thus, e behaves as idc on A.

2. e(v)\e(u)e(c). Let x,y,z e A be such that x\yzc and y\zc. Since (x,y) and (y, z) are in the same orbit as (u, v) in Aut(L; C, —, c), we have e(y)\e(x)e(c) and e(z)\e(y)e(c), and therefore e(z)\e(x)e(y)e(c). Thus, e behaves as rerc on A, and {e} U Aut(L; C) generates lin by Lemma 6.23.

3. e(u)e(v)\e(c). Canonicity of e on A implies that for any x,y e A we have e(x)e(y)\e(c) and thus e(A)\e(c). Let a1,a2, a3 e A be three distinct elements such that a1 \a2a3c and a2\a3c. By the convexity of — we have a1 — a2 — a3 so (a1,a2) and (a2, a3) are in the same orbit of Aut(L; C, — )as(u, v). The canonicity of e implies that either e(a1) — e(a2) — e(a3) or e(a3) — e(a2) — e(a1) holds. It follows from the convexity of — that either e(a1)\e(a2)e(a3) or e(a1)e(a2)\e(a3) holds. If the first case holds then e behaves as cutc, and if the second case holds then e behaves as rerc on A.

We conclude that unless {e} U Aut(L; C) generates lin, it behaves as idc or rerc on A. H

6.3. Canonical behavior with two constants. In this section we analyze canonical functions from (L; C; —, c1,c2) to (L; C; — ). For our purposes, it suffices to treat some special behaviors (Lemma 6.28); the motivation for those behaviors will become clear in the proof of Proposition 6.31. Then, we prove that certain behaviors of f imply that {f} U Aut(L; C) generates lin (Lemmas 6.29 and 6.30).

Definition 6.27. Let c1,c2 e L be distinct. Then A C L \ {c1,c2} is called (c1, c2)-universal if for every finite U C L and u1 ,u2 e U there is an a e Aut(L; C) such that a(U) C A U {u1, u2}, au1 = c1, and au2 = c2.

Note that when A is (c1,c2)-universal then this implies in particular that {x e A : xc1\c2} and {x e A : x\c1c2} are ^-universal.

Lemma 6.28. Let c1,c2 e L be distinct, and let A be (c1, c2)-universal such that all elements in A1 := {x e A : xc1 \c2} are in the same orbit in (L; C; — ,c1 ,c2), and all elements in A2 := {x e A : x\c1 c2} are in the same orbit in (L; C; —, c1, c2). Let f: L ^ L be canonical on A as a function from (L; C; —, c1, c2) to (L; C; —). Then {f} U Aut(L; C) generates lin or End(L; Q), or f preserves C on {c1} U A1 U A2.

Proof. It follows from the assumption on A\ and A2 that f is canonical on A\ and A2 as a function from (L; C, c\) to (L; C, —). By Lemma 6.26, if f does not preserve C on A\ U {c\} then {f} U Aut(L; C) generates lin and we are done, or it behaves as rerc1 on A\ U {c\} in which case {f} U Aut(L; C) generates End(L; Q) by Corollary 6.\9, and we are again done. The same argument applies if f does not preserve C on A2 U {c2}.

Thus, it remains to consider the case when f preserves C on both A\ U {c\} and on A2 U {c\}. Let a\ G A\ and a2 G A2. We distinguish the following cases:

• f (c\)|f (a\)f (a2). It follows from the canonicity of f that f (c\)|f(a\)f (x) for all x G A2 so f (c\)|f (A2). This is impossible since f preserves C on {c\}UA2.

• f (a2)f (c\)|f (a\). It follows from the canonicity of f that f (x)f (c\)|f(a\) for all x G A2, therefore f (a\)|f (A2). This implies that f behaves as cuta on A2. Since c\a\ x for all x g A2 and A2 is c\-universal, we have that A2 is also a\-universal, and, by Corollary 6.\5, {f} U Aut(L; C) generates lin.

• f (c\)f(a\)f (a2). It follows from the canonicity of f that f preserves C on {c\} U A\ U A2, and we are done.

Since these three cases are exhaustive, the statement follows. 4

Lemma 6.29. Let c\,c2 g L and A С L \{c\,c2} be (c\,c2)-universal. Let A\ = {x G A : xc\^2}, A2 = {x G A : c\^c2}, and A3 = {x G A : c\c2\x}. Let g : L ^ L be an injection such that

• g(A\ U{c\})|g(c2),

• g preserves C on {c\} U A\ and on {c2} U A2 U A3, and

• g(c\)g(c2)|g(x) for every x G A2 U A3.

Then {g }U Aut( L; C) generates nil.

Proof. We need to show that for all k and all x\,...,xk G L there is an f G M := (Aut(L; C) U {g}} such that f (xj) = nil(xj) for all j < к. This is clearly true for к < 2. To prove it for к > 3, suppose without loss of generality that x\ — • • • — xk. We first prove by induction on i G {\,...,k — \} that there exists an h G M with the following properties.

\. h(x\) • • • h(xi)|h(xj) for every j G{i + \,..., k},

2. h preserves C on {xi,...,xk},

3. for i > 2 we additionally require that h(x\) • • • h(xj)|h(xj+\) for every j G {\,...,i — \}.

For i = \ the identity function has the properties that we require for h G M. For i > 2, we inductively assume the existence of a function h' G M such that

• h'(x\) • • • h'(xi_\)|h'(xj) for every j G{i,..., k},

• h' preserves C on {xi_\,... ,xk}, and

• if i > 3 we additionally have h (x\) • • • h (xj )h (xj+\)forevery j g{\,..., i— 2}.

By (c\, c2)-universality of A, there exists an a G Aut(L; C) that maps h'(x\) to c\,

h'(xi) to c2, and such that ah'({x\,..., xk}) С A U {c\,c2}.

Observation. ah' ({x\,... ,xi _\}) С {c\} U A\ and ah '({xt,... ,xk}) С {c2} U A2 U A3.

Proof of the observation. The first property of h' implies that h'(x1) h'(xi-1)\h'(xi). Therefore, ah'(x1)ah'(xi-1)\ah'(xi) and c1x\c2 for every x e ah'({x1,..., xi-1}) which concludes the proof of the first part of the observation.

To show the second part, arbitrarily choose j e {i,...,k}. If j = i then ah'(xj) = ah'(xi) = c2 and there is nothing to show. Since xi-1 — xi — xj, we distinguish the cases that xi-1 \xixj and xi-1 xi\xj. By the inductive assumption, h' preserves C on {xt-1,..., xk} so we have

h' (xi _1)\h '(xt )h'(xj )or h '(xt _{)h' (xi )\h' (xj).

First consider the case h'(xi-1)\h'(xi)h'(xj). By the first property of h', we also have

h'(x1)h'(xi-1)\h'(xj) andh'(x1)h'(xt-1)\h'(xt)h'(xj).

Consequently, ah'(x1) \ah'(xi )ah'(xj), and thus c1\c2ah'(xj). Hence ah' (xj) e A2. Now consider the case h'(xi-1)h'(xi)\h'(xj). Since h'(x1)h'(xi-1)\h'(xj), we have h'(x1)h '(xi )\h' (xj). Thus c1c2\ah '(xj), and ah '(xj) e A3. H

We claim that h := g o a o h' satisfies the inductive claim so we have to verify the three properties from the inductive statement.

Ad 1. By the observation above with the facts that ah'(xi) = c2 and ah' is injec-tive, it follows that ah'({xi+1, ...,xk}) C A2 U A3. Since g(c1)g(c2)\g(x) for every x e A2 UA3 and g (A1 U{c1})\g (c2), we have g ({c1,c2}UA0\g (x) for every x e A2 U A3. Therefore, (g o a o h')({x1, ...,xi })\(g o a o h')(xj) for every j e{i + 1,..., k}, or, equivalently, h(x1) • • • h(xi)\h(xj), which is what we had to show.

Ad 2. By the second property of h', the restriction of h' to {xt-1 ,...,xk} preserves C. Since ah '({xi, ...,xk }) C {c2}UA2 U A3 and g preserves C over {c2} U A2 U A3, the restriction of h = g o a o h' to {xi,..., xk} preserves C as well.

Ad 3. We assume that i > 3 since otherwise there is nothing to show. Since g preserves C over A1 U {c1} and ah'({x1,...,xi-1) C A1 U {c1}, the third property of h' implies that g o a o h'({x1, ...,xj})\g o a o h'(xj+1) for all j e {1,...,i — 2}. Equivalently, h (xj)- • • h (xj )\h(xj+1) for all j e {1,...,i — 2}. It remains to show that h(xi-2)h(xi-1)\h(xi). This follows directly from the fact that g(A1 U {c1})\g(c2) and ah'(xi) = c2.

This concludes the induction. For i = k the third property of h implies that h (x1)^ • • h (xj )\h(xj+1) for all j e {1,...,k — 1}. This property and the homogeneity of (L; C) imply the existence of P e Aut(L; C) such that Ph(x) = nil(x) for all x e X, and hence f := P o h e M is a function with the desired properties. H

Lemma 6.30. Let c1,c2 e L and A C L \ {c1,c2} be (c1,c2)-universal. Let A1 = {x e A : xc1\c2}, A2 = {x e A : c1\xc2}, and A3 = {x e A : c1c2\x}. Let g: L ^ L be an injection such that

• for all a1 e A1, a2 e A2 we either have g(c1)g (a1)\g(a2) or g(c1)g(a2)\g (a1):

• g preserves C on {c1} U A1 U A3 and on {c2} U A2 U A3, and

• g(c1)g(c2)\g(x) for every x e A.

Then {g }U Aut(L; C) generates lin.

Proof. We first show that {g }U Aut(L; C) generates a function f with the property that there are no a, b,c,d e L such that f (a )f (b )\f (c )f (d). For this, it suffices by a standard application of Konig's tree lemma (see, e.g., Section 3.1 in [6]) to show that for all finite S = {x1,..., xk} C L there is an h e M := (Aut(L; C) U {g}} such that there are no a,b,c,d e S with h(a)h(b)\h(c)h(d).

This is clearly true for k < 1. To prove it for k > 2, we prove by induction on i e{1,...,k — 1} that there exists an h e M with the following property.

Phii The equivalence relation ~h defined on {x2,...,xk} by u v iff h(x1)\h(u)h(v) has at least i equivalence classes.

For i = 1 the statement is trivial and we let h e M be the identity function. For i > 2, we inductively assume the existence of a function h' e M satisfying Phti_1. If Ph'i holds, then there is nothing to be shown so we assume that there are distinct p ,q < k such that h '(x1)\h '(xp)h '(xq). By (c1, c2)-universality of A, there exists an a e Aut(L; C) that maps h'(x1) to c1, h'(xp) to c2, and such that ah ({x1,. ..,xk }) C A U{c1,c2}. We claim that h := g o a o h' satisfies Phii .To show that, we first prove that ~h has at least as many equivalence classes as ~h'.

Observe that when r,s e {2,...,k} are such that xr ^h' xs, then xr ^h xs: when both a(h'(xr)),a(h'(xs)) e A1 U A3 then this follows the assumption that g preserves C on {c1} U A1 U A3; a similar argument applies when both a(h'(xr)), a(h'(xs)) e A2 U A3. When a(h'(xr)) e A1 and a(h'(xs)) e A2 then either g(d)g(a(h'(xr)))\g(a(h'(x^))) or g(d)g(a(h'(xs)))\g(a(h'(xr))), so xr ^h xs.

Next, consider the case that one of r,s, say r, equals p, that is, a(h'(xr)) = c2. In this case we have by the third assumption on g in the statement of the lemma that g(a(h'(x1)))g(a(h'(xr)))\g(x) for all x e A, and in particular that g(a(h'(x{)))g(a(h'(xr)))\g(a(h'(xs))). Hence, xr ^h xs.

To see that ~h has strictly more equivalence classes than ~h', observe that xp xq but xp ^h xq as we have just seen. This concludes the inductive proof.

Note that Ph>k-1 implies that for all p < q < k we have h (xp )h (x1)\h (xq) or h(xq)h(x1)\h(xp), and in particular there cannot be a,b,c,d e S such that h (a )h (b)\h(c )h (d). This concludes our proof of the existence of f.

Since (L; C, -<) is homogeneous, Ramsey, and co-categorical, Theorem 5.6 asserts the existence of a function f' e {a1fa2 \ a1,a2 e Aut( L; C, —)} which is canonical as a function from (L; C, —) to (L; C). Clearly, f' also has the property that there are no a,b,c,d e L such that f'(a)f'(b)\f '(c)f '(d), and the behavior of f' is either lin or nil by Lemma 6.6. In both cases, {f'} U Aut(L; C) generates lin by Proposition 6.5. H

6.4. Proof of the main result. In this section we finish the proof of Theorem 2.1 and Corollary 2.3. We begin by proving two auxiliary results in Propositions 6.31 and 6.33.

Proposition 6.31. Let r be areduct of (L; C). Then one of the following applies.

1. End(r) = End(L; C);

2. End(r) contains a constant operation;

3. End(r) contains lin;

4. End(r) contains End(L; Q).

Proof. If r has a noninjective endomorphism, then r also has a constant endo-morphism by Lemma 6.1 and the second item of the statement of the proposition applies. Therefore, we suppose in the following that all endomorphisms are injec-tive. If all endomorphisms preserve C, then the first item applies and we are done. Hence, suppose that there is an injective endomorphism e that violates the rooted triple relation, that is, there are c1,c2,c3 such that c1\c2c3 and not e(c1)\e(c2)e(c3). Under this assumption, we claim that there are d1,d2, d3 e L such that d1 \d2d3 and e(d1)e(d2)\e(d3). By injectivity of e, weeither havee(c1)e(c3)\e(c2) or e(c1)e(c2)\e(c3). In the first case, choose (d1,d2,d3) := (c1,c3,c2) and in the second case choose (d1,d2,d3) := (c1,c2,c3).

By convexity of — we have either d1 — d2 — d3, d1 — d3 — d2, d2 — d3 — d1, or d3 — d2 — d1. In each case, by the homogeneity of (L; C), there exists an a e Aut(L; C) such that ad1 — ad2 — ad3. After replacing d1,d2, d3 by ad1, ad2, ad3 and e by x ^ e(a-1 x), we still have d1\d2d3 and e(d1)e(d2)\e(d3). So we assume in the following that d1 — d2 — d3. There also exists P e Aut(L; C) such that P(e(d1)) — P(e(d2)) — P(e(d3)). By replacing e with the function x ^ Pe(x), we may henceforth assume that e(d1) — e(d2) — e(d3).

Recall our strategy described at the beginning of this section: we explained that one can additionally assume (by Corollary 5.7) that e is canonical as a function from (L; C, — ,d1 ,d2,d3) to (L; C, —). Define

A1 := {a : a — d1, ad1 \d2d3},

A2 := {a : d1 — a — d2, d1 \ad2d3 A a\d2d3},

A3 := {a : a — d1, a\d1d2d3}.

Note that A := A1 U A2 U A3 is (d1,d2)-universal: for every finite X C L and arbitrary x1 ,x2 e X there exists an a e Aut(L; C) such that

• ax1 = d1 and ax2 = d2,

• {ax : x e X \{x1,x2},xx1 \x2}CA1,

• {ax : x e X \{x1,x2},x1 \x2x}C A2, and

• {ax : x e X \{x1,x2},x\x1x2}C A3.

We observe that if Ai is dj-universal, for 1 < i < 3 and 1 < j < 3, and e is canonical on Ai as a function from (L; C, —,dj) to (L; C, —), then Lemma 6.26 implies that e behaves as iddj or rerdj on Ai unless {e} U Aut(L; C) generates lin. If {e}U Aut(L; C) generates lin then the third item of the statement of the proposition holds and we are done. If e behaves as rerdj on Ai then Corollary 6.19 implies that {e} U Aut(L; C) generates End(L; Q); in this case the fourth item of the statement holds. Therefore, we assume in the following that e behaves as iddj on Ai. Note that this assumption implies that e preserves C on {dj}U Ai.

Now, pick r e A2 arbitrarily. By the injectivity of e, the following cases are exhaustive.

• e(d1)e(d2)\e(r)e(d3). This is in contradiction with the assumption that e behaves as idd2 on A2. To see this, choose an element a e A2 and note that e(d2)\e(a)e(d3) by the canonicity of e on A2. This implies that e(d2)\e(A2).

• e(d1)e(d2)e(r)\e(d3). This is in contradiction with the assumption that e behaves as idd3 on A2. To see this, choose an element a e A2 and note that e(d2)e(a)\e(d3) by the canonicity of e on A2. This implies that e(d3)\e(A2).

• e(d\)e(d2)e(d3)|e(r). This is the remaining case that we will consider in the rest of the proof.

Lemma 6.28 applied to f := e, c\ := d\, c2 := d2, and A shows that e preserves C on {d\}U A\ U A3, unless {e}U Aut(L; C) generates lin or End(L; Q). The same argument can be applied when we exchange d2 with d\ and A2 with A\ so we assume that e preserves C on {d\} U A\ U A3 and on {d2} U A2 U A3.

If there were a u G A3 such that e (d\)e(u)|e(d3) or e(d\)|e(u)e(d3) then e would not behave as idd3 or iddl on A3 since e(d3)|e(A3) or e(d\)|e(A3) by the canonicity of e, respectively. Hence, we have e(d\)e(d2)e(d3)|e(A3). If there were a u G A\ such that e(d\)|e(u)e(d2) then by the canonicity of e we would have e(d\)|e(A\), and e would not behave as idd\ on A\. Thus e(u)e(d\)|e(d2) or e(u)|e(d\)e(d2). This implies that either e(u)e(d\)|e(d2) for all u G A\ or e(u)|e(d\)e(d2) for all u G A\.

In the former case, we have e(A\ U {d\})|e(d2) and Lemma 6.29 applied to c\ = d\ and c2 = d2 shows that {e} U Aut(L; C) generates nil, and therefore lin by Proposition 6.5.

In the latter case, we show that the conditions in Lemma 6.30 are satisfied for A, g := e, c\ := d\, and c2 := d2. Clearly, the second and the third conditions are satisfied. It remains to show that the first condition is satisfied. Arbitrarily choose a\ G A\ and a2 G A2. If e(d\)|e(a\)e(a2) thenforall u G A\ we have e (d\)|e(u)e(a2) by the canonicity of e. This implies that e(d\ )|e(A \) which leads to a contradiction since e behaves as idd\ on A\. Thus either e (d\)e(a\)|e(a2) or e(d\)e(a2)|e(a\) holds. Hence, Lemma 6.30 shows that {e} U Aut(L; C) generates lin. 4

Proposition 6.3\ leaves us with the task of further analyzing the reducts of (L; Q). We first need the following lemma.

Lemma 6.32. Let U С L be finite and arbitrarily choose c G L \ U. Then there are U\,...,Uk С U such that U\ U • • • U Uk = U and ({c }U |J j_\ Uj )U for all i < k.

Proof. By induction on the size of U. If {c}U, then k := \ and U\ := U satisfies the statement. Otherwise, U| > 2, and by Lemma 3.6, there are two nonempty subsets V,W of U such that V U W = U and V \W. We either have ({c } U V )| W or V |( W U {c}). In the first case, we inductively have U\,..., Uk_\ such that U\ U • • • U Uk_\ = V and ({c} U Jj=\\ Uj)U for all i < k — \. Set Uk := W. Then U\,..., Uk_\, Uk satisfy the requirements from the statement. The case when V |(W U{c })canbe shown analogously. 4

Proposition 6.33. Let Г be a reduct of (L; Q). Then one of the following cases applies.

\. All endomorphisms of Г preserve Q;

2. Г has a constant endomorphism;

3. Г is preserved by lin.

Proof. If all endomorphisms of Г preserve Q, then we are in case one of the statement of the proposition; in the following we therefore assume that Г has an endomorphism f that violates Q. We can then choose four elements d\ ,d2,d3,d4 G L such that d\d2 : d3d4and f (d\)f (d3) : f (d2)f(d4). By the homogeneity of (L; Q) there are y,d G Aut(L; Q) such that

• y (d1) — y (d2) — y (d3) — y (d4),

• y (d1)y (d2)\y (d3)y (d4),

• S(f (d1)) — S (f(d3)) — S (f (d2)) — 5 (f (d4)),and

• S(f (d1))S (f (d3))\S(f (d2))S(f (d4)).

(Here, the order — is still the order as defined in Section 3.5.) By replacing f by S o f o y-1, we can assume that d1 — d2 — d3 — d4, d1d2\d3d4, f (d1) — f (d3) — f (d2) — f (d4), and f (d1)f (d3)\f(d2)f(d4). Corollary 5.7 asserts the existence of a function

g G {a2/o;i : a\ G Aut(L; ,d4), a2 G Aut(L; C, -<)},

which is canonical as a function from (L; C, —,d1,..., d4) to (L; C, —). Note that there exists an a e Aut(L; C, —) such that g(di) = a(f(di)) for all i e{1,... ,4}, and, in particular, g (d1)g(d3)\g (d2)g (d4).

Let S = {x e L : d1d2\x A d1d2x\d3d4 A d2 — x}. Note that S is d1-universal and d2-universal. By Lemma 6.26, either g behaves on S as idd1 or rerd1, or {g} U Aut(L; C) generates lin. Similarly, either g behaves on S as idd2 or rerd2, or {g }U Aut(L; C) generates lin. In the latter cases, we are done, so assume that g behaves on S as idd1 or rerd1, and as idd2 or rerd2.

We then show that the conditions of Lemma 6.14 apply to M := (Aut(L; Q) U{g}}. Let U C L be finite and arbitrarily choose u e U .By Lemma 6.32 there exists a partition U1 U ••• U Uk of U \ {u} such that ({u} U |Jj-1 Uj)\Ui for all i e {1,..., k}. By d1-universality of S, there are subsets X1,...,Xk of S such that X, \( j+1 Xj U{d1}) for all i e{1,...,k}, and (Xi; C) is isomorphic to (U,; C). By the homogeneity of (L; Q) there is an a e Aut(L; Q) such that a(u) = d3, a(U,) = X,, and a preserves C on each U,.

First consider the case that g behaves on S as rerd1. We claim that g(d3)\g(S) or g(d4)\g(S). Since g(d1)g(d3)\g(d2)g(d4) and by the canonicity of g as a function from (L; C, —,d1,..., d4) to (L; C, —), either

g(d1)g(d3)g(S )\g (d2)g(d4),g (d1)g (d3)\g (S)g (d2)g (d4),

or g (d1)g(d3)g(d2)g(d4)\g (S).

In the first case, g(d4)\g(S) holds while in the second and third case g(d3)\g(S) holds. We first consider the case g(d3)\g(S). Let h := g o a. Clearly, h is in M. We will show that h behaves as cutu on U. Since g behaves as rerd1 on S and

X-\(U k= =i+1 Xj U{d1})foralli e{1,.. .,k}, itfollowsfromthedefinitionofrerd1 that

jj=1 g(Xj )\g(Xi+1) for all i e{1,...,k — 1}. It implies that jj.=1 h (Uj )\h (U-+0 for all i e {1,...,k — 1}. Since a preserves C on each U, and g preserves C on each Xi, h preserves C on each U,. Since |Jj=1 Uj\ U,+1 , Uj=1 h(Uj)\h(Ui+1) for all i e {1,...,k — 1} and h preserves C on each U,, it follows that h preserves C on |J;=1 Ui. Since g(d3)\g(S), we have that h(u)\h(U!=1 U,). Thus h behaves as cutu on U. By Lemma 6.14, r is preserved by lin. The case g(d4)\g(S) can be treated similarly (by choosing a e Aut(L; Q) such that a(u) = d4 instead of a(u) = d3).

Finally, we consider the case when g behaves on S as idd1 . By the canonicity of g as a function from (L; C, —,d1,...,d4)to (L; C, —) and since all the elements of S lie in the same orbit of (L; C, — ,d1,...,d4), either g(d1)\g(d2)g(S), g(S)g(d1 )\g(d2),

or g(d1)g(d2)\g(x) for all x e S. The first case is impossible because g behaves as idd1 on S. The second case is impossible, too: to see this, pick a,b,c e S such that d1a\b and d1ab\c. Since g behaves on S as idd1, we have g(d1)g(a)g(b)\g(c) and g(d1)g(a)\g(b), and g(d1)g(a)g(b)g(c)\g(d2) by assumption. In case that g behaves as idd2, we would have g (d2)g (a) \g (b) which is inconsistent with the above. In case that g behaves as rerd2, we would have g(d2)g (a) : g(b)g (c) which is inconsistent with the above, too.

In the third and last case, we first show that g does not behave as rerd2 on S. Let a,b,c e S such that d1ab \c A d1a \b. Since g behaves as idd1, we have g(d1)g(a)g(b)\g(c). By the assumption g(d1)g(d2)\g(x) for all x e S, we have g(d1)g(di)\g(c). It follows from gd)g(a)g(b)\g(c) that gd)g(a)g(b)\g(c). Therefore, g does not behave as rerd2 on S. Hence g behaves as idd2 on S. Thus, {(d1),g(d2)} U j+1 g(Xj))\g(X) for all i e {1,...,k}. Since g(*)g(d3)\ g(d2)g(d4), we therefore must have that ({g(d3)} U |Jk=i+1 g(Xj))\g(Xi) for all i e {1,...,k}. Since (L; C) embeds all finite leaf structures, there are subsets Z1 ,...,Zk of L and z e L such that z\ U;.=1 Zj, (Uj_1 Zj)\Zi, and (Zi; C) is isomorphic to (g(Xi); C) for all i e {1,...,k}. The situation is illustrated in Figure 4. By the homogeneity of (L; Q) there is a P e Aut(L; Q) such that P(g(d3)) = z, P preserves C on each g(Xi), and P(g(Xi)) = Zi for all i e {1,...,k}. Then P o g o a is in M and behaves as cutu on U. Again, Lemma 6.14 implies that r is preserved by lin. H

We can now prove Theorem 2.1 and Corollary 2.3 that have already been stated in Section 2.

Proof of ThEOREM 2.1. Let r be a reduct of (L; C). We apply Proposition 6.31 and consider the following cases.

• All endomorphisms of r preserve C. Then End(r) C End(L; C); we claim that the opposite inclusion holds as well. Since End(r) is closed, it suffices to show that for every e e End(L; C) and every finite S C L there exists an f e End(r) such that f(s) = e(s) for all s e S. Since e preserves C, e\S is a partial isomorphism from (S; C) to (e(S); C) by Lemma 3.7. By homogeneity, e\S can be extended to an automorphism f e Aut(L; C). Since Aut(L; C) C End(r), we have f e End(r).

• r has a constant endomorphism. Then there is nothing to show since the second item of the statement applies.

g(d3) X3 X2 X, A Z2 Z3 z

Figure 4. Illustration for the last proof step for Proposition 6.33.

• r is preserved by lin. Then Lemma 6.12 shows that r is homomorphically equivalent to a reduct of (L; =) and the third item of the statement applies.

• End(r) contains End(L; Q). This case implies that r is a reduct of (L; Q). If r has a constant endomorphism or r is preserved by lin, then we are done as in the above cases. Otherwise, by Proposition 6.33 all endomorphisms of r preserve Q. This means that End(r) C End(Q). Hence we have End(r) = End(Q), therefore the fourth item applies.

By Proposition 6.31, these four cases are exhaustive. H

One may observe at this point that the proof of Theorem 2.1 does not rely on any results concerning Jordan permutation groups. We finally show that every reduct of r is existentially interdefinable with (L; C), with (L; Q), or with (L; =).

Proof of CoROLLaRy 2.3. Let r be a reduct of (L; C). Let r' be the expansion of r by the relations defined by negations of atomic formulas over r, including the equality relation (for example, when R is a ternary relation of r, the structure r' contains the binary relation defined by —R(x, x,y)). We apply Theorem 2.1 to r'. Since for every atomic formula 0 over r' the signature of r' also contains a relation symbol for —0, all endomorphisms of r' must be embeddings, and therefore item 2 of Theorem 2.1 is impossible. If r' has the same endomorphisms as (L; C )or(L; Q), then by Proposition 2.2 the structure r' is existentially positively interdefinable with (L; C) or with (L; Q); hence, r is existentially interdefinable with one of those structures and we are done. Otherwise, r' is homomorphically equivalent with a reduct A of (L; =). Again, the homomorphism from r' to A must in fact be an embedding. Hence, r' is isomorphic to a substructure of A. Since A is preserved by all permutations, so is this substructure, and so is r'. It follows that r is preserved by all permutations, so r is a reduct of (L; =) by Proposition 4.2. In fact, r is even preserved by all injective maps from L to L and therefore by all self-embeddings of (L; =). Hence, Proposition 2.2 shows that r has an existential definition over (L; =). Conversely, (L; =) has an existential definition in every structure with domain L, so r is existentially interdefinable with (L; =). H

§7. Acknowledgments. The first and third author have received funding from the European Research Council under the European Community's Seventh Framework Programme (FP7/2007-2013 Grant Agreement no. 257039). The third author has received funding from the project P27600 of the Austrian Science Fund (FWF) and the Vietnam National Foundation for Science and Technology Development (NAFOSTED). The second author is partially supported by the Swedish Research Council (VR) under Grant 621-2012-3239.

REFERENCES

[1] S. A. AdELEkE and D. Macpherson, Classification of infinite primitive Jordan permutation groups. Proceedings of the London Mathematical Society, vol. 72 (1996), no. 1, pp. 63-123.

[2] S. A. AdELEkE and P. M. Neumann, Primitive permutation groups with primitive Jordan sets. Proceedings of the London Mathematical Society, vol. 53 (1994), no. 2, pp. 209-229.

[3 ]-, Relations Related to Betweenness: Their Structure and Automorphisms, Memoirs of the

American Mathematical Society, vol. 623, American Mathematical Society, Providence, RI, 1998.

[4] A. Aho, Y. SAgiv, T. SzyMANSki, and J. Ullman, Inferring a tree from lowest common ancestors with an application to the optimization of relational expressions. SIAM Journal on Computing, vol. 10 (1981), no. 3, pp. 405-421.

[5] M. Bhattacharjee, D. Maopherson, R. G. Môller, and P. M. Neumann, Notes on Infinite Permutation Groups, Springer Lecture Notes in Mathematics, Springer-Verlag, Berlin, Heidelberg, 1998.

[6] M. Bodirsky, Complexity classification in infinite-domain constraint satisfaction. Empowerment of Memory to Direct Research, Diderot University, 2012, available at arXiv:1201.0856 (In French).

[7 ]-, Ramsey classes: Examples and constructions, Surveys in Combinatorics (A. Czumaj,

A. Georgakopoulos,D. Kral, V. Lozin, andO. Pikhurko, editors), London Mathematical Society Lecture Note Series, vol. 424, Cambridge University Press, Cambridge, 2015, pp. 1-48.

[8] M. Bodirsky, H. Chen, and M. Pinsker, The reducts of equality up to primitive positive interdefinability, this Journal, vol. 75 (2010), no. 4, pp. 1249-1292.

[9] M. Bodirsky, M. Hils, and B. Martin, On the scope of the universal-algebraic approach to constraint satisfaction, Proceedings of the Annual Symposium on Logic in Computer Science (LICS) (J-P. Jouannaud, editor), IEEE Computer Society, Los Alamitos, CA, 2010, pp. 90-99.

[10] M. Bodirsky, P. Jonsson, and T. V Pham, The complexity of phylogeny constraint satisfaction, Proceedings of the 33rd International Symposium on Theoretical Aspects of Computer Science (STACS-2016), Orleans, France, Feb, 2016.

[11] M. Bodirsky and J. KAra, The complexity of equality constraint languages. Theory of Computing Systems, vol. 3 (2008), no. 2, pp. 136-158. A conference version appeared in the proceedings of Computer Science Russia (CSR'06).

[12 ]-, The complexity of temporal constraint satisfaction problems. Journal of the Association for

Computing Machinery, vol. 57 (2009), no. 2, pp. 1-41. An extended abstract appeared in the Proceedings of the Symposium on Theory of Computing (STOC'08).

[13] M. Bodirsky and J. K. Mueller, Rooted phylogeny problems. Logical Methods in Computer Science, vol. 7 (2011), no. 4, pp. 165-173. An extended abstract appeared in the proceedings of ICDT'10.

[14] M. Bodirsky and M. Pinsker, Reducts of Ramsey structures, Model Theoretic Methods in Finite Combinatorics (M. Grohe, and J. A. Makowsky, editors), AMS Contemporary Mathematics, vol. 558, American Mathematical Society, Providence, RI, 2011, pp. 489-519.

[15 ]-, Minimal functions on the random graph. Israel Journal ofMathematics, vol. 200 (2014),

no. 1,pp. 251-296.

[16 ]-, Schaefer's theorem for graphs. Journal of the Association for Computing Machinery,

vol. 62 (2015), no. 3, Article no. 19, pp. 52. A conference version appeared in the Proceedings of STOC 2011, pp. 655-664.

[17] M. Bodirsky, M. Pinsker, and A. PongrAcz, The 42 reducts of the random ordered graph. Journal of the London Mathematical Society, vol. 111 (2015), no. 3, pp. 591-632. Preprint available at arXiv:1309.2165.

[18] M. Bodirsky, M. Pinsker, and T. Tsankov, Decidability of definability, this Journal, vol. 78 (2013), no. 4, pp. 1036-1054. A conference version appeared in the Proceedings of LICS 2011.

[19] M. Bodirsky and M. Wrona, Equivalence constraint satisfaction problems, Proceedings of Computer Science Logic (P. Cegielski and A. Durand, editors), LIPICS, vol. 16, Schloss Dagstuhl -Leibniz-Zentrum fiir Informatik, Wadern, 2012, pp. 122-136.

[20] D. Bryant, Building trees, hunting for trees, and comparing trees, Ph.D. thesis, University of Canterbury, 1997.

[21] D. Bryant and M. Steel, Extension operations on sets of leaf-labelled trees. Advances in Applied Mathematics, vol. 16 (1995), pp. 425-453.

[22] P. J. Cameron, Transitivity of permutation groups on unordered sets. Mathematische Zeitschrift, vol. 148 (1976), pp. 127-139.

[23 ]-, Some treelike objects. Quarterly Journal of Mathematics, Oxford Second Series, vol. 38

(1987), no. 150, pp. 155-183.

[24 ]-, Oligomorphic Permutation Groups, Cambridge University Press, Cambridge, 1990.

[25] G. Cantor, Uber unendliche, lineare Punktmannigfaltigkeiten. Mathematische Annalen, vol. 23 (1884), pp. 453-488.

[26] W. Deuber, A generalization of Ramsey's theorem for regular trees. Journal of Combinatorial Theory, Series B, vol. 18 (1975), pp. 18-23.

[27] C. Frasnay, Quelques problèmes conbinatoires concernant les ordres totaux et les relations monomorphes. Annales de l'Institut Fourier (Grenoble), vol. 15 (1965), pp. 415-524.

[28] D. Haskell and D. Macpherson, Cell decompositions of C-minimal structures. Annals of Pure and Applied Logic, vol. 66 (1994), pp. 113-162.

[29] M. Henzinger, V King, and T. Warnow, Constructing a tree from homeomorphic subtrees, with applications to computational evolutionary biology. Proceedings of the 7th Symposium on Discrete Algorithms (SODA'96) (E. Tardos, Editor), Association for Computing Machinery (ACM), and Society for Industrial and Applied Mathematics (SIAM), Philadelphia, PA, 1996, pp. 333-340.

[30] B. Herwig, H. D. Macpherson, G. Martin, A. Nurtazin, and J. K. Truss, On H0 -categorical weakly o-minimal structures. Annals of Pure and Applied Logic, vol. 101 (2000), no. 1, pp. 65-93.

[31] W Hodges, A Shorter Model Theory, Cambridge University Press, Cambridge, 1997.

[32] M. Junker and M. Ziegler, The 116 reducts of (Q,<, a), this Journal, vol. 74 (2008), no. 3, pp. 861-884.

[33] A. Kechris, V. Pestov, and S. Todorcevic, Fraisse limits, Ramsey theory, and topological dynamics of automorphism groups. Geometric and Functional Analysis, vol. 15 (2005),no. 1,pp. 106-189.

[34] D. Macpherson, A survey of Jordan groups, Automorphisms of First-order Structures (R. Kaye and D. Macpherson, editors), Oxford University Press, New York, NY, 1994, pp. 73-110.

[35 ]-, A survey of Homogeneous Structures. Discrete Mathematics, vol. 311 (2011), no. 15,

pp. 1599-1634.

[36] D. Macpherson and C. Steinhorn, On variants of o-minimality. Annals of Pure and Applied Logic, vol. 79 (1996), no. 2, pp. 165-209.

[37] K. R. Milliken, A Ramsey theorem for trees. Journal of Combinatorial Theory, Series A, vol. 26 (1979), no. 3, pp. 215-237.

[38] J. NeSetRil, Ramsey classes and homogeneous structures. Combinatorics, Probability & Computing, vol. 14 (2005), no. 1-2, pp. 171-189.

[39] M. P. Ng, M. Steel, and N. C. Wormald, The difficulty of constructing a leaf-labelled tree including or avoiding given subtrees. Discrete Applied Mathematics, vol. 98 (2000), pp. 227-235.

40] P. P. Pach, M. Pinsker, G. PluhAr, A. PongrAcz, and C. SzabO , Reducts of the random partial order. Advances in Mathematics, vol. 267 (2014), pp. 94-120.

[41] F. P. Ramsey, On a problem of formal logic. Proceedings of the London Mathematical Society (2), vol. 30 (1930), no. 1, pp. 264-286.

[42] M. Steel, The complexity of reconstructing trees from qualitative charaters and subtrees. Journal of Classification, vol. 9 (1992), pp. 91-116.

[43] S. Thomas, Reducts of the random graph, this Journal, vol. 56 (1991), no. 1, pp. 176-181.

INSTITUT FÜR ALGEBRA TU DRESDEN

01062 DRESDEN, GERMANY E-mail: manuel.bodirsky@tu-dresden.de

DEPARTMENT OF COMPUTER AND SYSTEM SCIENCE LINKOPINGS UNIVERSITET

SE-581 83 LINKOPING, SWEDEN E-mail: peter.jonsson@liu.se

INSTITUT FÜR COMPUTERSPRACHEN THEORY AND LOGIC GROUP TECHNISCHE UNIVERSnÄT WIEN FAVORITENSTRASSE 9/E1852 A-1040 WIEN, AUSTRIA E-mail: pvtrung@logic.at