The Stable Marriage
Problem
Consider the set M of men and W of women, where |M| = |W| = n, Let M x W be the set of all possible ordered pairs (m, w) where m Î M and w Î W. A matching S is a set of ordered pairs, each from M x W with the property that each member of M and each member of W appears in at most one pair in S. A perfect matching S' is a matching with the property that each member of M and each member of W appears in exactly one pair in S'.
An instability in S' occurs when there exits at least two pairs (m, w) and (m', w') such that m prefers w' to w and w' prefers m to m'.
Given a set of M men and W women and a list of preferences for each m Î M and each w Î W,
· Does there exist a stable matching for every set of preference lists?
· Given a set of preference lists, can we efficiently construct a stable matching if there is one?
Proof that there exists a stable matching for each set of preference lists.
Assume that each man in M and each woman in W ranks their preferences from 1 to n in strictly descending order.
Let the base case be |M| = |W| = 1.
then the pair (m1, w1) is the only pair in S' and is stable.
Now assume that there is a stable matching in the subset M' x W' where |M'| = |W'| = n-1
Let m Ï M' and w Ï W'. Then either
If case 1, there is a stable matching in M x W, and existence of such a matching is proved by induction
if case 2. There is a new stable matching of |M' x W'| = n-1 and (m', w) are not included in the matching
if case 3. There is a new stable matching of |M' x W'| = n-1 and (m, w') are not included in the matching
If case 2 or 3, then the three conditions pertain again, but the number of possible alternatives for the unpaired couple is reduced by at least 1 and eventually the remaining man and woman have no better alternative than each other.
This inductive proof points to an algorithm for determining a perfect matching.
The Gale-Shapley Algorithm
Initially all m Î M and allw Î W are free
While there is a man m who is free and hasn't proposed to every woman
Choose such a man m
Let w be the highest-ranked woman on m's preference list
to whom he has not yet proposed
If w is free then (m, w) become engaged
Else w is currently engaged to m'
If w prefers m' to m then m remains free
Else w prefers m to m'
(m, w) become engaged
m' becomes free
Endif
Endif
Endwhile
Return the set S of engaged pairs
Analysis of the
Algorithm
The Gale-Shapley Algorithm terminates after at most n2
iterations of the While loop
Let P(t) be the set of pairs (m, w) such that m has proposed to w by the end of iteration t.
We see that P(t) is strictly increasing, but P(t) must always be less than the total number of possible pairs of men and women. The number of possible pairs is n2, so this algorithm must have at most n2 iterations.
Proof of correctness
of Gale-Shapley
Corollary
1. If man m is free at some point in the
execution of the algorithm, then there exists some woman to whom he has not yet
proposed.
Proof. Suppose there comes a point when m is free, but has proposed to all n women. Then by rule 1 above, all n women are engaged at this point. Since the set orf engaged pairs forms a matching, there must also be n engaged men at this point in time. But there are only n men in total, so this lead to a contradiction.
Corollary
2. The set S returned at termination is a
perfect matching.
Proof. The set of engaged pairs always forms a matching. Suppose that the algorithm terminates with a free man m. At termination of the while loop it must be the case that m has already proposed to every woman, else the loop does not terminate. But this contradicts corollary 1 that says there cannot be a free man who has proposed to every woman.
Theorem. An
execution of the Gale-Shapley Algorithm returns a set
of pairs S that is a stable matching.
By corollary 2, S is a perfect matching. Assume that there is an instability in S. Consider two pairs (m, w) and (m', w') with the properties that
m prefers w' to w, and
w' prefers m to m'
If m were to choose before m', he would select w' before w and she would reject m prime's proposal.
If w' were already engaged to m' when m proposed, she would end her engagement and pair with m.
If m never proposed to w', then he would have proposed to w first contradicting the assumption that he prefers w'.
If he did propose to w' and was rejected, then w' must prefer some man m'' more than m. Man m' is the final partner of w', so either m'' = m', or by property 1 above, w' prefers her final partner m' to m''. Either way we have a contradiction.
Extensions of the
Gale-Shapley Algorithm
Representative
Problems