0% found this document useful (0 votes)
46 views29 pages

Notes Week2

Uploaded by

ruben135rejo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views29 pages

Notes Week2

Uploaded by

ruben135rejo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

Lecture notes for

F17SC Discrete Mathematics

Dr Matteo Capoferri1 and Dr Adrian Turcanu2

Department of Mathematics
Heriot-Watt University

AY 2022–2023

1 Senior Course Leader, Edinburgh. E-mail: m.capoferri@hw.ac.uk, Webpage: https:


//mcapoferri.com.
2 Dubai. E-mail: a.turcanu@hw.ac.uk.
Abstract

This course is in five parts. The first part is concerned with the foundations of
set and function theory, alongside elements of combinatorics. The second part deals
with probability theory and applications. The third part consists in Graph Theory,
indispensable for students of computer science and applied mathematics. The fourth
part is concerned with recurrence relations and, finally, the fifth part provides an
introduction to matrix theory and linear algebra.

Each section is complemented by a list of exercises. Exercises for which a solution


is provided are marked with a (∗).

All the teaching materials for the course are available on Canvas.

All you need is for the course is contained in these lecture notes and in the accom-
panying Problem Sets, which will gradually become available on Canvas. However,
if you wish to consult a textbook, you may refer to

• P. Grossman, Discrete Mathematics for Computing (has a nice introduction to


set theory, combinatorics and graphs with a range of examples from computer
science)

• A. Chetwynd and P. Diggle, Discrete Mathematics (a short, very friendly text-


book, covering combinatorics and probability)

• K. H. Rosen, Discrete Mathematics and its application (the graph theory chap-
ters are particularly useful)

• S. B. Maurer and A. Ralston, Discrete Algorithmic Mathematics (covers linear


algebra, probability and applications to algorithms)

• S. Lipschutz, Schaum’s outline of theory and problems of linear algebra (covers


matrices and linear equations)

Updated: January 29, 2023.

Acknowledgements: I am grateful to Dr Anatoly Konechny for making his teach-


ing materials available to me. These notes are largely based on his.
Contents

1 Set Theory and Combinatorics 3


1.1 Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1.1 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2 Set Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2.1 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.3 Computer Representation of Sets . . . . . . . . . . . . . . . . . . . . 7
1.3.1 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.4 Relations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.4.1 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.5 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.5.1 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.6 Mathematical Induction . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.6.1 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
1.7 The Sum and Product Rules . . . . . . . . . . . . . . . . . . . . . . 22
1.7.1 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
1.8 Permutations and Combinations . . . . . . . . . . . . . . . . . . . . 24
1.8.1 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

2
Chapter 1

Set Theory and Combinatorics

1.1 Sets
Definition 1.1. A set is an unordered collection of objects.

The notation A = {1, 3, 5, 7} means that the set A contains the four elements
1, 3, 5, 7 . We write a ∈ A to denote that a is an element of the set A . We write
a∈ / A to indicate that a does not belong to A . For example, given A = {1, 3, 5, 7}
we have that 5 ∈ A and 6 ∈ / A.
There are a number of ways of denoting sets. Thus for the set of positive even
numbers we could write
A = {2, 4, 6, 8, . . .}
or
A = {x | x is a positive even number} ,
where the vertical bar | is to be read “such that”.
A set cannot contain the same object more than once. Also, the elements in a
set are not ordered so the sets {a, b, c} and {c, a, b} are the same. In general, two
sets are equal if they contain the same elements.

Definition 1.2. A set B is a subset of a set A if every element of B is also an


element of a A .

If B is a subset of A we write B ⊂ A . For example, if A = {1, 3, 5, 7} and


B = {3, 7} , then B ⊂ A .

Remark 1.1. You should take care to distinguish between ‘B is a subset of A’ ( B ⊂


A ) and ‘B is a element of A’ ( B ∈ A ). For example if

A = {1, {3, 5}, 3, 6, 7},

then all of the following are true

3 ∈ A, {3, 5} ∈ A, 5∈
/ A, {3, 6} ⊂ A, {3} ⊂ A.

3
Discrete Mathematics Page 4

The set that has no elements is called the empty set and is denoted by ∅ . By
convention ∅ ⊂ A for any set A.
Remark 1.2. Note that the set ∅ and the set B = {∅} are different. The single
element of B is the empty set itself.

Definition 1.3. An ordered pair is a pair (a, b) , where a comes before b.


Two pairs (a, b) and (c, d) are equal whenever a = c and b = d . Note that
(3, 8) and (8, 3) are not equal.
Definition 1.4. If A and B are sets then the Cartesian product A × B is the set
of all ordered pairs (a, b) with a ∈ A and b ∈ B .

Example 1.5. Let A = {1, 2, 3} and B = {x, y} . Find the Cartesian product
A×B.
Solution. The Cartesian product A × B is

A × B = { (1, x), (1, y), (2, x), (2, y), (3, x), (3, y) }.

1.1.1 Exercises

Exercise 1.1.1 (∗). List the elements of the set

{x | x is the square of an integer and x < 25} .

Solution. We have

{x | x is the square of an integer and x < 25} = {0, 1, 4, 9, 16} .

Exercise 1.1.2 (∗). Find B × A for Example 1.5.

Solution. B × A = { (x, 1), (x, 2), (x, 3), (y, 1), (y, 2), (y, 3) } .

1.2 Set Operations


Definition 1.6. If A and B are sets then the union of A and B , A∪B is defined
as
A ∪ B := {x | x ∈ A or x ∈ B}.
Page 5 Dr Matteo Capoferri & Dr Adrian Turcanu

The symbol “:=” means “equal by definition”.

Definition 1.7. The intersection of A and B , A ∩ B is defined as

A ∩ B := {x | x ∈ A and x ∈ B}.

Note that the statement x ∈ A or x ∈ B does not exclude the possibility that
x is an element of both sets. For example, we have

{1, 3, 5, 7} ∪ {2, 5, 7} = {1, 2, 3, 5, 7}

and
{1, 3, 5, 7} ∩ {2, 5, 7} = {5, 7} .
Remark 1.3. It is useful to picture combinations of sets with the aid of Venn dia-
grams. This will be done in the lectures.

Definition 1.8. If A and B are sets, then the difference of A and B is denoted
by A \ B and defined as

A \ B := {x | x ∈ A and x ∈
/ B}.

For example, if A = {1, 3, 5, 7} and B = {4, 5, 6, 7} then A \ B = {1, 3} .


Often, all the sets under consideration are subsets of some larger set U called the
universal set.

Definition 1.9. The complement of a set A is A = U \ A .

Thus A = {x | x ∈
/ A} .

Example 1.10. Let U = {1, 2, 3, 4, 5, 6, 7} , A = {1, 7} , B = {1, 2, 4, 6} and


C = {1, 3, 5, 7} . Find the sets
(a) C \ A , (b) A ∩ B , (c) (A ∩ B) ∪ C , (d) A ∪ B , (e) (C − A) ∩ B .
Solution. (a) C \ A = {3, 5} .
(b) B = {3, 5, 7} so A ∩ B = {7} .
(c) A ∩ B = {1} and C = {2, 4, 6} . Hence (A ∩ B) ∪ C = {1, 2, 4, 6} .
(d) A ∪ B = {1, 2, 4, 6, 7} so A ∪ B = {3, 5, } .
(e) C \ A = {1, 2, 4, 6, 7} so (C \ A) ∩ B = {1, 2, 4, 6} .

Set operations satisfy the following laws.

A ∪ (B ∪ C) = (A ∪ B) ∪ C

A ∩ (B ∩ C) = (A ∩ B) ∩ C
Discrete Mathematics Page 6

A∪B =B∪A
A∩B =B∩A
A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C)
A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C)
(A ∪ B) = A ∩ B
(A ∩ B) = A ∪ B
Note that the empty set ∅ satisfies the following properties A ∪ ∅ = A and
A ∩ ∅ = ∅ for any set A.

1.2.1 Exercises

Exercise 1.2.1 (∗). Let U = {1, 2, 3, 4, 5, 6, 7, 8} , A = {3, 8} , B = {2, 4, 6, 8} and


C = {1, 3, 5, 7} .
Find the sets
(a) C \ A , (b) A ∩ B , (c) (A ∩ B) ∪ C ,
(d) A ∩ B , (e) (C \ A) ∩ B .

Solution. (a) C \ A = {1, 5, 7} .


(b) A ∩ B = {3, 8} ∩ {1, 3, 5, 7} = {3} .
(c) A ∩ B = {8} , so (A ∩ B) ∪ C = {2, 4, 6, 8} and
(d) A ∩ B = {1, 2, 3, 4, 5, 6, 7} .
(e) C \ A = {2, 3, 4, 6, 8} , so (C \ A) ∩ B = B .

Exercise 1.2.2 (∗). Let C = A ∩ B and D = A ∩ B . Find C ∩ D .

Solution. C ∩ D = ∅ since there are no elements that are in both B and B .

Exercise 1.2.3 (∗). What can you say about sets A and B if
(a) A∪B = A ? (b) A∩B = A ? (c) A∩B = B ∩A ? (d) A\B = A ?

Solution. (a) If A ∪ B = A then B ⊂ A .


(b) If A ∩ B = A then A ⊆ B .
(c) Since A ∩ B = B ∩ A is always true we cannot say anything about A and B .
(d) Suppose that A \ B = A and x ∈ A ∩ B . Then x ∈ A and x ∈ B so
x∈/ A \ B . Since A \ B = A , no such x can exist and A ∩ B = ∅ .
Page 7 Dr Matteo Capoferri & Dr Adrian Turcanu

1.3 Computer Representation of Sets


There are many ways to represent sets on a computer. We could store the elements
of a set in an unordered fashion. If we did this, it would be time-consuming to
compute the union or intersection of two sets since these operations would require a
large amount of searching for elements. We outline below a method for storing the
elements of a set which makes computing set operations easy.

• Step 1. We order a finite universal set U = {u1 , u2 , . . . , un } .

• Step 2. Given a subset A of U , we represent A by a bit string of length n


where the k th bit in the string is 1 if uk ∈ A and 0 otherwise.

As an example, let U = {1, 2, 3, 4, 5, 6} , A = {2, 3} and B = {3, 4, 5, 6} . Then


the bit string for A is 0 1 1 0 0 0 and the bit string for B is 0 0 1 1 1 1 .
Given the bit strings for A and B, one can easily compute the bit strings for A,
A ∪ B and A ∩ B as follows.

− To find the bit string for A from the bit string for A we turn each 1 into a 0
and each 0 into a 1.

For the above example, the bit string for A is 0 1 1 0 0 0 so the bit string for A
is 1 0 0 1 1 1 .

− The k th bit in the bit string for A ∪ B is 1 if either (or both) of the bits in
the k th position of A and B is 1, and is 0 if both bits are 0.

− The k th bit in the bit string for A ∩ B is 1 if both of the bits in the k th
position of A and B are 1 , and is 0 if either (or both) of the two bits is 0.

As an example, let U = {1, 2, 3, 4, 5} , A = {1, 3, 5} and B = {3, 4} . The bit


string for A is 1 0 1 0 1 whereas the bit string for B is 0 0 1 1 0 . Therefore, the bit
string for A ∪ B is 1 0 1 1 1 and the bit string for A ∩ B is 0 0 1 0 0 .

1.3.1 Exercises

Exercise 1.3.1 (∗). Let U = {1, 2, 3, 4, 5, 6, 7} , A = {3, 4, 5, 7} and B = {5, 6} .


Find the bit strings for A , B , A , A ∪ B , and A ∩ B .

Solution. The bit string for A is 0 0 1 1 1 0 1 , and the bit string for B is 0 0 0 0 1 1 0 .
The bit strings for A , A ∪ B and A ∩ B are 1 1 0 0 0 1 0 , 0 0 1 1 1 1 1 and
0000100.
Discrete Mathematics Page 8

Exercise 1.3.2 (∗). Which subsets of a finite universal set U do these bit strings
represent?
(a) the string with all zeros, (b) the string with all ones.

Solution. (a) The empty set. (b) The set U .

Exercise 1.3.3 (∗). Explain how to find the bit string corresponding to A \ B.

Solution. For A \ B , the k th bit is 1 if the k th bit of the first string is 1 and the
k th bit of the second string is 0, and is 0 otherwise.

1.4 Relations
Let A and B be sets. A relation between A and B links certain elements of A with
certain elements of B. More formally, a relation from A to B is a subset of A × B.
A relation on the set A is a relation from A to A.

Here are some examples of relations:

1. Let A be the set of students at Heriot-Watt University and let B be the set
of modules. The relation R consists of pairs (a, b) , a ∈ A , b ∈ B with the
student a being enrolled to the course b.

2. Let R be the relation on the set of people consisting of pairs (a, b) where a is
a parent of b.

3. Let A = {1, 2, 3, 4} and B = {x, y} . Then

R = { (1, y), (2, x), (3, x), (4, y) }

is a relation from A to B.

4. The following are relations on the set of integers:

R1 = {(a, b)|a ≥ b},

R2 = {(a, b)|a − b = 4}.

5. Let A = {1, 2, 3, 4} and let R be the relation on A given by

R = {(a, b)|a divides b }.

Then R contains the pairs

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


Page 9 Dr Matteo Capoferri & Dr Adrian Turcanu

If S is a (small) finite set, then we can represent a relation R on S by a directed


graph, a network of blobs and arrows. We have a blob for each element of S, and
draw an arrow from x to y if (x, y) ∈ R.
Let S = {a, b, c, d} and let R be the relation defined by the subset
{(a, a), (a, b), (b, b), (b, c), (c, b), (c, d), (d, d)}.
The directed graph encoding this relation is shown below.

Definition 1.11. Let R be a relation on a set A. We say that R is


• reflexive if (a, a) ∈ R for all elements a in A;
• symmetric if whenever (a, b) ∈ R then (b, a) ∈ R;
• antisymmetric if whenever (a, b) ∈ R and (b, a) ∈ R then a = b;
• transitive if whenever (a, b) ∈ R and (b, c) ∈ R then (a, c) ∈ R.
A description of the above properties in terms of graphs was given in class.

Example 1.12. As an example, consider the relation in item 5 above.


It is reflexive since it contains all pairs of the form (a, a) , namely,

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

It is not symmetric since, for example, it contains (1, 2) but not (2, 1) .
It is antisymmetric since there is no pair of elements a and b with a ̸= b such
that (a, b) and (b, a) belong to R.
It is transitive. To check this we have to show that if (a, b) and (b, c) belong to
R, then so does (a, c) .

Example 1.13. As another example, let R be the relation on the set of people
consisting of pairs (a, b) where a likes b. Unfortunately it is not symmetric. It is
not antisymmetric or transitive. It is probably not even reflexive.
Discrete Mathematics Page 10

Definition 1.14. A relation that is reflexive, symmetric and transitive is called an


equivalence relation.

Example 1.15. Let R be the relation on the set A = {1, 3, 5, 9, 11, 18} defined by
the pairs (a, b) such that a − b is divisible by 4.

Given a set A with an equivalence relation R on it, we can break up all elements in
A into disjoint groups (subsets) such that within each group all elements are related
between themselves but no two elements from two different groups are related. Such
groups of elements are called equivalence classes. For Example 1.15 the equivalence
classes are C1 = {1, 5, 9}, C2 = {3, 11}, C3 = {18}.

1.4.1 Exercises

Exercise 1.4.1 (∗). Let A = {2, 3, 4, 5, 6} and let R be the relation on A given by

R = {(a, b)|a divides b }

Write down the ordered pairs in R.


Solution. R = {(2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (2, 4), (2, 6), (3, 6)}.

Exercise 1.4.2 (∗). Let R be the relation on the set of real numbers consisting
of pairs (a, b) with a ≤ b. Determine whether the relation is reflexive, symmetric.
antisymmetric, or transitive.
Solution. This relation is reflexive because a ⩽ a. It is not symmetric because e.g.
2 ⩽ 3 but 3 ⩽̸ 2. It is antisymmetric because if a ⩽ b and b ⩽ a this does imply
a = b. It is transitive, that is a ⩽ b and b ⩽ c implies a ⩽ c.

Exercise 1.4.3. Show that Example 1.15 defines an equivalence relation.

1.5 Functions
Let X and Y be sets.
Definition 1.16. A function from X to Y is a rule that assigns to each element of
X exactly one element of Y . We write f : X → Y . The set X is called the domain
of f and the set Y is called the codomain of f .
Page 11 Dr Matteo Capoferri & Dr Adrian Turcanu

Here are some examples of functions.

Example 1.17. f : R → R defined by the formula f (x) = x2 is a real-valued


function of the kind studied in calculus courses.

Example 1.18. Let A = {1, 5, 7}, B = {3, 8, 22, 30}. A function f : A → B is


defined as
f (1) = 22 , f (5) = 3 , f (7) = 22 .

Example 1.19. Function f : N → N is defined so that f (1) = 1 and f (n + 1) =


(n + 1)f (n). The latter is called a recurrence relation. It allows one to compute
values of f starting from the one given explicitly. For example f (2) = f (1 + 1) =
2f (1) = 2 · 1 = 2. It is actually computing the factorial: f (n) = n!.

Example 1.20. The next example is called the McCarthy 91 function and was
given by John McCarthy, one of the founders of artificial intelligence.
Here f : N → Z is defined for positive integers n by

n − 10 if n ≥ 101
f (n) =
f (f (n + 11)) if n ≤ 100

If we try to find f (1) directly, we put n = 1 in the definition. This shows that f (1)
depends on f (12) which in turn depends on f (23) etc. It seems hopeless to find
f (1) in this way. The trick is to work backwards. Putting n = 100 in the definition
gives
f (100) = f (f (111)) = f (101) = 91
Putting n = 99 in the definition gives

f (99) = f (f (110)) = f (100) = 91 .

Continuing in this way we can show that f (n) = 91 for all n ≤ 100 .

If f : X → Y is any function, the set of images

Ran(f ) := {y ∈ Y | y = f (x) for some x ∈ X}

is called the range of f .


Discrete Mathematics Page 12

In Example 1.17 the range of f is the set of all non-negative real numbers:
Ran(f ) = {y ∈ R | y ≥ 0}. In Example 1.18 the range is the set Ran(f ) = {3, 22}.
For the McCarthy 91 function (Example 1.20) the range is Ran(f ) = {y ∈ N | y ≥
91}.
Definition 1.21. A function is called surjective if its range is equal to its codomain.
None of the above examples defines a surjective function. However it is easy to
construct functions from the above examples which are surjective by simply modi-
fying the codomain. For instance f (x) = x2 becomes surjective if we consider it as
a function from all real numbers into the non-negative real numbers: f : R → R≥0 .
Definition 1.22. A function is called injective if no two distinct elements of the
domain have the same image.
In the above only the factorial function of Example 1.19 is injective.

Given two functions f : A → B, g : B → C we can define their composition


g ◦ f : A → C by the rule g ◦ f (x) = g(f (x)). The notation g ◦ f needs to be read
from right to left: we first apply f then g.

Example 1.23. Let f : R → R be defined as f (x) = 2x2 and g : R → R is defined


as g(x) = 3x + 4 then

(f ◦ g)(x) = f (g(x)) = f (3x + 4) = 2(3x + 4)2 = 2(9x2 + 24x + 16) = 18x2 + 48x + 32

while
(g ◦ f )(x) = g(f (x)) = g(2x2 ) = 3(2x2 ) + 4 = 6x2 + 4

The identity function on a set A is the function i : A → A defined so that


i(x) = x.
Definition 1.24. Let f : A → B and g : B → A be functions. If g ◦ f : A → A is
the identity function on A and f ◦ g : B → B is the identity function on B then it
is said that f is the inverse of g (and g is the inverse of f ).

A function f that has an inverse is said to be invertible.


The following theorem is true.
Theorem 1.25. A function f is invertible if and only if it is surjective and injective.
Remark 1.4. A function that is both injective and surjective is often called bijective.

1.5.1 Exercises
Page 13 Dr Matteo Capoferri & Dr Adrian Turcanu

Exercise 1.5.1. For each of the following functions find their range. Determine
whether the function is surjective and whether it is injective.

(a)(∗) f : R → R , f (x) = 2x + 1 (b) g : R → R , g(x) = x4 + 1 ,

(c)(∗) h : X → Y , h(s) = number of ones in s ,


(d) j : X → Y , j(s) = the first bit of s
where X be the set of all finite non-empty strings of bits and let Y be the set of all
non-negative integers.

Solution. (a) The range is R because for any y ∈ R we always have a solution to
y = f (x) = 2x + 1 given by x = (y − 1)/2. This also gives the inverse function
f −1 (y) = (y − 1)/2. Therefore by Theorem 1.25 f is injective and surjective.

(c) The function h is surjective. To show this take any non-negative integer n.
If n > 0 then let sn be a string of length n containing only 1’s. then h(sn ) = n.
If n = 0 then we have h(0) = 0 where we take the string containing a single 0.
This function is not injective. To demonstrate this it suffices to note that, e.g.,
s(101) = 2 = s(011).

Exercise 1.5.2 (*). Let the functions f , g and h have R as their domain and
codomain, and be defined as
(
2
1 if x ≥ 0
f (x) = 4x − 3 , g(x) = x + 1 , h(x) = .
0 if x < 0

Find rules for the following functions (with domain and codomain R)

(a) f ◦ f , (b) h ◦ f , (c) h ◦ g .

Solution. (a) We have f ◦ f (x) = f (4x − 3) = 4(4x − 3) − 3 = 16x − 15.

(b) To calculate h ◦ f (x) we first obtain f (x) = 4x − 3. Then if 4x − 3 ≥ 0


the final result is 1 and if 4x − 3 < 0 the final result is 0. Since 4x − 3 ≥ 0 means
x ≥ 3/4 we can summarise the answer as
(
1 if x ≥ 3/4
h ◦ f (x) =
0 if x < 3/4

(c) Since g(x) = 1 + x2 is always greater or equal than 0, h ◦ g(x) = 1 for all x.
Discrete Mathematics Page 14

Exercise 1.5.3 (*). Find the inverse function for each of the following functions,
or explain why no inverse exists.

(a) g : R → R , g(x) = x2 ,

(b) j : S → S
where S is the set of non-empty finite strings of lower case letters, and j(s) gives
a string obtained by moving the last character to the beginning of the string, e.g.
j(yncrfm) = myncrf.

Solution. (a) This function is the same as the absolute value function g(x) = x2 =
|x|. Since g(−1) = 1 = g(1) this function is not injective and therefore by Theo-
rem 1.25 the inverse function does not exist.

(b) The inverse function j −1 (s) performs the inverse operation on the string: it
takes the first letter and moves it to the end of the string, e.g. j −1 (sdfj) = dfjs.

1.6 Mathematical Induction


Induction is one of the most commonly used proof techniques in Discrete Mathe-
matics and Computer Science. It is used for proving statements which depend on
the integers.

Suppose we want to find a formula for the sum of the first n odd integers:
• For n = 1 the sum is 1 = 12 .
• For n = 2 the sum is 1 + 3 = 4 = 22 .
• For n = 3 the sum is 1 + 3 + 5 = 9 = 32 .
• For n = 4 the sum is 1 + 3 + 5 + 7 = 16 = 42 .
Based on the above, it seems reasonable to conjecture that
1 + 3 + 5 + 7 + . . . + (2n − 1) = n2 .
But how does one rigorously prove this?

To start with, let us look at what it means for a statement (or proposition) to
depend on a positive integer n .

Example 1.26. Let P (n) be the statement

1 + 3 + 5 + 7 + . . . + (2n − 1) = n2 .

Then:
Page 15 Dr Matteo Capoferri & Dr Adrian Turcanu

• P (3) states that 1 + 3 + 5 = 32 ;

• P (4) states that 1 + 3 + 5 + 7 = 42 .

Both P (3) and P (4) are true.

Example 1.27. Let Q(n) be the statement 3n > (n + 2)2 . Then

• Q(2) states that 32 > 42 ;

• Q(3) states that 33 > 52 .

Q(2) is false, whereas Q(3) is true.

Example 1.28. Let P (n) be the statement n2 + n is even. Write down P (1) ,
P (3) , P (k) and P (k + 1) .
Solution. P (1) states that 12 + 1 is even. P (3) states that 32 + 3 is even. P (k)
states that k 2 + k is even. P (k + 1) states that (k + 1)2 + k + 1 is even.

Example 1.29. Let P (n) be the statement 50 − 2n ≥ 0 . Write down P (1) , P (5)
and P (30) . Which of them are true?
Solution. P (1) states that 50 − 2 ≥ 0 which is true. P (5) states that 50 − 10 ≥ 0
which is true. P (30) states that 50 − 60 ≥ 0 which is false.

Example 1.30. Let {an } be the sequence defined by a1 = 4 and

an+1 = 2an − 3 , n ≥ 1 .

Let P (n) be the statement an = 2n−1 + 3 . Write down P (1) , P (2) and P (3) .
Which of them are true?
Solution. P (1) states that a1 = 20 + 3 , that is, a1 = 4 . Hence P (1) is true. P (2)
states that a2 = 21 + 3 , that is, a2 = 5 . P (3) states that a3 = 22 + 3 , that is,
a3 = 7 .
We use an+1 = 2an − 3 to find a2 and a3 : a2 = 2a1 − 3 = 2(4) − 3 so a2 = 5,
and a3 = 2a2 − 3 = 2(5) − 3 so a3 = 7. Hence, both P (2) and P (3) are true.
Discrete Mathematics Page 16

Let P (n) be a proposition which depends n where n is a positive integer.


A proof by mathematical induction that P (n) is true for all positive integers n
consists of two steps.

Mathematical induction

Step 1. Show that P (1) is true.

Step 2. Let k be any positive integer. Show that if P (k) is true


then P (k + 1) is true.

Example 1.31. Use Mathematical Induction to prove that for any positive integer
n
1 + 3 + 5 + 7 + . . . + (2n − 1) = n2
Solution. Let P (n) be the statement

1 + 3 + 5 + 7 + . . . + (2n − 1) = n2 .

P (1) states that 1 = 12 which is correct. Hence P (1) holds.


Assume P (k) is true: 1 + 3 + 5 + 7 + . . . + (2k − 1) = k 2 . Then

1 + 3 + 5 + 7 + . . . + (2k − 1) + (2k + 1) = [1 + 3 + 5 + 7 + . . . + (2k − 1)] + 2k + 1.

Since P (k) holds,

1 + 3 + 5 + 7 + . . . + (2k − 1) + (2k + 1) = k 2 + 2k + 1 = (k + 1)2 .

This shows that P (k + 1) follows from P (k) .


By the principle of mathematical induction, P (n) is true for any positive integer
n .

Remark 1.5. In the above example, P (n) is a statement. It is not an algebraic


expression. It is not acceptable to write P (n) = n2 .

Example 1.32. Let {an } be the sequence defined by a1 = 1 and

an+1 = an + 8n , n ≥ 1 .

Prove by induction that an = (2n − 1)2 for all positive integers n .


Solution. Let P (n) be the statement: an = (2n − 1)2 .
P (1) is the statement: a1 = (2 − 1)2 . Since a1 = 1 , P (1) is true.
Page 17 Dr Matteo Capoferri & Dr Adrian Turcanu

Assume P (k) is true: ak = (2k − 1)2 . Then

ak+1 = ak + 8k
= (2k − 1)2 + 8k
= 4k 2 + 4k + 1
= (2k + 1)2 .

Since 2(k + 1) − 1 = 2k + 1 we see that P (k + 1) follows from P (k) . By the


principle of mathematical induction, P (n) is true for any positive integer n .

To prove things by induction you should:

(a) State P (n) .

(b) Show that P (1) is true.

(c) Do the inductive step : show that if P (k) is true then P (k + 1) is true.

It is worth stressing that one needs to carry out ALL of the above steps. Indeed,
there are a number of pitfalls in using the principle of mathematical induction as
the next three examples show.

I. It does not suffice to prove only that P (1) is true. Indeed, let P (n) be the
statement: n2 = n . Then P (1) is true. But P (n) is true only when n = 1
or n = 0 and is false for n ≥ 2.

II. It does not suffice to prove only that if P (k) is true then P (k + 1) is true.
Indeed, let P (n) be the statement: n + 1 = n . Assume that P (k) holds so
that k + 1 = k . Adding 1 to each side gives k + 2 = k + 1 so P (k + 1) is
true. Of course, P (1) is false so we cannot get started.

III. Another typical error is to give a proof of P (k) implies P (k + 1) which only
works for some values of k , for example k ≥ 2 . Let P (n) be the statement:
any n students taking the same examination must all score the same mark.
Clearly P (1) is true.
Assume that P (k) is true and let any group of k + 1 candidates be given.
Let A and B be particular candidates and C the remaining group of k − 1
students. Then A and C form a group of k students so by P (k) they all
have the same mark. The same is true of B and C . Thus A and B and the
group C score the same mark so P (k + 1) is true. By induction, P (n) holds
for all n .
The mistake is that the group C must not be empty. If k = 1 then C is
empty and the marks of students from the groups A and C do not coincide.
We have proved that P (k) is true implies that P (k + 1) is true if k ≥ 2 but
there is no way of establishing P (2) which is false.
Discrete Mathematics Page 18

Example 1.33. Let {an } be the sequence defined by a1 = 1 and



an+1 = 2 + an , n ≥ 1 .

Prove by induction that an ≤ 2 for all positive integers n .


Solution. Let P (n) be the statement: an ≤ 2 . Since a1 = 1 , P (1) is true.
Assume that P (k) holds. Thus ak ≤ 2. Then

ak+1 = 2 + ak

≤ 2+2
= 2,

that is, P (k + 1) is true. By induction P (n) is true for all n .

The next example uses the factorial function n! . The number 5! (read five
factorial or factorial 5) means 5 × 4 × 3 × 2 × 1 . Note that 1! = 1 and that by
convention 0! = 1 . The reader should check by calculation that 4! = 24 and use a
calculator to check that 7! = 5040 .

Example 1.34. Prove by induction that 2n < n! for n ≥ 4 .


Solution. Let P (n) be the statement: 2n < n! .
We first check that P (4) is true. This is correct since 4! = 24 > 16 = 24 .
Assume that k ≥ 4 and that P (k) holds so that 2k < k! . Then

2k+1 = 2 2k


< 2 (k!)
< (k + 1) k!
= (k + 1)!.

Hence 2k+1 < (k + 1)! so P (k + 1) is true.


By induction P (n) is true for all n .

1.6.1 Exercises

Exercise 1.6.1 (∗). Let P (n) be the statement 3n − 100 ≥ 0 . Write down P (1) ,
P (4) and P (40) . Which of them are true?

Solution. P (1) states that 3(1) − 100 ≥ 0 , which is false.


Page 19 Dr Matteo Capoferri & Dr Adrian Turcanu

P (4) states that states that 3(4) − 100 ≥ 0 , which is false.


P (40) states that states that 3(40) − 100 ≥ 0 , which is true.

Exercise 1.6.2 (∗). Let {an } be the sequence defined by a1 = 3 and

an+1 = 5an − 8 , n ≥ 1 .

Let P (n) be the statement an = 5n−1 + 2 . Write down P (1) and P (2) . Which of
them are true?

Solution. P (1) states that a1 = 50 + 2 , that is, a1 = 3 . Hence P (1) is true.


P (2) states that a2 = 51 +2 , that is, a2 = 7 . Since a2 = 5a1 −8 = 5(3)−8 = 7 ,
P (2) is true.

Exercise 1.6.3 (∗). Use Mathematical Induction to prove that for any positive
integer n
1 + 2 + 22 + 23 + . . . + 2n = 2n+1 − 1.

Solution. Let P (n) be the statement

1 + 2 + 22 + 23 + . . . + 2n = 2n+1 − 1.

P (1) states that 1 + 2 = 22 − 1 = 3 which is correct.


Assume P (k) is true: 1 + 2 + 22 + 23 + . . . + 2k = 2k+1 − 1 . Then by P (k) ,

1 + 2 + 22 + 23 + . . . + 2k + 2k+1 = 2k+1 − 1 + 2k+1 .

Since 2k+1 + 2k+1 = 2k+2 ,

1 + 2 + 22 + 23 + . . . + 2k + 2k+1 = 2k+2 − 1.

This shows that P (k + 1) follows from P (k) .


By the principle of mathematical induction, P (n) is true for any positive integer
n .

Exercise 1.6.4 (∗). Prove by induction that 3n < n! for n ≥ 7 .

Solution. Let P (n) be the statement 3n < n! .


We first check that P (7) is true. This is correct since 7! = 5040 and 37 = 2187 .
Discrete Mathematics Page 20

Assume that k ≥ 7 and that P (k) holds so that 3k < k! . Then

3 3k < 3 (k!) < (k + 1) k! = (k + 1)!.




Hence 3k+1 < (k + 1)! so P (k + 1) is true. By induction P (n) is true for all n .

Exercise 1.6.5 (∗). Let {an } be the sequence defined by a1 = x and

a2n + 12
an+1 = , n≥1
7
where 3 < x < 4. Prove by induction that 3 < an < 4 for all n.

Solution. Let P (n) be the statement : 3 < an < 4 .


Since a1 = x and 3 < x < 4 , P (1) is true.
Assume that P (k) holds so that 3 < ak < 4 . Then

7ak+1 = a2k + 12
< 16 + 12
= 28

so ak+1 < 4. Also,


7 ak+1 = a2k + 12 > 9 + 12 = 21
so P (k + 1) is true. By induction P (n) is true for all n .

Exercise 1.6.6 (∗). For n ≥ 2 the sequence {sn } is given by by


    
1 1 1
sn = 1 − 1− ... 1 −
2 3 n

so that s2 = 12 and s3 = 31 · By computing more values of sn if needed, guess a


formula for sn and use induction to prove it.

Solution. Using the formula for sn we obtain


1 1 1
s2 = s3 = s4 = ,
2 3 4
1
and we conjecture that sn = .
n
1
Let P (n) be the statement : sn = ·
n
Page 21 Dr Matteo Capoferri & Dr Adrian Turcanu

By the above calculations, P (2) is true.


Assume that P (k) holds so that
    
1 1 1 1
sk = 1 − 1− ... 1 − = .
2 3 k k

Then
       
1 1 1 1 1 1
sk+1 = 1− 1− ... 1 − 1− = 1− .
2 3 k k+1 k k+1

Since  
1 1 1
1− = ,
k k+1 k+1
P (k + 1) is true. By induction P (n) is true for all n ≥ 2 .

Exercise 1.6.7 (∗). Let {sn } be the sequence defined by

sn = 1(1!) + 2(2!) + 3(3!) + . . . + n(n!)

Check that s1 = 1 , s2 = 5 and s3 = 23 . By computing more values of sn if needed,


guess a formula for sn and use induction to prove it.

Solution. Using the formula for sn we obtain

s1 = 1 s2 = 5 s3 = 23 s4 = 119.

Since
2! = 2 3! = 6 4! = 24 5! = 120
we conjecture that sn = (n + 1)! − 1 .
Let P (n) be the statement: sn = (n + 1)! − 1 . The above calculations show
that P (n) is true for n = 1, 2, 3, 4 .
Assume that P (k) holds so that sk = (k + 1)! − 1 . Then

sk+1 = 1(1!) + 2(2!) + . . . + k(k!) + (k + 1) (k + 1)! = (k + 1)! − 1 + (k + 1) (k + 1)!.

Since

(k + 1)! − 1 + (k + 1) (k + 1)! = (k + 1)! [1 + k + 1] − 1 = (k + 2)! − 1,

P (k + 1) is true. By induction P (n) is true for all n .


Discrete Mathematics Page 22

1.7 The Sum and Product Rules


Consider the following examples of counting problems

Example 1.35. The mathematics teaching committee requires one student repre-
sentative from either the first year or the second year or the third year. If there
are 500 first year, 300 second year and 100 third year students, how many possible
different representatives are there?
Solution. There are obviously 500 different choices for picking a representative from
the first year students, 300 for the second and 100 for the third year. Since the
students are all different and we have to pick only one representative from either
year we can add the numbers of choices for a representative from each year to obtain
900 different possible representatives.

The solution to the above problem follows form a general rule.

The sum rule

If there are n(A) ways to do A and, distinct from them, n(B) ways
to do B, then the number of ways to do A or B is n(A) + n(B).
Similarly, one adds n(A), n(B), n(C) when one must do A or B or C;
and so on.

Consider a different problem.

Example 1.36. The mathematics student committee is composed of three students:


one from each of the first year, the second year and the third year. If there are 500
first year, 300 second year and 100 third year students, how many possible different
committees are there?
Solution. There are 500 choices for a representative from the first year students.
For each of those representatives there are 300 ways to pick a representative from
the second year students. So we have 500 × 300 = 150, 000 ways to pick the two
representatives from the first and second year students. For each choice of those (for
each pair of representatives) we have 100 choices for a third year representatives. In
total this gives us 150, 000 × 100 = 15, 000, 000 different possible committees. Thus
in this problem we had to multiply through the numbers for each respective choice:
500 × 300 × 100.

The solution to the above problem follows form a general rule.


Page 23 Dr Matteo Capoferri & Dr Adrian Turcanu

The product rule

If there are n(A) ways to do A and n(B) ways to do B, then the


number of ways to do A and B is n(A) × n(B). It is assumed that
A and B are independent; that is, the number of choices in B is the
same regardless of which choice in A is taken. Similarly, one multiplies
theree terms: n(A) × n(B) × n(C) if one has to do choices in A, B,
and C independently; and so on.

To solve the following example we need to use both of the above rules.

Example 1.37. In a certain computer system a file name must be a string of letters
and digits which is 1,2, or 3 symbols long. The first symbol must be a letter and
the system does not make any distinction between uppercase and lowercase letters.
How many legitimate file names are there?
Solution. A file name either has one symbol, or two symbols or three symbols. In
each case we have 26 choices for the first letter (the 26 letters of the alphabet).
The number of one-symbol names is then 26. The number of 2-symbol names is
26 × 36 = 936 because for the second symbol we can have either a letter or a
digit, 36 = 26 + 10 choices. We multiply the number of choices for the first and
for the second symbol because both choices are done independently. Similarly the
number of three-symbol names is 26 × 36 × 36 = 33696. Summing the numbers for
the three different cases (by the sum rule) we obtain that the system at hand can
accommodate 26 + 936 + 33696 = 34658 different files.

1.7.1 Exercises

Exercise 1.7.1 (∗). A binary word is made of 0’s and 1’s. How many binary words
are there with length exactly 7? How many binary words are there with length up
to 3?

Solution. For each digit we have two choices: 0 or 1. Thus by the product rule
we have 2 × 2 × 2 × 2 × 2 × 2 × 2 = 27 different words of length 7. To count the
number of words with length up to 3 we need to add up the numbers of words of
length 1,2,3 (here we use the sum rule). Using the product rule as before we obtain:
21 + 22 + 23 = 14 - the number of binary words with length up to 3.

Exercise 1.7.2. In a restaurant for the main dish there are 10 meat, 5 fowl, and 8
fish choices. How many ways are there to pick a main dish?
Discrete Mathematics Page 24

Exercise 1.7.3 (∗). A salesman is to visit 5 towns. Assuming that he goes to one
town after another, visiting all of them once, in how many orders can he make his
trip?

Solution. The salesman has 5 choices for the first town in his itinerary. Since each
town is to be visited only once he/she has 4 choices for the second town in the trip,
and so on. By the product rule we obtain 5 × 4 × 3 × 2 × 1 = 120 - the number of
different trips.

Exercise 1.7.4 (∗). How many numbers between 1 and 1000 have exactly one 7 in
them?

Solution. The condition of the problem means that we are considering numbers of
up to 3 digits. Hence we can count separately the numbers at hand with length
1,2,3 and then add them up. Clearly we have only one such number of length 1: 7.
For two-digit numbers the digit 7 can either be the first digit or the second one. If
it stands first then we have 9 choices for the second digit: 0, 1, 2, 3, 4, 5, 6, 8, 9. If 7
is the second digit we have only 8 choices for the first digit because 0 is not allowed.
Thus we have 9 + 8 = 17 required numbers of length 2. For length 3 the digit 7 can
again be on the 1st, 2nd or 3rd position. As before, taking care of the zero, we obtain
9 × 9, 8 × 9 and 8 × 9 different numbers for each case respectively. Finally using the
sum rule we add up all different cases and obtain 1 + 17 + 81 + 72 + 72 = 243.

1.8 Permutations and Combinations


Permutations and combinations are the basic building blocks of combinatorial math-
ematics.

Definition 1.38. A permutation of n objects taken k at a time is any ordered


selection of k distinct objects from a given set of n objects.
Note that the order in which the selection is made matters. Thus for a set of 5
letters {B, S, W, K, L} the lists {B, W, K}, {W, B, K} are two different permutations
of the 5 given letters taken 3 at a time.
Repetitions are not allowed. Thus for the above example a list {B, B, L} is not
a permutation. We will often say “ordered selection without repetitions” instead of
“permutations” as this is self-descriptive.

Example 1.39. In how many ways can a committee with 10 members select a
chairperson, a treasurer and an administrator?
Page 25 Dr Matteo Capoferri & Dr Adrian Turcanu

Solution. Suppose that the first person to be selected is to be the chairperson. There
are 10 different was to do it. Suppose the second person selected is the treasurer for
whom we have 9 choices. Finally, suppose the last person chosen is the administrator,
for whom there are 8 possible people available. By the product rule the number of
selections is 10 × 9 × 8 = 720.

In the above example we had to make an ordered selection of 3 distinct people


from a group of 10 people. For general permutations the following theorem holds.

Theorem 1.40. The number of ordered selections of k distinct objects from a set
of n objects is n(n − 1)(n − 2) . . . (n − k + 2)(n − k + 1).

Remark 1.6. The above number can be alternatively written as

n!
n(n − 1)(n − 2) . . . (n − k + 2)(n − k + 1) = (1.1)
(n − k)!

where we used the factorial notation

n! = n × (n − 1) × (n − 2) × · · · × 3 × 2 × 1

Note that by convention one defines

0! = 1 .

With this convention the expression on the right hand side in (1.1) gives the same
result for n = k as the expression on the left hand side.

Proof of Theorem 1.40. There are n ways to select the first object. After the first
object is selected there are n − 1 objects left and there are respectively n − 1 choices
for the second object. We continue selecting until the last object for which there
are n − k + 1 choices. By the product rule these selections can be made in n(n −
1)(n − 2) . . . (n − k + 1) ways.

Remark 1.7. Observe that using formula (1.1) for k = n we find that the number of
different ways to order n objects is n!.
Consider now a different kind of selections called combinations.

Definition 1.41. A combination of n objects taken k at a time is any selection of


k distinct objects from a given set of n objects.

In this case the order of objects selected does not matter. We will often say
“unordered selection without repetitions” rather than “combination”.
Discrete Mathematics Page 26

Theorem 1.42. The number of unordered selections of k objects from a set of n


objects without repetitions is
n(n − 1) . . . (n − k + 1) n!
= (1.2)
k! (n − k)!k!
The combination of factorials on the right hand side is called a binomial coefficient
and is denoted  
n n!
:= . (1.3)
k (n − k)!k!
Proof. We already know that the number of ordered selections is given by formula
(1.1). To pick an ordered selection of k elements one can first make an unordered
selection of k elements and then choose an order. We know that there are k! different
ways to order k elements. Thus by the product rule
 
n! n
= × k!
(n − k)! k

where nk stands for the number of unordered selections. Dividing both sides by k!


we obtain formula (1.2).


The binomial coefficients (1.3) appear in the binomial formula that gives coeffi-
cients for an expansion of a power
n  
n
X n k n−k
(x + y) = x y . (1.4)
k=0
k

For example
           
5 5 0 5 5 1 4 5 2 3 5 3 2 5 4 1 5 5 0
(x + y) = xy + xy + xy + xy + xy + xy
0 1 2 3 4 5
= y 5 + 5xy 4 + 10x2 y 3 + 10x3 y 2 + 5x4 y + x5 .

Example 1.43. In the card game bridge, a hand has 13 cards. There are 52 cards
in a deck. How many different bridge hands are there?
Solution. We have to make an unordered selection of 13 cards out of 52. Repetitions
are not allowed. By the above theorem there are 52 13
= 635013559600 different
bridge hands.

Example 1.44. A full house in poker is a collection of 5 cards in which 3 of them


are from one denomination and 2 from another. In a pack of cards there are 13
denominations (2,3,...,queen,king,ace) and 4 cards of each. How many different full
houses are there?
Page 27 Dr Matteo Capoferri & Dr Adrian Turcanu

Solution. The order in which we pick cards for a full house does not matter so we
can specify a convenient order. Let us first pick a denomination for three cards.
There are 13 choices. Next we have to pick  3 cards out of 4 in this denomination.
Since the order does not matter we have 43 = 4 choices. Next let us pick the second
denomination. We have 12  choices for it. To pick 2 cards out of 4 in the chosen
denomination we have 42 = 6 choices. Finally by the product rule we multiply
through the choices to obtain 13 × 4 × 12 × 6 = 3744 — the number of different full
houses.

1.8.1 Exercises

Exercise 1.8.1. Find in how many ways an ordered selection of 2 elements out of
a set of 5 elements can be made. No repetitions are allowed. How many unordered
selections of 2 elements from the same set are there?

Exercise 1.8.2. There are 14 available ingredients for making perfume. How many
different perfumes can be made if one is to use 4 ingredients for each one?

Exercise 1.8.3. A travelling salesemen is to visit any 5 different cities from a list
of 10. How many different itineraries he can have if he visits the cities successively
one after another?

Exercise 1.8.4 (∗). What is the number of ways in which a subset of one or two
elements can be picked up from a set of n elements?

Solution. Clearly there are n ways to pick a subset of one element. To pick a subset
of two elements we have to make an unordered selection with no repetitions of 2
elements out of n. Hence we have n2 = 2×(n−2)!
n!
= n(n−1)
2
two-element subsets. By
n(n−1) n(n+1)
the sum rule we obtain n + 2
= 2
.

Exercise 1.8.5 (∗). A university department has 12 male professors and 3 female
professors. It is decided that every committee of professors in this department should
Discrete Mathematics Page 28

have at least one female member. How many different committees of 12 people can
be formed?

Solution. If we temporarily disregard the requirement that there is at least one


15

female professor in the committee we have 12 = 455 different committees. To
ensure the condition of having at least one female professor we need to subtract
from the above number the number of all male committees which is just 1 as there
are only 12 male professors. Hence the final answer is 454.

Exercise 1.8.6. The computer science students are entering a team of 5 in the
university relay race. There are 20 undergraduates and 10 postgraduates. How
many teams are possible if
(a)(∗) any student is eligible
(b) there must be 2 postgraduates and 3 undergraduates

Solution. (a) We have an unordered


 selection without repetitions of 5 students out
30
of 30 = 10 + 20. This gives us 5 = 15504 possible teams.

Exercise 1.8.7 (∗). How many ways are there to pick a combination of k distinct
numbers from {1, 2, . . . , n} if 1 and 2 cannot both be picked?

Solution. We are dealing here with unordered selections. If we temporarily disregard


the condition on 1 and 2 not being picked together we obtain nk selections. To take


care of the additional condition we must subtract from that result the number of
forbidden combinations. In such combinations both 1 and 2 are picked. The number
n−2 n n−2

of all such combinations is k−2 . Therefore the final answer is k − k−2 .

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy