17
From a magic card trick to Hall’s Theorem M. Kawski and H. A. Kierstead A magic card trick is used to explore encoding sets by ordered sequences. Ex- tended hands-on activities involving variations of this trick motivate the in- troduction of (combinatorial) graphs and Hall’s Theorem 1 , and methods that students have developed for showing that these tricks are possible are used to prove Hall’s theorem. Grade Level/Prerequisites: This activity is suitable for students who are comfortable with permutations and combinations, especially the formulas n! (n-k)! and n! k!(n-k)! for the numbers of k -permutations and k -combinations of n ob- jects, and who are interested in problem solving. It is intended for grades 11 and 12, but Problem 1, and parts of Problems 2 and 3 could be used for grade 7. Time: The complete activity will fit in two 75–90 minutes sessions. It could be compressed to one session, or extended to many follow-up sessions. Materials: Each group of (say) three students needs: standard deck of 52 playing cards (4 suits, 13 ranks per suit) with two additional jokers; 112 index cards and 56 paper clips and extras; colored markers (two colors, Sharpies or similar); a large table on which to organize cards and a board with colored markers for collaboration. Preparation: The session leader and an assistant need to practice the magic card trick. If time is limited, the sessions can be sped up if the index cards are prepared beforehand (or cards from a previous session are used). Objectives: Understand a magic card trick, and develop strategies for per- forming variations of it; understand these tricks in the context of encoding sets by ordered sequences; discover natural limitations in terms of numbers of per- mutations and combinations; try out and develop different strategies; model the tricks in terms of graph theory; learn about Hall’s theorem and its appli- cation to these tricks; generalize strategies developed for card tricks to proving Hall’s theorem. Students move from small examples to generalizations and abstractions, with emphasis on asking new questions at every stage; they par- ticipate in making definitions that allow them to more precisely communicate their findings, conjectures, and arguments. 1 This is a fundamental combinatorial theorem with wide mathematical applications. 1

From a magic card trick to Hall’s Theorem - math.la.asu.eduhalk/Publications/124.pdf · A magic card trick is used to explore encoding sets by ordered sequences. Ex- ... We formalize

Embed Size (px)

Citation preview

From a magic card trick to Hall’s Theorem

M. Kawski and H. A. Kierstead

A magic card trick is used to explore encoding sets by ordered sequences. Ex-tended hands-on activities involving variations of this trick motivate the in-troduction of (combinatorial) graphs and Hall’s Theorem1, and methods thatstudents have developed for showing that these tricks are possible are used toprove Hall’s theorem.

Grade Level/Prerequisites: This activity is suitable for students who arecomfortable with permutations and combinations, especially the formulas n!

(n−k)!

and n!k!(n−k)! for the numbers of k -permutations and k -combinations of n ob-

jects, and who are interested in problem solving. It is intended for grades 11and 12, but Problem 1, and parts of Problems 2 and 3 could be used for grade 7.

Time: The complete activity will fit in two 75–90 minutes sessions. It couldbe compressed to one session, or extended to many follow-up sessions.

Materials: Each group of (say) three students needs: standard deck of 52playing cards (4 suits, 13 ranks per suit) with two additional jokers; 112 indexcards and 56 paper clips and extras; colored markers (two colors, Sharpies orsimilar); a large table on which to organize cards and a board with coloredmarkers for collaboration.

Preparation: The session leader and an assistant need to practice the magiccard trick. If time is limited, the sessions can be sped up if the index cards areprepared beforehand (or cards from a previous session are used).

Objectives: Understand a magic card trick, and develop strategies for per-forming variations of it; understand these tricks in the context of encoding setsby ordered sequences; discover natural limitations in terms of numbers of per-mutations and combinations; try out and develop different strategies; modelthe tricks in terms of graph theory; learn about Hall’s theorem and its appli-cation to these tricks; generalize strategies developed for card tricks to provingHall’s theorem. Students move from small examples to generalizations andabstractions, with emphasis on asking new questions at every stage; they par-ticipate in making definitions that allow them to more precisely communicatetheir findings, conjectures, and arguments.

1This is a fundamental combinatorial theorem with wide mathematical applications.

1

From a magic card trick to Hall’s Theorem

Description

Problem 1. With the master magician (the session leader) outside, and theassistant magician in the classroom, the students select a hand of five cardsfrom a standard deck of 52 playing cards, and give it to the assistant magician.The assistant carefully studies the cards, and then places them face-down ina stack on a table and leaves the room. The master magician then enters theroom without communicating with the assistant. The master magician flipsover the first four cards in the stack, and announces what the fifth card is.

Figure 1: Seeing the first four cards, what is the fifth?

Explain how this works, and invent a code for performing it. Practice the trickrepeatedly so that you can perform it quickly and accurately.

As an extra challenge add a joker to the deck and create a strategy to performthe analogous trick with five cards from the expanded deck of 53 cards. Supposeyou add both a red and a black joker?

Problem 2. Call the first trick in Problem 1 the 52,5-trick because the deckhas 52 cards and the hand has 5 cards. The trick with one joker added is the53,5-trick; adding two jokers makes the 54,5-trick. The n,k -trick uses an n-carddeck and k -card hands. Use your strategy for the 52,5-trick to derive strategiesfor the 3,2-trick, 6,3-trick and 15,4-trick. (Hint: Design your own deck. Howmany suits and ranks should you use in each case?) Find a number n, as largeas you can, so that the n,6-trick is possible. Find numbers m,n, as small asyou can, so that the m,2-trick and the n,5-trick are impossible. Which of the7,3-trick, 8,3-trick, and 9,3-trick are possible? Why?

Notice that a strategy for the n,k -trick assigns to each hand a permutation ofits cards so that no two hands are assigned the same permutation.

2

Problem 3. Now the students break up into teams of size about three2, eachteam having their own table. Our goal is to concentrate all our energy on the8,3-trick. We abandon the suits and ranks of the deck of cards, and instead justconsider a deck D whose cards are numbered by integers 1, 2, . . . , (n − 1), n.We can still, for example, do the first trick (more slowly) by identifying integerswith card values. Here is one way: 1 7→ A♣, 2 7→ A♦, 3 7→ A♥, 4 7→ A♠, 5 7→2♣, . . . , 51 7→ K♥, 52 7→ K♠.

We write nCr for the set of r -combinations (hands) of the n-card deck D ; thenthe cardinality of nCr is |nCr| = nCr . Similarly, we write nPr for the set ofr -permutations of D ; then the cardinality of nPr is |nPr| = nP r .

Figure 2: Checking for duplications and missing cards.

1. Label one set of index cards with all subsets of {1, 2, . . . , 8} that have threeelements (use a green pen, write near the top of the vertical card). Here, forexample, the combinations {2, 4, 7} and {4, 7, 2} are considered equal. Howmany are there?

2. Label a second set of index cards with all 2-card permutations of {1, 2, . . . , 8}(use a red pen, write near the top of the vertical card). Here, for example, thepairs (2, 3) and (3, 2) are considered different. How many are there?

3. Sort and lay out the index cards in a systematic pattern on the table. Onepossible way is shown in the Math Circle photo in Figure 2. Use this pattern

2How many cooks make the best broth?

3

to check for duplicates. Check that your set of cards is complete by counting,and comparing results with the formulas nPk = n!

(n−k)! and nCk = n!k!(n−k)! .

4. Find a pair of index cards such that one is a green combination {i, j, `}and the other is a red permutation (r, s) with {r, s} ⊆ {i, j, `}. For example{1, 3, 7} could form a pair with (3, 7) but not with (2, 7). Use a paper clipto attach these index cards so that both the combination and permutation arevisible. We call this a clipped pair. Form as many non-overlapping clippedpairs as you can.

5. As the available permutations become scarce, discover methods to makechanges to the pairs that result in more clipped pairs. The goal is to use everyindex card in a clipped pair (why?).

6. Reflect on whether it is always possible, as long as there are unclipped indexcards, to increase the number of clipped pairs. Focus on strategies for breakingclipped pairs and clipping new pairs that result in more clipped pairs. Beforeremoving any paper-clips, plan which pairs to change in order to increase thenumber of clipped pairs.

7. When you succeed in clipping every index card to another, use the result toperform the trick (not necessarily from memory).

Before stating the next problem let us agree on some technical language whichfacilitates more precise descriptions of situations and arguments. In order tomore effectively analyze the n,k -trick it is natural to visualize the possiblepairings in a graph as shown in Figure 3 for the special case of the 4,3-trick.

(1, 2) (2, 1) (1, 3) (3, 1) (1, 4) (4, 1) (2, 3) (3, 2) (2, 4) (4, 2) (3, 4) (4, 3)

{1, 2, 3} {1, 2, 4} {1, 3, 4} {2, 3, 4}

������

����

���

���

��

!!!!

!!!!

!!!!

!!!

�����

���

���

���������

���������A

AAAAA������

HHHH

HHHHHH

HH

aaaaaaaaaaaaaaa���������A

AAAAA

@@@@@@

aaaaaaaaaaaaaaa

PPPPPPPPPPPPPPPPPP����

���

���

��

���������Q

QQQQQQQQ

HHHH

HHHHHH

HH������

������AAAAAAv v v v v v v v v v v v

v v v v

Figure 3: Possible pairings of 4C3 with 4P2 displayed as the graph G4,3

Each possible hand is a combination in 4C3 represented by a ‘top’ vertex drawnas a dot. Each permutation in 4P2 is represented by a ‘bottom’ vertex drawnas a dot. There is an edge linking a hand to a permutation, drawn as a line, ifit is possible to code the hand with the permutation. This means that all the

4

cards in the permutation are also in the hand. For example, since (4, 2) can beformed from some of the elements of {1, 2, 4}, the combination {1, 2, 4} is linkedto the permutation (4, 2) by an edge in the graph. We write {1, 2, 4}(4, 2) or(4, 2){1, 2, 4} for this edge. More generally, the set of edges E consists of thelinked pairs of vertices of the form {c1, c2, c3}(p1, p2), where

{p1, p2} ⊆ {c1, c2, c3} ⊆ {1, 2, 3, 4}.

We formalize such pictorial notions in modern mathematical language.

Definition 1 A graph G = (V,E) consists of a set V of vertices and a setE of edges. Each edge e ∈ E consists of two linked vertices x and y , and isdenoted by e = xy . The order of the vertices does not matter, so the edge ecan also be written as e = yx. The vertices x and y are called the ends of e.A graph is finite if it has finitely many vertices.

The graphs considered in our problems have a distinguishing structure thatdeserves its own name.

Definition 2 A graph G = (V,E) is said to be bipartite if the vertex set Vcan be divided into a ‘top’ part C and a ‘bottom’ part P so that no two verticesof C are linked by an edge in E , and no two vertices of P are linked by anedge in E . In this case we say that G is a (C,P )-bipartite graph.

The graph in Figure 3 is a (4C3, 4P2)-bipartite graph. We call it G4,3 . Moregenerally, let Gn,k be the (nCk, nPk−1)-bipartite graph, whose edges are pairsHP where H is a hand of k cards and P is a (k− 1)-permutation of the cardsof H .

Definition 3 A matching in a graph G = (V,E) is a subset M ⊆ E of edgessuch that every vertex is an end of at most one edge in M . A vertex is said tobe matched if it is the end of an edge in M ; otherwise it is unmatched. A set ofvertices X ⊆ V is said to be matched if every x ∈ X is matched. A maximummatching is a matching that has at least as many edges as any other matching.

Problem 4. Explain clearly why the n,k -trick has a solution if and only if thegraph Gn,k has a matching that matches nCk . Illustrate this for the 4,3-trickusing Figure 3 and explain your work in Problem 3 in these terms.

While struggling with Problem 3, you likely wondered whether there reallywas a matching that included all index cards. For example, Figure 4 shows

5

(1) (2) (3) (4)

{1, 2} {1, 3} {1, 4} {2, 3} {2, 4} {3, 4}

@@@

@@@

������

HHH

HHH

HHH

HHH

������

���

���

���

���

HHH

HHH

HHH

HHH

���

���

���

���

HHH

HHH

HHH

HHH

������

v v v v

v v v v v v

Figure 4: Possible pairings of 4C2 with 4P1 as the bipartite graph G4,2

the graph G4,2 that is associated with the 4,2-trick. It is apparent (why?)that this trick is impossible. Hall’s Theorem is a general result for bipartitegraphs stating that it is always possible to find such a matching provided onenecessary condition is satisfied. To precisely state this condition, we need somemore notation.

For a vertex v ∈ V in a graph G = (V,E) we write N(v) for the set of vertices,called neighbors of v , that are linked to v by an edge in E . For a set of verticesX ⊆ V we write N(X) for the set of vertices that are neighbors of some vertexin X . For example, in Figure 4, if v = {1, 2} then N(v) = {(1), (2)} and ifX = {{1, 2}, {1, 3}} then N(X) = {(1), (2), (3)}.

Theorem 1 (Hall’s Theorem [6]) A finite3 (C,P )-bipartite graph has a match-ing such that C is matched if and only if

|X| ≤ |N(X)| for all X ⊆ C. (1)

Problem 5. Prove Hall’s theorem using methods developed in Problem 3.

Here are some hints. Let G be a finite (C,P )-bipartite graph. First suppose Ghas a matching that matches C . To check that Eq.(1) holds, consider any subsetX ⊆ C . Why must the vertices of X have at least |X| distinct neighbors? Youmay want to think about the special case of Problem 3 where X is a set of ‘red’index cards that have been clipped to ‘green’ index cards.

Now suppose G has no matching such that C is matched. The goal is to proveEq. (1) fails for at least one subset X ⊆ C . Consider a maximum matching Min G; it exists because G is finite. Try to improve M using methods generalizedfrom Problem 3. As M is maximum, this must fail. Construct such a set Xby analyzing the reason for this failure.

3It is easy to construct examples of infinite graphs for which the theorem fails.

6

u = v0 v2 v4 vn−1

u = v0 v2 v4 vn−1

v1 v3 v5

. . .

vn−2 vn

v1 v3 v5

. . .

vn−2 vn

AAAAAA

AAAAAA

AAAAAA

AA

AAAAAA

������

������

��

������

������

������

������

������

������

������

������

������

������

������

����������

������

������

������

������

������

AAAAAA

AAAAAA

AAAAAA

AAAAAA

AAAAAA

AAAAAA

AAAAAA

AAAAAA

AAAAAA

AAAAAA

AAAAAA

AAAAAA

AAAAAA

AAAAAA

AAAAAA

AAAAAAAAAA

AAAAAA

AAAAAA

AAAAAA

AAAAAA

AAAAAA

v v v v v

v v v v

v v v v v

v v v v

Figure 5: An augmenting path.

For inspiration, consider your work on Problem 3. In particular, recall a situa-tion like the one sketched in Figure 5. The green vertices on the top correspondto hands, the red ones on the bottom to permutations. The orange edges cor-respond to clipped pairs. The gray edges stand for other possible, but unusedpairings. In this case there is an unclipped hand u = v0 , all of whose possiblepermutations may be in use. But by putting together a sequence of cards, wecan find an alternating path of hands and permutations that connects u withan unclipped permutation vn . The key step was to break the pairs representedby the orange edges, and clip together new pairs corresponding to the violetedges. This process increased the number of clipped pairs.

Before extending this key trick to a proof of Hall’s Theorem, we formalize thesituation illustrated in Figure 5 with more definitions of formal terminology.

Definition 4 Let G be a graph. A path Q = v1v2 . . . vn in G is a sequenceof distinct vertices of G such that each pair vivi+1 is an edge of G. The setof vertices of Q is V (Q) = {v1, . . . , vn} and the set of edges of Q is E(Q) ={v1v2, v2v3, . . . , vn−1vn}. For a matching M , the path Q is an M -alternatingpath if each vertex v ∈ V (Q) is an end of at most one edge in E(Q) rM ; inthis case Q is M -augmenting if its ends v1 and vn are unmatched.

Using this language the sets of red edges M = {v1v2, . . . vn−2vn−1} and greenedges L = {v0v1, . . . vn−1vn} in Figure 5 form matchings, and Q = v0v1 . . . vn

7

is both an M -alternating path and an L-alternating path; also Q is an M -augmenting path, but not an L-augmenting path. Replacing M with L resultsin a larger matching. We conclude:

Lemma 1 If a graph with a matching M has an M -augmenting path, thenM is not a maximum matching.

Problem 6. Use your previous work and Hall’s Theorem to show that the n,k -trick is possible if and only if n ≤ k! + k − 1.

Teacher Guide/Solutions

Solutions:

Problem 1. We start with a quick explanation of why the 52,5-trick is possible.

The assistant and magician will use permutations of three cards, here calledlow, mid, and high to code the integers 1, 2, 3, 4, 5, 6. There are 6! such codes.The magicians could agree to use the following code, since it is easy to compute.

(high, mid, low) 7→ 1 (mid, high, low) 7→ 2 (mid, low, high) 7→ 3(high, low, mid) 7→ 4 (low, high, mid) 7→ 5 (low, mid, high) 7→ 6

The rule is: add the position (1, 2 or 3) of the high card to 0 if the mid cardcomes before the low card, and to 3 if mid card comes after the low card.

The magicians agree to order the deck by ranks ordered by A, 2, . . . , 10, J,Q,Kand break ties between ranks by suits ordered as ♣,♦,♥,♠ (alphabetical or-der). So A♠ precedes K♦ and 5♦ precedes 5♥.

Performing the 52,5-trick. The hand the assistant receives from the studentshas 5-cards. As there are only 4 suits in the deck, it must contain two cards c1and c2 from the same suit. The assistant chooses c1 and c2 so that the num-ber of steps t from the rank of c1 to the rank of c2 in the clockwise orderA, 2, . . . , 10, J,Q,K,A is as small as possible. Then c1 will be put in the firstposition and c2 in the last position (c2 is the card the magician must deter-mine). As they have the same suit, these cards have different ranks, so thereare 11 remaining ranks. Thus 1 ≤ t ≤ 6. Order the remaining three cards tocode t.

After turning over the first four cards, the magician (i) knows that the suit ofthe first card is the same as the suit of the last card, (ii) can determine t fromthe pattern of the next three cards, and (iii) can calculate the rank of the last

8

card by counting t clockwise steps from the rank of the first card. For example,in Figure 1, the fifth card is a heart, because the first card is. Since the nextthree cards have the pattern (high, low, mid), we have t = 4. Four steps from10 in clockwise order yields A, so the fifth card is the ace of hearts.

Performing the 53,5-trick. Now the deck has a joker. There are three cases.

Case 1: The hand does not contain the joker. Then the assistant uses themethod designed for the 52,5-trick.

Case 2: The hand contains no two cards of the same suit (so it contains ajoker). The assistant chooses a pair of cards c1 and c2 so that it is possible tomove clockwise from the rank of c1 to the rank of c2 in 0 ≤ t ≤ 3 steps andplaces c2 last. Then the assistant places the joker in position t + 1 and c1 inthe first position not occupied by the joker. So if t = 0 then the joker comesfirst and c1 comes second; else c1 comes first. The order of the remaining twocards c3 and c4 does not matter (for now) but the smaller is put first.

Case 3: The hand contains a joker and at least two cards from the same suit.The assistant chooses c1 and c2 and calculates t as in Case 1, puts c1 first andthe joker last, and orders the remaining three cards (including c2 !) to code t.

After turning over the first four cards, the magician checks to see if a joker isshowing. If so, the hand must satisfy Case 2. Then the other three face-upcards have different suits, and the suit of the last card is the only suit that isnot showing. Moreover the magician can determine the rank of the last cardfrom the position of the joker and the rank of the first-face-up non-joker.

Now suppose the joker is not showing. Then the hand could be in Case 1 orCase 3. The magician assumes that Case 1 holds, and using the methods forthe 52,5-trick, calculates what the last card c should be. If c is showing theassumption is false, so the hand is in Case 3 and the last card is the joker. Else,the assumption is true, and the last card is c.

Performing the 54,5-trick. Now the deck as are a red and a black joker. Thecoding must be slightly modified from the previous trick in case the hand hastwo jokers and also to distinguish the color of the joker in Case 3.

If there are two jokers the assistant will show one of them and put the otherlast. In Case 2, the magician is notified that the last card is the other joker byreversing the order of c3 and c4 . In Case 3 the magician will see two cards inthe same suit and a joker, so he will also know the last card is the other joker.

If there are at least two cards in the same suit and a joker, then the assistantpicks c1 and c2 as before, puts c1 in the first position and the joker in the

9

last position, but codes 5 for the red joker or 6 for the black joker. Now themagician knows the hand is in Case 3, because in Case 1 the the last card wouldbe in the same suit as c1 and c2 , and so t would be at most 4.

Problem 2.

Impossibilities. For the 4,2-trick, consider Figure 4. As there are more hands(6) than permutations (4), any plan must assign different hands to the samepermutation, and so the magician will not be able to identify the last card withcertainty. More generally, the n,k -trick is impossible if nCk > nPk−1 . This isthe case for the 9,3-trick and the 125,5-trick.

Strategies. Put n = (2(k − 2)! + 1)(k − 1). The strategy for the 52,5-trick canbe extended to the n,k -trick. In particular, we can do the 3,2-trick, 6,3-trickand 15,4-trick. To see this, start with a deck with k− 1 suits and 2(k− 2)! + 1ranks. Again we use orderings of the ranks and the suits to order the cards, andwe create a circular ordering of the ranks. Again there are two cards c1 and c2with the same suit, and we can choose the names c1 and c2 so that we can countfrom the rank of c1 to the rank of c2 in at most 1 ≤ t ≤ (k−2)! clockwise steps.The assistant puts c1 first, c2 last, and orders the remaining k − 2 cards tocode t using some agreed method. Again the magician can determine the suitof c2 from the suit of c1 , decode t from the order of the middle k−2 cards, andcalculate the rank of c2 from t and the rank of c1 . Similarly, the (n+1),k -trick,including the 7,3-trick, can be performed by generalizing the strategy for the53,5-trick, but our solution of the 54,5-trick fails for the 8,3-trick (why?).

Here are some examples. For k = 2, there are three cards and one suit. Theset of k − 2 = 0 middle cards is empty, and has 0! = 1 orderings (the emptyordering). The cards c1 and c2 are chosen so that c2 follows 1 step after c1 inthe circular order. For k = 3 there are six cards and two suits, but still onlyone ordering of the middle elements. For k = 4 there are 15 cards, three suits,and finally two orderings of the middle elements. For the n,3-trick, one readilycomputes that n = 8 is the largest deck for which the trick might work, sincen ≥ 9 implies n− 2 ≥ 7 > 6 = 3!, and so

nC3 =n(n− 1)(n− 2)

3!> n(n− 1) = nP2.

Problem 3. The obvious necessary condition that 8C3 ≤ 8P3 is satisfied, butat this stage it is unclear whether a coding is possible, due to the constraintthat the cards in the 2-permutation that codes a hand must be chosen fromthe cards of that hand.

10

{1,5,7} {1,7,8}(7, 5) (7, 8) (8, 7)

{2,4,6} {4,5,6} {4,5,7} {5,7,8} {5,6,8}(2, 4) (4, 5) (5, 4) (5, 8) (8, 5)

{1,2,3} {2,4,5} {2, 3,6} {3,5,7} {2,5,7} {3,5,8}(2, 3) (2, 5) (3, 2) (3, 5) (5, 2) (5, 3)

{2,3,5}

HHHHH

�����

�����

�����

�����

����

H�

H H� �

H H H� � �H H� �

H H H H H H� � � � � �HHH

HH

HHH

HH

HHH

HH

HHH

HH

HHH

HH

�����

�����

. . .

HHH

HH

���

��

``````

``````

PPPP

PPPP

@@@

���

����

����

Figure 6: Trying to increase the number of clipped pairs of cards.

Suppose we have started clipping pairs as in (1–4) of Problem 3, and eventu-ally there are no more unclipped index cards that can be paired to extend theexisting clipped pairs. Focus on one unclipped ‘green’ card’ (hand, combina-tion) c. Find all pairs whose ‘red’ card (permutation) could be matched to cand arrange them above c with their ‘red’ card below their ‘green’ card as inFigure 6. There will be six of these pairs above c. Now focus on the ‘green’cards in these lower pairs. Find all the ‘red’ cards (either clipped or unclipped)that are eligible to be clipped with these ‘green’ cards and put them and anyclipped mate above one of the corresponding ‘green’ cards as before. Continuethis process. Eventually you are guaranteed to have an unclipped ‘red’ card pat the top of this structure.4 Now there is a path from the unclipped card pto the unclipped card c such that pairs alternate between being unclipped andclipped. Rearranging the clips yields more clipped pairs. Repeat this processuntil all ‘green’ cards are clipped. At this point it is clear that the 8,3-trick canbe performed: The assistant and magician agree to code each hand with the

4You do not need to prove this until Problem 5; for now reflect on how many ‘green’and how many ‘red’ cards there would be in the structure if it were false.

11

permutation that is clipped to it. Given a hand the assistant arranges the cardsto reveal the permutation clipped to that hand, so the magician will know theoriginal hand and the hidden card.

Problem 4. First suppose Gn,k has a matching such that nCk is matched.Then the assistant and magician agree that the code for a hand H is thepermutation P to which H is matched. Since HP ∈ E(Gn,k) the assistant canarrange the first k− 1 cards of H in the order of P . Since no other edge of thematching has P for an end, when the magician sees P he will know H . So then,k -trick can be performed.

On the other hand, if this trick can be performed, the assistant can agreethat for any hand H she will always code H with the same permutation P .Moreover, she cannot code two hands with the same permutation. So all suchpairs HP will form a matching of Gn,k such that nCk is matched.

Proof of Theorem 1 (Problem 5.) For necessity, suppose G has a matchingsuch that C is matched, and consider any X ⊆ C . Since every vertex x ∈ X ismatched to a vertex of N(x) ⊆ N(X), and no two vertices of C are matchedto the same vertex, |X| ≤ |N(X)|.

For sufficiency, let G = (V,E) be a finite (C,P )-bipartite graph such that Cis not matched by any matching. This means that for every matching there isa vertex in C that is not matched. Our goal is to show that Eq. (1) fails. Wedo this by finding a subset X ⊆ C with |X| > |N(X)|.

Let M be a maximum matching in G; it exists since G is finite. By hypothesis,there is an unmatched vertex u. Let A ⊆ V be the set of all vertices v suchthat there exists an alternating path starting with u and ending with v . SetX = A ∩ C and Y = A ∩ P . Then u ∈ X (witnessed by the trivial path thatbegins and ends with u). Since G is a (C,P )-bipartite graph we observe: Forevery alternating path uv1 . . . vn and for each index i, if i is even then vi ∈ X ,and if i is odd then vi ∈ Y . Moreover, vi−1vi ∈M if and only if i is even.

We first show that N(X) ⊆ Y , that is, every neighbor of a vertex in X is in Y .Suppose z ∈ N(X). Then there is a vertex w ∈ X with wz ∈ E . Then w isthe end of an M -alternating path Q = v0 . . . vn with v0 = u and w = vn ∈ X .By our observation, the index n is even, and so vn−1vn ∈M . Either z ∈ V (Q)or Qwz is an alternating path. In either case, z ∈ Y . So N(X) ⊆ Y , andtherefore |N(X)| ≤ |Y |.

To finish, it suffices to show that |Y | < |X|. Consider a vertex ym ∈ Y . Byour observation, it is the end of an M -alternating path Q = uy1 . . . ym , where

12

m is odd. As M is a maximum matching, Q is not an M -augmenting path byLemma 1. So ym is matched. Thus there is an x ∈ C such ymx ∈ M . As uis unmatched, x ∈ C r {u} and Qymx = uy1 . . . ym−1ymx is an M -alternatingpath. Thus x ∈ X r {u}. We have shown that:

Every vertex of Y is matched to a vertex of X r {u}.

Consequently |Y | ≤ |Xr{u}|. As u ∈ X and X is finite, |Xr{u}| < |X|.

The following corollary is often sufficient for applying Hall’s Theorem.

Corollary 1 If G = (V,E) is a finite (C,P )-bipartite graph that satisfies

|N(x)| ≥ |N(y)| for all vertices x ∈ C and y ∈ P , (2)

then G has a matching such that C is matched.

Proof Suppose the hypothesis holds. Then there exists an integer n such that|N(x)| ≥ n ≥ |N(y)| for all vertices x ∈ C and y ∈ P . Using Hall’s Theorem,it suffices to check (1). We will need the notation: for X,Y ⊆ V , the set ofedges of G with one end in X and one end in Y is denoted by

E(X,Y ) = {xy ∈ E : x ∈ X and y ∈ Y }.For Eq. (1), consider any subset X ⊆ C . Then

n|X| ≤ |E(X,P )| = |E(X,N(X))| ≤ n|N(X)|.Dividing by n we have |X| ≤ |N(X)|, so (1) holds.

Problem 6. We claim that the n,k -trick is possible if and only if n ≤ k! +k−1.

Suppose the n,k -trick is possible. From Problem 2 we know nCk ≤ nP k . Thus,

n!

k!(n− k)!= nCk ≤ nPk =

n!

(n− k + 1)!.

Multiplying both sides by k!(n− k + 1)!/n! yields n ≤ k! + k − 1.

Now suppose n ≤ k! + k − 1. We show that the n,k -trick is possible byproving that the graph Gn,k has a matching such that nCk is matched. ByCorollary 1, it suffices to check that |N(H)| ≥ |N(p)| for all hands H ∈ nCkand permutations p = (c1, . . . , ck−1) ∈ nPk−1 . The neighbors of H are (k−1)-permutations of H , so |N(H)| = k!

(k−(k−1))! = k!. The neighbors of p have

the form {c1, . . . , ck−1, ck} where ck is a card not used in p. Thus |N(p)| =n− (k − 1) = n− k + 1. Since n ≤ k! + k − 1, we have

|N(H)| = k! ≥ n− k! + 1 = |N(p)|.

13

Mathematics Beneath & Beyond:

1. We have proved that the (k! + k− 1),k -trick is possible, but have not givena good way to perform it. There is a relatively easy algorithm; the hardest partof the calculation is coding and decoding {1, . . . , k!} with kPk−1 . For k = 3 thealgorithm can be performed with mental calculation; for k = 5 it can certainlybe done in real time with pencil and paper.

2. Consider a variation of our trick. Start with the deck {1, . . . , 2k + 1}. Theassistant receives a hand of k + 1 cards, and turns all but one face-up. Thestudents are allowed to mix-up the order of the face-up cards. Again it is themagician’s task to determine the face-down card. The ideas from Problem 6can be modified to prove that this trick is possible. Reading between the linesof [8, 3], there are many algorithms for performing it. Here is one. The assistantcalculates the sum i of the cards in the hand modulo k + 1. She then removesthe (i+1)st -smallest card in numerical order. The magician calculates the sumj of the remaining cards modulo k + 1. He then guesses the (j + 1)st -largestmissing card. For example with k = 6, if the hand is {1, 2, 5, 6, 9, 10, 13} theni = 4, so the assistant removes 9. Now j = 2, so the magician correctly guessesthe third largest card 9 from the missing cards 12, 11, 9, 8, 7, 4, 3.

3. Here is an infinite C,P -bipartite graph G = (V,E) that satisfies Eq. (1),but has no matching for which C is matched: Set C = {x1, x2, x3, . . . }, P ={y1, y2, y3, . . . } and E = {x1y1, x1y2, x1y3, . . . }∪{x2y1, x3y2, x4y3, . . . }. For allX ⊆ C , we have |X| = |N(X)| if x1 /∈ X and N(X) = P if x1 ∈ X , so Eq. (1)holds, but C is not matched by any matching M , since if x1yi ∈M then xi+1

is not matched. Infinite versions of Hall’s Theorem are explored in [5, 7, 12].

4. We have introduced matchings in graph theory in the playful context ofcard tricks, but the general theory of matchings has great importance in graphtheory, computer science and operations research. Here is a more serious, butstill easily understood, application. A university must assign dorm roommates.Among the collection of incoming students there are many pairs of studentswho are incompatible with each other. Is it possible to match the studentsinto roommate pairs so that there are no incompatibilities? This question goesbeyond Hall’s Theorem as the associated graph whose vertices are students andwhose edges are compatible pairs of students is most likely not bipartite. Evenif we know there is a solution, can we find it effectively? For an even deeperproblem, we rate the compatibility of any pair of students, and try to find amatching that maximizes the sum of the compatibilities of the matched pairs.For a comprehensive reference on matchings see [11].

14

Presentation:

1. This project is aimed at strong students in grades 11 and 12, but by con-centrating on combinations, permutations and coding, the first three problemswould be appropriate for younger or less advanced students.

2. In Problem 1 do not give away too much after performing the trick. If helpis needed suggest to separately look at the suit and the rank of the hidden card.The discussion should eventually focus on using the order (permutation) of themiddle three cards for the rank of the hidden card.

3. The 53,5-trick and 54,5-trick problems are quite a bit harder and make forchallenging homework problems. A reasonable suggestion to the students is todistinguish different cases.

4. Do not miss empowering the students by asking them to make up their owncard decks with fewer or more suits, and corresponding numbers of ranks. It isfun the perform the trick with, say, just 3 suits and ranks from ace to 5.

5. In Problem 3 it may take students quite a bit of time to make their ownindex cards. But this provides ownership, and familiarity with the cards. Ifseveral students work together, expect it to take some time until they agreehow to divvy up the task of labeling 112 cards. If time is at a premium, at leastask them to check whether the provided decks are complete, suggesting to laythem out in some systematic arrangement.

6. As unclipped cards become scarce, students will naturally start unclippingpairs of cards. We suggest to intervene as deemed appropriate: Try to discour-age randomly break pairs and clipping them back together in different pairs.Instead ask for strategies, to work together, make plans, lay out a path betweenunclipped cards which eventually leads to fewer unclipped index cards as cap-tured live in a math circle in the photo shown in Figure 7. If students are tryingto code an unclipped hand {i, j, k}, challenge them to at the same time find apartner for a very distant unused code (m,n), e.g., where the sets {i, j, k} and{m, n} have no common members. This leads to be more strategic planninghow to select a sequence of pairs that should be broken, and clipped togetherin a new way

7. We like to engage the students in the process of making definitions whichis an important part of the mathematical enterprise, as are generalizations.Emphasize that technical definitions make it easier to communicate with eachother, avoid misunderstandings. Abstracting from tangible playing cards andpaper clips to model these by graphs and matchings is a key stage of thissequence of activities.

15

Figure 7: Identifying an augmenting path

8. After visualizing the trick in terms of graphs in Problem 4, an importanttheorem of graph theory is proved in Problem 5. The necessity of the conditionEq. (1) in Hall’s theorem should be very clear by now, and provides a goodstart, by quickly getting the first part of the proof done. The organization ofthe sufficiency argument, using the contrapositive, likely needs some help bythe session leader. But most of the remaining argument can certainly be doneby teamwork of students with the session leaders. Key are the experienceswith the paper clips, and the pictorial illustration of augmenting paths figure 5.Regarding the contrapositive of the statement in Hall’s Theorem, rather thanshowing that if the inequality is satisfied for all subsets X , then one always canfind an augmenting path, the suggested argument assumes that no augmentingpath exists and then constructs one subset X of vertices that does not meetthe inequality in Hall’s theorem.

9. After proving Hall’s Theorem in Problem 5, the final problem applies graphtheory to give a conclusive answer to our central question, first raised in Prob-lem 2: For any fixed size k of a hand, what is the largest number n of cards in

16

a deck such that the n,k -trick is possible?

References/Authorship: The card trick has a long history dating back atleast to the 1950s [10] and it is commonly known as the Fitch Cheney Trick.Several recent articles in MAA magazines such as [14] revisit this trick anddiscuss related items. Searches of the WWW bring up an abundance of furtherblog-spots and related discussions. In the math circles community a descriptionmay be found here [1].

Hall’s (Marriage) Theorem was proven by Philip Hall in 1935 [6]. Four yearsearlier, Konig [9] and Egervary [4] independently proved an equivalent theorem.

The authors first developed and class-tested the activity presented here in 2011in a math circle [13] with high school age students.

References

[1] Davis, T., Mathematical Card Tricks (2008).http://www.geometer.org/mathcircles/CardTricks.pdf

[2] Diestel, R., Graph Theory, 5th ed. (2017), Springer.http://diestel-graph-theory.com/

[3] Duffus, D. A., Kierstead, H. A., and Snevily, H. S., An explicit 1-factorization in themiddle of the Boolean lattice, J. Combin. Theory Ser. A, 65 (1994), 334–342.

[4] Egervary, E., On combinatorial properties of matrices (Hungarian with German sum-mary), Mat. Lapok, 38 (1931), 16–28.

[5] Hall, M., Combinatorial Theory (2nd ed.), (1986), New York: John Wiley & Sons,ISBN 0-471-09138-3

[6] Hall, P., On Representatives of Subsets, J. London Math. Soc., 10 no.11 (1935), 26-30.

[7] Kierstead, H. A., An effective version of Hall’s theorem, Proc. Amer. Math. Soc., 88(1983), 124–128.

[8] Kierstead, H. A. and Trotter, W. T., Explicit matchings in the middle levels of theBoolean lattice, Order, 5 (1988), 163–171.

[9] Konig, D., Graphen und Matrizen, Mat. Lapok, 38 (1931), 116–119.

[10] Lee, W., Math Miracles, (1951) Micky Hades International.

[11] Lovasz, L. and Plummer, M. D., Matching theory,Annals of Discrete Mathematics 29 (1986) North-Holland Publishing Co., Amsterdam.

[12] Manaster, A. ; Rosenstein, J. Effective matchmaking (recursion theoretic aspects of atheorem of Philip Hall), Proc. London Math. 25 (1972) 615–654.

[13] Math Circle at ASU Tempe, calendar of events, https://math.la.asu.edu/

~mathcircle/events.php#events.

[14] Mulcahy, C., Mathematical Card Magic: Fifty-Two New Effects (2013), A K Pe-ters/CRC Press.

17