Ordered unavoidable sub-structures in matchings and random matchings

,


Introduction 1.Background
A graph G is said to be ordered if its vertex set is linearly ordered.Let G and H be two ordered graphs with vertex sets V (G) = {v 1 , . . ., v m } and V (H) = {w 1 , . . ., w m }, and the respective linear orders v 1 < • • • < v m and w 1 < • • • < w m , for some integer m ⩾ 1.We say that G and H are order-isomorphic if for all 1 ⩽ i < j ⩽ m, v i v j ∈ E(G) if and only if w i w j ∈ E(H).Note that every pair of order-isomorphic graphs is isomorphic, but not vice-versa.Also, if G and H are distinct graphs on the same linearly ordered vertex set V , then G and H are never order-isomorphic, and so all 2 ( |V | 2 ) labeled graphs on V are pairwise non-order-isomorphic.It shows that the notion of order-isomorphism makes sense only for pairs of graphs on distinct vertex sets.
One context in which order-isomorphism makes quite a difference is that of subgraph containment.If G is an ordered graph, then any subgraph G ′ of G can be also treated as an ordered graph with the ordering of V (G ′ ) inherited from the ordering of V (G).Given two ordered graphs, (a "large" one) G and (a "small" one) H, we say that a subgraph G ′ ⊂ G is an ordered copy of H in G if G ′ and H are order-isomorphic.We will sometimes denote this fact by writing G ′ ⪯ G.
All kinds of questions concerning subgraphs in unordered graphs can be posed for ordered graphs as well (see, e.g., [32] and [5]).For example, in [3] and [9] the authors studied Turán and Ramsey type problems for ordered graphs.In particular, they showed independently that there exists an ordered matching on n vertices for which the (ordered) Ramsey number is super-polynomial in n, a sharp contrast with the linearity of the Ramsey number for ordinary (i.e., unordered) matchings.This shows that it makes sense to study even such seemingly simple structures as ordered matchings.In fact, Jelínek [22] counted the number of matchings avoiding (i.e., not containing) a given small ordered matching.

Topics and organization
In this paper we focus exclusively on ordered matchings, that is, ordered graphs which consist of vertex-disjoint edges (and have no isolated vertices).For example, in Figure 1, we depict two ordered matchings, M = {{1, 3}, {2, 4}, {5, 6}} and N = {{1, 5}, {2, 3}, {4, 6}} on vertex set {1, 2, 3, 4, 5, 6} with the natural linear ordering.Unlike in [22], we study what sub-structures are unavoidable in ordered matchings.A frequent theme in both fields, the theory of ordered graphs as well as enumerative combinatorics, are unavoidable sub-structures, that is, patterns that appear in every member of a prescribed family of structures.A flagship example providing everlasting inspiration is the famous theorem of Erdős and Szekeres [14] on monotone subsequences (see [4,6,7,13,15,26,31] for some recent extensions and generalizations).In its diagonal form it states that any sequence x 1 , x 2 , . . ., x n of distinct real numbers contains an increasing or decreasing subsequence of length at least √ n.And, indeed, our first goal is to prove its analog for ordered matchings.The reason why the original Erdős-Szekeres Theorem lists only two types of subsequences is, obviously, that for any two elements x i and x j with i < j there are just two possible relations: x i < x j or x i > x j .For matchings, however, for every two edges {x, y} and {u, w} with x < y, u < w, and x < u, there are three possibilities: y < u , w < y, or u < y < w (see Figure 2).In other words, every two edges form either an alignment, a nesting, or a crossing (the first term introduced by Kasraoui and Zeng in [24], the last two terms coined in by Stanley [29]).These three possibilities give rise, respectively, to three "unavoidable" ordered sub-matchings (lines, stacks, and waves) which play an analogous role to the monotone subsequences in the classical Erdős-Szekeres Theorem.(In [29], stacks and waves consisting of k edges were called, respectively, k-nestings and k-crossings.)Informally, lines, stacks, and waves are defined by demanding that every pair of edges in a sub-matching forms, respectively, an alignment, a nesting, or a crossing (see Figure 5).In Subsection 2.1 we show, in particular, that every ordered matching of size n contains one of these structures of size at least n 1/3 .This special case was also proved by Huynh, Joos and Wollan (see Lemma 25 in [21]).In the remainder of Section 2, we first extend this result to 3-uniform ordered matchings and then study the size of the largest lines, stacks, and waves in random matchings.
Our second goal is to estimate the size of the largest (ordered) twins in ordered matchings.The problem of twins has been widely studied for other combinatorial structures, including words, permutations, and graphs (see, e.g., [1,25]).For an integer r ⩾ 2, we say that r edge-disjoint (ordered) subgraphs G 1 , G 2 , . . ., G r of an (ordered) graph G form (ordered) twins in G if they are pairwise (order-)isomorphic.The size of the (ordered) twins is defined as For ordinary matchings, the notion of rtwins becomes trivial, as every matching of size n contains twins of size ⌊n/r⌋ -just split the matching into r as equal as possible parts.But for ordered matchings the problem becomes interesting.The above mentioned analog of the Erdős-Szekeres Theorem immediately yields (again by splitting into r equal parts) ordered r-twins of length ⌊n 1/3 /r⌋.We provide much better estimates on the size of largest r-twins in ordered matchings (Subsection 3.1) and random matchings (Subsection 3.2) which, not so surprisingly, are of the same order of magnitude as those for r-twins in permutations (see [8,10]).

Random matchings
As indicated above, we examine both questions, of unavoidable sub-matchings and of twins, also for random matchings.A random (ordered) matching RM n is selected uniformly at random from all α n := (2n)! n!2 n ordered matchings on vertex set [2n].Among other results, we show that with probability tending to 1, as n → ∞, or asymptotically almost surely (a.a.s.), there are in RM n lines, stacks, and waves of size, roughly, √ n, as well as (ordered) twins of size Θ(n 2/3 ).There are two other ways of generating RM n which we are going to utilize in the proofs.Besides the above defined uniform scheme, we define the online scheme as follows.
For an arbitrary ordering of the vertices u 1 , . . ., u 2n one selects uniformly at random a match, say u j 1 , for u 1 (in 2n − 1 ways), then, after crossing out u 1 and u j 1 from the list, one selects uniformly at random a match for the first uncrossed vertex (in 2n − 3 ways), and so on.Note that the total number of ways to select a matching this way is (2n − 1)(2n − 3) • . . .• 3 • 1 = (2n − 1)!! which equals α n .A third equivalent way to generate RM n is particularly convenient when one intends to apply concentration inequalities available for random permutations.The permutation based scheme boils down to just generating a random permutation Π := Π n of [2n] and "chopping it off" into a matching {Π(1)Π(2), Π(3)Π(4), . . ., Π(2n − 1)Π(2n)}.Note that this way each matching corresponds, as it should, to exactly n!2 n permutations.We will stick mostly to the uniform scheme, applying the other two only occasionally.

Gauss codes
A convenient representation of ordered matchings can be obtained in terms of double occurrence words over an n-letter alphabet, in which every letter occurs exactly twice as the label of the ends of the corresponding edge in the matching.For instance, our two exemplary matchings can be written as M = ABABCC and N = ABBCAC (see Figure 3).In fact, this is a special case of an elementary combinatorial bijection between ordered partitions of a set and permutations with repetitions.A minor nuisance here is that ordered matchings correspond to unordered partitions, so every permutation of the letters yields the same matching.Nevertheless, we will sometimes use this representation to better illustrate some notions and ideas.
Interestingly, this type of words was introduced and studied already by Gauss [18] as a way of encoding closed self-intersecting curves on the plane (with points of multiplicity at most two).Indeed, denoting the self-crossing points by letters and traversing the curve in a fixed direction gives a (cyclic) word in which every letter occurs exactly twice (by the multiplicity assumption) (see Figure 4).A general problem studied by Gauss was to characterize those words that correspond to such curves.He found himself a necessary condition, but a full solution (in terms of some quite involved constraints on an auxiliary graph of crossing pairs) was obtained much later (see [28] for a brief history and further references).
It is, perhaps, also worthwhile to mention that ordered matchings constitute a special case of structures, known as Puttenham diagrams, that found an early application in the theory of poetry (see [27,33]).A basic idea is simple: a rhyme scheme of a poem can be encoded by a word in which same letters correspond to rhyming verses.Of particular interest here are planar rhyme schemes which are nothing else but ordered matchings without crossings, or more generally, noncrossing partitions (see [30]).

Unavoidable sub-matchings
Let us start with formal definitions.Let M be an ordered matching on the vertex set [2n], with edges denoted as e i = {a i , b i } so that a i < b i , for all i = 1, 2, . . ., n, and a 1 < • • • < a n .We say that an edge e i is to the left of e j and write e i < e j if a i < a j .That is, in ordering the edges of a matching we ignore the positions of the right endpoints.
We now define the three basic types of ordered matchings: • Wave: Assigning letter A i to edge {a i , b i }, their corresponding double occurrence words look as follows: • Line: Each of these three types of ordered matchings can be equivalently characterized as follows.
Let us consider all possible ordered matchings with just two edges.In the double occurrence word notation these are AABB (an alignment), ABBA (a nesting), and ABAB (a crossing).Now a line, a stack, and a wave is an ordered matching in which every pair of edges forms, respectively, an alignment, a nesting, and a crossing (see Figure 5).Note that alignments, crossings and nestings are just special instances (the smallest non-trivial) of, resp., lines, stacks, and waves, and throughout we will use these names interchangeably.
Figure 5: A line, a stack, and a wave of size three.

In arbitrary matchings
Consider a sub-matching M ′ of M and an edge e ∈ M \ M ′ , which is to the left of the left-most edge f of M ′ .Note that if M ′ is a line and e and f form a line, then M ′ ∪ {e} is a line too.Similarly, if M ′ is a stack and {e, f } form a nesting, then M ′ ∪ {e} is a stack too.However, an analogous statement fails to be true for waves, as e, though crossing f , may not necessarily cross all other edges of the wave M ′ .Due to this observation, in the proof of our first result we will need another type of ordered matchings combining lines and waves.We call a matching M = {{a i , b i } : i = 1, . . ., n} with a i < b i , for all i = 1, 2, . . ., n, and that is, the right-ends of the edges of M are also linearly ordered (a first-come-first-serve pattern).Notice that there are no non-trivial stacks in a landscape.In the double occurrence word notation, a landscape is just a word obtained by a shuffle of the two copies of the word Examples of landscapes for n = 4 are, among others, ABCDABCD, AABCBCDD, ABCABDCD (the last one is depicted in Figure 6).
The following is an Erdős-Szekeres type result for ordered matchings.Proof.Let M be any ordered matching with edges {a i , b i }, i = 1, 2, . . ., n.Let s i denote the size of a largest stack whose left-most edge is {a i , b i }.Similarly, let λ i be the largest size of a landscape whose left-most edge is {a i , b i }.Consider the sequence of pairs (s i , λ i ), i = 1, 2, . . ., n.We argue that no two pairs of this sequence may be equal.Indeed, let i < j and consider the two edges {a i , b i } and {a j , b j }.These two edges may form a nesting, an alignment, or a crossing.In the first case we get s i > s j , since the edge {a i , b i } enlarges the largest stack starting at {a j , b j }.In the two other cases, we have λ i > λ j by the same argument.Since the number of pairs (s i , λ i ) is n > s • ℓw, it follows that either s i > s for some i, or λ j > ℓw for some j.In the first case we are done, as there is a stack of size s + 1 in M .In the second case, assume that L is a landscape in M of size at least p = ℓw + 1.Let us order the edges of L as e 1 < e 2 < • • • < e p , accordingly to the linear order of their left ends.Decompose L into edge-disjoint waves, W 1 , W 2 , . . ., W k , in the following way.For the first wave W 1 , pick e 1 and all edges whose left ends are between the two ends of e 1 , say, W 1 = {e 1 < e 2 < . . .< e i 1 }, for some i 1 ⩾ 1.Clearly, W 1 is a true wave since there are no nesting pairs in L. Also notice that the edges e 1 and e i 1 +1 are non-crossing since otherwise the latter edge would be included in W 1 .Now, we may remove the wave W 1 from L and repeat this step for L − W 1 to get the next wave W 2 = {e i 1 +1 < e i 1 +2 < . . .< e i 2 }, for some i 2 ⩾ i 1 + 1.And so on, until exhausting all edges of L, while forming the last wave Clearly, the sequence e 1 < e i 1 +1 < . . .< e i k−1 +1 of the leftmost edges of the waves W i must form a line (see Figure 7).So, if k ⩾ ℓ+1, we are done.Otherwise, we have k ⩽ ℓ, and because p = ℓw+1, some wave W i must have at least w + 1 edges.This completes the proof.
It is not hard to see that the above result is optimal.For example, consider the case ℓ = 5, s = 3, w = 4.Take 3 copies of the wave of size w = 4: ABCDABCD, P QRSP QRS, XY ZT XY ZT .Arrange them into a stack-like structure (see Figure 8): ABCDP QRSXY ZT XY ZT P QRSABCD.Now, concatenate ℓ = 5 copies of this structure.Clearly, we obtain a matching of size  Proposition 2. For every positive integers ℓ, s and w there exists a matching of size n = ℓsw with all lines, waves, and stacks of size at most ℓ, s and w, respectively.
By forbidding one of the three basic structures to be present in M and setting the corresponding parameter, ℓ, s, or w to 1, we immediately deduce from Theorem 1 that one of the other two structures of an appropriately large size must be present in M .For example, in a landscape (i.e., no nestings) of size n ⩾ ℓw + 1 one can find either a line of size ℓ + 1 or a wave of size w + 1.More interestingly, forbidding an alignment we obtain what we define in Section 3.1 as permutational matchings which are in a one-toone correspondence with permutations of order n.Moreover, under this bijection waves and stacks in a permutational matching M correspond to, respectively, increasing and decreasing subsequences of the permutation which is the image of M .Thus, we recover the original Erdős-Szekeres Theorem as a special case of our Theorem 1.
Finally, we formulate separately the diagonal case of Theorem 1.
Corollary 3. Every ordered matching on 2n vertices contains a line, a stack, or a wave of size at least n 1/3 .

3-uniform matchings
It is perhaps natural and interesting to try to generalize Theorem 1 to r-uniform ordered matchings, that is, families of n disjoint r-element subsets of the linearly ordered set [rn].
Here we make the first step by showing that the case r = 3 follows relatively easily from Theorem 1 itself.At the start the problem seems a bit overwhelming, as there are 1 2 6 3 = 10 different ways in which two triples may intertwine.Using the triple occurrence words, they are AAABBB, AABABB, AABBBA, AABBAB, ABBBAA, ABBAAB, ABBABA, ABAABB, ABABBA, ABABAB.We will call them patterns or relations since these words describe a way in which any two edges are interwoven with each other.What is worse, one of them, AABABB, stands out as a culprit who spoils the otherwise nice picture.To see it through, call an ordered pair of triples (e, f ) collectable if for each k ⩾ 1 there exists a collection of k triples such that every pair of them is order-isomorphic to the pair (e, f ).
For instance, the relation AAABBB, which we may call, as before, an alignment, is collectable, as for any k one can take In fact, all nine relations but AABABB are collectable.However, for AABABB, which we may call an engagement, one cannot even add a third triple CCC.Indeed, if it were possible, then there should be a C between the second and third A, but after the first B, which makes the relation between B's and C's not an engagement, as it would begin with BC. (Here we assumed w.l.o.g. that the first A precedes the first B which precedes the first C.) Due to this annoying exception, the Erdős-Szekeres type result we are going to prove is not as clean as its predecessors for singletons and pairs.For reasons, which will become clear once we reveal our proof strategy, we "give names to all the animals" as presented in the first two columns of Table 1.
To explain this encoding, let us denote the three basic graph configurations as L = AABB, S = ABBA, and W = ABAB, accordingly to their (alternative) names, that is, line, stack, and wave.Now, each of the ten pairwise relations of triples can be uniquely decomposed into a pair of pairs consisting, resp., of the first two vertices in both triples and the last two vertices in both triples.For example, the relation AABBAB decomposes into a line AABB and a wave ABAB.We express this fact by writing AABBAB = AABB ⊕ ABAB and denoting relation AABBAB by R LW .
Obviously, for a given 3-uniform relation this decomposition is unique.However, this mapping is not one-to-one as there are only nine different ordered pairs made of three elements.And, indeed, the alignment AAABBB and the engagement AABABB both decompose into the same the pair AABB, AABB.To distinguish between them, we add asterisk for the latter, that is, we denote AAABBB by R LL while AABABB by R * LL .The last column of Table 1 displays this mapping using, again, the words with underlined and overlined letters.The three relations with the first subscript S differ in that the letters in the second component of the decomposition ⊕ are reversed; indeed, if the pairs of the first two elements of two triples form the sequence ABBA, then the pairs of the last two elements can only form sequences BBAA, BABA, or BAAB.But, let us emphasize that as Gauss words BBAA = AABB, etc.
Possible relations of two triples and their corresponding decompositions ⊕.
To cope with engagements, we will "marry" them with alignments by combining relations R LL and R * LL together.First, as in the case of pairs, define a line as an ordered 3-uniform matching M such that all pairs of triples of M are in relation R LL , that is, each pair forms an alignment.Call M a semi-line if all pairs of triples are in either relation R LL or R * LL , that is, they form an alignment or an engagement.
Proposition 4. Every semi-line of size k contains a line of size at least k/2.
Proof.Let e 1 , . . ., e k be a semi-line.Define an auxiliary graph G on vertex set [k] where ij ∈ E(G) if e i and e j form an engagement.It turns out that G is a linear forest.To prove it, assume w.l.o.g. that for all i < j the left-most vertex of e i is to the left of the left-most vertex of e j .We claim that every vertex i has at most one neighbor j > i.Indeed, if there were edges ij and ih, i < j < h, then, identifying e i , e j and e h , respectively, with letters A, B and C, we would have a sequence AABCA . . ., where the last 4 positions are occupied by 2 letters B and 2 letters C in an arbitrary order.This means, however, that B's and C's, or equivalently e j and e h , form neither an alignment nor an engagement, a contradiction with the definition of a semi-line.By symmetry, any vertex i has also at most one neighbor j < i.So, G is, indeed, a linear forest and as such has an independent number at least k/2.This completes the proof.
We are now ready to formulate an Erdős-Szekeres type result for 3-uniform matchings.
Theorem 5. Let a XY , where X, Y ∈ {L, S, W}, be arbitrary positive integers and let Then, every ordered 3-uniform matching M on 3n vertices either contains a semi-line of size a LL + 1, or there exists (X, Y ) ̸ = (L, L) such that M contains a sub-matching of a XY + 1 triples every two of which are in relation R XY (as defined in Table 1).
Remark 6.As in Corollary 3 one can show that every 3-uniform ordered matching of size n contains one of the nine sub-structures listed in Theorem 5 of size at least n 1/9 .Remark 7. At the moment we are not able to find a construction showing optimality of Theorem 5.It was relatively easy in the graph case, as both, stacks and waves, had the interval chromatic number equal to 2, which enabled one to superimpose one into another by blowing up the vertices of one of them and filling its edges with copies of the other (see Figure 8 for the superimposition of a wave of size 4 upon a stack of size 3).Following, e.g., [17], we say that an ordered r-uniform hypergraph has interval chromatic number r if it is r-partite with the partition sets forming consecutive blocks of the linearly ordered vertex set.Now, out of the eight 3-uniform relations, alignments and engagements aside, only four have interval chromatic number 3, namely those not having L within their indices: R SS = ABBAAB, R SW = ABBABA, R WS = ABABBA, and R WW = ABABAB.Thus, we can provide a counterexample showing optimality of Theorem 5 only in the special case when a LS = a LW = a SL = a WL = 1.We do so by superimposing the four "no-L" relations and then taking a LL disjoint copies of the obtained construction.The superimposition is done by carefully replacing each triple of the current matching with a matching obeying mutually the new relation.For the case when a SS = a SW = a WS = a WW = 2 (and all other parameters set to 1) see Figure 9, where the pairwise relations between all 16 triples can be described as follows.Let us first focus on the 8 triples drawn with solid colored lines (A, . . ., H).Among them, all 4 monochromatic pairs of triples (like A − B) are in relation R SS , the 8 red-blue and orange-green pairs of triples (like A − C) obey relation R SW , while the remaining 16 pairs (like A−E) satisfy relation R WS .The very same is true for the 8 triples drawn with dashed colored lines (I, . . ., P ).Finally, each solid-dashed pair (like A − I) satisfies relation R WW .Note that, viewing this construction as a complete graph K 16 , each relation corresponds to a bipartite subgraph, and so, crucially, no three triples are mutually in the same relation.in M .For graphs, lines and stacks were extendable, while waves were not, which forced us to come up with the notion of a landscape.Now, only R LL , R LS , R SW , and R SL are extendable, so any direct proof of Theorem 5 would require more sophisticated analogs of landscapes.Fortunately, we deduce Theorem 5 directly from Theorem 1.
Proof of Theorem 5. Let M be a matching (of triples) as in the assumptions of the theorem.Our proof strategy is to apply Theorem 1 twice, first to the (graph) matching M 1 composed of pairs consisting of the first two elements of the triples in M , then to a suitably chosen sub-matching of the (graph) matching M 1 composed of pairs of the last two elements of the triples in M .
Set b L = a LL a LS a LW , b S = a SL a SS a SW , and b W = a WL a WS a WW and apply Theorem 1 to M 1 with ℓ := b L , s := b S , and w := b W .We will now examine the three alternatives of the conclusion.
Case (L).M 1 contains a (graph) line L of size b L + 1.Let M L be the sub-matching of M 2 composed of pairs of the last two elements of those triples in M whose first two elements form a pair belonging to L. Formally, M L = {{j, k} : i < j < k, {i, j, k} ∈ M, and {i, j} ∈ L}.
We apply Theorem 1 to M L with ℓ := a LL , s := a LS , and w := a LW and examine the three possible outcomes.
Subcase (LL).M L contains a line L of size a LL + 1.This is the troublesome case.Let M LL be the sub-matching of M consisting of all triples in M whose first pair of elements belongs to L, while the last pair belongs to L. Consider any two triples in M LL .There are two possible relations they may be in: the alignment AAABBB and the engagement AABABB.Indeed, in both cases the first pairs and the last pairs, underlined and overlined, resp., form (graph) alignments.This shows that M LL is a semi-line.
Subcase (LS).M L contains a stack S of size a LS + 1.Let M LS be the sub-matching of M consisting of all triples in M whose first pair of elements belongs to L, while the last pair belongs to S. Consider any two triples in M LS .Then they necessarily are in relation R LS , that is, they form the word AABBBA.
Subcase (LW).M L contains a wave W of size a LW + 1.Let M LW be the sub-matching of M consisting of all triples in M whose first pair of elements belongs to L, while the last pair belongs to W . Consider any two triples in M LW .Then they necessarily are in relation R LW , that is, they form the word AABBAB.
Cases (S) and (W).Each case splits further, as before, into three subcases.It is straightforward to check that these altogether six subcases lead to the remaining six relations R SL , R SS , R SW , R WL , R WS , R WW , yielding each time the required size of the collection.

In random matchings
In this section we shall investigate the size of unavoidable structures one can find in random ordered matchings with the emphasis on the three canonical patterns: lines, stacks, and waves.Recall that RM n is a random (ordered) matching of size n, that is, a matching picked uniformly at random out of the set of all α n := (2n)!/(n!2 n ) matchings on the set [2n].
Baik and Rains in [2] (see also [29,Theorem 17]) determined the asymptotic distribution of the maximum size of two of the three canonical patterns contained in a random ordered matching.As a consequence, their values can be pinpointed very precisely.

Theorem 9 ([2]
).The sizes of the largest stack and the largest wave contained in RM n are a.a.s.equal to (1 + o(1)) √ 2n.
A similar result for lines was proved by Justicz, Scheinerman, and Winkler in [23].Note, however, that the constant is different.

Theorem 10 ([23]
).The size of the largest line contained in RM n is a.a.s.equal to In this section we provide simpler, purely combinatorial proofs of weaker versions of Theorems 9 and 10, with the asymptotic coefficient, resp., √ 2 and 2/ √ π replaced by pairs of constants setting lower and upper bounds only.The proof of the upper bounds is quite straightforward and provides a more general result.
max{k : Proof.Set k 0 = ⌊ 1 + n −1/3 e n/2⌋, and let X k be a random variable counting the number of ordered copies of M k in RM n .Our goal is to show, via the first moment method, that a.a.s.X k = 0 for all k ⩾ k 0 .Note that it is not enough to show that a.a.s.X k 0 = 0, as the sequence (M k ) ∞ 1 may not be ascending.To compute the expectation of X k , one has to first choose the 2k vertices of a copy of M k (the copy itself is placed in just one way), then count the number of extensions of that copy to an entire matching of size n, and, finally, divide by the total number of matchings.Thus, and, by the union bound applied together with Markov's inequality, Owing to the very homogeneous structure of lines, stacks, and waves, we are able to establish corresponding lower bounds for their maximum sizes in RM n .It is, perhaps, interesting to note that, unlike for permutations, the size of the sub-structures guaranteed by the of Erdős-Szekeres-type result (cf.Corollary 3) grows substantially in the random setting.
Theorem 12.A random matching RM n contains a.a.s.stacks and waves of size at least √ n each, as well as lines of size at least 1 8 √ n.
The proof for stacks and waves is very simple and relies mostly on Theorem 1.For lines we will make use of the following lemma which might be of some independent interest.For that reason we state it in a more general setting than what we actually need.The length of an edge {i, j} in a matching on [2n] is defined as |j − i|.
Proof.For each pair of vertices 1 ⩽ u < v ⩽ 2n, let X uv be the indicator random variable equal to one if {u, v} ∈ RM n and 0 otherwise.Clearly, Pr(X uv = 1) = 1/(2n − 1).Let us write for simplicity m = f (n).The sum X = 1⩽v−u⩽m X uv counts all edges in RM n of length at most m.As the number of summands is (2n In particular, by the assumptions on f (n), we get EX = m(1 − o( 1)) → ∞.To estimate the second moment, observe that Hence, estimating quite crudely, and consequently, by Chebyshev's inequality Proof of Theorem 12.We split the proof into two uneven parts.
Stacks and waves: Fix ε > 0 and choose Let M be the sub-matching of RM n consisting of all edges with one end in [n] and the other in so, using Chebyshev's inequality, it follows that a.a.s.|X − n/2| = o(n).
Observe that there are no lines in M longer than 1.By Proposition 11, a.a.s.there are no stacks or waves in RM n of size k 0 = ⌊(1+o( 1))e n/2⌋.Hence, by applying Theorem 1 to M with ℓ = 1, s = k 0 − 1, and w = ⌊ X−1 k 0 −1 ⌋, we conclude that a.a.s.there is a wave in M , and thus in RM n , of size at least By swapping the roles of waves and stacks in the above argument, we deduce that a.a.s.there is also a stack in M , and thus in RM n , of size . By Lemma 13, a.a.s. the number of edges of length at most m in RM n is at least √ n/4.We will show that among the edges of length at most k, there are a.a.s. at most √ n/8 pairs forming crossings or nestings.After removing one edge from each crossing and nesting we obtain a line of size at least .
Let X = X S , where the summation is taken over all sets S as above and such that denote the number of terms in this sum.We have as we have at most 2n(m − 1) − m 2 choices for u 1 and v 1 (see the proof of Lemma 13 with m replaced by m−1) and, once u 1 , v 1 have been selected, at most m 2 choices of u 2 , and v 2 .It is easy to see that f (n, m) = Ω(nm 3 ).(In fact, one could show that f (n, m) ∼ 2 3 nm 3 , but we do not care about optimal constants here.)Hence, EX = Ω(m 3 /n) → ∞, while To apply Chebyshev's inequality, we need to estimate E(X(X − 1)), which can be written as where the summation is taken over all (ordered) pairs of sets We split the above sum into two sub-sums Σ 1 and Σ 2 according to whether S ∩ S ′ = ∅ or |S ∩ S ′ | = 2 (for all other options the above probability is zero).In the former case, In the latter case, the number of such pairs (S, S ′ ) is at most f (n, m) • 4m 2 , as given S, there are four ways to select the common pair and at most m 2 ways to select the remaining two vertices of S ′ .Thus, and, altogether, By Chebyshev's inequality, Thus, a.a.s.X ⩽ 2EX ⩽ √ n/16.We deal with nestings in a similar way.For a 4-element subset choices for u 1 and u 2 and, once u 1 , u 2 have been selected, at most m−2 2 choices of v 1 , and v 2 , while the probability of both pairs appearing in RM n remains the same as before.The remainder of the proof goes mutatis mutandis.
We conclude that a.a.s. the number of crossings and nestings of length at most m in RM n is at most √ n/8 as was required.
We close this section with a straightforward generalization of Proposition 11 to random r-uniform ordered matchings, r ⩾ 2. Let RM (r)  n be a random (ordered) r-matching of size n, that is, a matching picked uniformly at random out of the set of all α k be the number of ordered copies of M (r) k of size k in RM (r)  n .Then In particular, the above statement yields that in RM (3)  n a.a.s.none of the nine collectable sub-matchings (as defined in Subsection 2.2) has size bigger than 2n 1/3 .It is, at the moment, an open problem to match it with a fair lower bound (see discussion in Section 4).Now, by the assumption of the lemma applied to n = r, noticing that t match r (r) = 1, we have that 1 ⩾ βr α , or β ⩽ r −α , so n ′ ⩾ n/4 ⩾ r.Thus, by the assumption of the lemma applied to n ′ , t perm r (n ′ ) ⩾ β(n/4) α .Further, noticing that n − n ′ + 2 ⩾ 3n/4, again by the induction assumption, we also have where the last inequality is equivalent to 3 ⩾ 2 3−1/α which, in turn, follows by estimating the R-H-S by 2 3−(2r−1)/r ⩽ 2 3−3/2 = 2 3/2 .

In random matchings
In this section we study the size of the largest r-twins in a random (ordered) matching RM n , which is, recall, selected uniformly at random from all α n := (2n)!/(n!2 n ) matchings on vertex set [2n].The first moment method yields that a.a.s.t r (RM n ) < cn r/(2r−1) for any c > e2 −(r−1)/(2r−1) . ( Indeed, the expected number of r-twins of size k in RM n is where we used inequalities n!/(n − rk)! ⩽ n rk , (2k)! ⩾ (2k/e) 2k , k! ⩾ (k/e) k , and r! ⩾ 1.Thus, it converges to 0, as n → ∞, provided k ⩾ cn r/(2r−1) , for any c as in (1).It turns out that the a.a.s. the lower bound on t r (RM n ) is of the same order.
In the proof of the lower bound we are going to use the Azuma-Hoeffding inequality for random permutations (see, e.g., Lemma 11 in [16] or Section 3.2 in [20]).Let us recall that Π n stands for a random permutation selected uniformly from all (2n)!permutations of the set [2n].
Theorem 21.Let h(π) be a function defined on the set of all permutations of order 2n such that, for some constant c > 0, if a permutation π 2 is obtained from a permutation π 1 by swapping two elements, then |h(π 1 ) − h(π 2 )| ⩽ c.Then, for every η > 0, Proof of Theorem 20.In view of (1), it suffices to prove a lower bound, that is, to show that a.a.s.RM n contains r-twins of size Ω(n r/(2r−1) ).In doing so we are following the proof scheme applied in [12,Theorem 1.2].Set a := r! 1/(2r−1) (2n) (r−1)/(2r−1) and assume for simplicity that both, a and N := 2n/a = r! −1/(2r−1) (2n) r/(2r−1) , are integers.Partition [2n] = A 1 ∪ • • • ∪ A N , where A i 's are consecutive blocks of a integers each, and define, for every 1 ⩽ i < j ⩽ N , a random variable X ij which counts the number of edges of RM n with one endpoint in A i and the other in A j .Consider an auxiliary graph A crucial observation is that a matching of size t in G corresponds to r-twins in RM n of size t.Indeed, let M = {i 1 j 1 , . . ., i t j t }, i 1 < • • • < i t , be a matching in G.For every 1 ⩽ s ⩽ t, let u s h ∈ A is and v s h ∈ A js , h = 1, . . ., r, be such that e s h := {u s h , v s h } ∈ RM n .Then, the sub-matchings {e 1  1 , . . ., e t 1 }, . . ., {e 1 r , . . ., e t r }, owing to the sequential choice of A i 's form r-twins in RM n .Thus, our ultimate goal is to show that a.a.s.G contains a matching of size Θ(n r/(2r−1) ).
Let us first estimate from below the probability of an edge in G, that is, Pr(X ij ⩾ r).Trivially, Pr(X ij ⩾ r) ⩾ Pr(X ij = r).We are going to further bound Pr(X ij = r) from below by counting matchings on [2n] with precisely r edges between the sets A i and A j , but with no edges within A i or A j (the latter is a simplifying restriction).To build such a matching one has to first select subsets S i , S j , T i , T j such that S For an integer D > 0, let G D be a subgraph of G induced by the set V D of all vertices of degrees at most D in G, that is, Hence, recalling (3) and noticing that EZ k = N Pr(Y 1 = k), we have It remains to estimate Pr(Y 1 = k) from above.Very crudely, to create a matching satisfying Y 1 = k, one has to select k other sets A i , choose r vertices from each of them, and match them with some kr vertices of A 1 .In the estimates below, we ignore the demand that Y 1 is precisely k, so, in fact, we estimate from above Pr(Y 1 ⩾ k).We thus have Using the inequality 1 − x ⩾ e −2x valid for x ⩽ 1/2, the last fraction can be estimated as which, together with (2), completes the proof.

Final remarks
Let us conclude the paper with some suggestions for future studies.The first natural goal is to extend our Erdős-Szekers-type results to r-uniform ordered matchings for arbitrary r ⩾ 4. We have inspected more carefully the case of r = 4 observing some similar phenomena as in the two smaller cases, r = 2 and r = 3.In particular, among the 35 possible relations between pairs of ordered quadruples there are exactly 27 that are collectable.This boosts some hope that by cleverly handling the remaining 8 relations, one can, indeed, generalize Theorem 5 with the exponents 1/9 replaced by 1/27.Returning to the case r = 3, we are not yet completely done, as we were unable to construct a general counterexample showing the optimality of Theorem 5 for arbitrary values of all 9 parameters (c.f.Remark 7).
Problem 22.For all positive integers a XY , where X, Y ∈ {L, S, W}, (X, Y ) ̸ = (L, L), construct a matching M of size n = X,Y a xy such that neither M contains a semi-line of size 2, nor for any pair (X, Y ) does it contain a sub-matching of a XY + 1 triples every two of which are in relation R XY .
As mentioned earlier, setting a LL = 1 is not a restriction at all, as in the general case one may simply concatenate a LL disjoint copies of the matching described in Problem 22 A related problem is to estimate the size of unavoidable patterns in random r-matchings RM (r)  n with r ⩾ 3.For r = 2, we have established (c.f.Theorem 12) that it is a.a.s. of the order Θ( √ n).As it was already mentioned at the end of Section 2.3, as a consequence of Proposition 14, for r = 3 a.a.s.none of the nine collectable sub-matchings (as defined in Subsection 2.2) has size bigger than 2n 1/3 .It would be nice to prove a complementary lower bound.Although for 3-uniform lines this does not seem to be difficult (as, likely, Lemma 13 can be extended for hyperedges), showing that a.a.s.RM (3)  n contains every collectable sub-matching of size Ω(n 1/3 ) will require some new ideas.
For arbitrary r, it too seems natural to expect that, as in the case r = 2, all homogeneous substructures (corresponding to collectable relations) of RM (r)  n should a.a.s.have size Θ(n cr ), for some constant 0 < c r < 1.By Theorem 12 we know that c 2 = 1/2, while guided by Proposition 14, we suspect that c r = 1/r.
Other open problems can be formulated for twins in ordered matchings.Based on what we proved here we state the following conjecture.The same statement is conjectured for twins in permutations (see [12]), and, by our results, we know that both conjectures are actually equivalent.
One could also study the size of twins in r-uniform ordered matchings or, more generally, in arbitrary ordered graphs or hypergraphs.For ordinary unordered graphs there is a result of Lee, Loh, and Sudakov [25] giving an asymptotically exact answer of order Θ(n log n) 2/3 .It would be nice to have an analogue of this result for ordered graphs.

Figure 2 :
Figure 2: An alignment, a nesting, and a crossing of a pair of edges.

Figure 7 :
Figure 7: Greedy decomposition of a landscape into waves.The left-most edges of the waves (in bold) form a line.

Figure 8 :
Figure 8: A stack of waves.
E.g., replacing ABABAB (relation R WW ) with CD EF CD EF DC F E results in a matching where four pairs of triples retain relation R WW , while two pairs (C −D and E − F ) enjoy the new relation R WS .It is crucial here that consecutive blocks of size 2 in CD CD DC each contain both letters C and D, which is equivalent to having interval chromatic number 3.

Remark 8 .
As in the case of graph matchings it is impossible to employ directly the original Erdős-Szekeres proof idea.To see this, call a relation R extendable if, given a collection M of disjoint triples which are mutually in relation R, every triple to the left of M which is in relation R with the left-most triple of M , is in relation R with all triples

Figure 9 :
Figure 9: A matching of 2 4 = 16 triples illustrating optimality of Theorem 5 with a SS = a SW = a WS = a WW = 2 (and all other parameters set to 1).

Corollary 19 . 2 ( 5 .
For every n, t match Moreover, any future improvement of the bound in Theorem 15 would automatically yield a corresponding improvement of the lower bound on t match 2 (n).
let Y S be an indicator random variable equal to 1 if both{u 1 , u 2 } ∈ RM n and {v 1 , v 2 } ∈ RM n , that is, if S spans a nesting in RM n .Further, let Y = Y S, where the summation is taken over all sets S as above and such thatu 2 − u 1 ⩽ m and (consequently) v 2 − v 1 ⩽ m − 2.It is crucial to observe that, again, EY ⩽ m 3 /n = √ n/32.Indeed, this time there are at most 2nm − m+1 2