Date post: | 02-Apr-2018 |
Category: |
Documents |
Upload: | saifulahmed49 |
View: | 220 times |
Download: | 0 times |
of 41
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
1/41
Discrete Mathematics
Dr. J. Saxl
Michlmas 1995
These notes are maintained by Paul Metcalfe.
Comments and corrections to [email protected] .
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
2/41
Revision: 2.3
Date: 1999/10/21 11:21:05
The following people have maintained these notes.
date Paul Metcalfe
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
3/41
Contents
Introduction v
1 Integers 1
1.1 Division . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 The division algorithm . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 The Euclidean algorithm . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4 Applications of the Euclidean algorithm . . . . . . . . . . . . . . . . 4
1.4.1 Continued Fractions . . . . . . . . . . . . . . . . . . . . . . 51.5 Complexity of Euclidean Algorithm . . . . . . . . . . . . . . . . . . 6
1.6 Prime Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.6.1 Uniqueness of prime factorisation . . . . . . . . . . . . . . . 7
1.7 Applications of prime factorisation . . . . . . . . . . . . . . . . . . . 7
1.8 Modular Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.9 Solving Congruences . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.9.1 Systems of congruences . . . . . . . . . . . . . . . . . . . . 9
1.10 E ulers Phi Function . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.10.1 Public Key Cryptography . . . . . . . . . . . . . . . . . . . . 10
2 Induction and Counting 11
2.1 The Pigeonhole Principle . . . . . . . . . . . . . . . . . . . . . . . . 11
2.2 Induction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.3 Strong Principle of Mathematical Induction . . . . . . . . . . . . . . 12
2.4 Recursive Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.5 Selection and Binomial Coefficients . . . . . . . . . . . . . . . . . . 13
2.5.1 Selections . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.5.2 Some more identities . . . . . . . . . . . . . . . . . . . . . . 14
2.6 Special Sequences of Integers . . . . . . . . . . . . . . . . . . . . . 16
2.6.1 Stirling numbers of the second kind . . . . . . . . . . . . . . 16
2.6.2 Generating Functions . . . . . . . . . . . . . . . . . . . . . . 16
2.6.3 Catalan numbers . . . . . . . . . . . . . . . . . . . . . . . . 17
2.6.4 Bell numbers . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.6.5 Partitions of numbers and Young diagrams . . . . . . . . . . 18
2.6.6 Generating function for self-conjugate partitions . . . . . . . 20
3 Sets, Functions and Relations 23
3.1 Sets and indicator functions . . . . . . . . . . . . . . . . . . . . . . . 23
3.1.1 De Morgans Laws . . . . . . . . . . . . . . . . . . . . . . . 24
3.1.2 Inclusion-Exclusion Principle . . . . . . . . . . . . . . . . . 24
iii
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
4/41
iv CONTENTS
3.2 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.3 Permutations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.3.1 Stirling numbers of the first kind . . . . . . . . . . . . . . . . 27
3.3.2 Transpositions and shuffles . . . . . . . . . . . . . . . . . . . 27
3.3.3 Order of a permutation . . . . . . . . . . . . . . . . . . . . . 28
3.3.4 Conjugacy classes in Sn
. . . . . . . . . . . . . . . . . . . . 28
3.3.5 Determinants of an n n matrix . . . . . . . . . . . . . . . . 283.4 Binary Relations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.5 Posets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.5.1 Products of posets . . . . . . . . . . . . . . . . . . . . . . . 30
3.5.2 Eulerian Digraphs . . . . . . . . . . . . . . . . . . . . . . . 30
3.6 Countability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.7 Bigger sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
5/41
Introduction
These notes are based on the course Discrete Mathematics given by Dr. J. Saxl in
Cambridge in the Michlmas Term 1995. These typeset notes are totally unconnected
with Dr. Saxl.
Other sets of notes are available for different courses. At the time of typing these
courses were:
Probability Discrete Mathematics
Analysis Further Analysis
Methods Quantum MechanicsFluid Dynamics 1 Quadratic Mathematics
Geometry Dynamics of D.E.s
Foundations of QM Electrodynamics
Methods of Math. Phys Fluid Dynamics 2
Waves (etc.) Statistical Physics
General Relativity Dynamical Systems
Physiological Fluid Dynamics Bifurcations in Nonlinear Convection
Slow Viscous Flows Turbulence and Self-Similarity
Acoustics Non-Newtonian Fluids
Seismic Waves
They may be downloaded from
http://www.istari.ucam.org/maths/ or
http://www.cam.ac.uk/CambUniv/Societies/archim/notes.htm
or you can email [email protected] to get a copy of the
sets you require.
v
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
6/41
Copyright (c) The Archimedeans, Cambridge University.
All rights reserved.
Redistribution and use of these notes in electronic or printed form, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of the electronic files must retain the above copyright notice, thislist of conditions and the following disclaimer.
2. Redistributions in printed form must reproduce the above copyright notice, this
list of conditions and the following disclaimer.
3. All materials derived from these notes must display the following acknowledge-
ment:
This product includes notes developed by The Archimedeans, Cambridge
University and their contributors.
4. Neither the name of The Archimedeans nor the names of their contributors may
be used to endorse or promote products derived from these notes.
5. Neither these notes nor any derived products may be sold on a for-profit basis,
although a fee may be required for the physical act of copying.
6. You must cause any edited versions to carry prominent notices stating that you
edited them and the date of any change.
THESE NOTES ARE PROVIDED BY THE ARCHIMEDEANS AND CONTRIB-
UTORS AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABIL-
ITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL THE ARCHIMEDEANS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSE-
QUENTIAL DAMAGES HOWEVER CAUSED AND ON ANY THEORY OF LI-ABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUD-
ING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THESE NOTES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAM-
AGE.
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
7/41
Chapter 1
Integers
Notation. The natural numbers, which we will denote by N , are
f 1 2 3 : : : g :
The integers Z are
f : : : ; 2 ; 1 0 1 2 : : : g :
We will also use the non-negative integers, denoted either byN
0
orZ
+
, which isN
f 0 g . There are also the rational numbers Q and the real numbers R .
Given a set S , we write x 2 S if x belongs to S , and x =2 S otherwise.
There are operations + and on Z . They have certain nice properties which we
will take for granted. There is also ordering.N
is said to be well-ordered, which
means that every non-empty subset of N has a least element. The principle of induction
follows from well-ordering.
Proposition (Principle of Induction). Let P ( n ) be a statement about n for each n 2
N . Suppose P ( 1 ) is true and P ( k ) true implies thatP ( k + 1 ) is true for each k 2 N .
ThenP
is true for alln
.
Proof. SupposeP
is not true for alln
. Then consider the subsetS
ofN
of all numbers
k for which P is false. Then S has a least element l . We know that P ( l ; 1 ) is true
(sincel > 1
), so thatP ( l )
must also be true. This is a contradiction andP
holds for all
n .
1.1 Division
Given two integersa
,b 2 Z
, we say thata
dividesb
(and writea j b
) ifa 6= 0
andb = a
q for some q
2Z ( a is a divisor of b ). a is a proper divisorof b if a is not
1
or b
.
Note. If a j b and b j c then a j c , for if b = q1
a and c = q2
b for q1
, q2
2 Z then
c = ( q
1
q
2
) a
. Ifd j a
andd j b
thend j a x + b y
. The proof of this is left as an exercise.
1
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
8/41
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
9/41
1.3. THE EUCLIDEAN ALGORITHM 3
a = q
1
b + r
1
with0 < r
1
< b
b = q
2
r
1
+ r
2
with 0 < r2
< r
1
r
1
= q
3
r
2
+ r
3
with0 < r
3
< r
2
...
r
i ; 2
= q
i
r
i ; 1
+ r
i
with0 < r
i
< r
i ; 1
...
r
n ; 3
= q
n ; 1
r
n ; 2
+ r
n ; 1
with0 < r
n
< r
n ; 1
r
n ; 2
= q
n
r
n ; 1
+ 0 :
This process must terminate as b > r1
> r
2
> > r
n ; 1
> 0 . Using Lemma
(1.2),( a b ) = ( b r
1
) = = ( r
n ; 2
r
n ; 1
) = r
n ; 1
. So( a b )
is the last non-zero
remainder in this process.
We now wish to findx
0
andy
0
2 Zwith
( a b ) = a x
0
+ b y
0
. We can do this by
backsubstitution.
2 1 = 6 3
;1
4 2
= 6 3 ; ( 2 3 1 ; 3 6 3 )
= 4 6 3 ; 2 3 1
= 4 ( 5 2 5 ; 2 2 3 1 ) ; 2 3 1
= 4 5 2 5 ; 9 2 3 1 :
This works in general but can be confusing and wasteful. These numbers can be
calculated at the same time as ( a b ) if we know we shall need them.
We introduceA
i
andB
i
. We putA
; 1
= B
0
= 0
andA
0
= B
; 1
= 1
. We
iteratively define
A
i
= q
i
A
i ; 1
+ A
i ; 2
B
i
= q
i
B
i ; 1
+ B
i ; 2
:
Now consider a Bj
;b A
j
.
Lemma 1.3.
a B
j
; b A
j
= ( ; 1 )
j + 1
r
j
:
Proof. We shall do this using strong induction. We can easily see that (1.3) holds for
j = 1 and j = 2 . Now assume we are at i
2 and we have already checked that
r
i ; 2
= ( ; 1 )
i ; 1
( a B
i ; 2
; b A
i ; 2
)
andr
i ; i
= ( ; 1 )
i
( a B
i ; 1
; b A
i ; 1
)
. Now
r
i
= r
i ; 2
; q
i
r
i ; 1
= ( ; 1 )
i ; 1
( a B
i ; 2
; b A
i ; 2
) ; q
i
( ; 1 )
i
( a B
i ; 1
; b A
i ; 1
)
= ( ; 1 )
i + 1
( a B
i
; b A
i
) , using the definition of Ai
and Bi
.
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
10/41
4 CHAPTER 1. INTEGERS
Lemma 1.4.
A
i
B
i + 1
; A
i + 1
B
i
= ( ; 1 )
i
Proof. This is done by backsubstitution and using the definition of Ai
andB
i
.
An immediate corollary of this is that ( Ai
B
i
) = 1 .
Lemma 1.5.
A
n
=
a
( a b )
B
n
=
b
( a b )
:
Proof. (1.3) fori = n
givesa B
n
= b A
n
. Therefore a( a b )
B
n
=
b
( a b )
A
n
. Now a( a b )
and b( a b )
are coprime. An
and Bn
are coprime and thus this lemma is therefore an
immediate consequence of the following theorem.
Theorem 1.2. If d j c e and ( c d ) = 1 then d j e .
Proof. Since ( c d ) = 1 we can write 1 = c x + d y for some x , y 2 Z . Then e =
e c x + e d y
andd j e
.
Definition. The least common multiple (lcm) ofa and b (written a b ] ) is the integerl
such that
1.a j l
andb j l
,
2. ifa j l
0 andb j l
0 thenl j l
0 .
It is easy to show that a b ] =
a b
( a b )
.
1.4 Applications of the Euclidean algorithm
Takea
,b
andc 2 Z
. Suppose we want to find all the solutionsx
,y 2 Z
ofa x + b y = c
.
A necessary condition for a solution to exist is that ( a b ) j c , so assume this.
Lemma 1.6. If ( a b ) j c then a x + b y = c has solutions in Z .
Proof. Take x 0 and y 0 2 Z such that a x 0 + b y 0 = ( a b ) . Then if c = q ( a b ) then if
x
0
= q x
0 andy
0
= q y
0 ,a x
0
+ b y
0
= c
.
Lemma 1.7. Any other solution is of the form x = x0
+
b k
( a b )
,y = y
0
;
a k
( a b )
for
k 2 Z .
Proof. These certainly work as solutions. Now supposex
1
andy
1
is also a solution.
Then a( a b )
( x
0
; x
1
) = ;
b
( a b )
( y
0
; y
1
)
. Since a( a b )
and b( a b )
are coprime we havea
( a b )
j ( y
0
; y
1
)
and b( a b )
j ( x
0
; x
1
)
. Say thaty
1
= y
0
;
a k
( a b )
,k 2 Z
. Then
x
1
= x
0
+
b k
( a b )
.
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
11/41
1.4. APPLICATIONS OF THE EUCLIDEAN ALGORITHM 5
1.4.1 Continued Fractions
We return to5 2 5
and2 3 1
. Note that
5 3 5
2 3 1
= 2 +
6 3
2 3 1
= 2 +
1
2 3 1
6 3
= 2 +
1
3 +
4 2
6 3
= 2 +
1
3 +
1
1 +
1
2
:
Notation.5 3 5
2 3 1
= 2 +
1
3 +
1
1 +
1
2
= 2 3 1 2 ] = 2 3 1 2 :
Note that2
,3
,1
and2
are just theq
i
s in the Euclidean algorithm. The rationala
b
> 0 is written as a continued fraction
a
b
= q
1
+
1
q
2
+
1
q
3
+
: : :
1
q
n
with all theq
i
2 N
0
,q
i
1for
1 < i < n
andq
n
2.
Lemma 1.8. Every rational ab
with a and b 2 N has exactly one expression in this
form.
Proof. Existance follows immediately from the Euclidean algorithm. As for unique-ness, suppose that
a
b
= p
1
+
1
p
2
+
1
p
3
+
: : :
1
p
m
with the pi
s as before. Firstly p1
= q
1
as both are equal to b ab
c . Since 1p
2
+
1
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
12/41
6 CHAPTER 1. INTEGERS
1.5 Complexity of Euclidean Algorithm
Givena
andb
, how many steps does it take to find( a b )
. The Euclidean algorithm is
good.
Proposition. The Euclidean algorithm will find( a b ) , a > b in fewer than 5 d ( b ) steps,
whered ( b )
is the number of digits ofb
in base1 0
.
Proof. We look at the worst case scenario. What are the smallest numbers needingn
steps. In this case qi
= 1 for 1 i < n and qn
= 2 . Using these qi
s to calculate An
andB
n
we find the Fibonacci numbers, that is the numbers such thatF
1
= F
2
= 1
,
F
i + 2
= F
i + 1
+ F
i
. We getA
n
= F
n + 2
andB
n
= F
n + 1
. So ifb < F
n + 1
then fewer
thann
steps will do. Ifb
hasd
digits then
b 1 0
d
; 1
1
p
5
1 +
p
5
2
!
5 d + 2
; 1 < F
5 d + 2
as
F
n
=
1
p
5
"
1 +
p
5
2
!
n
;
1 ;
p
5
2
!
n
#
: This will be shown later.
1.6 Prime Numbers
A natural number p is a prime iff p > 1 and p has no proper divisors.
Theorem 1.3. Any natural number n > 1 is a prime or a product of primes.
Proof. If n is a prime then we are finished. If n is not prime then n = n1
n
2
with n1
andn
2 proper divisors. Repeat withn
1 andn
2 .
Theorem 1.4 (Euclid). There are infinitely many primes.
Proof. Assume not. Then letp
1
p
2
: : : p
n
be all the primes. Form the numberN =
p
1
p
2
: : : p
n
+ 1 . Now N is not divisible by any of the pi
but N must either be prime
or a product of primes, giving a contradiction.
This can be made more precise. The following argumentof Erdos shows that thek
th
smallest prime pk
satisfies pk
4
k ; 1
+ 1 . Let M be an integer such that all numbers
Mcan be written as the product of the powers of the first
k
primes. So any such
number can be written
m
2
p
i
1
1
p
i
2
2
: : : p
i
k
k
with i1
: : : i
k
2 f 0 1 g . Now m p
M , so there are at mostp
M 2
k possible num-
bers less thanM
. HenceM 2
k
p
M
, orM 4
k . Hencep
k + 1
4
k
+ 1
.
A much deeper result (which will not be proved in this course!) is the Prime Num-
ber Theorem, that pk
k l o g k .
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
13/41
1.7. APPLICATIONS OF PRIME FACTORISATION 7
1.6.1 Uniqueness of prime factorisation
Lemma 1.9. If p j a b , a b 2 N then p j a and/or p j b .
Proof. If p - a then ( p a ) = 1 and so p j b by theorem (1.2).
Theorem 1.5. Every natural number > 1 has a unique expression as the product ofprimes.
Proof. The existence part is theorem (1.3). Now suppose n = p1
p
2
: : : p
k
= q
1
q
2
: : : q
l
with thep
i
s andq
j
s primes. Thenp
1
j q
1
: : : q
l
, sop
1
= q
j
for somej
. By renumber-
ing (if necessary) we can assume that j = 1 . Now repeat with p2
: : : p
k
and q2
: : : q
l
,
which we know must be equal.
There are perfectly nice algebraic systems where the decomposition into primes
is not unique, for instanceZ
p
; 5
= f a + b
p
; 5 : a b 2 Z g, where
6 = ( 1 +
p
; 5 ) ( 1 ;
p
; 5 ) = 2 3 and 2 3 and 1 p
; 5 are each prime. Or alternatively,
2 Z = fall even numbers
g, where prime means not divisible by
4
.
1.7 Applications of prime factorisation
Lemma 1.10. If n 2 N is not a square number thenp
n is irrational.
Proof. Supposep
n =
a
b
, with( a b ) = 1
. Thenn b
2
= a
2 . Ifb > 1
then letp
be a
prime dividingb
. Thusp j a
2 and sop j a
, which is impossible as( a b ) = 1
. Thus
b = 1
andn = a
2 .
This lemma can also be stated: ifn 2 N
withp
n 2 Qthen
p
n 2 N.
Definition. A real number is algebraic if it satisfies a polynomial equation with co-efficients in
Z
.
Real numbers which are not algebraic are transcendental (for instance and e ).
Most reals are transcendental.
If the rational ab
( with( a b ) = 1
) satisfies a polynomial with coefficients inZ
then
c
n
a
n
+ c
n ; 1
a
n ; 1
b + : : : b
n
c
0
= 0
sob j c
n
anda j c
0
. In particular ifc
n
= 1
thenb = 1
, which is stated as algebraic
integers which are rational are integers.
Note that if a = p 11
p
2
2
: : : p
k
k
and b = p
1
1
p
2
2
: : : p
k
k
with i
i
2 N
0
then
( a b ) = p
1
1
p
2
2
: : : p
k
k
and a b ] = p 11
p
2
2
: : : p
k
k
, i
= m i n
f
i
i
gand
i
=
m a x f
i
i
g.
Major open problems in the area of prime numbers are the Goldbach conjecture
(every even number greater than two is the sum of two primes) and the twin primes
conjecture (there are infinitely many prime pairs p and p + 2 ).
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
14/41
8 CHAPTER 1. INTEGERS
1.8 Modular Arithmetic
Definition. Ifa
andb 2 Z
,m 2 N
we say thata
andb
are congruent mod(ulo)m
if m j a ; b . We write a b ( m o d m ) .
It is a bit like=
but less restrictive. It has some nice properties:
a a ( m o d m ) ,
if
a b ( m o d m )then
b a ( m o d m ),
if
a b ( m o d m )and
b c ( m o d m )then
a c ( m o d m ).
Also, ifa
1
b
1
( m o d m )
anda
2
b
2
( m o d m )
a
1
+ a
2
b
1
+ b
2
( m o d m ) ,
a
1
a
2
b
1
a
2
b
1
b
2
( m o d m )
.
Lemma 1.11. For a fixed m2
N , each integer is congruent to precisely one of the
integers
f 0 1 : : : m ; 1 g :
Proof. Take a 2 Z . Then a = q m + r for q r 2 Z and 0 r < m . Then a r
( m o d m )
.
If0 r
1
< r
2
< m
then0 < r
2
; r
1
< m
, som - r
2
; r
1
and thusr
1
6 r
2
( m o d m ) .
Example. No integer congruent to 3 ( m o d 4 ) is the sum of two squares.
Solution. Every integer is congruent to one of0 1 2 3 ( m o d 4 )
. The square of any
integer is congruent to0
or1 ( m o d 4 )
and the result is immediate.
Similarly, using congruence modulo 8, no integer congruent to7 ( m o d 8 )
is the
sum of 3 squares.
1.9 Solving Congruences
We wish to solve equations of the forma x b ( m o d m )
givena b 2 Z
andm 2 N
for x 2 Z . We can often simplify these equations, for instance 7 x 3 ( m o d 5 )
reduces tox 4 ( m o d 5 )
(since2 1 1
and9 4 ( m o d 5 )
).
This equations are not always soluble, for instance 6 x 4 ( m o d 9 ) , as 9 - 6 x ; 4
for anyx 2 Z
.
How to do it
The equation a x b ( m o d m ) can have no solutions if( a m ) - b since then m - a x ; b
for anyx 2 Z
. So assume that( a m ) j b
.We first consider the case ( a m ) = 1 . Then we can find x
0
and y0
2 Z such
thata x
0
+ m y
0
= b
(use the Euclidean algorithm to getx
0 andy
0
2 Zsuch that
a x
0
+ m y
0
= 1 ). Then put x0
= b x
0 so a x0
b ( m o d m ) . Any other solution is
congruent tox
0
( m o d m )
, asm j a ( x
0
; x
1
)
and( a m ) = 1
.
So if ( a m ) = 1 then a solution exists and is unique modulo m .
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
15/41
1.10. EULERS PHI FUNCTION 9
1.9.1 Systems of congruences
We consider the system of equations
x a m o d m
x b m o d n :
Our main tool will be the Chinese Remainder Theorem.
Theorem 1.6 (Chinese Remainder Theorem). Assume m n 2 N are coprime and
leta b 2 Z
. Then9 x
0
satisfying simultaneouslyx
0
a ( m o d m )and
x
0
b
( m o d n ) . Moreover the solution is unique up to congruence modulo m n .
Proof. Writec m + d n = 1
withm n 2 Z
. Thenc m
is congruent to0
modulom
and 1 modulo n . Similarly d n is congruent to 1 modulo m and 0 modulo n . Hence
x
0
= a d n + b c m
satifiesx
0
a ( m o d m )and
x
0
b ( m o d n ). Any other solution
x
1
satisfies x0
x
1
both modulo m and modulo n , so that since ( m n ) = 1 , m n j
x
0
; x
1
andx
1
x
0
( m o d m n )
.
Finally, if1
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
16/41
10 CHAPTER 1. INTEGERS
An immediate corollary of this is that for anyn 2 N
,
( n ) = n
Y
p j n
p prime
1
;
1
p
:
Theorem 1.8 (Fermat-Euler Theorem). Takea
,m 2 N
such that( a m ) = 1
. Thena
( m )
1 ( m o d m ).
Proof. Multiply each residue ri
by a and reduce modulo m . The ( m ) numbers thus
obtained are prime tom
and are all distinct. So the ( m )
new numbers are just
r
1
: : : r
( m )
in a different order. Therefore
r
1
r
2
: : : r
( m )
a r
1
a r
2
: : : a r
( m )
( m o d m )
a
( m )
r
1
r
2
: : : r
( m )
( m o d m ) :
Since( m r
1
r
2
: : : r
( m )
) = 1
we can divide to obtain the result.
Corollary (Fermats Little Theorem). If p is a prime and a2
Z such that p - a then
a
p ; 1
1 ( m o d p ) .
This can also be seen as a consequence of Lagranges Theorem, sinceU
m
is a group
under multiplication modulo m .
Fermats Little Theorem can be used to check thatn 2 N
is prime. If9 a
coprime
to n such that a n ; 1 6 1 ( m o d n ) then n is not prime.
1.10.1 Public Key Cryptography
Private key cryptosystems rely on keeping the encoding key secret. Once it is known
the code is not difficult to break. Public key cryptography is different. The encoding
keys are public knowledge but decoding remains impossible except to legitimate
users. It is usually based of the immense difficulty of factorising sufficiently large
numbers. At present 150 200 digit numbers cannot be factorised in a lifetime.
We will study the RSA system of Rivest, Shamir and Adleson. The user A (forAlice) takes two large primes
p
A
andq
A
with> 1 0 0
digits. She obtainsN
A
= p
A
q
A
and chooses at random
A
such that(
A
( N
A
) ) = 1
. We can ensure thatp
A
; 1and
q
A
;1 have few factors. Now A publishes the pair N
A
and A
.
By some agreed methodB
(for Bob) codes his message for Alice as a sequence of
numbers M < NA
. Then B sends A the number M A ( m o d NA
) . When Alice wants
to decode the message she choosesd
A
such thatd
A
A
1 ( m o d ) ( N
A
)
. Then
M
A
d
A
M ( m o d N
A
) since M ( N A ) 1 . No-one else can decode messages to
Alice since they would need to factoriseN
A
to obtain ( N
A
)
.
If Alice and Bob want to be sure who is sending them messages, then Bob could
send AliceE
A
( D
B
( M ) )
and Alice could applyE
B
D
A
to get the message if its
from Bob.
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
17/41
Chapter 2
Induction and Counting
2.1 The Pigeonhole Principle
Proposition (The Pigeonhole Principle). If n m + 1 objects are placed into n boxes
then some box contains more thanm
objects.
Proof. Assume not. Theneach box has at most m objects so the total number of objects
isn m
a contradiction.
A few examples of its use may be helpful.
Example. In a sequence of at leastk l + 1 distinct numbers there is either an increasing
subsequence of length at leastk + 1
or a decreasing subsequence of length at leastl + 1
.
Solution. Let the sequence be c1
c
2
: : : c
k l + 1
. For each position let ai
be the length
of the longest increasing subsequence starting withc
i
. Letd
j
be the length of the
longest decreasing subsequence starting with cj
. If ai
k and di
l then there are
only at mostk l
distinct pairs( a
i
d
j
)
. Thus we havea
r
= a
s
andd
r
= d
s
for some
1 r < s k l + 1
. This is impossible, for ifc
r
< c
s thena
r
> a
s and ifc
r
> c
s
thend
r
> d
s
. Hence either somea
i
> k
ord
j
> l
.
Example. In a group of 6 people any two are either friends or enemies. Then there
are either 3 mutual friends or 3 mutual enemies.
Solution. Fix a person X . Then X has either 3 friends or 3 enemies. Assume the
former. If a couple of friends ofX
are friends of each other then we have 3 mutual
friends. Otherwise, X s 3 friends are mutual enemies.
Dirichlet used the pigeonhole principle to prove that for any irrational
there are
infinitely many rationals pq
satisfying
;
p
q
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
18/41
12 CHAPTER 2. INDUCTION AND COUNTING
Proposition (Principle of Induction). Let P ( n ) be a statement aboutn for each n 2
N
0
. Suppose P ( k0
) is true for some k0
2N
0
and P ( k ) true implies that P ( k + 1 ) is
true for eachk 2 N
. ThenP ( n )
is true for alln 2 N
0
such thatn k
0
.
The favourite example is the Tower of Hanoi. We have n rings of increasing radius
and 3 vertical rods (A
,B
andC
) on which the rings fit. The rings are initially stacked
in order of size on rodA
. The challenge is to move the rings fromA
toB
so that alarger ring is never placed on top of a smaller one.
We write the number of moves required to moven
rings asT
n
and claim that
T
n
= 2
n
; 1for
n 2 N
0
. We note thatT
0
= 0 = 2
0
; 1, so the result is true for
n = 0
.
We takek > 0
and suppose we havek
rings. Now the only way to move the largest
ring is to move the other k;
1 rings onto C (in Tk ; 1
moves). We then put the largest
ring on rodB
(in1
move) and move thek ; 1
smaller rings on top of it (inT
k ; 1
moves
again). Assume that Tk ; 1
= 2
k ; 1
; 1 . Then Tk
= 2 T
k ; 1
+ 1 = 2
k
; 1 . Hence the
result is proven by the principle of induction.
2.3 Strong Principle of Mathematical Induction
Proposition (Strong Principle of Induction). If P ( n ) is a statement aboutn for eachn 2 N
0
,P ( k
0
)
is true for somek
0
2 N
0
and the truth ofP ( k )
is implied by the truth
of P ( k0
) , P ( k0
+ 1 ) , : : : , P ( k ; 1 ) then P ( n ) is true for all n 2 N0
such that n k0
.
The proof is more or less as before.
Example (Evolutionary Trees). Every organism can mutate and produce2
new ver-
sions. Then n mutations are required to produce n + 1 end products.
Proof. Let P ( n ) be the statement n mutations are required to produce n + 1 end
products.P
0
is clear. Consider a tree withk + 1
end products. The first mutation (the
root) produces 2 trees, say with k1
+ 1 and k2
+ 1 end products with k1
k
2
< k . Then
k + 1 = k
1
+ 1 + k
2
+ 1
sok = k
1
+ k
2
+ 1
. If bothP ( k
1
)
andP ( k
2
)
are true then
there arek
1 mutations on the left andk
2 on the right. So in total we havek
1
+ k
2
+ 1
mutations in our tree andP ( k )
is true isP ( k
1
)
andP ( k
2
)
are true. HenceP ( n )
is true
for alln 2 N
0
.
2.4 Recursive Definitions
(Or in other words) Defining f ( n ) , a formula or functions, for all n 2 N0
with n k0
by definingf ( k
0
)
and then defining fork > k
0
,f ( k )
in terms off ( k
0
)
,f ( k
0
+ 1 )
,
: : : , f ( k ; 1 ) .
The obvious example is factorials, which can be defined by n ! = n ( n ; 1 ) ! for
n 1and
0 ! = 1
.
Proposition. The number of ways to order a set ofn
points isn !
for alln 2 N
0 .
Proof. This is true for n = 0 . So, to order an n -set, choose the 1 st element in n ways
and then order the remainingn ; 1
-set in( n ; 1 ) !
ways.
Another example is the Ackermann function, which appears on example sheet 2.
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
19/41
2.5. SELECTION AND BINOMIAL COEFFICIENTS 13
2.5 Selection and Binomial Coefficients
We define a set of polynomials form 2 N
0
as
x
m
= x ( x ; 1 ) ( x ; 2 ) : : : ( x ; m + 1 )
which is pronounced x
to them
falling. We can do this recursively byx
0
= 1
and
x
m
= ( x ; m + 1 ) x
m ; 1 for m > 0 . We also define x to the m rising by
x
m
= x ( x + 1 ) ( x + 2 ) : : : ( x + m ; 1 ) :
We further define;
x
m
(read x
choosem
) by
x
m
=
x
m
m !
:
It is also convienient to extend this definition to negativem
by;
x
m
= 0
ifm 0
,S
n
= 2 S
n ; 1
. (Pick a point in then
-set and observe that
there are Sn ; 1
subsets not containing it and Sn ; 1
subsets containing it.
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
20/41
14 CHAPTER 2. INDUCTION AND COUNTING
3.( 1 ; 1 )
n
= 0 =
P
k
;
n
k
( ; 1 )
k so in any finite set the number of subsets of
even sizes equals the number of subsets of odd sizes.
It also gives us another proof of Fermats Little Theorem: if p is prime then a p a
( m o d p )
for alla 2 N
0
.
Proof. It is done by induction ona
. It is obviously true whena = 0
, so takea > 0
and
assume the theorem is true for a ; 1 . Then
a
p
= ( ( a ; 1 ) + 1 )
p
( a ; 1 )
p
+ 1 m o d p
as
p
k
0 ( m o d p )unless
k = 0
ork = p
a ; 1 + 1 m o d p
a m o d p
2.5.1 Selections
The number of ways of choosing m objects out of n objects is
ordered unordered
no repeats n m;
n
m
repeats n m;
n ; m + 1
m
The only entry that needs justification is;
n ; m + 1
m
. But there is a one-to-one cor-
respondance betwen the set of ways of choosing m out of n unordered with possible
repeats and the set of all binary strings of lengthn + m ; 1
withm
zeros andn ; 1
ones. For suppose there are mi
occurences of element i , mi
0 . Then
n
X
i = 1
m
i
= m $ 0 : : : 0
| { z }
m
1
1 0 : : : 0
| { z }
m
2
1 : : : 1 0 : : : 0
| { z }
m
n
:
There are;
n ; m + 1
m
such strings (choosing where to put the1
s).
2.5.2 Some more identities
Proposition.
n
k
=
n
n ; k
n 2 N
0
k 2 Z
Proof. For: choosing a k -subset is the same as choosing an n ; k -subset to reject.
Proposition.
n
k
=
n ; 1
k ; 1
+
n ; 1
k
n 2 N
0
k 2 Z
Proof. This is trivial if n 0 . Choose a special
element in then
-set. Anyk
-subset will either contain this special element (there are;
n ; 1
k ; 1
such) or not contain it (there are;
n ; 1
k
such).
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
21/41
2.5. SELECTION AND BINOMIAL COEFFICIENTS 15
In fact
Proposition.
x
k
=
x ; 1
k ; 1
+
x ; 1
k
k 2 Z
Proof. Trivial if k
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
22/41
16 CHAPTER 2. INDUCTION AND COUNTING
2.6 Special Sequences of Integers
2.6.1 Stirling numbers of the second kind
Definition. The Stirling number of the second kind, S ( n k ) , n k 2 N0
is defined
as the number of partitions of f 1 : : : n g into exactly k non-empty subsets. Also
S ( n 0 ) = 0
ifn > 0
and1
ifn = 0
.Note that S ( n k ) = 0 if k > n , S ( n n ) = 1 for all n , S ( n n ; 1 ) =
;
n
2
and
S ( n 2 ) = 2
n ; 1
; 1.
Lemma 2.1. A recurrence: S ( n k ) = S ( n ; 1 k ; 1 ) + k S ( n ; 1 k ) .
Proof. In any partition off 1 : : : n g
, the elementn
is either in a part on its own (S ( n ;
1 k
;1 ) such) or with other things ( k S ( n
;1 k ) such).
Proposition. For n 2 N0
,x
n
=
P
k
S ( n k ) x
k .
Proof. Proof is by induction on n . It is clearly true when n = 0 , so take n > 0 and
assume the result is true forn ; 1
. Then
x
n
= x x
n ; 1
= x
X
k
S ( n ; 1 k ) x
k
=
X
k
S ( n ; 1 k ) x
k
( x ; k + k )
=
X
k
S ( n ; 1 k ) x
k + 1
+
X
k
k S ( n ; 1 k ) x
k
=
X
k
S ( n ; 1 k ; 1 ) x
k
+
X
k
k S ( n ; 1 k ) x
k
=
X
k
S ( n k ) x
k as required.
2.6.2 Generating Functions
Recall the Fibonacci numbers,F
n
such thatF
1
= F
2
= 1
andF
n + 2
= F
n + 1
+ F
n
.
Suppose that we wish to obtain a closed formula.
First method
Try a solution of the form Fn
=
n . Then we get 2 ; ; 1 = 0 and = 1 p
5
2
. We
then take
F
n
= A
1 +
p
5
2
!
n
+ B
1
;
p
5
2
!
n
and use the initial conditions to determine A and B . It turns out that
F
n
=
1
p
5
"
1 +
p
5
2
!
n
;
1 ;
p
5
2
!
n
#
:
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
23/41
2.6. SPECIAL SEQUENCES OF INTEGERS 17
Note that 1 +p
5
2
> 1
and
1 ;
p
5
2
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
24/41
18 CHAPTER 2. INDUCTION AND COUNTING
SinceC ( 0 ) = 1
we must have the;
sign. From the binomial theorem
( 1 ; 4 z )
1
2
=
X
k 0
1
2
k
( ; 4 )
k
z
k
:
Thus Cn
= ;
1
2
;
1
2
n + 1
( ; 4 )
n + 1 . Simplifying this we obtain Cn
=
1
n + 1
;
2 n
n
and note
the corollary that ( n + 1 )j
;
2 n
n
.
Other possible definitions forC
n
are:
The number of ways of bracketing
n + 1
variables.
The number of sequences of length
2 n
withn
each of 1
such that all partial
sums are non-negative.
2.6.4 Bell numbers
Definition. The Bell number Bn
is the number of partitions off 1 : : : n g .
It is obvious from the definitions that Bn
=
P
k
S ( n k ) .
Lemma 2.3.
B
n + 1
=
X
0 k n
n
k
B
k
Proof. For, put the element n + 1 in with a k -subset of f 1 : : : n g for k = 0 to k =
n
.
There isnt a nice closed formula for Bn
, but there is a nice expression for its
exponential generating function.
Definition. The exponential generating function that is associated with the sequence
( a
n
)
n 2 N
0
is
A ( z ) =
X
n
a
n
n !
z
n
:
If we have A ( z )
and B ( z )
(with obvious notation) and A ( z )
B ( z ) =
P
n
c
n
n !
z
n then
c
n
=
P
k
;
n
k
a
k
b
n ; k
, the exponential convolution of ( an
)
n 2 N
0
and ( bn
)
n 2 N
0
.
HenceB
n + 1
is the coefficient ofz
n in the exponential convolution of the sequences
1 1 1 1 : : : and B0
B
1
B
2
: : : . Thus B ( z ) 0 = e z B ( z ) . (Shifting is achieved by
differentiation for exponential generating functions.) Therefore B ( z ) = e
e
z
+ C and
using the condition B ( 0 ) = 1
we find thatC = ; 1
. So
B ( z ) = e
e
z
; 1
:
2.6.5 Partitions of numbers and Young diagrams
Forn 2 N
letp ( n )
be the number of ways to writen
as the sum of natural numbers.
We can also definep ( 0 ) = 1
.
For instance, p ( 5 ) = 7 :
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
25/41
2.6. SPECIAL SEQUENCES OF INTEGERS 19
5 4 + 1 3 + 2 3 + 1 + 1
Notation5 4 1
3
3 2 3 1
2
2 + 2 + 1 2 + 1 + 1 + 1 1 + 1 + 1 + 1 + 1
Notation 2 2 1 2 1 3 1 5
These partitions of n are usefully pictured by Young diagrams.
The conjugate partition is obtained by taking the mirror image in the main diag-
onal of the Young diagram. (Or in other words, consider columns instead of rows.)
By considering (conjugate) Young diagrams this theorem is immediate.
Theorem 2.2. The number of partions ofn
into exactlyk
parts equals the number ofpartitions of n with largest part k .
We now define an ordinary generating function forp ( n )
P ( z ) = 1 +
X
n 2 N
p ( n ) z
n
:
Proposition.
P ( z ) =
1
1 ; z
1
1 ; z
2
1
1 ; z
3
=
Y
k 2 N
1
1 ; z
k
:
Proof. The RHS is ( 1 + z + z 2 + : : : ) ( 1 + z 2 + z 4 + : : : ) ( 1 + z 3 + z 6 : : : ) : : : .
We get a termz
n whenever we selectz
a
1 from the first bracket,z
2 a
2 from the
second,z
3 a
3 from the third and so on, andn = a
1
+ 2 a
2
+ 3 a
3
+ : : :
, or in other words
1
a
1
2
a
2
3
a
3
: : : is a partition of n . There are p ( n ) of these.
We can similarly prove these results.
Proposition. The generating function Pm
( z )
of the sequencep
m
( n )
of partitions ofn
into at most m parts (or the generating function for the sequence pm
( n ) of partitions
ofn
with largest part m
) satisfies
P
m
( z ) =
1
1 ; z
1
1 ; z
2
1
1 ; z
3
: : :
1
1 ; z
m
:
Proposition. The generating function for the number of partitions into odd parts is
1
1 ; z
1
1 ; z
3
1
1 ; z
5
: : : :
Proposition. The generating function for the number of partitions into unequal parts
is
( 1 + z ) ( 1 + z
2
) ( 1 + z
3
) : : : :
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
26/41
20 CHAPTER 2. INDUCTION AND COUNTING
Theorem 2.3. The number of partitions ofn into odd parts equals the number of par-
titions ofn into unequal parts.
Proof.
( 1 + z ) ( 1 + z
2
) ( 1 + z
3
) : : : =
1 ; z
2
1
;z
1 ; z
4
1
;z
2
1 ; z
6
1
;z
3
: : :
=
1
1 ; z
1
1 ; z
3
1
1 ; z
5
: : :
Theorem 2.4. The number of self-conjugate partitions ofn
equals the number of par-
titions ofn into odd unequal parts.
Proof. Consider hooks along the main diagonal like this.
This process can be reversed, so there is a one-to-one correspondance.
2.6.6 Generating function for self-conjugate partitions
Observe that any self-conjugate partition consists of a largest k k subsquare and twice
a partition of 12
( n ; k
2
)
into at mostk
parts. Now
1
( 1 ; z
2
) ( 1 ; z
4
) : : : ( 1 ; z
2 m
)
is the generating function for partitions ofn
into even parts of size at most2 m
, or
alternatively the generating function for partitions of 12
n into parts of size
m . We
deduce thatz
l
( 1 ; z
2
) ( 1 ; z
4
) : : : ( 1 ; z
2 m
)
is the generating function for partitions of 12
( n ; l )into at most
m
parts. Hence the
generating function for self-conjugate partitions is
1 +
X
k 2 N
z
k
2
( 1 ; z
2
) ( 1 ; z
4
) : : : ( 1 ; z
2 k
)
:
Note also that this equals
Y
k 2 N
0
( 1 + z
2 k + 1
)
as the number of self-conjugate partitions ofn
equals the number of partitions ofn
into
unequal odd parts.
In fact in any partition we can consider the largestk k
subsquare, leaving two
partitions of at most k parts, one of ( n ; k 2 ; j ) , the other of j for some j . The number
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
27/41
2.6. SPECIAL SEQUENCES OF INTEGERS 21
of these two lots are the coefficients ofz
n ; k
2
; j andz
j inQ
k
i = 1
1
1 ; z
i
respectively.
Thus
P ( z ) = 1 +
X
k 2 N
z
k
2
( ( 1
;z ) ( 1
;z
2
) : : : ( 1
;z
k
) )
2
:
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
28/41
22 CHAPTER 2. INDUCTION AND COUNTING
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
29/41
Chapter 3
Sets, Functions and Relations
3.1 Sets and indicator functions
We fix some universal set S . We write P ( S ) for the set of all subsets ofS the power
set ofS
. IfS
is finite withj S j = m
(the number of elements), thenj P ( S ) j = 2
m
.Given a subset
A
ofS
(A S
) we define the complement A
ofA
inS
as
A = f s 2 S : s =2 A g .
Given two subsetsA
,B
ofS
we can define various operations to get new subsets
ofS
.
A \ B = f s 2 S : s 2 A and s 2 B g
A B = f s 2 S : s 2 A(inclusive) or
s 2 B g
A n B = f s 2 A : s =2 B g
A B = f s 2 S : s 2 A(exclusive) or
s 2 B gthe symmetric difference
= ( A B ) n ( A \ B )
= ( A n B ) ( B n A ) :
The indicator functionI
A
of the subsetA
ofS
is the functionI
A
: S 7! f 0 1 g
defined by
I
A
( s ) =
(
1 x 2 A
0 otherwise.
It is also known as the characteristic function A
. Two subsets A and B of S are equal
iffI
A
( s ) = I
B
( s ) 8 s 2 S. These relations are fairly obvious:
I
A
= 1 ; I
A
I
A \ B
= I
A
I
B
I
A B
= I
A
+ I
B
I
A B
= I
A
+ I
B
m o d 2 :
Proposition. A ( B C ) = ( A B ) C .
23
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
30/41
24 CHAPTER 3. SETS, FUNCTIONS AND RELATIONS
Proof. For, modulo 2,
I
A ( B C )
= I
A
+ I
B C
= I
A
+ I
B
+ I
C
= I
A B
+ I
C
= I
( A B ) C
m o d 2 :
Thus P ( S ) is a group under . Checking the group axioms we get:
Given A B 2 P ( S ) , A B 2 P ( S ) closure,
A ( B C ) = ( A B ) C associativity,
A = Afor all
A 2 P ( S ) identity,
A A = for all
A 2 P ( S ) inverse.
We note that A B = B A so that this group is abelian.
3.1.1 De Morgans LawsProposition. 1. A \ B = A B
2. A B = A \ B
Proof.
I
A \ B
= 1 ; I
A \ B
= 1 ; I
A
I
B
= ( 1 ; I
A
) + ( 1 ; I
B
) ; ( 1 ; I
A
) ( 1 ; I
B
)
= I
A
+ I
B
; I
A \
B
= I
A
B
:
We prove 2 by using 1 on
A and
B .
A more general version of this is: Suppose A1
: : : A
n
S . Then
1.T
n
i = 1
A
i
=
S
n
i = 1
A
i
2.S
n
i = 1
A
i
=
T
n
i = 1
A
i
.
These can be proved by induction onn
.
3.1.2 Inclusion-Exclusion Principle
Note thatj A j =
P
s 2 S
I
A
( s )
.
Theorem 3.1 (Principle of Inclusion-Exclusion). Given A1
: : : A
n
Sthen
j A
1
A
n
j =
X
6= J f 1 : : : n g
( ; 1 )
j J j ; 1
j A
J
j where
A
J
=
\
i 2 J
A
i
.
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
31/41
3.1. SETS AND INDICATOR FUNCTIONS 25
Proof. We considerA
1
A
n
and note that
I
A
1
A
n
= I
A
1
\ \
A
n
= I
A
1
I
A
2
: : : I
A
n
= ( 1 ; I
A
1
) ( 1 ; I
A
2
) : : : ( 1 ; I
A
n
)
=
X
J f 1 : : : n g
( ; 1 )
j J j
I
A
J
Summing over s2
S we obtain the result
A
1
A
n
=
X
J f 1 : : : n g
( ; 1 )
j J j
j A
J
j
which is equivalent to the required result.
Just for the sake of it, well prove it again!
Proof. For eachs 2 S
we calculate the contribution. Ifs 2 S
buts
is in noA
i
then
there is a contribution 1 to the left. The only contribution to the right is + 1 when J = .
Ifs 2 S
andK = f i 2 f 1 : : : n g : s 2 A
i
gis non-empty then the contribution to the
right isP
I K
( ; 1 )
j I j
=
P
k
i = 0
;
k
i
( ; 1 )
i
= 0
, the same as on the left.
Example (Eulers Phi Function).
( m ) = m
Y
p
primep j m
1 ;
1
p
:
Solution. Letm =
Q
n
i = 1
p
a
i
i
, where thep
i
are distinct primes anda
i
2 N. Let
A
i
be
the set of integers less than m which are divisible by pi
. Hence ( m ) =
T
n
i = 1
A
i
.
Nowj A
i
j =
m
p
i
, in fact forJ f 1 : : : m g
we havej A
J
j =
m
Q
i 2 J
p
i
. Thus
( m ) = m ;
m
p
1
;
m
p
2
; ;
m
p
n
+
m
p
1
p
2
+
m
p
1
p
3
+ +
m
p
2
p
3
+ +
m
p
n ; 1
p
n
...
+ ( ; 1 )
n
m
p
1
p
2
: : : p
n
= m
Y
p primep j m
1 ;
1
p
as required.
Example (Derangements). Suppose we have n psychologists at a meeting. Leaving
the meeting they pick up their overcoats at random. In how many ways can this be
done so that none of them has his own overcoat. This number isD
n
, the number of
derangements of n objects.
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
32/41
26 CHAPTER 3. SETS, FUNCTIONS AND RELATIONS
Solution. LetA
i
be the number of ways in which psychologisti
collects his own coat.
Then Dn
=
A
1
\ \
A
n
. If J f
1 : : : n
gwith
jJ
j= k then
jA
J
j= ( n
;k ) ! .
Thus
A
1
\ \
A
n
= n ! ;
n
1
( n ; 1 ) ! +
n
2
( n ; 2 ) ! ; : : :
= n !
n
X
k = 0
( ; 1 )
k
k !
:
Thus Dn
is the nearest integer to n ! e ; 1 , since D nn !
!e
; 1 as n! 1
.
3.2 Functions
Let A B be sets. A function (or mapping, or map) f : A 7! B is a way to associate
a unique imagef ( a ) 2 B
with eacha 2 A
. IfA
andB
are finite withj A j = m
and
j B j = n then the set of all functions from A to B is finite with n m elements.
Definition. The function f : A7!
B is injective (or one-to-one) if f ( a1
) = f ( a
2
)
implies thata1
= a
2
for all a1
a
2
2 A .
The number of injective functions from an m -set to an n -set is n m .
Definition. The function f : A7!
B is surjective (or onto) if each b2
B has at least
one preimagea 2 A
.
The number of surjective functions from an m -set to an n -set is n ! S ( m n ) .
Definition. The function f : A 7! B is bijective if it is both injective and surjective.
IfA
andB
are finite thenf : A 7! B
can only be bijective ifj A j = j B j
. If
j A j = j B j
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
33/41
3.3. PERMUTATIONS 27
3.3 Permutations
A permutation ofA
is a bijectionf : A 7! A
. One notation is
f =
1 2 3 4 5 6 7 8
1 3 4 2 8 7 6 5
:
The set of permutations ofA
is a group under composition, the symmetric group
s y m A . If j A j = n then s y m A is also denoted Sn
and j s y m A j = n ! . Sn
is not abelian
you can come up with a counterexample yourself. We can also think of permutations
as directed graphs, in which case the following becomes clear.
Proposition. Any permutation is the product of disjoint cycles.
We have a new notation for permutations, cycle notation. 1 For our functionf
above, we write
f = ( 1 ) ( 2 3 4 ) ( 5 8 ) ( 6 7 ) = ( 2 3 4 ) ( 5 8 ) ( 6 7 ) :
3.3.1 Stirling numbers of the first kind
Definition. s ( n k ) is the number of permutations off
1 : : : n
gwith precisely k cycles
(including fixed points).
For instances ( n n ) = 1
,s ( n n ; 1 ) =
;
n
2
,s ( n 1 ) = ( n ; 1 ) !
,s ( n 0 ) =
s ( 0 k ) = 0 for all k n 2 N but s ( 0 0 ) = 1 .
Lemma 3.1.
s ( n k ) = s ( n ; 1 k ; 1 ) + ( n ; 1 ) s ( n ; 1 k )
Proof. Either the pointn
is in a cycleon its own (s ( n ; 1 k ; 1 )
such) or it is not. In this
case, n can be inserted into any of n ; 1 places in any of the s ( n ; 1 k ) permutations
off 1 : : : n ; 1 g
.
We can use this recurrence to prove this proposition. (Proof left as exercise.)
Proposition.
x
n
=
X
k
s ( n k ) x
k
3.3.2 Transpositions and shuffles
A transposition is a permutation which swaps two points and fixes the rest.
Theorem 3.2. Every permutation is the product of transpositions.
Proof. Since every permutations is the product of cycles we only need to check for
cycles. This is easy: ( i1
i
2
: : : i
k
) = ( i
1
i
2
) ( i
2
i
3
) : : : ( i
k ; 1
i
k
) .
Theorem 3.3. For a given permutation , the number of transpositions used to write
as their product is either always even or always odd.
1See the Algebra and Geometry course for more details.
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
34/41
28 CHAPTER 3. SETS, FUNCTIONS AND RELATIONS
We writes i g n =
(
+ 1 if always even
;1 if always odd
. We say that
is aneven
oddpermutation.
Letc ( )
be the number of cycles in the disjoint cycle representation of
(including
fixed points).
Lemma 3.2. If = ( a b ) is a transposition thatc ( ) = c ( ) 1 .
Proof. If a and b are in the same cycle of then has two cycles, so c ( ) =
c ( ) + 1
. Ifa
andb
are in different cycles then they contract them together andc ( ) =
c ( ) ; 1 .
Proof of theorem 3.3. Assume = 1
: : :
k
=
1
: : :
l
. Then c ( ) = c ( ) + k
c ( ) + l ( m o d 2 )
. Hencek l ( m o d 2 )
as required.
We note that s i g n = ( ; 1 ) n ; c ( ) , thus s i g n ( 1
2
) = s i g n
1
s i g n
2
and thus
s i g n
is a homomorphism fromS
n
tof 1 g
.
Ak
-cycle is an even permutation iffk
is odd. A permutation is aneven
oddper-
mutation iff the number of even length cycles in the disjoint cycle representation iseven
odd.
3.3.3 Order of a permutation
If is a permutation then the order of is the least natural number n such that n = .
The order of the permutation
is the lcm of the lengths of the cycles in the disjoint
cycle decomposition of .
In card shuffling we need to maximise the order of the relevant permutation
. One
can show (see) that for of maximal length we can take all the cycles in the disjoint
cycle representation to have prime power length. For instance with3 0
cards we can get
a 2 S
3 0
with an order of4 6 2 0
(cycle type3 4 5 7 1 1
).
3.3.4 Conjugacy classes in Sn
Two permutations 2 Sn
are conjugate iff 9 2 Sn
such that = ; 1 .
Theorem 3.4. Two permutations are conjugate iff they have the same cycle type.
This theorem is proved in the Algebra and Geometry course. We note the corollary
that the number of conjugacy classes inS
n
equals the number of partitions ofn
.
3.3.5 Determinants of an n n matrix
In the Linear Maths course you will prove that ifA = ( a
i j
)
is ann n
matrix then
d e t A =
X
2 S
n
s i g n
n
Y
j = 1
a
j ( j )
:
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
35/41
3.4. BINARY RELATIONS 29
3.4 Binary Relations
A binary relation on a set S is a property that any pair of elements of S may or may
not have. More precisely:
WriteS S
, the Cartesian square ofS
for the set of pairs of elements ofS
,S S =
f ( a b ) : a b 2 S g. A binary relation
Ron
S
is a subset ofS S
. We writea R b
iff
( a b ) 2 R . We can think of R as a directed graph with an edge from a to b iff a R b .
A relation R is:
reflexive iff a
Ra
8a
2S ,
symmetric iff
a R b ) b R a 8 a b 2 S,
transitive iff
a R b b R c ) a R c 8 a b c 2 S,
antisymmetric iff
a R b b R a ) a = b 8 a b 2 S.
The relationR
onS
is an equivalence relation if it is reflexive, symmetric and
transitive. These are nice properties designed to make R behave something like = .
Definition. If R is a relation on S , then
a ]
R
= a ] = f b 2 S : a R b g :
IfR
is an equivalence then these are the equivalence classes.
Theorem 3.5. If R is an equivalence relation then the equivalence classes form a par-
tition ofS .
Proof. Ifa 2 S
thena 2 a ]
, so the classes cover all ofS
. If a ] \ b ] 6=
then
9 c 2 a ] \ b ] . Now a R c and b R c ) c R b . Thus a R b and b 2 a ] . If d 2 b ]
thenb R d
soa R d
and thus b ] a ]
. We can similarly show that a ] b ]
and thus
a ] = b ]
.
The converse of this is true: if we have a partition ofS
we can define an equivalence
relation onS
bya R b
iffa
andb
are in the same part.
An application of this is the proof of Lagranges Theorem. The idea is to show that
being in the same (left/right) coset is an equivalence relation.
Given an equivalence class on S the quotient set is S = R , the set of all equivalence
classes. For instance ifS = R
anda R b
iffa ; b 2 Z
thenS = R
is (topologically) a
circle. If S = R 2 and ( a1
b
1
) R ( a
2
b
2
) iff a1
; a
2
2 Z and b1
; b
2
2 Z the quotient
set is a torus.
Returning to a general relationR
, for eachk 2 N
we define
R
( k )
= f ( a b ) : there is a path of length at k from a to b g :
R
( 1 )
= Rand
R
( 1 )
= t ( R )
, the transitive closure ofR
.R
( 1 ) is defined asS
i 1
R
( i ) .
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
36/41
30 CHAPTER 3. SETS, FUNCTIONS AND RELATIONS
3.5 Posets
Ris a (partial) order on
S
if it is reflexive, anti-symmetric and transitive. The setS
is
a poset (partially ordered set) if there is an orderR
on S .
We generally writea b
iff( a b ) 2 R
, anda < b
iffa b
anda 6= b
.
ConsiderD
n
, the set of divisors ofn
.D
n
is partially ordered by division,a b
if
a
jb . We have the Hasse diagram, in this case for D 3 6 :
36
18 12
9
3
46
2
1
A descending chain is a sequence a1
> a
2
> a
3
> : : : . An antichain is a subset of
S
with no two elements directly comparable, for instancef 4 6 9 g
inD
3 6
.
Proposition. If S is a poset with no chains of length > n then S can be covered by at
most n antichains.
Proof. Induction on n . Take n > 1 and let M be the set of all maximal elements in S .
NowS n M
has no chains of length> n ; 1
andM
is an antichain.
3.5.1 Products of posets
Suppose A and B are posets. Then A B has various orders; two of them being
product order: ( a1
b
1
) ( a
2
b
2
) iff a1
a
2
and b1
b
2
,
lexicographic order:
( a
1
b
1
) ( a
2
b
2
)
if eithera
1
a
2
or ifa
1
= a
2
then
b
1
b
2
.
Exercise: check that these are orders.
Note that there are no infinite descending chains inN N
under lexicographic
order. Such posets are said to be well ordered. The principle of induction follows from
well-ordering as discussed earlier.
3.5.2 Eulerian Digraphs
A digraph is Eulerian if there is a closed path covering all the edges. A necessary
condition is: the graph is connected and even (each vertex has an equal number of in
and out edges). This is in fact sufficient.
Proposition. The set of such digraphs is well-ordered under containment.
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
37/41
3.6. COUNTABILITY 31
Proof. Assume proposition is false and letG
be a minimal counterexample. LetT
be
a non-trivial closed path in G , for instance the longest closed path. Now T must be
even, soG n T
is even. Hence each connected component ofG n T
is Eulerian asG
is minimal. But then G is Eulerian: you can walk along T and include all edges of
connected components ofG n T
when encountered giving a contradiction. Hence
there are no minimal counterexamples.
3.6 Countability
Definition. A setS
is countable if eitherj S j
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
38/41
32 CHAPTER 3. SETS, FUNCTIONS AND RELATIONS
Theorem 3.6. A countable union of countable sets is countable. That is, if I is a
countable indexing set andAi
is countable8
i
2I then
S
i 2 I
A
i
is countable.
Proof. Identify firstI
with the subsetf ( I ) N
. DefineF : A 7! N
bya 7! 2
n
3
m
where n is the smallest index i with a2
A
i
, and m = fn
( a ) . This is well-defined and
injective (stop to think about it for a bit).
Theorem 3.7. The set of all algebraic numbers is countable.
Proof. LetP
n
be the set of all polynomials of degree at mostn
with integral coeffi-
cients. Then the mapc
n
x
n
+ + c
1
x + c
0
7! ( c
n
: : : c
1
c
0
)
is an injection fromP
n
toZ
n + 1 . Hence eachP
n
is countable. It follows that the set of all polynomials with
integral coefficients is countable. Each polynomial has finitely many roots, so the set
of algebraic numbers is countable.
Theorem 3.8 (Cantors diagonal argument). R is uncountable.
Proof. Assume R is countable, then the elements can be listed as
r
1
= n
1
: d
1 1
d
1 2
d
1 3
: : :
r
2
= n
2
: d
2 1
d
2 2
d
1 3
: : :
r
3
= n
3
: d
3 1
d
3 2
d
3 3
: : :
(in decimal notation). Now define the real r = 0 : d1
d
2
d
3
: : : by di
= 0 if di i
6= 0 and
d
i
= 1
ifd
i i
= 0
. This is real, but it differs fromr
i
in thei
th decimal place. So the list
is incomplete and the reals are uncountable.
Exercise: use a similiar proof to show that P ( N ) is uncountable.
Theorem 3.9. The set of all transcendental numbers is uncountable. (And therefore at
least non-empty!)
Proof. LetA
be the set of algebraic numbers andT
the set of transcendentals. ThenR = A T , so if T was countable then so would R be. Thus T is uncountable.
3.7 Bigger sets
The material from now on is starred.
Two sets S and T have the same cardinality ( j S j = j T j ) if there is a bijection
betweenS
andT
. One can show (the Schroder-Bernstein theorem) that if there is an
injection from S to T and an injection from T to S then there is a bijection between S
andT
.
For any setS
, there is an injection fromS
toP ( S )
, simplyx 7! f x g
. However
there is never a surjection S 7! P ( S ) , so j S j
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
39/41
3.7. BIGGER SETS 33
Proof. Letf : S 7! P ( S )
be a surjection and considerX 2 P ( S )
defined byf x 2
S : x =
2f ( x )
g. Now
9x
0
2S such that f ( x 0 ) = X . If x 0
2X then x 0 =
2f ( x
0
) but
f ( x
0
) = X
a contradiction. But ifx
0
=2 Xthen
x
0
=2 f ( x
0
)
andx
0
2 X giving a
contradiction either way.
If there is aninjection
surjection
f : A 7! Bthen there exists a
surjection
injection
g : B 7! A.
Moreover we can ensure thatg f =
A
f g =
B
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
40/41
34 CHAPTER 3. SETS, FUNCTIONS AND RELATIONS
7/27/2019 Discrete Mathematics - Dr. J. Saxl - University of Cambridge
41/41
References
Hardy & Wright, An Introduction to the Theory of Numbers, Fifth ed., OUP, 1988.
This book is relevant to quite a bit of the course, and I quite enjoyed (parts of!) it.
H. Davenport, The Higher Arithmetic, Sixth ed., CUP, 1992.
A very good book for this course. Its also worth a read just for interests sake.
Ive also heard good things about Biggs book, but havent read it.
35