Chapter 14

Two-sided Matchings: Stable Marriages

Let us now return to the marriage problem discussed in Section 6.4; we again consider a set X of n men, and a set Y of n women, but this time, instead of simply specifying whether a man–woman pair finds a marriage “acceptable,” we consider how desirable each party finds each potential partner: for any pair x X,y Y , let vx(y) denote how valuable x finds y, and let vy(x) denote how valuable y finds x. We are interested in the question of whether we can find a perfect matching between men and women where everyone is “happy” with the assignment—that is, can we find a set of “stable marriages.”

14.1  Two-sided Matching Problems

To formalize this, let us first define such a matching problem and the notion of an outcome of a two-sided matching problem.

Definition 14.1. We refer to the tuple Γ = (X,Y,v) where X,Y are finite sets such that |X| = |Y |, and vz : X Y for z X Y , as a two-sided matching problem. An outcome M of Γ is a perfect matching in the complete bipartite graph over X Y .

Note that a two-sided matching problem can be thought of as a variant of a matching market, but this time not only the nodes on “the left” (i.e., the buyers) have a valuation for the matching, but also the nodes on “the right” (i.e., the items in the matching market) have their own valuations—this is why these types of problems are called two-sided matching problems.

We now turn to defining a notion of stability of an outcome of a matching problem; the notion is similar to the notion of a market equilibrium, and the notion of stability for exchange networks, but this time without any prices. Roughly speaking, an outcome (i.e., a matching M) is stable if there does not exists a pair (x,y) that prefer each other to their current partners—such a pair is usually called a blocking pair. See Figure 14.1 for examples of stable and unstable matchings.

We turn to the formal definition.

Definition 14.2. An outcome M of a two-sided matching problem Γ = (X,Y,v) is stable if there does not exists x X,y Y such that vx(y) > vx(M(x)) and vy(x) > vy(M(y)).

Figure 14.1: An example of a stable (left) and an unstable (right) matching between four men and four women, whose preferences are indicated in the illustration. Notice, in the unstable matching, Charlie and Gloria constitute a “blocking pair”—they both prefer each other to their current partners; this instability is highlighted in red.

14.2  The Stable Marriage Theorem

The following theorem—referred as the stable marriage theorem—shows that every two-sided matching problem has a stable outcome. Furthermore, this stable matching can be efficiently found.

Theorem 14.1. A stable outcome M exists for every two-sided matching problem Γ = (X,Y,v). Additionally, there exists an efficient procedure that finds this outcome in polynomial time in |X|.

Proof. We present Gale–Shapley’s deferred acceptance algorithm (or simply, the DA algorithm) for finding a stable matching.

  • Initialize M to the “empty” matching: for all x X,y Y , M(x) = , M(y) = .
  • While there exists some man x that is unmatched (i.e., M(x) = ) do the following:
    •   Pick some unmatched man x. Let y be x’s preferred (according to vx) “attainable” woman (breaking ties in some arbitrary way), where y is attainable for x if y is currently unmatched (i.e., M(y) = ) or y prefers x to her current partner M(y) (i.e., vy(x) > vy(M(y))). (Such a woman must exist since the number of men and women are equal, and x is unmatched, so there must exist at least one unmatched woman.)
    •   If y was matched, break up y’s earlier “engagement”: if x = M(y), let M(x) = .
    •   Match x with y; let M(x) = y,M(y) = x. (Think of this as x and y getting “engaged.”)
  • Output M (note that by construction M is always one-to-one throughout the execution of the algorithm and thus M is always a matching).

See Figure 14.2 for an illustration of the execution of the DA algorithm. Note that if the algorithm ends, every man is matched to some (unique) woman, and thus also all the women get a match, since there are as many women as men. Thus, the final matching M is always a perfect matching.

Figure 14.2: The process of running the Deferred Acceptance Algorithm on the example from Figure 14.1. New proposals are indicated in green, existing engagements in black, and broken engagements in red.

Let us start by making a simple but useful observation:

Lemma 14.1. If a woman y is unattainable to a man x at some point in the execution of the algorithm, she will always remain so.

This lemma follows from the fact that a woman will only break an earlier engagement by “upgrading” to some man that she prefers over her current match.

We start by showing that the DA algorithm runs in polynomial time.

Claim 14.1. The DA algorithm ends within |X|2 iterations.

Proof. First note that by Lemma 14.1, a man x can never be engaged to the same woman y twice—the only reason an engagement is broken off is if y “upgrades” and thus she becomes unattainable to x (and by Lemma 14.1 remains so for the rest of the execution). As a consequence, each man can get engaged at most |Y | = |X| times; since there are |X| men, and one engagement must occur in every iteration, we conclude that the number of iterations is at most |X|2.

Since each iteration can be implemented in polynomial time in |X|, it follows that the DA algorithm always terminates within a polynomial (in |X|) number of steps. We next show that the matching output by the DA algorithm always is a stable matching.

Claim 14.2. The matching M output by the DA algorithm is stable.

Proof. Assume, for contradiction, that M is not stable; that is, there exists a blocking pair (x,y) for M such vx(y) > vx(M(x)) and vy(x) > vy(M(y)). That means that y is attainable to x, yet x is matched with some woman y = M(x) that he likes less than y. By Lemma 14.1, since y is attainable to x at the end of the execution, she must have been so throughout the execution. By construction of the algorithm, x must thus have been engaged to y at some earlier point since he would never have proposed to y before trying to propose to y first (and y would have accepted since she is attainable to him). But this engagement could never have gotten broken, since the only way it can break is if y no longer is attainable to x, which is a contradiction, and thus M must be stable.

This concludes the proof of Theorem 14.1.

The above-described DA algorithm is also called the “man-proposing” DA algorithm; we may also consider an alternative variant of it, called the “woman-proposing” DA algorithm, which is identically defined except that instead of having the men propose engagements (and the women accepting or rejecting them), we instead have the women propose (and men accept or reject). Subsequently, whenever we refer to the “DA algorithm,” we refer to the man-proposing DA algorithm.

14.3  Optimality of Stable Outcomes

We turn to analyzing the stable outcome computed by the DA algorithm. To simplify our treatment (and in accordance with much of the literature on matching), we restrict ourselves to the case when men and women have strict preferences over partners. Note that in this case, the DA algorithm only needs to take as input a profile of preferences μ over partners. More precisely, given a set of men X and set of women Y , a partner preference profile μ (over X,Y ) as a profile of preferences such that μi is a preference ordering over Y if i X and a preference ordering over X if i Y . Let 𝒱DA denote the DA mechanism taking a partner preference profile as input.

Note that in the case of strict preferences, to determine whether a matching M between X and Y is stable, it suffices to know the preferences of all players μ—we can thus refer to M being a stable matching between X,Y with respect to the partner preference profile μ.

We start by showing a surprising phenomenon: for the case of strict preferences, there always exists a stable outcome that is “optimal” for the men in the sense that every man x gets matched to his best “achievable” partner y, where a partner is achievable for x if there exists some stable matching where x gets matched to y.

Definition 14.3. Given a partner preference profile μ over X,Y , we say that y Y is achievable for x X (with respect to μ) if there exists some stable matching M with respect to μ such that (x,y) M.

Definition 14.4. Given a partner preference profile μ over X,Y , we say that a stable matching M is man-optimal with respect to μ if every man x X gets matched (with respect to M) with his most preferred (with respect to μx) achievable woman y Y (with respect to μ).

Note that man-optimal outcomes are always unique since when players have strict preferences, for every man there exists only one “most preferred” achievable woman, and this man must be matched to their most preferred achievable choice; that is, we have the following useful fact.

Fact 14.1. Given a partner preference profile μ over X,Y , there exists at most one man-optimal stable matching with respect to μ.

We now turn to showing that the outcome produced by the (man-proposing) DA algorithm is (the unique) man-optimal matching.

Theorem 14.2. For every partner preference profile μ, 𝒱DA(μ) outputs a man-optimal stable matching (with respect to μ).

Proof. Assume not; let x be the first man in the execution of the DA who is “rejected” by an achievable woman y (i.e., some achievable woman y is no longer available when it is x’s turn to get engaged). Since y rejected x, she must already be engaged to some man x that she prefers to x; additionally, since x was the first rejected man, y must either be x’s optimal achievable choice, or preferred to it—in other words, from the point of view of x, y dominates every achievable choice that is distinct from y.

Now, consider the stable matching M where x is matched with y (such a matching must exist, since y is achievable for x). Here, y clearly prefers to switch to x, and x also prefers to switch to y since y dominated every achievable choice that is distinct from y; this contradicts stability.

An interesting corollary of this result is that the order in which the men get to make engagement proposals have no relevance to the outcome—we always get the unique man-optimal outcome.

Obviously, by the same token, the woman-proposing DA would instead give a “woman-optimal” outcome; see Figure 14.3 for an illustration. There is, however, an inherent asymmetry (or “unfairness”) in the outcomes generated by the algorithm. Man-optimal solutions, although stable, are not that great for the women, and vice versa.

Definition 14.5. Given partner preference profile μ over X,Y , we say that a stable matching M is woman-pessimal with respect to μ if every woman y Y gets matched (with respect to M) with her least preferred achievable man x Y .

Theorem 14.3. Given partner preference profile μ over X,Y , a stable matching M is man-optimal with respect to μ if and only if it is woman-pessimal with respect to μ.

Proof. We separately show each direction.

“Only-if” direction Assume for contradiction that M is man-optimal, but not woman-pessimal; that is, there exists some woman y that is matched with some man x, but there exists some achievable man x that y likes less than x. Consider the stable matching M in which y is matched with the (less desirable) x (such a matching must exists since x is achievable for y). Let y denote the woman that x (i.e., y’s original partner) is matched with in M. Since M was man-optimal, x must strictly prefer y to y (by the assumption of strict preferences); and y strictly prefers x to x, thus M cannot be stable, which is a contradiction.

“If” direction The backward direction follows using a similar argument, except we now show that the original matching M cannot be stable. Assume for contradiction that M is woman-pessimal, but not man-optimal; that is, there exists some man x that is matched with some woman y, but there exists some achievable woman y that x likes more than y. Let x denote the man that y is matched with in M. Since M is woman-pessimal, y strictly prefers x to x (by the assumption of strict preferences); however, x strictly prefers y to y, and so M cannot be stable, which is a contradiction.

Thus, we see an interesting phenomenon: the order in which either the men or the women make proposals makes no difference in the final outcome, but whether the men or the women are proposers makes a big difference—the proposers get their optimal outcome, and the accepters get their pessimal outcome—it pays to be “pushy”!

Figure 14.3: The man-optimal (left) and woman-optimal (right) stable matchings for the example from Figure 14.1.

14.4  Strategy-proofness of Two-sided Matching Rules

We turn to considering whether the DA algorithm is strategy-proof. Following our treatment of voting and one-sided matchings, we can define a two-sided matching context analogously to matching context except that now (a) both the left nodes and the right nodes are associated with a valuation function, and (b) the players’ types are preferences over partners: We say that Γ = (2n,Ω,T,v) is a two-sided matching market context if

If it always holds that vi(μ,M) > vi(μ,M) (i.e., we have strict inequality) when i prefers their partner in M, we refer to the context as a two-sided matching context with strict preferences. Furthermore, if for each player i, Ti is the full set of preferences (i.e., all orderings are possible), we refer to the context as a complete two-sided matching context.

We refer to a payment-free mechanism 𝒱 for a two-sided matching-market context as a two-sided matching rule 𝒱; as usual, we say that 𝒱 is strategy-proof if 𝒱 is DST. In the context of two-sided matching, we will also consider two weaker notions of strategy-proofness where DST only holds for either the men or the women:

Definition 14.6. We say that a two-sided matching rule 𝒱 is strategy-proof for the men for the two-sided matching market context Γ = (2n,Ω,T,v) if for every μ T, μi is a dominant strategy for every i [n] in GΓ,t,𝒱. If instead the above holds for every i [n + 1,,2n], we say that 𝒱 is strategy-proof for the women.

Clearly, a matching rule 𝒱 is strategy-proof if and only if 𝒱 is strategy-proof for both the men and the women. As we shall now see, the (man-proposing) DA algorithm is strategy-proof for the men in every complete two-sided matching context with strict preferences (and, symmetrically, the woman-proposing DA algorithm is strategy-proof for the women).

Theorem 14.4. 𝒱DA is strategy-proof for the men for every complete two-sided matching context with strict preferences.

The theorem follows directly from Theorem 14.2 and the next proposition that shows that any voting rule that always (no matter what the preferences are) outputs man-optimal outcomes is strategy-proof for the men.

Proposition 14.1. Consider some complete two-sided matching context Γ = (2n,Ω,T,v) with strict preferences and a two-sided matching rule 𝒱. Assume that for every μ T, 𝒱(μ) is a man-optimal stable matching with respect to μ. Then 𝒱 is strategy-proof for the men for Γ.

Proof [Advanced]. We refer to a matching rule that always outputs man-optimal stable matchings as being simply man-optimal. We start by showing that man-optimal two-sided matching rules satisfy a notion of monotonicity: the voting rule continues to output exactly the same matching if we modify some men’s preferences to rank the woman they previously got matched with the highest.

Lemma 14.2. Let 𝒱 be a man-optimal two-sided matching rule. Let μ T be a preference profile, let M = 𝒱(μ), and let μ be a preference profile where some of the men s S rank M(x) the highest (but have otherwise arbitrary preferences), and the remaining players iS have exactly the same preferences as in μ. Then, 𝒱(μ) = M.

Armed with the above lemma, we turn to prove the proposition. Consider a man-optimal two-sided matching rule 𝒱, and assume for contradiction that 𝒱 is not strategy-proof for the men. That is, there exists some preference profile μ, some man i and some preference ordering μi such that i strictly prefers his match y in M = 𝒱(μi,μi) to his match y in M = 𝒱(μ). We consider a set of “hybrid preferences”:

This concludes the proof of the proposition.

14.5  Strategy-proofness vs. Stability

So, if we use the man-proposing DA algorithm, none of the men will ever want to deviate, and if we use the woman-proposing DA algorithm, none of the women will want to deviate. We would obviously like to have a mechanism that is strategy-proof for both the men and the women. Unfortunately, as the next theorem shows, no mechanism that outputs stable outcomes can be strategy-proof (for both men and women):

Consider a complete two-sided matching context Γ = (2n,Ω,T,v) with strict preferences. We say that 𝒱 is stable for Γ if 𝒱(μ) is stable with respect to μ for every μ T.

Theorem 14.5. Consider a complete two-sided matching context Γ = (2n,Ω,T,v) with strict preferences such that n 3. There does not exists a two-sided matching rule 𝒱 that is both stable and strategy-proof for Γ.

Proof. Consider some complete context Γ with strict preferences and assume for contradiction that there exists some two-sided matching 𝒱 that is both stable and strategy-proof for Γ.

We start by considering the case that n = 3; that is, consider three men {M1,M2,M3} and three women {W1,W2,W3} (we may without loss of generality assume that those are their “names”), and consider the partner preference profile μ specified as follows:

  • M1 prefers W1 > W2 > W3, M2 prefers W2 > W1 > W3, and M3 prefers W1 > W2 > W3.
  • W1 prefers M2 > M1 > M3, W2 prefers M1 > M2 > M3, and W3 prefers M1 > M2 > M3.

That is, M1,M2’s preferences are aligned—according to them the matches (M1,W1), (M2,W2) are optimal; likewise, W1,W2’s preferences are aligned but orthogonally to the men’s preferences—according to them the matches (M1,W2), (M2,W1) are optimal. The third man and woman (M3,W3) are just “dummy” players that all the others place last. Thus, there are exactly two stable matchings with respect to μ:

  • (M1,W1), (M2,W2), (M3,W3)
  • (M1,W2), (M2,W1), (M3,W3)

Assume the 𝒱(μ) picks the first of these matchings (it must pick one of them since 𝒱 is stable). If so, the men are happy with the outcome, but both the women are not. In particular, if W1 instead had reported M2 > M3 > M1, then the only stable outcome is (M1,W2), (M2,W1), (M3,W3). This follows by simply inspecting the six possible matchings:

  • (M1,W1) can never be part of a stable matching, since then W1 prefers to switch to M3 (who prefers her).
  • (M1,W3) can never be part of a stable matching, since M1 prefers W2 to W3 (and M1 is W2’s top preference, so she would switch).
  • (M2,W3) can never be part of a stable matching, since M2 prefers W1 to W3 (and M2 is W1’s top preference, so she would switch).

Thus, we conclude that (M1,W2),(M2,W1),(M3,W3) is the only stable matching under these new preferences. It follows that 𝒱 must output it (under W1’s deviation), and thus W1 strictly gains by misreporting her preferences.

An analogous argument can be applied if the mechanism instead outputs the second matching. Finally, we remark that if n > 3, then for every i > 3, we can simply have man i rank woman i first, and woman i rank man i first. It follows that in any stable matching, for i > 3, man i must be matched to woman i, and we can simply disregard these extra players and repeat the argument above.

We end this section by noting that Theorem 14.5 has intriguing social consequences: as we cannot hope to get a mechanism that is strategy-proof for “both sides,” when running a two-sided matching mechanism, we need to decide toward what side we want robustness to manipulation. Indeed, the DA algorithm is commonly used in practice: perhaps the most famous application is for matching residents to hospitals; in this application, the residents are acting as proposers and the hospitals as accepters (which means that the mechanism is strategy-proof for the residents, but also means that the outcome is “resident-optimal”).

Notes

The two-sided matching problem and the Deferred Acceptance algorithm were introduced by Gale and Shapley [GS62]; Gale and Shapley also proved the stable marriage theorem. Dubins and Freedman [DF81] and Roth [Rot82] showed the the DA algorithm is strategy-proof of the men; the proof we present here, however, is new (although it takes some inspiration from the proof in [GS85]). Roth [Rot82] showed the impossibility of mechanisms that are both strategy-proof and stable. See [RS92] for a more extensive survey of two-sided matchings. Alvin E. Roth and Lloyd S. Shapley received the Nobel Prize in Economic Sciences (for the “theory of stable allocations”) in 2012.