 # A Simply Exponential Upper Bound on the Maximum Number of Stable Matchings

Stable matching is a classical combinatorial problem that has been the subject of intense theoretical and empirical study since its introduction in 1962 in a seminal paper by Gale and Shapley. In this paper, we provide a new upper bound on f(n), the maximum number of stable matchings that a stable matching instance with n men and n women can have. It has been a long-standing open problem to understand the asymptotic behavior of f(n) as n→∞, first posed by Donald Knuth in the 1970s. Until now the best lower bound was approximately 2.28^n, and the best upper bound was 2^n n- O(n). In this paper, we show that for all n, f(n) ≤ c^n for some universal constant c. This matches the lower bound up to the base of the exponent. Our proof is based on a reduction to counting the number of downsets of a family of posets that we call "mixing". The latter might be of independent interest.

## Authors

##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Introduction

Stable matching is a classical combinatorial problem that has been the subject of intense theoretical and empirical study since its introduction in a seminal paper by Gale and Shapley in 1962 [GS62]. Variants of the algorithm introduced in [GS62] are widely used in practice, e.g. to match medical residents to hospitals. Stable matching is even the focus of the 2012 Nobel Prize in Economics [Ram12].

A stable matching instance with men and women is defined by a set of preference lists, one per person. Person ’s preference list gives a ranking over members of the opposite sex. The Stable Matching Problem is to find a matching (i.e., a bijection) between the men and the women that is stable, that is, has no blocking pairs. A man and a woman form a blocking pair in a matching if they are not matched to each other, but both prefer the other to their partner in the matching. Gale and Shapley [GS62] showed that a stable matching always exists and gave an efficient algorithm to find one.111Stable matching algorithms were actually developed and used as early as 1951 to match interns to hospitals [Sta53]. Since at least one stable matching always exists, a natural question is to determine the maximum number of stable matchings an instance of a given size can have. This problem was posed in the 1970s in a monograph by Knuth [Knu76], and was the first of Gusfield and Irving’s twelve open problems in their 1989 textbook [GI89]. We denote the maximum number of stable matchings an instance with men and women can have by .

Progress on determining the asymptotics of has been somewhat slow. The best lower bound is approximately , and the best upper bound prior to this paper was . See the related work section for a detailed history.

In this paper, we present an improved upper bound.

###### Theorem 1.1.

There is a universal constant such that , the number of stable matchings in an instance with men and women, is at most .

To prove this theorem, we use a result due to Irving and Leather [IL86] that shows that there is a bijection between the stable matchings of an instance and the downsets222See section 2 for definitions of all the relevant terminology. of a particular partially-ordered set (poset) associated with known as the rotation poset. We show that the rotation poset associated with a stable matching instance has a particular property that we call -mixing, and that any poset with this property has at most downsets. All the steps in our proof are elementary.

The bound extends trivially to stable roommates instances. In the stable roommates problem, a set of agents rank the other agents in the set. The agents are paired off into roommate pairs, which are stable if no two agents would like to leave their partners and be matched to each other. A construction of Dean and Munshi [DM10], demonstrates that a stable roommates instance with agents can be converted into a stable matching instance with men and women, such that the stable roommate assignments correspond to a subset of the stable matchings in the new instance. Using this construction, we can apply our upper bound to Stable Roommates.

###### Theorem 1.2.

There is a universal constant , such that the number of stable assignments in a stable roommate instance with agents is at most .

### 1.1 Related Work

#### Lower bounds:

It is trivial to provide instances with stable matchings by combining disjoint instances of size 2. Irving and Leather constructed a family of instances [IL86] which has since been shown by Knuth333Personal communication, as described in [GI89]. to contain at least matchings. Irving and Leather’s family only has instances for which is a power of . Benjamin, Converse, and Krieger also provided a lower bound on by creating a family of instances with matchings [BCK95]. While this is fewer matchings than the instances in [IL86], Benjamin et al.’s family has instances for every even , not just powers of . In 2002, Thurber extended Irving and Leather’s lower bound to all values of . For powers of , Thurber’s construction exactly coincides with Irving and Leather’s. For all other , the construction produces a lower bound of for some constant [Thu02]. To date, this lower bound of is the best known. We refer the reader to Manlove’s textbook for a more thorough description of the history of these lower bounds [Man13].

#### Upper bounds:

Trivially, there are at most stable matchings (as there are at most bijections between the men and women). The first progress on upper bounds that we are aware of was made by Stathoupolos in his 2011 Master’s thesis [Sta11], where he proves that the number of stable matchings is at most for some constant . A more recent paper of Drgas-Burchardt and Świtalski shows a weaker upper bound of approximately [DBŚ13]. All previous upper bounds have the form .

#### Restricted preferences:

The number of possible stable matchings has also been studied under various models restricting or randomizing the allowable preference lists. If all preference lists are equally likely and selected independently for each agent, Pittel shows that the expected number of stable matchings is [Pit89]. Applying Markov’s Inequality shows that the number of stable matchings is polynomial in

with probability

. Therefore, the lower bound instances described above are a vanishingly small fraction of all instances. Work of Hoffman, Levy, and Mossel (described in Levy’s PhD thesis [Lev17]) shows that under a Mallows model [Mal57], where preference lists are selected with probability proportional to the number of inversions in the list, the number of stable matchings is with high probability (where the constant depends on the exact parameters of the model).

The number of attainable partners444 Woman is an attainable partner of man if there is a stable matching in which they are matched to each other. a person can have has also been the subject of much research. Knuth, Motwani, and Pittel show that the number of attainable partners is with high probability if the lists are uniformly random [KMP90]. Immorlica and Mahdian show that if agents on one side of the instance have random preference lists of length (and consider all other agents unacceptable) the expected number of agents with more than one attainable partner depends only on (and not on ) [IM05]. Ashlagi, Kanoria, and Leshno show that if the number of men and women is unbalanced, with uniformly random lists, the fraction of agents with more than one attainable partner is with high probability [AKL17].

#### Counting:

A natural computational problem is to count the number of stable matchings in a given instance as efficiently as possible. Irving and Leather show that finding the exact number of matchings is -complete [IL86], so finding an approximate count is a more realistic goal. Bhatnagar, Greenberg, and Randall consider instances where preference lists come from restricted models [BGR08]; for example, those in which the preference lists reflect linear combinations of “attributes” of the other set, or where every agent appears in a “range” of

consecutive positions in every preference list. In both of these cases, they show that a natural Markov Chain Monte Carlo approach does not produce a good approximation (as the chain does not mix efficiently). As part of their proof, they show the number of stable matchings can still be as large as

for some constant , even in these restricted cases.

A formal hardness result was later shown by Dyer, Goldberg, Greenhill, and Jerrum [DGGJ04]. They show approximately counting the number of stable matchings is equivalent to approximately counting for a class of problems, canonically represented by BIS.555More specifically, they show an FPRAS for the number of stable matchings exists if and only if one exists for BIS, approximately counting the number of independent sets in a bipartite graph. Goldberg and Jerrum conjecture that no such FPRAS exists [GJ12]. See [CGM12] for formal definitions. This hardness result was strengthened by Chebolu, Goldberg, and Martin [CGM12] to hold even if the instances come from some of the restricted classes of [BGR08].

The heart of all of these results is the rotation poset (originally developed in [IL86]), which we use and describe in section 4.

#### Stable matching in general:

See the books by Roth and Sotomayor [RS92], Gusfield and Irving [GI89], Manlove [Man13], and Knuth [Knu97] for more about the topic of stable matching. For many examples of stable matching in the real world, see [Rot15].

## 2 Preliminaries and main technical theorem

In this section, we review standard terminology regarding partially ordered sets, describe the key property of a poset we will use, and state our main technical theorem (Theorem 2.5).

###### Definition 2.1 (Poset).

A partially ordered set (or poset) , is defined by a set and a binary relation, , on satisfying:

• Antisymmetry: For all distinct if then , and

• Transitivity: for all if and then .

Two elements are comparable if or . They are incomparable otherwise.

If , we say is dominated by and dominates .

###### Definition 2.2 (Chain).

A set of elements is called a chain if each pair of elements in is comparable. In other words, for , a chain of length is a sequence of elements .

A set of elements is called an antichain if they are pairwise incomparable.

###### Definition 2.3 (Downset).

A downset of a partial order is an antichain and all elements dominated by some element of that antichain.

Observe that a downset is closed under . That is, for any downset , if and then .

The following is the key property of the posets associated with stable matching instances that we will use in the proof.

###### Definition 2.4 (n-mixing).

A poset is -mixing if there exist chains (not necessarily disjoint) such that

1. Every element of belongs to at least one chain, i.e., ,

2. For any , there are at least chains each containing an element of .

Observe that if a poset is formed by disjoint chains, each of length , it has about downsets, and could be arbitrarily bigger than . But such a poset is not mixing, since taking to be the set of elements on one of the chains violates property ii) of mixing. For an example of a mixing poset, see Figure 1. We can now state our main technical theorem.

###### Theorem 2.5.

There is a universal constant , such that if a poset is -mixing, then it has at most downsets.

Note that the -mixing property immediately implies that the poset has at most elements; just let in the above definition. A poset with elements covered by chains can have at most downsets (this is achieved for equal length chains). So, the main contribution of the above theorem is to improve this trivial upper bound to for some constant .

Theorem 2.5 is the main technical contribution of this work. The proof is contained in section 3. To complete the proof of Theorem 1.1 we use the following theorem relating mixing posets to stable matchings. theoremrotationReduction For every stable matching instance with a total of men and women, there exists an -mixing poset , called the rotation poset, such that the number of downsets of the poset is equal to the number of stable matchings of . Note that Theorem 2.5 and Theorem 2.5 immediately imply Theorem 1.1. We prove Theorem 2.5 in section 4, by combining existing observations about the rotation poset.

## 3 Proof of main technical theorem

In this section we prove Theorem 2.5. The proof proceeds by finding an element of the poset which dominates and is dominated by many elements. We then count downsets by considering those downsets that contain and those that do not. Since dominates and is dominated by many elements, the size of each remaining instance is significantly smaller, yielding the bound.

Formally, we say an element is -critical if it dominates elements and is dominated by elements. The key lemma is that there is always an -critical element.

###### Lemma 3.1.

Let be an -mixing poset with respect to chains , and define . For some universal constants and , there is an element such that is -critical as long as .

We prove 3.1 in subsection 3.1 via a counting argument.

In the rest of this section we prove Theorem 2.5 using 3.1. We bound the number of downsets by induction on .

Our base case is when . In this case, the number of downsets is maximized when the chains are all the same length, so we have an upper bound of .

For larger , first we identify a -critical element . The number of downsets containing is the number of downsets in the poset remaining after we delete and everything it dominates. Similarly, the number of downsets not containing is the number of downsets in the poset remaining after we delete and everything dominating . In both cases, the resulting poset is still -mixing, so we can induct. We call such a step (choosing a critical element) an iteration.

It remains to bound the number of downsets that this process enumerates. By the -mixing property, there are at most elements in the initial poset. We partition the iterations into phases, where in phase we reduce the size of the poset from elements to elements. By definition, in phase , . So, we can bound the number of iterations required in phase (call it ) by:

 c0(n2i+1)3/2ki>n22i+1.

Rearranging, we see that it suffices to choose . We continue until . Summing across all phases, the number of choices to make is at most

 √nc0logn∑i=02(i+1)/2<5nc0.

So, the algorithm enumerates at most downsets in the base case and it makes at most choices during the inductive process. Thus, the number of downsets is at most as required.

### 3.1 Proof of main technical lemma

Finally, we prove 3.1, i.e. we show that any -mixing poset contains a -critical element as long as . (Recall that .)

We make use of the standard graph representation of the partial order: In this graph there is a node for each element of the partial order, and a directed edge from to if . Of course, this directed graph is acyclic. Henceforth, we refer only to this DAG rather than to the poset and partition the nodes of the DAG into levels as follows: Level nodes are those with no outgoing edges, i.e., sinks of the DAG, and level nodes are those whose longest path to a sink (i.e., a level node) has exactly nodes. Note that each level is an antichain.

Next, we create disjoint subchains . The subchain will be a subset of the nodes in . We perform the assignment of nodes to subchains by processing up the DAG level by level. Initialize every subchain to be empty. For each node , consider the set of indices . Assign to the subchain for an index in which currently has the fewest nodes among those chains, i.e. , breaking ties arbitrarily. If is the node assigned to a subchain , then we say the height of is . By construction, the following properties hold:

(a) The ’s are chains, since .

(b) The ’s are disjoint.

(c) If has height , then dominates at least nodes in each of the subchains such that (i.e., ).

###### Claim 3.2.

Let be the set of nodes of height at least . Each node dominates at least nodes, for , where and are universal constants.

###### Proof.

Suppose that is at height and let be the nodes in of height through . By the mixing property, these nodes lie on at least chains . Moreover, by construction, on each subchain , at least nodes are dominated by some node in and hence are dominated by . Therefore, dominates at least nodes. ∎

Since the number of nodes in the DAG is , we conclude:

###### Corollary 3.3.

There is a set of strictly more than nodes, that each dominate nodes.

A symmetric argument in which subchains are built starting from the sources of the DAG shows that there is a set of strictly more than nodes that are dominated by nodes. Therefore, there is some node in the intersection of and . This is the -critical node we seek.

###### Remark 3.4.

A crude analysis shows that when .

## 4 Rotations and the rotation poset

In this section we present a key theorem of Irving and Leather [IL86] and show how it can be used to prove Theorem 2.5.

*

We begin with the definitions needed to prove Theorem 2.5.

###### Definition 4.1 (Rotation).

Let . A rotation is an ordered list of pairs

 ρ=((m0,w0),(m1,w1),…,(mk−1,wk−1))

that are matched in some stable matching with the property that for every such that , woman (where the subscript is taken mod ) is the highest ranked woman on ’s preference list satisfying:

1. man prefers to , and

2. woman prefers to .

In this case, we say is exposed in .

We will sometimes abuse notation and think of a rotation as the set containing those pairs. Also, we will need the following facts about rotations later.

###### Lemma 4.2 ([Il86, Lemma 4.7]).

A pair can appear in at most one rotation.

###### Lemma 4.3 ([Gi89, Lemma 2.5.1]).

If is a rotation with consecutive pairs and , and is a woman between and in ’s preference list, then there is no stable matching containing the pair .

###### Definition 4.4 (Elimination of a Rotation).

Let be a rotation exposed in stable matching . The rotation is eliminated from by matching to , for all , leaving all other pairs in unchanged, i.e., matching is replaced with matching , where

 M′ :=M∖ρ ∪ {(m0,w1),(m1,w2),…,(mk−1,w0)}.

Note that when we eliminate a rotation from , the resulting matching is stable.666Switching from to makes all the women in happier and all the men in less happy. It is easy to check that this switch cannot create a blocking pair inside the set . The only other possibility for a blocking pair is a man in with a woman outside . For to become a blocking pair, would have to prefer to , but by the definition of rotation, was the first woman on ’s list who would prefer to be matched to him, so he cannot prefer to . See also [GI89, Lemma 2.5.2].

Irving and Leather studied the following process: Fix a stable matching instance . Starting at the man-optimal matching777 A fascinating fact about stable matching is that there is a matching, known as the man-optimal matching, in which each man is matched with his favorite attainable partner. Recall that woman is attainable for man if there is some stable matching in which they are matched., choose a rotation in the current matching, and eliminate it. They show that for any stable matching , there is a set of rotations, , one can eliminate (starting from the man-optimal matching) that will yield .

However, there is a partial order on the set of rotations – some must be eliminated before others.888For example, a rotation containing a pair is not exposed (and thus cannot be eliminated) until that pair is matched, so a rotation with consecutive pairs must be eliminated first. The details of exactly when one rotation must be eliminated before another are not of direct use to us (we only require the rather coarse description in 4.6), so we do not describe them here. See [IL86] or [GI89] for a full description of the poset. If must be eliminated before , we write . Let be the set of rotations for a stable matching instance, and let be that partial order on the rotations defined by elimination order. We call this poset the rotation poset. See Figure 2 for an example of a stable matching instance and the corresponding rotation poset.

For our purposes, the important result relating the rotation poset to stable matchings is the following.

###### Theorem 4.5 ([Il86, Theorem 4.1]).

For any stable matching instance, there is a one-to-one correspondence between downsets of the rotation poset and the set of stable matchings. In other words, the number of stable matchings is exactly equal to the number of downsets of .

Indeed, the downset corresponding to is exactly the set discussed above.

Thus, to prove Theorem 2.5, it remains to show that the rotation poset associated to any stable matching instance with a total of men and women is -mixing. First we construct the chains . We are going to have one chain for each agent (man or woman), where the corresponding chain contains all the rotations that include that agent. Call these sets . To prove that is -mixing, we first need to show that each is indeed a chain, i.e., every pair of rotations where a specific agent appears are comparable and second we need to show that satisfy property (ii) of 2.4.

###### Claim 4.6.

If two rotations share an agent, then they are comparable.999This observation is not novel; for example, it is implicit in the discussion of [GI89], but we have not seen the statement explicitly written down, so we prove it here.

###### Proof.

First, suppose that the shared agent is a man. If it is a woman, we can just switch the designations of “men” and “women” and use the same proof on the “reversed” version of the rotation graph. Let be rotations sharing an agent , and let be matched to in and in , where prefers to .

For the sake of contradiction assume that and are incomparable. We show that there exists a rotation which causes to skip over . This would contradict 4.3 as it implies that belongs to no stable matching.

Suppose we start from the man optimal stable matching and eliminate all rotations dominated by and let be the resulting stable matching. By the correspondence in Theorem 4.5, . Since prefers to , there must be a rotation that we eliminated which caused to be matched to someone worse than for the first time. Since and are incomparable, . Therefore, by 4.2 ; so, caused to skip over . This is a contradiction. ∎

###### Claim 4.7.

Every set of rotations contains at least agents.

###### Proof.

We argue by contrapositive. Suppose we have a set of rotations involving fewer than agents. Every rotation contains a (man, woman) pair, who (by 4.2) have not appeared together before. With fewer than agents, there are strictly less than (man, woman) pairs which can appear, and thus fewer than rotations in the set. ∎

## 5 Conclusion

We have shown there is some constant such that . We have not made a significant effort to optimize the constants in our argument, favoring ease of exposition over the exact result. By making a few minor changes to the argument, we obtain for sufficiently large . A more careful argument could probably improve this constant somewhat, but this approach will not get a constant close to the (approximately) we would need to match the best known lower bound. Determining the precise asymptotic behavior of remains an interesting open problem.

## Acknowledgements

The first author gratefully acknowledges the support of NSF grant CCF 1420381. The second author gratefully acknowledges the support of NSF grant CCF-1552097 and ONR-YIP grant N00014-17-1-2429. Figure 2: A size-8 instance of stable matching with its rotation poset. This is part of the family of instances described by Irving and Leather, which produces the Ω(2.28n) lower bound.

## References

• [AKL17] Itai Ashlagi, Yash Kanoria, and Jacob D Leshno. Unbalanced random matching markets: The stark effect of competition. Journal of Political Economy, 125(1):69–98, 2017.
• [BCK95] Arthur T Benjamin, Cherlyn Converse, and Henry A Krieger. How do I marry thee? Let me count the ways. Discrete Applied Mathematics, 59(3):285–292, 1995.
• [BGR08] Nayantara Bhatnagar, Sam Greenberg, and Dana Randall. Sampling stable marriages: why spouse-swapping won’t work. In Proceedings of the nineteenth annual ACM-SIAM symposium on Discrete algorithms, pages 1223–1232. Society for Industrial and Applied Mathematics, 2008.
• [CGM12] Prasad Chebolu, Leslie Ann Goldberg, and Russell Martin. The complexity of approximately counting stable matchings. Theoretical Computer Science, 437:35–68, 2012.
• [DBŚ13] Ewa Drgas-Burchardt and Zbigniew Świtalski. A number of stable matchings in models of the gale–shapley type. Discrete Applied Mathematics, 161(18):2932–2936, 2013.
• [DGGJ04] Martin Dyer, Leslie Ann Goldberg, Catherine Greenhill, and Mark Jerrum. The relative complexity of approximate counting problems. Algorithmica, 38(3):471–500, 2004.
• [DM10] Brian C Dean and Siddharth Munshi. Faster algorithms for stable allocation problems. Algorithmica, 58(1):59–81, 2010.
• [GI89] Dan Gusfield and Robert W Irving. The stable marriage problem: structure and algorithms. MIT press, 1989.
• [GJ12] Leslie Ann Goldberg and Mark Jerrum. Approximating the partition function of the ferromagnetic potts model. Journal of the ACM (JACM), 59(5):25, 2012.
• [GS62] David Gale and Lloyd S Shapley. College admissions and the stability of marriage. The American Mathematical Monthly, 69(1):9–15, 1962.
• [IL86] Robert W Irving and Paul Leather. The complexity of counting stable marriages. SIAM Journal on Computing, 15(3):655–667, 1986.
• [IM05] Nicole Immorlica and Mohammad Mahdian. Marriage, honesty, and stability. In Proceedings of the sixteenth annual ACM-SIAM symposium on Discrete algorithms, pages 53–62. Society for Industrial and Applied Mathematics, 2005.
• [KMP90] Donald E Knuth, Rajeev Motwani, and Boris Pittel. Stable husbands. Random Structures & Algorithms, 1(1):1–14, 1990.
• [Knu76] Donald Ervin Knuth. Mariages stables et leurs relations avec d’autres problèmes combinatoires: introduction à l’analyse mathématique des algorithmes. Montréal: Presses de l’Université de Montréal, 1976.
• [Knu97] Donald Ervin Knuth. Stable marriage and its relation to other combinatorial problems: An introduction to the mathematical analysis of algorithms, volume 10. American Mathematical Soc., 1997. English translation of Mariages stables.
• [Lev17] Avi Levi. Novel uses of the Mallows model in coloring and matching. PhD thesis, University of Washington, 2017.
• [Mal57] Colin L Mallows. Non-null ranking models. i. Biometrika, 44(1/2):114–130, 1957.
• [Man13] David F Manlove. Algorithmics of matching under preferences, volume 2. World Scientific, 2013.
• [Pit89] Boris Pittel. The average number of stable matchings. SIAM Journal on Discrete Mathematics, 2(4):530–549, 1989.
• [Ram12] Catherine Rampell. 2 From U.S. win Nobel in economics. The New York Times, October 15, 2012.
• [Rot15] Alvin E Roth. Who Gets What–and Why: The New Economics of Matchmaking and Market Design. Houghton Mifflin Harcourt, 2015.
• [RS92] Alvin E Roth and Marilda A Oliveira Sotomayor. Two-sided matching: A study in game-theoretic modeling and analysis. Cambridge University Press, 1992.
• [Sta53] John M Stalnaker. The matching program for intern placement. Academic Medicine, 28(11):13–19, 1953.
• [Sta11] Georgios K. Stathopoulos. Variants of stable marriage algorithms, complexity and structural properties. Master’s thesis, University of Athens, Department of Mathematics, 2011.
• [Thu02] Edward G Thurber. Concerning the maximum number of stable matchings in the stable marriage problem. Discrete Mathematics, 248(1-3):195–219, 2002.