BCW Hall 2
BCW Hall 2
》
廷
誼 se
陳 U
n《 al
h e rn
C nt e
n
a , I
Ev I S
y
B O T
OTIS, © Evan Chen, internal use only. Artwork contributed by Stable Diffusion.
1
Evan Chen《陳誼廷》 (OTIS, updated 2024-03-26) Hall’s Marriage Lemma
§1 Lecture Notes
§1.1 A narrative on the poker problem
The first thing we might try is a greedy algorithm (always try the dumbest things
first!), namely
Grab any Ace, then any 2, and so on, and hope that this always works.
This, unfortunately, fails. For example, consider the following first five rows.
A♥ 3♠ 4♥ 4♠
2♣ 3♦ 3♣ 3♥
》
2♠ 4♦ 5♥ 5♦
2♦ 4♣ 5♣ 5♠
廷
A♠ A♦ A♣ 2♥
誼 se
As promised, we start by taking the first A we see and the first 2 we see – and lo and
behold, we’re already stuck!
陳 U A♥ 3♠ 4♥ 4♠
n《 al
2♣ 3♦ 3♣ 3♥
e rn
2♠ 4♦ 5♥ 5♦
h e
2♦ 4♣ 5♣ 5♠
C t
A♠ A♦ A♣ 2♥
n
a , I n
We see that we have boxed ourselves in, and we can’t pick any 3’s. So let’s backtrack,
v
and reverse our most recent decision, grabbing 3♦ from the second row. We grab a 2♠,
S
and then the 4♣ (the only remaining 4), and. . .stuck, no 5.
y E T I A♥ 3♠ 4♥ 4♠
B O
2♣ 3♦ 3♣ 3♥
2♠ 4♦ 5♥ 5♦
2♦ 4♣ 5♣ 5♠
A♠ A♦ A♣ 2♥
Now, by hand I’m sure you can see a way to pick. But there do exist situations in which
your first move could fatally sabotage the position, and you wouldn’t know until quite a
bit later. But how could you show this works in general? You can try for a while, but it
turns out to not be easy.
In summary:
• One is trying to create some sort of “pairing”: in this case, match each row with a
particular rank.
• A “naïve” or “greedy” algorithm does not work: it’s possible that you can make
a “bad” choice early on, like we did by picking A♥ and 2♣ on the offset. In this
sense the problem sort of “feels like induction” even though the structure of the
problem changes after the first move.
2
Evan Chen《陳誼廷》 (OTIS, updated 2024-03-26) Hall’s Marriage Lemma
• It feels hard to split into smaller parts (which is what you’d want to e.g. induct).
• You can solve small cases by hand, but not in general. It’s hard to get footholds in
the problem.
• There is often more than one correct choice in the small cases. (But it feels tight in
some other ways too.)
》
Problem setup.
廷
You have a finite set G of gifts and finite set B of boxes that you want to mail out.
誼 se
You wish to place each gift inside a box, satisfying certain constraints (for example,
the gift should fit in the box, but not be too small relative to the box, or might need
陳 U
special postage or bubble wrap, etc.). When is this goal possible?
Two notes:
n《 al
• Leftover boxes are okay as long as gifts are placed. In other words, |G| ≤ |B|.
h e rn
• The standard formulation is as a bipartite graph, where we draw an edge between
compatible gifts and boxes. We use it, but complain about it later.
C t e
The following hypothesis will be called Hall’s Condition.
n
n
a , I
Definition (Hall’s Condition). We say that a box-gift setup satisfies Hall’s Condition
v
if for any k gifts, there are at least k boxes which at least one gift fits with.
E I S
Exercise 1.1. Verify that Hall’s condition is obviously necessary.
y
B O T
Theorem 1.2 (Hall’s Marriage Theorem)
It is possible to match every gift to a box if and only if Hall’s condition is satisfied.
Proof. Suppose the graph is m-regular, meaning all vertices have exactly m neighbors.
Consider any random k gifts. In the graph, they emit a total of km edges. Each box
absorbs at most m of the edges, so there are at least k boxes compatible with at least
one of the gifts.
3
Evan Chen《陳誼廷》 (OTIS, updated 2024-03-26) Hall’s Marriage Lemma
Y
G2 B2
》
G3 B3
廷
誼 se
G4 B4
陳 U
Given such X and Y , we must pair gifts in X and boxes in Y together if we are to
have any chance of succeeding. By induction hypothesis on the subgraph X ∪ Y .
《 al
Exercise 1.4. Check that Hall’s condition is still true after removing the pairs. So, we
n
apply the induction hypothesis again to resolve this case completely.
h e rn
In the other case, assume there is no critical set. Then we pair the first gift off with
C e
any box.
n nt
Exercise 1.5. Check Hall’s Condition also remains true in the resulting graph.
a , I
(Intuitively, the absence of a critical set means that we have the latitude to make a
v
single arbitrary move while preserving Hall’s Condition.) This completes the proof.
E I S
Remark 1.6. You might be surprised how simple the proof of the theorem is – if the proof
y T
of the theorem is so easy, why does it give people such an upper hand?
B O
The reason is that the hypothesis we are inducting on (Hall’s Condition) is actually really
heavy-handed. The fact that it’s the “correct” condition (it’s if-and-only-if) means that the
induction is going to work.
In contrast, most typical applications of Hall’s Theorem satisfy Hall’s Condition in a way
that doesn’t generalize after trying to make a first few “greedy” steps. For example, if you
try to prove the Regular Hall lemma directly by induction, you are almost certainly going
to fail.
There’s no good proof I know that doesn’t involve showing the master result and then
deducing the lemma as a direct corollary. In other words, specific corollaries of Hall’s
Theorem are harder to prove than Hall’s Theorem itself.
• Typical olympiad graph theory problems are stated cleanly, using “tennis tourna-
ments” or “schoolchildren with friendships” or “schoolchildren in Russia” and what
4
Evan Chen《陳誼廷》 (OTIS, updated 2024-03-26) Hall’s Marriage Lemma
not. In contrast, problems involving bipartite graphs are stated in completely differ-
ent terms; the most transparent is “rectangular grids”, and several less transparent
examples below.
• One reason this is true is that in a bipartite graph setup, the vertices often have
different “types”: one side is rows and the other is columns, or one side is children
and the other is presents, et cetera. In contrast for a typical graph theory problem
the vertices are “more or less the same”. So standard graphs and bipartite graphs
are suited for entirely different classes of problems.
• Pro tip: if you have a rectangular board, consider thinking of it as a bipartite
graph.
In short, I think graph theory gives you the wrong instincts here. These problems are
》
a completely different class.
Maybe the most useful way (in my opinion) to think about this:
廷
Hall’s marriage theorem tells you whether you can construct an
誼 se
injective function X ,→ Y .
So, any time you find yourself trying to construct an injective function on finite sets
陳 U
satisfying so-and-so “compatibility” conditions, Hall’s theorem gives you the definitive
answer whether or not it’s possible.
n《 al
e rn
§1.5 The original three problems
h
Example 1.7
C t e
A deck of poker cards is arranged in a 13 × 4 array, face up. Show that it’s possible
n n
to pick a card from each of the 13 rows so that each rank appears exactly once.
va , I
S
Example 1.8 (Kazakhstan 2003)
E I
Two identical unit squares are given; each has been divided into n disjoint polygons
y T
of area n1 . We overlay these two sheets of paper on top of each other. Prove that
B O
one can puncture the overlaid sheet n times such that every polygon is punctured.
16PUMACFA1 Walkthrough. Let |S| = 12. Most of this problem is trying to think about the problem
in the right way; afterwards, Hall will destroy it.
(a) Phrase the problem as trying to match S4 to itself.
5
Evan Chen《陳誼廷》 (OTIS, updated 2024-03-26) Hall’s Marriage Lemma
§2 Practice problems
Instructions: Solve [20♣]. If you have time, solve [30♣]. Problems with red weights are mandatory.
Z5581CD0
[2♣] Problem 1. Let S = {1, 2, . . . , 2015}. Prove that there exists an injective function
S S
f: ,→
》
1007 1008
such that T ⊆ f (T ) for every T . (Here Sk is the set of k-element subsets of S.)
廷
ZB9281DC
[2♣] Required Problem 2 (Another useful-later special case of Hall). Let G = A ∪ B
誼 se
be a bipartite graph on 2n vertices with minimum degree n/2 and |A| = |B| = n. Show
that G has a perfect matching.
陳 U
ZCE73C9C
[2♣] Problem 3. There are 2017 boys and 2017 girls such that each boy and girl is
《 al
compatible with exactly 100 other members of the opposite gender. A set of k boys and k
n
girls, k ≥ 2, is called dramatic if it is possible to arrange them in a circle with alternating
e rn
genders such that each person is compatible with both of their neighbors. Prove that it’s
h
possible to partition all 4034 people into one or more dramatic sets.
C e
Z05797B3
t
[2♣] Problem 4. Let G be a bipartite graph on A ∪ B, where A and B are finite and
n n
|B| = 2|A|. Assume for every set S ⊆ A, there are at least 2|S| members of B adjacent
a , I
to someone in S. Prove that there is a 1-to-2 matching of elements from A to B.
v
ZB1FC962
[2♣] Problem 5 (Hall doesn’t work on infinite graphs, added by Edward Yu). Show
E I S
that Hall’s theorem does not hold for infinite graphs, even if they are countable. That is,
find an infinite bipartite graph between countably infinite sets A and B for which every
y T
finite subset of S ⊆ A has at least |S| neighbors in B, but there is no way of matching A
B O
to a subset of B.
ZF13143F
[3♣] Required Problem 6. On a 1000 × 1000 chessboard, we delete some squares from
the board so that each row and each column has at most k deleted squares. For which
values of k is it always still possible to place 1000 non-attacking rooks on the board?
(Rooks may still attack across deleted squares.)
12PTNMB3
[5♣] Problem 7 (Putnam 2012 B3). A round-robin tournament among 2n teams lasted
for 2n − 1 days, as follows. On each day, every team played one game against another
team, with one team winning and one team losing in each of the n games. Over the
course of the tournament, each team played every other team exactly once. Can one
necessarily choose one winning team from each day without choosing any team more
than once?
Z685102E
[5♣] Problem 8 (Halls Chessboard). An n × n chessboard has some of its squares
painted blue. Assume that for every n squares chosen, no two in the same row or column,
at least one of the squares is blue. Prove that one can find a rows and b columns whose
intersection contains only blue squares, so that a + b ≥ n + 1.
6
Evan Chen《陳誼廷》 (OTIS, updated 2024-03-26) Hall’s Marriage Lemma
WOOTPO46
[5♣] Problem 9. A table has m rows and n columns with m, n > 1. The following
permutations of its mn elements are permitted: any permutation leaving each element in
the same row (a “horizontal move”), and any permutation leaving each element in the
same column (a “vertical move”). Find the smallest integer k in terms of m and n such
that any permutation of the mn elements can be realized by at most k permitted moves.
18TMD7
[3♣] Problem 10 (Tuymaada 2018/7). A school has three senior classes of M students
each. Every student knows at least 34 M people in each of the other two classes. Prove
that the school can send M non-intersecting teams to the olympiad so that each team
consists of 3 students from different classes who know each other.
10SLC2
[5♣] Required Problem 11 (Shortlist 2010 C2). Let n ≥ 4 be an integer. A flag is a
binary string of length n. We say that a set of n flags is diverse if these flags can be the
》
rows of an n × n binary matrix with the entries in its main diagonal all equal. Determine
the smallest positive integer M such that among any M distinct flags, there exist n flags
廷
forming a diverse set.
誼 se
12SLC5
[9♣] Problem 12 (Shortlist 2012 C5). The columns and the rows of a 3n × 3n square
board are numbered 1, 2, . . . , 3n. Every square (x, y) with 1 ≤ x, y ≤ 3n is colored
陳 U
asparagus, byzantium or citrine according as the modulo 3 remainder of x + y is 0, 1 or 2
《 al
respectively. One token colored asparagus, byzantium or citrine is placed on each square,
so that there are 3n2 tokens of each color.
n
e rn
Suppose that one can permute the tokens so that each token is moved to a distance of at
most d from its original position, each asparagus token replaces a byzantium token, each
h
byzantium token replaces a citrine token, and each citrine token replaces an asparagus
C t e
token. Prove that it is possible to permute the tokens so that each token is moved to a
n
distance of at most d + 2 from its original position, and each square contains a token
n
a , I
with the same color as the square.
v
[1♣] Mini Survey. Fill out feedback on the OTIS-WEB portal when submitting this
E I S
problem set. Any thoughts on problems (e.g. especially nice, instructive, easy, etc.) or
overall comments on the unit are welcome.
y T
In addition, if you have any suggestions for problems to add, or want to write hints for
B O
one problem you really liked, please do so in the ARCH system!
The maximum number of [♣] for this unit is [46♣], including the mini-survey.
7
Evan Chen《陳誼廷》 (OTIS, updated 2024-03-26) Hall’s Marriage Lemma
》
of four rare candies (i.e. the quadruple C that Chad will report) with a quadruple E of
four candies that Eric will remove.
廷
Hence we have a bipartite graph with 12 4 vertices on each side (in the obvious way);
Two subsets C and E are connected if C ∩ E = ∅. Then this graph is regular (degree
誼 se
4 ) and by Hall there exists a matching, which becomes the desired strategy.
8
To make this matching explicit, one can do the following. For each candy in C that
陳 U
has no candy to its left, add to E its leftmost neighbor and then delete both candies.
Repeating this gives a set E and one can check this operation is bijective.
n《 al
Remark. Every year HMMT sends a delegation to PUMaC, which largely ends up helping
e rn
grade the proof contests. Thus Allen Liu and I, among others, received the problem on the
h
bus ride. Allen solved it upon reading the question off my phone, using the Hall approach.
e
It turns out thinking about this problem abstractly, without the aid of paper, actually made
C t
it easier to think about.
n
a , I n
Ev I S
y
B O T