Betweenness of partial orders

We construct a monadic second-order sentence that characterizes the ternary relations that are the betweenness relations of finite or infinite partial orders. We prove that no first-order sentence can do that. We characterize the partial orders that can be reconstructed from their betweenness relations. We propose a polynomial time algorithm that tests if a finite relation is the be-tweenness of a partial order.


Introduction
Betweenness is a standard notion in the study of structures such as trees, partial orders and graphs. It is defined as the ternary relation B(x, y, z) expressing that an element y is between x and z, in a sense that depends on the considered structure. This relation is easy to understand and axiomatize in firstorder (FO) logic for linear orders. In particular, a linear order can be uniquely described, up to reversal, from its betweenness relation. However, the notion of partial betweenness 1 raises some difficult algorithmic and logical problems ( [8], Chapter 9).
Betweenness in partial orders is axiomatized in [9] by an infinite set of FO sentences that cannot be replaced by a finite one, as we will prove. In this article, we axiomatize betweenness in partial orders by a single monadic secondorder (MSO) sentence. We characterize the partial orders that are uniquely reconstructible, up to reversal, from their betweenness relations. We show that an MSO formula can describe some partial order P such that B P = B Q from

Definitions and known results
All partial orders, graphs and relational structures are finite or countably infinite.
(a) Betweenness in linear orders Let L = (V, ≤) be a linear order. Its betweenness relation B L is the ternary relation on V defined by : B L (x, y, z) :⇐⇒ x < y < z or z < y < x.
The following properties hold for B = B L and all x, y, z, u ∈ V : B1 : B(x, y, z) ⇒ = (x, y, z). We get an axiomatization by finitely many universal first-order sentences: if a ternary structure S = (V, B) satisfies these properties, then B = B L for a linear order L = (V, ≤). We will say that the class of betweenness relations of linear orders is first-order (FO ) definable. The order L = (V, ≤) and its reversal L rev := (V, ≥) are the only ones whose betweenness relation is B L , see [4,5,8]. We will say that ≤ is uniquely defined, up to reversal (written u.t.r.), or reconstructible from its betweenness relation.

(b) Betweenness in partial orders
The betweenness relation B P of a partial order P = (V, ≤) -we will also say a poset 2 -is the ternary relation on V defined, as in (a), by : We denote by Bet(P ) the ternary structure (V, B P ). For all x, y, z, u, v ∈ V , the relation B = B P satisfies Properties B1 to B5 together with: and an infinite set O of properties expressed by universal first-order sentences. The notation is borrowed to the article by Lihova [9] who proved, conversely, that if a ternary structure S = (V, B) satisfies these properties, then B = B P for a poset P = (V, ≤) and, of course for its reversal P rev := (V, ≥). We will prove that no finite set of first-order sentences can characterize betweenness in posets. Our proof will use the following examples.
(c) A B-cycle is a ternary structure (V, B) such that V = {a 1 , a 2 , ..., a n , b 1 , b 2 , ..., b n }, n ≥ 2, and B consists of the triples (a 1 , b 1 , a 2 ), (a 2 , b 2 , a 3 ), ..., (a n−1 , b n−1 , a n ), (a n , b n , a 1 ) and their inverse ones, (a 2 , b 1 , a 1 ), (a 3 , b 2 , a 2 ), ... so that B2 is satisfied. This structure satisfies Properties B1-B5. If n is even, then B = B P where P = (V, ≤) is the poset such that : ..a n−1 < b n−1 < a n > b n > a 1 , and no other inequality holds except by transitivity (e.g. a 1 < a 2 ). If n is odd, no such partial order does exist (cf. Lemma 14). Consider for example the case n = 3. A partial order P such that a 1 < b 1 and B P = B must verify b 1 < a 2 > b 2 > a 3 < b 3 < a 1 but then, we would have (b 3 , a 1 , b 1 ) in B, which is not assumed. The set O excludes these odd B-cycles.
We will prove that the class of betweenness relations of partial orders is monadic second-order (MSO) definable without using the set O. We will also identify the partial orders that can be reconstructed u.t.r. from their betweenness relations, independently of any logical description. We refer to [3,8] for first-order and monadic second-order logic. We say that S is connected if Gf (S) is. If Gf (S) is not connected, then S is the union of the pairwise disjoint induced structures S[X] := (X, B ∩ X 3 ), called the connected components of S, where the sets X are the vertex sets of the connected components of Gf (S).
(b) If P = (V, ≤) is a partial order, its comparability graph Comp(P ) having vertex set V and an edge u−v if and only if u and v are different and comparable, i.e., u < v or v < u. It is the Gaifman graph of the binary structure P .
We say that P is connected if Comp(P ) is. If Comp(P ) is not connected, then P is the union of the pairwise disjoint posets P [X] := (X, ≤ ∩X 2 ) where the sets X are the vertex sets of the connected components of Comp(P ).
We have Gf (Bet(P )) ⊆ Comp(P ). The inclusion may be proper. If Gf (Bet(P )) is connected, then so is Comp(P ), but not necessarly conversely, because Gf (Bet(P )) has no edge if P has no chain x < y < z.
Example 3 : Here is an example where Gf (Bet(P )) ⊂ Comp(P ). Let P = (V, ≤) where V = {a, b, c, d, e, f } and ≤ is generated by a < b < c < d, e < c, e < f, b < f, reflexivity and transitivity. The edge e − f of Comp(P ) is not in Gf (Bet(P )) because e and f do not belong to any chain of size 3. If we remove the clause e < f , the resulting partial order has the same betweenness relation as P and Gf (Bet(P )) = Comp(P ). We will generalize this observation in Proposition 6.
(a) A chain (resp. an antichain) is a subset X of V that is linearly ordered (resp. where any two elements are incomparable.) Its size is |X| ∈ N ∪ {ω}. Maximality of chains and antichains is understood for set inclusion.
We use A P (x, y, z) to abreviate B P (x, y, z) ∨ B P (x, z, y) ∨ B P (y, x, z), meaning that x, y and z belong to a chain of size at least 3.
(b) We say that P is B-minimal if Gf (Bet(P )) = Comp(P ), equivalently, if every two comparable elements belong to a chain of size at least 3, or, as we will see, that it is the unique minimal poset P such that Gf (Bet(P )) = Gf (Bet(Q)) for some poset Q, where posets are related by inclusion of the defining binary relations.
(c) We define M in(P ) and M ax(P ) as the sets of minimal and maximal elements respectively of a poset P . They are its extremal elements. An element is isolated if it is so in Comp(P ), equivalently, if it belongs to M in(P )∩M ax(P ).
(d) In a ternary structure S = (V, B) that satisfies Properties B1,B2 and B3 (in order to avoid uninteresting cases), we say that an element x is extremal if B(y, x, z) does not hold for any y, z. The extremal elements of a structure Bet(P ) are the extremal elements of P .
Example 5: d, e, f } and ≤ is generated by a < b < c, d < e < f, d < c, reflexivity and transitivity. Then Comp(P ) is connected but Gf (Bet(P )) is not. The only orderings on V that yield Comp(P ) as comparability graph are P and P rev . The graph Gf (Bet(P )) has two connected components with vertex sets {a, b, c} and {d, e, f }. From it, one obtains 4 orderings on V that yield the betweenness structure Bet(P ). We will develop this observation.
Proposition 6 : Let P = (V, ≤) be a poset and ≤ ′ be defined by : x ≤ ′ y if and only if x = y or x < y and, if x ∈ M in(P ) and y ∈ M ax(P ), then x < z < y for some z.
The poset P := (V, ≤ ′ ) ⊆ P is B-minimal and Bet( P ) = Bet(P ). It is the unique minimal poset Q such that Bet(Q) = Bet(P ) and Q ⊆ P .
Proof : We have ≤ ′ ⊆ ≤ , hence, P ⊆ P . If x < ′ y < ′ z, then x < y < z, hence x < z, and if x ∈ M in(P ) and z ∈ M ax(P ), we have y between them, hence x < ′ z. Reflexivity and antisymmetry are clear and so we have a partial order.
We have Bet( P ) ⊆ Bet(P ). However, if x < y < z, we have x < ′ y < ′ z by the definitions. Hence, P and P have the same chains of size at least 3. In particular, Bet( P ) = Bet(P ).
If P is not B-minimal, there are x, y such that x < ′ y and x and y do not belong to any chain of size 3 in P , whence, in P . As x < y this implies that x ∈ M in(P ) and y ∈ M ax(P ), but we have x < z < y for some z, hence we have x < ′ z < ′ y, which contradicts the assumption that x and y do not belong to a chain of size 3 in P .
Assume that Q = (V, ≤ Q ) ⊆ P and Bet(Q) = Bet(P ). If x < ′ y, then, we have x < Q y: to prove this, we observe that the defintions yield x < y < z or z < x < y or x < z < y of some z. In the first case, (x, y, z) ∈ B P = B Q , hence x < Q y < Q z because Q ⊆ P , and so x < Q y. The proofs are similar for the two other cases. Hence P ⊆ Q. Hence, P is the unique minimal poset Q such that Bet(Q) = Bet(P ) and Q ⊆ P .
A partial order P is B-reconstructible (that is reconstructible from its betweenness relation) if P and P rev are the only ones whose betweenness structure is Bet(P ).
Theorem 7 : A partial order is B-reconstructible if and only if it is Bminimal and, either it is connected or it has exactly two connected components that are one without extremal elements and an isolated element. A finite Breconstructible partial order is B-minimal and connected.
Proof : We first recall the case of a linear order L = (V, ≤) from [5] that is connected and B-minimal. If a < b in V , then ≤ is the unique linear order 4 such that a < b and whose betweenness relation is B L .
"If" Let P = (V, ≤) be connected and B-minimal, and let B be its betweenness relation. Let C be a maximal chain (it has size at least 3) and a, b in C such that a < b. The linear order (C, ≤) is uniquely determined by B ∩ C 3 and the pair (a, b).
Consider another maximal chain D. If |C ∩ D| ≥ 2, we say that C and D merge. Then, the order on D is uniquely determined from that on C and the relation B ∩ (C ∪ D) 3 .
If  < c and ¬B(a, c, d).
Then, the ordering on D between c and d determines in a unique way the ordering on D. Hence, if there is a sequence of maximal chains C = C 1 , C 2 , ..., C n such that C i and C i+1 merge or join for each i, then the ordering on all of them is determined from the ordering on C.
Finally, we prove that any two comparable elements of V are related in a unique way, provided the ordering of a maximal chain C is fixed. Let a ∈ C and a = b 0 − b 1 − b 2 − ... − b n be a path in the comparability graph. There is a sequence of maximal chains C = C 1 , C 2 , ..., C n such that, for each i, C i and C i+1 merge or join, and b i and b i+1 are in C i+1 . The proof is by induction on n. We only consider the first step.
Let C be a maximal chain containing a, and b = b 1 / ∈ C be such that a < b. There is a maximal chain D that contains a and b. If C and D merge, we are done. Otherwise, C ∩ D = {a}. If there is c ∈ C such that c < a, then we can replace D by a maximal chain D ′ containing c, a and b, and it merges with C; otherwise, a = M in(C) and by the maximality of D, we have a = M in(D), hence C and D join. The proof is similar if b < a. We let C 1 be D or D ′ in the second case.
It follows that the partial order on V is uniquely determined from B and the linear order on C, because if x, y are adjacent in Comp(P ), then there is a sequence C = C 1 , C 2 , ..., C n such that C i and C i+1 merge or join, and x, y ∈ C n . The relation x < y or y < x, is thus determined in a unique way.
As there are on C exactly two linear orders compatible with B, there are exactly two partial orders on V , P and P rev whose betweenness relation is the given B P .
If P is B-minimal and has one connected component X without extremal elements and one isolated element u, then, the set X can be ordered in exactly two ways, and u must be isolated in any poset Q such that Bet(Q) = Bet(P ), otherwise, any ordering u < v or v < u for v ∈ X would add triples to B P . "Only if" Let P = (V, ≤) be not B-minimal. There are x, y ∈ V that do not belong to any chain of size 3, and such that x < y. Hence, x ∈ M in(P ) and y ∈ M ax(P ). If we remove from ≤ the pair (x, y), as in the definition of P , we obtain a poset with same betweenness relation as P and that is not the reversal of P .
If P is B-minimal and has two connected components that are not singletons, then each of them can be ordered in two ways while giving the same betweenness relation as P . Hence, V can be ordered in at least 4 ways, hence, P is not Breconstructible.
Let P be B-minimal. If it has two isolated elements u and v we can order them u < v, or v < u or leave them incomparable, without modifying Bet(P ). If P has one isolated element u and a component having an extremal element w, then we can order V so that w is maximal and then, we define u < w or leave u isolated. Hence, P is not B-reconstructible.
As a connected component without extremal elements must be infinite, the last assertion holds.
Next we prove definability results in MSO logic. We let B P O be the class of structures Bet(P ) for posets P .
Theorem 8: The class B P O is MSO definable. There is a pair of monadic second-order formulas that defines, for each structure S in B P O , some partial order P such that S = Bet(P ).
Definition 9 : Cut of a partial order.
A cut of a poset P = (V, ≤) is a partition (L, U ) of V such that : (i) L is downwards closed and U is upwards closed, (ii) Every maximal chain meets L and U .
Note that (U, L) is a cut of the reversal (V, ≥) of P . These cuts are Dedekind cuts in linear orders.
Lemma 10 : Every poset P without isolated element has a cut. Proof: We let A be a maximal antichain of P . There exists one that is constructible from an enumeration 5 v 1 , v 2 , ... of V. We define U := {x ∈ V − M in(P ) | y ≤ x for some y ∈ A} and L := V − U .
We prove that (L, U ) is a cut. From the definition, U is upwards closed, and so, L is downwards closed. Let C be a maximal chain: it contains a unique element a ∈ A. If a = M in(C), then a ∈ M in(P ) ⊆ L. As a is not isolated in P , a = M ax(C), hence, we have a < x for some x ∈ C, and so x ∈ U . Otherwise, we have y < a for some y ∈ C, hence a / ∈ M in(P ) and so a ∈ U and y / ∈ U . Hence, (L, U ) is a cut.
Proof of Theorem 8 : It follows from Proposition 6 that B P O is the class of structures Bet(P ) for B-minimal posets P .
First part : We first characterize the structures Bet(P ) for B-minimal posets P without isolated elements.
Let P = (V, ≤) be B-minimal without isolated elements, and let (L, U ) be a cut of it.
We claim that ≤ can be defined from L, U and its betweenness relation B P by FO formulas 6 .
Claim 1 : For x, y ∈ V, we have x < y if and only if one of following conditions holds, for B := B P : (i) x ∈ L, y ∈ U , and B(x, y, z) ∨ B(x, z, y) ∨ B(z, x, y) holds for some z, (ii) x, y ∈ L and B(x, y, w) holds for some w ∈ U , (iii) x, y ∈ U and B(w, x, y) holds for some w ∈ L. Proof : Let x, y be such that x < y. As P is B-minimal, x and y belong to a maximal chain C of size at least 3. This chain contains some z such that x < y < z, x < z < y or z < x < y and meets L and U .
If x ∈ L and y ∈ U , then each of these three cases can hold and yields respectively B(x, y, z), B(x, z, y) or B(z, x, y).If x, y ∈ L , then, since C meets U , we have some w ∈ U such that x < y < w and B(x, y, w) holds. If x, y ∈ U then, since C meets L, we have some w ∈ L such that w < x < y and B(w, x, y) holds. Hence, we have one of the exclusive cases (i), (ii) or (iii).
Let Proof: "If" Let P = (V, ≤) be B-minimal, B = B P be its betweenness relation, and assume that Bet(P ) has no isolated elements. The poset P has none either and has a cut (L, U ). Properties (a) and (b) hold by the definitions. By Claim 1, ϕ(B, L, x, y) defines the strict partial order < and so, (c) and (d) hold. So we have S |= θ(B).
Conversely, assume that B and L satisfy ψ(B, L). Properties (c) and (d) hold hence B = B P for the strict and B-minimal partial order P defined by ϕ(B, L, x, y). By Property (a), S has no isolated elements.
Hence, to define a B-minimal partial order P such that Bet(P ) = S where S satisfies θ(B), we use the following MSO formulas: ψ(B, L) intended to select in S = (V, B) an appropriate set L. ϕ(B, L, x, y) that defines the partial order in terms of L assumed to satisfy ψ(B, L).
If P is a partial order such that Bet(P ) has no isolated elements, then, Bet(P ) |= θ(B) because, by Proposition 6, Bet(P ) = Bet( P ) where P is Bminimal. But the formula ϕ(B, L, x, y) defines in the structure Bet(P ) partial orders Q such that Bet(Q) = Bet(P ).
Second part : Let be given a structure S = (V, B). It is the union of its connected components S[X] where the sets X are the vertex sets of the connected components of Gf (S). There is nothing to verify for the components which are isolated elements. The others can identified by an MSO formula γ(X), cf. [8]. Then, S ∈ B P O if and only if each of these components satisfies θ(B). For this purpose, we translate θ(B) into a formula θ ′ such that, for every subset X of V , This is a classical construction called relativization of quantifications to a set X, see e.g. [8]. Hence, a structure S belongs to B P O if and only if: Similarily, ψ(B, L) can be transformed into ψ ′ such that, if X, L ⊆ V , then: It follows that, from a set L ⊆ V such that: S |= ∀X.(γ(X) =⇒ ψ ′ (B, L ∩ X, X)), one can define partial orders for the components S[X]. We transform ϕ(B, L, x, y) into ϕ ′ (B, L, X, x, y) that defines a partial order on X, by using L ∩ X . Then, from L as above, one obtains a strict partial order on V defined by : x < y :⇐⇒ S |= ∃X.(x, y ∈ X ∧ γ(X) ∧ ϕ ′ (B, L, X, x, y)) whose betweenness relation is B. This completes the proof of the theorem.
Remark 11: A B-minimal poset P = (V, ≤) has several cuts (L, U ). However, from the structure Bet(P ), they yield only two orders whose betweenness relation is Bet(P ). If Gf (Bet(P )) has n connected components that are not singleton, the formulas ψ ′ and ϕ ′ define the 2 n partial orders whose betweenness is Bet(P ).
Remark 12 : A partial order is reconstructible, u.t.r., from its comparability graph if and only if this graph is prime. This notion is relative to the theory of modular decomposition. Furthermore, there is an MSO formula that defines the two transitive orientations of a prime comparability graph G, equivalently, the two partial orders P such that G = Comp(P ). More generally, the class of comparability graphs is MSO definable, and primality is MSO definable. These results are proved in Section 5 of [3]. They concern finite and countably infinite partial orders.

Finite partial orders
We give an algorithm that decides in polynomial time whether a finite ternary structure S = (V, B) is Bet(P ) for some poset P , and produces one if possible.
Lemma 13 : Let P = (V, ≤) is a finite and B-minimal partial order. For x, y ∈ V , we have: x < y if and only if either B P (x, y, z) holds for some z ∈ M ax(P ), or y ∈ M ax(P ) and B P (w, x, y) ∨ B P (x, w, y) holds for some w ∈ V .
Proof : The "if" direction is clear, since M ax(P ) is not empty. For the converse, assume that x < y. The elements x and y belong to a chain of size at least 3 with maximal element z ∈ M ax(P ). If y = z we have B P (x, y, z), otherwise B P (w, x, y) ∨ B P (x, w, y) for some w ∈ V (the last case is for the case where x is minimal).
In a ternary structure S = (V, B) that satisfies Properties B1, B2 and B3, we say that an element x ∈ V is extremal if B(y, x, z) does not hold for any y, z. We let Ext(S) be the graph whose vertex set is the set of extremal elements denoted by V Ext , and u − v is an edge if and only if B(u, w, v) holds for some w (necessarly not in V Ext ). It follows that Ext(S) is a subgraph of Gf (S).
Lemma 14 : Let P = (V, ≤) be a finite and B-minimal partial order without isolated elements. The graph Ext(Bet(P )) is bipartite, with bipartition (M ax(P ), M in(P )). It is connected if P is.
Proof: Each element of M ax(P ) ∪ M in(P ) is extremal in Bet(P ). If w / ∈ M ax(P ) ∪ M in(P ) then u < w < v for some u, v and so B P (u, w, v) holds and w is not extremal in Bet(P ).
The set M ax(P )∩M in(P ) is empty. If u−v is an edge of Ext(Bet(P )), then B P (u, w, v) holds hence u < w < v or v < w < u and u and v cannot be both in M ax(P ) or in M in(P ). Hence, Ext(Bet(P )) is bipartite with bipartition (M ax(P ), M in(P )).
Assume now that P is connected. Consider a sequence of maximal chains C 1 , C 2 , ..., C n such that, for each i, C i and C i+1 merge or join, as in the proof of Theorem 7. We have in Ext(Bet(P )) a path This lemma proves in particular that the odd B-cycles (cf. Definition 1(c)) are not Bet(P ) for any partial order, because their extremal elements are a 1 , ..., a n forming an odd cycle.
Theorem 15 : There exists a polynomial time algorithm that decides whether a finite ternary structure S = (V, B) is the betweenness structure of a partial order P , and produce one if possible.
These triples and the opposite ones (to satisfy Property B2) form a set B w ⊆ [2m] 3 The structure T (w) := ([2m], B w ) is thus a B-cycle as in Definition 1(c). Its vertives a 1 , ..., a m are the odd positions, those of letter a, its vertives b 1 , ..., b m are the even positions, those of letter b.
It follows from Definition 1(c) and Lemma 14 that T (w) ∈ B P O if and only if m is even.
Assume now that B P O is axiomatized by a first-order sentence θ, possibly not universal. This sentence can be translated into an FO sentence ϕ such that, for every word w over {a, b}, we have: Then the language L := {(ab) 2n | n ≥ 1} would be first-order definable, which is not the case by a classical result due to McNaughton, Papert and Schützenberger, see [10].
We get a contradiction hence, the class B P O is not axiomatizable by a single first-order sentence.