0% found this document useful (0 votes)
23 views

Combinatorics Web

Uploaded by

allfarhaniisalem
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Combinatorics Web

Uploaded by

allfarhaniisalem
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 146

Introduction to Combinatorics

Mark Wildon
Contents

Introduction page 1

PART ONE ENUMERATION 5


1 The Derangements Problem 7
1.1 Derangements 7
Exercises 14
2 Binomial coefficients 19
2.1 Binomial coefficients and bijective proofs 19
2.2 Basic binomial identities 22
2.3 Balls and urns 27
2.4 Binomial coefficients as polynomials 30
Exercises 32
Interlude I: The Egg Dropping Problem 39
3 Principle of Inclusion and Exclusion 45
3.1 Introduction to the Principle of Inclusion and Exclusion 45
3.2 Counting derangements 47
3.3 Counting five card hands 48
3.4 Prime numbers and Euler’s f function 49
Exercises 53
4 Rook Polynomials 60
4.1 Introduction to rook polynomials 60
4.2 Splitting boards 62
4.3 Complementary boards and the Problème des Ménages 64
Exercises 71
iv Contents

PART TWO GENERATING FUNCTIONS 81


5 Introduction to generating functions 83
5.1 First examples 83
5.2 The Generalized Binomial Theorem 83
5.3 What are generating functions? 84
Exercises 84
6 Recurrences and asymptotics 85
6.1 The three-step method for solving recurrence relations 85
6.2 Applications 85
6.3 Ansatz methods 85
6.4 Asymptotic results from generating functions 86
6.5 Fibonacci and Lucas numbers 86
Exercises 86
Interlude II: Snakes and Ladders 88
7 Partitions 89
7.1 Introduction to partitions 89
7.2 q-binomial coefficients 89
7.3 Euler’s Pentagonal Number Theorem 89
7.4 Asymptotic results: Erdős and van Lint–Wilson arguments 89
7.5 The abacus and `-cores 90
Exercises 90
8 Convolutions and the Catalan Numbers 91
8.1 Decomposing objects 91
8.2 Catalan Numbers 91
8.3 Binomial inversion and derangements 91
8.4 Lagrange inversion and generalized Catalan numbers 91
Exercises 91
9 Exponential generating functions 93
9.1 Decomposing labelled objects 93
9.2 The cycle decomposition of permutations 93
9.3 Polya’s Cycle Index Formula 93
9.4 Enumerating Latin rectangles 94
Exercises 94
Interlude III: The Locker Room 95
Contents v

PART THREE RAMSEY THEORY AND PROBABILITY 97


10 Introduction to Ramsey Theory 99
10.1 Small Ramsey Numbers 99
10.2 Ramsey’s Theorem 99
10.3 Union bound and lower bounds for Ramsey Numbers 99
Exercises 99
11 Beyond Ramsey’s Theorem 100
11.1 Schur’s Theorem 100
11.2 Ramsey’s Theorem for k-subsets 100
11.3 Infinite sets 100
11.4 Ramsey’s Theorem for paths 100
Exercises 101
12 First moment method and applications 102
12.1 First moment method 102
12.2 Applications to random graphs and tournaments 102
Exercises 102
13 Lovasz Local Lemma 103
13.1 Proof of the Lovasz Local Lemma 103
13.2 The Ramsey numbers R(3,t) and other applications 103
Exercises 103
Interlude IV: Hats 104

PART FOUR FURTHER DIRECTIONS 105


14 Further directions 107
14.1 Derangements 107
14.2 Binomial coefficients and the WZ-method 107
14.3 Hales–Jewett theorem 107

Appendix A Reminder of notation 109


Appendix B Background from probability and analysis 110
Appendix C Solutions to exercises 111
Appendix 5 End notes 167

References 169
Index 171
Introduction

Combinatorial arguments may be found in all branches of mathematics. Many


people become interested in mathematics through a combinatorial problem. But,
strangely enough, at first many mathematicians tended to sneer at combinatorics.
Thus one finds:
“Combinatorics is the slums of topology.”
J. H. C. Whitehead (early 1900s, attr.)

Fortunately attitudes have changed, and the importance of combinatorial argu-


ments is now widely recognised:
“The older I get, the more I believe that at the bottom of most deep mathematical problems
there is a combinatorial problem.”
I. M. Gelfand (1990)

Combinatorics is a very broad subject. This book gives a straightforward and


motivated introduction to four related areas of combinatorics. Each is the subject
of current research, and taken together, they give a good idea of what combinatorics
is about. While one aim is to show a range of important techniques, the material
is chosen primarily to maximize interest and accessibility. No attempt is made at a
comprehensive treatment.

Outline
[This is not necessarily close to the final form of this section, but should give
an idea of the planned content.]
[Estimated page count at most 420 pages: 200 pages for the main text, 30 pages
for Appendices A, B and D, 180 pages, but probably less, for Appendix C
(solutions to exercises).]
2 Introduction

Part A: Enumeration
We begin with bijections and adding and multiplying choices: the building blocks
of combinatorial enumeration.
• The derangements problem: enumerating permutations with no fixed points.
This problem is solved eight times in the book, each solution illustrating a
different combinatorial technique.
• Binomial coefficients, emphasising memorable bijective proofs of the key
identities.
• Principle of Inclusion and Exclusion with applications to Euler’s f function
and counting
• Rook polynomials. Applications including the Problème des Ménages.

Part B: Generating functions


A generating function is a power series whose coefficients record a combinato-
rial sequence. For example, the generating function for the Fibonacci numbers
0, 1, 1, 2, 3, 5, 8, 13, . . . is x + x2 + 2x3 + 3x4 + 5x5 + 8x6 + 13x7 + · · · , which has the
closed form x/(1 x x2 ).
• Introduction: formal and analytic interpretations of power series. First ex-
amples: enumerating compositions and tilings.
• Generating function methods for simple recurrence relations, such as the
Fibonacci recurrence an = an 2 + an 1 or the derangements recurrence dn =
(n 1)(dn 2 + dn 1 ). Ansatz methods. Asymptotic results, obtained by very
basic singularity analysis. Stirling numbers as example.
• Partitions, with an emphasis on bijective and involutive proofs. Asymptotic
results and the abacus representation of partitions.
• Enumerating Catalan numbers and derangements, using generating func-
tions. In each case we will see how natural ‘splitting’ of a combinatorial
object into subobjects corresponds to a equation satisfied by a generating
function. Solving these equations we obtain formulae and asymptotic re-
sults on the objects we want to count.

Part C: Ramsey Theory and probability


The slogan of Ramsey Theory is ‘Complete disorder is impossible’. For example,
if any two people are either friends or enemies, then in any room with six people,
there must be three mutual friends or three mutual enemies.
• Ramsey’s Theorem and its generalizations.
• Probability and Ramsey Theory: ‘Considerable disorder is possible, if you
pick at random’.
• Ramsey type results including Schur’s Theorem.
Introduction 3

• Lovasz Local Lemma and applications.


• First moment method and applications to random graphs.

Part D: Further directions


This part gives a highly selective survey of more recent results in some of the areas
seen earlier in the book, bringing the reader close to the state-of-the-art. Some
suggestions for further reading from advanced textbooks or the research literature
are given.

Some features of this book


This book is based on a 33 lecture course lectured by the author at Royal Holloway,
University of London, from 2010 to 2015. This course was attended by third year,
fourth year and MSc students. With the few exceptions noted below, all the sections
have been the subject of lectures, and the majority of the end of chapter exercises
have been set on problem sheets. In many cases this led to significant changes in
the approach.
The ‘core’ exercises are those set as compulsory questions. Experience suggests
that most students can get somewhere with them. Students who put in this work—a
large majority in most years—typically did well in the final exam and enjoyed the
course. In short: this is a practical book aimed at real students.
Sections 2.4, 4.3, 6.3, 7.2, 7.3, 7.4, 7.5, 8.4, 9.1, 9.3, 9.4, 11.2, 11.3, 11.4 and
12.2 were not part of the original course. Like most of the book, their content is
fairly standard, and can be found in many undergraduate textbooks. The exceptions
are §7.4 on the abacus representation of partitions, §11.4 on Ramsey’s Theorem for
paths and Part E ‘Further directions’. The four ‘Interludes’ are also new. These give
motivated solutions, intended to shed some light on mathematical problem solving,
to four easily stated and immediately appealing combinatorial problems. While
techniques from the book are used, the pre-requisites are mild. You are encouraged
to tackle these problems for yourself. Hints are provided to give you a head start:
why not begin now with the Egg Dropping Problem?
Appendix A is a review of basic mathematical notation. Appendix B reviews the
analysis needed in Part B and the discrete probability needed in Part D. Appendix C
gives solutions to all the exercises in the main text and all the core exercises. This is
intended to prevent self-learners from getting needlessly stuck. Solutions are given
to many further problems, including all the problems that appeared on problem
sheets for the course. The harder exercises, or parts of exercises, are marked (?).
Appendix D gives brief endnotes and acknowledgements of sources.
4 Introduction

Acknowledgements
I gratefully acknowledge the significant contribution made by Eugenio Giannelli,
who did much of the initial work in preparing the first two chapters of this book.

Website
Corrections or comments sent by email to [email protected] are very
welcome. Errata will be collected on the web at www.ma.rhul.ac.uk/~uvah099/.
PART ONE
ENUMERATION
1
The Derangements Problem

1.1 Derangements
We begin with the Derangements Problem. Later we will develop techniques that
can be used to solve this problem in a routine way. Our first solution is necessarily
somewhat ad-hoc. Along the way we will see three basic counting principles that
are fundamental to combinatorial enumeration.
Recall that if X and Y are sets then a function f : X ! Y is a bijection if for every
y 2 Y there exists a unique x 2 X such that f (x) = y.
Definition 1.1.1 A permutation s of a set X is a bijection s : X ! X.
Usually we will consider permutations of {1, 2, . . . , n} for some natural number
n 2 N. It is often useful to represent permutations by diagrams. For example, the
diagram below shows the permutation s : {1, 2, 3, 4, 5} ! {1, 2, 3, 4, 5} defined by
s (1) = 2, s (2) = 1, s (3) = 4, s (4) = 5, s (5) = 3.
1 2 3 4 5

1 2 3 4 5
s (2) s (1) s (5) s (3) s (4)

More briefly, we may write s in one-line form as 21453. You might also have
seen two-line form; later in §9.2 we will see the disjoint cycle decomposition of
permutations.
As a starting point, consider the following questions:
(a) How many permutations are there of {1, 2, . . . , n}?
(b) How many of these permutations s satisfy s (1) = 1?
For (a), we construct a permutation s : {1, 2, . . . , n} ! {1, 2, . . . , n} step-by-step.
Let X = {1, 2, . . . , n}. We may choose any element of X for s (1). For s (2) we
8 The Derangements Problem

may choose any element of X except s (1). Continuing in this way, for s (r) we
may choose any element of X except s (1), . . . , s (r 1). Finally for s (n) we have
a unique choice. Thus there are n (r 1) choices for each s (r). Multiplying
choices, we see that there are n(n 1) . . . 1 = n! permutations of {1, 2, . . . , n}.
For (b), we have only 1 choice for s (1). Then as before, and for the same rea-
sons, we have n 1 choices for s (2), n 2 choices for s (3), and so on. So there are
1(n 1)(n 2) . . . 1 = (n 1)! permutations s of {1, 2, . . . , n} such that s (1) = 1.
This principle of multiplying numbers of choices is very powerful.

Basic Counting Principle 1 (BCP1). If an object can be specified


uniquely by a sequence of k choices so that, when making the rth choice,
we always have exactly cr possibilities to choose from, then there are ex-
actly c1 c2 . . . ck objects.

Note that in (a), the choices we have for s (r) depend on our earlier choices of
s (1), . . . , s (r 1). But it was still correct to apply BCP1 because the number
of choices for s (r) is always n (r 1). In the special case where we make two
choices, and one choice does not affect the next, so we first choose an element of
a set A, then an element of a set B, BCP1 simply says that |A ⇥ B| = |A||B|. (See
Appendix A if any of this notation is unfamiliar to you.)

Definition 1.1.2 Let s be a permutation of a set X. A fixed point of s is an


element x 2 X such that s (x) = x. We say that s is a derangement if it has no fixed
points. For n 2 N0 , let dn be the number of derangements of {1, 2, . . . , n}.

By (b), the number of permutations of {1, 2, . . . , n} having 1 as a fixed point is


(n 1)!. Correspondingly, the probability a permutation fixes 1 is (n 1)!/n! =
1/n. This should be intuitive: if you take a fresh deck of cards, shuffle it well, and
then deal, the probability that the top card is the Ace of Spades is 1/52.
Enumerating derangements is not so easy. Clearly d1 = 0, since the unique per-
mutation of {1} fixes 1, and d2 = 1, since we have to swap 1 and 2. The diagrams
below show the two derangements of {1, 2, 3}.
1 2 3 1 2 3

1 2 3 1 2 3

Exercise 1.1.3 Check, by listing or drawing permutations, or some cleverer method,


that d4 = 9. What is d0 ?
1.1 Derangements 9

The solution to this exercise given in Appendix B uses a further counting prin-
ciple.

Basic Counting Principle 2 (BCP2). If a finite set of objects can be


partitioned into disjoint subsets A1 , A2 , . . . , Ar then the total number of
objects is |A1 | + |A2 | + · · · + |Ar |.

Our final basic counting principle is arguably the most basic of all.

Basic Counting Principle 0 (BCP0). If there is a bijection between


finite sets A and B then |A| = |B|.

Both principles should seem obvious. For instance, when r = 2, BCP2 says that if
X is a finite set and X = A [ B where A \ B = ?, then |X| = |A| + |B|.

Exercise 1.1.4 You are a shepherd with a flock of several hundred sheep. You are
an expert on sheep, but have never learned to count above 5. How can you work
out how many sheep were killed by wolves over Winter?

Exercise 1.1.5 Try to construct a derangement of {1, 2, 3, 4, 5} such that s (1) = 2


step-by-step. Show that there are two derangements such that s (1) = 2, s (2) = 1,
and three derangements such that s (1) = 2, s (2) = 3. How many choices are there
for s (3) in each case?

The previous exercise shows that we cannot hope to solve the derangements
problem just by multiplying choices. Instead we shall find a recurrence for the
numbers dn .

Lemma 1.1.6 If n 2 then the number of derangements s of {1, 2, . . . , n} such


that s (1) = 2 is dn 2 + dn 1 .

Proof A combinatorial interpretation is helpful. Imagine n parcels, sent to Per-


sons 1, 2, . . . , n. By a sorting error, Parcel x is sent to Person s (x). Thus Parcel 1
is sent to Person 2, and no-one gets the right parcel. We consider two cases.
• Either: s (2) = 1, so Parcel 2 is sent to Person 1. Then Parcels 3, . . . , n are
sent to Persons 3, . . . , n. There are dn 2 derangements of the set {3, . . . , n}
so there are dn 2 derangements in this case.
• Or: s (2) 6= 1. Imagine that Persons 1 and 2 meet and swap parcels. Now
Person 1 has Parcel 1, and Person 2 has the parcel sent to Person 1. Suppose
10 The Derangements Problem

that, after the swap, Parcel x has now gone to Person t(x). An example is
shown below.
1 2 3 4 5

s, before swap

1 2 3 4 5

1 2 3 4 5

t, after swap

1 2 3 4 5

Since s (2) 6= 1, Parcel 2 was not sent to Person 1. Hence, after Persons 1
and 2 swap parcels, Person 2 does not have Parcel 2. Therefore t(2) 6= 2.
The swap does not affect the parcels sent to Persons 3, . . . , n, so t(3) 6= 3,
. . . , t(n) 6= n. Clearly the swap can be undone: just repeat it! So swapping
parcels defines a bijection
8 9
( ) > permutations t of {1, 2, . . . , n} >
< =
derangements s of {1, 2, . . . , n}
! such that t(1) = 1, t(2) 6= 2, .
such that s (1) = 2, s (2) 6= 1 >
: >
;
t(3) 6= 3, . . . , t(n) 6= n

Since there are dn 1 derangements of {2, 3, . . . , n}, the set on the right-hand
side has size dn 1 . By BCP0 so does the set on the left-hand side.
Now add up the numbers of choices for the ‘either’ and ‘or’ cases using BCP2.
Exercise 1.1.7 Let f be the ‘swapping parcels’ bijection defined in the proof of
Lemma 1.1.6. Consider Figure 1.1 overleaf. Apply f to the permutation s on the
left, and apply f 1 = f to the permutation t on the right. Check in each case the
image is in the expected set. Check also that f ( f (s )) = s and f ( f (t)) = t.
It is often useful to see how proofs work by trying them out on particular exam-
ples. In the early sections of this book some exercises are included to encourage
you to get into this habit.
The proof of the next theorem is modelled on the solution to Exercise 1.1.3.
Theorem 1.1.8 If n 2 then dn = (n 1)(dn 2 + dn 1 ).

Proof Let D be the set of derangements of {1, 2, . . . , n}. For each x 2 {1, 2, . . . , n}
let Dx = {s 2 D : s (1) = x}. By Lemma 1.1.6 we have |D2 | = dn 2 + dn 1 . There
is nothing special about 2 in this context, except that 2 6= 1. Hence
|D2 | = |D3 | = . . . = |Dn | = dn 2 + dn 1 .
1.1 Derangements 11

1 2 3 4 5 1 2 3 4 5

1 2 3 4 5 1 2 3 4 5
s (4) s (1) s (2) s (5) s (3)

f f 1

1 2 3 4 5 1 2 3 4 5

1 2 3 4 5 1 2 3 4 5
t (1) t (3) t (2) t (5) t (4)

Figure 1.1 Another example of the ‘swapping parcels’ bijection f .

Since D1 = ?, we have, by BCP2,


|D| = |D1 | + |D2 | + |D3 | + · · · + |Dn | = (n 1)(dn 2 + dn 1 ),

as required.

Using this recurrence relation it is easy to find values of dn for much larger n.
For example, you can easily compute d5 = (5 1)(d3 + d4 ) = 4 ⇥ (2 + 9) = 44.
Compare this with the effort required to find the 44 derangements of {1, 2, . . . , 5}
by listing all 5! permutations of {1, 2, . . . , 5}.
Whenever one meets a new combinatorial sequence, it is a good idea to look it up
in N. J. A. Sloane’s Online Encyclopedia of Integer Sequences: see oeis.org. You
will usually find it there, along with references and often other combinatorial in-
terpretations. The derangement numbers d0 , d1 , d2 , . . . are sequence A000166. The
terms for n  10 are
1, 0, 1, 2, 9, 44, 265, 1854, 14833, 133496, 1334961, . . .
(See the answer to Exercise 1.1.3 if you are surprised that d0 = 1.) We also find
a formula: a(n) = n!*Sum((-1)^k/k!, k=0..n). Knowing the answer, it is not
hard to prove by induction that it is correct.
Corollary 1.1.9 For all n 2 N0 ,
1 1 1 ( 1)n
dn = n! 1+ +···+ .
1! 2! 3! n!
Proof When n = 0 both sides are 1 and when d = 1 both sides are 0. Let n 2 and
12 The Derangements Problem

suppose, inductively, that the formula holds for dn 2 and dn 1 . By Theorem 1.1.8
and the inductive hypothesis we have

dn (n 1)(dn 2 + dn 1 )
=
n! n!
dn 2 n 1 dn 1
= +
n(n 2)! n (n 1)!
1 1 1 ( 1)n 2
= 1 + ···+
n 1! 2! (n 2)!
1 1 1 ( 1)n 2 ( 1)n 1
+ 1 1 + ···+ + .
n 1! 2! (n 2)! (n 1)!
k
1 ( 1)k
Each term 1n ( k!1) in the first summand is cancelled by a corresponding n k!
from the second summand. We are left with

dn 1 1 ( 1)n 2 ( 1)n 1 1 ( 1)n 1


= 1 + ···+ +
n! 1! 2! (n 2)! (n 1)! n (n 1)!
1 1 ( 1) n 2 ( 1)n 1 ( 1)n
=1 + ···+ + + .
1! 2! (n 2)! (n 1)! n!

Multiplying through by n! gives the required formula for dn .

A more systematic way to derive Corollary 1.1.9 from Theorem 1.1.8 will be
seen in Part 2. We will later prove Corollary 1.1.9 in many other ways, none of
which require knowing the answer in advance.
The proof of Corollary 1.1.9 shows that it is helpful to consider the probability
dn /n! that a permutation of {1, 2, . . . , n} is a derangement. (This assumes that each
probability is chosen uniformly at random, that is, with equal probability 1/n!.)
Before reading further, please take a moment to think about the next question.

Question 1.1.10 Let n be large. Suppose that n parcels are delivered uniformly
at random to n people, so that each person gets one parcel. Roughly, what is the
probability that no-one gets the right parcel?

Of course this probability is dn /n!. Since all n people have to be unlucky, one
reasonable guess is ‘nearly 0’. On the other hand, the chance a particular parcel
(say Parcel 1) is wrongly delivered is 1 1/n, which is very close to 1. So another
reasonable guess is ‘nearly 1’. This line of thought is continued in Exercise 1.8.
In fact, by the following theorem, the probability is close to 1/e = 0.36788 . . .,
and on average, exactly one person gets their own parcel.
1.1 Derangements 13

Theorem 1.1.11 Suppose that permutations of {1, 2, . . . , n} are chosen uniformly


at random.
(i) The probability dn /n! that a permutation of {1, 2, . . . , n} is a derangement
tends to 1/e as n ! •.
(ii) The mean number of fixed points of a permutation of {1, 2, . . . , n} is 1.
Proof (i) By Corollary 1.1.9,
dn 1 1 1 ( 1)n
=1 + +···+ .
n! 1! 2! 3! n!
Recall that the Taylor series for ex is 1 + x + x2 /2! + · · · + xn /n! + · · · . Substituting
x = 1 we get
1 1 1 ( 1)n
e =1 1+ +···+ +···
2! 3! n!
1 1 1 ( 1)n
= lim 1 + +···+
n!• 1! 2! 3! n!
dn
= lim ,
n!• n!

as required.
(ii) We define a set of ordered pairs
n s is a permutation of {1, 2, . . . , n},o
P = (s , x) : .
x 2 {1, 2, . . . , n}, s (x) = x

(See Appendix A if you need a reminder of the notation for ordered pairs.) Count-
ing P by summing over all n! permutations s of {1, 2, . . . , n} we get
|P| = Â x 2 {1, 2, . . . , n} : s (x) = x .
s

Hence the mean number of fixed points is |P|/n!. On the other hand, counting |P|
by summing over x 2 {1, 2, . . . , n} we get
n
|P| = Â permutations s of {1, 2, . . . , n} : s (x) = x .
x=1

We saw on page 8 that there are exactly (n 1)! permutations of {1, 2, . . . , n} fix-
ing 1. In this context there is nothing special about 1. Hence every summand above
is (n 1)!. Therefore |P| = n(n 1)! = n! and the mean number of fixed points is
n!/n! = 1.
The double-counting technique used in (ii) is often useful in combinatorial prob-
lems. A group theoretic generalization of (ii) is given in Exercise 1.11 below. It
should be admitted that the proof of (ii) is far from the shortest possible: we will
14 The Derangements Problem

use probabilities and expectations to give a ‘one-line proof’ of a more general result
in §9.2.

Exercises
Exercises 1.1 to 1.6 are core exercises intended to give you some practice in apply-
ing the Basic Counting Principles.
1.1 A menu has 3 starters, 4 main courses and 6 desserts.
(a) How many ways are there to order a three course meal, consisting of a starter,
main course and dessert? [Hint: multiply choices using BCP1]
(b) How many ways are there to order a two course meal, including exactly one
main course?
1.2 Let
T = {(x1 , x2 , x3 ) : 1  x1 , x2 , x3  10, x1 , x2 , x3 distinct},
S = {X : X ✓ {1, . . . , 10}, |X| = 3}.
Define a function f : T ! S by f (x1 , x2 , x3 ) = {x1 , x2 , x3 }. For example,
(3, 2, 5) 2 T and f (3, 2, 5) = {3, 2, 5} = {2, 3, 5} 2 S.
(a) Find |T |.
(b) Find the number of tuples (x1 , x2 , x3 ) 2 T such that f (x1 , x2 , x3 ) = {2, 3, 5}.
(c) By generalizing the idea in (b), find |S|.
[Hint: the point of this question is to show the ideas in one proof of the
formula for binomial coefficients. So please do not assume this formula is
true in (c). For a reminder of the difference between tuples and sets, see Ap-
pendix A.]
1.3 Fix n 2 N. Let X = {(a, b) : 1  a  b  n}. Find a simple formula for |X| in
terms of n.
1.4 For each n 2 N, how many subsets are there of {1, 2, . . . , n}? [Hint: work out
the answer for n = 1, 2, 3, . . . by writing down all the subsets in each case. Do
not forget the empty set! Now explain the pattern using BCP1.]
1.5 Let
nplacements of 4 indistinguishable balls into 7 o
A= ,
numbered urns so that each ball is in a different urn
n ways to walk 4 blocks East and 3 blocks South o
B= ,
on a New York grid, moving only East and South

C = X ✓ {1, 2, . . . , 7} : |X| = 4 .
Exercises 15

(a) Define explicit bijections f : A ! C and g : B ! C. [Hint: it might help to first


work out what you want the answers to (b) and (c) to be.]
(b) Which element of C corresponds, by the bijection g, to the walking route
ESEESSE 2 B shown in the diagram below?
start
E
S

E E
S

E end

(c) Which walking route in B corresponds to the ball-and-urn placement in A


shown below?

1 2 3 4 5 6 7

(d) Find a binomial coefficient equal to |A| and |B|.


1.6 A standard deck has 52 cards. There are four Aces, four Kings, four Queens
and four Jacks. How many hands of five cards are there that
(a) have at least one Ace, King, Queen and Jack? [Hint: first count hands of the
form AKQJx, where x stands for a ten or smaller card, then hands of the form
AAKQJ, and so on. Note that hands are unordered: AKQJ3 is the same hand
as KQ3JA.]
(b) have at least one Ace, King and Queen?
(In Chapter 3 we will see the Principle of Inclusion and Exclusion: it gives a
simple unified way to solve both problems.)

Exercises 1.7 to 1.11 extend the results so far on permutations and derangements.

1.7 Let pn = dn /n! be the probability that a permutation of {1, 2, . . . , n}, chosen
uniformly at random, is a derangement. Using only the recurrence in Theo-
rem 2.4, prove by induction that pn pn 1 = ( 1)n /n!; hence give an alter-
native proof of Corollary 1.1.9.
16 The Derangements Problem

1.8 As in Question 1.1.10, suppose that n parcels are delivered uniformly at ran-
dom to n people, so that each person gets one parcel.
(a) Let x 2 {1, . . . , n}. Show that the probability that Parcel x is wrongly delivered
is 1 1/n.
(b) Assuming the events that parcels are wrongly delivered are independent, show
that the probability that no-one gets their own parcel is (1 1/n)n .
(c) Show that (1 1/n)n ! 1/e as n ! •.
(d) Show, regrettably, that the independence assumption in (b) is false whenever
n 2.
(Despite the bad news in (d), this line of reasoning can still be modified to
give a rigorous proof that dn /n! ! 1/e as n ! •: see Exercise 11.4.)
1.9 Use the formula for dn in Corollary 1.1.9 to prove that if n > 0 then dn is the
nearest integer to n!/e.
1.10
(a) Let an (t) be the number of permutations of {1, 2, . . . , n} with exactly t fixed
points. Note that dn = an (0). Prove that
n! ⇣ 1 1 ( 1)n t ⌘
an (t) = 1 + ···+ .
t! 1! 2! (n t)!
Hence, or otherwise, give a simple expression for an (0) an (1).
(b) Use (a) to give an alternative proof of Theorem 2.6(ii), that the mean number
of fixed points of a permutation of {1, 2, . . . , n} is 1.
(c) (?) Let en be the number of derangements of {1, 2, . . . , n} that are even per-
mutations, and let on be the number that are odd permutations. By evaluating
the determinant of the matrix
0 1
0 1 1 ... 1
B1 0 1 . . . 1C
B C
B1 1 0 . . . 1C
B C
B. . . .
@ .. .. .. . . ... A
C

1 1 1 ... 0

in two different ways, prove that en on = ( 1)n 1 (n 1).


1.11 This exercise needs some group theory.
(a) Let G be a subgroup of the symmetric group of all permutations of {1, 2, . . . , n}.
Let P = {(s , x) : s 2 G, x 2 {1, 2, . . . , n}, s (x) = x}. (Thus if G is the full
symmetric group, then P is as defined in the proof of Theorem 1.1.11.) Let
Fix(s ) be the set of fixed points of s 2 G. By double-counting P and using
Exercises 17

the Orbit-Stabiliser Theorem, show that


1
|G| sÂ
| Fix(s )|
2G

is equal to the number of orbits of G on {1, 2, . . . , n}. (This result is usually,


but wrongly, attributed to Burnside.)
(b) How many ways are there to colour the faces of a tetrahedron red, blue and
green? (Regard two colourings as the same if they differ by a rotation of the
tetrahedron. Any combination of the three colours may be used.)
(c) How many ways are there to put 3 white balls and 2 black balls into three
indistinguishable urns? (You may find Theorem 2.3.3 useful.)

Exercises 1.12 to 1.15 are more challenging. They can all be solved by elementary
arguments, but you will have to think hard. Try looking at small cases to get started.

1.12 (?) The hare and the tortoise—both of them capable mathematicians—play
a game. The umpire places evenly many coins in a row: a possible starting
position for a six coin game is shown below.
'$
'$'$
'$'$
'$

20p 50p £1 20p £2 £1


&%
&%&%
&%&%
&%

The players then alternately take coins from either end, until none are left.
The winner is the player who ends up with the most money. If the players get
equal amounts, the game is a draw. Tradition dictates that the tortoise starts.
Show that the tortoise can guarantee never to lose. Find a reasonably general
sufficient condition for the tortoise to win.
1.13 (?) There are 12 numbered locked safes that can be unlocked by 12 numbered
keys. Before you arrive, the keys are randomly distributed so that each safe
contains one key, and the safes are shut. When you arrive, the referee unlocks
the first r safes using her master key. What is the probability that you can now
open all the safes? (Once you have unlocked a safe, you may take and use the
key it contains.)
1.14 [American Mathematical Monthly Problem 11573] (?) A square matrix of
order n2 is said to be a Sudoku permutation matrix if all its entries are either
0 or 1, and it has exactly one 1 in each row, each column, and each of the n2
submatrices obtained by dividing the matrix into an n ⇥ n array of n ⇥ n sub-
matrices. For each n 2 N, find the number of Sudoku permutation matrices of
order n2 .
Challenge problems for MT4540 Combinatorics
Here are four hopefully interesting problems embodying combinato-
rial ideas. I will happily give £5 per problem to any person (or team of
people) that solves a problem and presents their solution at the board.
If you solve the first problem before 31st December you could send in
your solution to the American Mathematical Monthly; they publish
18 the names of solvers,Theand
Derangements Problem
the best solution.
(See below for an example when n = 2. If n = 3 then the 1s in a completed
Problem 1 (American Mathematical Monthly, Problem 211520). Let A
Sudoku
be grid
a setform a Sudoku
of n real permutation
numbers. For each imatrix
2 {1, 2,of
. . .order 3 .)
, n} define by
i

0i = 1 0max0X
0 X0 A 1 0
1 0X of0size0exactly i, and max X denotes
where the sum is over all subsets
the maximum element of the 0 subset
0 0 X.1 Express the k-th smallest
element of A as a linear combination of the i.

1.15 (?) Given a necklace with 168 beads, 84 black and 84 white, can it necessarily
be cut, and the 2new
Problem ends retied,
(Beads). Given aso that two
necklace necklaces
with 168 beads,each with 42
84 black andbeads
84 white, can it be cut, and the new ends retied, so that two necklaces
of either colour are obtained? (See below for one solution with an 8 bead
each with 42 beads of either colour are obtained? (See below for one
necklace.)
solution with an 8 bead necklace.)

Problem 3 (Coins). The hare and the tortoise—both of them capable


mathematicians—play a game. The umpire places evenly many coins
in a row; a possible starting position is shown below.

£1 20p £1 £2 50p 1p

The players then alternately take coins from either end, until none are
left. The winner is the person who ends up with the most money.
Tradition dictates that the tortoise starts. Who wins? What can be
said if there are an odd number of coins?
2
Binomial coefficients

2.1 Binomial coefficients and bijective proofs


The following notation is standard and often useful.
Notation 2.1.1 If X is a set of size k 2 N0 then we say that X is a k-set. To
emphasise that X is a subset of a set Y , we say that X is a k-subset of Y .

We define binomial coefficients combinatorially.


n
Definition 2.1.2 Let n, k 2 N0 . The binomial coefficient k is the number of
k-subsets of {1, 2, . . . , n}.
For example 42 = 6: the six 2-subsets of {1, 2, 3, 4} are {1, 2}, {1, 3}, {1, 4},
{2, 3}, {2, 4}, {3, 4}. Note that, by definition, if k > n then nk = 0. We could re-
place {1, 2, . . . , n} with any other set of size n and still define the same numbers nk .
Exercise 2.1.3
n n
(a) Show that 0 = n = 1 for all n 2 N0 .
n
(b) Show that = n for all n 2 N0 .
1
In each case, does your argument work when n = 0?
We now check that the expected formula holds for binomial coefficients. Note
this is a non-trivial result: it is not true by definition! The proof uses the same idea
as Exercise 1.2.
Lemma 2.1.4 If n, k 2 N0 and k  n then
✓ ◆
n n(n 1) . . . (n k + 1) n!
= = .
k k! k!(n k)!
Proof Let

T = (x1 , . . . , xk ) : x1 , . . . , xk 2 {1, 2, . . . , n}, x1 , . . . , xk distinct .


20 Binomial coefficients

Constructing an element of T step-by-step, we have n choices for x1 , n 1 choices


for x2 , . . . , n (r 1) choices for xr , . . . , n (k 1) choices for xk . Therefore
|T | = n(n 1) . . . (n k + 1) by BCP1. Let
S = X : X ✓ {1, 2, . . . , n}, |X| = k .
n
By Definition 2.1.2, |S| = k . Consider the function f : T ! S defined by
f (x1 , . . . , xk ) = {x1 , . . . , xk }.
Let X 2 S. There are k! tuples (x1 , . . . , xk ) 2 T such that f (x1 , . . . , xk ) = X, one
for each of the k! permutations of X. Hence
✓ ◆
n |T | n(n 1) . . . (n k + 1)
= |S| = = .
k k! k!
The second equality then follows from n(n 1) . . . (n k + 1) = n!/(n k)!.

Many of the basic properties of binomial coefficients have combinatorial proofs


using explicit bijections and the three basic counting principles. We say that such
proofs are bijective. They are not always shorter than algebraic proofs, but they are
often more illuminating.

Lemma 2.1.5 If n, k 2 N0 and n k then


✓ ◆ ✓ ◆
n n
= .
k n k
Proof By definition, there are nk subsets of {1, 2, . . . , n} of size k and n n k sub-
sets of {1, 2, . . . , n} of size n k. Taking complements in {1, 2, . . . , n} defines a
bijection between the two collections of subsets. By BCP0, they have the same
size.
As ever, looking at a particular example may clarify the proof.
Exercise 2.1.6 Take n = 4 and k = 1. What explicitly is the bijection
{1}, {2}, {3}, {4} ! {1, 2, 3}, {1, 2, 4}, {1, 3, 4}, {2, 3, 4}
4 4
proving that 1 = 3 in the previous proof? What is its inverse?
Lemma 2.1.5 has a one-line algebraic proof. The next result also has a short
algebraic proof, although some care is needed to deal with the case k = n. The
bijective proof works in a uniform way, and really explains why the result is true.

Lemma 2.1.7 (Fundamental Recurrence) If n, k 2 N then


✓ ◆ ✓ ◆ ✓ ◆
n n 1 n 1
= + .
k k 1 k
2.1 Binomial coefficients and bijective proofs 21

Proof Let X be a k-subset of {1, 2, . . . , n}. We consider two cases.


• Either n 2 X. Removing n from X gives a (k 1)-subset of {1, 2, . . . , n 1}.
Conversely, given such a set, inserting n gives a k-subset of {1, 2, . . . , n} con-
taining n. Hence the k-subsets containing n are in bijection with the (k 1)-
subsets of {1, 2, . . . , n 1}, and so there are nk 11 such subsets.
• Or n 62 X. Then X is a k-subset of {1, 2, . . . , n 1}. By definition there are
n 1
k such subsets.
There are nk k-subsets of {1, 2, . . . , n} and each k-subset is counted in a unique
case. By BCP1 we have nk = nk 11 + n k 1 , as required.
Our next result is the Binomial Theorem. Probably you have already seen this
proved by induction. The bijective proof may require more thought from you, but
once mastered, is far shorter.
Theorem 2.1.8 (Binomial Theorem) Let z, w 2 C. If m 2 N0 then
m ✓ ◆
m k m k
(z + w) = Â
m
zw .
k=0 k

Proof When we multiply out

(z + w)m = (z + w)(z + w) · · · (z + w)
| {z }
m

we must choose either z or w from each bracket (z + w). If we choose z from k


brackets and w from the other m k brackets, then we get a contribution of 1 to the
coefficient of zk wm k . Since there are mk ways to choose k of the n brackets, this
coefficient is mk .
Here is an example of a deliberately informal bijective proof that is nonetheless
entirely rigorous.
n n
Claim 2.1.9 Let n, k 2 N0 . If k  n then (n k) k = (k + 1) k+1 .

Proof Take n people. To form a team consisting of k + 1 people, one of whom is


the leader, we can choose k people in nk ways, and then choose one of the remain-
ing n k people to be the leader. Hence, by BCP1, there are nk (n k) teams-with-
n
leaders. Or, more democratically, we could choose k + 1 people in k+1 ways, and
n
then let them elect a leader, in k + 1 ways. Hence, by BCP1, there are k+1 (k + 1)
teams-with-leaders. These numbers must be equal.
See Exercise 2.1 for a similar identity proved bijectively. If you doubt the rigour
of the previous proof, then you might be happier with the formalized version, giv-
ing in the exercise below. Or you might feel, perhaps correctly, that in this case the
22 Binomial coefficients

bijective proof is too much work, and the algebraic proof


✓ ◆
n n! n!
(n k) = (n k) =
k k!(n k)! k!(n k 1)!
✓ ◆
n! n
= (k + 1) = (k + 1)
(k + 1)!(n (k + 1))! k+1
is preferable. (Note however that the second equality is only valid when k < n, so
the case k = n has to be treated separately.)
Exercise 2.1.10 Formalize the proof of Claim 2.1.9 by defining a bijection
n X ✓ {1, 2, . . . , n}, |X| = k, o n Z ✓ {1, 2, . . . , n}, o
f : (X, y) : ! (Z, y) : .
y 2 {1, 2, . . . , n}, y 62 X |Z| = k + 1, y 2 Z
Give a formula for f 1 (Z, y) where (Z, y) is in the right-hand set above.

2.2 Basic binomial identities


Sums involving binomial coefficients often appear in mathematical problems. In
this section we see some of the basic identities that are most useful for simplifying
such sums.

Identities from Pascal’s Triangle


We introduce Pascal’s Triangle by solving part of Exercise 1.5: how many ways
are there to walk 4 blocks East and 3 blocks South on a New York grid, starting
at A and ending at B as shown below, and moving only East and South?
A

The answer is 74 : each walking route has 7 steps, of which we must choose ex-
actly 4 to be East. Alternatively, we can compute iteratively. Let C be a street
junction. If C is due East or due South of A then there is a unique walking route
2.2 Basic binomial identities 23

from A to C. Otherwise, suppose that there are d ways to go to D (immediately to


the North of C), and e ways to go to E (immediately to the West of C). Then there
are d + e ways to go from A to C, since we must reach C either from D or from E.
Applying these two rules we count the walking routes as shown below.

1 1 1 1 1
A

1 2 3 4 5 D d

1 3 6 10 15 E C
e d+e
1 4 10 20 35
B

The numbers form a tilted version of Pascal’s Triangle: the number of routes going
to a junction k steps East and n k steps South of A is, as expected, nk .

Exercise 2.2.1 Computing iteratively, we obtain 35 as the sum 35 = 20 + 15.


Correspondingly, 74 = 63 + 64 . Explain the connection with the proof of the
Fundamental Recurrence nk = nk 11 + n k 1 .

In practice it is more convenient to draw Pascal’s Triangle as below; the entry in


row n and column k is nk . The Fundamental Recurrence is shown graphically to
the left.

n\k 0 1 2 3 4 5 6 7 8 9 10
0 1
1 1 1
2 1 2 1
✓ ◆ ✓ ◆
n 1 n 1 3 1 3 3 1
k 1 k
4 1 4 6 4 1
@
@@✓ ◆ 5 1 5 10 10 5 1
n 6 1 6 15 20 15 6 1
k
7 1 7 21 35 35 21 7 1
8 1 8 28 56 70 56 28 8 1
9 1 9 36 84 126 126 84 36 9 1
10 1 10 45 120 210 252 210 120 45 10 1
24 Binomial coefficients

We now prove some identities that come from summing adjacent entries in Pas-
cal’s Triangle. Consider row 8. Taking the alternating sum of the entries, we get
1 8 = 7 = 71 , 1 8 + 28 = 21 = 72 , 1 8 + 28 56 = 35 = 73 , and so
on. This suggests the following result.

Lemma 2.2.2 (Alternating row sums) If n 2 N, m 2 N0 and m  n then


m ✓ ◆ ✓ ◆
k n m n 1
 ( 1) k = ( 1) m .
k=0

Proof We work by induction on m. If m = 0 then the left-hand side is ( 1)0 n0 =


1 and the right-hand side is ( 1)0 n 0 1 = 1. By induction we may assume that
k n m 1 n 1 . Now
Âm 1
k=0 ( 1) k = ( 1) m 1

m ✓ ◆ m 1 ✓ ◆ ✓ ◆
n k n m n
 ( 1) k =  ( 1) k + ( 1) m
k
k=0 k=0
✓ ◆ ✓ ◆
n 1 n
= ( 1)m 1 + ( 1)m
m 1 m
⇣✓ n ◆ ✓ n 1 ◆⌘
m
= ( 1)
m m 1
✓ ◆
n 1
= ( 1)m
m
where the final step uses the Fundamental Recurrence.

Perhaps surprisingly, there is no simple formula for the unsigned row sums
n
Âmk=0 k . But there are simple formulae for many, apparently more complicated,
sums along the rows. See for example Exercises 2.2 and 2.8.
Now consider the diagonals. Suppose we start at 40 = 1 and step right and down.
The sums are 1 + 5 = 6 = 61 , 1 + 5 + 15 = 21 = 72 , 1 + 5 + 15 + 35 = 56 = 83 ,
and so on. To see the reason for this pattern, think of the initial 1 not as 40 , but
as 50 , one position below. Then the sum 50 + 51 + 62 + 73 simplifies, by three
applications of the Fundamental Recurrence, to 61 + 62 + 73 = 72 + 73 = 84 .
This is a special case of the following result.

Lemma 2.2.3 (Diagonal sums) If n, m 2 N0 then


m ✓ ◆ ✓ ◆
n+k n+m+1
 k = m
.
k=0

Proof Again we work by induction on m. If m = 0 then both sides are 1. For the
2.2 Basic binomial identities 25

inductive step we have


m ✓ ◆ m 1✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆
n+k n+k n+m n+m n+m n+m+1
 k = k + m = m 1 + m = m
k=0 k=0

where, as expected, the final equality uses the Fundamental Recurrence.

For the column sums on Pascal’s Triangle see Exercise 2.3. For the other di-
agonal sum, see Exercise 2.6. For a bijective proof of Lemma 2.2.3, see Exer-
cise 2.13(e).
Incidentally, while it is common to credit Pascal with the triangle of binomial
coefficients, the Fundamental Recurrence and the Binomial Theorem were already
known around 1000 CE by the Iranian mathematician al-Karaji.

Arguments with subsets


The two identities below are among the most useful in practice. Both have memo-
rable and illuminating bijective proofs.

Lemma 2.2.4 (Subset of a subset) If k, r, n 2 N0 and k  r  n then


✓ ◆✓ ◆ ✓ ◆✓ ◆
n r n n k
= .
r k k r k
Proof Let
P = (X,Y ) : X ✓ Y ✓ {1, 2, . . . , n}, |X| = k, |Y | = r .
We can first choose Y in nr ways, then choose X ✓ Y in kr ways. So |P| = nr kr .
Or, we can first choose X in nk ways, and then choose Z ✓ {1, 2, . . . , n}\X such
that |Z| = r k in nr kk ways, and then take Y = X [ Z. Hence |P| = nk nr kk .
Exercise 2.2.5 ‘Deformalize’ the previous proof using the setting of Claim 2.1.9.
So you might start ‘Take n people and form a (generalized) football team of r of
them in nr ways. Then choose k of these r people to be defenders in kr ways.
Hence there are nr kr teams-with-defenders. Alternatively . . . ’
Lemma 2.2.6 (Vandermonde’s convolution) If a, b 2 N0 and m 2 N0 then
m ✓ ◆✓ ◆ ✓ ◆
a b a+b
 = .
k=0 k m k m
Proof The pet-shop has a alsatians and b budgies for sale. Each animal has its
own distinctive personality and coat/plumage. Suppose I want to buy m pets. Here
are two ways to do this.
26 Binomial coefficients

(i) I go into the petshop, announce to the surprised owner that I want m pets,
of any species. There are a + b pets on sale, so there are a+b m possible
purchases.
(ii) Alternatively, I first buy k alsatians for some k 2 {0, 1, . . . , m}, in ak ways,
and then buy m k budgies, in mb k ways. Multiplying choices, by BCP1,
there are ak mb k ways to do this. Summing over k, using BCP2, we count
a b
all Âm
k=0 k m k possible purchases.
a b a+b
Comparing (i) and (ii) we get Âm
k=0 k m k = m .

Note that there is no restriction on a, b and m, except that they are all in N0 . For
instance, if a < m then the summands in Vandermonde’s convolution for k > a are
all zero, because ak = 0; correspondingly, there is no way to buy k > a alsatians.

Exercise 2.2.7 Let A = {x1 , . . . , xa } and B = {y1 , . . . , yb } be disjoint sets of sizes a


and b respectively. Formalize the previous proof by counting the number of m-
subsets of A [ B in two different ways.

Corollaries of the Binomial Theorem


The Binomial Theorem (Theorem 2.1.8) states that if m 2 N0 and z, w 2 C then
m k m k
Âmk=0 k z w = (z + w)m . The following results can be obtained by making a
strategic choice of z and w. Ask yourself: How can I make mk zk wm k look like mk
and ( 1)k mk ?

Corollary 2.2.8 ✓ ◆
m
m
(i) If m 2 N0 then  = 2m .
k=0 k
m ✓ ◆
k m
(ii) If m 2 N then  ( 1) = 0.
k=0 k
m k m k
Proof For (i) take z = 1 and w = 1 to get Âm
k=0 k 1 1 = (1+1)n = 2n . For (ii),
m m k n k
take z = 1 and w = 1 to get Âk=0 k ( 1) 1 = ( 1 + 1)m . Since m 1 the
right-hand side is 0.

An alternative proof of (i) was given in Exercise 1.4; (ii) is also a special case of
Lemma 2.2.2.

Corollary 2.2.9 For all m 2 N there are equally many subsets of {1, 2, . . . , m} of
even size as there are of odd size.

Proof Written out without the summation notation, Corollary 2.2.8(ii) states that
2.3 Balls and urns 27
m m
0 1+ m2 m m m
3 + · · · = 0. Add 1 + 3 + · · · to both sides. This cancels
the negative terms on the left-hand side, giving
✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆
m m m m m m
+ + +··· = + + +··· .
0 2 4 1 3 5
The left-hand side is the number of subsets of {1, 2, . . . , m} of even size, and the
right-hand side is the number of subsets of {1, 2, . . . , m} of odd size.

Exercise 2.2.10 Find a bijective proof of Corollary 2.2.9 when m is odd. You may
find your bijection also works when m is even. If not, find a bijective proof that also
works in this case.

Exercise 2.15 gives some further identities involving alternating sums of bino-
mial coefficients that have bijective proofs.

2.3 Balls and urns


Using binomial coefficients and the basic counting principles we can answer a fun-
damental combinatorial question: How many ways are there to put k balls into n
numbered urns? We consider both balls that are numbered from 1 to k, and indistin-
guishable balls. The answer also depends on the capacity of the urns: we consider
small urns, that can contain only one ball, and large urns, that have unlimited ca-
pacity. Some urns may be empty.
For example, two of the twelve placements of 2 numbered balls into 4 small urns
are shown below.

1 2 2 1

1 2 3 4 1 2 3 4

Exercise 2.3.1 Using BCP1 find the number of ways to put k numbered balls
into n numbered urns that are (i) small, (ii) large.

A placement of k indistinguishable balls into n small urns is completely deter-


mined by the set {r 2 {1, . . . , n} : urn r has a ball}. For example, the placements
when n = 4 and k = 2 corresponding to the subsets {1, 2} and {2, 3} of {1, 2, 3, 4}
are shown below.

1 2 3 4 1 2 3 4
28 Binomial coefficients

This gives a bijection between the placements of k indistinguishable balls into n


small urns and the k-subsets of {1, 2, . . . , n}. By definition, there are nk such sub-
sets.
We now have the three entries shown in the table below.

Numbered balls Indistinguishable balls


✓ ◆
n
small urns n(n 1) . . . (n k + 1)
k

large urns nk

Exercise 2.3.2 Explain why there are number of placements of k numbered balls
into small urns is k! times the number of placements of k indistinguishable balls.
[Hint: compare the diagrams on the previous page. How many ways are there to
add labels to the indistinguishable balls?] Will the same result hold for large urns?
The final entry is revealed below. If you compute a few small cases by hand, and
compare the answers with Pascal’s Triangle (see page 23) you will discover it for
yourself.
Theorem 2.3.3 Let n 2 N and let k 2 N0 . The number of ways to place k indistin-
guishable balls into n numbered urns of unlimited capacity is n+kk 1 .
We give two proofs, one inductive, using the same idea as the proof of the Fun-
damental Recurrence (Lemma 2.1.7), and one bijective.
Inductive proof Let f (n, k) be the number of ways to place k indistinguishable
balls into n large urns. We consider two cases.
• Either urn n has a ball. Removing this ball gives a placement of k 1 balls
into n urns, and putting the ball back restores the original placement. Hence
there are f (n, k 1) such placements.
• Or urn n is empty. Then all the balls are in urns 1 up to n 1, and so there
are f (n 1, k) such placements.
By BCP2, we have
f (n, k) = f (n, k 1) + f (n 1, k) provided n 2 and k 1. (?)
The restriction in (?) is necessary for f (n, k 1) and f (n 1, k) to both be defined.
We want to assume that the claimed formula holds for f (n, k 1) and f (n 1, k).
But there is a problem: we cannot do induction on n, because we need to know
f (n, k 1). And we cannot do induction on k, because we need to know f (n 1, k).
2.3 Balls and urns 29

So how can we capture the sense that finding f (n, k 1) and f (n 1, k) are ‘smaller’
problems than finding f (n, k)?
The solution is to do induction n + k, the sum of the number of balls and urns.
The base cases come from the restriction in (?). When n = 1 we have f (1, k) = 1
for all k (we have to put all k balls in urn 1). This agrees with 1+kk 1 = kk = 1.
When k = 0 we have f (n, 0) = 1 for all n (the unique placement has no balls in any
urn). This agrees with n+00 1 = n 0 1 = 1. For the inductive step we use (?) to
get
✓ ◆ ✓ ◆ ✓ ◆
n+k 2 n+k 2 n+k 1
f (n, k) = f (n, k 1) + f (n 1, k) = + =
k 1 k k
where the final equality uses the Fundamental Recurrence.
Bijective proof Given a placement of k indistinguishable balls into n numbered
urns, perform the following procedure:
(1) Draw the balls and urns from left to right, starting with urn 1.
(2) Erase the left wall of urn 1 and all right urn walls, urn floors, urn numbers.
(3) Replace each ball with 0 and each remaining left urn wall with 1.
For example, when n = 4 and k = 3 we have

1 2 3 4

7 ! 7 ! 001101.

This procedure defines a bijection between the placements of k indistinguishable


balls into n urns and strings of length n + k 1 with k 0s and n 1 1s. There
are n+kk 1 such strings, since we can choose any k positions of the n + k 1
positions to have 0s. (For example, 001101 corresponds to the 3-subset {1, 2, 5}
of {1, 2, 3, 4, 5, 6}.) Hence, by BCP0, the number of ball-and-urn placements is
n+k 1
k .
Exercise 2.3.4 By reversing steps (1), (2) and (3) find the ball-and-urn placements
corresponding to the strings 100110, 000111 and 111000.
The following reinterpretation of Theorem 2.3.3 is often useful.
Corollary 2.3.5 Let n 2 N and let k 2 N0 . The number of n-tuples (t1 ,t2 , . . . ,tn )
such that t1 ,t2 , . . . ,tn 2 N0 and t1 + t2 + · · · + tn = k is n+kk 1 .
Proof Let T be the set of n-tuples (t1 ,t2 , . . . ,tn ) such that t1 ,t2 , . . . ,tn 2 N0 and
30 Binomial coefficients

t1 + t2 + · · · + tn = k. Given (t1 ,t2 , . . . ,tn ) 2 T , we define a corresponding place-


ment of k indistinguishable balls into n large urns by putting tr balls into urn r for
each r 2 {1, 2, . . . , n}. Conversely, a ball-and-urn placement with tr balls in urn r
corresponds to the tuple (t1 ,t2 , . . . ,tn ) 2 T . By Theorem 2.3.3 and BCP0, we get
|T | = n+kk 1 , as required.

2.4 Binomial coefficients as polynomials


z
We may extend the definition of binomial coefficients to define k for z 2 C by
✓ ◆
z z(z 1) . . . z (k 1)
= .
k k!
By Lemma 2.1.4 this agrees with the combinatorial definition (Definition 2.1.2)
when z 2 N0 .
For example, k1 = ( 1)k and k2 = ( 1)k (k + 1) for all k 2 N0 . More gen-
erally there is the following lemma, which is often useful for simplifying sums in
which binomial coefficients appear with alternating signs.
Lemma 2.4.1 Let z 2 C and let k 2 N0 . Then
✓ ◆ ✓ ◆
z k k z 1
= ( 1) .
k k
Proof This is a straightforward check.

In particular, n+kk 1 = ( 1)k kn . Thus nk is the number of placements of k


balls into n small urns, and, up to a sign, kn is the number of placements of k balls
into n large urns. A reason for this remarkable connection will be seen in §5.1.
Many of the identities proved so far hold for these generalized binomial coef-
ficients. To show this we must think of kz as a polynomial of degree k in z. For
example, 3z = 16 z(z 1)(z 2) = 16 z3 12 z2 + 13 z. We then use a key principle,
proved in Exercise 2.16: if two polynomials of degree k agree at k + 1 distinct
points then they are equal.
As an example we prove the generalization of Lemma 2.2.2.
Lemma 2.4.2 If z 2 C and m 2 N0 then
m ✓ ◆ ✓ ◆
k z m z 1
 ( 1)
k
= ( 1)
m
.
k=0

Proof The left-hand side is a polynomial of degree at most m in z. The degree of


the right-hand side is m. By Lemma 2.2.2, the two sides agree for all z 2 N. Hence,
by the key principle, they are equal as polynomials in z.
2.4 Binomial coefficients as polynomials 31

Similarly, the Fundamental Recurrence (Lemma 2.1.7), Claim 2.1.9, Lemma


2.2.3 and Lemma 2.2.4 all hold with n replaced with a general z 2 C. Vander-
monde’s Convolution (Lemma 2.2.6) holds with a and b replaced with general z,
w 2 C. However Lemma 2.1.5, that nk = n n k , does not generalize, because
n
n k = n(n 1) . . . (k + 1)/(n k)! is not a polynomial in n.

Exercise 2.4.3 Using Lemma 2.4.1, deduce the general form of Lemma 2.2.3,
z+k
namely Âmk=0 k = z+m+1
m , from Lemma 2.4.2.

As another application of Lemma 2.4.1 we prove a variant of Vandermonde’s


Convolution in which the sum of the upper parts of the binomial coefficients is
constant.

Claim 2.4.4 If c, d 2 N0 and m 2 N0 then


m ✓ ◆✓ ◆ ✓ ◆
c+k d +m k m+c+d +1
 c d
=
c+d +1
.
k=0

Proof By Lemma 2.1.5 and Lemma 2.4.1, c+kc = c+kk = ( 1)k ck 1 and sim-
ilarly d+md k = d+m
m k
k
= ( 1)m k md k1 . Hence the left-hand side is
m ✓ ◆✓ ◆
c 1 d 1
( 1) m
 k m k
.
k=0

By the general version of Vandermonde’s Convolution, taking a = c 1 and b =


d 1, this is ( 1)m c md 2 . The claim now follows by another application of
the two lemmas used at the start of the proof.

Exercise 2.14 asks for a bijective proof of this identity. To finish we prove a
tougher binomial identity.

Claim 2.4.5 If n, ` 2 N0 and n ` then


n ✓ ◆✓ ◆✓ ◆ ✓ ◆✓ ◆
( 1)n k n ` + k k + 1 1 2` `
 = .
k=` k + 1 k k `+1 `+1 ` n `

Proof Our aim in each step is to reduce the number of appearances of the sum-
mation variable k. The 1/(k + 1) looks particularly troublesome, but it can easily
1 k+1 1 k
be removed using the identity k+1 `+1 = `+1 ` . (See Exercise 2.1 at the end of
this chapter for the combinatorial proof.) Hence the left-hand side is
✓ ◆✓ ◆✓ ◆
1 n n k n `+k k
 ( 1) k
` + 1 k=` k `
.
32 Binomial coefficients

Now use Lemma 2.2.4 to rewrite nk k` as n` n `


k ` to get
✓ ◆ n ✓ ◆✓ ◆
1 n n k n ` `+k
` + 1 ` k=`Â ( 1) k ` k
.

The sum is now somewhat similar to Vandermonde’s convolution, suggesting that


the technique used to prove Claim 2.4.4 may be effective. Indeed, negating the
binomial coefficient `+k
k and applying Lemma 2.1.5 to nk `` gives
✓ ◆ ✓ ◆✓ ◆
( 1)n n n n ` ` 1
` + 1 ` k=`Â n k k
which simplifies, by the general version of Vandermonde’s Convolution with a =
1)n n n 2` 1 1 n 2`
n ` and b = ` 1 to (`+1 ` n . Another negation gives `+1 ` n and the
required form then follows from another application of Lemma 2.2.4.
It should be admitted this identity was strategically chosen to show the methods
of this chapter in a good light. Further techniques for proving binomial coefficient
identities are given in the exercises below and Chapter 5, and in §8.3 and §14.2.

Exercises
The core exercises are 2.1 to 2.4. Exercises 2.1 to 2.7 were used on the problem
sheet for this part of the course.
2.1 Prove that
✓ ◆ ✓ ◆
n n 1
k =n
k k 1
for n, k 2 N in two ways:
(a) using the formula for a binomial coefficient;
(b) bijectively.
2.2 Prove that if m, n 2 N0 then
n ✓ ◆✓ ◆ ✓ ◆
m n m+n 1
Âr r r =n n
.
r=0

[Hint: use Exercise 2.1 and then aim to apply Vandermonde’s convolution.]
2.3 Let n, k 2 N0 . Prove if n k then
✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆
k k+1 k+2 n n+1
+ + +···+ =
k k k k k+1
in two ways:
Exercises 33

(a) by induction on n (where k is fixed in the inductive argument);


(b) bijectively, by reasoning with subsets of {1, 2, . . . , n + 1}. [Hint: interpret the
summand kr as counting the (k + 1)-subsets of {1, 2, . . . , n + 1} with a spe-
cific maximum element.]

2.4 A lion tamer has n 2 N0 cages in a row. For k 2 {0, 1, . . . , n}, let g(n, k) be
the number of ways in which she may accommodate k indistinguishable lions
so that no cage contains more than one lion, and no two lions are housed in
adjacent cages.
(a) Show that g(n, k) = g(n 2, k 1) + g(n 1, k) if n 2 and k 1.
(b) Prove by induction that g(n, k) = n k+1
k for all n 2 N and k 2 N0 such that
k  n. [Hint: the base cases are determined by the conditions n 2 and k 1
in (a).]
(c) (?) Find a bijective proof of the formula for g(n, k).

2.5 Let n, k 2 N. How many solutions are there to the equation u1 +u2 +· · ·+un =
k if the ur are strictly positive integers, that is ur 2 N for each r?
2.6 Define
✓ ◆ ✓ ◆ ✓ ◆
n n 1 n 2
bn = + + +···
0 1 2
for n 2 N0 .
(a) Find the first few terms of the sequence b0 , b1 , b2 , b3 , . . ..
(b) State and prove a recurrence relating bn+2 to bn+1 and bn . Hence identify the
numbers bn .

2.7
(a) What is 114 ? Explain the connection to binomial coefficients.
(b) Let m 2 N. Prove that
✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆
2m 2m 2m 2m 2m
< ... < < > > ... >
0 m 1 m m+1 2m
and that
✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆
2m + 1 2m + 1 2m + 1 2m + 1
< ... < = > ... > .
0 m m+1 2m + 1

(c) By considering a suitable binomial expansion prove that


✓ ◆
4m 2m
  4m .
2m + 1 m
34 Binomial coefficients
In some of the further exercises below we use the convention that if no bounds are
given on a sum then it is over all elements of N0 . For example, by Corollary 2.2.8(i)
we have Âk mk = 2m , since mk = 0 for k > n.

2.8 Prove that if m 2 N0 then


✓ ◆2 ✓ ◆
m 2m
 k = m .
k

(The sum is defined using the convention just described.)


2.9 Show that if n 2 N and k 2 N0 then
✓ ◆✓ ◆ ✓ ◆
n r r n
 r k x = k xk (1 + x)n k .
r
✓ ◆✓ ◆ ✓ ◆ ✓ ◆✓ ◆
n r n n k r n r
Deduce that  = 2 . Show also that Â( 1) = 0,
r r k k r r k
provided n > k.
2.10 Prove that if m, n, k 2 N0 then
✓ ◆✓ ◆✓ ◆ ✓ ◆✓ ◆
r m n n m+n k
 k r r = k n
r

generalizing Exercise 2.2.


2.11 Let n, m 2 N0 .
(a) Prove that
m ✓ ◆ ✓ ◆
n n m+1 n
 2
k
k
=
2 m+1
.
k=0
n n
(b) Deduce that Âm k=0 (n 2k) k = (n m) m .
(c) (?) Find a bijective proof of the identity in (b).
(This exercise is a generalization of Problem A4 in the 1974 Putnam Math-
ematical Competition, a mathematics olympiad for students at USA univer-
sities. For a probabilistic interpretation and a suggestion for further reading,
see Exercise B.1.)
2.12 Given sets X and Y define their symmetric difference by
X 4 Y = (X [Y )\(X \Y ).
Thus X 4 Y consists of the elements lying in exactly one of X and Y .
(a) Let S be the set of all subsets of a set W. Show that S is a commutative ring
with addition defined by X + Y = X 4 Y and multiplication by XY = X \ Y .
(Identify the zero and one elements explicitly.)
Exercises 35

(b) Show that X 4 X = ? for all X 2 S. Thus every element of S is its own additive
inverse.
(c) Let X, Y , Z 2 S. Show that

X 4 Y = Z () Y 4 Z = X () Z 4 X = Y.

[Hint: imagine X, Y and Z are numbers. How would you solve the equation
X +Y = Z for X?]
(d) Let X, Y , Z, W 2 S. Show that

X 4 Y = Z 4 W () X 4 Z = Y 4 W

and (X 4 Y ) \ (Z 4 W ) = (X \ Z) 4 (Y \ Z) if and only if X \ Z = Y \W .


2.13 Fix k 2 N. Given distinct k-subsets X and Y of N, say that X is smaller than Y ,
and write X < Y if the largest element of X [Y not contained in X \Y is in Y .
This defines the colexicographic order on k-subsets of N.
(a) The first six sets in the colexicographic order on 3-subsets of N are

{1, 2, 3}, {1, 2, 4}, {1, 3, 4}, {2, 3, 4}, {1, 2, 5}, {1, 3, 5}.

Find the next six sets.


(b) Let r 2 N. What is the kr th set in the colexicographic order on k-subsets
of N?
(c) Find the 2016th set in the colexicographic order on 5-subsets of N.
(d) What is the ten millionth set in the colexicographic order on 10-subsets of N?
(e) Give a bijective proof that if r, m 2 N0 and r m then r 0m + r 1m + · · · +
r r+1
m = m . (This is equivalent to Lemma 2.2.3.)

2.14 Give a bijective proof of Claim 2.4.4.


2.15 Some binomial identities have elegant proofs using self-inverse bijections.
Such functions are known as involutions. The solution to Exercise 2.2.10
gives a more basic example of this method.
(a) Let n 2 N. Let

P = {(X,Y ) : X, Y ✓ {1, 2, . . . , n}, |X| + |Y | = n}.

Define sgn(X,Y ) = ( 1)|X| . Define f : P ! P by


8
<(X,Y )
> if X = Y
f (X,Y ) = X\{z},Y [ {z} if z 2 X
>
:
X [ {z},Y \{z} if z 2 Y
36 Binomial coefficients

where z is the maximum element of X 4 Y . (For the definition of 4 see Ex-


ercise 2.12. Note that X 4 Y is non-empty, and so has a maximum, when-
ever this definition uses z.) Show that f is an involution on P and that if
f (X,Y ) 6= (X,Y ) then sgn f (X,Y ) = sgn(X,Y ). Deduce that
✓ ◆2 ( n
n
k n ( 1)n/2 n/2 if n is even
 ( 1)
k
=
0 if n odd.
k=0

(For a simpler proof see Exercise 5.2.)


(b) Let n 2 N0 . Adapt the involution in (a) to prove that
n ✓ ◆✓ ◆ (
n n 0 if n is even
 ( 1)k k k 1 = ( 1)(n+1)/2 n if n is odd.
k=1 (n+1)/2

The following exercises use the generalized definition of binomial coefficients in-
troduced in §2.4

2.16
(a) Let h(z) = a0 + a1 z + · · · + ad zd be a polynomial in C[z]. Show that if there
exist distinct complex numbers c1 , c2 , . . . , cd+1 2 C such that h(ci ) = 0 for all
i 2 {1, 2, . . . , d + 1} then h = 0.
(b) Hence show that if f and g are polynomials of degree at most d that agree at
d + 1 distinct elements of C then f = g.
n
2.17 Let b 2 N and let n 2 N0 . Give a bijective proof that (b + 1)n = Âk k bk .
Deduce the Binomial Theorem using the previous exercise.
2.18 Show that if z 2 C and n 2 N0 then
m ✓ ◆ ✓ ◆
r z+1 m z 1
 ( 1)
r
r = ( 1)
m 1
(z + 1).
r=0

2.19 Let f (z) = z3 3z2 + 1. The table below has f (0), f (1), . . . , f (6) in its first
row. Each entry in each subsequent row is computed by taking the difference
between the two entries in the row above.
1 1 3 1 17 51 109
2 2 4 16 34 58
0 6 12 18 24
6 6 6 6
0 0 0
(a) Show that f (z) = 6 3z + 0 2z 2 1z + 0z . What is the connection with the
table? (The connection is proved in Exercise 2.21.)
Exercises 37

(b) Find a polynomial g(z) of small degree such that g(0), g(1), g(2), g(3), g(4)
equal 0, 1, 0, 1, 0, respectively.
2.20 Let an be the maximum number of regions inside a circle that can be formed
by taking n points on its circumference and joining every two distinct points
by a line. For example, counting regions in the diagram below shows that
a5 = 16.

(a) Find a1 , a2 , a3 , a4 .
(b) Conjecture (if you feel brave) a formula for an .
(c) Find a0 and a6 .
(d) Using the table method in Exercise 2.19 conjecture a formula for an .
(The formula given by (d) is in fact correct: this is proved in Exercise 6.1
using generating functions.)
2.21 Given a function f : C ! C, define D f : C ! C by (D f )(z) = f (z + 1) f (z).
Set D0 f = f and define Dk f = D(Dk 1 f ) inductively for k 2 N. For example,
if f (z) = z2 then (D f )(z) = (z + 1)2 z2 = 2z + 1 and hence (D2 f )(z) =
(2(z + 1) + 1) (2z + 1) = 2.
(a) Prove by induction on n that
8✓ ◆
✓ ◆ < z
z if 0  n  r
Dn = r n
r :
0 otherwise.

(b) Let b(z) = rz . Let k 2 N0 . Show that (Dn b)(0) = 1 if k = n and (Dn b)(0) = 0
if k 6= r.
(c) Show that the binomial coefficients rz for r 2 N0 are a basis for C[z]. (Equiv-
alently, for each polynomial f (z) 2 C[z] of degree d, there exist unique coef-
ficients c0 , c1 , . . ., cd 2 C such that f (z) = Âdr=0 cr rz .)
(d) Using (b) and (c) show that if f (z) is a polynomial of degree at most d then
f (z) = Âdr=0 cr rz where cr = (Dr f )(0) and that the coefficients c0 , c1 , . . . , cd
are the entries on the diagonal of a table constructed as in Exercise 2.19.
(e) Show that (Dn f )(z) = Ânk=0 ( 1)k nk f (z + n k).
38 Binomial coefficients

2.22 Let z 2 C and let m 2 N0 . Prove that


2m ✓ ◆✓ ◆✓ ◆ ✓ ◆✓ ◆
k 2m z z m 2m z+m
 ( 1) k k 2m k = ( 1) m 2m
.
k=0

by showing that the two sides are equal for z 2 { m, . . . , 1, 0, 1, . . . , m}.


Deduce Dixon’s Identity,
2m ✓ ◆3
k 2m (2m)!
 ( 1)
k
= ( 1)m
m!3
.
k=0
Interlude I: The Egg Dropping Problem

Problem You are given three Fabergé eggs by the owner of a building with 100
floors. The owner wants to know the highest floor from which an egg will survive
being dropped. What is the smallest number of drops that guarantees to give the
correct answer?
(The eggs are identical in every respect. If an egg smashes it is gone for ever, if it
survives the fall then it is as good as new. It is possible that the eggs can survive
the drop from floor 100.)

Hints
Try simplifying the problem: take two eggs and a building with 10 floors.
• How many drops might be needed if the first egg is dropped from floor 5?
• How many drops might be needed if the first egg is dropped from floor 3?
• How is the optimal floor for the first drop related to the total number of
drops, in the worst case for your strategy?
Now solve the problem for some other small buildings and look for a pattern.

Solution
Following the hints, we start by looking at the smaller two egg problem. You should
have found that if there are 10 floors and the first egg is dropped from floor 4 then
4 drops always suffice:
• if the first drop smashes an egg then we drop the remaining egg from floor 1,
then floor 2 (if it survives), then floor 3 (if it survives again);
• if the egg survives the first drop then, after making the next drop from
floor 7, two more drops suffice.
40 Interlude I: The Egg Dropping Problem

Exercise Check the second claim above, and show, if you have not already done
so, that if the first drop is made from floor 5 or floor 3 then four more drops (making
five in total) may be necessary.
The analysis so far shows two key ideas:
(A) If we are down to one egg, because the other egg smashed when dropped
from floor r, and we have not made any drops from floors below r, then
there is nothing better than to make up to r 1 further drops working from
floor 1 upwards.
(B) If an egg survives a drop from floor r then we can ignore floors 1 up to r,
and think of the building as having n r floors.
Let f (n) be the number of drops needed, in the worst case, to find the highest
egg-safe floor in a building of n floors. Suppose we make the first drop from floor
r. If this smashes an egg then, by (A), we need at most r 1 further drops. If it
survives then, by (B), we need at most f (n r) further drops. (This is correct even
when r = n, provided we set f (0) = 0.) Hence
f (n)  1 + max r 1, f (n r) = max r, 1 + f (n r) (?)
for each r 2 N with r  n. Moreover, the true value of f (n) is given by choosing r
to minimize the right-hand side of (?). Using (?) and computing iteratively, starting
with f (1) = 1, we get the table shown below.

n 0 1 2 3 4 5 6 7 8 9 10 11
f (n) 0 1 2 2 3 3 3 4 4 4 4 5

For example, if n = 5 we have f (5)  max(1, f (4) + 1) = 4, f (5)  max(2, f (3) +


1) = 3, f (5)  max(3, f (2) + 1) = 3, f (5)  max(4, f (1) + 1) = 4 and f (5) 
max(5, f (0) + 1) = 5. So f (5) = 3 and we can drop the first egg from either floor
2 or floor 3.
Exercise Check some more entries from the table. In each case, show that an
optimal strategy drops the first egg from floor f (n).
The jumps in f (n) occur immediately after the triangle numbers 1, 3, 6, 10, . . . .
This motivates the following conjecture.
d+1
Conjecture For all n 2 N, f (n) is the minimum d such that 2 n. Moreover,
an optimal strategy drops the first egg from floor d.
Proof We work by induction on n. If n = 1 then after dropping an egg from floor 1
we know the highest egg-safe floor. Hence f (1) = 1, and correspondingly, the min-
imal d such that d+1
2 1 is 1. Now let n 2 N and let d be minimal such that
Interlude I: The Egg Dropping Problem 41
d+1
2 n. If the first drop is from floor d then (?) gives
f (n)  max(d, 1 + f (n d)). (†)
Since d+12 d = d+1 2
d d
1 = 2 , we have 2
d
n d. Hence f (n d), being
the minimal e such that e+1 2 n d, satisfies f (n d)  d 1. Suppose f (n
d 1
d)  d 2. Then 2 n d, and repeating the previous argument in reverse,
d
we get 2 n, contradicting the minimality of d. Therefore f (n d) = d 1 and
(†) implies that f (n)  max(d, d) = d.
Now suppose that there is an optimal strategy in which the first drop is from
floor r. By (A) we have r  d. If the egg survives then, by (B), and we may need
f (n r) more drops. Since n r n d, we have f (n r) f (n d) = d 1.
Therefore max r, 1 + f (n r) 1 + f (n r) 1 + (d 1) = d. Hence dropping
from floor d is optimal and f (n) = d.
It is possible to solve the 3 egg problem by generalizing this argument. But the
analysis so far motivates a much more elegant approach. p For brevity, let us say that
2n
p p
f (n) drops solve a building with n floors. Note that 2 = 2n( 2n + 1)/2 =
p p
n + n/2 n, so we have f (n)  2n. (This uses the generalized definition of
binomial coefficients introduced in §2.4.) The square-root function is not so easy
to work with, and is responsible for the slow, but jumpy, growth of f (n). Maybe it
would be more convenient to work with something like an inverse function . . . .
Let g(d) be the number of floors in the tallest building that can be solved using
at most d drops of two eggs. We know that a building of height d+1 2 can be solved
d+1
with d drops, so g(d) 2 .
d+1
Conjecture If d 2 N then g(d) = 2 .

Proof Let n = d+1 2 . By the conjecture before this, d drops suffice to solve a
building of height n, and d drops do not suffice to solve a building of height n + 1,
since d+1
2 < n + 1.
Generalizing the definition of g, let ge (d) be the number of floors in the tallest
building that can be solved using at most d drops of e eggs. Clearly ge (1) = 1 for all
e 2 N and, by (A), g1 (d) = d for all d 2 N. We now run the argument proving the
first conjecture, thinking about ge . An instructive exercise is to prove the following
claim in the special case e = 2.
Claim For any d, e 2 N we have ge (d) = ge 1 (d 1) + ge (d 1) + 1.
Proof Let n = ge (d). Suppose an optimal strategy drops the first egg from floor r.
If it smashes, we are left with e 1 eggs and d 1 drops to deal with a building
of effective height r 1. Hence r 1  ge 1 (d 1). If the first egg survives, we
42 Interlude I: The Egg Dropping Problem

have e eggs and d 1 drops to deal with a building of effective height n r. Hence
n r  ge (d 1). Adding these two inequalities implies that
ge (d)  ge 1 (d 1) + ge (d 1) + 1. (??)
Moreover, taking r = ge 1 (d 1) + 1 we see that a building with ge 1 (d 1) +
ge (d 1) + 1 floors can be solved using d drops. Hence equality holds.
Using the recurrence (??) and the boundary conditions ge (1) = 1 and g1 (d) = d,
it is easy to calculate the following table of values for small d and e.

d\e 1 2 3 4 5 6
1 1 1 1 1 1 1
2 2 3 3 3 3 3
3 3 6 7 7 7 7
4 4 10 14 15 15 15
5 5 15 25 30 31 31
6 6 21 41 56 62 63
7 7 28 63 98 119 126
8 8 36 92 162 218 246
9 9 45 129 255 381 465
10 10 55 175 385 637 847

From the table we see that with 3 eggs, 8 drops do not suffice to solve a building
with 100 floors, but 9 drops are sufficient. (In fact 9 drops can solve a building with
129 floors.) This answers the original problem.
The values of g1 (d) and g2 (d) appearing in the first and second column and the
almost powers of 2 along the diagonal now suggest a final conjecture.
Conjecture For all d, e 2 N we have
✓ ◆ ✓ ◆ ✓ ◆
d d d
ge (d) = + +···+ .
1 2 e
Proof We work by induction on d. If d = 1 then we have ge (1) = 1, which agrees
with 11 + 12 + · · · + 1e = 1. Suppose inductively that the conjecture holds for
d 1. Then, by (??) and the Fundamental Recurrence (Lemma 2.1.7) we get
e 1✓ ◆ e ✓ ◆
d 1 d 1
ge (d) = ge 1 (d 1) + ge (d 1) + 1 = Â +Â +1
k=1 k k=1 k
e 1 ✓ ◆ ✓ ◆ ✓ ◆ e 1✓ ◆ e ✓ ◆
d 1 d 1 d 1 d d
=Â + + +1 = Â +d = Â
k=1 k k + 1 1 k=1 k + 1 k=1 k
Interlude I: The Egg Dropping Problem 43

as required.
Going back to the inverse function, we see that the minimum number of drops
of e eggs needed, in the worst case, to find the highest egg-safe floor in a building
with n floors is the minimum d such that d1 + d2 + · · · + de n.

Final discussion
After solving a problem, it is very tempting to (metaphorically) throw a quick party
with oneself as the guest of honour, and then forget all about it. But often the
greatest insights come from asking oneself further questions: “Is there an easier
solution?”, “Is the answer intuitive?”, “What techniques did I use that might be
applicable elsewhere?”, “Are there appealing generalizations or connections with
other areas of mathematics?” Here are some thoughts suggested by these questions.
• To get started we generalized the problem, by allowing buildings of arbitrary
height and any number of eggs, before simplifying it, by considering just two
eggs and small buildings. It is often useful, but humbling, to ask “What is the
simplest related problem that I still can’t solve?”
• One key idea was to switch from minimizing the number of drops, for a fixed
building height, to maximizing the building height, for a fixed number of drops.
This kind of ‘inversion’ is a common theme in mathematics. Jacobi, who made
important contributions to the theory of elliptic functions using inversion, fa-
mously said “man muss immer umkehren” (one must always invert).
• The proof of the recurrence ge (d) = ge 1 (d 1) + ge (d 1) + 1 shows that
when we drop the first egg from floor ge 1 (d 1) + 1 in a building with ge (d)
floors, we are indifferent to the outcome. If the egg smashes, we are left with
a building of effective height ge 1 (d 1), solvable in d 1 drops with the re-
maining e 1 eggs; if it survives we are left with a building of effective height
ge (d) (ge 1 (d 1) + 1) = ge (d 1), solvable in d 1 drops of the e eggs. This
feature, that with optimal play we are indifferent to our adversary’s response, of-
ten appears in the analysis of games.
• When we started, computing even the two-egg number f (10) was a non-trivial
problem. At the end, the explicit formula for ge (d) gives a fast algorithm for
finding the number of drops needed to solve any building, with any number of
eggs. As seen earlier for the derangement numbers, better understanding leads
to faster computation.
• Next we ask “Is the answer intuitive?” Suppose we make d drops. Interpreting
d
s as the number of ways to choose s of these drops to smash an egg, we see
that the number of different outcomes of a sequence of d drops is d1 + d2 +
44 Interlude I: The Egg Dropping Problem

· · · + de . Hence, using d drops, we can distinguish at most d1 + d2 + · · · + de


outcomes, and so ge (d)  d1 + d2 + · · · + de . Given this, it is a reasonable
guess that equality is attained, and one can jump immediately to the recurrence
(??) to prove this.
• Finally, if you have done some coding theory, you might remember the definition
of the Hamming ball of radius r about a vector w 2 Fn2 as the set of all v 2 Fn2 such
that v differs from w in at most r positions. For example, the Hamming ball of
radius 2 about (1, 1, 1) 2 F32 is F32 \{(0, 0, 0)}. By the final conjecture, ge (d) + 1
is the size of a Hamming ball of radius e in Fd2 . The previous remark goes some
way to explaining this surprising connection.
Exercise Investigate the asymptotics of ge (d). [Hint: Shannon’s entropy function
is relevant.]
3
Principle of Inclusion and Exclusion

3.1 Introduction to the Principle of Inclusion and Exclusion


The Principle of Inclusion and Exclusion is a way to find the size of the union of a
finite collection of subsets of a finite universe set, W. Typically we really want the
complement of the union. We start with the two smallest non-trivial examples.
If X is a subset of W, its complement in W is
X = {x 2 W : x 62 X}.
Clearly |X| = |W| |X|.
Example 3.1.1 Let A and B be subsets of the finite universe set W. In |A| + |B|,
each member of A \ B is counted twice. To count |A [ B| we must therefore subtract
|A \ B|, giving |A [ B| = |A| + |B| |A \ B|. Taking the complement we get
|A [ B| = |W| |A| |B| + |A \ B|.
Now let C be a further subset of W. We claim that
|A [ B [C| = |W| |A| |B| |C| + |A \ B| + |A \C| + |B \C| |A \ B \C|.
The Venn diagram and table below show the non-zero contributions from the mem-
bers of each region to the right-hand side. Up to symmetry, there are four cases.
For example, in case (2), x 2 A \ B \C is counted in the summands |W|, |A|, |B|
and |A \ B|, for an overall contribution of 1 1 1 + 1 = 0.
W
(0) C (0) A \ B \C 1
(1) A \ B \C 1 1
(3) (2) A \ B \C 1 1 1+1
(1)
(2) (3) A \ B \C 1 1 1 1+1+1+1 1
A B
46 Principle of Inclusion and Exclusion

Thus elements of A \ B \ C = A [ B [C each contribute 1, and all other elements


of W contribute 0, as required. Taking the complement we get
|A [ B [C| = |A| + |B| + |C| |A \ B| |A \C| |B \C| + |A \ B \C|.
Example 3.1.2 The m-th (centred) hexagonal number hm is the number of dots in
the m-th figure below.

• • •
B
• • • • • •

• , • • • , A • • • • • , ...

• • • • • •

• • • C

Let A, B, C be the three rhombic subsets of the m-th diagram, as indicated above
for h3 . By counting dots we see that |A| = m2 , |A \ B| = m and |A \ B \ C| = 1.
Hence, by symmetry and the final formula in Example 3.1.1,
hm = m2 + m2 + m2 m m m + 1 = 3m(m 1) + 1.
Observe that it was easier to find the sizes of the intersections of the three rhombi
than it was to find the size of their unions. Whenever intersections are easier to
think about than unions, the Principle of Inclusion and Exclusion may be helpful.
In the general result, we have subsets A1 , A2 , . . . , An ✓ W. For each non-empty
subset I ✓ {1, 2, . . . , n} we define
\
AI = Ai .
i2I

Thus AI is the set of elements which belong to each set Ai for i 2 I. (We deliberately
do not specify which other sets, if any, these elements lie in.) For example x 2 A{1,3}
if and only if x 2 A1 and x 2 A3 . More generally, if i, j 2 {1, 2, . . . , n} then A{i} = Ai
and A{i, j} = Ai \ A j . By convention the empty intersection is the universe set W.
Thus
A0/ = W.
Theorem 3.1.3 (Principle of Inclusion and Exclusion) If A1 , A2 , . . . , An are sub-
sets of a finite universe set W then
|A1 [ A2 [ · · · [ An | = Â ( 1)|I| |AI |.
I✓{1,2,...,n}
3.2 Counting derangements 47

Exercise 3.1.4 Check that you understand the AI notation by writing out the Prin-
ciple of Inclusion and Exclusion when n = 3 as a sum with eight summands and
comparing with Example 3.1.1.
We prove the Principle of Inclusion and Exclusion by generalizing the argument
in Example 3.1.1. We need the identity Âm k m
k=0 ( 1) k = 0 for m 2 N, proved in
Corollary 2.2.8(ii) by expanding ( 1 + 1)m using the Binomial Theorem. The spe-
cial case 30 3
1 + 2
3 3
3 = 0 may be seen in case (3) of this example.

Proof of Theorem 3.1.3 Let x 2 W. Suppose that x is not a member of any of the
sets A1 , A2 , . . . , An . Then x is counted once on the left-hand side. Since A0/ = W, on
the right-hand side x contributes 1 to |A0/ | and 0 to every other summand, giving an
overall contribution of 1, as required.
Now suppose that x 2 A j if and only if j 2 J, where J is a non-empty subset
of {1, 2, . . . , n}. On the right-hand side, x contributes to |AI | if and only if x lies
in Ai for every i 2 I, so if and only if I ✓ J. Hence the contribution from x to the
right-hand side is ÂI✓J ( 1)I . Since there are |J| k subsets of J of size k, this sum
is
|J| ✓ ◆
k |J|
 ( 1) k = 0
k=0

where the final equality is the case |J| = m of the identity just mentioned. Hence
the contribution of x to the right-hand side is 0, again as required.
Exercise 3.1.5 Deduce from Theorem 3.1.3 that
|A1 [ A2 [ · · · [ An | = Â ( 1)|I| 1 |AI |.
I✓{1,2,...,n}
I6=0/

Exercises 3.14 and 3.15 strengthen the Principle of Inclusion and Exclusion,
using a more formal argument in which a function from W to Z records the contri-
butions from each x 2 W to its right-hand side.

3.2 Counting derangements


The Principle of Inclusion and Exclusion gives a particularly elegant proof of the
formula for the derangement numbers dn first proved in Corollary 1.1.9:
1 1 1 ( 1)n
dn = n! 1 + +···+ .
1! 2! 3! n!
Recall from Definition 1.1.2 that a permutation s : {1, 2, . . . , n} ! {1, 2, . . . , n} is a
derangement if and only if it has no fixed points. Let W be the set of all permutations
of {1, 2, . . . , n}. Let Ai be the set of permutations we do not want to count, because
48 Principle of Inclusion and Exclusion

they fix i. (The permutation in Ai might have other fixed points too, but in the spirit
of the Principle of Inclusion and Exclusion, we use just one property to define Ai .)
Thus
Ai = {s 2 W : s (i) = i}

and A1 [ A2 [ . . . [ An is the set of derangements. To apply the Principle of Inclu-


sion and Exclusion we need to know the sizes |AI | on its right-hand side.

Lemma 3.2.1 Let s 2 W and let I ✓ {1, 2, . . . , n}. Then s 2 AI if and only if
s (i) = i for all i 2 I. Moreover |AI | = (n |I|)!.

Proof Let s be a permutation of {1, . . . , n}. Then s 2 AI if and only if s 2 Ai for


each i 2 I, so if and only if s fixes every element of I. The remaining elements in
{1, . . . , n}\I can be permuted in any way. (For instance, some might be fixed.) Since
there are (n |I|)! permutations of {1, . . . , n}\I, we have |AI | = (n |I|)!.

We are now ready to apply the Principle of Inclusion and Exclusion to the right-
hand side in dn = |A1 [ . . . [ An |. It gives
n ✓ ◆
n
dn = Â ( 1) |AI | = Â ( 1) (n |I|)! = Â
|I| |I|
( 1)k (n k)!.
I✓{1,...,n} I✓{1,...,n} k=0 k

The final equality holds because there are nk subsets of {1, . . . , n} of size k, and for
each such subset I, we have ( 1)|I| (n |I|)! = ( 1)k (n k)!. Since nk (n k)! =
n!/k! by Lemma 2.1.4, it follows that
n
( 1)k
dn = n! Â
k=0 k!

as expected.

3.3 Counting five card hands


We apply the Principle of Inclusion and Exclusion to solve Exercise 1.6 on count-
ing hands of five cards from a standard deck. The universe set W is all 52
5 hands
of five cards. Let H be those hands with at least one Ace, King and Queen. We
have three relevant types of card, so we aim to express H as CA [CK [CQ for three
well-chosen subsets of W.

Exercise 3.3.1 Think of CK as those hands we do not want to count, because of a


reason to do with the King. What property defines CK ?
3.4 Prime numbers and Euler’s f function 49

The answer is that CK is the set of hands with no King. (Again the hands in CK
might also be unwanted because they lack other cards.) The notation CK is chosen
to suggest ‘King complement’. Similarly, CA is the set of hands with no Ace, and
CQ is the set of hands with no Queen. A hand is in H if and only if it is in none of
CA , CK and CQ , hence H = CA [CK [CQ . Of the 52 cards in the pack, 48 are not
aces, so |CA | = 48 48
5 . Similarly |CK | = |CQ | = 5 . There are 44 cards that are not
Aces or Kings, so |CA \ CK | = 5 , and similarly |CA \ CQ | = |CK \ CQ | = 44
44
5 .
Finally |CA \CK \CQ | = 40 5 . By the Principle of Inclusion and Exclusion, in the
three subset case from Example 3.1.1, we get

|CA [CK [CQ | = |W| |CA | |CK | |CQ |


+ |CA \CK | + |CA \CQ | + |CK \CQ | |CA \CK \CQ |
✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆
52 48 44 40
= 3 +3
5 5 5 5
= 62064.

You should now have no difficulty in counting the five card hands in Exercise 1.6(a)
with at least one Ace, King, Queen and Jack. The answer, from the Principle of
Inclusion and Exclusion applied with four sets, is 52 5 4 48
5 +6 5
44
4 40
5 +
36
5 = 10752.
Part of the strength of the Principle of Inclusion and Exclusion is that, once one
has grasped one application, it can often be adapted to solve similar problems. As
an example (see also Exercise 3.4), we count hands with at least one Ace, King and
Queen, and at least one of the two red Jacks. We redefine CJ to be those hands we do
not want to count, because they are missing both red Jacks. Thus |CJ | = 50 5 , and,
for instance, |CA \CJ | = 46 5 , and |CA \C K \C J | = 42
5 . The number of hands is
✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆
52 48 50 44 46 40 42 38
3 +3 +3 3 + = 5504.
5 5 5 5 5 5 5 5

3.4 Prime numbers and Euler’s f function


The Sieve of Eratosthenes
Start by writing out the numbers 1, 2, 3, . . . , M for an M of your choice. Immediately
cross out 1. On each subsequent step, circle the smallest unmarked number, and
then cross out all its proper multiples. (After the first step, some of these multiples
may already have been crossed out.) Stop when no number is unmarked. Since
a number gets circled if and only if it is not 1 and not divisible by any smaller
number, the circled numbers are precisely the primes. For example, the diagram
overleaf shows the sieve on {1, 2, 3, . . . , 48} after crossing out the multiples of 2, 3
50 Principle of Inclusion and Exclusion

and 5. Any composite number in {1, 2, . . . , 48} is divisible by one of the primes 2,
3 or 5, so the uncrossed numbers are precisely the primes between 2 and 48. In
each subsequent step, a prime is circled, and there are no new crossings-out.

1 2 3 4 5 6 7 8 9 10

11 12 13 14 15 16 17 18 19 20

21 22 23 24 25 26 27 28 29 30

31 32 33 34 35 36 37 38 39 40

41 42 43 44 45 46 47 48

We now interpret the diagram using the Principle of Inclusion and Exclusion.
Generally let W = {1, 2, . . . , M} and for m 2 N let

D(m) = {x 2 W : x is divisible by m}.

Example 3.4.1 Take W = {1, 2, . . . , 48}. We have seen that any composite number
in W is in the set D(2) [ D(3) [ D(5). Also this set contains 2, 3 and 5. The com-
plement of D(2) [ D(3) [ D(5) is therefore all the primes p 2 W such that p 7,
together with 1. (This appearance of 1 is annoying, but inevitable, since 1 is clearly
not in D(2) [ D(3) [ D(5).) In symbols,

{1} [ {p 2 W : p 7 and p is prime} = D(2) [ D(3) [ D(5).

Let Q be the size of either side. By the Principle of Inclusion and Exclusion,
Q = |W| |D(2)| |D(3)| |D(5)| + |D(2) \ D(3)|
+ |D(2) \ D(5)| + |D(3) \ D(5)| |D(2) \ D(3) \ D(5)|.
Either using Lemma 3.4.2 below, or by direct enumeration, one finds that Q =
48 24 16 9 + 8 + 4 + 3 1 = 13. For example, since a number is divisible
by 3 and 5 if and only if it is divisible by 15, D(3) \ D(5) = D(15) = {15, 30, 45}.
Reintroducing the primes 2, 3, and 5, and remembering to remove the non-prime 1,
we have shown that there are 13 + 3 1 = 15 primes in {1, 2, . . . , 48}. Observe that
we did this using only properties of 2, 3 and 5.

Sieves and the f function


We start by finding the sizes of the sets D(d). Recall that if y 2 R then byc is the
greatest natural number s such that s  y. For instance b2c = b 52 c = bec = 2. It is
often useful that if c 2 Z then c  y if and only if c  byc.
3.4 Prime numbers and Euler’s f function 51

Lemma 3.4.2 Let M 2 N. There are exactly bM/dc numbers in {1, 2, . . . , M} that
are divisible by d.

Proof For x 2 N we have xd  M if and only if x  M/d. By the useful property


of the floor function, this holds if and only if x  bM/dc.

We can now generalize Example 3.4.1 to a sieve over an arbitrary set of primes.

Proposition 3.4.3 Let p1 , p2 , . . . , pn be distinct prime numbers and let M 2 N.


Let S be the set of numbers in {1, 2, . . . , M} that are not divisible by any of primes
p1 , p2 , . . . , pn . Then

M
|S| = Â ( 1) ’i2I pi .
|I|

I✓{1,2,...,n}

Proof Let W = {1, 2, . . . , M}. The numbers in D(pi ) are those we do not want to
count, because they are divisible by pi . (Again, they might also be unwanted be-
cause they are divisible by other primes, but we define D(pi ) using pi only.) There-
fore S = D(p1 ) [ . . . [ D(pn ). Let I ✓ {1, . . . , n}. Since the pi are distinct primes, a
number is divisible by pi for all i 2 I if and only if it is divisible by ’i2I pi . Thus
T
i2I D(pi ) = D ’i2I pi . (When I = ? this holds by our convention that the empty
intersection is the universe W; by a standard convention, the empty product is 1.)
By Lemma 3.4.2 and the Principle of Inclusion and Exclusion, we get

\ M
|S| = Â ( 1) |I|
D(pi ) = Â ( 1) ’i2I pi
|I|

I✓{1,2,...,n} i2I I✓{1,2,...,n}

as required.

We say that natural numbers are coprime if they share no prime factors. Let
f (M) be the number of natural numbers in {1, 2, . . . , M} that are coprime to M.
For example, f (15) = 8 counts 1, 2, 4, 7, 8, 11, 13, 14.
Observe that if M has distinct prime factors p1 , p2 , . . . , pn then x 2 {1, 2, . . . , M}
is coprime to M if and only if x is not divisible by any of p1 , p2 , . . . , pn . Hence
f (M) = |S| where S is the set in Proposition 3.4.3. Since each product ’i2I pi
divides M exactly, we have

( 1)|I|
f (M) = M Â .
I✓{1,2,...,n} ’i2I i
p

For example, if M = 15 then p1 = 3 and p2 = 5 and


⇣ 1 1 1⌘ ⇣ 1 ⌘⇣ 1⌘
f (15) = 15 1 + = 15 1 1 .
3 5 15 3 5
52 Principle of Inclusion and Exclusion

More generally,
n ⇣
( 1)|I| 1⌘
f (M) = M Â = M’ 1
I✓{1,2,...,n} ’i2I i
p i=1 pi

since the summand ( 1)|I| / ’i2I pi in the middle is obtained by multiplying out
the product taking pi from 1 p1i if i 2 I and taking 1 if i 62 I.
Proposition 3.4.4 Let M 2 N have prime factorization pe11 pe22 . . . penn where ei 2 N
for each i. Then
n ⇣ 1⌘
f (pe11 pe22 . . . penn ) = ’ pei i 1 .
i=1 pi
Proof This is a restatement of the formula for f (M) just proved.
Euler’s f function is important in number theory and has applications in public
key cryptography: see Exercises 3.6 and 3.7.

Sieving to count primes


Let p(M) be the number of primes in {1, 2, . . . , M}. We use Proposition 3.4.3 and
the ideas in Example 3.4.1 to estimate p(M). Rather than pull the correct sieving
parameters out of a hat, we prove a more general result and then specialize it.
Theorem 3.4.5 Let p1 , p2 , . . . , pn be the first n prime numbers and let M pn .
Then
M
p(M)  n + + 2n .
log pn
Proof Let S be the numbers in {1, 2, . . . , M} not divisible by any of p1 , . . . , pn .
By Proposition 3.4.3 we know |S| exactly. But the floor functions make it hard
to use the right-hand side. Motivated by the formula for f (M), we approximate
the summand ( 1)|I| bM/ ’i2I pi c by ( 1)|I| M/ ’i2I pi . Since ’i2I pi might not
divide M, this introduces an error e 2 R such that 1 < e < 1. Since there are 2n
summands, one for each subset of {1, 2, . . . , n}, the overall error is between 2n
and 2n . Hence
M
|S|  Â ( 1)|I| ’i2I pi + 2n .
I✓{1,2,...,n}

By Proposition 3.4.4, we get |S|  M ’ni=1 1 p1i + 2n . Since S contains all the
primes in {1, 2, . . . , M} other than p1 , p2 , . . . , pn , we have p(M)  |S|+n. Therefore
n ⇣
1⌘
p(M)  n + M ’ 1 + 2n .
i=1 pi
Exercises 53

To get an upper bound on ’ni=1 1 1


pi we estimate its reciprocal, as follows:
n ⇣ 1⌘ 1 n ⇣
1 1 ⌘ pn
1
’ 1
pi
= ’ 1+ + 2 +···
pi pi Âx log pn .
i=1 i=1 x=1

(For details of the two inequalities above see Exercise 3.11.) We conclude that
’ni=1 1 p1i  1/ log pn and so p(M)  n + M/ log pn + 2n .
Restated, this theorem says that if we choose a number in {1, 2, . . . , M} uni-
formly at random, the probability that it is prime is at most n/M + 1/ log pn + 2n /M.
To get a non-trivial bound, we need 2n to be smaller than M. More precisely, since
2n /M = en log 2 log M , we need n  log M/ log 2.
Corollary 3.4.6 We have limM!• p(M)/M = 0.
Proof Take n = blog Mc in Theorem 3.4.5. Since pn n + 1 log M, we have
log pn log log M. Using 2blog Mc  2log M = M log 2 to bound the third summand,
we get
p(M) log M 1 M log 2
 + + .
M M log log M M
Now observe that each summand tends to 0 as M tends to infinity.
This makes precise the intuitive idea that as numbers get larger, they become
increasingly unlikely to be prime. In Exercise 3.10 you are asked to refine the
previous proof to show that p(M)/M  2/ log log M for all M sufficiently large.
Regrettably, this is still significantly weaker than the asymptotically correct result.
Known as the Prime Number Theorem, it states that
p(M)
lim = 1.
M!• M/ log M

While it seems that sieve methods cannot prove the Prime Number Theorem,
they are still very important in number theory. A sieve was used in Zhang’s break-
through proof in 2013 that there are infinitely many prime numbers p and q such
that q > p and q p  70 ⇥ 106 . Before Zhang’s theorem, no constant upper bound
was known. Thanks to the work of Maynard, Tao and the Polymath project (an
ad-hoc collaborative network of mathematicians) we now know that there are in-
finitely many pairs of primes differing by at most 246. It is conjectured, but as yet
unproved, that there are infinitely many primes p such that p + 2 is also prime.

Exercises
The core exercises are 3.1 to 3.4.
54 Principle of Inclusion and Exclusion

3.1 Let W = {1, . . . , 2019}. Let A = {x 2 W : x is even} and let B = {x 2 W :


x is divisible by 5}. What numbers are in A [ B? Find |A|, |B|, |A \ B| and
|A [ B|. Illustrate your answer with a Venn diagram.
3.2 How many numbers in {1, 2, . . . , 100} are not divisible by any of 2, 3, 5 or 7?
Use the Principle of Inclusion and Exclusion, making it clear which sets you
apply it to. Hence find the number of primes in {1, 2, . . . , 100}.
3.3 Let p, q and r be distinct primes. Find (a) f (pq), (b) f (p2 q) and (c) f (pqr)
using the Principle of Inclusion and Exclusion. Define the sets you use pre-
cisely. (Do not apply Proposition 3.4.4: instead you should adapt the argu-
ment.)
3.4 Recall that a deck of cards has four suits each of 13 cards: spades , hearts ~,
diamonds } and clubs |.
(a) How many five card hands are there with at least one card of each suit?
(b) How many five card hands are there with at least one card of each suit and at
least one Ace, King, Queen and Jack? You may give your answer as a sum
but try to simplify it as much as possible.

3.5 Let W be the set of all functions f : {1, 2, . . . , m} ! {1, 2, . . . , n}. For each
i 2 {1, 2, . . . , n} define

Ai = f 2 W : f (t) 6= i for any t 2 {1, 2, . . . , m} .

(a) What is |W|? What is |Ai |?


T
(b) Let I ✓ {1, 2, . . . , n} be a non-empty subset and let AI = i2I Ai . What condi-
tion must a function f 2 W satisfy to lie in AI ? Hence find |AI |.
(c) Use the Principle of Inclusion and Exclusion to show that the number of sur-
jective functions from {1, 2, . . . , m} to {1, 2, . . . , n} is
n ✓ ◆
k n
 ( 1) k (n k)m .
k=0

(d) Show that the above expression is the number of ways to put m numbered
balls into n numbered urns, so that each urn contains at least one ball.
(For the connection with Stirling Numbers of the Second Kind, see §?? and
Exercise 6.3.)
3.6 Recall that M and N are coprime if they share no common prime factor. Us-
ing Proposition 3.4.4, prove that if M and N are coprime then f (MN) =
f (M)f (N). Does this result hold for general M and N?
Exercises 55

3.7 In the RSA cryptosystem, Alice chooses two distinct primes p and q and
calculates M = pq. She chooses an encryption exponent a 2 N coprime to
f (M), and calculates a decryption exponent d such that ad ⌘ 1 mod f (M).
She publishes (M, a) as her public key and keeps p, q and d private. When Bob
sends a message to Alice, he looks up her public key (M, a), and encrypts his
message x 2 {0, 1, . . . , M 1} as xa mod M. When Alice receives an encrypted
message y, she decrypts by calculating yd mod M.
(Why this works to find x, and why, when p and q are large, it is believed that
an attacker cannot easily compute d, is explained in Exercise 3.9 below.)
In this toy example, we suppose that Alice takes p = 11 and q = 17 and a = 9.
She publishes (187, 9) as her public key.
(a) Encrypt the message 7 using Alice’s public key.
(b) Using Euclid’s Algorithm find d 2 N such that ad ⌘ 1 mod f (M).
(c) Alice has agreed with Bob that he will encrypt her exam mark using her
public key. She receives 51 from Bob. What is her exam mark?
(d) What are some problems with the scheme as described? [Hint: even if p and q
were far larger, there is a simple way for an attacker who observes Bob’s
encrypted message to deduce Alice’s exam mark.]
3.8 Suppose that M is the product of two distinct primes p and q. Show how to
find p and q given M and f (M).
3.9 (This exercise needs some basic group theory.) Let M = pq where p and q are
distinct primes. Let U = x 2 {0, 1, . . . , M 1} : x is coprime to p and q .
(a) Show that if x, y 2 U then xy mod M is also in U.
(b) Let x 2 U. Define fx : {0, 1, . . . , M 1} ! {0, 1, . . . , M 1} by fx (y) = xy
mod M. Show that fx is injective.
(c) Deduce from (b) that if x 2 U then there exists a unique x0 2 U such that
xx0 ⌘ 1 mod M.
(d) Hence show that U is a group under multiplication modulo M. What is the
order of U?
(e) Show that if a is coprime to f (M) then the function x 7! xa from U to itself is
invertible and find the inverse function. Can you compute the inverse function
knowing only a and M, but not f (M) or p or q?
3.10 The displayed equation in the proof of Corollary 3.4.6 implies that
p(M) log log M log M M log 2
 log log M + 1 + log log M.
M M M
(a) Prove that if c 2 R and c > 0 then ye cy ! 0 as y ! •.
56 Principle of Inclusion and Exclusion

(b) Using (a) and the crude inequality log log M  log M, or otherwise, show that
p(M)/M  2/ log log M for all sufficiently large M.
3.11 As in the proof of Theorem 3.4.5, let p1 , p2 , . . . , pn be the first n prime num-
bers.
(a) By the formula for the sum of a geometric progression,
⇣ 1⌘ 1 1 1
1 = 1+ + 2 +··· .
pi pi pi
Using that each natural number has a unique prime factorization, deduce that
n ⇣
1⌘ 1 pn
1
’ 1 pi  x.
i=1 x=1
R
S dt
(b) Show that ÂSx=1 1x 1 t = log S for any S 2 N.
(c) Deduce from (a) and (b) that there are infinitely many primes.
3.12 The Riemann z function is defined for z 2 C such that Re z > 1 by z (z) =
• z
m=1 1/m .
(a) Use |mz | = mRe z to show that the series converges absolutely when Re z > 1.
What happens when z = 1?
(b) By adapting the argument in Exercise 3.11(a), show that
• ⇣
1⌘ 1
z (z) = ’ 1
n=1 pzi
for z 2 C such that Re z > 1.
(c) For z 2 C such that Re z > 0, let h(z) = • m=1 ( 1)
m 1/mz . Show that if

Re z > 1 then
h(z)
z (z) = .
1 2 (z 1)
(d) Prove that h(z) converges if z 2 R and z > 0. (?) Prove that h(z) converges
whenever Re z > 0.
(The Prime Number Theorem was first proved in 1896, independently by
Hadamard and de la Vallée Poussin. Both proofs used complex analysis and
the Riemann z function extended, as the stronger result in (d) shows is possi-
ble, to the domain {z : Re z > 0, z 6= 1}. The Riemann Hypothesis, one of the
Clay Mathematics Institute’s million dollar open problems in mathematics,
states that if z (z) = 0 and Re z > 0 then z = 12 + it for some t 2 R.)
3.13 Given M 2 N, let p2 (M) be the number of numbers in {1, 2, . . . , M} that are
square-free; that is, they are not divisible by the square of any prime.
Exercises 57
p
(a) Let p1 , p2 , . . . , pn be the primes less than or equal to M. By adapting the
argument used to estimate p(M), show that
p2 (M) n
1⌘ 1

?
1 2
p .
M i=1 pi M
where ? denotes that all terms ±1/d 2 with d > M that arise when expanding
the product arepto be ignored. (This technicality is necessary to get the good
error bound 1/ M.)
(b) Deduce from (a) and Exercise 3.12(a) that
p2 (M)
lim = z (2).
M!• M
(c) Why does this sieve give a more precise result than the sieve used in Theo-
rem 3.4.5 to estimate p(M)?
2
(It is known that z (2) = p6 : you will easily find proofs using techniques
including real variable integration, contour integration, and Fourier series if
you search on the web.)
3.14 This question builds on the proof of the Principle of Inclusion and Exclusion
(Theorem 3.1.3). For r 2 {0, 1, . . . , n}, define gr : W ! Z by
(
( 1)|I| if x 2 AI
gr (x) = Â
I✓{1,2,...,n} 0 otherwise.
|I|r

(a) Let cr = Âx2W gr (x). Show that


cr = Â ( 1)|I| |AI |
I✓{1,2,...,n}
|I|r

is the sum in Principle of Inclusion and Exclusion, restricted to those indexing


sets of size at most r.
(b) Let x 2 W. Suppose that x 2 A j if and only if j 2 J where J ✓ {1, 2, . . . , n}.
Show that gr (x) = Ârk=0 ( 1)k |J| r |J| 1 . De-
k and hence that gr (x) = ( 1) r
duce that ✓ ◆
r mx 1
cr = Â ( 1)
x2W r

where mx = j 2 {1, 2, . . . , n} : x 2 A j .
(c) By taking r = n in (b) deduce Theorem 3.1.3.
(d) Prove that if r is even then |A1 [ A2 [ . . . [ An |  cr .
(e) Prove that if r is odd then cr  |A1 [ A2 [ . . . [ An |.
(f) Prove that if r (n 1)/2 then cr  cr+2 if r is odd and cr+2  cr if r is even.
58 Principle of Inclusion and Exclusion

(g) (?) In fact the bound on r in (f) can be slightly improved. Find the strongest
possible improvement.
(Thus the cr alternately under- and over-estimate the size of |A1 [ A2 [ . . . [ An |,
and the approximations get strictly better once r (n 1)/2.)
3.15 Again this question can be answered by adapting the proof of the Principle
of Inclusion and Exclusion in Theorem 3.1.3.
(a) Show there exist coefficients e1 , e2 , . . . , en 2 N such that the number of ele-
ments of W in exactly one of the sets A1 , A2 , . . . , An is
n
Â( 1)k 1 ek  |AI |.
k=1 I✓{1,2,...,n}
|I|=k

[Hint: suppose, as in (a) in the previous exercise, that the sum is truncated
to the terms for k = 1, . . . , r. By analogy with (b) in the previous exercise, the
formula should then be correct for elements lying in at most r of the sets A1 ,
A2 , . . . , An .]
(b) Prove a generalization of the Principle of Inclusion and Exclusion counting
the number of elements of W that lie in exactly t of the sets A1 , A2 , . . . , An ,
for each t 2 N0 .
(c) Fix t 2 {0, 1, . . . , n}. Check your result in (b) by counting the number of per-
mutations of {1, 2, . . . , n} that have exactly t fixed points. (See Exercise 1.10
for the answer.)
3.16 (?) Exercises 3.14 and 3.15 strengthen the Principle of Inclusion and Exclu-
sion in two different ways. Prove a still stronger version that implies both.
3.17 This question gives an alternative proof of the Principle of Inclusion and Ex-
clusion (Theorem 3.1.3). Fix a universe set W. For each X ✓ W, define a func-
tion 1X : W ! {0, 1} by
(
1 if x 2 X
1X (x) =
0 if x 62 X.

We say that 1X is the indicator function of X.


(a) Let X ✓ W. What is Âx2W 1X (x)?
(b) Show that if B, C ✓ W then 1B \C (x) = 1B (x)1C (x) for all x 2 W and so 1B\C =
1B 1C .
(c) Let A1 , A2 , . . . , An be subsets of W. Show that

1A1 [A2 [···[An = (1W 1A1 )(1W 1A2 ) . . . (1W 1An ).


3.4 Prime numbers and Euler’s f function 59

(d) By multiplying out the right-hand side in (c) and using (b), show that
1A1 [A2 [···[An = Â ( 1)|I| 1AI
I✓{1,2,...,n}

where AI has its usual definition.


(e) Prove Theorem 3.1.3 by summing the previous equation over all x 2 W.
3.18 There are many binomial coefficient identities that can be proved by a well-
chosen application of the Principle of Inclusion and Exclusion.
(a) Prove that if m, n 2 N0 then
n ✓ ◆✓ ◆ ✓ ◆
k n m+n k m
 ( 1)
k r
=
r n
.
k=0

[Hint: count the r-subsets of {1, . . . , m + n} not meeting {m + 1, . . . , m + n}.


An alternative proof uses Exercise 2.21(a) and (e).]
(b) Prove that if n, s 2 N0 then
n ✓ ◆✓ ◆ ✓ ◆
k n 2n 2k n s n
 ( 1) k n s 2k = 2 s
k=0

and hence find Ânk=0 ( 1)k nk n+s


2k
.
(c) (American Mathematical Monthly Problem 11862). Prove that if m, n 2 N0
then ✓ ◆✓ ◆
n
k n (n k)m n
 ( 1) k n+1
= (mn+1 mn ).
2
k=0

3.19 By applying the Principle of Inclusion and Exclusion to the set of functions
f : {1, 2, . . . , n} ! {1, 2, . . . , n} such that f has no fixed points, prove Ryser’s
formula for the number of derangements of {1, 2, . . . , n}:
n ✓ ◆
k n
dn = Â ( 1) (n k 1)k (n k)n k .
k=0 k
[Hint: Exercise 3.5 is related.] How does this use of the Principle of Inclusion
and Exclusion compare with its use in §3.2?
4
Rook Polynomials

4.1 Introduction to rook polynomials


The derangements problem asks us to count permutations with no fixed points.
Many other combinatorial problems can be interpreted as counting permutations
of a special type. In this chapter we shall see a unified way to solve these problems.

Definition 4.1.1 A board is a subset of the squares of an n ⇥ n grid. Given a


board B, let rk (B) be the number of ways to place k rooks on B, so that no two rooks
are in the same row or column. Such placements are said to be non-attacking. The
rook polynomial of B is defined to be

fB (z) = r0 (B) + r1 (B)z + r2 (B)z2 + · · · + rn (B)zn .

For example, the rook polynomials of the four boards shown below

, , ,

are 1 + 3z + z2 , 1 + 4z + 2z2 , 1 + 4z + 3z2 and 1 + 5z + 6z2 + z3 . Writing B for the


final board, the six rook placements counted by rB (2) are

R R R R R
R , R , , R , , R .
R R R

3 2 The diagram in the margin summarizes the enumeration above by counting num-
1 0 bers of placements according to the position of the top-left rook.
0
Exercise 4.1.2 Let B be a board. Show that r1 (B) is the number of squares in B.
What is r0 (B)?

Exercise 4.1.3 Show that the rook polynomial of the six-square board in the mar-
gin is 1 + 6z + 9z2 + 2z3 .
4.1 Introduction to rook polynomials 61

Exercise 4.1.4 Find the rook polynomial of the seven-square board in the margin.
[Hint: the non-attacking rook placements not having a rook in the top right are
counted by the previous exercise.]
Example 4.1.5 After the recent cutbacks, only four professor remain at the Uni-
versity of Erewhon. The basic course 1 can be lectured by Prof. W, Prof. X, or
Prof. Z, the trickier course 2 only by Prof. X, course 3 by Prof. Y or Prof. Z
and course 4 by Prof. W or Prof. Z. We model this timetabling problem using
the board B shown below, in which there is a square in row i and column P if and
only if Prof. P can lecture course i.
W X Y Z
1
2
3
4

Assignments of professors to courses, so that each professor lectures at most one


course and no course is lectured twice, are in bijection with non-attacking rook
placements on B. Thus rB (k) is the number of ways in which exactly k courses can
be lectured. For instance rB (4) = 2: putting four rooks down the diagonal defines
one of the two possible assignments. We find the rook polynomial fB (z) and hence
rB (2) and rB (3) using a general method in Example 4.2.3.

Example 4.1.6 Let n 2 N. Given a permutation s : {1, 2, . . . , n} ! {1, 2, . . . , n}


we may define a non-attacking placement of n rooks on the n ⇥ n grid by putting a
rook on the square (i, j) in row i and column j if and only if s (i) = j. Clearly each
row has one rook. Since
• s is injective, no two rooks lie in the same column;
• s is surjective, each column has a rook.
Conversely, any non-attacking placement of n rooks corresponds to a permutation.
Taking n = 5, it follows that derangements of {1, 2, 3, 4, 5} are in bijection with
non-attacking placements of 5 rooks on the board below; the left rook placement
corresponds to the derangement s such that s (1) = 2, s (2) = 3, s (3) = 4, s (4) =
5 and s (5) = 1.

R R
R R
R R
R R
R R
62 Rook Polynomials

Going back, the right rook placement corresponds to the derangement t such that
t(1) = 2, t(2) = 3, t(3) = 5, t(4) = 1 and t(5) = 4. We use rook polynomials to
calculate derangement numbers in §4.3 below.

4.2 Splitting boards


A special case of the next lemma was indicated by the hint to Exercise 4.1.4.
Lemma 4.2.1 Let B be a board contained in the n ⇥ n grid and let s be a square
in B. Let D be the board obtained from B by deleting s and let E be the board
obtained from B by deleting the entire row and column containing s. Then
fB (z) = fD (z) + z fE (z).
Proof For each k 2 N0 there is an obvious bijection
nnon-attacking placements of ko nnon-attacking placementso
! .
rooks on B with no rook on s of k rooks on D
Suppose there are k rooks on B including a rook on s. No other rook lies in the
row and column containing s. Deleting the row and column containing s therefore
defines a bijection
nnon-attacking placements of ko nnon-attacking placementso
! .
rooks on B with a rook on s of k 1 rooks on E
Combining these bijections shows that rk (B) = rk (D) + rk 1 (E) for k 2 N. By Ex-
ercise 4.1.2, r0 (B) = r0 (D) = 1. Since at most n non-attacking rooks can be placed
on B, and at most n 1 on E, we have
n
fB (z) = r0 (B) + Â rk (D) + rk 1 (E) zk
k=1
n n 1
= r0 (D) + Â rk (D)zk + Â r` (E)z`+1
k=1 `=0
= fD (z) + z fE (z)
as required.
To illustrate another very helpful result, consider the single large board split
between the left and right margin of this page. A rook in the left subboard can
never attack attack a rook in the right subboard. Therefore we may treat these two
subboards independently. The next lemma makes this precise. In the proof, we
take one final chance to emphasise the use of the basic counting principles from
Chapter 1.
4.2 Splitting boards 63

Lemma 4.2.2 Let B be a board. Suppose that B can be partitioned into sub-
boards C and C0 so that no square in C lies in the same row or column as a square
of C0 . Then rk (B) = Âk`=0 r` (C)rk ` (C0 ) for each k 2 N and

fB (z) = fC (z) fC0 (z).

Proof Let k 2 N0 . Given ` 2 {0, 1, . . . , k} we may place k rooks on B by putting `


non-attacking rooks on C and k ` non-attacking rooks on C0 . Since rooks on C
never attack rooks on C0 , any such placement is non-attacking, and every non-
attacking placement of k rooks on B is obtained in this way.
By BCP0, that sets in bijection have the same size, and BCP1, the basic count-
ing principle on multiplying choices, there are exactly rk (C)rk ` (C0 ) non-attacking
placements with ` rooks on C. Hence, by BCP2, the basic counting principle on
adding choices,
k
rk (B) = Â r` (C)rk ` (C
0
),
`=0

as required. The right-hand side is the coefficient of zk when we multiply fC (z) =


Ân`=0 r` (C)z` and fC0 (z) = Ânm=0 rm (C0 )zm by adding r` (C)z` rm (C0 )zm for all ` and
m. (The relevant products for the coefficient of zk are those with ` + m = k.) This
holds for each k 2 N0 , hence fB (z) = fC (z) fC0 (z).

We will see later that Lemma 4.2.2 is a special case of Theorem 8.0.1 on products
of generating functions.
We now show how the two previous lemmas are used in practice.
Example 4.2.3 Let B be the board in Example 4.1.5. Figure 4.2 overleaf shows
the four boards DD, DE, ED and EE given by applying Lemma 4.2.1 first to the
square s, then to the square u. By this lemma,

fB (z) = fD (z) + z fE (z) = fDD (z) + z fDE (z) + z fED (z) + z fEE (z) .

To calculate the rook polynomials on the right-hand side, we use Lemma 4.2.2:

fDD (z) = f (z) f (z) = (1 + 4z + 2z2 )(1 + 2z) = 1 + 6z + 10z2 + 4z3

fDE (z) = f (z) f (z) = (1 + 3z + z2 )(1 + z) = 1 + 4z + 4z2 + z3

fED (z) = f (z) f (z) = (1 + 3z + z2 )(1 + z) = 1 + 4z + 4z2 + z3

Clearly fEE (z) = 1 + 2z. Remembering to include the powers of z, we get


fB (z) = (1 + 6z + 10z2 + 4z3 ) + z(1 + 4z + 4z2 + z3 )
+ z(1 + 4z + 4z2 + z3 ) + z2 (1 + 2z) = 1 + 8z + 19z2 + 14z3 + 2z4 .
64 Rook Polynomials

In particular, rB (2) = 19 and rB (3) = 14. The squares s and u were chosen so that
Lemma 4.2.2 could be applied after two steps. Other choices are also sensible, and
are, of course, permitted.

u u
D E

DD DE ED EE

Figure 4.1 Lemma 4.2.1 applied to the board B in Examples 4.1.5 and 4.2.3, first
to the square s in position (3, 3), then the square u in position (4, 1).

To give another example, if B is the board split across the previous page and C
and C0 are the left and right subboards then, by symmetry, fC (z) = fC0 (z). Hence,
by Lemma 4.2.2, fB (z) = fC (z)2 . The simple algorithm based on Lemma 4.2.1
suggested in Exercise 4.9 takes about a minute to compute fC (z), and reveals that
fB (z) = (1 + 63z + 1544z2 + 18984z3 + · · · + 270000z8 + 23760z9 )2 .
By contrast, computing fB (z) directly by this algorithm, even on a supercomputer,
would not finish within the lifetime of our universe.

4.3 Complementary boards and the Problème des Ménages


Given a board B contained in the n ⇥ n grid, let B denote the complementary board
consisting of all the squares in the grid not in B. For instance the board B in Exam-
ple 4.1.4 and its complement B in the 4 ⇥ 4 grid are below.
4.3 Complementary boards and the Problème des Ménages 65

In this section we explore the surprisingly close connection between the non-
attacking rook placements on B and B.

Placements on the complement


Let W be the set of all n! non-attacking placements of n rooks on the n ⇥ n grid.
Let B be a board contained in W. We shall use the Principle of Inclusion and Ex-
clusion to express rn (B) in terms of r0 (B), r1 (B), . . . , rn (B).
Exercise 4.3.1 For each i 2 {1, 2, . . . , n}, let Ai be those placements in W we do
not want to count because of a reason to do with row i (and only row i). How
should Ai be defined?
The answer is that Ai is the placements in which the rook on row i is on B. More
generally, if I ✓ {1, 2, . . . , n}, then AI is those placements in which the rooks on the
rows in I are in B. We use the following lemma to find the sum over the sizes |AI |
in the right-hand side of the Principle of Inclusion and Exclusion.

Lemma 4.3.2 Let k 2 {0, 1, . . . , n}. Then

 |AI | = rk (B)(n k)!.


I✓{1,2,...,n}
|I|=k

Proof Given a rook placement in AI , colouring the rooks in the rows in I red
gives a rook placement with k black rooks on B and n k white rooks on either
B or B, such that all n rooks are non-attacking. Let Ck be the set of such coloured
rook placements. Going back, given a placement in C , the k black rooks identify
an indexing set I. Hence the left-hand side is |Ck |.
We may construct a rook-placement in Ck by putting k non-attacking black rooks
on B, in rk (B) ways, and a further n k non-attacking white rooks on the n k rows
and columns not yet used, in (n k)! ways. Hence |Ck | is the right-hand side.

This proof is more subtle than it might seem. For instance, except when k = 0,
S
the set Ck (which consists of coloured placements) is not I✓{1,2,...,n},|I|=k AI . As
ever, seeing how the proof works by trying it out on a particular example is helpful:
one relevant to derangements is suggested in Exercise 4.6 below. See Exercise 4.12
for another application of the colouring idea.
66 Rook Polynomials

Corollary 4.3.3 Let B be a board contained in an n ⇥ n grid. Then


n
rn (B) = Â( 1)k rk (B)(n k)!.
k=0

Proof By the Principle of Inclusion and Exclusion,


n n
rn (B) =  ( 1)|I| |AI | =  ( 1)k  |AI | = Â( 1)k rk (B)(n k)!
I✓{1,2,...,n} k=0 I✓{1,2,...,n} k=0
|I|=k

where the final equality uses Lemma 4.3.2.

Derangements
Fix n 2 N with n 2 and let B be the board of all diagonal squares in the n ⇥ n
grid, as shown by the shaded squares in the margin when n = 3. As seen in Exam-
ple 4.1.6, derangements of {1, 2, . . . , n} are in bijection with non-attacking place-
ments of n rooks on B. To apply Corollary 4.3.3 we need r0 (B), r1 (B), . . . , rn (B).
Note that any placement on B is non-attacking. Since there are nk to choose k
rows of B on which to put rooks, we have rk (B) = nk for each k. Hence, by Corol-
lary 4.3.3,
n ✓ ◆ n
k n n!
rn (B) = Â ( 1) (n k)! = Â ( 1)k
k=0 k k=0 k!
where the final equality uses Lemma 2.1.4. This is our usual formula for dn .

Problème des Ménages


Let n 2 N with n 2. How many ways can n heterosexual couples be seated around
a circular table with 2n numbered seats so that men and women alternate, and no-
one sits next to his or her partner? For example if n = 4 then labelling the people
W1 , M1 ,W2 , M2 ,W3 , M3 ,W4 , M4 , two possible seating placements are shown below.
M4 M1
W2 3 W1 W4 3 W2
4 2 4 2

M1 5 1 M3 M3 5 1 M4
6 8 6 8
W3 7 W4 W1 7 W3
M2 M2

Observe that the women are either all sat in odd-numbered seats or all sat in
even-numbered seats. Suppose, as in the both examples above, the women are in
4.3 Complementary boards and the Problème des Ménages 67

even seats. Define a permutation s : {1, . . . , n} ! {1, . . . , n} so that woman Ws (i)


sits in seat 2i. The men can now choose their seats in any way such that Ms (i) is
not in seat 2i 1 or seat 2i + 1. (When i = n, regard seat 2n + 1 as seat 1.) This puts
the problem in the same setting as Examples 4.1.5 and 4.1.6.
For instance, if women sit as in the second example above, then the permutation
is s (1) = 2, s (2) = 4, s (3) = 1, s (4) = 3 and ways to seat the men correspond
to placements of 4 non-attacking rooks on the board below.
1 3 5 7

M2
M4
M1
M3

In the first example, the board is the same, but since the permutation s is now
s (1) = 1, s (2) = 2, s (3) = 3, s (4) = 4, the row labels change to M1 , M2 , M3 , M4 .
The rook placements for the two examples above are shown below.
1 3 5 7 1 3 5 7

M1 R M2 R
M2 R M4 R
M3 R M1 R
M4 R M3 R
In general we label row i of the n ⇥ n grid by man Ms (i) . Then ways to seat the n
men correspond to placements of n non-attacking rooks on the complement of the
board Bn obtained by taking the staircase board S2n 1 with 2n 1 squares in the
sequence below and extending it by a square in the bottom-left corner.

, , , ,....

For example, B4 is the board of shaded squares seen three times above. It follows
from Lemma 4.2.1, taking the distinguished square to be one in the top-right corner,
that the rook polynomial of Bn is fS2n 1 (z) + x fS2(n 1) 1 (z).

Exercise 4.3.4 Using the formula fSm (z) = Ânk=0 m kk+1 , which you are asked to
discover in Exercise 4.5, prove that
n ✓ ◆
2n k 2n
fBn (z) = Â .
k=0 k 2n k
68 Rook Polynomials

Therefore, by Corollary 4.3.3, the number of ways to place the men is the ménage
number un defined by
n ✓ ◆
k 2n k 2n
un = Â ( 1) (n k)!.
k=0 k 2n k

For example fB4 (z) = 1 + 8z + 20z2 + 16z3 + 2z4 and so u4 = 4! 8 ⇥ 3! + 20 ⇥


2! 16 ⇥ 1! + 2 ⇥ 0! = 2, as can easily be seen directly. The table below shows
the small values of un ; the reason for defining u0 = 2 and u1 = 1 is seen after
Proposition 4.3.6 below.

n 0 1 2 3 4 5 6 7 8
un 2 1 0 1 2 13 80 579 4738

To count all the seating arrangements we multiply un by n! counting the n! per-


mutations s and by 2, since women might also have sat in the even-numbered
seats, getting 2n!un .

Discordant permutations and les ménages aux tables multiples


We end with a generalization of the Probème des Ménages. Given permutation s ,
t : {1, 2, . . . , n} ! {1, 2, . . . , n}, we say that s and t are discordant if s (i) 6= t(i)
for each i 2 {1, 2, . . . , n}. For example, t is discordant with the identity permutation
if and only if t is a derangement. For n 2, permutations discordant with both the
identity permutation, and the permutation s defined by
s (1) = 2, s (2) = 3, . . . , s (n) = 1,
correspond to placements of n rooks on the complement of the board Bn . Therefore
the number of such permutations is the ménage number un tabulated above.
For n 2 N with n 2 let gn (z) = fBn (z).
Example 4.3.5 Let s : {1, 2, 3, 4, 5, 6, 7} ! {1, 2, 3, 4, 5, 6, 7} be the permutation
defined by s (1) = 2, s (2) = 3, s (3) = 4, s (4) = 5, s (5) = 1, s (6) = 7, s (7) = 6.
Let B be the board of shaded squares shown in the margin, defined so that permu-
tations t discordant with both the identity permutation and s are counted by r7 (B).
By Exercise 4.3.4, g5 (z) = 1 + 10z + 35z2 + 50z3 + 25z4 + 2z5 . By splitting up the
shaded squares using Lemma 4.2.1 we get
fB (z) = g5 (z)g2 (z) = (1 + 10z + 35z2 + 50z3 + 25z4 + 2z5 )(1 + 4z + 2z2 )
= 1 + 14z + 77z2 + 210z3 + 295z4 + 202z5 + 58z6 + 4z7 .
4.3 Complementary boards and the Problème des Ménages 69

We could now apply Corollary 4.3.3 to find r7 (B). Instead, we motivate a more
general result by observing that g7 (z) = 1 + 14z + 77z2 + 210z3 + 294z4 + 196z5 +
49z6 + 2z7 . Since g3 (z) = 1 + 6z + 9z2 + 2z3 , it follows that

g5 (z)g2 (z) = g7 (z) + z4 g3 (z).

Hence rk (B) = rk (B7 ) + rk 4 (B3 ). Now using Corollary 4.3.3, we get


7
r7 (B) = Â rk (B7 )+rk 4 (B3 ( 1)k (7 k)!
k=0 7 3
= Â rk (B7 )( 1)k (7 k)! + Â r` (B3 )( 1)` (3 `)!.
k=0 `=0

(In the second summand, we replaced k 4 with `.) By two more applications of
Corollary 4.3.3, this is u7 + u3 , or 579 + 1 = 580.

The decomposition g5 (z)g2 (z) = g7 (z)+z4 g3 (z) is a special case of a remarkable


general rule. If you would like to discover it for yourself, calculate gr (z)gs (z)
gr+s (z) for other small r and s. The results motivate defining g0 (z) = 2 and g1 (z) =
1 + 2z.

Proposition 4.3.6 Let `, m 2 N0 with ` m. Then g` (z)gm (z) = g`+m (z)+z2m g` m (z).

Proposition 4.3.6 is proved in Exercise 4.14. Using the proposition one can gen-
eralize Example 4.3.5 to arbitrary permutations s : see Exercise 4.16.
For example, to show why we defined u1 = 1, suppose that s has cycles of
lengths m + 1 and m. (Cycles are formally defined in §9.2: the permutation s in
Example 4.3.5 has cycles of lengths 5 and 2.) Defining B by analogy with Exam-
ple 4.3.5, so if m = 3 then B is as shown in the margin, Proposition 4.3.6 implies
that

fB (z) = gm+1 (z)gm (z) = g2m+1 (x) + z2m g1 (x) = g2m+1 (z) + z2m (1 + 2z).

By Corollary 4.3.3, the number of permutations discordant with both the identity
permutation and s is
2m 1
 rk (B2m+1 )( 1)k (2m + 1 k)! + r2m (B2m+1 ) + 1 1! r2m+1 (B2m+1 ) + 2 0!
k=0
2m+1
= Â rk (B)( 1)k (2m + 1 k)! + 1 2 = u2m+1 1 = u2m+1 + u1 .
k=0

The useful linearity property in Corollary 4.3.3 seen in this calculation general-
izes as follows. In practice the signs are often always +1: see Exercise 4.15(d).
70 Rook Polynomials

Exercise 4.3.7 Suppose that B is a board in the n ⇥ n grid such that fB (z) =
Ân`=0 a` zn ` g` . Show that rn (B) = Ân`=0 ( 1)n ` a` u` .
As motivation for our final result, fix m 2 N and observe that by repeatedly multi-
plying by gm using Proposition 4.3.6, we have g2m = g2m +2z2m , g3m = g3m +3z2m gm ,
g4m = g4m + 4z2m g2m + 6z4m and g5m = g5m + 5z3m g3m + 10z4m gm . The coefficients
should seem familiar.
Proposition 4.3.8 Fix m 2 N and c 2 N0 . Suppose that there are c circular tables,
each seating 2m diners, and that there are mc couples who must be seated obeying
the restrictions of the Problème des Ménages. The number of seating arrangements
is ✓ ◆ ✓ ◆
c c
2 (mc)! Â
c
um(c 2k) +
0k<c/2
k c/2

where the final summand is regarded as 0 if c is odd.


Proof As before, we begin by letting the women choose their seats. Seating ar-
rangements for the men are then in bijection with placements of mc rooks on
the board B formed from c diagonal copies of the board Bm . By Lemma 4.2.1,
fB (z) = gm (z)c . Suppose inductively, as suggested by the calculations above, that
✓ ◆ ✓ ◆
c 2mk c
gm (z) = Â
c
z gm(c 2k) (z) + zmc
0k<c/2
k c/2

where again the final summand is regarded as 0 if c is odd. If c is even, with say
c = 2s, then multiplying the equation above by gm using Proposition 4.3.6, we get
s 1✓ ◆ ✓ ◆
2s 2mk 2s
gm (z)2s+1
=Â z 2m
gm(2s 2k+1) (z) + z gm(2s 2k 1) (z) + gm z2ms
k=0 k s
s 1 ✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆
2s 2s 2s 2s
=Â + 2mk
z gm(2s+1 2k) (z) + + gm (z)z2ms
k=0 k k 1 s 1 s
s ✓ ◆
2s + 1 2mk
=Â z gm(2s+1 2k) (z)
k=0 k
where the final step uses the Fundamental Recurrence (Lemma 2.1.7). The induc-
tive step is similar if c is odd. Hence, by Exercise 4.3.7, the number of ways to seat
the men is ✓ ◆ ✓ ◆
c c
 k m(c 2k) c/2 .
u +
0k<c/2

To count all seating arrangements we must multiply this by 2c , counting the choices
of whether women are in even or odd seats at each table, and then by (mc)!, count-
ing the ways the women may choose seats of the chosen parity at each table.
Exercises 71

An alternative proof of the formula for gcm direct from the Binomial Theorem is
given in Exercise 4.15(e). We apply the results in this section to find the number
of permutations discordant with any two given permutations, and hence to count
3 ⇥ n Latin rectangles, in §9.4.

Exercises
The core exercises are 4.1 to 4.7.

4.1 Find the rook polynomials of the boards , , , .

✓ ◆✓ ◆
n
m n k
4.2 Show that the rook polynomial of the m ⇥ n grid is  k! z.
k=0 k k

4.3 Let T be the set of all derangements s of {1, 2, 3, 4, 5} such that


• s (i) 6= i + 1 if 1  i  4,
• s (i) 6= i 1 if 2  i  5.

(a) Explain why |T | is the number of ways to place 5 non-attacking rooks on the
board B formed by the unshaded squares below. (Include in your answer an
explicit example of how a permutation corresponds to a rook placement.)

(b) Find the rook polynomial of B, and hence find |T |. [Hint: consider the four
possibilities for the starred squares. For example, if both are occupied, the
contribution to the rook polynomial is z2 f1 (z) f2 (z) where fn (z) is the rook
polynomial of the n ⇥ n square board. You could also use Lemma 4.2.1.]
(c) Use Corollary 4.3.3 to find the number of ways to place 5 non-attacking rooks
on the shaded squares.
(d) (?) By adapting the argument used to prove Corollary 4.3.3, find the number
of ways to place 4 non-attacking rooks on the shaded squares. (See Exer-
cise 4.13 for a generalization.)
72 Rook Polynomials

4.4
(a) Show that permuting the rows or columns of a board does not change its rook
polynomial.
(b) Let B be the board in Example 4.1.5. Show that B and its complement B in
the 4 ⇥ 4 grid have the same rook polynomial.
4.5 Let Sm denote the staircase board with exactly m squares in the sequence
shown below.

, , , , ,....

(a) Calculate the rook polynomials of Sm for m 2 {1, 2, 3, 4, 5}.


(b) Find fS6 (z) using Lemma 4.2.1.
(c) Conjecture a formula for fSm . [Hint: look at the southwest to northeast diag-
onals on the Pascal’s Triangle on page 23. The answer is revealed in §4.3.]
(d) Prove your conjecture. [Hint: while you could generalize (b), there is also a
very short proof using Exercise 2.4.]

4.6 Let n = 3 and let B be the board formed by the shaded squares below.

Draw the rook placements lying in each of the sets A? , A{1} , A{2} , A{3} ,
A{1,2} , A{1,3} , A{2,3} , A{1,2,3} in the proof of Lemma 4.3.2 and hence find
the set Ck of coloured rook placements for each k 2 {0, 1, 2, 3}. Check that it
has the expected size.
For instance you should find that C1 has the six coloured placements

r r R R R R
R R r r R R
R R R R r r

and correspondingly |C1 | = 6 agreeing with |A{1} | + |A{2} | + |A{3} | = 2 + 2 +


2 = 6 and r1 (B)(3 1)! = 3 ⇥ 2! = 6.
Exercises 73

4.7 A Latin rectangle of order n is a rectangle in which every row contains each
of the numbers 1, 2, . . . , n exactly once and the entries in each column are
distinct. Let L be the Latin rectangle shown below

1 2 3 4 5 .
2 3 1 5 4

Let B be the board contained in the 5 ⇥ 5 grid with a square in position (i, j)
if and only if the number i can be put in row 3 and column j of L.
(a) Find the rook polynomial of B and hence find r5 (B).
(b) Explain why r5 (B) is the number of ways to extend L to a 3 ⇥ n Latin rectan-
gle.
(c) Use Proposition 4.3.6 and Exercise 4.3.7 to express r5 (B) as a sum of the
ménage numbers un .

4.8 Find the number of permutations s of {1, 2, 3, 4, 5, 6} such that s (m) 6= m for
any even number m.

4.9 Rook polynomials can be computed recursively by repeated applications of


Lemma 4.2.1.

(a) Representing boards as list of squares, implement this algorithm in the pro-
gramming language of your choice, choosing as the square s the first square
in the list. (One possibility is M ATHEMATICA: it has polynomial addition and
multiplication built-in and good support for lists and recursion.)
(b) Refine the algorithm by instead choosing the square on which a rook attacks
the maximum number of other squares.
(c) Refine the algorithm further by splitting boards using Lemma 4.2.2.
(d) Which, if any, of the algorithms in (a), (b), (c) can compute the rook poly-
nomial of the ‘coffee’ board on page 62 in a short time? (A M ATHEMATICA
notebook including the squares in this board may be downloaded from the
author’s website, see page 4.)

4.10 Given a board B contained in the n ⇥ n grid. Let M(B) be the matrix with
a 1 in each position where B has a square, and 0 in all other positions. Let
H(B) be the bipartite graph with adjacency matrix M(B). For example, if B
is the board in Example 4.1.5 with rows labelled by courses and columns by
74 Rook Polynomials

professors, then B, M(B) and H(B) are as shown below.

W X Y Z
0 1
1 1 1 1 0 W X Y Z
• • • •
2 B0 1 0 0C
!B
@0
C !
3 0 1 1A
• • • •
4 1 0 0 1 1 2 3 4

(The thick edges in H(B) are used in (b) below.)


(a) The permanent of a matrix is defined like the determinant, but omitting the
signs. Thus if M is an n⇥n matrix then per M = Âs ’ni=1 Mis (i) where the sum
is over all permutations of {1, . . . , n}. Show that per M(B) is the coefficient
of zn in the rook polynomial fB (z).
(b) A matching in a bipartite graph is a set of edges such that every vertex is
in exactly one edge; one of the two matchings in the graph H(B) above is
shown by thick edges above. Show that per M(B) is the number of matchings
in H(B).
(c) (For those who know a little about computational complexity.) Show that
computing the coefficient of zn in the rook polynomial of a board contained
in the n ⇥ n grid is in the complexity class #P. [Hint: an important early
result of Valiant is that computing the permanent of a matrix with 0, 1 entries
is in this class.] How does this compare with the difficulty of deciding if the
coefficient is non-zero?
4.11 The Lah Number nk may be defined as the number of ways to put n k
non-attacking rooks on the (n 1) ⇥ n grid.
(a) Show that nk = n! n 1
k! k 1 .
(b) Show that k! nk is the number of ways to put n labelled balls into k labelled
tubes so that each tube is non-empty. For example, 1! n1 = n! for all n and 4
of the 12 placements counted by 2! 32 are shown below.

2 1 3 1

1 3 2 3 1 2 3 2
1 2 1 2 1 2 1 2
[Hint: Exercise 2.5 is relevant; you will need to swap the roles of n and k.]
(c) Deduce that nk is the number of ways to put n labelled balls into k unlabelled
tubes so that each tube is non-empty. (This is the usual definition of the Lah
Numbers.)
(d) (?) Give a bijective proof of (c).
Exercises 75

4.12 Fix n 2 N and let B be a board contained in the n ⇥ n grid. The hit number
ht (B) is the number of ways to put n non-attacking rooks on the n ⇥ n grid
so that exactly t rooks are on B. For example, if n = 4 and B is the board
of shaded squares in the margin then h0 (B) counts the 9 derangements and
h1 (B) = 8, h2 (B) = 6, h3 (B) = 0 and h4 (B) = 1.
(a) Show that
n ✓ ◆
t
 ht (B) k = rk (B)(n k)!.
t=k

[Hint: interpret each side as the number of ways to put k black rooks on B and
n k white rooks anywhere on the grid, so that all n rooks are non-attacking.]
n
(b) Deduce that Ât=0 ht (B)(1 + z)t = Ânk=0 rk (B)(n k)!zk and hence that
n n
 ht (B)wt =  rk (B)(n k)!(w 1)k .
t=0 k=0

(c) By substituting w = 0 give a new proof of Corollary 4.3.3.


(d) Let an (t) be the number of permutations of {1, 2, . . . , n} with precisely t fixed
points. Use the previous question with the board in §4.3 to prove that
n! ⇣ 1 1 ( 1)n t ⌘
an (t) = 1 + ···+
t! 1! 2! (n t)!
as seen in Exercise 1.10.
(e) Find a formula for the number of seating arrangements in the Problème des
Ménages if exactly t couples sit in adjacent seats. (As before, women and
men must sit in alternating positions.)
4.13 Generalize Corollary 4.3.3 and Exercise 4.3(d) by proving that if B is a board
contained in the n ⇥ n grid then
✓ ◆
m
n k 2
rm (B) = Â ( 1) rk (B)
k
(m k)!.
k=0 m k
4.14 For m 2 N, let Cm be the m-vertex cycle, as shown below.

• • • •
• • •
• • • • • • • • ...
C1 C2 C3 C4 C5
2 1+2z 1+3z 1+4z+z2 1+5z+5z2

Let rk (Cm ) be the number of ways to put k rooks on the vertices of Cm so


that no two rooks are on adjacent vertices. Let pm (z) = Âm k
k=0 rk (Cm )z . Let
76 Rook Polynomials

p0 = 2 and note that, because of the self-loop on its unique vertex, p1 (z) = 1,
as shown above.
(a) Show that if n 2 then p2n (z) is the rook polynomial gn (z) of the board Bn
with 2n squares used in the Problème des Ménages.
m/2
(b) Show that rk (Cm ) = rk (Sm 1 )+rk 1 (Sm 3 ) and hence pm (z) = Âk=0 mk k mm k zk
for m 2 N, generalizing Exercise 4.3.4.
(c) Show that if m 2 then pm (z) = pm 1 (z) + zpm 2 (z). [Hint: the direct proof
from (b) is not hard. There is also a more enlightening bijective proof using
Exercise 4.18(e) below.]
(d) Show by induction on m that pm (z)p2 (z) = pm+2 (z) + z2 pm 2 (z) for m 2.
(e) For n 2 N let gen (w) = wn gn ( w 1 ). Thus gen (w) = Ânk=0 rBn (n k)( 1)n k wk
for n 2 and, because of our earlier definitions, ge0 (w) = 2, ge1 (w) = w 2.
Show that for all n 2 N,

gen (w)e
g1 (w) = gen+1 (w) + gen 1 (w).

(f) Deduce that there is an injective ring homomorphism q : C[w] ! C[t 1 ,t]
such that q gen (w) = t n + t n for all n 2 N0 . [Hint: do not be scared by the
ring theory. Since ge1 (w) = w 2 generates C[w], it suffices to prove that q
respects multiplication by ge1 (w); that is,

q gen (w)e
g1 (w) = q gen (w) q ge1 (w)

for all n 2 N. The details of this reduction are given in the answer.]
(g) Using (f) and the identity (t n + t n )2 = t 2n + 2 + t 2n prove that gn (z)2 =
g2n (z) + 2z2n for all n 2 N0 .
(h) Show more generally that g` (z)gm (z) = g`+m (z)+z2m g` m (z) for all `, m 2 N0
with ` m, as claimed in Proposition 4.3.6.
(i) (?) Is there a bijective proof of (g)?
4.15 Suppose that B is a board in the n ⇥ n grid such that fB (z) = g2 (z)c2 . . . gn (z)cn .
See Proposition 4.3.8 and the two following exerciss for cases where this
arises.
(a) Show that wn fB ( w 1 ) = ge2 (w)c2 . . . gen (w)cn , where gen (w) is as defined in
Exercise 4.14(e).
(b) Show that there are constants b` 2 N0 such that

(t 2
+ t 2 )c2 . . . (t n
+ t n )cn = Â b` (t (n 2`)
+ tn 2`
).
0`n/2

(c) Deduce from Exercise 4.14(f) that fB (z) = Â0`n/2 b` z2` gn 2` (z).
(d) Deduce from Exercise 4.3.7 that rB (n) = Â0`n/2 b` un 2` .
Exercises 77

(e) Use the Binomial Theorem applied to (t m + t m )c and (d) to give an alterna-
tive proof of Proposition 4.3.8.

4.16 Let B and C be the boards of shaded squares shown below.

(a) Express rB (9) as a sum of the ménage numbers un . [Hint: a very quick method
uses the machine developed in Exercise 4.15.]
(b) Express rC (10) as a sum of the ménage numbers un . [Hint: Exercise 4.15
generalizes to products with g1 (z); note that f (z) = 1 + z = (1 + 2z) z =
g1 (z) z.]

4.17
(a) Let s , t : {1, 2, . . . , n} ! {1, 2, . . . , n} be permutations. Give a bijection be-
tween permutations discordant with both s and t and permutations discor-
dant with both the identity permutation and s 1 t.
(b) For n 3 let Dn be the board of unshaded squares contained in the n ⇥ n
grid, shown below for D3 , D4 , D5 , D6 . Find the number of ways to put n non-
attacking rooks on Dn in terms of the ménage numbers un . (See Lemma 9.4.1
for the general result behind this.)

4.18 Let G be a graph (possibly with self-loops) with m vertices. For k 2 N0 , we


say that a placement of k rooks on the vertices of G is non-attacking if no
two rooks are on vertices connected by an edge. Let rk (G) be the number
of such placements. Generalizing Exercise 4.14, we define the independence
polynomial G to be the polynomial fG (z) = Âm k
k=0 rk (G)z . For example, the
independence polynomials of the graphs
78 Rook Polynomials

• • • •
• • •
• • • • • • •
• • • •
• • • •
are 1 + 5z + 6z2 + 4z3 , 1 + 5z, 1 + 6z + 9z2 + 2z3 and (1 + z)2 (1 + 3z + z2 ). The
name comes from graph theory: a subset of the vertices of G is independent
if it contains no two adjacent vertices.
(a) Find the independence polynomials of the graphs below.

• • • •
• • • • • •
• • • •
• • •
• •
• •
(b) State a generalization of Lemma 4.2.1 to independence polynomials. Does
the proof of this lemma also generalize?
(c) State a generalization of Lemma 4.2.2 to independence polynomials. Does
the proof of this lemma also generalize?
(d) Find the independence polynomial of the graph below by applying (b) and
then (c).
• •
• • • • •
t u v
• •
(e) Let G be a graph having vertices {t, u, v} such that the only edges involving
u are {t, u} and {u, v}. Let
• G/u be G with vertex u and its incident edges deleted and (unless it is
already an edge), a new edge {t, v} inserted;
• G//u be G with vertex v deleted and vertices u and w identified.
(If {t, v} is an edge of G then G//u has a self-loop on the vertex replacing t
and v.) For example, if G is the graph in (d) with t, u, v as marked, then G/u
and G//u are as shown below.
• • • •
• • • • • • •
• • • •
Show that fG (z) = fG/v (z) + z fG//v (z).
(f) Show that given a board B with m boxes there is a graph G(B) with m vertices
such that fB (z) = fG(B) (z).
(g) Which of the graphs in (a) are graphs of boards?
(h) (?) Give a necessary and sufficient condition for a graph to be the graph of a
board.
4.3 Complementary boards and the Problème des Ménages 79

4.19 [This ‘exercise’ and the answer in Appendix C are included for more expert
readers as in indication of how the machinery of Lemma 4.15 leads to a quick
proof of Riordan’s formula for the number of 3 ⇥ n Latin rectangles. It will
be part of the text in §9.4.]
Notation. For n 2 N let un be the ménage number defined in §4.3; this could
also have been defined as the number of permutations of {1, 2, . . . , n} discor-
dant with both the identity and an n-cycle. By definition, u0 = 2. (Alas, here
zn
u0 = 1 would be the better choice.) Let F(z) = • n=0 dn n! be the exponential
generating function of the derangement numbers dn .
(a) Show that if s is a permutation of {1, 2, . . . , n} with cycle type (2c2 , . . . , ncn )
then the number of permutations discordant with both the identity and s is
Â0`n/2 b` (s )un 2` where the coefficients b` (s ) are defined by

(t 2
+ t 2 )c2 . . . (t n
+ t n )cn = Â b` (s )(t (n 2`)
+ tn 2`
).
0`n/2

(b) Let Dn be the set of derangements of {1, 2, . . . , n}. By specializing Polya’s


Cycle Index Formula appropriately show that

zn
F(z/t)F(zt) = Â Â Â b` (s )(t (n 2`)
+ tn 2`
).
n=0 n! s 2Dn 0`n

(c) Show that formally specializing the right-hand side in (b) by replacing t k +t k
with uk for each k 2 N gives the exponential generating function for 3 ⇥ n
Latin rectangles.
(d) Show that if 0  `  n/2 then the coefficient of znt n 2` /n! on the right-hand
side in (b) is n` d` dn ` and hence that the number of 3 ⇥ n Latin rectangles
with first row 1, 2, . . . , n is
✓ ◆
n
 ` d` dn ` vn 2`
`

where vk = uk for k 2 N and v0 = 1.


Appendix C
Solutions to exercises

1. The Derangements Problem


Exercise 1.1.3 We first count the derangements s of {1, 2, 3, 4} such that s (1) =
2. Clearly s (2) 2 {1, 3, 4}. If s (2) = 1 then, to avoid fixing 3, we must have s (3) =
4 and s (4) = 3. Hence s = 2143 in one-line form. Similarly if s (2) = 3 then
s = 1342 and if s (2) = 4 then s = 1432. The diagrams are shown below.

1 2 3 4 1 2 3 4 1 2 3 4

1 2 3 4 1 2 3 4 1 2 3 4

Similarly, or by symmetry if you prefer, there are three derangements such that
s (1) = 3, and three derangements such that s (1) = 4. Hence d4 = 3 ⇥ 3 = 9.

Exercise 1.1.4 Before Winter sets in, walk around your land. For each sheep you
see, put a stone in your pocket. Keep the stones safe until Spring. At Spring, take
the stones and again walk around your land. For each sheep you see, throw away a
stone. The number of remaining stones is the number of lost sheep. If this number
is less than 10, you can count it. Otherwise, make another bijection between the
remaining stones and a subset of the remaining sheep to visualize how many sheep
were eaten by wolves. (This only fails if more than half the sheep were lost.)
Remark: Tally marks have been found carved on bones dating back to 30000BC
and clay tokens, such as the ones in Figure A.1 overleaf, were used to represent
sheep in neolithic times. More sophisticated recording devices, known as quipu,
using knots on cords, were made by the Incans.

Exercise 1.1.5 The two derangements s of {1, 2, 3, 4, 5} such that s (1) = 2 and
s (2) = 1 are shown overleaf.
112 Solutions to exercises

Figure A.1 Clay accounting tokens, Susa, Uruk period. Louvre Museum.

1 2 3 4 5 1 2 3 4 5

1 2 3 4 5 1 2 3 4 5
s (2) s (1) s (5) s (3) s (4) s (2) s (1) s (4) s (5) s (3)

We have s (3) 2 {4, 5} so there are two choices for s (3). On the other hand, the
three derangements of {1, 2, 3, 4, 5} such that s (1) = 2 and s (2) = 3 are 23154,
23451 and 23514 in one-line form, so now there are 3 choices for s (3).

Exercise 1.1.7 The missing diagrams in Figure 1.1.7 are shown below.

1 2 3 4 5 1 2 3 4 5

1 2 3 4 5 1 2 3 4 5
s (4) s (1) s (2) s (5) s (3)

f f 1

1 2 3 4 5 1 2 3 4 5

1 2 3 4 5 1 2 3 4 5
t (1) t (3) t (2) t (5) t (4)
Solutions to exercises 113

End of chapter exercises


1.1 (a) Multiplying choices we get 3 ⇥ 4 ⇥ 6 = 72 meals.
(b) By BCP1 there are 3 ⇥ 4 = 12 two course meals with a starter and main course
and 4 ⇥ 6 = 24 two course meals with a main course and dessert. Adding up, using
BCP2, we count 12 + 24 = 36 two course meals with exactly one main course.
1.2 (a) Constructing (x1 , x2 , x3 ) step-by-step we have 10 choices for x1 (any num-
ber in {1, 2, . . . , 10}, then 9 choices for x2 (since x1 may not be chosen), then 8
choices for x3 (since x1 and x2 may not be chosen). Hence |X| = 10 ⇥ 9 ⇥ 8 = 720
by BCP1.
(b) f (x1 , x2 , x3 ) = {2, 3, 5} () {x1 , x2 , x3 } = {2, 3, 5}. We have 3 choices for x1 ,
then 2 choices for x2 , then 1 choice for x3 , giving 3 ⇥ 2 ⇥ 1 = 3! tuples.
(c) By the general version of part (b), for each X 2 S, there are exactly 3! tuples
(x1 , x2 , x3 ) 2 T such that f (x1 , x2 , x3 ) = X. Hence
|T | 720
|S| = = = 120.
3! 3!
10
Note that |S| = 3 , as you probably expected.
1.3 We partition X as follows:
X = (a, a) : 1  a  n [ (a, b) : 1  a < b  n .
There are n pairs in the first set. Pairs in the second set are in bijection with subsets
of {1, 2, . . . , n} of size 2, by the map (a, b) 7! {a, b}. So there are n2 = n(n 1)/2
pairs in the second set. Hence
n(n 1) n(n + 1)
|X| = n + = .
2 2
1.4 There are 2 subsets of {1}, namely ? and {1}, and 4 subsets of {1, 2},
namely ?, {1}, {2}, {1, 2}. You should find there are 8 subsets of {1, 2, 3}. So it
looks like the number of subsets of {1, 2, . . . , n} is 2n . We can construct a subset
X of {1, 2, . . . , n} step-by-step: for each x 2 {1, 2, . . . , n} make a yes/no choice of
whether to put it into X. We have 2 choices for each x, and n choices to make, so
by BCP1, there are 2 ⇥ 2 ⇥ · · · ⇥ 2 = 2n subsets.
When n = 0 this formula says, correctly, that the empty set ? has a unique subset,
namely itself.
1.5 (a) Send a placement with balls in urns a1 , a2 , a3 , a4 to {a1 , a2 , a3 , a4 }. This
defines a bijection f : A ! C. A walking route in B consists of seven steps, of
which exactly four are East. If the steps numbered a1 , a2 , a3 , a4 are East, then send
the route to {a1 , a2 , a3 , a4 }. This defines a bijection g : B ! C.
114 Solutions to exercises

(b) The steps East are steps number 1, 3, 4, 7 so the element of C corresponding to
this walk is {1, 3, 4, 7}.
(c) Urns 2, 3, 4 and 6 have balls, so the corresponding element of C is {2, 3, 4, 6},
and the corresponding walking route is SEEESES.
7
(d) By definition |C| = 4 . The sets A and B are in bijection with C, so by BCP0
we have
✓ ◆
7
|A| = |B| = |C| = .
4

1.6 (a) See the table below. The ‘x-card’ in AKQJx stands for any ten or lower.
There are 52 16 = 36 such cards, and 4 of each royal card, so the number of
AKQJx hands is 4 ⇥ 4 ⇥ 4 ⇥ 4 ⇥ 36 = 9216.

Hand type Number


AKQJx 4 ⇥ 4 ⇥ 4 ⇥ 4 ⇥ 36 = 9216
AAKQJ 6 ⇥ 4 ⇥ 4 ⇥ 4 = 384
AKKQJ 4 ⇥ 6 ⇥ 4 ⇥ 4 = 384
AKQQJ 4 ⇥ 4 ⇥ 6 ⇥ 4 = 384
AKQJJ 4 ⇥ 4 ⇥ 4 ⇥ 6 = 384

For instance, the number of AAKQJ hands is 42 ⇥ 4 ⇥ 4 ⇥ 4, since we can choose


two aces in 42 = 6 ways, and then we have 4 choices for the King, Queen and
Jack. The other rows of the table below are found similarly. Adding up, we count
9216 + 4 ⇥ 384 = 10752 hands.
(b) Now an x-card is any Jack or lower: there are 40 such cards.

Hand type Number


40
AKQxx 4⇥4⇥4⇥ 2 = 49920
4
AAKQx, AKKQx, AKQQx each 2 ⇥ 4 ⇥ 4 ⇥ 40 = 3840
4 4
AAKKQ, AAKQQ, AKKQQ each 2 ⇥ 2 ⇥ 4 = 144
4
AAAKQ, AKKKQ, AKQQQ each 3 ⇥ 4 ⇥ 4 = 64

Adding up, we count 49920 + 3 ⇥ 3840 + 3 ⇥ 144 + 3 ⇥ 64 = 62064 hands.

1.7 We have d0 = 1, d1 = 0 and so p0 = 1, p1 = 0. Hence p1 p0 = 1 =


( 1)1 /1!, as required. For the inductive step, suppose that pn pn 1 = ( 1)n /n!.
Solutions to exercises 115

Using the recurrence in Theorem 2.4 to rewrite dn+1 as n(dn + dn 1 ) we get


dn+1 dn n(dn + dn 1 ) dn
pn+1 pn = =
(n + 1)! n! (n + 1)! n!
⇣ n ⌘d dn 1 1
n
= 1 + = (pn pn 1 ).
n+1 n! (n + 1)(n 1)! n + 1
Hence, by induction, we have
1 ( 1)n ( 1)n+1
pn+1 pn = =
n + 1 n! (n + 1)!
as required.
It now follows by an easier induction on n 2 N0 that dn = n!pn is as claimed in
Corollary 1.1.9.
1.8 (a) Let x 2 {1, 2, . . . , n}. There are (n 1)! permutations s of {1, 2, . . . , n} that
fix x. (See page 8 for the case x = 1; we argued in the proof of Theorem 1.1.11(ii)
that there was nothing special about 1 in this context.) Since each permutation is
chosen with equal probability 1/n!, the probability that x is fixed is (n 1)!/n! =
1/n. Hence the probability that Parcel x is wrongly delivered is 1 1/n.
(b) Let Wx be the event that Parcel x is wrongly delivered. The event that all parcels
T
are wrongly delivered is nx=1 Wx . Assuming independence, we have
n n n
⇥\ ⇤ 1 1 n
P Wx = ’ P[Wx ] = ’ 1 = 1 .
x=1 x=1 x=1 n n

(c) Fix a > 0. A sketch graph shows that e y 1 y for all y 0, and 1 y
e (1+a)y for all sufficiently small y. (These inequalities are surprisingly useful.)
Putting y = 1/n and taking nth powers we get
1 1/n n 1 n n
e = e 1 e (1+a)/n = e (1+a)
n
for all sufficiently large n. Since a was arbitrary, it follows that limn!• (1 1/n)n =
1/e, as required.
(d) Suppose Parcel 1 is correctly delivered. Then the probability that Parcel 2 is
correctly delivered is 1/(n 1), which is more than the usual 1/n chance. (In par-
ticular, if n = 2, then once Parcel 1 is correctly delivered, it is certain that Parcel 2
is correctly delivered.) The events that the parcels are correctly delivered are there-
fore not independent.
1.9 Corollary 1.1.9 states that
⇣ 1 1 ( 1)n ⌘
dn = n! 1 + ···+ .
1! 2! n!
116 Solutions to exercises

Evaluating the Taylor series for ex at x = 1, as in the proof of Theorem 1.1.11(a),


we get
1 1 1 ( 1)n ( 1)n+1
e =1 + ···+ + +··· .
1! 2! n! n+1
Hence

n! dn 1 ( 1)m
dn
e
= n!
n! e
= n! Â .
m=n+1 m!

If a1 , a2 , . . . is a decreasing sequence of positive real numbers then a1 a2 + a3


· · · < a1 . Applying this with ai = 1/(n + i)! we get
n! n! 1
dn < = .
e (n + 1)! n + 1
n!
If n 2 then 1/(n + 1)  1/3 < 1/2. So provided n 2, the nearest integer to e
is dn . This result also holds if n = 1 since d1 = 0 and 1/e < 1/2.

1.10 (a) Observe that if s is a permutation of {1, 2, . . . , n} fixing exactly the


elements of Y ✓ {1, 2, . . . , n} then s permutes {1, 2, . . . , n}\Y as a derangement. If
|Y | = k then we have nk choices for Y and dn k choices for the derangement on
{1, 2, . . . , n}\Y . By the formula for dn k , the number of permutations with exactly
k fixed points is
✓ ◆ ⇣
n 1 1 ( 1)n k ⌘
an (k) = (n k)! 1 + ···+ .
k 1! 2! (n k)!
n
Since k (n k)! = n!/k!, this agrees with the claimed formula for an (k).
Hence
⇣ 1 1 ( 1)n ⌘
an (0) an (1) = n! 1 + ···+
1! 2! n!
⇣ 1 1 ( 1)n 1 ⌘ ( 1)n
n! 1 + ···+ = n! = ( 1)n .
1! 2! (n 1)! n!
(For a bijective proof of this identity see Herbert S. Wilf, A bijection in the theory
of derangements, Mathematics Magazine 57 (1984) 37–40.)
(b) The mean number of fixed points is

1 n n
1 ⇣ 1 1 ( 1)n k ⌘
Â
n! k=1
kan (k) = Â 1 + ···+ .
k=1 (k 1)! 1! 2! (n k)!

We get a summand ( 1)` / j!`! for every j, ` 2 N0 such that j + `  n 1. The


Solutions to exercises 117

contribution from those summands for which j + ` = m is


m m ✓ ◆ ✓ ◆
( 1)` k 1 m 1 m ` m
 =  ( 1)
m! `
= Â ( 1) ` .
m! `=0
`=0 (m `)!`! `=0

By Corollary 2.2.8(ii) the right-hand side is 0 unless m = 0, in which case it is 1.


Hence the mean number of fixed points is 1.
(c) (?) Let A be the matrix in the question. By one definition of the determinant,
n
det A = Â sgn(s ) ’ Ais (i)
s i=1

where s varies over all permutations of {1, 2, . . . , n}. Since Ais (i) = 1 if s (i) 6= i
and Ais (i) = 0 if s (i) = i, we have
(
n 1 if s is a derangement
’ Ais (i) = 0 otherwise.
i=1

Hence det A = en on .
Another way to find the determinant uses that det A is the product of the eigen-
values of A. Since A + I is the all-ones matrix, of rank 1, it has n 1 linearly
independent vectors in its kernel. Hence 1 is an eigenvalue of A with multiplicity
n 1. Another eigenvalue of A is n 1, since every column of A has sum n 1 and
so (1, . . . , 1)A = (n 1, . . . , n 1). Hence det A = ( 1)n (n 1). Comparing we get
en on = ( 1)n (n 1).
1.11 (a) We have defined P = {(s , x) : s 2 G, x 2 {1, 2, . . . , n}, s (x) = x}. Let
Fix s be the set of fixed points of s 2 G and let Stab x = {s 2 G : s (x) = x}.
Counting |P| by summing over s 2 G we get
|P| = Â |Fix s |.
s 2G

Recall that, by the orbit stabiliser theorem, if Orb x is the orbit of x under G then
|Orb x| = |G|/|Stab x|. Hence, counting |P| by summing over x 2 {1, 2, . . . , n}, we
get
n n
|G|
|P| = Â |Stab x| = Â |Orb x| .
x=1 x=1

Thus each x in an orbit of size r contributes |G|/r to the sum. Hence each orbit
contributes |G| to the sum, and |P|/|G| is the number of orbits of G on {1, 2, . . . , n}.
(b) Take a tetrahedron with faces labelled 1, 2, 3, 4. Any permutation of the faces
can be realised by a rotation that leaves the tetrahedron occupying the same position
118 Solutions to exercises

in space. Conversely, any rotation is clearly determined by what it does to the faces.
Thus the symmetry group of the tetrahedron is Sym({1, 2, 3, 4}).
The table below shows the number Cs of red-blue-green colourings fixed by an
element s of each cycle type. (See §9.2 for disjoint cycle notation.) For example,
the double-transposition s = (1, 2)(3, 4) fixes a colouring if and only if faces 1
and 2 have the same colour, and faces 3 and 4 have the same colour. So there are
C(1,2)(3,4) = 32 = 9 such colourings.

s id (1, 2) (1, 2, 3) (1, 2)(3, 4) (1, 2, 3, 4)


Cs 34 33 32 32 3
Ns 1 6 8 3 6

The bottom row shows the number of elements Ns with each cycle type. The num-
ber of coloured tetrahedra up to rotation is the number of orbits of Sym({1, 2, 3, 4})
on the set of all 34 coloured tetrahedra. By (a), it is
1 34 + 33 ⇥ 6 + 32 ⇥ 8 + 32 ⇥ 3 + 3 ⇥ 6
4! Â
Cs = = 15.
s 4!

(c) Attach labels 1, 2 to 3 to the three urns. We will ‘undo’ this labelling by counting
ball-urn placements up to the action of the symmetric group Sym({1, 2, 3}) on the
labels. For example, the ball and urn placement drawn below

1 2 3

is sent by the 3-cycle (1, 2, 3) to the placement with the same diagram, but with the
urns instead labelled 2, 3, 1 from left to right.
3+3 1 3+2 1 5 4
The total number of placements (into labelled urns) is 3 2 = 3 2 =
60, by BCP1 and Theorem 2.3.3.
A ball and urn placement is fixed by the transposition (1, 2) if and only if urns 1
and 2 have the same number of balls of each colour. Writing (w, b) for w white balls
and b black balls, the contents could be (0, 0), (1, 0), (0, 1) or (1, 1). Therefore there
are 4 placements fixed by each of the transpositions (1, 2), (1, 3) and (2, 3). Since
there are exactly 2 black balls, no placement is fixed by a three cycle. By (a), the
number of placements into indistinguishable urns is (60 + 3 ⇥ 4)/3! = 12.

1.12 Number the coins 1, 2, . . . , 2m from left to right. The tortoise can guarantee
to take all the odd coins (just do it!). Similarly the tortoise can guarantee to take
Solutions to exercises 119

all the even coins. So unless the value of the odd coins equals the value of the even
coins, the tortoise has a winning strategy.
Suppose that the even coins and the odd coins both have total value V . Let ci be the
value of coin i. Suppose that c1 > c2 and c1 > c2m . Let W = min(V c2 ,V c2m ).
Since V c1 < V c2 and V c1 < V c2m we have V c1 < W . Since V c2 =
c4 + · · · + c2m and V c2m = c2 + · · · + c2(m 1) , it follows that if the tortoise starts
by taking coin 1, and then switches to the even coins, he takes at least W + c1 > V .
By symmetry we see that the tortoise wins in the tied case whenever the coins at
each end are not equally valuable, and the more valuable one is worth more than
its neighbour.
1.13 The problem is no harder generalized to n safes. The keys can be distri-
bution uniformly at random as follows: start by putting key i in safe i, for each
i 2 {1, . . . , n}. Then for each k working from 1 up to n, choose a number j between
1 and k uniformly at random, and swap the keys in safes j and k. (If j = k then leave
the key in safe k where it is.) The first r swaps are irrelevant to the probability that
all safes can be opened. Then for each k > r, the key k in safe k must be moved
into an earlier openable safe. The probability this happens in every case is
k k+1 n 1 k
... = .
k+1 k+2 n n
This solution is due to Igors Stepanovs.
1.14 We build up a Sudoku permutation matrix one column at a time, starting
with column 1 and ending with column n2 . Let i, j 2 {0, 1, . . . , n 1}. When we
choose the row to contain the unique 1 in column ni + j + 1, there are j blocks,
each of n rows, that are barred because of the 1s in columns ni + 1, . . . , ni + j.
Let B be the n j-set of such rows. There are also ni rows that are barred because of
1s in columns 1, 2, . . . , ni. However, this double-counts any row containing a 1 in
columns 1, 2, . . . , ni whose number lies in B. In each block of columns nk + 1, . . . ,
nk + n for 0  k < i there are exactly j such rows. Hence there are
n2 nj ni + i j
possible positions for the 1 in column ni + j + 1. The total number of Sudoku
permutation matrices is therefore
n 1n 1 n 1
’ ’ (n i)(n j) = ’ n!(n j)n = n!n n!n = n!2n .
i=0 j=0 j=0

1.15 We give the start of one possible solution and invite the reader to complete
it.
120 Solutions to exercises

Working with a 4n-bead necklace, with 2n black beads and 2n white beads, number
the positions by integers, so m, m + 4n, m + 8n, . . . all label the same position. For
each m 2 {1, . . . , 4n}, let bm be the difference between the number of black beads
in positions {m, m + 1, . . . , m + 2n 1} and the number of black beads in positions
{m + 2n, . . . , m + 4n 1}. If bm = 0 then we may cut in position m to get two
necklaces, each with n black and white beads. Now consider how bm may vary
for m between 0 and 4m 1.

2. Binomial coefficients
Exercise 2.1.3 (a) The empty set ? is the unique subset of {1, 2, . . . , n} of size 0,
and {1, 2, . . . , n} is the unique subset of {1, 2, . . . , n} of size n. Hence n0 = nn = 1.
(If n = 0 then {1, 2, . . . , n} = ?; since ? ✓ ?, the empty set is the unique subset in
both cases.)
(b) Let n 2 N. The subsets of {1, 2, . . . , n} of size 1 are {1}, {2}, . . . , {n}. Clearly
the empty set ? has no subsets of size 1, so 01 = 0. Hence n1 = n for all n 2 N0 .

Exercise 2.1.6 The bijection

f : {1}, {2}, {3}, {4} ! {1, 2, 3}, {1, 2, 4}, {1, 3, 4}, {2, 3, 4}

is defined by f (X) = {1, 2, 3, 4}\X. Thus f ({1}) = {2, 3, 4}, f ({2}) = {1, 3, 4},
and so on. The inverse of f is

g : {1, 2, 3}, {1, 2, 4}, {1, 3, 4}, {2, 3, 4} ! {1}, {2}, {3}, {4}

defined by g(Y ) = {1, 2, 3, 4}\Y .


Remark: It would not be accurate to say that f and g are the same function, be-
cause they have different domains. However, if we let P be the set of all subsets
of {1, 2, 3, 4} then we can define a function h : P ! P by h(X) = {1, 2, 3, 4}\X;
then (i) h is a self-inverse bijection; (ii) f is the restriction of h to the 1-subsets
in P, and (iii) g is the restriction of h to the 3-subsets in P.

Exercise 2.1.10 The bijection


n X ✓ {1, 2, . . . , n}, |X| = k, o n Z ✓ {1, 2, . . . , n}, o
f : (X, y) : ! (Z, y) :
y 2 {1, 2, . . . , n}, y 62 X |Z| = k + 1, y 2 Z
defined in the informal proof is

f (X, y) = (X [ {y}, y).

The inverse of f is defined by f 1 (Z, y) = (Z\{y}, y).


Solutions to exercises 121

Exercise 2.2.1 Following the bijective proof of the Fundamental Recurrence we


see that 63 counts the 4-subsets of {1, 2, . . . , 7} containing 7, and 64 counts the
4-subsets of {1, 2, . . . , 7} not containing 7. The former subsets are in bijection with
the walking routes A to B where step 7 (the final step) is East, and the latter are
in bijection with the walking routes A to B where step 7 is South. (In either case
we put a number in the subset if it corresponds to a step East, as in the solution to
Exercise 1.5.)
Exercise 2.2.5 Take n people and form a (generalized) football team of r of them
in nr ways. Then choose k of these r people to be defenders in kr ways. Hence
there are nr kr teams-with-defenders. Alternatively, we first choose k of the n
people to be defenders in nk ways, and then complete the team by choosing r k
attackers from the remaining n k people in nr kk ways. So the number of teams-
with-defenders is also nk nr kk .
Exercise 2.2.7 Let P = {Z : Z ✓ A [ B, |Z| = m}. Since A [ B has size a + b,we
have |P| = a+b a . Observe that if Z 2 P then |Z \ A| 2 {0, 1, . . . , m}. For each k 2
{0, 1, . . . , m}, let
Pk = {Z 2 P : |Z \ A| = k}.
The size of Pk is ak mb k since we must choose exactly k elements of A for Z \ A
and then exactly m k elements of B for Z \ B. Hence
✓ ◆ m m ✓ ◆✓ ◆
a+b a b
= |P| = Â |Pk | = Â ,
m k=0 k=0 k m k
as required.
Exercise 2.2.10 When n is odd there is a bijection
f : X : X ✓ {1, 2, . . . , n}, |X| is even ! X : X ✓ {1, 2, . . . , n}, |X| is odd
defined by f (X) = {1, 2, . . . , n}\X.
This fails when n is even, because then |X| and |{1, 2, . . . , n}\X| always have the
same size. Instead, let P be the set of all subsets of {1, 2, . . . , n} and define g : P ! P
by
(
X [ {1} if 1 62 X
g(X) =
X\{1} if 1 2 X.
Observe that |g(X)| = |X|±1 for all X 2 P, so |g(X)| and |X| have different parities.
Moreover, g(g(X)) = X for all X 2 P, so g is its own inverse. Hence the restriction
of g to even sized sets is a bijection
X : X ✓ {1, 2, . . . , n}, |X| is even ! X : X ✓ {1, 2, . . . , n}, |X| is odd .
122 Solutions to exercises

The choice of 1 in the definition of g is arbitrary; some such choice is unavoidable


when n is even.
Exercise 2.3.1 (i) We have k numbered balls and n numbered small urns. For
ball 1 we have n choices for its urn; for ball 2 we have n 1 choices, and so on,
until ball k when we have n (k 1) choices. Hence, by BCP1, the number of
placements is n(n 1) . . . (n k + 1).
(ii) If the urns are large then an urn can be reused. Hence the number of choices
is n every time and the number of placements is nk .
Exercise 2.3.2 We have k indistinguishable balls, each in a unique small urn.
There are k! ways we can add numbers to these balls, one for each permutation
of {1, 2, . . . , k}, each giving a different placement of numbered balls. So the num-
ber of placements of k numbered balls is k! times the number of placements of k
indistinguishable balls.
The number of placements of k numbered balls into n large urns is nk . This number
is not divisible by k! in general. To see why the rule breaks down, imagine 2 balls
in a single urn. When we add labels 1 and 2, we get labelled balls 1 and 2, still in
a single urn. So there is one way to do this, not two. For a bigger example, take
n = 4 and k = 3, and check that there are 3, not 3! = 6 ways to add numbers to the
3 indistinguishable balls below.

1 2 3 4

Exercise 2.3.4 The ball-and-urn placements corresponding to the strings 100110,


000111 and 111000 are shown below.

1 2 3 4

1 2 3 4

1 2 3 4
Solutions to exercises 123

Exercise 2.4.3 We have


m ✓ ◆ m ✓ ◆ ✓ ◆ ✓ ◆
z+k z 1 z 2 m+z+1
 k =  ( 1) k
k
= ( 1) m
m
=
m
k=0 k=0

where the first and last equalities follow from Lemma 2.4.1 and the middle from
Lemma 2.4.2.

End of chapter exercises


2.1 (a) By Lemma 2.1.4 we have
✓ ◆ ✓ ◆
n n! n! n(n 1)! n 1
k =k = = =n .
k k(k 1)!(n k)! (k 1)!(n k)! (k 1)!(n k)! k 1

(b) We count pairs (y, X) where X is an k-subset of {1, 2, . . . , n} and y 2 X. On


the one hand, there are nk ways to choose X; then we can choose any of the k
elements of X to be y. Hence the number of pairs is k nk . On the other hand, we
can choose any y 2 {1, 2, . . . , n} in n ways; then we can choose any k 1 elements
of {1, 2, . . . , n}\{y} to form X\{y}. So the number of pairs is also n nk 11 .
Remark: This exercise is the special case k = 1 of Lemma 2.2.4. For a ‘deformal-
ized’ proof just put k = 1 in the answer to Exercise 2.2.5 above.
2.2 By Exercise 2.1 and Lemma 2.1.5 we have r nr = n nr 1
1 . Hence
n ✓ ◆✓ ◆ n ✓ ◆✓ ◆
m n m n 1
Âr r k =n r r 1 .
r=0 r=0

To apply Vandermonde’s Convolution (Lemma 2.2.6) we need the bottom parts of


the binomial coefficients to have constant sum, so we use Lemma 2.1.5 to rewrite
n 1 n 1
r 1 as n r . (This trick is often useful.) Therefore
n ✓ ◆✓ ◆ n ✓ ◆✓ ◆ ✓ ◆
m n m n 1 m+n 1
Âr r k =n r n r =n n
,
r=0 r=0

where the final equality uses Vandermonde’s Convolution.


2.3 (a) Fix k 2 N0 . When n = k the left-hand side is kk = 1 and the right-hand
side is k+1
k+1 = 1. Suppose inductively, that the formula holds for n 1 2 N0 , where
n 1 k. Then
✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆
k k+1 n 1 n n n
+ +···+ + = +
k k k k k+1 k
n+1
which is k+1 by the Fundamental Recurrence (Lemma 2.1.7).
124 Solutions to exercises

(b) The maximum element of an (k + 1)-subset of {1, 2, . . . , n} is at least k + 1 and


at most n. Hence,
(k + 1)-subsets of {1, 2, . . . , n + 1}
n n
[ (k + 1)-subsets of {1, 2, . . . , n + 1} o (?)
=
m=k+1
with maximum element m

where the union is disjoint. Let X be a (k +1)-subset of {1, 2, . . . , n} with maximum


element m. Removing m from X gives a k-subset of {1, 2, . . . , m 1}. Conversely,
given an k-subset of {1, 2, . . . , m 1}, we can insert m into it, and get a subset of
size k + 1 with m as its maximum element. Hence there is a bijection
n (k + 1)-subsets of {1, 2, . . . , n + 1} o n o
! k-subsets of {1, 2, . . . , m 1} .
with maximum element m
The right-hand set has size m k 1 . By BCP0, the mth set in the union in the right-
hand side of (?) also has size m k 1 . Since the left-hand side of (?) has size n+1
k+1 ,
we get
✓ ◆ n+1 ✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆
n+1 m 1 k k+1 n
= Â = + +···+
k+1 m=k+1 k k k k
as required.
2.4 (a) Number the cages from 1 up to n. If cage n has a lion then cage n 1
is empty, so there are k 1 lions in cages 1 up to n 2; by definition, there are
g(n 2, k 1) ways to place these k 1 lions. If cage n is empty then there are k 1
lions in cages 1 up to n 1; by definition there are g(n 1, k) such placements. This
counts each lion placement exactly once, so g(n, k) = g(n 2, k 1) + g(n 1, k).
(b) We work by induction on n, dealing with all k 2 N0 at once. Since the recurrence
for g in (a) assumes that n 2 we need two base cases. When n = 0 we have
g(0, 0) = 1 which agrees with 10 . When n = 1 we have g(1, 0) = g(1, 1) = 1 which
agrees with 1 k+1
k for each k, since 20 = 11 = 1.
We also need to check the formula holds when k = 0, since k 1 is assumed in (a).
Clearly g(n, 0) = 1 for all n 2 N, and this agrees with n 0+1
0 = 1.
For the inductive step, suppose that n 2 and k 1. By induction, we may assume
that
✓ ◆ ✓ ◆
(n 1) k + 1 n k
g(n 1, k) = =
k k
✓ ◆ ✓ ◆
(n 2) (k 1) + 1 n k
g(n 2, k 1) = = .
k k 1
Solutions to exercises 125

Using these and (a) we get


✓ ◆ ✓ ◆ ✓ ◆
n k n k n k+1
g(n, k) = g(n 2, k 1) + g(n 1, k) = + =
k 1 k k
where the final equality follows from the Fundamental Recurrence (Lemma 2.1.7).
Hence g(n, k) = n k+1
k for all k 2 N0 .

Bijective proof of (a) Assume that k 2 N. Take n k + 1 cages in a row and


choose k to have lions in n k+1
k ways. For each cage containing a lion, except
the left-most, put a new cage to its left. This gives a bijection between lion place-
ments counted by g(n, k) and the k-subsets of {1, . . . , n k + 1}.
2.5 If ur 2 N for each r and
u1 + u2 + · · · + un = k
then ur 1 2 N0 for each r and
(u1 1) + (u2 1) + · · · + (un 1) = k n.
This gives a bijection between solutions to the equation u1 + u2 + · · · + un = k with
ur 2 N for each r and solutions to the equation t1 +t2 + · · · +tn = k n with tr 2 N0
for each r. By Corollary 2.3.5 there are exactly k n+n k n
1
solutions to the latter
equation. Hence there are
✓ ◆ ✓ ◆ ✓ ◆
k n+n 1 k 1 k 1
= =
k n k n n 1
solutions to the original equation.
2.6 (a) The first few terms are b0 = 1, b1 = 1, b2 = 2, b3 = 3, b4 = 5, . . . .
(b) The numbers in (a) are all Fibonacci numbers. We conjecture that bn+2 = bn+1 +
bn for all n 2 N0 . This follows easily from the Fundamental Recurrence:
✓ ◆ ⇣✓ ◆ ✓ ◆⌘ ⇣✓ ◆ ✓ ◆
n+1 n n n 1 n 1 ⌘
bn+1 + bn = + + + + +···
0 1 0 2 1
✓ ◆ ✓ ◆
n+1 n
= 1+ + +···
1 2
= bn+2 .
Hence the bn are the Fibonacci numbers, defined starting at 1.
2.7 (a) By the Binomial Theorem (10 + 1)4 = 104 + 41 103 + 42 102 + 43 10 +
4 4 4 4
4 = 10000 + 4000 + 600 + 40 + 1 = 14641. The digits 0 , 1 , . . . , 4 are the en-
tries in row 4 of Pascal’s Triangle. (The pattern breaks down for (10 + 1)5 because
5 5
2 = 3 = 10 creates a carry when we add in base 10.)
126 Solutions to exercises

(b) Putting n = 2m in Claim 2.1.9 gives (2m k) 2m 2m


k = (k +1) k+1 . Hence k <
2m
2m
k+1 if and only if 2m k > k + 1, which holds if and only if k < m. Therefore
✓ ◆ ✓ ◆ ✓ ◆
2m 2m 2m
< ... < < .
0 m 1 m
The remaining inequalities 2mm >
2m
m+1 > ... > 2m
2m follow from 2m
k = 2m
2m k .
The proof for 2m + 1 is similar.
(c) Consider
2m ✓ ◆
2m
22m
= (1 + 1) 2m
=Â .
k=0 k

There are 2m + 1 summands, of which the largest is 2m m by (b). Hence 2


2m 2m
m
and, since the largest summand is at least the mean summand,
✓ ◆
22m 2m
 .
2m + 1 m
2.8 By Lemma 2.1.5 we have mk = mm k for k 2 {0, 1, . . . , m}. Hence
✓ ◆2 m ✓ ◆✓ ◆ n ✓ ◆✓ ◆ ✓ ◆
m m m m m 2m
 k = k k = k n k = m
k k=0 k=0

where the final equality uses Vandermonde’s Convolution (Lemma 2.2.6).


2.9 Since nr kr = 0 if r < k or r > n, we have Âr nr kr xr = Ânr=k nr kr xr . Now
use Lemma 2.2.4, that nr kr = nk nr kk whenever k  r  n, to get
✓ ◆✓ ◆ n ✓ ◆✓ ◆ ✓ ◆ n ✓ ◆
n r r n n k r n n k r
 r k x = k r k x = k  r k x
r r=k r=k
✓ ◆ n ✓ ◆ ✓ ◆ n k✓ ◆ ✓ ◆
n k n k r k n k n k m n k
= x  x = x  x = x (1 + x)n k
k r=k r k k m=0 m k

where the final step uses the Binomial Theorem. Substituting x = 1 we get Âr nr r
k =
n n k
k 2 and substituting x = 1 we get Âr ( 1)r nr kr = 0, provided n > k.
2.10 Again we use Lemma 2.2.4 to replace nr kr with nk nr kk . This gives
✓ ◆✓ ◆✓ ◆ n ✓ ◆✓ ◆✓ ◆ ✓ ◆ n ✓ ◆✓ ◆
r m n m n n k n m n k
 k r r  r k r k
= = Â r r k
k r=k
r r=k
✓ ◆ n ✓ ◆✓ ◆ ✓ ◆✓ ◆
n m n k n m+n k
= Â r n r = k
k r=k n
where the final step uses Vandermonde’s convolution (Lemma 2.2.6).
Solutions to exercises 127

2.11 (a) We work by induction on m. If m = 0 then the left-hand side is n2 n0 = n2


and the right-hand side is 12 n1 , so they agree. We now suppose, by induction, that
Âm 1 n
k=0 2 k nk = m2 mn . Hence
m ✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆
n n m n n n n m n m+1 n
 k = + m = =
k=0 2 k 2 m 2 m 2 m 2 m+1
where the final step uses Claim 2.1.9.
(b) Stop at the penultimate equality above and double each side.
(c) (?) Observe that the summands for k and n k in (b) are equal in magnitude but
have opposite signs. So it is sufficient to prove that
m ✓ ◆ ✓ ◆
n n
 (n 2k) k = (n m) m (†)
k=0

when m < n/2. For this we use the team-and-leader combinatorial interpretation.
Take n people, all of different ages. Given a team X of r  n/2 of these people,
say that Person x is paired with Person x? if Person x is the jth youngest person
in the team and Person x? is the jth youngest person not in the team. Say Person y
is a suitable leader for X if she is not in the team and is not paired with any team
member. The left-hand side of (†) counts the number of teams-and-suitable-leaders
where the team has size at most m.
The right-hand side of (†) counts the number of teams-and-leaders where the team
has size m. (The leader is not in the team, but need not be suitable.) Given such
a team X and a leader, either the leader is suitable, and we stop, or the leader is
paired with a unique team-member, say Person x. Sack the leader, and promote
Person x. If Person x is a suitable leader for the new team of size m 1, then stop.
Otherwise repeat this process. Since any leader is suitable for the empty team, the
process eventually stops with a team and suitable leader.
We illustrate the inverse by example. Take n = 6 and m = 3 and number the people
1, 2, 3, 4, 5, 6 in increasing seniority. Then Person 4 is a suitable leader for the team
with members Persons 1 and 5. This team must have been obtained by sacking an
unsuitable leader of a team with Persons 1, 4 and 5 and promoting Person 4. This
unsuitable leader was paired with Person 4. Since 4 is in the middle of {1, 4, 5}
and 3 is in the middle of {2, 3, 6}, this leader was Person 3.
2.12 (a) Since X 4 Y = Y 4 X and X \Y = Y \ X for all subsets X and Y , addition
and multiplication are commutative. The zero element is ?, since ? 4 X = X for
all subsets X and the one element is W since W \ X = X for all subsets X. Since
(X 4 Y ) 4 Z and X 4 (Y 4 Z) are both equal to
{w 2 W : w is in exactly one or exactly three of X, Y , Z, }
128 Solutions to exercises

the addition is associative. Clearly the multiplication is associative. The distribu-


tivity law holds because
(X 4 Y ) \ Z = (X [Y )\(X \Y ) \ Z
= (X [Y ) \ Z \ X \Y \ Z
= (X \ Z) [ (Y \ Z) \ (X \ Z) \ (Y \ Z)
= (X \ Z) 4 (Y \ Z).

(b) We have X 4 X = X\X = ? for all X 2 S.


(c) Take the symmetric difference of both sides of X 4 Y = Z with Z. This gives
X 4 Y 4 Z = Z 4 Z = ?. (One can think of this as adding Z to both sides.) By sym-
metry we have
X 4 Y = Z () Y 4 Z = X () Z 4 X = Y () X 4 Y 4 Z = ?.

(d) Similarly, by adding Y 4 Z to both sides, we get


X 4 Y = Z 4 W () X 4 Y 4 Y 4 Z = Z 4 W 4 Y 4 Z () X 4 Z = W 4 Y.
Since (X 4 Y ) \ (Z 4 W ) = (X \ Z) 4 (Y \W ) 4 (X \W ) 4 (Y \ Z) by the distributiv-
ity of multiplication over addition, the left-hand side equals (X \ Z) 4 (Y \ W ) if
and only if (X \W ) 4 (Y \ Z) = ?. This is the case if and only if X \W = Y \ Z.
2.13 (a) The next six sets in the colexicographic order on 3-subsets of N are
{2, 3, 5}, {1, 4, 5}, {2, 4, 5}, {3, 4, 5}, {1, 2, 6}, {1, 3, 6}.
(b) There are kr subsets of {1, 2, . . . , r}; of these {r k + 1, . . . , n} is the greatest
under the colexicographic order. Any k-subset of N containing an element strictly
greater than r is bigger than {r k + 1, . . . , r} in the colexicographic order. Hence
{r k + 1, . . . , r} is the kr th element of the colexicographic order on k-subsets
of N.
(c) Since 14 5 = 2002, the 2002nd element of the colexicographic order on 5-
subsets of N is {10, 11, 12, 13, 14}. The 2003rd element is {1, 2, 3, 4, 15}, and it
is now routine to step forward to get the element in position 2016. Or, to indicate
a more general approach, we argue that the 2016th set is {x1 , x2 , x3 , x4 , 15} where
{x1 , x2 , x3 , x4 } lies in position 2016 2002 = 14 of the colexicographic order on 4-
subsets of N. Since 54 = 5, whereas 64 = 15, we take the set immediately before
{3, 4, 5, 6, 15}, namely {2, 4, 5, 6, 15}.
(d) Using the method from (c) we note that 28
10 107 whereas 27 7
10 < 10 , so the
maximum element in the required 10-subset is 28. We then need the set in posi-
27 25
tion 107 10 = 1563715 of the colexicographic order on 9-subsets; since 9
Solutions to exercises 129

1563715 whereas 24 9 < 1563715, this set has maximum element 25, and we now
27 24
need the set in position 107 10 9 = 256211 of the colexicographic order
on 8-subsets. Continuing in this way we arrive at {?, 5, 7, 10, 12, 14, 20, 22, 25, 28},
corresponding to
✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆
27 24 21 19 13 11 9 6 4
107 = + + + + + + + + + 3.
10 9 8 7 6 5 4 3 2
3
The least entry, marked ? above, is therefore 3 = 1 .
(e) By (b), the set in position mr in the colexicographic order on m-subsets of
{1, 2, . . . , r} is {r m + 1, . . . , r}. Specifying this set by the ‘coding’ in (d), we get
✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆
r 1 r m+1 r m+1 r
+···+ + = .
m 2 1 m
r 1 r r r
(The argument, as in (d), starts ‘since m < m whereas m m , the maxi-
r m+1
mum element is r, . . . ’.) Now rewrite 1 = r 1m + r 0m .

2.14 Let S(r, k) be the set of strings of 0s and 1s with exactly r 1s and k 0s.
There are r+k k ways to choose k positions in a string of length r + k to be zero, so
r+k
|S(r, k)| = k . The left-hand side of Claim 2.4.4 therefore counts the number of
pairs (s,t) where s 2 S(c, k) and t 2 S(d, m k), for some k 2 {0, 1, . . . , m}. Given
such a pair, we can form a new string s1t 2 S(c + d + 1, m) by inserting 1 between s
and t. Conversely, given a string in S(c + d + 1, m), split it at the (c + 1)th 1, and
discard this 1. This gives a left string in S(c, k) and a right string in S(d, m k),
where k is the number of 0s in the left string. Hence,
m
 |S(c, k)||S(d, m k)| = |S(c + d + 1, m)|.
k=0

Claim 2.4.4 is an immediately corollary.


Remark: another bijective proof, related to the one given here by the bijective proof
of Theorem 2.3.3, interprets c+k
k as the number of ways to place k indistinguish-
able balls in c + 1 numbered urns. and d+m m k
k
as the number of ways to place
m k indistinguishable balls in a further d + 1 numbered urns.

2.15 (a) Let (X,Y ) 2 P. If X = Y then, by definition, f (X,Y ) = (X,Y ). Other-


wise, let z = max(X 4 Y ) and let f (X,Y ) = (X 0 ,Y 0 ). If z 2 X then the sets X 0 , Y 0
are defined by moving z from X to Y , so z = max(X 0 4 Y 0 ), z 2 Y 0 and f (X 0 ,Y 0 ) is
defined by moving z from Y 0 to X 0 . Therefore f (X 0 ,Y 0 ) = (X,Y ). The proof is sim-
ilar if z 2 Y . Hence f is an involution. Since |X 0 | = |X| ± 1, we have sgn(X 0 ,Y 0 ) =
0
( 1)|X | = ( 1)|X| = sgn(X,Y ).
130 Solutions to exercises
n 2 n n
Rewriting k as k n k , we see that
n ✓ ◆2
k n
 ( 1) k =  sgn(X,Y ).
k=0 (X,Y )2P

Split up the right-hand side as

 sgn(X,Y ) +  sgn(X,Y ).
(X,Y )2P (X,Y )2P
f ((X,Y ))=(X,Y ) f ((X,Y ))6=(X,Y )

Let Q = {(X,Y ) : f (X,Y ) = (X,Y )} be the set of summands in the first sum.
Note that f restricts to the identity map on Q and to a sign-reversing involution on
P\Q. Evaluating the second sum by applying f we get

 sgn(X,Y ) =  sgn(X,Y ) =  sgn f (X,Y ) =  sgn(X,Y ).


(X,Y )2P\Q f (X,Y )2P\Q (X,Y )2P\Q (X,Y )2P\Q

Hence the second sum is zero and

 sgn(X,Y ) =  sgn(X,Y ). (??)


(X,Y )2P (X,Y )2Q

(This is the key identity for the involutive method.)


We have f (X,Y ) = (X,Y ) if and only if X = Y . In particular, this implies that
|X| = |Y | = n/2. Hence if n is odd then Q = ? and the right-hand side of (??) is
zero. If n is even then Q = {(Z, Z) 2 P : |Z| = n/2} and the right-hand side of (??)
n
is ( 1)n/2 n/2 , as required.
(b) Hint: interpret k n 1 as n (kn 1) and define an involution on the pairs (X,Y )
of subsets of {1, 2, . . . , n} such that |X| + |Y | = n + 1.
2.16 (a) We work by induction on d. If d = 0 then h(x) = a0 and, by hypothesis,
h(c1 ) = 0. Hence a0 = 0 and h = 0. Let d 2 N. By the Factor Theorem, there is a
polynomial k(z) = b0 + b1 z + · · · + bd 1 zd 1 such that
h(z) = (z cd+1 )k(z).
Note that 0 = h(ci ) = (ci cd+1 )k(ci ) for each i 2 {1, . . . , d}. Since c1 , . . . , cd , cd+1
are distinct, it follows that k(ci ) = 0 for each i 2 {1, . . . , d}. By induction k = 0 and
hence h = 0.
(b) Apply (a) to f g.
2.17 Let P be the set of functions f : {1, 2, . . . , n} ! {1, 2, . . . , b + 1}. For each
x 2 {1, 2, . . . , n} we have b + 1 choices for f (x), so |P| = (b + 1)n . Let Pk be the
subset of P containing those functions f such that
x 2 {1, 2, . . . , n} : f (x) 2 {1, 2, . . . , b} = k.
Solutions to exercises 131

To specify f 2 Pk we can choose k elements x 2 {1, 2, . . . , n} such that f (x) 6= b + 1


in nk ways; then for each such x, we have b choices for f (x). Multiplying choices
we get |Pk | = nk bk . Summing over k we get (b + 1)n = Âk nk bk , as required.
Let f (z) = (z + 1)n and let g(z) = Âk nk zk . We have shown that f (b) = g(b) for all
b 2 N0 . By Exercise 2.16, we have f = g. Hence
✓ ◆
n k
(z + 1) = Â
n
z
k k

for all z 2 C. To get the form in Theorem 2.1.8, replace z with z/w and multiply
through by wn . (A separate argument is required if w = 0.)

2.18 Let n 2 N0 . By Exercise 2.1 we have r n+1


r = (n + 1) r n 1 for each r 2 N.
Hence
m ✓ ◆ m ✓ ◆ ✓ ◆
r n+1 n n 1
 ( 1) r r = (n + 1)  ( 1) r 1 = ( 1) (n + 1) m 1
r m
r=1 r=1

where the final equality uses Lemma 2.2.2. The required identity therefore holds
for all z 2 N0 . Since each side is a polynomial in z, it holds for all z 2 C.

2.19 (a) Starting with the right-hand side we have 6 3x 2 1x + 0x = 6x(x 1)(x
6
2)
x
2x + 1 = x(x 1)(x 2) 2x + 1 = x3 3x2 + 1. The coefficients of d for 0 
d  3 are 1, 2, 0, 6; these are the numbers appearing on the diagonal of the table.
(b) Using 0, 1, 0, 1, 0 as the top row of a table gives
0 1 0 1 0
1 1 1 1
2 0 2
2 2
0
Motivated by (a), we take
✓ ◆ ✓ ◆ ✓ ◆
x x x x3 8x 1
g(x) = 2 2 + = 2x2 + = x(x 2)(x 4).
3 2 1 3 3 3
Clearly g has roots at 0, 2 and 4 and g(1) = 1, g(3) = 1, as required.

2.20 (a) You should find a1 = 1, a2 = 2, a3 = 4, a4 = 8.


(b) Since a5 = 16, just looking at the values computed so far, it is very tempting to
conjecture that an = 2n 1 .
(c) Clearly a0 = 1; this is not consistent with the conjecture in (b). It is surprisingly
132 Solutions to exercises

rare in combinatorial problems for the ‘empty’ case to be truly exceptional, so al-
ready this casts doubt on the conjecture. If you draw a sufficiently generic diagram
for n = 6 and carefully count the regions you should find that a6 = 31.
(d) The table below is constructed as in Exercise 2.19:
1 1 2 4 8 16 31
0 1 2 4 8 15
1 1 2 4 7
0 1 2 3
1 1 1
0 0
n n
We therefore conjecture (surely no more rashly than before) that an = 4 + 2 +1
for all n 2 N0 .

2.21 (a) If n = 0 then Dn rz = rz . Suppose inductively that Dn 1 rz = r (nz 1) .


Then
✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆
n z n 1 z z z+1 z z
D =D D =D = =
r r r n+1 r n+1 r n+1 r n
where the final equality follows from the general form of the Fundamental Recur-
rence (Lemma 2.1.7).
(b) We have b(z) = rz . By (a), if n < r then (Dn b)(0) = r 0 n = 0. When n = r we
have (Dn b)(z) = 0z = 1. So (Dn b)(0) = 1, and since Dr b is a constant polynomial
Dn b = 0 for all n > r.
(c) Suppose that Âdr=0 cr rz = 0 where cr 2 C for each r, and cd 6= 0. Since rz has
degree r, the left-hand side has degree d, a contradiction. Therefore Therefore the
binomial coefficients rz for r 2 N0 are linearly independent and the subspace of
C[z] spanned by 0z , . . . , dz has dimension d + 1. It is contained in the (d + 1)-
dimensional subspace of polynomials of degree at most d. Hence these subspaces
are equal, and so the binomial coefficients rz for r 2 N0 span C[z].
(d) By (c), there exist unique coefficients cr 2 C such that f (z) = Âdr=0 cr rz . Let n 2
N0 . By (b), (Dn f )(0) = Âdr=0 cr (Dn rz )(0) = cn . Hence f (z) = Âdr=0 (Dr f )(0) rz , as
claimed. A table of differences, as in Exercise 2.19, has f (0), f (1), . . . in its first
row, and (D f )(0) = f (1) f (0), (D f )(1) = f (2) f (1), . . . in its second row. A
routine induction shows that, more generally, the entries in row n are (Dn f )(0),
(Dn f )(1), . . . . In particular, the nth entry on the diagonal is (Dn f )(0) = cn , as
required.
(e) When n = 0 we have (D0 f )(z) = f (z), which agrees with the right-hand side.
Solutions to exercises 133
n
Suppose inductively that (Dn f )(z) = Ânk=0 ( 1)k k f (z + n k). Then

(Dn+1 f )(z)
= D Dn f (z)
n ✓ ◆ n ✓ ◆
k n k n
= Â ( 1) f (z + 1 + n k) Â ( 1) f (z + n k)
k=0 k k=0 k
n ✓ ◆ n+1 ✓ ◆
k n n
= Â ( 1) f (z + n + 1 k) Â ( 1) j 1
f (z + n (j 1))
k=0 k j=1 j 1
n+1 ✓✓ ◆ ✓ ◆◆
n n
= Â ( 1) k
+ f (z + n + 1 k)
k=0 k k 1
n+1 ✓ ◆
k n+1
= Â ( 1) f (z + n + 1 + k)
k=0 k

where again the final step uses the Fundamental Recurrence. This gives the induc-
tive step.

2.22 Considered as polynomials in z, both sides have degree 2m. If z = m then


z z m 2m . If
k 2m k is non-zero only when k = m, and so both sides equal ( 1) m
z 2 {0, 1, . . . , m 1} then both sides are zero. If z = r where r 2 {1, . . . , m} then,
using Lemma 2.4.1 and Lemma 2.1.5, the left-hand side is
2m ✓ ◆
k 2m
 ( 1) k g(k)
k=0

where g(y) = r+y r 1


1 r+2m y 1
r 1 . Since g is a polynomial of degree 2(r 1) < 2m
in y, we have D2m g = 0 by Exercise 2.21. So both sides are again zero. This shows
that the two sides agree at 2m + 1 values of z, and so, by the key principle, they are
equal as polynomials in z.

3. Principle of Inclusion and Exclusion


Exercise 3.1.4 Taking n = 3 in the Principle of Inclusion and Exclusion (The-
orem 3.1.3) we get |A1 [ A2 [ A3 | = ÂI✓{1,2,3} ( 1)|I| |AI |. The eight summands,
indexed by the subsets of {1, 2, 3}, are the sizes of the sets A? = W, A{1} = A1 ,
A{2} = A2 , A{3} = A3 , A{1,2} = A1 \ A2 , A{1,3} = A1 \ A3 , A{2,3} = A2 \ A3 and
A{1,2,3} = A1 \ A2 \ A3 . Thus written out, the formula is

|A1 [ A2 [ A3 | = |W| |A1 | |A2 | |A3 | + |A1 \ A2 |


+ |A1 \ A3 | + |A2 \ A3 | |A1 \ A2 \ A3 |.
134 Solutions to exercises

This agrees with Example 3.1.1 if we change the labels of the sets from A1 , A2 , A3
to A, B, C.

Exercise 3.1.5 Since |X| = |W| |X| for any subset X of W, we have |A1 [ A2 [
. . .[An | = |W| |A1 [ A2 [ . . . [ An |. Using the Principle of Inclusion and Exclusion
we get

|A1 [ A2 [ . . . [ An | = |W| Â ( 1)|I| |AI |.


I✓{1,2,...,n}

By the convention that A? = W, the summand for I = ? is |W|; this cancels with
the first term. We are left with

|A1 [ A2 [ . . . [ An | = Â ( 1)|AI | 1 |AI |.


I✓{1,2,...,n}
I6=?

End of chapter exercises

3.1 We have A = {2, 4, 6, . . . , 2018} and B = {5, 10, 15, . . . , 2015}. Hence |A| =
2018/2 = 1009 and |B| = 2015/5 = 403. Clearly x 2 A \ B if and only if x 2 W
and x is divisible by 10. Hence A \ B = {10, 20, . . . , 2010} and |A \ B| = 201. It
follows from Example 3.1.1 that

|A [ B| = |W| |A| |B| + |A \ B| = 2019 1014 403 + 201 = 808.

The elements of A [ B are precisely those x 2 N such that x  2019 and x is an odd
number not divisible by 5, as shown in the Venn diagram below.

A A\B B

{2, 4, 6, . . . , 2018} {10, 20, . . . , 2010} {5, 15, . . . , 2015}

A [ B = {1, 3, 7, 9, 11, . . . , 2013, 2017, 2019}

3.2 Let W = {1, 2, . . . , 100} and let D(m) = {x 2 {1, . . . , 100} : x is divisible by m}
as in §3.4. By adapting Example 3.4.1, we find |D(2) [ D(3) [ D(5) [ D(7)|. By the
Solutions to exercises 135

Principle of Inclusion and Exclusion and Lemma 3.4.2, we have


\
|D(2) [ D(3) [ D(5) [ D(7)| = Â ( 1)|P| D(p)
P✓{2,3,5,7} p2P

= Â ( 1)|P| D( ’ p)
P✓{2,3,5,7} p2P

100
= Â ( 1) |P|
’ p2P p
.
P✓{2,3,5,7}

Calculating the 16 summands we get |D(2) [ D(3) [ D(5) [ D(7)| = 100 50


33 20 14 + 16 + 10 + 7 + 6 + 4 + 2 3 2 1 0 + 0 = 22. The two zero sum-
mands come from D(3⇥5⇥7) = D(105) = ? and D(2⇥3⇥5⇥7) = D(210) = ?.
If x 2 W and x is composite then x is divisible by either 2, 3, 5 or 7. (If not the small-
est prime dividing x is 11, and since x is composite, x 112 > 100, a contradiction.)
Hence x 2 D(2) [ D(3) [ D(5) [ D(7). Remembering that 1 is not composite, we
get
D(2) [ D(3) [ D(5) [ D(7) = {1} [ {p 2 W : p 11 and p is prime}
and so the number of primes in {1, 2, . . . , 100} is 22 1 + 4 = 25.

3.3 As usual, for W ✓ N, let D(m) = {x 2 W : x is divisible by m}. For (a) we take
W = {1, 2, . . . , pq}. If x 2 W then
x is coprime to pq () x is not divisible by p and x is not divisible by q
() x 2 D(p) [ D(q).

Hence f (pq) = D(p) [ D(q) and so using the Principle of Inclusion and Exclusion
we get
f (pq) = |W| |D(p)| |D(q)| + |D(p) \ D(q)|
= |W| |D(p)| |D(q)| + |D(pq)|
pq pq pq
= pq +
p q pq
⇣ 1 ⌘⇣ 1⌘
= pq 1 1 .
p q
In (b) we take W = {1, 2, . . . , p2 q} and argue similarly that
x is coprime to p2 q () x is not divisible by p and x is not divisible by q
() x 2 D(p) [ D(q).
The conclusion is the same as (a), but now D(p) and D(q) are defined using
136 Solutions to exercises

{1, 2, . . . , p2 q}. (Note that it is correct to work with D(p) rather than D(p2 ), since
we have to rule out divisibility by p, not p2 .) The same calculation as (a) now gives
pq2 pq2 pq2 ⇣ 1 ⌘⇣ 1⌘
f (pq2 ) = pq2 + = pq2 1 1 .
p q pq p q
The three prime case in (c) is similar to (a): you should find that
⇣ 1 ⌘⇣ 1 ⌘⇣ 1⌘
f (pqr) = pqr 1 1 1 .
p q r

3.4 (a) This is similar to the second example in §3.3, replacing the ranks Ace,
King, Queen and Jack with the suits spades , hearts ~, diamonds } and clubs |.
As before, let W be all 52
5 hands of five cards. Let C be the hands we do not want
to count because they have no spades, and define C~ , C} and C| similarly. For
example, |C | = 5239 since there are 39 non-spades in the deck. By the Principle
of Inclusion and Exclusion, the number of five card hands with at least one card of
each suit is
|C \C~ \C} \C| |
= |W| |C | |C~ | |C} | |C| | + |C \C~ | + · · · + |C} \C| |
|C \C~ \C} | · · · |C~ \C} \C| | + |C \C~ \C} \C| |
✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆ ✓ ◆
52 39 26 13 0
= 4 +6 4 +
5 5 5 5 5
= 682604.
1
(This is a bit over 4 of all hands.)
For (b) we use the sets above and also CA , CK , CQ , CJ from §3.3. As an example,
consider CA \ C \ C~ . Its elements are the five card hands built from a reduced
deck having no aces, spades or hearts. Using the Principle of Inclusion and Exclu-
sion in the case n = 2, there are 52 4 26+2 cards in the reduced deck. (The final
+2 accounts for the aces of spades and hearts.) Therefore |CA \ C \ C~ | = 24 5 .
More generally, a set AI defined by taking r of the rank sets CA ,CK ,CQ ,CJ and s of
the suit sets C ,C~ ,C} ,C| has size 52 13r5 4s+rs . Hence there are
4 4 ✓ ◆✓ ◆✓ ◆
r+s 4 4 52 13r 4s + rs
  ( 1) r s 5
= 2592
r=0 s=0

five card hands having at least one card of each suit and at least one Ace, King,
Queen and Jack. (The sum has 25 terms, so is most easily evaluated using computer
algebra.)
Solutions to exercises 137

3.5 (a) A function f : {1, 2, . . . , m} ! {1, 2, . . . , n} is uniquely determined by


its values f (1), f (2), . . . , f (m) 2 {1, 2, . . . , n}. There are n possible choices for
each f (t). Hence, multiplying independent choices, we find that |W| = nm . For
Ai we may not choose f (t) = i so there are now n 1 choices and |Ai | = (n 1)m .
(b) We have

AI = f 2 W : f (t) 62 I for any t 2 {1, 2 . . . , m} .

Generalizing the argument in (a), there are n |I| possible choices for each f (t) so
|AI | = (n |I|)m .
(c) A function f 2 W is surjective if and only if f 62 A1 , f 62 A2 , . . . , f 62 An . Equiv-
alently, f 2 A1 [ A2 [ · · · [ An . By the Principle of Inclusion and Exclusion and (b)
we get

|A1 [ A2 [ · · · [ An | = Â ( 1)|I| |AI |


I✓{1,2,...,n}

= Â ( 1)|I| (n |I|)m
I✓{1,2,...,n}
n ✓ ◆
k n
= Â( 1)
k
(n k)m
k=0

as required.
(d) Given a placement of m numbered balls into n numbered urns, define f 2 W by

f (t) = u () ball number t is put in urn number u.

Conversely, each f 2 W defines a corresponding ball-and-urn placement. The place-


ments where every urn contains a ball are precisely those corresponding to surjec-
tive functions.

3.6 Let the factorizations of M and N into distinct primes be M = pe11 pe22 . . . penn
and N = q1f1 q2f2 . . . qrfr . Since M and N are coprime, the pi and q j are distinct. Hence
Proposition 3.4.4 implies that
n ⇣ 1 ⌘ r fj⇣ 1⌘
f (MN) = ’ pei i 1
pi ’
q j 1
i=1 j=1 qj

By another application of Proposition 3.4.4, this is f (M)f (N). This multiplicativ-


ity property fails whenever M and N are not coprime. For example if p is prime
then f (p2 ) = p2 (1 1p ) = p2 p whereas f (p)2 = (p 1)2 = p2 2p + 1.
138 Solutions to exercises

3.7 (a) The encryption of 7 is 79 mod 187, namely 129.


(b) Since M = 187 = 11 ⇥ 17, we have f (M) = (11 1)(17 1) = 160. We must
solve 9d ⌘ 1 mod 160. Using Euclid’s Algorithm to express 1 as an integral linear
combination of 9 and 160 we compute 160 = 17 ⇥ 9 + 7, 9 = 1 ⇥ 7 + 2 and 7 =
3 ⇥ 2 + 1, hence 1 = 7 3 ⇥ 2 = 7 3 ⇥ (9 1 ⇥ 7) = 4 ⇥ 7 3 ⇥ 9 = 4 ⇥ (160
17 ⇥ 9) 3 ⇥ 9 = 4 ⇥ 160 71 ⇥ 9. Since 71 ⌘ 89 mod 160 we have d = 89.
(c) Using d, Alice decrypts 51 as 5189 mod 187, namely 85. (You can do this on a
3
calculator by repeated squaring: write 89 = 26 + 24 + 23 + 1 and compute 512 by
successively squaring 51 three times, reducing modulo 187 after each square, then
4
square this to get 512 , and so on.)
(d) Of course the primes are far too small. But even if p and q were of the size
currently recommended by NCSC (National Cyber Security Centre, UK) and NIST
(National Institute of Standards and Technology, USA) of about 21024 , Eve the
eavesdropper could use Alice’s public key (n, a) to encrypt each of the possible
messages to Alice, 0a mod n, 1a mod n, . . . , 100a mod n. If xa mod n matches
Bob’s encrypted message, then Alice’s exam mark is x. This attack is an inevitable
feature of public key encryption, but can be avoided if Bob pads his message with
sufficient unpredictable text. Another problem is that, since anyone can send a
message to Alice using her public key, Alice has no way to be certain the message is
from Bob. This problem is solved by asking Bob to ‘sign’ the encrypted message by
decrypting it using his RSA private key. With these changes correctly implemented,
the scheme is widely believed to be secure. (With some refinements, it is used
whenever you pay for something online.)

3.8 We are given M = pq and f (M) = (p 1)(q 1) = pq p q + 1. Let


s = M f (M) + 1 = p + q. Since M = p(s p) = q(s q), the factors p and q are
the roots of the quadratic equation M = x(s x), where the coefficients M and s are
known.

3.9 (a) Since p is prime, and p does not divide x or y, p does not divide xy. (This is
less obvious than it might sound, but follows from unique factorization.) If xy ⌘ r
mod M then xy = kpq + r for some k 2 N0 , and so p does not divide r. Similarly q
does not divide r. Hence r is in U.
(b) Let y, y0 2 {0, 1, . . . , M 1} and suppose that fx (y) = fx (y0 ). Then xy ⌘ xy0 mod
M, so x(y y0 ) ⌘ 0 mod M. Hence p and q divide x(y y0 ). But since x 2 U is
coprime to p and q, pq must divide y y0 . Hence y ⌘ y0 mod M, and so y = y0 .
(c) By (a), each fx restricts to a function from U to U. Since 1 2 U and an injective
Solutions to exercises 139

function on a finite set is surjective, there exists x0 2 U such that fx (x0 ) = 1. That
is, xx0 ⌘ 1 mod M.
(d) By (a), U is closed under multiplication modulo M. The identity element is 1
and by (c) each element of U has an inverse. Multiplication is well known to be
associative. Therefore U is a group. The order of U is f (M), namely (p 1)(q 1).
(e) Suppose that a is coprime to f (M). There exists d such that ad ⌘ 1 mod f (M).
Suppose that ad = kf (M) + 1. By Lagrange’s Theorem, xf (M) ⌘ 1 mod M for all
x 2 U. Hence

(xa )d = xad = xkf (M)+1 = (xf (M) )k x ⌘ x mod M.

Similarly (xd )a ⌘ x mod M. This shows that x 7! xd mod M is the inverse of x 7! xa


mod M. Given f (M) we can compute d as in Exercise 3.7(b) using Euclid’s Algo-
rithm. No other method is known for computing d. In particular, by Exercise 3.7,
computing f (M) is equivalent to factoring M; when p and q are large (see the
answer to Exercise 3.7(d) above), this is widely believed to be computationally
infeasible.

3.10 (a) Using the Taylor series for the exponential function we have ecy > c2 y2 /2
for y > 0. Hence ye cy < 2/c2 y ! 0 as y ! •.
(b) Using log log M  log M and (a) with y = log M, we get

log M (log M)2


log log M  = y2 e y = (ye y/2 )2  ( 8y )2 ! 0 as y ! •,
M M
M log 2 log M
log log M  1 log 2 = ye (1 log 2)y  ye y/4  8y ! 0 as y ! •.
M M
Hence p(M)  2M/ log log M for all sufficiently large M.
(In fact the bounds above imply that p(M)  2M/ log log M for log M 16; then
by checking the ‘small’ cases where M < e16 < 107 on a computer, one gets the
more explicit result that p(M)  2M/ log log M for all M 3.)

3.11 (a) Expanding the geometric series we get


n ⇣ 1⌘ 1 n ⇣
1 1 1 ⌘
’ 1
pi
= ’ 1 + + 2 + · · · + ei + · · · .
pi pi pi
i=1 i=1

If x  pn then x has a prime factorization pe11 pe22 . . . penn for some e1 , e2 , . . . , en 2 N0 .


Hence 1/x is obtained by multiplying out the product, taking 1/pei i from the ith
pn 1
term for each i. It follows that the product is at least Âx=1 x.
140 Solutions to exercises

(b) We have
Z x+1 Z x+1
dt dt 1
 
x t x x x
for each x 2 N. Hence
Z S S 1 Z x+1
dt dt S 1 1 S
1
t
 Â t
Â Â
1 x=1 x x=1 x x=1 x

as required.
1
(c) If there are finitely many primes then ’ p 1 1p , where the product is over all
primes, is finite and so converges. This contradicts (b). (Of course Corollary 3.4.6
and Exercise 3.10 give a stronger result: the argument here is an even shorter
demonstration of the relevance of analytic methods to number theory.)

3.12 (a) Since |1/mz | = 1/mRe z and • r


m=1 1/m converges whenever r > 1 (for
• z
example, by the integral test), Âm=1 1/m converges absolutely when Re z > 1.
When z = 1 the series diverges, by Exercise 3.11(b).
(b) Replacing pi with pzi in Exercise 3.11(a) we get
n ⇣ 1⌘ 1 1
’ 1 =Â
i=1 pzi mz
where the sum is over all those m 2 N divisible only by the primes p1 , . . . , pn .
By (a), the right hand-side converges to • z
m=1 1/m as n ! •. This series converges
absolutely, so the sum is independent of the order of terms. Therefore
• ⇣
1⌘ 1 •
1
’ 1 pz = Â mz
i=1 i m=1

as required.
(c) Using h(z) to cancel summands 1/(2m + 1)z in z (z) we get

1
z (z) h(z) = 2 Â (2m) z
=2 (z 1)
z (z).
m=1

Hence z (z)(1 2 (z 1) ) = h(z), as required.


(d) If z 2 R and z > 0 then the terms ( 1)m /mz are alternating in sign and decreas-
ing. Convergence of h(z) follows from the alternating series test. Convergence for
general z with Re z > 0 can be proved by using the Generalized Binomial Theorem
(Theorem 5.2.1) to write
s z
(m + 12 + `) z = (m + 12 ) z 1 + m+` 1 = (m + 12 ) z 1+ `
1 m+ 1 + O(m 2 ) .
2 2
Solutions to exercises 141

Now take ` = ± 12 and m = 2q 1 to show that


z z 1 z z 1 (z+1)
(2q 1) (2q) = (2q 2) 2q 1 +O(q 2 ) = z(2q 2) +O(q (z+2) ).
2

The ‘big-O’-notation used above is defined in §6.4. We saw in (a) that •


q=1 1/q
z+1

converges absolutely when Re z > 0, hence h(z) converges when Re z > 0.


(A less ad-hoc proof uses Abel summation, one of the main techniques in analytic
number theory; this method can also be applied directly to the z function to get the
R
meromorphic continuation z (s) = s s 1 + 1• x{x}
s+1 dx to Re s > 0; here {x} denotes

the fractional part of x 2 R.)

3.13 (a) Let W = {1, 2, . . . , M}. Since x 2 W is square-free if and only if x is not
divisible by any of p21 , p22 , . . . , p2n , we have

S = D(p21 ) [ D(p22 ) [ . . . [ D(p2n ).


Thus p2 (M) = |S| and by the Principle of Inclusion and Exclusion and Proposi-
tion 3.4.3,
j M k
p2 (M) = Â ( 1)|I|
’i2I p2i
.
I✓{1,2,...,n}

If we repeat the approximation in the proof of Theorem 3.4.5 we p get thepsame error
term of 2n . By the Prime
p Number Theorem, there arepabout M/ log M primes
less than or equal to M, so the error term is roughly M
p 2 . This is far larger than M
and p2 (M). Instead, we observe that if ’i2I pi > M then the summand p for I is
zero. We can therefore drop all these summands, leaving at most M non-zero
summands. Dividing by M and using the ? notation from the question to denote
that summands ±1/d with d > M are to be ignored, we get
p
p2 (M) 1 M
Â
? |I|
( 1) 2
 .
M I✓{1,2,...,n} ’i2I pi M

Writing the sum as a product, as in Theorem 3.4.5, gives


p2 (M) n
1⌘ 1

?
1 2
p .
M i=1 pi M
where the ? notation is as in the question. This proves (a).
(b) As M tends to infinity we sieve over more and more primes and every ± d12 for
d 2 N appears as an (unignored) term in the product. The right-hand side tends to
0. Therefore
• ⇣
p2 (M) 1
lim =’ 1 .
M!• M
i=1 p2i
142 Solutions to exercises

By Exercise 3.12(a) it follows that limM!• p2M


(M)
= z (2).
(c) We were able to estimate p2 (M) by sieving over all relevant primes relevant
to p2 (M) without introducing a large error term. This was impossible for p(M).
Therefore we get a more precise answer for p2 (M) than p(M). Correspondingly,
1
’ni=1 1 p12 converges to z (2) as n ! •, whereas, by Exercise 3.11(a),
i
n
1 1
’ 1
pi
! • as n ! •.
i=1

(For this reason, the sieve used in this question is called the ‘convergent sieve’.)

3.14 (a) Using the definition of gr (x) and then swapping the sums over x 2 W and
I ✓ {1, 2, . . . , n}, we have
(
( 1)|I| if x 2 AI
cr = Â gr (x) = Â Â = Â ( 1)|I| |AI |
x2W I✓{1,2,...,n} x2W 0 otherwise I✓{1,2,...,n}
|I|r |I|r

as claimed.
(b) By hypothesis, x 2 A j if and only if j 2 J. As seen in the proof of the Principle
of Inclusion and Exclusion, x contributes to |AI | if and only if I ✓ J. Therefore we
can restrict the sum defining fr (x) to those I such that I ✓ J to get
gr (x) =
I✓J
Â( 1)|I| .
|I|r

Since there are |J|


k k-subsets of J, the right-hand side is Ârk=0 ( 1)k |J|k . By
r |J| 1 r |J| 1
Lemma 2.2.2 the sum is ( 1) r , hence gr (x) = ( 1) r as required. By
definition of mx we have mx = |J|. Therefore, summing over all x 2 W we get
✓ ◆
r mx 1
cr = Â gr (x) = Â ( 1) .
x2W x2W r

(c) Let x 2 W. If x 2 A1 [ A2 [ . . . [ An then mx = 0. By the extended definition


of binomial coefficients in §2.4, 01 = 1, therefore x contributes 1 to cn . Other-
wise mx 1 and mxr 1 = 0. Hence cn = |A1 [ A2 [ . . . [ An |; this is equivalent to
Theorem 3.1.3.
(d) Generalizing (c), each x 2 A1 [ A2 [ . . . [ An contributes 1 to cr , and since r is
even and so ( 1)r mxr 1 0, the contribution from all other x 2 W is non-negative.
Hence cr |A1 [ A2 [ . . . [ An |.
(e) This is very similar to (d).
Solutions to exercises 143

(f) By (b) we have


⇣✓m 1
◆ ✓ ◆
mx 1 ⌘
Â( r x
cr cr+2 = 1) .
x2W r r+2

Since r (n 1)/2 and mx  n 1, it follows from Exercise 2.7 that mxr 1


mx 1
r+2 . Therefore cr cr+2 0 if r is even and cr cr+2  0 if r is odd, as required.

(g) (?) The ‘worst case’ in (f) requires n r 1 n 1


r+2 . If n = 2m is even then, by
2m 1 2m 1
Exercise 2.7, r r+2 if and only if r m 1. If n = 2m + 1 is odd then,
2m 2m
again by Exercise 2.7, r r+2 if and only if r m 1. Therefore we may
take r bn/2c 1 in place of (n 1)/2. To show that no further improvement is
possible, apply the Principle of Inclusion and Exclusion to the case where W is a
singleton set, and A1 , A2 , . . . , An = W.

3.15 (a) Suppose that x 2 W lies in exactly r of the sets A1 , A2 , . . . , An . If r = 0


then x never contributes to the right-hand side. If r = 1 and x 2 Ai then x contributes
to the right-hand side if and only if I = {i}, with coefficient ( 1)0 e1 . We must
therefore take e1 = 1. If r = 2 and x 2 Ai and x 2 A j then x contributes to the right-
hand side if and only if I is a non-empty subset of {i, j}; the coefficient is ( 1)0 e1 +
( 1)0 e1 + ( 1)1 e2 = 1 + 1 e2 . We must therefore take e2 = 2. Continuing this
line of reasoning suggests that the number of elements of W lying in exactly one of
the sets A1 , A2 , . . . , Ar is
n
Â( 1)k 1 k  |AI |.
k=1 I✓{1,2,...,n|
|I|=k

Having guessed the formula it is not hard to prove it by the usual method. Suppose
that x 2 W lies in A j if and only if j 2 J. The contribution from x to the right-hand
side is then
|J| ✓ ◆
|J|
 ( 1) |I| =  ( 1) k k .
|I| 1 k 1
I✓J k=1

|J| |J| 1
By Exercise 2.1 we have k k = |J| k 1 . Hence, by Corollary 2.2.8(ii), the right-
hand side is
|J| ✓ ◆ (
|J| 1 1 if |J| = 1
|J| Â ( 1)k 1 =
k=1 k 1 0 otherwise,
as required.
(b) The argument used to discover the formula in (a) generalizes to suggest that the
144 Solutions to exercises

number of elements of W lying in exactly t of the sets A1 , A2 , . . . , Ar is


n ✓ ◆
k t k
 ( 1) t  |AI |.
k=t I✓{1,2,...,n|
|I|=k

We now prove this. Suppose that x 2 W lies in A j if and only if j 2 J. Then the
contribution from x to the right-hand side is
✓ ◆ |J| ✓ ◆✓ ◆
|I| t |I| k t k |J|
 ( 1) t
= Â ( 1)
t k
.
I✓J k=t
|J| |J| t
By Lemma 2.2.4, kt |J|
k = t k t . Hence, by Corollary 2.2.8(ii), the right-
hand side is
✓ ◆ |J| ✓ ◆ (
|J| k t |J| t 1 if |J| = t
 ( 1)
t k=t k t
=
0 otherwise,
as required.
(c) Define the sets Ai as in §3.2, so Ai is the set of permutations of {1, 2, . . . , n} that
fix i. We saw in this section that |AI | = (n |I|)!. Therefore, by (b), the number of
permutations with exactly t fixed points is
n ✓ ◆✓ ◆ n
k t k n n!
 ( 1)
t k
(n k)! = Â ( 1)k t
(k t)!t!
.
k=t k=t
n t
This is n!
t! 1 1
1! + · · · + ((n1)t)! , as seen in Exercise 1.10.

3.16 This is left to you as an extended exercise on the method of counting contri-
butions.

3.17 (a) Since 1X (x) = 1 if x 2 X and 1X (x) = 0 if x 62 X, we have Âx2W 1X (x) = |X|.
(b) Again by definition of 1X , we have 1B (x)1C (x) = 1 () 1B (x) = 1 and 1C (x) =
1 () x 2 B and x 2 C () x 2 B \C () 1B\C (x) = 1. Therefore 1B 1C = 1B\C .
(c) As in (b), we check that the two sides agree on all x 2 W. Suppose that x 2
A1 [ A2 [ · · · [ An . Then x 2 A j for some j and (1W 1A j )(x) = 1 1 = 0. If x 62
A1 [ A2 [ · · · [ An then (1W 1A j )(x) = 1 for all j. Hence
x 2 A1 [ A2 [ · · · [ An () (1W 1A1 )(1W 1A2 ) . . . (1W 1An )(x) = 1
and so 1A1 [A2 [···[An = (1W 1A1 )(1W 1A2 ) . . . (1W 1An ).
(d) Multiplying out the right hand side above we get ( 1)|I| 1Ai1 . . . 1Aik by taking
Solutions to exercises 145

1Ai from the term 1W 1Ai if i 2 I and 1W if i 62 I. If I = ? we always take 1W


and get 1W = 1A? . Otherwise, by (a), repeatedly applied, we have 1Ai1 1Ai2 . . . 1Aik =
1Ai1 \Ai2 \...\Aik = 1AI . Hence the right-hand side is ÂI✓{1,2,...,n} ( 1)|I| 1AI , as re-
quired.
(e) Summing the result of (d) over all x 2 W we get

 1A [A [···[A (x) = Â
1 2 n  ( 1)|I| 1AI (x)
x2W x2W I✓{1,2,...,n}

= Â ( 1)|I| Â 1A (x)
I
I✓{1,2,...,n} x2W

= Â ( 1)I| |AI |
I✓{1,2,...,n}

where the final equality uses (a).

3.18 (a) Following the hint, we let W be the collection of r-subsets of {1, . . . , m +
n} and aim to count the r-subsets not meeting {m + 1, . . . , m + n}. Let Ai be those
subsets we do not want to count because they contain m + i. Then A1 [ A2 [ . . . [ An
is the collection of r-subsets of {1, . . . , m}. By the Principle of Inclusion and Ex-
clusion, we have
✓ ◆
m
r
= Â ( 1)|I| |AI |.
I✓{1,2,...,n}

An r-subset is in AI if and only if it contains m + i for each i 2 I. This leaves r |I|


elements that can be chosen freely. Hence |AI | = n+m |I|
r |I|
. As we have often seen,
the sizes of the sets AI depends only on |I|. Hence the formula above from the
Principle of Inclusion and Exclusion simplifies to
✓ ◆ n ✓ ◆✓ ◆
m k n n+m k
= Â ( 1)
r k=0 k r k
as required.
(b) Here the challenge is finding a suitable set to count. Considering how k varies
and the terms n2ns 2k2k , one guess is that we should let W be the collection of all
(n s)-subsets of a set of size 2n. If you reason from the case k = 1 that each Ai
should contain exactly n2n2 2s of these (n s)-subsets, you may find the solution
outlined below.
Let Ai be those (n s)-subsets of {1, 2, . . . , 2n} that contain {2i, 2i + 1}. Then
A1 [ A2 [ . . . [ An is those (n s)-subsets having at most one element of each of
{1, 2}, {3, 4}, . . . , {2n 1, 2n}. There are 2n s n n s such subsets. Since AI is those
146 Solutions to exercises
S
(n s)-subsets of {1, 2, . . . , 2n} that contain the 2k elements i2I {2i, 2i + 1}, we
have |AI | = n2ns 2k2k . Hence, by the Principle of Inclusion and Exclusion,
✓ ◆ n ✓ ◆✓ ◆
n k n 2n 2k
2 n s
= Â ( 1) .
n s k=0 k n s 2k
n n
Since n s =s , by Lemma 2.1.5, this is equivalent to the identity. Rewriting
2n 2k 2n 2k
n s 2k as n+s , changing the the summation variable to n k and applying
n n k n 2k n n s n
Lemma 2.1.5 to n k we get Âk=0 ( 1) k n+s = ( 1) 2 s .

(c) Let S = {1, 2, . . . , n} ⇥ {1, 2, . . . , m} and let W be the set of all (n + 1)-subsets
of S. Say that X 2 W is admissible if for all i 2 {1, 2, . . . , n} there exists r 2
{1, 2, . . . , m} such that (i, r) 2 X. Let a be the number of admissible subsets. For
each i 2 {1, 2, . . . , n} let

Ai = X 2 W : (i, r) 62 X for any r 2 {1, . . . , m} .

Thus Ai is those subsets that are inadmissible (and we do not want to count) because
they contain no pair with first entry i. By the Principle of Inclusion and Exclusion

a = |A1 [ A2 [ · · · [ An | = Â ( 1)|I| AI
I✓{1,2,...,n}

For any I ✓ {1, . . . , n} we have

AI = X 2 W : X ✓ ({1, . . . , n}\I) ⇥ {1, . . . , m} .


(n |I|)m
Therefore |AI | = n+1 . Summing over I ✓ {1, . . . , k} according to their size k
we get
n ✓ ◆✓ ◆
n (n k)m
a = Â ( 1) k
.
k=0 k n+1

On the other hand, we can construct an admissible (n + 1)-subset of S by choosing


(1, r1 ), . . . , (n, rn ) 2 S in mn ways, and then choosing any remaining element of S in
mn n ways. This double counts each admissible subset X since if (i, r) 2 X and
(i, r0 ) 2 X are distinct then either (i, r) or (i, r0 ) could have been the final element
chosen. Therefore
mn (mn n) n n+1
a= = m mn .
2 2
The identity follows by equating the two expressions for a.
3.19 As suggested, let W be the set of functions f : {1, 2, . . . , n} ! {1, 2, . . . , n}
having no fixed points. Let Ai be those functions we do not want to count because i
is not in their range. The set of derangements is then A1 [ A2 [ . . . [ An . To construct
Solutions to exercises 147

f 2 Ai we have n 2 choices for f (x) for each x 6= i, and n 1 choices for f (i).
Therefore |Ai | = (n 2)n 1 (n 1). More generally, if |I| = k then

|AI | = (n k 1)k (n k)n k .

Since there are nk subsets I of size k, it follows from the Principle of Inclusion
and Exclusion that
n ✓ ◆
n
dn = Â (n k 1)k (n k)n k .
k=0 k

Here we started with a set of fixed-point-free functions, and threw out those that
were not injective (and so were not permutations); by comparison, in §3.2 we
started with a set of permutations and threw out those that had a fixed point.

4. Rook polynomials
Exercise 4.1.2 A single rook is always non-attacking so r1 (B) is the number of
squares in B. Since there is a unique rook placement with no rooks, r0 (B) = 1 for
any board B.

Exercise 4.1.3 By the previous exercise r0 (B) = 1 and r1 (B) = 6. The non-
attacking placements with two rooks are enumerated according to the position of
the highest rook in the left diagram below. For instance, the three placements with
the highest rook in the box in the middle of the top row are shown to the right.

3 3 R R R
2 1 R
R R
Therefore r2 (B) = 9. The two diagrams below show that rB (3) = 2. Hence fB (z) =
1 + 6z + 9z2 + 2z3 .

R R
R R
R R
Exercise 4.1.4 By Exercise 4.1.3, there are 9 placements of 2 rooks and 2 place-
ments of 3 rooks not having a rook in the top-left corner. If there is a rook in this
corner then the remaining rooks are on the board of unshaded squares in the margin.
Hence r2 (B) = 9 + 2 = 11 and r3 (3) = 2 + 1 = 3 and so fB (z) = 1 + 7z + 11z2 + 3z3 .
148 Solutions to exercises

Exercise 4.3.4 Applying Lemma 4.2.1 to Bn , using the square in the top-right
corner as instructed, we get

fBn (z) = fS2n 1 (z) + z fS2(n 1) 1 (z)


n ✓ ◆ n ✓ ◆
2n k k 2(n 1) k k
= z +z  z
k=0 k k=0 k
n ⇣✓ ◆ ✓ ◆
2n k 2n k 1 ⌘ k
= 1+ Â + z
k=1 k k 1
n ✓ ◆
2n k k
= 1+ Â 1+ zk
k=1 k 2n k
n ✓ ◆
2n k 2n k
= 1+ Â z
k=1 k 2n k
2n k 1 2n
where the fourth equality uses the identity (2n k) k 1 =k k ; this is an
instance of Exercise 2.1.

Exercise 4.3.7 Since g` (z) is the rook polynomial of the board B2` , the coefficient
of zk in zn ` g` is rk (n `) (B2` ) for each k 2 {n `, . . . , n}. Therefore Corollary 4.3.3
implies that
n n
rn (B) = Â a` Â ( 1)k rk (n `) (B2` )(n k)!
`=0 k=n `
n `
= Â a` Â ( 1) j+(n `)
r j (B2` )(` j)!
`=0 j=0
n
= Â a` ( 1)n ` r` (B2` )
`=0
n
= Â( 1)n ` u`
`=0

where the third inequality uses Corollary 4.3.3 applied to B2` .

End of chapter exercises

4.1 Using Exercise 4.1.2 and a direct count of the number of placements of 2
rooks we get f (z) = 1 + 3z + z2 , f (z) = 1 + 4z + 2z2 , f (z) = 1 + 5z + 4z2 .
The final board could also be done by a direct count, or by the method in Ex-
ercise 4.1.3, but instead we apply Lemma 4.2.1 to the square in the bottom-left
corner. Deleting this square gives the third board, while deleting its entire row and
Solutions to exercises 149

column gives the first board. Hence


f (z) = f (z) + z f (z)

= 1 + 5z + 4z2 + z(1 + 3z + z2 )
= 1 + 6z + 7z2 + z3 .
4.2 To put k non-attacking rooks on the m ⇥ n grid we can choose k rows in mk
ways and k columns in nk ways. We must then put k rooks on the k ⇥ k subboard
of squares in the chosen rows and column; by the bijection between non-attacking
rook placements and permutations seen in Example 4.1.6, this can be done in k!
ways. Therefore the coefficient of zk is mk nk k!, as required.
4.3 (a) As seen in Example 4.1.6, there is a bijection between permutations of
{1, 2, 3, 4, 5} and ways to place five non-attacking rooks on the squares of a 5 ⇥ 5
grid: a permutation s corresponds to the rook placement with rooks in positions
(i, s (i)) for each i 2 {1, 2, 3, 4, 5}. Derangements correspond to rook placements
with no rooks on the diagonal. Moreover
• s (i) 6= i + 1 if 1  i  4 rules out the squares (1, 2), (2, 3), (3, 4), (4, 5), below
the diagonal,
• s (i) 6= i 1 if 2  i  5 rules out the squares (2, 1), (3, 2), (4, 3), (5, 4) above the
diagonal.
Therefore derangements in T are in bijection with non-attacking rook placements
of 5 rooks on the board of unshaded squares. For example, the permutation s
defined by s (1) = 3, s (2) = 4, s (3) = 5, s (4) = 2, s (5) = 1 corresponds to
the non-attacking placement shown below.

? R
R
R ?
R
R
(b) Suppose that neither starred square is occupied. Then all rooks lie in the un-
shaded squares below.
?

?
150 Solutions to exercises

No square in the bottom-left subboard lies in the same row or column as a square in
the top-right subboard. Hence, by Lemma 4.2.2 and Exercise 4.1, the contribution
to the rook polynomial from this case is
f (z) f (z) = (1 + 4z + 2z2 )(1 + 6z + 7z2 + z3 )
= 1 + 10z + 33z2 + 41z3 + 18z4 + 2z5 .
If the only starred square occupied is the one in position (1, 3) then all other rooks
are on the unshaded squares below.
?

Taking into account that one rook is already placed, the contribution to the rook
polynomial is
zf (z) f (z) = z(1 + 2z)(1 + 5z + 4z2 )
= z + 7z2 + 14z3 + 8z4 .
By symmetry we get the same contribution to the rook polynomial if the other
starred square is the only occupied starred square. Finally, as stated in the question,
if both starred squares are occupied, the contribution to the rook polynomial is
z2 f (z) f (z) = z2 (1 + z)(1 + 4z + 2z2 )
= z2 + 5z3 + 6z4 + 2z5 .
Adding up these four contributions shows that the rook polynomial of the original
board is
(1 + 10z + 33z2 + 41z3 + 18z4 + 2z5 ) + 2(z + 7z2 + 14z3 + 8z4 )
+ (z2 + 5z3 + 6z4 + 2z5 ) = 1 + 12z + 48z2 + 74z3 + 40z4 + 4z5 .
(c) By Corollary 4.3.3, the number of placements of five non-attacking rooks on
the shaded squares forming the complement B of B is
5!r0 (B) 4!r1 (B) + 3!r2 (B) 2!r3 (B) + 1!r4 (B) 0!r5 (B)
= 120 288 + 288 148 + 40 4 = 8.
(d) (?) Let Ai be the set of non-attacking placements of four rooks on the 5 ⇥ 5
grid in which there is a rook in row x and this rook is on a square in B. The sum
ÂI✓{1,...,n}:|I|=k |AI | of the sizes of all intersections of exactly k of the Ai is the
number of ways to put down k red rooks on squares in B and 4 k blue rooks
Solutions to exercises 151
2
anywhere on the grid. By the argument in Lemma 6.9, this quantity is 54 kk (4
k)! rk (B). Hence using 2(b) we find that there are
✓ ◆2 ✓ ◆2 ✓ ◆2 ✓ ◆2 ✓ ◆2
5 4 3 2 1
4! r0 (B) 3! r1 (B) + 2! r2 (B) 1! r3 (B) + 0! r4 (B)
4 3 2 1 0
= 52 .24.1 42 .6.12 + 32 .2.48 22 .1.74 + 40
= 600 1152 + 864 296 + 40 = 56
ways to put four non-attacking rooks on the shaded squares.
4.4 (a) If we take a board with a non-attacking rook placement and swap two
rows then each row still has at most one rook in it, as does each column. Hence the
rook placement on the new board is still non-attacking. Since any row permutation
can be obtained by repeated swapping of rows, this shows that permuting the rows
does not change the rook polynomial. Similarly for columns.
(b) The board B in Example 4.1.5 is formed from the unshaded squares in the
diagram left below.

We aim to permute the rows and column of B to obtain its complement B, shown
right above. Note that the rows of B have, from top to bottom, 3, 1, 2 and 2 unshaded
squares. So the only chance is to swap rows 1 and 2. This gives the board below.

Then we must move column 4 to column 2, since this is the only column to have a
shaded square in row 2. Swapping these columns we get the board below.

Finally swapping rows 3 and 4 gives B, shown below.


152 Solutions to exercises

Hence, by (a), B and B have the same rook polynomial.


4.5 (a) Using Exercise 4.1.2 and the method of Exercise 4.1.3 it is routine to show
that fS1 (zz) = 1 + z, fS2 (z) = 1 + 2z, fS3 (z) = 1 + 3z + z2 , fS4 (z) = 1 + 4z + 3z2 . The
rook polynomial fS5 (z) = 1 + 5z + 6z2 + z3 was found at the start of the chapter.
(b) Applying Lemma 4.2.1 to the bottom right square in S6 (shown in the margin)
we get
fS6 (z) = fS5 (z) + z fS4 (z)
= 1 + 5z + 6z2 + z3 + z(1 + 4z + 3z2 )
= 1 + 6z + 10z2 + 4z3 .

(c) Looking at the Pascal’s Triangle on page 23 one can spot the coefficients in
f5 and f6 on the southwest to northeast diagonals. For instance, the coefficients
of f6 are 1 = 70 , 6 = 61 , 10 = 52 , 4 = 43 . This suggests the conjecture that
rSn (k) = n k+1
k .
(d) The routine proof uses Lemma 4.2.1 to split the board on the bottom-left square.
As seen in (b), removing this square gives Sm 1 , while removing this square and all
squares in its row and column gives Sm 2 . Therefore by the lemma and induction
we have
fSm (z) = fSm 1 (z) + z fSm 2 (z)
✓ ◆ ✓ ◆
(m 1) k + 1 k (m 2) k + 1 k
= z +z z
k k k k
✓ ◆ ✓ ◆
m k k m k 1 k+1
=Â z +Â z
k k k k
⇣✓m k◆ ✓m k◆⌘
=Â + zk
k k k 1
✓ ◆
m k+1 k
=Â z
k k
where the final step uses the Fundamental Recurrence (Lemma 2.1.7). The base
cases fS1 (z) = 1 + z and fS2 (z) = 1 + 2z are easily checked.
Alternatively, observe that if we number the squares in the staircase board Sm from
Solutions to exercises 153

1 at the top-left to m in the bottom-right, as shown by the diagram in the margin 1 2


for S6 , then a rook placement on Sm is non-attacking if and only if no two rooks 3 4
lie on consecutively numbered suqares. Therefore there is a bijection between non- 5 6
attacking placements of k rooks on Sm and placements of k lions into m cages as in
Exercise 2.4. By this exercise, there are m kk+1 placements.

4.6 As usual A? is the universe set W of all non-attacking placements of 3 rooks


on the 3 ⇥ 3 grid; as seen in Example 4.1.6 these correspond to the 3! = 6 permu-
tations of {1, 2, 3}:
8 9
>
<R R R R R R> =
A? = R R R R R R .
>
: >
;
R R R R R R
This is also the set C0 , since no rooks need to be coloured. As expected |C0 | =
r0 (B)3! = 6. By definition A{1} consists of those non-attacking rook placements
where the rook on row 1 is on B; since the only shaded square in row 1 is in
column 1, we have
8 9
> >
<R
> R >
=
A{1} = R R> .
>
> >
: ;
R R
Similarly A{2} consists of the two placements with a rook on the middle square,
and A{3} of the two placements with a rook on the bottom-right square. Therefore
the set C1 is as stated in the question
The set A{1,2} consists of those non-attacking rook placements where the rooks on
rows 1 and row 2 are on B; there is a unique such placement and
8 9
> >
<R
> >
=
A{1,2} = A{1,3} = A{2,3} = R > .
>
> >
: ;
R
These equal sets are distinguished in the proof of Lemma 4.3.2 by colouring rooks,
giving
8 9
> >
<r
> r R >
=
C2 =
>
>
r R r > >
.
: ;
R r r
Hence |C2 | = 3 agreeing with |A{1,2} | + |A{1,3} | + |A{2,3} | = 1 + 1 + 1 = 3 and
154 Solutions to exercises

r2 (B)(3 2)! = 3 ⇥ 1! = 3. Finally


8 9 8 9
> > > >
<R
> >
= >
< r >
=
A{1,2,3} = R , C3 = r .
>
> >
> >
> >
>
: ; : ;
R r
Hence |C3 | = 1 agreeing with |A{1,2,3} | = 1 and r3 (B)(3 3)! = 1 ⇥ 0! = 1.

4.7 Let B be the board of shaded square shown below

(a) By Lemma 4.2.2, we have

fB (z) = (1 + 6z + 9z2 + 2z3 )(1 + 4z + 2z2 ) = 1 + 10z + 35z2 + 50z3 + 26z4 + 4z5 .

Hence, by Corollary 4.3.3, the number of ways to put five non-attacking rooks on B
is 5! 10 ⇥ 4! + 35 ⇥ 3! 50 ⇥ 2! + 26 ⇥ 1! 4 ⇥ 0! = 12.
(b) Suppose we put down five non-attacking rooks on B, in positions (1, j1 ), (2, j2 ),
(3, j3 ), (4, j4 ), (5, j5 ). Then j1 62 {1, 2}, j2 62 {2, 3}, j3 62 {1, 3}, j4 62 {4, 5} and j5 62
{4, 5} and j1 , j2 , j3 , j4 , J5 are distinct. Therefore we can extend the Latin rectangle
to a 3⇥n Latin rectangle with third row j1 j2 j3 j4 j5 . Conversely, any allowable third
row corresponds to a way to put five non-attacking rooks on B. Therefore there are
12 extensions to a 3 ⇥ n Latin rectangle.
(c) Since fB (z) = g3 (z)g2 (z) = g5 (z) + z4 g1 (z) by Proposition 4.3.6, it follows from
Exercise 4.3.7 that r5 (B) = u5 + u1 .

4.8 Let B be the board of shaded squares below.

By the bijection seen in Example 4.1.6, the permutations of {1, 2, 3, 4, 5, 6} with


no even fixed point are in bijection with non-attacking placements of 6 rooks on B.
Solutions to exercises 155

The rook polynomial of B is (1+z)3 = 1+3z+3z2 +z3 . Hence, by Corollary 4.3.3,


the number of such permutations is

r6 (B) = 6! 5! ⇥ 3 + 4! ⇥ 3 3! = 720 360 + 72 6 = 426.

4.9 (a) The following M ATHEMATICA code implements Lemma 4.2.1.

RookPolynomial[{}] := 1
DS[{i_, j_}, bs__] := DeleteCases[bs, {i, j}]
ES[{i_, j_}, bs__]
:= DeleteCases[bs, {iP_, jP_} /; Or[iP == i, jP == j]]
RookPolynomial[{{i_, j_}, bs___}]
:= RookPolynomial[DS[{i, j}, List[bs]]]
+ z*RookPolynomial[ES[{i, j}, List[bs]]]

For example RookPolynomial[{{1,1},{1,2},{2,1},{2,2}}] evaluates to 1+


4z + 2z2 . The ‘helper’ functions DS and ES create the boards D and E required in
Lemma 4.2.1. In the main function, the pattern {{i_, j_}, bs___} matches an
arbitrary non-empty list of squares, binding i and j to the position of the first
square and bs to the remaining squares. After this bs is stored as a M ATHEMAT-
ICA sequence, suitable for use as the collection of arguments to a function; it has
to be converted back to a list by the List function in the recursive step.

(b), (c) M ATHEMATICA code for these refined algorithms may be downloaded from
the author’s website (see page 4). An alternative implementation in the functional
programming language H ASKELL is also available.

(d) Using the algorithm in (c) that applies Lemma 4.2.2 where possible, the rook
polynomial of the ‘coffee’ board is computed in 86 seconds on a 2015 MacBook
Pro in M ATHEMATICA. The compiled Haskell code takes 12 seconds. The simpler
algorithms in (a) and (b) cannot compute this rook polynomial in a reasonable time.

4.10 (a) The summand ’ni=1 Mis (i) in per M is 0 unless Mis (i) = 1 for all i; if this
condition holds the summand is 1. Therefore the permanent counts the number of
ways to put n non-attacking rooks on the n ⇥ n grid so that every rook is in a square
(i, j) such that Mi j = 1. This is the coefficient of zn in fB (z).

(b) Choose notation so that H(B) has bipartition {1, . . . , n} [ {10 , . . . , n0 } where
vertices {1, . . . , n} to the rows and vertices {10 , . . . , n0 } correspond to the columns.
For instance, replacing Profs. W, X, Y, Z with 10 , 20 , 30 , 40 , the example graph and
matching are shown on the left below.
156 Solutions to exercises

10 20 30 40

10

20

30

40

1 R
!
2 R
• • • •
3 R
1 2 3 4 4 R
There is a bijection between placements of n non-attacking rooks on B and match-
ings in H(B) in which we choose the edge {i, j0 } if and only if there is a rook on
the square (i, j). The non-attacking rook placement corresponding to the matching
in the example is shown on the right above. Hence, by (a), per M(B) is the number
of matchings in H(B).
(c) A board B contained in the n ⇥ n grid given as a list of squares can be turned
into the n ⇥ n matrix M(B) with 0, 1 entries in time O(n2 ). Similarly one can go
turn such a matrix into a board, also in time O(n2 ). The problems of finding the
coefficient of zn in fB (z) and computing per M(B) are therefore polynomial time
equivalent. By Valiant’s result, both are in #P, the complexity class of counting the
number of accepting states of a non-deterministic Turing Machine that promises to
run in polynomial time.
Perhaps surprisingly, it is possible to decide in polynomial time if fB (z) is non-
zero. This is most easily seen using (b): there are algorithms that run in time poly-
nomial in n and return either a complete matching in the graph H(B), or a subset
X ✓ {1, 2, . . . , n} such that X has strictly fewer than |X| neighbours in {10 , . . . , n0 }.
See for instance the algorithmic proof of Hall’s Marriage Theorem on page 27 of
Bryant (1993). Alternatively one can apply the Ford–Fulkerson Algorithm (which
you might have seen used to prove the Max-flow Min-cut Theorem) to the network
version of H(B).
Therefore, unless P = NP, it is strictly harder to compute the coefficient of zn in
fB (z) than to decide if it is non-zero.
n 1 n
4.11 (a) By Exercise 4.2, the rook polynomial of the n 1⇥n grid is Ânk=0 k k k!.
Hence
✓ ◆✓ ◆ ✓ ◆
n n 1 n n 1 n!
= (n k)! =
k n k n k k 1 k!
as required.
(b) By Exercise 2.5, swapping the roles of k and n, there are nk 11 solutions to the
equation u1 + u2 + · · · + uk = n with ur 2 N for each r. Fix such a solution. We then
choose a permutation s : {1, 2, . . . , n} ! {1, 2, . . . , n} and put balls s (1), . . . , s (u1 )
into tube 1, balls s (u1 + 1), . . . , s (u1 + u2 ) into tube 2, and so on. This shows that
Solutions to exercises 157

there are nk 1
1 n! ways to put n labelled balls into k labelled tubes. By (a), this
n
number is k! k .
(c) Given a placement of n labelled balls into k unlabelled tubes so that each tube
is non-empty, we can distinguish the tubes using the balls at their bottoms, and so
label them in k! ways. This gives a placement of n labelled balls into k labelled
urns; by (b) there are k! nk such placements. Hence the number of placements into
unlabelled tubes is nk .

(d) (?) A non-attacking placement of n k rooks on the (n 1) ⇥ n grid has ex-


actly k empty columns. Suppose that columns c1 , . . . , ck are empty. Put balls c1 , . . . ,
ck at the bottom of the k tubes; this labels the tubes 1, 2, . . . , k. Now scanning from
row 1 downwards, find the column of each rook, and put the corresponding ball in
tube 1, stopping at the first empty row. Then continue with tube 2, and so on. Since
there are k 1 empty rows we make k scans; these specify the remaining balls in
each of the k urns. An example with n = 7 and k = 3 is shown below.

1 2 3 4 5 6 7
1 R
2 R 3 4
3
! 6 1
4
5 R 2 5 7
6 R 1 2 3

Note that the second scan finishes immediately since row 4 is empty. Therefore
tube 2 contains only ball number 5.
Constructing the inverse map from ball-and-tube placements to rook placements is
left as an exercise: for a detailed solution see pages 15 and 16 of Butler et al. (n.d.).

4.12 (a) Clearly ht (B) kt is the number of ways to put n non-attacking rooks on
the n ⇥ n grid so that exactly t on B and then to colour k of the rooks on B black.
Alternatively, we can construct such a coloured rook placement by first putting k
non-attacking black rooks on B and then n k white rooks on the rest of the grid,
so that all n rooks are non-attacking. As seen in the proof of Lemma 4.3.2, we can
do this in rk (B)(n k)! ways.
(b) By the Binomial Theorem,
n n t ✓ ◆
t
 ht (B)(1 + z) =   ht (B) k zk .
t
t=0 t=0 k=0
158 Solutions to exercises
t
The coefficient of zk on the right-hand side is Ât ht (B) k ; by (a) this is rk (B)(n
k)!. This proves the first identity. Now substitute w = z 1 to get the second.
(c) Substituting w = 0 the left-hand side is replaced with its constant term h0 (B),
so we have
n
h0 (B) = Â rk (B)(n k)!( 1)k
k=0

as first proved in Corollary 4.3.3.


(d) Let B be the board of diagonal square in the n ⇥ n grid. By the usual cor-
respondence seen in Example 4.1.6 between non-attacking rook placements and
permutation, the hit number ht (B) is the number of permutations of {1, 2, . . . , n}
with precisely t fixed points, namely an (t). Since rk (B) = nk , it follows from (b)
in the previous question that
n n ✓ ◆
n
 ht (B)w =  k (n k)!(w 1)k .
t
t=0 k=0

Taking the coefficient of wt on the right-hand side, we get


n ✓ ◆ ✓ ◆
n k n! n ( 1)t k
an (t) = Â (n k)!( 1)t k = Â
k=0 k t t! k=t (t k)!
n k n!
where the final equality uses k t (n k)! = t!(k t)! .

(e) Let Bn be the board contained in the n ⇥ n grid used to solve the Problème des
Ménages used in §4.3. By Exercise 4.12(b), we have
n n
 ht (B)wt =  rk (B)(n k)!(w 1)k .
t=0 k=0
2n k 2n
By Exercise 4.3.4, rk (B) = k 2n k . Hence taking the coefficient of wt as in the
previous exercise, we get
n ✓ ◆ ✓ ◆
2n k k
ht (B) = Â (n k)! ( 1)k t .
k=t k t
Now following the argument in §4.3, we seat the men in n! ways in the odd-
numbered seats, and the women in ht (B) ways in the even numbered seats, thus
putting t couples into adjacent seats. Multiplying by 2 as before to count the place-
ments with men in even-numbered seats we get 2n! Ânk=t 2nk k (n k)! kt ( 1)k t
placements.
4.13 Let Ai be those placements of m non-attacking rooks on the n ⇥ n grid that
we do not want to count because there is a rook in row i and this rook is on B.
Solutions to exercises 159

Generalizing the colouring argument used to prove Lemma 4.3.2, suppose that we
2
put k non-attacking black rooks on B. We then have mn kk (m k)! ways to put
m k white rooks on the grid so that all m rooks are non-attacking. Therefore
✓ ◆
n k 2
 |AI | = rk (B) m k (m k)!
I✓{1,2,...,n}
|I|=k

and using the Principle of Inclusion and Exclusion as in the proof of Corollary 4.3.3,
we get
✓ ◆
m
n k 2
rm (B) = Â ( 1) rk (B)
k
(m k)!
k=0 m k

as required.

4.14 (a) Label the squares of Bn by the numbers 1, 2, . . . , 2m 1, 2m from top-left


to bottom row, as shown on the left below for B4 . Then rk (Bn ) is the number of
ways to put k rooks on the squares of Bn so that no two rooks are on squares with
consecutive numbers. (Regard 2m + 1 as 1.)

1
1 2 8 •
• •2
3 4
7• •3
5 6
8 7 • •
6 • 4
5

Labelling the vertices of the graph C2n as shown on the right above for C8 , it is
clear the number of such placements is rk (C2n ).

(b) A similar argument to (a) shows that the graph corresponding to the staircase
board Sm is the line with m vertices, shown below.
• • ... •
1 2 m

Therefore, splitting placements of k rooks on Cm according to whether or not there


is a rook on vertex m, we count rk (Sm 1 ) placements with no rook on vertex m,
and rk 1 (Sm 3 ) placements with a rook on vertex m (and so no rook on either
vertex 1 or vertex m 1). Hence rk (Cm ) = rk (Sm 1 ) + rk 1 (Sm 3 ) and so fCm (z) =
fSm 1 (z) + z fSm 3 (z), as seen earlier for B2m using Lemma 4.2.1. The calculation in
m k m k
Exercise 4.3.4 now shows that fCm (z) = Âm k=0 k m kz .

(c) It is equivalent to show that rk (Cm 1 ) + rk 1 (Cm 2 ) = rk (Cm ). By (b), the left-
160 Solutions to exercises

hand side is
✓ ◆ ✓ ◆
m 1 k m 1 m 1 k m 2
+
k m 1 k k 1 m 1 k
✓ ◆
m k 1 (m 2k)(m 1) k(m 2)
= +
k m 1 k m k m k
✓ ◆
m k m (m 2k)(m 1) + k(m 2)
=
k m k m(m 1 k)
✓ ◆
m k m
=
k m k
which is rk (Cm ) by another application of (b). As mentioned in the question, there
is a much more enlightening proof using Exercise 4.18(e): if u is any vertex of Cm
then Cm /u is Cm 1 and Cm //u is Cm 2 , and so, by this exercise, pm (z) = pm 1 (z) +
zpm 2 (z).
(d) Using the given polynomials we have p2 (z)2 = (1 + 2z)2 = 1 + 4z + 4z2 =
(1 + 4z + 2z2 ) + 2z2 = p4 (z) + z2 p0 (z) and p3 (z)p2 (z) = (1 + 3z)(1 + 2z) = 1 +
5z + 6z2 = (1 + 5z + 5z2 ) + z2 = p5 (z) + z3 p1 (z). Using (c) to get the first and last
equalities below, and the inductive hypothesis for the second, we have
pm (z)p2 (z) = pm 1 (z)p2 (z) + zpm 2 p2 (z)

= pm+1 (z) + z pm 3 (z) + zpm (z) + z3 pm 4 (z)


2

= pm+1 (z) + zpm (z) + z2 pm 3 (z) + zpm 4 (z)


= pm+2 (z) + z2 pm 2 (z)
as required.

g1 (w) = wn gn ( w 1 )wg1 ( w 1 ) = wn+1 p2n ( w 1 )p2 ( w 1 ).


(e) We have gen (w)e
By (d) this is
wn+1 p2(n+1) ( w 1 ) + ( w 1 )2 p2(n 1) ( w 1)
= wn+1 gn+1 ( w 1 ) + w n 1
gn 1 ( w 1 )
= gen+1 (w) + gen 1 (w).

(f) Since ge1 (w) = w 2 generates the polynomial ring C[w], there is a unique
ring homomorphism C[w] ! C[t 1 ,t] that sends w 2 to t 1 + t and satisfies
q h(w)(w 2) = q h(w) q (w 2) for all h(w) 2 C[w]. Suppose, inductively,
that q gem (w) = t m + t m for m  n. Then
q gen (w)(w 2) = q gen (w) q (w 2)
n n 1
= (t + t )(t + t) = t (n+1)
+ t n+1 + t (n 1)
+ t n 1.
Solutions to exercises 161

By (e), the left-hand side is q gen+1 (w) + gen 1 (w) , and since q is a ring homo-
morphism, this is q gen+1 (w) + q gen 1 (w) . Since q gen 1 (w) = t (n 1) + t n 1 ,
it follows that q gen+1 (w) = t (n+1) +t n+1 , as required for the inductive step. Since
a polynomial of degree d in C[w] is sent to a polynomial in C[t 1 ,t] with leading
term t d , the homomorphism q is injective.
(g) Since q is a ring homomorphism,
2
q gen (w)2 = q gen (w) = (t n
+ t n )2 = t 2n
+ 2 + t 2n = q ge2n (w) + w .
Since q is injective, it follows that gen (w)2 = ge2n (w) + 2, or equivalently, that
2
wn gn ( w 1 ) = w2n g2n ( w 1 ) + 2.
2
Replacing w 1 with z we get ( z 1 )n gn (z) = ( z 1 )2n g2n (z)+2. Multiplying
through by z2n we get gn (z)2 = g2n (z) + 2z2n .
(h) This follows in the same way as (g), using the identity
m
(t `
+ t ` )(t + t m) = t (`+m)
+ t `+m + t (` m)
+ t` m
.

(i) (?) Label the vertices of C2n by 1, 2, . . . , 2n as shown in (a) for the case n = 4.
Let k < n. Given a placement of k rooks on the vertices of C2n with no two rooks
adjacent, there exists j  n such that neither j nor j + n has a rook. Choose j
minimal with this property, and split the cycle into two n-cycles with vertices
1, 2, . . . , j, j + n + 1, . . . , 2n and j + 1, . . . , j + n, keeping rooks on their chosen ver-
tices. Construction of the inverse map is left as an exercise: see Ilya Bogdanov’s
answer to MathOverflow Question 364978. Since rBm (m) = 2 for all m 2 N, this
bijection does all the work needed to prove that gn (z)2 = g2n (z) + 2.
4.15 (a) Since n = 2c2 + · · · + ncn , we have
wn fB ( w 1 ) = wn g2 ( w 1 )c2 . . . gn ( w 1 )cn
c2 cn
= (w2 g2 ( w 1 ) . . . (wn gn ( w 1 ) = gec22 . . . gecnn .

(b) The coefficient of t m in the right-hand side is the number of ways to write
m = 2c+
2 2c2 + 3c+
3 3c3 + · · · + nc+
n + ncn

where c+ k + ck = ck for each k. Since kck


+
kck has the same parity as kc+
k + kck =
m
kck , and 2c2 + · · · + ncn = n, if t has a non-zero coefficient then n  m  n and m
and n have the same parity.
(c) Applying the ring homomorphism q from Exercise 4.14(f) we get
c2 cn
q wn fB ( w 1 ) = q ge2 (w) . . . q gen (w)
= (t 2
+ t 2 )c2 . . . (t n
+ t n )cn = Â b` (t (n 2`)
+ tn 2`
).
0`n/2
162 Solutions to exercises

Since q is injective and q Â0`n/2 b` gen 2` (w) is equal to the right-hand side,
we have wn fB ( w 1 ) = Â0`n/2 b` gen 2` (w). Now replace w with z 1 and use
gen 2` (w) = wn 2` gn 2` ( w 1 ) to get

( z 1 )n fB (z) = Â ( z)n 2`
b` gn 2` (z).
0`n/2

Finally multiplying through by ( z)n gives fB (z) = Â0`n/2 b` z2` gn 2` (z).

(d) Apply Exercise 4.3.7 to (c) to get rn (B) = Â0`n/2 b` un 2` .

(f) Let B be the board contained in the mc ⇥ mc grid used in the proof of Proposi-
tion 4.3.8. By (d) we have rmc (B) = Â0`mc/2 b` umc 2` where the coefficients b`
are defined by
(t m
+ t m )c = Â b` (t (n 2`)
+ tn 2`
).
0`mc

By the Binomial Theorem, the left-hand side is


c ✓ ◆ c ✓ ◆
c c
 k t mc m(c k)
t = Â k (t m(c 2k)
+ t m(c 2k)
).
k=0 k=0

c
Comparing coefficients, we see that rmc (B) = Â0kc/2 k um(c 2k) as required.

4.16 (a) Since


2
(t + t 2 )(t 3
+ t 3 )(t 4
+ t 4 ) = (t 1
+ t) + (t 3
+ t 3 ) + (t 5
+ t 5 ) + (t 9
+ t 9)

it follows from Exercise 4.15(d) that fB (z) = z8 g1 (z) + z6 g3 (z) + z4 g5 (z) + g9 (z)
and r9 (B) = u1 + u3 + u5 + u9 .
(b) Since (t 1 +t)(t 2 +t 2 )(t 3 +t 3 )(t 4 +t 4 ) = 2(t 2 +t 2 ) + 2(t 4 +t 4 ) + (t 6 +
t 6 ) + (t 8 + t 8 ) + (t 10 + t 10 ) the generalization of Exercise 4.15(d) to products
involving g1 (z) implies that

(1 + 2z) fB (z) = 2z8 g2 (z) + 2z6 g4 (z) + 4z4 g6 (z) + z2 g8 (z) + g10 (z).

Since f (z) = 1 + z = (1 + 2z) z and, by Lemma 4.2.2, fC (z) = (1 + z) fB (z), we


have
fC (z) = (1 + 2z) fB (z) z fB (z) = z9 g1 (z) + 2z8 g2 (z) z7 g3 (z)
+ 2z6 g4 (z) z5 g5 (z) + z4 g6 (z) + z2 g8 (z) zg9 (z) + g10 (z).

Hence by Exercise 4.3.7, noting the signs, we get r10 (B) = u1 + 2u2 + u3 + 2u4 +
u5 + u6 + u8 + u9 + u10 .
Solutions to exercises 163

4.17 (a) A permutation f : {1, 2, . . . , n} ! {1, 2, . . . , n} is discordant with both s


and t if and only if f (i) 62 {s (i), t(i)} for each i, and so, if and only if s 1 f (i) 62
{i, s 1 t(i)}. Therefore the function sending f to s 1 f is a bijection between per-
mutations discordant with both s and t and permutations discordant with both the
identity and s 1 t.
(b) Let s : {1, 2 . . . , n} ! {1, 2, . . . , n} be the n-cycle defined by s (1) = 2, s (2) =
3, . . . , s (n) = 1. Placements of n non-attacking rooks on Dn correspond to permu-
tations discordant with both s and s 1 . By (a), such permutations are in bijection
with permutations discordant with both the identity and s 2 . Let B be the board of
diagonal squares in the n ⇥ n grid and all squares i, s 2 (i) .
If n = 2m + 1 is odd then s 2 is the n-cycle (1, 3, . . . , 2m + 1, 2, . . . , 2m). Hence the
rows and columns of B can be reordered, as shown below for the case n = 5, so
that B becomes the board Bn used in the Problème des Ménages. (This reordering
is generalized in the proof of Lemma 9.4.1.)

1 2 3 4 5 1 3 5 2 4
1 1
2 3
3 ! 5
4 2
5 4

If n = 2m is even then s 2 = (1, 3, . . . , 2m 1)(2, 4, . . . , 2m) written in disjoint cycle


notation. Hence the rows and columns of B can be reordered, as shown below for
the case n = 6, so that B is two disjoint copies of the board Bm .
1 2 3 4 5 6 1 3 5 2 4 6
1 1
2 3
3 5
4 ! 2
5 4
6 6

Therefore fB (z) = gm (z)2 . By Proposition 4.3.6, fB (z) = g2m (z) + z2m g0 (z) and so,
by Exercise 4.3.7, rn (B) = un + u0 = un + 2.
4.18 (a) The independence polynomials are 1 + 4z + 3z2 + z3 , 1 + 4z + 3x2 , 1 +
4z + 2z2 , 1 + 5z + 5z2 and 1 + 5z + 4z2 + z3 , respectively.
(b) Given a vertex u 2 G, let G\u be G with u (and its incident edges) deleted,
and let G u be G with u and all the vertices adjacent to u deleted. Then fG (z) =
fG\u (z) + z fG u .
164 Solutions to exercises

The proof of Lemma 4.2.1 generalizes routinely: for instance, deleting u and its
adjacent vertices defines a bijection between non-attacking placements of k rooks
on G with a rook on u and non-attacking placements of k 1 rooks on G u.
(c) Suppose that G can be partitioned into subsets H and H 0 so that no vertex in
H is adjacent to a vertex of H 0 . Then rk (G) = Âk`=0 r` (H)rk ` (H 0 ) and fG (z) =
fH (z) fH 0 (z).
The proof of Lemma 4.2.2 generalizes almost word-for-word; again this is a special
case of Theorem 8.0.1.
(d) Applying (b) to vertex u we define the graphs G\u and G u shown below.
• • • •
• • • • • •
• • • •

By (c) we have fG\u (z) = (1 + 4z + 2z2 )2 . and fG u (z) = (1 + 3z)2 . Therefore

fG (z) = (1 + 4z + 2z2 )2 + z(1 + 3z)2 = 1 + 9z + 26z2 + 25z3 + 4z4 .

(e) We give a bijective proof. Given a non-attacking placement of rooks on G, there


are five cases for the vertices t, u, v. If at most one rook is on these vertices, and
vertex u is unoccupied, then send the placement to the corresponding placement on
G/u, as shown in the table on the left below.
t 2 G u 2 G v 2 G t 2 G/u v 2 G/u
t 2 G u 2 G v 2 G u0 2 G//u
· · · · ·
R · · R ·
· R · ·

· · R · R R · R R

If there is a rook on u (and so no rook on t or v), remove this rook to get a non-
attacking placement on G//u; if there are rooks on both t and v (and so no rook
on u), remove both these rooks and put a rook on the vertex, u0 say, identifying t
and v in G//u. Since there were rooks on t and v, the new placement on G//u is
non-attacking. As seen in the table on the right above, in both cases the number of
rooks is reduced by one.
It is clear from the tables that this procedure is bijective, therefore
fG (z) = fG/u (z) + z fG//u (z)
as required.
(f) Let G(B) have vertices all boxes (i, j) 2 G and edges between all two boxes in
the same row or column. Then non-attacking placements of k rooks on B are in
Solutions to exercises 165

bijection with placements of k rooks on G, with no two rooks on adjacent vertices.


Hence rk (B) = rk G(B) and fB (z) = fG(B) (z).
(g) Label the vertices of the first graph as shown in the margin. If G is the graph of
v2 •
a board then each of the vertices v1 , v2 , v3 is either in the same row or column as
•u • v1
u. Hence two of these vertices are in the same row or column as u, and so should v3 •
have an edge between them. Therefore G is not the graph of a board.
Neither is any cycle graph Cm for odd m. Since there are no triangles in Cm , steps
along distinct edges must alternative moves along rows and down columns. A se-
quence of such moves returning to the starting point must have even length.
The remaining graphs are the graphs of the boards below.

(h) (?) As a hint, part of the argument for (g) generalizes to show that each vertex
is in at most two non-trivial cliques.

4.19 Let c j (s ) be the number of cycles of length j in the permutation s .


(a) Let B(s ) be the board with squares in positions i, s (i) for i 2 {1, 2, . . . , n}.
Permuting the rows and columns of B(s ) so that whenever i, s (i), . . . , s m 1 (i)
is a cycle of s , with i minimal, the rows and columns appear in the order i, s (i),
. . . , s m 1 (i) turns B(s ) into the board formed by c j (s ) diagonally disjoint copies
of the board B2 j in the Probléme des Ménages. Hence, by Lemma 4.2.2, the rook
polynomial of B is g2 (z)c2 . . . gn (z)cn . Now use Exercise 4.15(d).
(b) Polyá’s Cycle Index Formula states that
• •
zn xj
 n!  1 ’ exp j z j .
c1 (s ) cn (s )
x . . . x n =
n=0 s 2Sym n j=1

Specialize by setting x1 = 0 and x j = t j +t j to get


• •
zn t j +t j
 n!  (t 2
+ t 2 )c2 (s ) . . . (t n
+ t n )cn (s ) = ’ exp
j
zj
n=0 s 2Dn j=1
⇣ • (z/t) j ⌘ ⇣ • (zt) j ⌘
= exp  exp Â
j=1 j j=1 j

= F(z/t)F(zt)

where the final step uses that F(z) is the specialization of Polyá’s Cycle Index
j
Formula by setting x1 = 0 and x j = 1 for j 2 N, and so F(w) = ’•j=1 exp wj . By
166 Solutions to exercises

(a), the left-hand side is



zn
   bn 2` (t
(n 2s )
+ tn 2s
).
n=0 n! s 2Dn 0`n/2

(c) This follows from (a): note that formally replacing t 0 + t 0 with u0 = 2 is cor-
rect, but this means that the zeroth power t 0 is replaced with v0 = 1.
n
(d) Since F(w) = • w
n=0 dn n! , we have
• n ✓ ◆
n zn
F(z/t)F(zt) = Â Â d` dn ` ` t n 2`
n!
.
n=0 `=0

Therefore if 0  `  n/2, the coefficient of znt n 2` /n! in the right-hand side of


(b) is Ân`=0 d` dn ` n` . By (c), formally replacing each t n 2` with vn 2` gives the
exponential generating function for 3 ⇥ n Latin rectangles with first row 1, 2, . . . ,
n. The number of such Latin rectangles is therefore Ân`=0 n` d` dn ` vn 2`
Appendix 5
End notes

Introduction
Whitehead: “Combinatorics is the slums of topology” is reported in Combinatorics
entering the third millennium, Peter J. Cameron, fourth draft, September 2011,
www.maths.qmul.ac.uk/~pjc/preprints/histcomb.pdf.
Gelfand: “The older I get, the more I believe that at the bottom of most deep
mathematical problems there is a combinatorial problem.”, lecture to Courant In-
stitute (1990), as reported in www-history.mcs.st-and.ac.uk/Quotations/
Gelfand.html.

1. Derangements
Exercise 1.11: the misattribution of Burnside’s Lemma is discussed in Peter M. Neu-
mann, A lemma that is not Burnside’s, The Mathematical Scientist, 4 (1979) 133–
141.
Exercise 1.14, Amer. Math. Monthly 118 (2011) 463, Problem 11573, proposed by
Rob Pratt, SAS Institute, Cary, NC.

2. Binomial coefficients
Al-Karaji: www-history.mcs.st-and.ac.uk/Biographies/Al-Karaji.html.
Exercise 2.10: Graham et al. (1994) (5.18).
Exercise 2.15(a): Jennifer J. Quinn, Tonight! Epic math battles: counting vs. match-
ing, Math Horizon (February 2015).
Exercise 2.22: A. C. Dixon, On the sum of the cubes of the coefficients in a certain
expansion by the binomial theorem, Messenger of Mathematics 20 (1891) 79–80.
168 End notes

Interlude I: The Egg Dropping Problem


Jacobi: “man muss immer umkehren” is reported in Edward B. Van Vleck, Current
tendencies of mathematical research, Bull. Amer. Math. Soc. 23 (1916), 1–13. For
a historical account of the early development of elliptic functions (first defined by
their inverses, the elliptic integrals), see Chapter 12 of J. Stillwell, Mathematics
and its history, Undergraduate Texts in Mathematics, Springer 2010 (2nd edition).
An expository article on the egg dropping problem is Michael Boardman, The Egg-
Drop Numbers, Mathematics Magazine 77 (2004), 368–372.

3. Principle of Inclusion and Exclusion


Eratothenes (c. 275–194 BC) was librarian at the Great Library of Alexandria. In
Eratosthenes’ original version of the sieve, only odd numbers were considered. He
is credited with his sieve by the later writer Nicomachus of Gerasa in his Introduc-
tion to Arithmetic (Book II). In the example in Hoche’s edition, I. 13. 2, page 31
(see archive.org/details/nicomachigerasen00nicouoft/page/n6), g, e,
z , q and ia stand for 3, 5, 7, 9, and 11. The square for q is marked g, to indicate
that 3 divides 9.

4. Rook Polynomials
The exposition of the Problème des Ménages and Exercise 4.14 are based on Chap-
ter 8 of Riordan (2002). The formula for the number of 3 ⇥ n Latin rectangles in
Exercise 4.17 [which will be part of the text in §9.4] was first proved by Riordan
in Riordan (1946).

C. Solutions to exercises
Clay tokens, early numeracy and literacy: http://sites.utexas.edu/dsb/tokens/
tokens-and-writing-the-cognitive-development/.
Figure A.1.1: https://commons.wikimedia.org/wiki/File:Clay_accounting_
tokens_Susa_Louvre_n2.jpg, public domain.
References

Beasley, John D. 1989. The mathematics of games. Recreations in Mathematics, vol. 5.


The Clarendon Press, Oxford University Press, New York.
Bryant, Victor. 1993. Aspects of combinatorics. Cambridge University Press, Cambridge.
A wide-ranging introduction.
Butler, Fred, Mahir, Can, Haglund, Jim and Remmel, Jeffrey B. Rook Theory Notes. 57
pages.
de Bruijn, N. G. 1981. Asymptotic methods in analysis. third edn. Dover Publications, Inc.,
New York.
Erdős, P. 1942. On an elementary proof of some asymptotic formulas in the theory of
partitions. Ann. of Math. (2), 43, 437–450.
Graham, Ronald L., Knuth, Donald E. and Patashnik, Oren. 1994. Concrete Mathematics.
Addison Wesley.
Loehr, Nicholas A. 2011. Bijective combinatorics. Discrete Mathematics and its Applica-
tions (Boca Raton). Boca Raton, FL: CRC Press.
Riordan, John. 1946. Three-line latin rectangles. II. Amer. Math. Monthly, 53, 18–20.
Riordan, John. 2002. An introduction to combinatorial analysis. Dover Publications,
Inc., Mineola, NY. Reprint of the 1958 original [Wiley, New York; MR0096594
(20 #3077)].
van Lint, J. H. and Wilson, R. M. 2001. A course in combinatorics. Second edn. Cambridge
University Press, Cambridge.
Wildon, Mark. 2008. Counting partitions on the abacus. Ramanujan J., 17(3), 355–367.
Wilf, Herbert S. 2006. generatingfunctionology. 3rd edn. A. K. Peters.
Index

You might also like