MAS334 Combinatorics

11. Hall’s marriage theorem

Video (Up to Lemma 11.5)

Consider a matching problem, with a set A of people, a set B of jobs, and a set EA×B consisting of pairs (a,b) where person a is qualified for job b.

Definition 11.1.

We say that the matching problem is solvable if there exists a full matching. This means that it is possible to allocate every job to a qualified person, in such a way that no one has more than one job.

Suppose we want to decide whether a given matching problem is solvable. One approach would be to use the methods that we have already seen to count or tabulate the full matchings; that will in particular tell us whether there are any full matchings. However, if we are only interested in the existence question, then some different methods become available, as we will describe in this section.

Definition 11.2.

Recall that in Remark 6.5, we defined

Cb={aA|(a,b)E}={ people who are qualified to do job b}.

We will refer to this as the candidate set for b. More generally, if UB is some subset of the jobs, we put

CU =bUCb={aA|(a,b)E for some bU}
={ people who are qualified for at least one of the jobs in U}.

We again call this the candidate set for U. We say that

  • (a)

    U is implausible if |CU|<|U|.

  • (b)

    U is barely plausible if |CU|=|U|.

  • (c)

    U is very plausible if |CU|>|U|.

  • (d)

    U is plausible if |CU||U| (so U is either barely plausible or very plausible).

We also say that the whole matching problem is plausible if every subset UB is plausible.

Remark 11.3.

We always have C= so |C|=0=|| so is barely plausible.

Example 11.4.

Suppose we have a set A={Paula,Quentin,Ruth,Steve,Tessa} of people, and a set B={Artist,Baker,Courier,Dentist,Electrician} of jobs, with qualifications as follows:

We then have

C{B,D} ={ people qualified to be a baker or a dentist }=CBCD
={P,Q,R,T}{S}={P,Q,R,S,T}.

Proceeding in the same way, we see that

  • C{E}={Q,S}, so |C{E}|=2>1=|{E}|, so {E} is very plausible.

  • C{A,B}={P,Q,R,S,T}, so |C{A,B}|=5>2=|{A,B}|, so {A,B} is very plausible.

  • C{C,D}={Q,S}, so |C{C,D}|=2=|{C,D}|, so {C,D} is barely plausible.

  • C{C,D,E}={Q,S}, so |C{C,D,E}|=2<3=|{C,D,E}|, so {C,D,E} is implausible.

This last example is a problem. We need to assign jobs C, D and E, and we can ignore people P, R and T, because none of them can do any of these jobs. This just leaves two people Q and S who need to cover three jobs, which is not possible. Thus, our allocation problem is not solvable. The next lemma will generalise this line of argument.

Lemma 11.5.

If the problem is solvable, then it is plausible. Thus, by the contrapositive, if the problem is not plausible then it has no solution.

Proof.

If the problem is solvable, then we can choose a full matching M. Consider a subset U={b1,,bm}B. Then M must allocate each job biU to some person aiA. As M is a matching, we know that the people a1,,am are all different, and that ai is qualified for job bi, so aiCU. We thus have distinct elements a1,,amCU, so |CU|m=|U|, so the set U is plausible. This holds for all U, so the whole matching problem is plausible. ∎

The main result of this section is the converse to the above lemma.

Theorem 11.6 (Hall’s Marriage Theorem).

If a matching problem is plausible, then it is solvable.

Remark 11.7.

Hall first formulated this result in the context of assigning romantic partners rather than jobs, hence the name.

We will give two different proofs of Hall’s theorem. The first proof will rely on the following construction.

Construction 11.8.

Suppose we have a matching problem as above, and a partial matching M that assigns some subset BB of the jobs to some subset AA of the people. (Note that M gives a bijection from B to A, so we automatically have |A|=|B|.) There is then an obvious way to set up a new matching problem for the assignment of the remaining jobs. In more detail, we take A′′=AA (the set of people who have not already been given a job), and B′′=BB (the set of jobs that still need to be assigned) and E′′=E(A×B). This gives a new matching problem, with candidate sets CU′′=CUA′′=CUA for all UB′′. We call this the completion problem for M. If we can find a solution M′′ for the completion problem, then we can combine it with M to get a solution for the original problem.

First proof of Theorem 11.6.

If there are no jobs, then there is nothing to do, and the problem is vacuously solved.

Suppose instead that there is only one job, say B={b}. By hypothesis, the set {b} is plausible, which means that |Cb|1, so Cb, so we can choose aCb. This means that person a is qualified to do job b, so we can just allocate b to a, and there is nothing more to do.

Now suppose that |B|=n>1. We can assume by induction that any plausible problem with at most n-1 jobs can be solved. By an intermediate set we mean a set UB with U and UB. Note that one of the following two cases must hold:

  • (easy)

    Every intermediate set is very plausible.

  • (hard)

    There is an intermediate set BB such that B is barely plausible.

First consider the easy case. Choose any job b0B, and put B={b0} and B′′=BB. As {b0} is plausible, we have |Cb0|1, so we can choose a0Cb0 and put A={a0} and A′′=AA. Let M be the partial matching that assigns b0 to a0. We claim that the corresponding completion problem is plausible. In other words, for all UB′′, we claim that |CU′′||U|. If U is empty, this holds by Remark 11.3. Suppose instead that U. As UB′′, we also have UB. As we are in the easy case, it follows that U is very plausible, so |CU|>|U|, or equivalently |CU|-1|U|. We also have CU′′=CU{a0}, so |CU′′| is either |CU|-1 (if a0CU) or |CU| (if a0CU). Either way, we have |CU′′||CU|-1|U|, as required. As C′′ is a plausible problem with n-1 jobs, our induction hypothesis guarantees that it has a solution, say M′′. We can combine this with M to get a solution for the original problem.

Now suppose instead that we are in the hard case. We can therefore choose an intermediate set B (so BB with BB) such that B is barely plausible. Put B′′=BB. Note that |B|<n and |B′′|<n, so our induction hypothesis guarantees that any plausible allocation problem for B or for B′′ is solvable. In particular, we can restrict our original allocation problem to B, and there must exist a solution for this, say M. This assigns the jobs in B to some set of people AA, which must have |A|=|B|. We again claim that the completion problem for M is plausible. However, the proof is a little more complicated than in the easy case. The first point to note is that A=CB. To see this, note that each person in A has been assigned a job in B, and M is assumed to be a valid partial matching so they must be qualified for the job that they have been assigned, so ACB. On the other hand, we have already remarked that |A|=|B|, and |B|=|CB| because B is assumed to be barely plausible, so |A|=|CB|. As ACB with |A|=|CB|, we see that A=CB as claimed. Now consider a subset UB′′. Recall that CU′′=CUA, essentially by definition. As A=CB, this can be rewritten as CU′′=CUCB. It is also easy to see that CBU=CBCU and so

CBUCB=(CBCU)CB=CUCB=CU′′.

This gives

|CU′′|=|CBUCB|=|CBU|-|CB|=|CBU|-|A|.

As the original problem is assumed to be plausible, we have |CBU||BU|. Here UB′′, so B and U are disjoint, so |BU|=|B|+|U|=|A|+|U|. Putting this together, we get

|CU′′|(|A|+|U|)-|A|=|U|.

This shows that the completion problem C′′ is plausible, as claimed. We also know that |B′′|<n, so we can use our induction hypothesis to show that the completion problem has a solution. Just as in the easy case, we can choose a solution to the completion problem and combine it with M to get a solution for the original problem, as required. ∎

The above proof is theoretically satisfying, but does not really provide much guidance about how to find a solution. We will therefore give a second proof which is a bit more complicated, but also more constructive. In this second proof, we try to allocate the jobs one by one. Suppose we have already allocated a subset BB of the jobs, and we are trying to allocate one more job, say b0. It might happen that we get stuck: all the people who are qualified to do b0 have already been given one of the jobs in B. To fix this, we need to change the allocation of the jobs in B in order to free up someone who is qualified to do b0, and the main problem is to analyse the possibilities for making this kind of adjustment.

Video (Definition 11.9 to the end of Section 11)

Definition 11.9.

Suppose we have a matching problem as before, and a partial matching M, which assigns some subset BB of the jobs. Let b0 be an element of BB, so job b0 is not assigned by M. By an open zigzag for (M,b0), we mean a pattern like this:

In more detail, an open zigzag is a sequence (a0,,ar;b0,,br) with properties as follows (the picture above shows r=3).

  • The people a0,,ar are all different, and the jobs b0,,br are all different.

  • For i=1,,r, job bi is assigned by M to person ai-1 (so biB, and ai-1 is qualified for bi). This is indicated by the solid arrows in the picture.

  • For i=0,,r, person ai is qualified for job bi. This is indicated by the dotted arrows in the picture.

  • Person ar is not assigned a job by M.

Given such an open zigzag, we define a new matching M* for the jobs in B{b0} as follows:

  • M* assigns bi to ai for i=0,,r

  • For bB{b1,,br}, the matching M* assigns b in the same way that M does.

This can be illustrated as follows:

The process that constructs M* from M is called flipping.

Remark 11.10.

The easiest case is the case r=0, where a0 is qualified for b0 and has not already been assigned a job by M, so M* does not change any of the assignments made by M but simply adds an assignment of b0 to a0.

Suppose we can prove that for every M and b0 as above, there always exists an open zigzag. We can then flip the zigzag to get a new matching that includes b0. After doing this repeatedly, we will eventually get a full matching. Thus, the key problem is to prove the existence of open zigzags.

Example 11.11.

Consider an allocation problem with people A={p,q,r,s} and jobs B={i,j,k,l} and qualifications as follows:

We have a partial matching M assigning the first three jobs to the first three people in the obvious way: ip and jq and kr. Now we seem to be stuck: the only person who can do l is p, but p is already doing i. We therefore remove p from i and give them l instead, leaving i unfilled. This creates another problem: the only remaining person qualified for i is q, but q is already doing j. We therefore remove q from j and give them i instead, leaving j unfilled. This creates another problem: the only remaining person qualified for j is r, but r is already doing k. We therefore remove r from k and give them j instead, leaving k unfilled. Now we are OK because person s is free and is qualified for k, so we can assign k to s and we have filled all jobs. What we have effectively done is to flip the following zigzag:

We could also illustrate M and M* using rook placements, as follows:

Definition 11.12.

By an closed zigzag for (M,b0), we mean a sequence x=(a0,,ar-1;b0,,br) such that

  • The people a0,,ar-1 are all different, and the jobs b0,,br are all different.

  • For i=1,,r, job bi is assigned by M to person ai-1 (so biB, and ai-1 is qualified for bi).

  • For i=0,,r-1, person ai is qualified for job bi.

In other words, a closed zigzag is like an open zigzag, except that the person ar is not provided. We say that x is openable if there exists another person ar who is qualified for br and is not assigned any job by M, so that the sequence (a0,,ar;b0,,br) is an open zigzag. We say that x is extendable if there exists another person ar and another job br+1 such that M assigns br+1 to ar, but ar is also qualified for br, so that the sequence (a0,,ar;b0,,br+1) is a closed zigzag.

Definition 11.13.

We define U to be the set of jobs that occur in some closed zigzag.

Remark 11.14.

If a job b occurs in some closed zigzag, then we can discard everything after b, and that gives a closed zigzag that ends with b. Thus, we can also say that U is the set of jobs that appear at the end of some closed zigzag.

Remark 11.15.

Suppose that bU, so there exists a closed zigzag x=(a0,,ar-1;b0,,br) with br=b. This usually means that M assigns b to person ar-1, so in particular bB. The only exception is the case where r=0. The sequence (;b0) counts as a closed zigzag, showing that b0U, but b0B. We thus have U={b0}U, where UB.

Second proof of Theorem 11.6.

As before, we argue by induction on |B|. We choose any job b0B and put B=B{b0}. The matching problem is still plausible when restricted to B, so the induction hypothesis gives us a partial matching M that assigns all the jobs in B. We just need to assign b0 as well, which may involve changing some of the assignments for B. We then define U and U as in Definition 11.13 and Remark 11.15. Put m=|U| and note that |U|=m+1. Recall that UB, so M assigns all the jobs in U to a set of people VA. Because M is a legitimate matching, it assigns different jobs to different people, so |V|=m. Moreover, the people in V are qualified for the jobs that they have been assigned, so VCU. However, our matching problem is plausible by assumption, so |CU||U|=m+1. As |CU|>|V|, we can choose a*CU such that a*V. Because a*CU, we can choose a job b*U such that a* is qualified for b*. Because b*U, we can choose a closed zigzag x=(a0,,ar-1;b0,,br) such that br=b*. Note that bi+1U for i=0,,r-1, and M assigns bi+1 to ai, so aiV. As a*V, we see that a* is different from a0,,ar-1. Now suppose for a contradiction that M assigns some job b to a*. Note that M does not assign b0, and assigns bi+1 to ai, which is different from a*; so b must be different from all of b0,,br. It now follows that the sequence

x=(a0,,ar-1,a*;b0,,br,b)

is again a closed zigzag. As bb0 and b appears in a closed zigzag, we have bU. As M assigns bU to a*, it follows that a*V, which contradicts our initial assumption about a*. It follows that M does not in fact assign any job to a*, so that the sequence

x*=(a0,,ar-1,a*;b0,,br)

is an open zigzag. We can thus flip this zigzag to obtain a new matching M* that assigns b0 as well as all of B. In other words, M* assigns all the jobs. ∎