Mallows permutations as stable matchings

We show that the Mallows measure on permutations of $1,\ldots,n$ arises as the law of the unique Gale-Shapley stable matching of the random bipartite graph conditioned to be perfect, where preferences arise from a total ordering of the vertices but are restricted to the (random) edges of the graph. We extend this correspondence to infinite intervals, for which the situation is more intricate. We prove that almost surely every stable matching of the random bipartite graph obtained by performing Bernoulli percolation on the complete bipartite graph $K_{\mathbb{Z},\mathbb{Z}}$ falls into one of two classes: a countable family $(\sigma_n)_{n\in\mathbb{Z}}$ of tame stable matchings, in which the length of the longest edge crossing $k$ is $O(\log |k|)$ as $k\to\pm \infty$, and an uncountable family of wild stable matchings, in which this length is $\exp \Omega(k)$ as $k\to +\infty$. The tame stable matching $\sigma_n$ has the law of the Mallows permutation of $\mathbb{Z}$ (as constructed by Gnedin and Olshanski) composed with the shift $k\mapsto k+n$. The permutation $\sigma_{n+1}$ dominates $\sigma_{n}$ pointwise, and the two permutations are related by a shift along a random strictly increasing sequence.


Introduction
In this paper we will establish a connection between two classical objects: the Mallows measure on permutations and Gale-Shapley stable marriage. The Mallows measure Mal n q on permutations of {1, . . . , n} with parameter q ∈ [0, 1] is the probability measure that assigns to each permutation σ ∈ S n a probability proportional to q inv(σ) , where inv(σ) is the inversion number of σ, given by inv(σ) = # (i, j) ∈ {1, . . . , n} 2 : i < j but σ(i) > σ(j) .
More generally, we define the Mallows measure Mal I q on permutations of a general finite interval I ⊆ Z by shifting the index. The Mallows measure was extended to permutations of infinite intervals by Gnedin and Olshanski [10,11], who showed that for q ∈ [0, 1) and an infinite interval I ⊆ Z, the measures Mal I∩[−n,n] q converge weakly (with respect to the topology of pointwise convergence) to a probability measure Mal I q on permutations of I. We call this limit the Mallows measure on permutations of I with parameter q. They also characterised the Mallows permutation of Z, together with its compositions with shifts, as the unique random permutations of Z with a property that they called q-exchangeability, which is equivalent to being a Gibbs measure on permutations of Z with respect to the Hamiltonian H(σ) = inv(σ) and inverse temperature β = − log q.
The Mallows measure was originally introduced in the context of statistical ranking theory [16]. It has recently enjoyed substantial interest among both pure and applied mathematicians. In particular, analysis has been carried out of the cycle structure [9] and the longest increasing subsequence [2,4,17] of a Mallows permutation, of the longest common subsequence of two independent Mallows permutations [15], and of mixing times of related Markov chains [3,6]. The Mallows permutation has also been studied as a statistical physics model [18,19], and has found applications in learning theory [5] and in the theory of finitely dependent processes [13]. The Mallows measure also arises as a stationary measure of the asymmetric exclusion process (ASEP) [1].
In this paper, we show that, for both finite and infinite intervals, the Mallows permutation arises as a stable matching of the random bipartite graph on the interval. In particular, we obtain a new construction of the Mallows permutation of an infinite interval. The finite case follows in a straightforward way by consideration of known algorithms for sampling from the Mallows distribution, while the infinite case is more subtle and requires a more delicate treatment.
The notion of stable matching was introduced in the hugely influential work of Gale and Shapley [8]. Since then, thousands of articles on the topic have been written, and Nobel Memorial Prizes in Economics have been awarded to Roth and Shapley for related work.
Let us now describe informally the random stable matchings with which we shall be concerned. Suppose that we have a set of males and a set of females who seek to be matched into heterosexual pairs, in accordance with preferences defined as follows. Both the set of males and the set of females are ranked according to a universally agreed order of attractiveness. However, each male-female pair has a probability q ∈ [0, 1) of being incompatible, independently of all other pairs, meaning that neither will consider the other as a partner under any circumstances. Attractiveness and compatibility are the only factors affecting preferences. In particular, if each set is finite, a female's first choice for partner is the most attractive male she is compatible with, her second choice is the second most attractive male she is compatible with, and so on. A matching is a collection of compatible pairs such that each individual is in at most one pair. A matching is stable if there does not exist a compatible male-female pair who would both prefer to be matched to each other over their current status, where any compatible partner is preferred to being unmatched.
We now introduce notation in order to make these definitions more formal. A matching of a graph G is a set of edges no two of which share a vertex. A matching is perfect if every vertex has a partner. Given intervals I, J ⊆ Z, we write K I,J for the graph whose vertex set is (I×{♂})∪(J ×{♀}) and whose edge set is {(i, ♂), (j, ♀)} : i ∈ I, j ∈ J . If G is a subgraph of K I,J , we say that (i, ♂) and (j, ♀) are compatible if there is an edge between them in G. Thus, a matching of K I,J is a matching of G if and only if every matched pair is compatible. We identify each matching of K I,J with a function σ : I → J ∪ {−∞} by setting σ(i) = j if (i, ♂) is matched to (j, ♀) and setting σ(i) = −∞ if (i, ♂) is unmatched. The function σ −1 : J → I ∪ {−∞} is defined similarly by interchanging the roles of ♂ and ♀. In particular, if I = J and the matching is perfect then σ is a permutation of I and σ −1 is its inverse; this yields a bijection between perfect matchings of K I,I and permutations of I. A matching of a subgraph G of K I,J is stable if there does not exist a pair Given p ∈ [0, 1], we let K I,I (p) be the subgraph of K I,I with the same vertex set as K I,I and where each edge is included independently at random with probability p. Proposition 1. Let p ∈ (0, 1], let q = 1 − p, and let I ⊆ Z be an interval that is bounded above. Then the following hold. i. Every subgraph of K I,I has a unique stable matching, so that in particular K I,I (p) has a unique stable matching almost surely. ii. If I is finite then the unique stable matching of the random subgraph K I,I (p) is perfect with probability |I| k=1 (1 − q k ). iii. If I is infinite then the unique stable matching of K I,I (p) is perfect almost surely. Orange discs indicate unmatched individuals. Thin grey (solid and dotted) lines represent edges connecting incompatible pairs. Edges between compatible individuals that are not in the matching are not shown. The matching can be computed without examining all edges: those that need to be examined are the edges of the matching (whose endpoints are compatible), and the solid grey edges (which are all those edges whose endpoints must be incompatible in order for the matching to be stable). In the case of a perfect matching, these solid grey edges are simply all those that connect the upper endpoints of a crossing pair of edges of the matching. iv. Conditional on the event that the unique stable matching of K I,I (p) is perfect, it is distributed as a Mallows permutation of I with parameter q.
We remark that the limit (q) ∞ := ∞ k=1 (1 − q k ) as |I| → ∞ of the probabilities appearing in Proposition 1.ii is positive but strictly less than 1 for each q ∈ (0, 1). We also remark, as a point of general interest, that the asymptotics of this infinite product were computed by Hardy and Ramanujan [12] to be as q 1.
The function (q) ∞ is the reciprocal of the generating function of integer partitions. It is also known as both the q-Pochhammer symbol and the Euler function, owing to its role in Euler's pentagonal number theorem [7]. The situation for intervals that are unbounded from above (so that there do not exist maximally attractive individuals) in very different, and is the main topic of this paper. Indeed, for p ∈ (0, 1) the random graph K Z,Z (p) has uncountably many stable matchings, and even uncountably many stable matchings that are not perfect. We will prove, however, that the stable matchings of K Z,Z (p) fall into two sharply distinguished classes: a countable family of tame matchings which correspond to compositions of the Mallows permutation of Z with shifts, and an uncountable family of wild stable matchings. Moreover, the tame and wild stable matchings have quantitatively very different behaviours. Figure 2. A portion of the balanced tame stable matching of K Z,Z (p), for p = 0.2 (left), p = 0.4 (middle), and p = 0.6 (right), shown by blue lines. The law of the matching corresponds to the Mallows measure on permutations of Z. Thin grey lines indicate edges whose endpoints must be incompatible for this matching to be stable. Other edges are omitted.
To state these results we introduce some more definitions. For an interval I ⊆ Z, a matching σ of K I,I and i ∈ I, we define the quantities That is, L + (σ, i + 1 2 ) and L − (σ, i + 1 2 ) are the numbers of edges crossing over i + 1 2 in each direction. We say that the matching σ is locally finite if L + (σ, i + 1 2 ) + L − (σ, i + 1 2 ) is finite for some (and hence every) i ∈ I. Note that matchings of intervals other than Z are always locally finite. If σ is perfect and locally finite, we define the flow of σ to be Fl(σ) = L + σ, i + 1 2 − L − σ, i + 1 2 , which is easily seen to be independent of i. We say that σ is balanced if it is perfect, locally finite, and has flow zero.
For each matching σ of K Z,Z and each i ∈ Z, we also define to be the length of the longest edge in the matching crossing i + 1 2 , where the maximum of the empty set is taken to be zero. We say that a matching σ of K Z,Z is tame if it is locally finite and  that is, if the maximum length of an edge crossing i + 1 2 grows at least exponentially as i → +∞. In particular, every matching that is not locally finite is wild. There is a wide gulf between tameness and wildness -it is easy to construct matchings of K Z,Z that are neither tame nor wild. However, our stable matchings are either tame or wild.
Theorem 2 (Tame/wild dichotomy). Let p ∈ (0, 1], let q = 1−p, and consider the random bipartite graph K Z,Z (p). Almost surely, every locally finite stable matching of K Z,Z (p) is perfect, and every stable matching of K Z,Z (p) is either tame or wild.
Simulated examples of tame and wild matchings of K Z,Z (p) are depicted in Figures 2 to 4. Note that the definition of wildness is asymmetric, and does not say anything about the behaviour as i → −∞. In fact, we will show that for every perfect, locally finite stable matching σ of K Z,Z (p), there is a tame stable matching that agrees with σ at all sufficiently large negative isee Corollary 12. Next, we relate the tame matchings of K Z,Z (p) to the Mallows permutation, and describe some of their properties.
Theorem 3 (Classification of tame matchings). Let p ∈ (0, 1], let q = 1−p, and consider the random bipartite graph K Z,Z (p). Almost surely, the tame stable matchings of K Z,Z (p) form a countable family (σ n ) n∈Z with the following properties.
i. For each n ∈ Z, the matching σ n is perfect and has flow n.
ii. The stable matching σ n is the almost sure pointwise limit of the unique stable matching σ n,m of K (−∞,m],(−∞,m+n] (p) as m → ∞. iii. The matching σ n is distributed as the composition σ with the shift i → i + n, where σ is a Mallows-distributed permutation of Z with parameter q. iv. If n ≤ n, then the males do no better in σ n than in σ n , and the females do no worse. That is, σ n (i) ≤ σ n (i) and σ −1 n ≥ σ −1 n (i) for every i ∈ Z. Moreover, for every n ∈ Z, the matchings σ n and σ n+1 agree except on a strictly increasing sequence (i n,k ) k∈Z , for which σ n (i n,k ) = σ n+1 (i n,k+1 ) for all k ∈ Z.
In particular, note that while σ n+1 is distributed as the shift of σ n , it is not equal to the shift of σ n (see Figure 3). Theorem 3.iii is reminiscent of the situation for stable matchings with general preferences on finite sets, where there are two extremal matchings, one of which is female-optimal and male-pessimal while the other is male-optimal and female-pessimal [8].
Finally, we prove that wild stable matchings do indeed exist. (The fact that tame matchings also exist is part of Theorem 3).
Theorem 4 (Existence of wild matchings). Let p ∈ (0, 1), let q = 1 − p, and consider the random bipartite graph K Z,Z (p). Almost surely, there exist stable matchings of K Z,Z (p) in each of the following categories: • not perfect, • perfect but not locally finite, • perfect and locally finite, but wild.
Indeed, there almost surely exist uncountably many stable matchings in each category. Also, if I is an infinite interval that is bounded from below, then K I,I (p) has uncountably many wild stable matchings almost surely.
Matchings satisfying the conditions of Theorem 4 can be constructed via a simple and explicit algorithm. (In particular, no appeal to the axiom of choice is required. ) We remark that Theorem 2 and Theorem 4 are sharp in the sense that, disregarding constants, the definitions of tame and wild cannot be strengthened without the theorem becoming false. In other words, the tame stable matchings of K Z,Z (p) have logarithmically long edges, and there exist wild stable perfect matchings of K Z,Z (p) in which the longest edge crossing i + 1 2 is at most exponentially large in i. See Propositions 13 and 16 respectively for the precise statements.
About the proofs. Recall from Proposition 1 that there is a unique stable matching of every interval that is bounded from above. A central step in the proofs of Theorems 2 and 3 is to prove that the unique stable matchings of two different intervals, both bounded from above, coincide for all sufficiently large negative i, and moreover that the distance elapsed before they couple in this way has an exponential tail. In particular, we will prove that if σ and σ are the unique stable matchings of K (−∞,0],(−∞,0] (p) and K (−∞,n],(−∞,n] (p) for some n ≥ 0, then Note that the bound on the right of (1) does not depend on n. The exact statement required for the proofs of Theorems 2 and 3 is a little more general than this and is given in Proposition 7.
To prove this proposition, we consider the mutual cuts of σ and σ . If σ is a permutation of Z, we say that i + 1 2 is a cut for σ if σ fixes the sets {j ∈ Z : j < i + 1 2 } and {j ∈ Z : j > i + 1 2 }. If, in the setting above, i ≥ 0 and −i + 1 2 is a cut for both σ and σ , then it follows from Proposition 1 that σ(−j) = σ (−j) for all j ≥ i. Thus, to prove (1), it suffices to prove that ∞ . The proof of Proposition 7 also yields the following variation of this result concerning a single permutation, which is of independent interest. Proposition 5. Let q ∈ [0, 1), let I be an infinite interval, and let σ be a random permutation of I drawn from the Mallows distribution with parameter q. Then the process We note that if σ is a Mallows permutation of Z then P(i + 1 2 is a cut for σ) = (q) ∞ for every i ∈ Z; this is an immediate consequence of Proposition 1 and Theorem 3, and is also an easy consequence of the q-shuffling algorithm for sampling the Mallows permutation [11]. Thus, the density of the cuts of σ and of the Bernoulli process that Proposition 5 states that they dominate differ by a factor of 1 − q.
We now briefly discuss the proofs of Proposition 7 and Proposition 5. Proposition 1 naturally leads to several algorithms for sequentially sampling the Mallows permutation, depending on the order in which we choose to reveal the status of the edges in K I,I (p). Different algorithms lend themselves to studying different aspects of the permutation. For example, the diagonal exposure algorithm of Gladkich and Peled [9], which is well suited to studying the cycle structure of the Mallows permutation, is of this form. To prove Proposition 5, we introduce a new algorithm for sequentially sampling the Mallows permutation that is well suited to studying cuts, and has a natural interpretation in terms of the matching. In this algorithm, an "alpha" male prevents less attractive males from finding partners until he himself finds one (at which point another male takes To prove Proposition 7, we use a variation on this algorithm in which the two matchings σ and σ are computed simultaneously.

Intervals with maximally attractive individuals
We now prove Proposition 1. As advertised in the introduction, we will also obtain a new proof that the weak limit used to define the Mallows permutation of the infinite interval (−∞, 0] exists.
Proof of Proposition 1. Let I be an interval that is bounded from above. We may assume without loss of generality that max I = 0. Fix a subgraph G of K I,I . In any stable matching of G, the most attractive male must be matched to the most attractive female that is compatible with him. Inductively, the i th most attractive male must be matched to the most attractive female he is compatible with among those who are not matched to a more attractive male. This shows that the stable matching is unique, and gives an algorithm to compute it. Formally, we set max ∅ = −∞ and define σ : I → I ∪ {−∞} recursively by setting where we use the notation σ(A) = {σ(a) : a ∈ A}. It follows by induction on i that σ is the unique stable matching of G. Now suppose that G = K I,I (p). Then the probability that σ(−i) = −∞ given σ(0), . . . , σ(−i + 1) is equal to the probability that (−i, ♂) is compatible with (k, ♀) for some k in the set If I is infinite, then A i is infinite for every i, and we deduce that σ(−i) = −∞ for every i ≥ 0 almost surely. Otherwise, |I| = n for some n ≥ 0. In this case, on the event that σ(−j) = −∞ for all 0 ≤ j < i, the set A i has cardinality n − i. It follows that Thus, the probability that the unique stable matching is perfect is given by We next show that if I is finite, then the conditional distribution of the unique stable matching σ of K I,I (p) given that it is perfect is equal to Mal I q . Fix a permutation τ of I. We wish to show that the probability that σ = τ is proportional to q inv(τ ) . By the recursive formula for σ given above, we have that for all 1 ≤ i ≤ n, Taking the product of these conditional probabilities and observing that Note that this yields a proof of the well-known formula Now suppose that I = (−∞, 0], and let σ be the unique stable matching of K I,I (p), which is almost surely perfect. It remains to prove that σ is the Mallows permutation of I as defined by Gnedin and Olshanki [10,11]. That is, we must prove that the law of σ is equal to the weak limit of the Mallows measures on permutations of I n = [−n, 0] as n → ∞, i.e., that for every k ≥ 1 and x 1 , . . . , x k ∈ I. In fact, we will obtain as a corollary a new proof that this weak limit exists, recovering the result of [10]. For each n ≥ 0, let σ n be the unique stable matching of K In,In (p) and observe that, by the above algorithm, Observe that for every n ≥ 1, every k ≤ n and every x 1 , . . . , x k ∈ I, we have that, by a similar analysis to above, Thus, we have that The ratio of products at the end of the right-hand side tends to one as n → ∞ when k is fixed, and so we obtain that (4) holds as desired.
Remark. The proof of convergence shows that the restriction of σ n to [−k, 0] is close to the infinite Mallows permutation not just for fixed k as needed, but even if k, n → ∞ jointly, as long as n − k → ∞.
3. Cuts, coupling, and the existence of the tame stable matchings In this section we prove Proposition 7, below, which generalizes (1) from the introduction. We then use this proposition to prove the existential claims from Theorem 3. We begin by proving a special case of Proposition 5, applying to intervals that are bounded from above. Proposition 5 will later follow by an easy limiting argument. Besides being of independent interest, the proof of Proposition 6 will serve as a warm-up to the proof of Proposition 7. We will then apply Proposition 7 to prove Corollary 9 and Corollary 10, which establish the existential claims of Theorem 3. Proposition 7 will also be used in the following section to prove Theorem 2 and complete the proof of Theorem 3. Proposition 6. Let q ∈ [0, 1), let I be an infinite interval that is bounded from above, and let σ be a random permutation of I drawn from the Mallows distribution with parameter q. Then the process 1 i + 1 2 is a cut for σ i∈I stochastically dominates an i.i.d. Bernoulli process with parameter (1 − q)(q) ∞ .
Before beginning the proof of Proposition 6, we note that, by re-indexing, Proposition 1 also implies that for every p ∈ (0, 1] and every two non-empty sets A, B ⊆ Z with |A| = |B|, both of which are bounded above, there is a unique stable matching of K A,B (p), which we denote by σ A,B . Moreover, again by re-indexing and applying Proposition 1, the stable matching σ A,B is perfect almost surely if A is infinite, and with probability Proof. We assume without loss of generality that I = (−∞, −1]. We define a sequence of partial matchings σ n : It suffices to prove that P −n − 3 2 is a cut for σ | σ n ≥ (1 − q)(q) ∞ . In fact we will prove the equality where U n is the number of males who are among the n most attractive (i.e., are in [−n, −1] × {♂}) and are unmatched in the partial matching σ n . Note that −n − 3 2 is a cut for σ if and only if U n+1 = 0.
First, the most attractive male queries his compatibility with each of the n most attractive females, i.e., each female in [−n, −1] × {♀}. If he finds he is not compatible with any of them, then we stop the procedure and do not match anyone. Otherwise, he is matched to the most attractive of these females with whom he is compatible. In this case, the second most attractive male queries his compatibility with each of the n most attractive females. If he is not compatible with any of these females other than the one that is already matched, we stop the procedure and do not match any males other than the most attractive one. Otherwise, we match the second most attractive male to the most attractive of these females with whom he is compatible and who is not already matched. We continue this procedure recursively, finding matches for the males in order of attractiveness until we reach a male who cannot be matched, at which point we stop. Let F n be the σ-algebra generated by all the information concerning compatibility that is revealed when computing σ n via this procedure. Now suppose that we wish to compute σ n+1 , given σ n and the σ-algebra F n . We know that the most attractive male who is unmatched in σ n is not compatible with any of the females in [−n, −1] × {♀} who are unmatched in σ n . Other than this, the only information we have about compatibility concerns pairs of males and females at least one of whom is already matched in σ n , and this information is no longer relevant for computing σ n+1 .
Thus, to compute σ n+1 , we use the following procedure, illustrated in Figure 6. First, the most attractive male who is unmatched in σ n queries his compatibility with (−n − 1, ♀), who is always unmatched in σ n . If he finds he is not compatible with her, we set σ n+1 = σ n and stop. Otherwise, he finds he is compatible with her. This occurs with probability p = 1 − q independently of everything that has happened previously. If this is the case, we then try to match the remaining U n unmatched males with the remaining U n unmatched females. Since no information concerning compatibility between any of these individuals has been revealed, we can re-index and apply Lemma 8 to deduce that the conditional probability that the stable matching between them is perfect is equal to |Un| k=1 (1 − q k ). It follows that and the equality (5) follows by taking the conditional expectation over F n given σ n .
Remark. In the sampling algorithm used above, the information concerning compatibilities that is revealed when computing σ n+1 given σ n and F n is precisely F n+1 . In fact, (U n ) n≥0 is a Markov chain with the filtration F n , and (5) gives the probability of jumping to 0. The associated Markov chain is positive recurrent by the above proposition, and a stationary Z-indexed Markov process with the same transition rule can be used to sample the Mallows permutation of Z.
We now come to the main technical result of this section. We say that a set A ⊆ Z is low if it is bounded from above and its complement Z \ A is bounded from below (equivalently, if its symmetric difference with (−∞, 0] is finite). For each low set A, we define r(A) to be the largest integer such that (−∞, r] ⊆ A. In particular, if σ is a locally finite matching then the set By re-indexing, it follows from Proposition 1 that for any two low sets A, B ⊆ Z, there is almost surely a unique stable matching of K A,B (p), which we denote σ A,B , and which is perfect almost surely. Since there are only countably many low sets, this holds for all low sets simultaneously almost surely. We say that a pair of low sets A and B is balanced if |A \ B| = |B \ A|. Note this condition is equivalent to |A ∩ [−n, ∞)| = |B ∩ [−n, ∞)| for all sufficiently large n, or indeed for all n ≥ r(A) ∧ r(B). Proposition 7. Let p = 1 − q ∈ (0, 1] and consider K Z,Z (p). For ∈ {1, 2} let (A , B ) be a pair of balanced low subsets of Z, set r = r(A ) ∧ r(B ), and set σ = σ A ,B , the unique stable matching of K A ,B (p). Then ∞ n for every n ≥ 0. In particular, σ 1 (−i) = σ 2 (−i) for all sufficiently large i almost surely.
We remark that one may deduce a similar result (with a worse constant) from Proposition 5 via a finite-energy argument.
Our proof of Proposition 7 will use the following simple correlation inequality. (1 − q k ).
In other words, the perfection of the stable matching of different pairs of sets are positively correlated events. Note that these events are not increasing with respect to the compatibility graph, so that the claimed positive correlation does not follow from the FKG inequality.
First suppose that i is in exactly one of A or A ; without loss of generality we may assume that i ∈ A \ A . As in the proof of Proposition 1, the male (i, ♂) must be matched in σ A,B to the most attractive female he is compatible with in B × {♀}, and the probability that there is at least one such compatible female is 1 − q |A| . Note that on the event that (i, ♂) is matched to (j, ♀) in σ A,B we have that σ A,B (k) = σ A\{i},B\{j} (k) for every k ∈ A \ {i}. Note also that the only information required to compute σ A,B (i) concerns compatibility information between (i, ♂) and Z × {♀}, and that, given σ A,B (i) = j, this information is no longer relevant for computing either σ A\{i},B\{j} or σ A ,B . Thus, it follows by the induction hypothesis that for every j ∈ B, P σ A,B and σ A ,B are both perfect | σ A,B (i) = j = P σ A\{j},B\{i} and σ A ,B are both perfect The result now follows since P(σ A,B (i) = j for some j ∈ B) = 1 − q |A| . Now suppose that i ∈ A ∩ A . In order for σ A,B and σ A ,B both to be perfect, (i, ♂) must be compatible with both a female from B × {♀} and a female from B × {♀}, with these two females possibly being the same. The probability of the required females existing is Arguing similarly to the previous case, we have that P σ A,B and σ A ,B are both perfect | σ A,B (i) = j, σ A ,B (i) = j = P σ A\{j},B\{i} and σ A \{i},B \{j } are both perfect for every j ∈ B and j ∈ B such that the event being conditioned on has positive probability, and the claim follows from the induction hypothesis together with (7).
We remark that the same argument also yields analogous inequalities for more than two pairs.
Proof of Proposition 7. We may assume without loss of generality that r 1 ∧ r 2 = 0. The proof is an elaboration of the proof of Proposition 6, and we omit some minor details. First, observe that if i ≥ 0 and −i + 1 2 is a cut for both σ 1 and σ 2 , then the restrictions of σ 1 and σ 2 to (−∞, −i] both define stable matchings of K (−∞,−i],(−∞,−i] (p), and hence are equal by Proposition 1. Thus, it suffices to prove that P ∃i ∈ [1, n] such that −i + 1 2 is a cut for both σ 1 and We perform a similar sampling procedure to that used in the proof of Proposition 5. For both ∈ {1, 2}, we define a sequence of partial matchings σ ,n : A → B ∩[−n, ∞)∪{−∞} for n ≥ −1 by setting σ ,n (i) = σ (i) if the following three conditions hold for i ∈ A , and otherwise σ ,n (i) = −∞.
It suffices to prove that P −n − 3 2 is a cut for both σ 1 and σ 2 | σ 1,n , σ 2,n ≥ (1 − q)(q) 2 ∞ for every n ≥ −1. We will prove the stronger bound P −n − 3 2 is a cut for both σ 1 and σ 2 | σ 1,n , σ 2,n ≥ (1 − q) Similarly to the proof of Proposition 5, we try to match the males in (A 1 ∪ A 2 ) × {♂} in order of attractiveness. At each step, we may need to find them a match in either σ 1,n , σ 2,n , or both, according to whether they are in A 1 × {♂}, A 2 × {♂}, or both. If we reach a male for whom we cannot find both the required matches, we stop. If that male can be matched in one of σ 1,n , σ 2,n but not the other, we make the single match, and stop. During this procedure, the information revealed can be described as follows: Thus, to compute σ 1,n+1 and σ 2,n+1 given σ 1,n and σ 2,n , we may do the following. First, the most attractive male who is unmatched in either σ 1,n or σ 2,n queries his compatibility with (−n − 1, ♀). If he finds he is not compatible with her, we set σ 1,n+1 = σ 1,n and σ 2,n+1 = σ 2,n and stop. Otherwise, he finds he is compatible with her. This occurs with probability p = 1−q independently of everything that has happened previously. If this is the case, we match him to her in whichever of the matchings σ 1,n and/or σ 2,n that he was previously unmatched in. Call these updated matchings σ 1,n and σ 2,n .
At this point, the number of remaining unmatched males (and females) in σ ,n is either U ,n or U ,n + 1, and no information about their compatibility has been revealed so far. Thus, by Lemma 8, the conditional probability that all the unmatched individuals in σ 1,n and in σ 2,n both support a perfect stable matching is at least Thus the conditional probability that −n − 3 2 is a cut for both σ 1 , σ 2 is at least (1 − q)(q) 2 ∞ , and the claim follows.
The final part of the proposition follows by continuity of measure. Corollary 9 (Existence of limit matchings). Let p ∈ (0, 1]. Let n ∈ Z, and for each m ≥ 0 let σ n,m be the unique stable matching of K (−∞,m+n],(−∞,m] (p). Then σ m,n converges almost surely as m → ∞ to a permutation σ n of Z, and the limit is distributed as the composition of the Mallows permutation of Z with the shift θ n : i → i + n.
Proof. It suffices to consider the case n = 0, as the others then follow by re-indexing. We write σ m = σ 0,m . For each k ∈ Z, it follows from Proposition 7 that m>k P σ m (k) = σ m+1 (k) < ∞.
It follows by Borel-Cantelli that σ m almost surely converges pointwise to a function σ : Z → Z. By symmetry, the inverse functions σ −1 m also almost surely converge pointwise to a function σ −1 : Z → Z.
, it follows that σ −1 (σ(i)) = σ(σ −1 (i)) = i for every i ∈ Z, so that σ is a permutation almost surely. The fact that σ is Mallows-distributed with parameter q, and in particular that the limit defining this permutation exists, follows from the corresponding statement for σ m , proven in Proposition 1.
Proof of Proposition 5. This follows from Proposition 6 and Corollary 9, by taking the result through to the limit.
We call the matching σ n from Corollary 9 the Mallows matching of K Z,Z (p) with flow n.
Corollary 10 (Mallows matchings are tame). Let q ∈ [0, 1), and let σ be a random permutation of Z drawn from the Mallows distribution with parameter q. Then almost surely the composition of σ with the shift θ n : i → i + n is tame for all n.
Proof. Tameness is clearly invariant to composition with a shift, so it suffices to consider the case n = 0. Observe that if (T i + 1 2 ) i∈Z are the sequence of cuts of σ in order, then for every i ∈ Z max M (σ, j + 1 2 ) : Thus, if σ is the Mallows permutation of Z, then it follows from Proposition 5 that P M (σ, i + 1 2 ) ≥ 2m ≤ c 1 (q) m for some c 1 (q) < 1. It follows by Borel-Cantelli that M (σ, i + 1 2 ) = O(log |i|) almost surely, so that σ is tame as claimed.
We also have the following immediate corollaries of Proposition 7, showing that every perfect locally finite matching is "tame towards −∞". Corollary 11. Let p ∈ (0, 1] and consider K Z,Z (p). Almost surely, every perfect, locally finite, balanced stable matching σ of K Z,Z (p) has a cut.
Corollary 12. Let p ∈ (0, 1] and consider K Z,Z (p). Then the following holds almost surely. For every perfect, locally finite stable matching σ of K Z,Z (p) with flow n, there exists N σ such that σ(−i) = σ n (−i) for every i ≥ N σ , where σ n is the Mallows matching of K Z,Z (p) with flow n.
Finally, let us note that Theorem 2 is sharp in the sense that, disregarding constants, the definition of tameness cannot be strengthened. Proof. For each i ∈ Z, let X i = min{|i − j| : (j, ♀) is compatible with (i, ♂)}. Then the random variables X i are i.i.d. with P(X i ≥ n) = q 2n−1 for all n ≥ 1. Thus, for all a > 0 and for all i ≥ e 1/a we have that When a −1 = 2 log q −1 , the latter expression has infinite sum (over i ≥ e 1/a ) and thus by the Borel-Cantelli Lemma X i ≥ a log |i| infinitely often, almost surely. The claim follows since M (σ, i

The dichotomy between tame and wild
In this section we complete the proof of Theorems 2 and 3. The central additional ingredients required are the following two lemmas concerned with perfect, locally finite stable matchings.
Lemma 14. Let p ∈ (0, 1], let q = 1 − p, and consider the random bipartite graph K Z,Z (p). There exists a positive constant c 2 (q) such that the following holds almost surely: Every perfect, locally finite stable matching σ of K Z,Z (p) satisfying is equal to the Mallows stable matching of K Z,Z (p) with the same flow as σ. In particular, σ is tame if and only if (9) holds.
Lemma 15. Let p ∈ (0, 1], let q = 1 − p, and consider the random bipartite graph K Z,Z (p). Almost surely, every perfect, locally finite stable matching σ of K Z,Z (p) satisfying is wild. In particular, σ is wild if and only if (10) holds.
Before proving these lemmas, let us use them to prove Theorem 2 and Theorem 3.

Proof of Theorem 2.
Let Ω be the almost sure event that for every i ∈ Z, the sets {j : (j, ♀) compatible with (i, ♂)} and {j : (j, ♂) compatible with (i, ♀)} are both unbounded below. We claim that every locally finite stable matching of K Z,Z (p) is perfect on the event Ω. Indeed, suppose without loss of generality that (i, ♂) is unmatched in some stable matching σ of K Z,Z (p). Then each element of the set {j : (j, ♀) compatible with (i, ♂)} must be matched to a male more attractive than (i, ♂), and thus σ is not locally finite. The remaining claims of the theorem follow from Lemmas 14 and 15, since at least one of (9) or (10) must hold for every σ.
Proof of Theorem 3. The fact that a tame stable matching of flow n exists almost surely for each n follows from follows from Corollaries 9 and 10, while the fact that the matching is unique and can be described as the limit of the unique stable matchings σ n,m of K (−∞,m],(−∞,m+n] (p) as m → ∞ follows from Lemma 14. Given this limiting construction, Theorem 3.iii follows from Proposition 1.
For Theorem 3.iv, fix m ≥ 0 and n ∈ Z. Let (i k ) k≥0 and (j k ) k≥1 be decreasing sequences defined recursively by i 0 = m + n + 1, j k = σ −1 m,n+1 (i k−1 ) for every k ≥ 0 and i k = σ m,n (j k ) for every k ≥ 1. Considering the gender-reversal of the recursive procedure for computing σ m,n and σ m,n+1 as in the proof of Proposition 1, beginning by assigning matches to the most attractive females in (−∞, m + n] and (−∞, m + n + 1] respectively, it follows by a straightforward induction argument that σ −1 m,n (i) otherwise and similarly that The second part of Theorem 3.iv follows by taking the limit as m → ∞. The first part follows from the second, since if for each n males do no worse in σ n+1 than in σ n , then the same comparison holds for any σ n , σ n .
Proof of Lemma 14. By re-indexing, it suffices to consider the balanced case of flow 0. Let 0 < a < 1, and let A i,a be the set of low subsets A of Z such that the pair of low sets ((−∞, i], A) is balanced, and the symmetric difference where c 1 (q) = 1 − (1 − q)(q) 2 ∞ . Thus, it follows by the union bound that For any such matching, σ((−∞, i]) belongs to A i,a for infinitely many i. However, on the event Ω a , the balanced Mallows stable matching of K Z,Z (p) is the only stable matching of K Z,Z (p) with this property, and so σ must be equal to this matching.
Proof of Lemma 15. By re-indexing it suffices to consider balanced stable matchings. Moreover, since by Corollary 11 there is a probability one event on which every perfect, locally finite, balanced stable matching of K Z,Z (p) has a cut, it suffices by re-indexing to consider matchings that have a cut at 1 2 . That is, it suffices to prove that there is a probability one event on which every perfect, locally finite, balanced stable matching σ of K Z,Z (p) that has a cut at 1/2 and satisfies lim inf Figure 7. Exponential blow-up in wild matchings. Edges whose length is linear in their height necessitate edges whose length is exponential in their height (with high probability as the height goes to infinity).
is wild. For ε, δ > 0, define Ω ε,δ to be the event on which there exists N < ∞ such that the following conditions hold for all i ≥ N . We claim that for each ε > 0, there exists δ(ε, q) > 0 such that Ω ε,δ occurs almost surely. Indeed, for condition (i), the Chernoff bound implies that there exists a constant c 3 (ε, q) < 1 such that for each i, k ≥ 0, the probability that either of the sets in question is smaller than (1 − q)εi/2 is at most c 3 (ε, q) i . Thus, summing over the possible choices of k and i and applying Borel-Cantelli shows that if δ is sufficiently small then the required inequalities hold for all i sufficiently large almost surely. where we have used the elementary inequality m n ≤ m n . If δ is sufficiently small then C(ε, δ) < 0, and the result follows by Borel-Cantelli. This completes the proof of the claim. Now suppose that the almost sure event Ω = n≥1 Ω 1/n,δ(1/n) occurs. Let σ be a stable perfect matching of K Z,Z (p) that is balanced and has a cut at 1 2 , let n ≥ 2 be such that ε = 1/n < 1 2 lim inf M (σ, i + 1/2)/i, and let δ = δ(ε, q). For each a, b ≥ 0, we define the indicator functions We claim that if i ≥ N and F (i, i + εi) = 1, then we must have that F (i + εi, e δi ) = 1 also. Given this, it is easily seen that σ is wild: Indeed, our choice of ε guarantees that for every sufficiently large i there is an edge of length at least 2εi spanning i, so that at least one of F (i, i + εi) or F (i − εi, i) is equal to 1 for every sufficiently large i. In the first case we have that F (i + εi, e δi ) = 1 and in the second we have that F (i, e δ(i−εi) ) = 1. In either case we deduce that M (σ, 2i + 1/2) ≥ e δi/2 , concluding the proof.
To prove the claim above, let k = εi , and suppose that F (i, i + k) = 1. By symmetry between males and females, let us suppose without loss of generality that some j ≤ i has σ(j) > i + k. If σ(j) > e δi , we are done. Otherwise, let V be the set of males in (i, i + k] × {♂} that are compatible with σ(j). By (i) we have that |V | ≥ 1−q 2 k. Note that each male (a, ♂) ∈ V must have σ(a) > σ(j), since otherwise σ would be unstable. Moreover, if any a ∈ V has σ(a) > e δi we are done, so we may suppose not.
Since σ is balanced and has a cut at 1/2, there is a set W ⊆ [1, i + k] of size at least k such that σ −1 (w) > i for every w ∈ W . If any w ∈ W has σ −1 (w) > e δi , we are done, so suppose not. Since each female in W × {♀} is less attractive than σ(j) and is matched to a male more attractive than (j, ♂), stability implies that they cannot be matched to any male in V × {♂}. It follows that there is a set W ⊂ W of females of size at least |V | that are matched to males in (i + k, e δi ] × {♂}. Remark. It is possible to show using the above proof that for every p = 1 − q ∈ (0, 1), there exists a positive constant c 3 (q) such that for every wild stable matching of K Z,Z (p) almost surely.

Existence of wild stable matchings
Proof of Theorem 4. For a finite set A ⊂ Z and for an integer i ∈ Z \ A, let Ω A,i be the event that both of the sets j ∈ Z : (j, ♀) is compatible with (i, ♂) but not (k, ♂) for any k ∈ A and j ∈ Z : (j, ♂) is compatible with (i, ♀) but not (k, ♀) for any k ∈ A are unbounded from above. Clearly P(Ω A,i ) = 1 for all A and i. Since there are only a countable number of finite subsets of Z, the event Ω = {Ω A,i : A finite subset of Z, i ∈ Z \ A} also has probability 1. We will show that the conclusions of the theorem hold on Ω. All three claims will follow from variants of the same construction. Let (x n ) n≥0 be an enumeration of a subset of Z × {♂, ♀} (representing individuals to be matched in a given order), and let (a j ) j≥1 be a sequence of positive integers (which will encode uncountably many options). We take the enumerated subset to be one of the following: These three choices are used to construct matchings that are respectively: not perfect; perfect but not locally finite; and perfect, locally finite, and wild. For each fixed sequence (x n ) n≥0 , every choice of the sequence (a j ) j≥1 will yield a different stable matching with this desired properties.
At each step of the construction, we choose the next individual in the sequence, and if they are not already matched, we find a compatible partner for them who is incompatible with everyone previously matched. At the end of step n ≥ 0 of the construction, we have a partial matching σ n with the property that the vertices x 1 , . . . , x n are all matched, and that σ n is a stable perfect matching of the subgraph induced by the set of all matched vertices.
Initially we take σ 0 to be the empty matching. Given σ n for some n ≥ 0, we define σ n+1 as follows.
• If x n+1 is already matched in σ n then we set σ n+1 = σ n . (That is, we do nothing.) • If x n+1 is not matched in σ n , then we choose a partner for it as follows. Suppose x n+1 is a female (the case of a male x n+1 is similar). We will match (x n+1 , ♀) to a male in the set S × {♂}, where S =      k ≥ 0 : (k, ♂) is more attractive than any male that has already been matched, is compatible with x n+1 , and is not compatible with any female that is matched in σ n      .
(We take k ≥ 0 so that S is bounded from below.) On Ω, the set S is unbounded from above. If σ n has j edges, we match (x n+1 , ♀) to the a j+1 -th least attractive male in S × {♂}.
Let σ = lim σ n . As a result, the following hold.
• If (x i ) i≥0 is an enumeration of A = (Z×{♂})∪([0, ∞)×{♀}), then σ is a perfect matching of A, with (−∞, −1] × {♀} left unmatched. Such a matching must also be a stable matching of K Z,Z (p), since every male in the matching prefers their partner to every female in (−∞, −1]. • If (x i ) i≥0 is an enumeration of Z × {♂, ♀}, taking the limit as n → ∞ we obtain a perfect stable matching of K Z,Z (p). The construction ensures that for every k > 0, the partner of (−k, ♀) belongs to [0, ∞) × {♂}, so that σ is not locally finite. , we obtain a stable perfect matching of K Z,Z (p) with a cut at − 1 2 , which must be balanced.
It is clear that, in each case, different sequences (a n ) yield different matchings σ. Indeed, at the first place two sequences differ, the edge added to the matchings will also differ. In the last case (locally finite matchings) we have not ruled out that σ is the unique balanced, tame stable matching. However, excluding this matching still leaves uncountably many locally finite, balanced, wild stable matchings. Similar statements for other values of the flow follow by re-indexing.
Finally, note that in the third case, the restrictions to K [0,∞),[0,∞) (p) of the matchings that we obtain are stable and perfect, and by re-indexing we obtain that K I,I (p) has uncountably many wild stable matchings almost surely for every infinite interval I that is bounded from below.
Finally, we show that Theorem 2 is sharp in the sense that, disregarding constants, the definition of wildness cannot be strengthened.
Proposition 16. Let p = 1 − q ∈ (0, 1) and consider the random bipartite graph K Z,Z (p). Then there almost surely exists a perfect, locally finite, wild stable matching of K Z,Z (p) such that Proof. Let (x i ) i≥1 be the enumeration of [1, ∞) × {♂, ♀} given by x 2i−1 = (i, ♂) and x 2i = (i, ♀) for every i ≥ 1. As in the proof of Theorem 4, we define a sequence of partial matchings (σ n ) n≥0 as follows. Let σ 0 be the unique stable perfect matching of K (−∞,0],(−∞,0] . Having defined σ n , if x n+1 is matched in σ n then σ n+1 = σ n . If x n+1 is not matched in σ n , let σ n+1 be obtained from σ n by matching x n to the least attractive member of the opposite gender that is compatible with x n+1 , is strictly more attractive than every individual (of either gender) that is already matched in σ n , and is incompatible with every individual of the same gender as x n+1 that has positive index and is already matched in σ n . As before, we obtain a locally finite stable perfect matching σ of K Z,Z (p) by taking the limit as n → ∞.
We wish to verify that this matching σ satisfies (12). For each n ≥ 0, let H n be the index of the most attractive individual (of either gender) that is already matched in σ n . For each n ≥ 1, let N n be the number of individuals of positive index that are of the same gender as x n and already matched in σ n−1 , and note that (n − 1)/2 ≤ N n ≤ n − 1. Then, conditional on σ n , we either have that x n+1 is already matched in σ n in which case H n+1 − H n = 0, or else H n+1 − H n − 1 is conditionally distributed as a geometric random variable with success probability pq n ≤ pq N n+1 ≤ pq n/2 . In particular, it follows that H n+1 − H n ≥ p −1 q − n/2 for infinitely many n almost surely, which clearly implies that σ is not tame and is therefore wild almost surely by Theorem 2. On the other hand, it also follows that