Applied

Nobody has a reason to run away

A matching is stable when no two people on opposite sides would both rather have each other than what they have — a condition that names nothing to build and everything to rule out. The surprise is that something always satisfies it, however perverse the rankings are made.

Worth reading first: Two injections make a bijection · Twenty-four out of two hundred and fifty-six.

Two sides, four on each. Side one is lettered A, B, C, D and side two is numbered 1, 2, 3, 4, and every member of each side holds a strict ranking of all four members of the other. A matching pairs them off one to one, and there are twenty-four ways to do that. The question is which of the twenty-four are stable — and the answer has a strange shape, because stability is defined by what it forbids and forbids nothing in particular.

One matching that is not stable, and all 24 counted by blocking pairsAn unstable matching with its blocking pair ringed and both members' rankings marked, above an exhaustive census of every matching of the instance by how many blocking pairs it has.a matching that is not stableA1B2C3D4why that pair blocksD13would rather4has now23ADwould ratherChas nowBhow many of the 24 matchings have each number of blocking pairs40315283241516blocking pairsevery matching, sorted — the 4 stable ones first000011122222333333334456A1 B2 C3 D4 has 1 blocking pair: D and 3 would each rather have the otherall 24 matchings were formed and each put all 16 blocking questions; 4 of them came back with nonethe strip holds one cell per matching, sorted by that count with the 4 zeroes at the left
Fig. 1 All 24 matchings of one instance, each put all 16 blocking questions, sorted by how many came back yes. The pairing A1 B2 C3 D4 at the top has exactly 1 blocking pair — D and 3 would each rather have the other — and the leftmost band of the strip holds the 4 matchings with none at all. The census is complete: every matching was formed and every pair of every one of them was asked.

The definition that names nothing to build

A preference profile is the whole input: for each member of side one, a strict ranking of side two, and for each member of side two, a strict ranking of side one. Nothing else. No numbers are attached to the rankings, no member is more important than another, and no two rankings need have anything to do with each other.

A matching is a one-to-one correspondence between the two sides — a bijection, and for sides of size nn there are n!n! of them. That much is arithmetic.

Stability is not arithmetic. A pair consisting of one member ii of side one and one member jj of side two is a blocking pair for a matching when both of the following hold:

  • ii strictly prefers jj to the partner the matching gave ii, and
  • jj strictly prefers ii to the partner the matching gave jj.

Both halves are needed, and both are strict. A matching is stable when it has no blocking pair at all.

Read that definition again and notice what it does not do. It does not say how to build a stable matching, or what one looks like, or which pairs it contains. It is a filter applied to a finished object, and the filter is a conjunction of n×nn \times n separate refusals — every one of the pairs has to fail to block. On the instance above that is 4×4=164 \times 4 = 16 questions per matching and 24×16=38424 \times 16 = 384 questions in total, and the figure asks all of them, including the nn questions about pairs the matching already contains, which cannot block and are asked anyway so that the count reported is the number of questions put.

So the natural first question is not how does one find a stable matching but whether there is one to find. Nothing in the definition suggests there should be. The rankings can be set adversarially; the condition quantifies over every pair at once; and a condition that rules things out with that much freedom is exactly the kind that rules everything out.

The smallest instance where the question means anything

With one member on each side there is one matching and no pair to compare it with, so stability is vacuous. Two on each side is where the question first has content.

One matching that is not stable, and all 2 counted by blocking pairsAn unstable matching with its blocking pair ringed and both members' rankings marked, above an exhaustive census of every matching of the instance by how many blocking pairs it has.a matching that is not stableA1B2why that pair blocksA1would rather2has now1Awould ratherBhas nowhow many of the 2 matchings have each number of blocking pairs100112blocking pairsevery matching, sorted — the 1 stable ones first02A2 B1 has 2 blocking pairs: A and 1 would each rather have the otherall 2 matchings were formed and each put all 4 blocking questions; 1 of them came back with nonethe strip holds one cell per matching, sorted by that count with the 1 zeroes at the left
Fig. 2 Two on each side: all 2 matchings, each put all 4 blocking questions. A2 B1 has 2 blocking pairs — both of the cross pairs would rather have each other — and the other matching has none, so 1 of the 2 is stable. The bar chart has one bar per count that occurs and the strip has one cell per matching, which here is a very short strip.

Two matchings, and one of them survives. That is the whole of the theorem at this size and it is not yet evidence of anything: with two matchings and a symmetric definition, an instance where neither survives would need both cross pairs to block simultaneously in one arrangement and both diagonal pairs in the other, and a moment’s checking shows that cannot happen. Small cases are agreeable that way, which is precisely why the collection distrusts them.

Three, and a census that comes out even

At three on each side there are six matchings, and an instance can be built where the two sides’ wishes rotate against each other: A wants 1, B wants 2, C wants 3, while 1 wants B, 2 wants C, and 3 wants A. Every first choice is somebody else’s second or third. Nobody gets what they want first and nobody has an obvious claim.

One matching that is not stable, and all 6 counted by blocking pairsAn unstable matching with its blocking pair ringed and both members' rankings marked, above an exhaustive census of every matching of the instance by how many blocking pairs it has.a matching that is not stableA1B2C3why that pair blocksC31would rather2has now1BCwould ratherAhas nowhow many of the 6 matchings have each number of blocking pairs3031blocking pairsevery matching, sorted — the 3 stable ones first000111A1 B3 C2 has 1 blocking pair: C and 1 would each rather have the otherall 6 matchings were formed and each put all 9 blocking questions; 3 of them came back with nonethe strip holds one cell per matching, sorted by that count with the 3 zeroes at the left
Fig. 3 An instance whose two sides’ first choices rotate against each other. All 6 matchings were formed and each put all 9 blocking questions; 3 came back with none, and the other 3 have exactly 1 blocking pair each. The one drawn at the top is A1 B3 C2, whose single failure is that C and 1 would each rather have the other.

Half the matchings survive, and the ones that fail all fail in the mildest possible way — one blocking pair each, never two. That is a pleasant census and it is also a warning: the shape of a census is not the theorem. What matters is only that the leftmost column is not empty.

A construction, and the check that it worked

The proof that the leftmost column is never empty is a construction, and it is worth watching because it is a rare thing: an existence proof that hands over the object it claims exists.

One side proposes. Everybody on the proposing side who is unattached offers themselves to the best name on their list that has not already refused them. Everybody on the receiving side who is holding offers keeps the best one and releases the rest. The released offer again next round, further down their lists. The process stops when nobody is unattached.

Deferred acceptance on a 4-by-4 instance, and its output put to the testBoth sides' preference tables with every rejected proposal struck through, the round-by-round ledger of proposals, and the matching the construction settles on.side one's rankings, best firstside two's rankings, best firstthe matching it settles on1st2nd3rd4thABCD14324231312413421st2nd3rd4th1234BCADCBDAADCBCDABA1B2C3D4the pair that settledproposed to, then rejectedroundproposals madewhat each name in hand did with them1A→1 B→4 C→3 D→11 holds A; 4 holds B; 3 holds C; 1 keeps A, D rejected2D→33 takes D, C rejected3C→11 takes C, A rejected4A→44 takes A, B rejected5B→22 holds Bside one proposing settles on A4 B2 C1 D3 after 5 roundsall 16 pairs were put the blocking question and none answered yes, so the settled matching is stable8 proposals were made — a fact about these particular lists, not a claim about how long anything takes
Fig. 4 Deferred acceptance on a 4-by-4 instance with side one proposing. Both preference tables carry the whole history — every cell proposed to and then refused is struck through, and the cell each member settles on is shaded — and the ledger under them says what happened in each round. It settles on A4 B2 C1 D3 after 5 rounds and 8 proposals, and all 16 pairs were then put the blocking question with none answering yes.

The figure does not claim its output is stable because a theorem says the construction produces stable matchings. It puts the finished pairing to the definition, pair by pair, and reports that all sixteen questions came back no. That is the house habit and it matters here more than usual, because the whole essay turns on a definition being satisfied rather than on a procedure being correct.

A word about the number eight, since it is on the page. Eight is a fact about these particular lists, in exactly the register of “four of the twenty-four matchings are stable”: it is what this instance did, not a measurement of anything. How much work a procedure takes, and how that grows, is a question about cost, and cost is another site’s subject in this fleet; nothing here divides eight by anything, compares it to sixteen, or draws a conclusion from it.

Why nobody is left holding a blocking pair

The argument that the construction cannot fail has two halves, and neither is long.

It stops. Nobody on the proposing side ever offers to the same name twice, because a refusal moves them one place down their own list and they never move back up. So each proposer’s position in their own ranking only increases, and it is bounded by nn. A quantity in a finite ordered set that only moves one way cannot move for ever — the same device as the infinite descent that shows no square can shrink for ever, and the same one that makes the oldest algorithm terminate. Descent arguments usually appear in number theory and this one is about rankings, but the mechanism is identical: a well-ordered quantity, moved monotonically, with nowhere left to go.

It ends with everybody attached. A member of the receiving side, once holding an offer, is never left empty afterwards — they may swap what they hold for something better, but they never release without replacing. So if some proposer ran out of list, they would have offered to every member of the receiving side, all of whom would then be holding something; and nn receivers each holding at most one offer, with one proposer unattached, is more things than boxes run in reverse. The count refuses it.

And the result blocks nowhere. Take any pair not in the final matching. Either the proposer never offered to that receiver — in which case the proposer prefers what they have, since offers go down the list in order and they stopped before reaching this name — or they did offer and were refused, in which case the receiver was holding somebody better at that moment and has only improved since. One of the two halves of the blocking condition fails, whichever pair is chosen. There is no third case, so there is no blocking pair, so a stable matching exists for every preference profile.

That last sentence is the theorem, and it is worth noticing how little of the argument used anything about the instance. Nothing was assumed about the rankings except that they are strict and complete.

As perverse as the lists can be made

If the theorem is going to fail anywhere, it should fail where the two sides’ wishes conflict most. Take the instance in which every member of side one has the same ranking of side two — 1 first, then 2, then 3, then 4 — and every member of side two has the same ranking of side one, in the opposite lettered order: D first, then C, then B, then A. Total agreement within each side, and everybody’s first choice contested by all three rivals.

One matching that is not stable, and all 24 counted by blocking pairsAn unstable matching with its blocking pair ringed and both members' rankings marked, above an exhaustive census of every matching of the instance by how many blocking pairs it has.a matching that is not stableA1B2C3D4why that pair blocksB123would rather4has now3DCBwould ratherAhas nowhow many of the 24 matchings have each number of blocking pairs10315263543516blocking pairsevery matching, sorted — the 1 stable ones first011122222333333444445556A3 B4 C2 D1 has 1 blocking pair: B and 3 would each rather have the otherall 24 matchings were formed and each put all 16 blocking questions; 1 of them came back with nonethe strip holds one cell per matching, sorted by that count with the 1 zeroes at the left
Fig. 5 Every member of side one ranks side two identically, and every member of side two ranks side one identically. All 24 matchings were formed and each put all 16 blocking questions; exactly 1 of them came back with none. The bar chart is symmetric — 1, 3, 5, 6, 5, 3, 1 — and the guarantee is met with nothing to spare.

One survivor out of twenty-four, and 1+3+5+6+5+3+1=241 + 3 + 5 + 6 + 5 + 3 + 1 = 24 accounts for the whole census. This is the instance to keep in mind whenever the theorem starts to sound generous. It promises a non-empty set; it does not promise a large one, and here the set is a single point. Twenty-three of the twenty-four arrangements have somebody with a reason to walk away, and one does not.

Running the construction on the same lists shows why the survivor is the one it is.

Deferred acceptance on a 4-by-4 instance, and its output put to the testBoth sides' preference tables with every rejected proposal struck through, the round-by-round ledger of proposals, and the matching the construction settles on.side one's rankings, best firstside two's rankings, best firstthe matching it settles on1st2nd3rd4thABCD12341234123412341st2nd3rd4th1234DCBADCBADCBADCBAA1B2C3D4the pair that settledproposed to, then rejectedroundproposals madewhat each name in hand did with them1A→1 B→1 C→1 D→11 holds A; 1 takes B, A rejected; 1 takes C, B rejected; 1 takes D, C rejected2A→2 B→2 C→22 holds A; 2 takes B, A rejected; 2 takes C, B rejected3A→3 B→33 holds A; 3 takes B, A rejected4A→44 holds Aside one proposing settles on A4 B3 C2 D1 after 4 roundsall 16 pairs were put the blocking question and none answered yes, so the settled matching is stable10 proposals were made — a fact about these particular lists, not a claim about how long anything takes
Fig. 6 The same lists, with side one proposing. All four offer to 1 in the first round and three are refused; the survivors cascade down the columns. It settles on A4 B3 C2 D1 after 4 rounds and 10 proposals, and all 16 pairs were then put the blocking question with none answering yes.

The ledger is a picture of the cascade: four offers to the same name in round one, three refusals, and the losers moving down in lockstep. What comes out pairs the most-wanted member of each side with the other — and it is the only thing that can, because any other arrangement leaves the two of them able to improve on each other, which is a blocking pair by definition. The rest follows by the same argument on what is left.

What the census settles, and what it does not

This needs saying plainly, because the figures are persuasive and they are persuasive about the wrong proposition.

Every census on this page exhausts one instance. It forms all n!n! matchings of a fixed preference profile, asks all n×nn \times n blocking questions of each, and reports the tally. What it establishes is a statement about that profile: on this profile, four of twenty-four are stable; on that one, exactly one of twenty-four. Each of those is settled beyond argument, in the way a finite check of finitely many cases settles things.

The existence theorem is not a statement about any profile. It is a statement about all of them — every nn, and every assignment of strict rankings to both sides. There are (n!)2n(n!)^{2n} profiles at each size, and no drawing exhausts that. The census confirms; the argument of the previous section proves. A reader who takes the pattern of the bar charts as the content has read a picture of one instance as a claim about all instances.

Nor is the shape of a census stable across instances. Compare the four-of-twenty-four above with the one-of-twenty-four beside it, and then with five on a side.

One matching that is not stable, and all 120 counted by blocking pairsAn unstable matching with its blocking pair ringed and both members' rankings marked, above an exhaustive census of every matching of the instance by how many blocking pairs it has.a matching that is not stableA1B2C3D4E5why that pair blocksD45would rather123has now5BCDwould ratherEhas nowAhow many of the 120 matchings have each number of blocking pairs306113215318420510613712829310411112blocking pairsevery matching, sorted — the 3 stable ones first00011111122222222222223333333333333334444444444444444445555555555555555555566666666667777777777777888888888888991010101111111112A1 B2 C4 D3 E5 has 1 blocking pair: D and 5 would each rather have the otherall 120 matchings were formed and each put all 25 blocking questions; 3 of them came back with nonethe strip holds one cell per matching, sorted by that count with the 3 zeroes at the left
Fig. 7 Five on a side: all 120 matchings formed, each put all 25 blocking questions, 3 of them stable. The tally runs 3, 6, 13, 15, 18, 20, 10, 13, 12, 2, 3, 4, 1 across counts 0 to 12, so the commonest matching here fails in five separate ways at once. The only band the theorem speaks about is the leftmost one, and the only thing it says about it is that it is not empty.

Three of a hundred and twenty. The proportion has collapsed and the theorem has not noticed, because the theorem never mentioned a proportion. What the strip at the bottom of that figure shows, and what no smaller drawing shows as well, is how thin the stable set can be inside the space of arrangements while still being non-empty.

Where the two-sidedness is load-bearing

Two conditions were slipped in at the start and both are doing real work.

The rankings are strict and complete. Ties break the argument at the point where a receiver “keeps the best offer” — with a tie there is no best — and incomplete lists break it where a proposer runs out of names, which the counting argument above forbids only because every name is on every list. Both variants have their own theory and neither is this page’s.

There are two sides. This is the surprising one. Put everybody into a single pool, so that any two participants may be matched and each ranks all the others, and the same definition of blocking pair applies word for word. The existence theorem then fails. There are profiles in that setting with no stable matching at all: whichever pairing is proposed, some two participants prefer each other to what they have, and the counterexample is small enough to check by hand with four participants. Gale and Shapley pointed this out in the same paper that proved the two-sided case.

So the theorem is not a fact about matchings, or about preferences, or about the blocking condition. It is a fact about the bipartite structure — about there being two sides with one side able to propose and the other able only to hold or refuse. Take the sides away and everything else survives except the conclusion. That is an unusually clean example of a hypothesis earning its place, and it is worth setting beside the way a single missing case collapses an otherwise uniform pattern.

Where it came from

The result is from a short paper of 1962 by David Gale and Lloyd Shapley, whose closing pages make a point of the fact that the whole argument runs without a single piece of mathematical notation. The proof above is theirs, and it is fair to say the claim holds: the two halves of it fit in a paragraph each and nothing in either needs a symbol. Shapley shared the 2012 prize in economic sciences with Alvin Roth for this line of work. Neither the paper’s applications nor the prize’s citation belongs on this page; what belongs is the argument, which is complete without either.

The word “stable” in the definition was theirs too, and it repays attention. It does not mean optimal, or fair, or best by any measure. It means only that no two participants on opposite sides can both do better by abandoning what they were given. That is a low bar, deliberately, and the low bar is what makes the existence theorem possible at all — a stronger condition would be exactly the kind that rules everything out.

Where this anchor goes next

The census at the top of the page shows four stable matchings, and it draws them as four cells in a band without saying anything about how they relate to each other. They relate to each other a great deal.

The 4 stable matchings of the instance, ordered by side one's preferenceA Hasse diagram of the stable matchings with the best for side one at the top, beside a table giving the join and the meet of every pair.better for side one, worse for side twoM1 A4 B2 C1 D3side one's ranks 2, 2, 2, 2M2 A3 B2 C1 D4side one's ranks 3, 2, 2, 3M3 A4 B1 C2 D3side one's ranks 2, 4, 3, 2M4 A3 B1 C2 D4side one's ranks 3, 4, 3, 3join and meet, on every pairpairjoinmeetM1, M2M1M2M1, M3M1M3M1, M4M1M4M2, M3M1M4M2, M4M2M4M3, M4M3M44 of the 24 matchings are stable, drawn with the best for side one at the topevery one of the 16 ordered pairs was joined and met, and all 32 results were themselves stablethe top A4 B2 C1 D3 is what side one proposing returns; the bottom A3 B1 C2 D4 is what side two proposing returns
Fig. 8 The 4 stable matchings of the first instance, ordered by side one’s common preference. The top A4 B2 C1 D3 is what side one proposing returns and the bottom A3 B1 C2 D4 is what side two proposing returns; every one of the 16 ordered pairs was joined and met, and all 32 results were themselves stable.

Two of the four are incomparable — one is better for some members of side one and worse for others — so the picture is a diamond rather than a chain, and the two extremes are precisely what the construction returns depending on which side does the proposing. That the pointwise better of two stable matchings is again stable is not obvious and is not proved here; it is the subject of the side that proposes wins, which is where this anchor’s second rung sits.

The third rung asks the question this one has carefully not asked. Everything above assumed the rankings submitted are the rankings held. They need not be, and no stable rule is safe from a lie shows what happens when one participant hands in a ranking that is not theirs — searched exhaustively on an instance small enough to search completely, which is the only honest way to exhibit a counterexample to a universal claim.

What survives all three rungs is the fact established here, and it is worth stating one last time in the negative form the definition uses. Given any two sides of the same size and any strict rankings whatever, there is at least one way to pair them off such that nobody has a reason to run away — not because anybody is satisfied, but because nobody can find a partner who would have them.

What links here

Computed from the collection, not written here: the essays that point at this one.

Reads more easily once this is understood

Essays that name this one as worth reading first.

Shares its objects with

Essays that name at least two of the same things, and that neither author linked.

Named objects

A dashed tag is an object no other essay names yet.

BijectionBlocking pairConstructive proofCounterexampleDeferred acceptanceExistence proofPreference profileStable matching