Discrete Mathematics Notes 2023
Discrete Mathematics Notes 2023
Course Notes
Felipe Balbi
Week 1 5
1.101 Introduction to discrete mathematics . . . . . . . . . . . . . . . . . . . . 5
1.104 The definition of a set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.106 The listing method and rule of inclusion . . . . . . . . . . . . . . . . . . . 7
1.108 The powerset of a set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.110 Set operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Week 2 13
1.201 The representation of a set using Venn diagrams . . . . . . . . . . . . . . 13
1.203 De Morgan’s laws . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
1.205 Laws of sets: Commutative, associative and distributive . . . . . . . . . . 16
1.207 Partition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Week 3 20
2.101 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.102 The Definition of A Function . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.104 Plotting functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.106 Injective and surjective functions . . . . . . . . . . . . . . . . . . . . . . . 25
Week 4 28
2.201 Function composition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.203 Bijective functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.205 Logarithmic functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.207 Floor and ceiling functions . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Week 5 35
3.101 Introduction to propositional logic . . . . . . . . . . . . . . . . . . . . . . 35
3.103 Propositions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
3.105 Truth tables and truth sets . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.107 Compound propositions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Week 6 41
3.202 Logical implication (→) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
3.204 Logical equivalence (↔) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
3.206 Laws of propositional logic . . . . . . . . . . . . . . . . . . . . . . . . . . 45
2
Contents
Week 7 46
4.101 Introduction to predicate logic . . . . . . . . . . . . . . . . . . . . . . . . 46
4.103 What are predicates? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
4.105 Quantification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
4.107 Nested Quantifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Week 8 52
4.201 De Morgan’s laws for quantifiers . . . . . . . . . . . . . . . . . . . . . . . 52
4.203 Rules of inference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
4.205 Rules of inference with quantifiers . . . . . . . . . . . . . . . . . . . . . . 59
Week 9 63
5.101 Introduction to Boolean algebra . . . . . . . . . . . . . . . . . . . . . . . 63
5.103 Postulates of Boolean algebra . . . . . . . . . . . . . . . . . . . . . . . . . 65
5.105 Boolean functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Week 10 70
5.201 Logic gates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
5.203 Combinational circuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
5.205 Simplification of circuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Week 11 81
6.101 Introduction to proofs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
6.103 The principle of mathematical induction . . . . . . . . . . . . . . . . . . . 83
6.106 Proof by induction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
6.108 Strong induction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Week 12 89
6.201 Recursive definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
6.204 Recurrence relations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
6.206 Solving recurrence relations . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Week 13 93
7.101 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
7.103 Definition of a graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
7.105 Walks and paths in a graph . . . . . . . . . . . . . . . . . . . . . . . . . . 96
7.107 The degree sequence of a graph . . . . . . . . . . . . . . . . . . . . . . . . 100
7.109 Special graphs: simple, r-regular and complete graphs . . . . . . . . . . . 102
Week 14 105
7.201 Isomorphic graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
7.203 Bipartite graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
7.205 The adjacency matrix of a graph . . . . . . . . . . . . . . . . . . . . . . . 107
7.207 Dijkstra’s algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
3
Contents
Week 15 112
8.103 Definition of a tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
8.105 Spanning trees of a graph . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
8.107 Minimum spanning tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
Week 16 117
8.201 Rooted trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
8.203 binary search trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
Week 17 122
9.101 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
9.103 Definition of a relation: relation versus function . . . . . . . . . . . . . . 123
9.105 Matrix and graph representations of a relation . . . . . . . . . . . . . . . 124
9.107 The properties of a relation: reflexive, symmetric and anti-symmetric . . 126
9.109 Relation properties: transitivity . . . . . . . . . . . . . . . . . . . . . . . 129
Week 18 132
9.201 Equivalence relations and equivalence classes . . . . . . . . . . . . . . . . 132
9.203 Partial and total order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
Week 19 135
10.101 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
10.103 The basics of counting . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
10.105 The pigeonhole principle . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
10.107 Permutations and combinations . . . . . . . . . . . . . . . . . . . . . . . 137
Week 20 138
10.201 Binomial coefficients and identities . . . . . . . . . . . . . . . . . . . . . 138
10.204 Generalised permutations and combinations . . . . . . . . . . . . . . . . 140
10.206 Distinguishable objects and boxes . . . . . . . . . . . . . . . . . . . . . . 141
4
Week 1
Learning objectives:
• Define a set, the elements of a set and the cardinality of a set.
• Define the concepts of the universal set and the complement of a set, and the
difference between a set and a powerset of a set.
• Define the concepts of the union, intersection, set difference and symmetric differ-
ence, and the concept of a membership table.
Essential Reading
• Rosen, K.H. Discrete mathematics and its applications. (New York: McGraw-Hill,
2012) 7th edition, pp.117–126
• Exercises
pp.127–128 exercises 1–8 and 12–19.
For reading on set operations, please see the Essential reading for Week 2.
5
Week 1
Definition of a set
A collection of any kind of objects: people, ideas, numbers. . .
A set must be well-defined, meaning that there can be no ambiguity to which objects
belongs to the set.
E = {2, 4, 6, 8}
V = {a, e, i, o, u}
EmptySet = {} = ∅
Special Sets: N, Z, Q, R
N: set of natural numbers
Z: set of integers
Q: set of rational numbers
R: set of real numbers
6
Week 1
A = {1, 2, 3, 4, 5, 6, 7, 8, 9}
B = {{1, 2, 3, 4}, {5, 6}, {7, 8, 9}}
Powerset of a set
Definition 4 (Powerset). Given a set S, the powerset of S, P (S), is the set containing
all the subsets of S
1. Example 1
Given a set S = {1, 2, 3}, the subsets of S are:
∅, {1}, {2}, {3},
{1, 2}, {1, 3}, {2, 3},
{1, 2, 3}
7
Week 1
P (∅) = {∅}
P (P (∅)) = {∅, {∅}}
Cardinality of a powerset
Given a set S, then |P (S)| = 2|S|
In other words: the cardinality of the powerset of S is the 2 to the power of the cardinality
of S. For example:
S = {1, 2}
|S| = 2
P (S) = {∅, {1}, {2}, {1, 2}}
|P (S)| = 4 = 22 = 2|S|
1. Example
Given a set A, if |A| = n find |P (P (P (A)))|
|P (A)| = 2n
n
|P (P (A))| = 22
2n
|P (P (P (A)))| = 22
Union (∪)
Definition 5 (Union). Given two sets A and B, the union of A and B, A ∪ B, contains
all the elements in either A or B.
A ∪ B = {x | x ∈ A or x ∈ B}
8
Week 1
A B
1. Example
A = {1, 2, 3}
B = {4, 5, 6}
A ∪ B = {1, 2, 3, 4, 5, 6}
2. Membership Table (A ∪ B)
A B A∪B
0 0 0
0 1 1
1 0 1
1 1 1
Intersection (∩)
Definition 6 (Intersection). Given two sets A and B, the intersection of A and B,
A ∩ B, contains all the elements in both A and B.
A ∩ B = {x | x ∈ A and x ∈ B}
A B
9
Week 1
1. Example
A = {1, 2, 3}
B = {2, 3, 4}
A ∩ B = {2, 3, }
2. Membership Table (A ∩ B)
A B A∩B
0 0 0
0 1 0
1 0 0
1 1 1
Difference (−)
Definition 7 (Difference). Given two sets A and B, the difference of A and B, A − B,
contains all the elements that are in A but not in B.
A − B = {x | x ∈ A and x ∈
/ B}
A B
1. Example
A = {1, 2, 3}
B = {3, 4, 5}
A − B = {1, 2, }
2. Membership Table (A − B)
10
Week 1
A B A−B
0 0 0
0 1 0
1 0 1
1 1 0
A ⊕ B = {x | (x ∈ A or x ∈ B) and x ∈
/ A ∩ B}
A B
1. Example
A = {1, 2, 3}
B = {3, 4, 5}
A ⊕ B = {1, 2, 4, 5}
2. Membership Table (A ⊕ B)
A B A⊕B
0 0 0
0 1 1
1 0 1
1 1 0
Summary
1. Operations
11
Week 1
A = {1, 2, 3}
B = {3, 4, 5}
A ∪ B = {1, 2, 3, 4, 5}
A ∩ B = {3}
A − B = {1, 2}
A ⊕ B = {1, 2, 4, 5}
2. Membership Table
A B A∪B A∩B A−B A⊕B
0 0 0 0 0 0
0 1 1 0 0 1
1 0 1 0 1 1
1 1 1 1 0 0
12
Week 2
Learning objectives:
• Understand the concept of Venn diagrams and how they are used to represent and
compare different set expressions.
• Understand and prove De Morgan’s law using membership tables.
Essential Reading
• Rosen, K.H. Discrete mathematics and its applications. (New York: McGraw-Hill,
2012) 7th edition, pp.128–137.
• Exercises
pp.138–139 exercises 1–9, 14, 15, 17, 18, 22–26, 32 and 34–36.
13
Week 2
Complement of a set
Given a set A, the complement of A is written as A, contains all the ements in the
universal set U but not in A. It’s represented by the area in red in figure below.
U
In other words A = U − A.
Example
U = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
A = {2, 4, 6, 8, 10}
A=U −A
= {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} − {2, 4, 6, 8, 10}
= {1, 3, 5, 7, 9}
The union of a set A with its completement A is always the universal set U .
A∪A=U
The symmetric difference of A and B is the same as the union of A and B minus the
intersection of A and B:
14
Week 2
A ⊕ B = A ∪ B − (A ∩ B)
A∪B =A∩B
A∩B =A∪B
15
Week 2
Commutativity
When the order of operands in an operation does NOT affect the result, we say the
operation is commutative. For example, addition is commutative
2+3=3+2
2·3=3·2
2 − 3 6= 3 − 2
In Set Theory, Union ∪, Intersection ∩, and Symmetric Difference ⊕ are all commutative
operations. Much like in Algebra, Set difference is NOT commutative:
A = {1, 2}
B = {1, 3}
A − B = {1, 2} − {1, 3} = {2}
B − A = {1, 3} − {1, 2} = {3}
(A − B) 6= (B − A)
Associativity
When the grouping of elements in an operation doesn’t change the result, we say the
result is associative. Addition is associative:
(a + b) + c = a + (b + c)
In set theory, Union, Intersection and Symmetric Difference are all associative opera-
tions. Set difference is not associative:
16
Week 2
A = {1, 2}
B = {1, 3}
C = {2, 3}
(A − B) − C = ({1, 2} − {1, 3}) − {2, 3}
= {2} − {2, 3}
=∅
∴ (A − B) − C 6= A − (B − C)
Distributivity
The distributive property, in general, refers to the distributive law of multiplication which
states that multiplying a sum of two numbers b and c by a coefficient a is the same as
multiplying each addend by the coeficient a and adding the resulting products. We say
the multiplication is distributive over the addition:
a · (b + c) = a · b + a · c
A ∪ (B ∩ C) = (A ∪ B) ∩ (B ∪ C)
A ∩ (B ∪ C) = (A ∩ B) ∪ (B ∩ C)
17
Week 2
(A ∩ B) ∪ B = (A ∩ B) ∩ B
= (A ∩ B) ∩ B
= (A ∪ B) ∩ B
=A∩B∪B∩B
=A∩B∪∅
=A∩B
=B∩A
1.207 Partition
A partition of an object is a subdivision of the object into parts such that the parts are
completely separated from each other, yet together they form the whole object.
Data partitioning has many applications in Computer Science such as Big Data analysis.
This is usually referred to as Divide and Conquer approach. Such techniques must be
applied in cases where the entire input data doesn’t fit into the physical memory of the
Computer. In such cases, we must find a way to partition the data so that subsets of the
original data can be operated on without changing the result of the whole computation.
18
Week 2
Definition 9 (Set Partition). A partition of set A is a set of subsets Ai such that all
subsets are disjointed and then union of all subsets Ai is equal to A.
19
Week 3
Learning objectives:
• Define a function.
• Describe the properties of functions.
• Explain how to plot a function.
Essential Reading
• Rosen, K.H. Discrete mathematics and its applications. (New York: McGraw-Hill,
2012) 7th edition, pp.140–146.
• Exercises
pp.153–154 exercises 1–4 and 6–17.
2.101 Introduction
A function is a rule that relates to how one quantity depends on another quantity. Much
like a voltage depends on electrical current and resistance.
During this lecture, we learn the definition of a function and study a few of their prop-
erties.
Definition
A function maps an element of set 1 to an element in set 2. Such mapping is well-behaved
meaning that given a starting point we always know exactly where to go. For example,
we could have a function that maps a set of strings to their corresponding number of
characters:
20
Week 3
Sea → 3
Land → 4
Sky → 3
On → 2
Sea → 3
Land → 4
Sky → 3
21
Week 3
In this case:
Moreover, we can say that 2 is the image of the string On and On is the pre-image of 2.
P re − images(2) = {On}.
3 is the image of Sea and Sky, therefore P re − images(3) = {Sea, Sky}.
Linear Functions
A function f is called a linear function if it is of the form f (x) = ax + b. This function
is a straight line passing through the point (0, b) with gradient a.
If a > 0, then the function is increasing. It’s decreasing if a < 0.
In order to plot this function, first we make a table of values for this function. We use
f (x) = 3x + 2 as an example.
x f(x)
0 2
1 5
2 8
3 11
4 14
22
Week 3
Quadratic functions
A function f of the form f (x) = ax2 + bx + c is called a Quadratic function.
x f(x)
0 0
1 1
2 4
3 9
4 16
23
Week 3
Exponential functions
A function f of the form f (X) = bx is called an exponential function. The variable b is
called the base of the function.
A more formal definition may be:
Definition 11 (Exponential Function). The function f defined by f : R → R+ and
f (x) = bx where b > 0 and b 6= 1 is called and exponential function with a base b.
x f(x)
0 1
1 2
2 4
3 8
4 16
24
Week 3
The point (0, 1) is the common point for all exponentials. When b > 1 we have an
exponential growth. When 0 < b < 1, we have exponential decay.
25
Week 3
∴ f is injective.
a 6= b →2a 6= 2b
2a + 3 6= 2b + 3
f (a) 6= f (b)
∴ f is injective.
Proof.
f (5) = (5)2 = (−5)2 = f (−5)
however 5 6= −5
∴ f is not injective.
26
Week 3
Surjective Functions
Let f : A → B be a function; f is said to be surjective, or onto if and only if ∀y ∈ B ∃x ∈
A | y = f (x). This means that every element in the co-domain of f , B, has at least
one pre-image in the domain of f , A. This is equivalent to saying that the range and the
co-domain of a surjective function, are equal (i.e. Rf = co − Df ).
1. Example: linear function
Show that a function f : R → R with f (x) = 2x + 3 is a surjection (onto).
To prove this, we must show that for every element in B, there is a pre-image in
A.
f (x) = y →2x + 3 = y
2x + 3 − 3 = y − 3
2x y−3
=
2 2
y−3
x= ∈R
2
y−3
∴ ∀y ∈ R∃x = 2 ∈ R | f (x) = y, hence f is surjective.
27
Week 4
Learning objectives:
• Discuss special functions.
• Describe inverse functions.
Essential Reading
• Rosen, K.H. Discrete mathematics and its applications. (New York: McGraw-Hill,
2012) 7th edition, pp.146–153.
• Exercises
pp.153–155 exercises 5, 14–25, 30–36, 44–46 and 49.
For logarithmic and exponential functions, please read Appendix 2 and complete exercises
1 to 6 in Appendix 2.
(f ◦ g)(x) = f (g(x))
= f (x2 )
= 2x2
(f ◦ g)(1) = f (g(x))
= f (12 )
= 2 · 12
=2
28
Week 4
Exercise 1:
Show that the function f : R → R with f (x) = 2x + 3 is a bijective (invertible) function.
Proof. To prove this, suffices to prove that this function is both an injection and a
surjection. Let’s prove the injection case first:
Let a, b ∈ R, we will show that if f (a) = f (b) then a = b.
∴ f is injective.
Now turning our attention to the surjection case, we have:
Let y ∈ R, we will show that ∀y ∈ R∃x ∈ R | f (x) = y.
f (x) = y →2x + 3 = y
2x + 3 − 3 = y − 3
2x y−3
=
2 2
y−3
x= ∈R
2
29
Week 4
y−3
∴ ∀y ∈ R∃x = 2 ∈ R | f (x) = y, hence f is surjective.
Because we have proved that f (x) = 2x + 3 is both an injection and a surjection, we
have also proved that it is a bijection.
Inverse function
Definition 13 (Inverse function). Let f : A → B, if f is bijective, then the inverse
function f −1 exists and is defined as f −1 : B → A.
Given this definition, let’s find the inverse of 2x + 3.
Exercise 2:
The following function f : R → R with f (x) = 2x + 3 is a bijection. Find the inverse
function f −1 .
f (x) = 2x + 3
f (x) = y
2x + 3 = y
2x + 3 − 3 = y − 3
2x y−3
=
2 2
y−3
x=
2
x−3
∴ f −1 (x) =
2
Identity function
There is one special case of composition which is (f ◦ f −1 )(x) = (f −1 ◦ f )(x) = x. For
example if f (x) = 2x, then f −1 (x) = x2 , therefore (f ◦ f −1 )(x) = 2 x2 = x. Similarly,
(f −1 ◦ f )(x) = 2x
2 = x.
30
Week 4
y
f (x) = 2xf (x) = x
x
f (x) = 2
Definition
With that review out of the way, we can define Logarithmic functions:
Definition 14 (Logarithmic function). The logarithmic function with base b where b > 0
and b 6= 1 is defined as follows:
logb x = y ↔ x = by
We can say that logb x is the inverse function of the exponential function bx .
31
Week 4
3. logb mn = n timeslogb m
4. logb 1 = 0
5. logb b = 1
Exercise 1
1. log3 81
log3 81 = log3 34 = 4 × log3 3 = 4 × 1 = 4
2. log10 100
log10 100 = log10 102 = 2 × log10 10 = 2 × 1 = 2
1
3. log3 81
1
log3 81 = log3 81−1 = log3 3−4 = −4 × log3 3 = −4 × 1 = −4
4. log2 1
log2 1 = log2 20 = 0 × log2 2 = 0 × 1 = 0
Natural logarithm
The natural logarithm, commonly written as ln(x) is the logarithm with base e. In other
words: ln(x) = loge x where e ≈ 2.71828.
32
Week 4
0
−4 −3 −2 −1 0 1 2 3 4
−1
−2
−3
−4
We can think of the floor function as if we’re walking on the number line to the left until
we find an integer. This means that ⌊1.1⌋ = 1 but ⌊−1.1⌋ = −2.
Ceiling function
Definition 16 (Ceiling function). The ceiling function is a function f : R → Z. It
takes a real number x as input and outputs the smallest integer that is greater than or
equal to x. Denoted as ceiling(x) = ⌈x⌉.
For example, given a real number x such that n < x ≤ n + 1, the ceiling of x is n + 1. In
other words: ceiling(x) = ⌈x⌉ = n + 1.
33
Week 4
0
−4 −3 −2 −1 0 1 2 3 4
−1
−2
−3
−4
This is exact opposite of the floor function. So we can think of it as if were were walking
on the number line to the right until we find an integer. This means that ⌊1.1⌋ = 2, but
⌊−1.1⌋ = −1.
Exercise 1
Let n be an integer and x a real number. Show that:
⌊x + n⌋ = ⌊x⌋ + n
Proof. Let m be an integer such that m = ⌊x⌋. By definition of the floor function we have
m ≤ x < m+1. Addin n to both sides of this inequality, we have m+n ≤ x+n < m+n+1.
This implies that ⌊x + n⌋ = m + n by definition. And m = ⌊x⌋. Therefore ⌊x + n⌋ =
⌊x⌋ + n.
34
Week 5
Learning Objectives
• Explain and apply basic concepts of propositional logic.
• Construct truth tables of propositions and use them to demonstrate the equivalence
of logical statements.
• Translate natural language statements into symbolic logical statements and vice
versa.
Essential Reading
• Rosen, K.H. Discrete mathematics and its applications. (New York: McGraw-Hill,
2012) 7th edition, pp.1–12.
• Exercises
p.12 exercises 1–3.
35
Week 5
Many computer reasoning systems, including theorem provers, program verifiers and
applications in the field of Artificial Intelligence, have been implemented in logic-based
programming languages.
These languages, generally employ predicate logic, a form of logic that extends the ca-
pabilities of propositional logic.
3.103 Propositions
Definition 18 (Proposition). A declarative sentence that is either true or false, but not
both.
A Proposition is the most basic element of logic. Which means that propositions are the
building blocks for our reasoning and logical statements.
Examples of propositions
As mentioned above, a proposition must be a declarative statement that is either true or
false, therefore the following statements are propositions:
• London is the capital of the United Kingdom
We know this is true, so this is considered to be a true proposition.
• 1+1=2
This is also a true proposition.
• 2<3
This is also a true proposition.
• Madrid is the capital of France
This is a false proposition.
• 3<2
This is also a false proposition.
• 10 is an odd number
This is also a false proposition.
What follows is a series of statements which are not propositions, as they can not assume
a true or false value:
• x+1=2
We don’t know the value of x, so this is not a proposition. However, if a value
is assigned to x, then at that moment it becomes a proposition. IF we assign the
36
Week 5
Propositional Variables
To avoid writing long, repetivive propositions, we make use of propositional variables.
They are typically a letter, such as p, q, r, . . .
We can assign letters to our previous propositions, for example: Let p be the proposition
London is the capital of the United Kingdom.
True Tables
A truth table is tabular representation of all the possible combinations of truth values
for a set of propositional variables.
For example:
p q
F F
F T
T F
T T
A truth table of n propositional variables, will contain 2n rows. So a table for 3 propo-
sitional variables, will have 8 rows:
37
Week 5
p q r
F F F
F F T
F T F
F T T
T F F
T F T
T T F
T T T
Truth Set
Definition 19 (Truth Set). Let p be a proposition on a set S. The truth set of p is the
set of elements of S for which p is true.
Commonly, we use a capital letter to refer to the truth set of a proposition. For example
the truth set of a proposition p is referred to as P .
1. Example
Let S = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}.
Let p and q be two propositions concerning an integer n in S, defined as follows:
p : n is even
q : n is odd
Therefore, the truth set of p is P = {2, 4, 6, 8, 10} and the truth set of q is Q =
{1, 3, 5, 7, 9}.
Negation ¬
Let p be a proposition, the negation of p, denoted by ¬p, and read as “not p”, is the
statement: it is not the case that p.
38
Week 5
For example if p is the statement John’s program is written in Python, then ¬p is the
statement John’s program is not written in Python.
p ¬p
F T
T F
Conjunction ∧
Let p and q be propositions, the conjuntion of p and q, denoted by p ∧ q, and read as “p
and q”, is the statement: p and q.
The conjunction is only true when both p and q are true and false otherwise.
For example if p is the statement John’s program is written in Python, and q is the
statement John’s program has less then 20 lines of code, then p ∧ q is the statement
John’s program is written in Python and has less than 20 lines of code.
p q p∧q
F F F
F T F
T F F
T T T
Disjunction ∨
Let p and q be propositions, the disjuntion of p and q, denoted by p ∨ q, and read as “p
or q”, is the statement: p or q.
The disjunction is only false when both p and q are false and true otherwise.
For example if p is the statement John’s program is written in Python, and q is the
statement John’s program has less then 20 lines of code, then p ∨ q is the statement
John’s program is written in Python or has less than 20 lines of code.
p q p∨q
F F F
F T T
T F T
T T T
Exclusive-or ⊕
Let p and q be propositions, the exclusive-or of p and q, denoted by p ⊕ q, and read as
“p exclusive-or q”, is the statement: p exclusive-or q.
The exclusive is true when either p or q are true, but not both.
39
Week 5
For example if p is the statement John’s program is written in Python, and q is the
statement John’s program has less then 20 lines of code, then p ⊕ q is the statement
John’s program is written in Python or has less than 20 lines of code, but not both.
p q p⊕q
F F F
F T T
T F T
T T F
Exercise
Given a positive integer n, let’s consider the propositions p and q, where:
• p: n is an even number
• q: n is less than 10
Let’s write the logical expression for each of the following propositions:
1. n is an even number and is less than 10 p ∧ q
2. n is either an even number or is less than 10 p ∨ q
3. n is either an even number or is less than 10 but not both p ⊕ q
4. ¬p ∨ (p ∧ q)
p q p∧q p∨q p⊕q ¬p ¬p ∨ (p ∧ q)
F F F F F T T
F T F T T T T
T F F T T F F
T T T T F F T
40
Week 6
Learning Objectives
• How to formalise a logical implication
• Apply the laws of propositional to analyse propositions and arguments.
Essential Reading
• Rosen, K.H. Discrete mathematics and its applications. (New York: McGraw-Hill,
2012) 7th edition, pp.1–12.
• Exercises
p.13 exercises 6–12
p.14 exercises 19–21
p.33 exercises 6–11.
41
Week 6
Truth Table
p q p→q
F F T
F T T
T F F
T T T
As we can see, the only situation where an implication evaluates to false is when our
hypothesis is true but the conclusion is false.
42
Week 6
Truth Table
p q p↔q
F F T
F T F
T F F
T T T
We can see here that the biconditional statement of p and q is true whenever p and q
have the same truth value and is false otherwise.
43
Week 6
Equivalent propositions
Let p and q be propositions. We say that p and q are logically equivalent if they always
have the same truth value.
We write p ≡ q to signify that p is equivalent to q.
Note that ≡ is not a logical operator, and p ≡ q is not a compound proposition. p ≡ q
means that the compound proposition p ↔ q is always true.
Proving equivalence
One way of determining logical equivalence, is by means of truth tables and verifying
that two propositions have the same truth values for every possible input.
p q p→q ¬p ¬p ∨ q
F F T T T
F T T T T
T F F F F
T T T F T
If values difer in any row, then we demonstrate non-equivalence.
1. Example 1
Let p, q, and r be the following propositions concerning n:
• p: n = 20
• q: n is even
• r: n is positive
Let’s express each conditional statement below symbolically:
• If n = 20, then n is positive
p→r
• n = 20 if n is even
q→p
• n = 20 only if n is even
p→q
44
Week 6
The meaning of compound propositions can change depending on the order in which
parentheses are used. For example (p ∨ q) ∧ (¬r) 6= p ∨ (q ∧ ¬r).
Here’s a small table of precedence:
Operator Name Precedence
¬ Negation 1
∧ Conjunction 2
∨ Disjunction 3
→ Conditional or Implication 4
↔ Biconditional or Equivalence 5
1
A statement that’s always true is a Tautology
2
A statement that’s always false is a Contradiction
45
Week 7
Learning Objectives
• Describe the basic concepts of predicate logic.
• Describe existential and universal quantifiers.
• Assign truth values to quantified statements.
Essential Reading
• Rosen, K.H. Discrete mathematics and its applications. (New York: McGraw-Hill,
2012) 7th edition, pp.34–49 and pp.53–60.
• Exercises
pp.50–51 exercises 1–8, 10–12 and 15–20
p.60 exercises 1–5.
Example 1
Given the statements:
• All men are mortal.
• Socrates is a man.
It’s natural to conclude that Socrates is a man. This sort of reasoning cannot be expressed
by Propositional Logic. Predicate Logic enables us to formalise it.
46
Week 7
Example 2
Given the statement x square is equal to 4. We know this statement is NOT a proposi-
tion as its truth value is a function depending on x, however Predicate Logic can express
and formalise this statement.
Definition of Predicate
Predicates are generalizations of propositions. They are (Boolean) functions which
return TRUE or FALSE depending on their variables. They become propositions when
their variables are assigned values.
Predicates, much like regular sentences, are composed of smaller parts. The statement x
square is equal to 4 contains two parts: the variable x; and the predicate is equal to 4.
We can formalize this statement as P (x) where P is the predicate squared is equal to 4
and x is the variable.
P is referred to as the Propositional Function.
As soon as a value is assigned to the variable x, the statement P (x) becomes a proposition
and has a truth value.
1. Example 1
Let x be an integer and let P be the propositional function square is equal to 4,
therefore P (2) is TRUE and P (3) is FALSE.
47
Week 7
2. Example 2
Let Q(x, y, z) denote x + y < z, therefore Q(2, 4, 5) ≡ 2 + 4 < 5 which is FALSE,
Q(1, 2, 4) ≡ 1 + 2 < 4 which is TRUE, and Q(1, 2, z) is NOT a proposition.
Logical operations
All logic previously defined for propositional logic carries over to predicate logic.
1. Example 1
If P (x) denotes x2 < 16, then P (1) ∨ P (−5) ≡ (1 < 16) ∨ (25 < 16) ≡ T ∨ F ≡ T.
4.105 Quantification
Quantification expresses the extent to which a predicate is true over a range of elements.
The two most most important quantifiers are the universal quantifier ∀ and the existential
quantifier ∃.
There is a third quantifier called the uniqueness quantifier ∃!.
1. Example 1
The following statements give examples of quantified predicates.
• All men are mortal.
• Some computers are not connected to the network.
Universal Quantifier ∀
The Universal Quantification of a predicate P (x) is the proposition:
• P (x) is true for all values of x in the universe of discourse.
We use the notation ∀xP (x) and read it as for all x.
If the universe of discourse is finite {n1 , n2 , . . . , nk } then the universal quantifier is the
conjunction of the propositions over all elements: ∀xP (x) ≡ P (n1 )∧P (n2 )∧. . .∧P (nk ).
1. Example 1
Let P, Q denote the following propositional functions of x:
• P (X): x must take a discrete mathematics course
• Q(X): x is a Computer Science student
Where the universe of discourse for both P (x) and Q(x) is all university students.
Let’s express the following statements symbolically:
48
Week 7
Existential Quantifier ∃
The existential quantification of a predicate P (x) is the proposition There exists a value
of x in the universe of discourse, such that P (x) is true.
If the universe of discourse is finite {n1 , n2 , . . . , nk }, then the existential quantifier is the
disjunction of the proposition over all elements: ∃xP (x) ≡ P (n1 ) ∨ P (n2 ) ∨ . . . ∨ P (nk ).
1. Example 1
Let P (x, y) denote the statement x + y = 5. The expression ∃x∃yP (x, y) means
“There exists a value x and a value y in the universe of discourse such that x+y = 5
is true”.
2. Example 2
Let a, b, c denote fixed real numbers and S be the statement /There exists a real
solution to ax2 + bx − c = 0. S can be expressed as ∃xP (x).
Uniqueness Quantifier ∃!
The uniqueness quantification of a predicate P (x) is the proposition There exists a unique
value x in the universe of discourse such that P (x) is true.
The uniqueness quantifier is a special case of the existential quantifier.
We use the notation ∃!xP (x) and read it as /there exists a unique x“.
49
Week 7
Example 1
Let P (x) be the statement x2 = 4. The expression ∃!xP (x) means “There exists a unique
value of x such that x2 = 4 is true”.
Binding Variables
A variable is said to be bound if it is within the scope of a quantifier. A variable that
is not bound is called a free variable.
1. Example 1
Let P be a propositional function and S be the statement ∃xP (x, y). In this case,
x is bound while y is free.
Logical operations
All the logical operations discussed previously, can also be applied to quantified state-
ments.
Order of operations
When we have quantifiers of the same type, either all universal or all existential, the
other doesn’t matter. However, when we’re dealing with quantifiers of different types we
must apply the quantifiers at the correct order.
1. Example 1
∀x∀yP (x, y) ≡ ∀y∀xP (x, y)
However
∀x∃yP (x, y) 6= ∃y∀xP (x, y)
50
Week 7
Precedence of Quantifiers
The quantifiers ∀ and ∃ have precedence over all other logical operators. This means
that ∀xP (x) ∨ Q(x) should be read as (∀xP (x)) ∨ Q(x) and ∀xP (x) → Q(x) is to be
read as (∀xP (x)) → Q(x).
51
Week 8
Learning Objectives
• Identify logical equivalence involving quantifiers and apply De Morgan’s laws.
• Apply predicate logic to programming.
Essential Reading
• Rosen, K.H. Discrete mathematics and its applications. (New York: McGraw-Hill,
2012) 7th edition, pp.26–28 and pp.62–74.
• Exercises
p.32 exercises 1–5
pp.74–75 exercises 1–5 and 8–12.
De Morgan’s Laws
Quantified Expression Negated Expression
∀xP (x) ∃x¬P (x)
∃xP (x) ∀x¬P (x)
52
Week 8
Example 1
Let S be the statement Every student of Computer Science has taken a course in Neural
Networks. Therefore S can be expressed symbolically as ∀xP (x) where U = {students in CS}
and P (x) = x has taken a course in Neural Networks.
The negation of S is ¬S which translates to It is not the case that every student in
Computer Science has taken a course in Neural Networks. This statement implies that
There is at least one student of Computer Science who has not taken a course in Neural
Networks. Which can be expressed symbolically as ∃x¬P (x).
53
Week 8
• If you have access to the internet, you can order a book in Machine Learning.
• You can order a book on Machine Learning.
Rules of inference
These can be seen as building blocks for constructing complex valid arguments incre-
mentally.
Given an argument, we could use a truth table to decide whether an argument is true or
false, however we will need 2n rows in the truth table for n variables. This process can
be really labor-intensive.
Rules of inference, however, provide a much simpler way of proving the validity of an
argument.
Moreover, every rule of inference can be proved using a Tautology1 .
Modus Ponens
Here’s the tautology used as the basis for Modus Ponens.
(p ∧ (p → q)) → q
And the rules of inference
p→q
p
∴q
And an example
p: It is snowing
q: I will study Discrete Mathematics
54
Week 8
Modus Tollens
Tautology shown below is the basis for Modus Tollens.
(¬q ∧ (p → q)) → ¬p
And the rule of inference
¬q
p→q
∴ ¬p
And an example
p: It is snowing
q: I will study Discrete Mathematics
Conjunction
The following tautology is the basis for Conjunction.
((p) ∧ (q)) → (p ∧ q)
This leads to the following rule of inference
p
q
∴p∧q
And an example
p: I will study Programming
q: I will study Discrete Mathematics
Simplification
The next tautology is the basis for Simplification
(p ∧ q) → p
55
Week 8
Addition
The tautology shown below is the basis for Addition
p → (p ∨ q)
It leads to the following valid argument form
p
∴p∨q
And an example
p: I will study Programming
q: I will study Discrete Mathematics
Hypothetical Syllogism
The tautology that follows is the basis for Hypothetical Syllogism
(p → q) ∧ (q → r)) → (p → r)
It leads to the following valid argument form
p→q
q→r
∴p→r
And an example
p: It is snowing
56
Week 8
Disjunctive Syllogism
The following tautology is the basis for Disjunctive Syllogism
((p ∨ q) ∧ ¬p) → q
It leads to the following valid argument form
p∨q
¬p
∴q
And an example
p: I will study Programming
q: I will study Discrete Mathematics
Resolution
The next tautology is the basis for Resolution
((p ∨ q) ∧ (¬p ∨ r)) → (q ∨ r)
It leads to the following valid argument form
p∨q
¬p ∨ r
∴q∨r
And an example
p: It is raining
q: It is cold
r: It is snowing
57
Week 8
58
Week 8
Step Justification
1 q→p Hypothesis
2 ¬p Hypothesis
3 ∴ ¬q Modus Tollens 1,2
4 ¬q → r Hypothesis
5 ∴r Modus Ponens 3,4
6 r→s Hypothesis
7 ∴s Modus Ponens 5,6
Conclusion: We will need to make popcorn
Fallacies
A fallacy is the use of incorrect argument when reasoning. Formal fallacies can be
expressed in propositional logic and proved to be incorrect.
Common formal fallacies:
• affirming the consequent
• a conclusion that denies the premises
• contradictory premises
• denying the antecedent
• existential fallacy
• esclusive premises
59
Week 8
60
Week 8
61
Week 8
62
Week 9
Learning Objectives
• Write Boolean expressions.
• Use the laws of Boolean algebra to simplify Boolean expressions.
• Represent a Boolean function.
• Simplify logic circuits/expressions.
• Convert truth tables into Boolean expressions and vice versa.
Essential Reading
• Rosen, K.H. Discrete mathematics and its applications. (New York: McGraw-Hill,
2012) 7th edition, pp.811–821.
• Exercises
pp.818–819 exercises 1–5, 20–25 and 35–40.
For gates and circuits, see the Essential reading for Week 2.
63
Week 9
64
Week 9
x y xy
0 0 0
0 1 1
1 0 1
1 1 1
• NOT
Also referred to as logical complement or negation. Can be represented as x′ , x̄ or
¬x.
Truth Table is as follows:
x x̄
0 1
1 0
When parentheses are not used, these three operators have the following order of prece-
dence: NOT > AND > OR. Note that this still respects the same order of precedence
defined in Precedence of logical operators.
65
Week 9
• Distinct Elements
This states that any Boolean Algebra has to have two distinct values, therefore
0 6= 1.
Basic theorems
Using the 6 axioms from previous sections, we can establish other useful theorems for
designing and analysing digital circuits.
Logical Sum Theorem Logical Product
x+x=x Idempotent Laws x·x=x
x+1=1 Tautology and Contradiction x·0=0
¯=x
x̄ Involution
(x + y) + z = x + (y + z) Associative Laws (x · y) · z = x · (y · z)
x + (x · y) = x Absorption Laws x · (x + y) = z
if y + x = 1 and y · x = 0, Uniqueness of Complement
then x = ȳ
0̄ = 1 and 1̄ = 0 Inversion Law
De Morgan’s Theorems
Theorem 1 (De Morgan’s Theorem 1). The complement of a logical product or variables
is equal to the logical sum of the complements of the variables. x · y = x̄ + ȳ.
Theorem 2 (De Morgan’s Theorem 2). The complement of a logical sum or variables is
equal to the logical product of the complements of the variables. x + y = x̄ · ȳ.
Principle of duality
Starting with a Boolean Relation, we can build another equivalent Boolean Relation by:
• Changing every + to ·
• Changing every · to +
• Changing every 0 to 1
• Changing every 1 to 0
For example A + B · C ≡ A · (B + C).
66
Week 9
• Perfect Induction
Show that both relations have identical truth tables. This can be tedious as the
number of variables grow.
• Axiomatic Proof
Apply Huntington’s postulates or theorems to the expressions until identical ex-
pressions are found.
• Duality Principle
Every theorem remain valid after application of the Duality Principle.
• Contradiction
Assuming the hypothesis is false and then proving that the conclusion is also false.
1. Example: Absorption Rule
This rule can be proved easily with a truth table:
x y x + (x · y)
0 0 0
0 1 0
1 0 1
1 1 1
It can also be proved directly:
x + (x · y) ≡ (x · 1) + (x · y)
≡ x · (1 + y)
≡x·1
≡x
To prove the second part of the absorption law, we can use the duality principle,
therefore x + (x · y) = x = x · (x + y).
67
Week 9
x y z f (x, y, z)
0 0 0 1
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 0
1 1 0 0
1 1 1 1
Algebraic forms
There is a single way of representing a Boolean function in a truth table, however al-
gebraically a function can be represented in a variety of forms. For example f (x) =
x + x̄ · y = x + y.
68
Week 9
Useful functions
The exclusive-or function x ⊕ y is true when either x or y is true, but not both. This
can be expressed as f (x, y) = x̄y + xȳ.
The implies function x → y is false when x is true and y is false, and true otherwise.
This can be expressed f (x, y) = x̄ + y.
69
Week 10
Learning Objectives
• Write Boolean expressions.
• Use the laws of Boolean algebra to simplify Boolean expressions.
• Represent a Boolean function.
• Simplify logic circuits/expressions.
• Convert truth tables into Boolean expressions and vice versa.
Essential Reading
• Rosen, K.H. Discrete mathematics and its applications. (New York: McGraw-Hill,
2012) 7th edition, pp.15–21.
• Exercises
p.22 exercises 23 and 24.
AND Gate
The AND Gate produces a HIGH output (value 1) when all its inputs are HIGH ; oth-
erwise, the output LOW (value 0).
The AND Gate is represented as show in figure 1, below we show its truth table:
70
Week 10
x
y AND
x OR
y
x y x·y
0 0 0
0 1 0
1 0 0
1 1 1
Note that f = x · y can also be written as f = xy.
OR Gate
The OR Gate produces a HIGH output (value 1) when at least one of its inputs are
HIGH ; otherwise, the output LOW (value 0).
The OR Gate is represented as show in figure 2, below we show its truth table:
x y x+y
0 0 0
0 1 1
1 0 1
1 1 1
Inverter Gate
The Inverter Gate produces a HIGH output (value 1) when its input is LOW ; and
produces a LOW when its input is HIGH.
The Inverter Gate is represented as show in figure 3, below we show its truth table:
x x̄
0 1
1 0
71
Week 10
x NOT
x
y XOR
XOR Gate
The XOR Gate produces a HIGH output (value 1) its inputs have different values and
a LOW otherwise.
The XOR Gate is represented as show in figure 4, below we show its truth table:
x y x⊕y
0 0 0
0 1 1
1 0 1
1 1 0
NAND Gate
Equivalent to “not AND”, so this is the inversion of the AND Gate. The NAND Gate is
represented as show in figure 5.
NOR Gate
Similarly, this is the inversion of the OR Gate. The NOR Gate is represented as show in
figure 6.
XNOR Gate
The inversion of the XOR Gate. The XOR Gate is represented as show in figure 7.
x
y NAND
72
Week 10
x
y NOR
x
y XNOR
x
y
z
73
Week 10
x
y NAND
x
y OR
x
y NOR
74
Week 10
x
y OR
x y z
f (x, y, z)
f (x, y, z)
w z y x
75
Week 10
w z y x
(x + y)
w z y x
(x + y)
z(x + y)
z(x + y) + w
76
Week 10
y x
sum
carry
77
Week 10
carry − iny x
sum
carry − out
78
Week 10
Algebraic simplification
A technique based on the application of Boolean algebra theorems to simplify the be-
havior of Boolean functions.
To produce a sum-of-product expression, we usually need to rely on at least one of the
following theorems:
• De Morgan’s laws and involution
• Distributive laws
• Commutative laws
• Idempotent laws
• Complement laws
• Absorption laws
1. Example
Simplify the following Boolean expression:
79
Week 10
Karnaugh maps
A Karnaugh Map (or K-map) is a graphical representation of Boolean functions and is
different from a truth table. Adjacent cells in a K-map only change one variable.
ȳ y
x̄ 0 0
x 1 1
1. Example
Consider the Boolean function represented by the truth table below:
x y z f
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 1
1 0 1 1
1 1 0 1
1 1 1 1
Since we have three variables, we need a K-map of three inputs:
ȳz̄ ȳz yz yz̄
x̄ 0 0 1 0
x 1 1 1 1
In this case, the expression is x + yz.
80
Week 11
Learning Objectives
• State the principle of mathematical induction.
• Discuss the ideas of the base step and inductive step in a proof by mathematical
induction.
• Apply the ideas of mathematical induction to recursion and recursively defined
structures.
Essential Reading
• Rosen, K.H. Discrete mathematics and its applications. (New York: McGraw-Hill,
2012) 7th edition, pp.307–325 and pp.328–336.
• Exercises
pp.325–326 exercises 1, 2, 6, 7, 15 and 16
p.338 exercises 19–21.
For recursion, see the Essential reading for Week 2
81
Week 11
Terminology
Theorem A formal statement that can be shown to be true
Axiom A statement assumed to be true to serve as a premise to further arguments
Lemma A proven statement used as a step to a larger result rather than as a statement
of interest by itself
Corollary A theorem that can be established by a short proof from a theorem
Formalising a theorem
The statement S There exists a real number between any two non-equal real numbers can
be formalized as:
Theorem 3. ∀x, y ∈ Rx < y → ∃z ∈ R | x < z < y
Direct proof
A Direct Proof is simply a demonstration that a conditional statement p → q is true.
We always with the assumption that p is true, then we employ axioms, definitions,
and theorems, together with rules of inference, to show that q must also be true.
For example, let’s prove our theorem defined in section Formalising a theorem.
Proof by contrapositive
A Proof by Contrapositive is a proof technique that relies on the fact that proving p → q
is equivalent to proving ¬q → ¬p.
We start the proof by assuming ¬q is true, then use axioms, definitions, and theorems,
together with rules of inference, to show that ¬p must also be true.
For example, let’s prove the theorem If n2 is even, then n is even.
82
Week 11
Proof by contradiction
A Proof by Contradiction is a form of proof which relies on assuming the premise to be
false and showing that it leads to a contradiction.
We start the proof by assuming ¬p to be true\ then use axioms, definitions, and
theorems, together with rules of inference, to show that ¬p is false. We can conclude,
therefore, that assuming ¬p was wrong, so it must be true.
For example, let’s prove the theorem There are infinitely many prime numbers.
Proof. Let’s suppose there are finitely many prime numbers and list them as p1 , p2 , p3 , . . . , pn .
Let’s consider the number c = p1 · p2 · p3 · . . . · pn + 1, the product of all primes + 1.
As c is a natural number, it has at least one prime divisor. Then, ∃k ∈ {1, . . . , n} | pk /c.
Then, ∃k ∈ {1, . . . , n}∃d ∈ N | d · pk = c = p1 · p2 · p3 · . . . · pn + 1.
1
Then, ∃k ∈ {1, . . . , n}∃d ∈ N | d = p1 · p2 · p3 · . . . · pk−1 + pk+1 + . . . + pn + pk .
83
Week 11
Structure of induction
In order to complete a proof by induction for a propositional function P (n), we need to
verify two steps:
Base Case Prove that P (1) is true
Inductive Step Prove that ∀k ∈ NP (k) → P (k + 1)1
Proving formulas
n(n+1)
Let’s prove P (n) : 1 + 2 + 3 + . . . + n = 2 .
1(1 + 1)
1=
2
1(2)
1=
2
2
1=
2
1=1
1
P (k) is referred to as the inductive hypothesis
84
Week 11
k(k + 1)
1 + 2 + 3 + ... + k =
2
(k + 1)(k + 2)
1 + 2 + 3 + . . . + k + (k + 1) =
2
k(k + 1) (k + 1)(k + 2)
+ (k + 1) =
2 2
k(k + 1) + 2(k + 1) (k + 1)(k + 2)
=
2 2
(k + 1)(k + 2) (k + 1)(k + 2)
=
2 2
We have shown that the property holds for the base case and for the inductive step,
therefore the proof is complete.
Proving inequalities
Let’s prove P (n) : 3n < n! if n ≥ 7.
37 < 7!
2187 < 5040
3k < k!
3k+1 < (k + 1)!
3 · 3k < (k + 1) · k!
We have shown that the property holds for the base case and for the inductive step,
therefore the proof is complete.
Proving divisility
Let’s prove P (n) : ∀n ∈ N5|6n + 4.
5|60 + 4
5|1 + 4
|
55
85
Week 11
5|6k + 4
5|6k+1 + 4
5|6 · 6k + 4
5|6(5p − 4) + 4
5|30p − 24 + 4
5|30p − 20
5|5(6p − 4)
We have shown that the property holds for the base case and for the inductive step,
therefore the proof is complete.
Strong induction
It can formalised using the following rule of inference:
P (1)is true
∀k(P (1), P (2), . . . , P (k) → P (k + 1))
∴ ∀nP (n)
It’s sometimes called Complete Induction.
Example
Let’s prove P (n) : ∀n ∈ N ∧ n ≥ 2, n is divisible by a prime number.
Proof. We start with the base case, which reduces to 2. 2 is a prime number and divides
itself.
86
Week 11
Then we move on to the inductive step. Let k ∈ N, greater than 2. If the inductive
hypothesis P (k) is true, let’s assume P (2), . . . , P (k + 1) is true. Then, ∀m ∈ N and
2 ≤ m ≤ k + 1, ∃p a prime number dividing m.
Here we have two cases:
k + 2 is a prime number then k + 2 is trivially divisible by itself
k + 2 is a composite number then ∃m dividing k + 2. Because 2 ≤ m ≤ k + 1, then ∃p
dividing m, which also divides k + 2.
We have shown that the property holds for the base case and for the inductive step,
therefore the proof is complete.
Well-ordering property
It is an axiom about N that we assume to be true. The axioms about N are as follows:
1. The number 1 is a positive integer
2. If n ∈ N, then n + 1 is also a positive integer
3. Every positive integer other than 1, is the successor of a positive integer
4. The Well-ordering property: every non-empty subset of the set of positive integers
has a least element
The well-ordering property can be used as a tool in building proofs.
Example
Let’s reconsider our previous proof.
Proof. Let S be the set of positive integers greater than 1 without a prime divisor.
Suppose S is non-empty. Let n be its smallest element. n cannot be prime since n divides
itself if n is prime; i.e. n would be its own prime divisor.
Therefore, n must be composite, which means it must have a divisor d such that 1 < d < n
Then d must have a prime divisor.
Let p be the prime divisor of d. We know that p/d and d/n, therefore p/n, which
contradicts our statement that S is the set of positive integers greater than 1 without a
prime divisor.
Therefore, S must be an empty set, which verifies P (n).
87
Week 11
88
Week 12
Learning Objectives
• Describe the concept of recursion and give examples of its application.
• Identify the base case and the general case of a recursively defined problem.
Essential Reading
• Rosen, K.H. Discrete mathematics and its applications. (New York: McGraw-Hill,
2012) 7th edition, pp.339–351.
• Exercises
p.351 exercises 1–9 and 15–17.
f (0) 1
f (1) 1
f (n) f (n − 1) + f (n − 2)
89
Week 12
Recursive algorithms
An algorithm is a finite sequence of precise instructions for performing a computation or
for solving a problem.
A recursive algorithm is an algorithm which solves a problem by reducing it to a smaller
instance of the same problem with smaller input.
For example, here’s a recursive algorithm for computing n!:
Algorithm 1 Computing n!
1: function Factorial(n)
2: if n = 0 then
3: return 1
4: return n× Factorial(n − 1)
Linear recurrences
A relation in which each term of the sequence is a linear function of earlier terms.
There are two types of linear recurrences:
90
Week 12
Arithmetic sequences
A sequence is called arithmetic if the difference between consecutive terms is a constant
c.
Geometric sequences
A sequence is called geometric if the ratio between consecutive terms is a constant r.
91
Week 12
92
Week 13
Learning Objectives
• Define a graph, edges, vertices, parallel edges, loops, cycles and walk, path and
connected graphs.
• Describe the degree sequence of a graph and the relation that links the sum of the
degree sequence.
• Describe special graphs: simple graphs, complete graphs and r-regular graphs.
Essential Reading
• Rosen, K.H. Discrete mathematics and its applications. (New York: McGraw-Hill,
2012) 7th edition, pp.617–625, pp.627–631, pp.637–640 and pp.666–676.
• Exercises
pp.625–626 exercises 1–3, 18, 19 and 20
pp.641–642 exercises 1–10 and 28–32
pp.676–677 exercises 1–4 and 12–23.
7.101 Introduction
We start studying Graphs. Graphs are discrete structures consisting of vertices and edges
connecting them.
Graph Theory is a branch of discrete mathematics which studies these structures.
Applications of Graphs
• Modeling computer networks
• Modeling road maps
• Solving shortest-path problems between cities
• Assigning jobs to employees
• Distinguishing chemical compound structures
93
Week 13
• Modeling molecules
Vertex
The basic element of a graph, drawn as a node or a dot. The set of vertices of G is
usually denoted by V (G) or simply V . Figure 20 denotes a graph with 3 vertices.
e1
v1 v2
e2
v3
Edge
A link between two vertices. It’s drawn as line connecting exactly two vertices. The set
of edges in a graph G is denoted by E(G) or simply E.
In the graph shown in figure 20, E(G) = {e1, e2} = {{v1, v2}, {v2, v3}}.
Adjacency
• Two vertices are adjacent if they are endpoints on the same edge
• Two edges are adjacent if they share the same vertex
• If vertex v is and endpoint of edge e, then we say that v and e are incident
94
Week 13
v6
e4
e5
v4 v5
e7
e3 e6 e8 v1 e9
e1
v3 v2
e2
The vertices v2 and v5 are linked with two edges (e6 and e8), those edges are referred to
as parallel edges.
The vertex v1 is linked to itself by edge e9, that edge is called a loop.
95
Week 13
v6
e4
e5
v4 v5
e7
e3 e6 e8 v1 e9
e1
v3 v2
e2
Definition of a trail
A trail is a walk in which no edge is ever repeated. Vertices can be repeated, but no
edges can be repeated.
Definition of a circuit
A circuit is a closed trail, meaning the starting and ending vertices are the same. Only
vertices can be repeated.
96
Week 13
Definition of a path
A path is a trail in which neither vertices nor edges are repeated.
Definition of a cycle
A cycle is a closed path in which a vertex is reachable from itself.
Eulerian path
An Eulerian path is a path that uses each edge precisely once. If such a path exists, the
graph is called traversable.
Hammiltonian path
A Hammiltonian path (or traceable path) is a path that visits each vertex precisely once.
If such a path exists, the graph is called a traceable graph.
Hammiltonian cycle
A cycle that uses each vertex exactly once (except for the starting vertex, which is visited
exactly twice) is called a Hammiltonian cycle. If such a cycle exists, the graph is called
a Hammiltonian graph.
Connectivity
An undirected graph is connected if you can get from any node to any other node by
following a sequence of edges. This means that any two random nodes in a graph are
connected by a path.
The graph depicted in figure 23 is a connected graph while the graph depicted in figure
24 is not a connected graph.
97
Week 13
v4 v5
v1
v3 v2
v4 v5
v1
v3 v2
Strong Connectivity
A directed graph is a strongly connected graph if there is a directed path from any node
to any other node. Figure 25 shows a depiction of such a graph. Conversely, the graph
depicted by figure 26 is not strongly connected.
98
Week 13
v3
v1
v4 v2
v3
v1
v4 v2
Transitive Closure
Given a digraph G, the Transitive Closure of G is the digraph G∗ such that:
• G∗ has the same vertices as G
• If G has a directed path from u to v (u 6= v), G∗ has a directed edge from u to v.
Figure 27 shows a depiction of a transitive closure of G.
99
Week 13
y u v y u v
x z x z
1 2
v4 v2
0 4
v6 v1
v4 v3
3 4
100
Week 13
1 2
v5 v2
0 2
v6 v1
v4 v3
3 4
1 2
v4 v2
4
v1
v4 v3
2 3
101
Week 13
v4 v2
v1
v4 v3
Regular graphs
A graph is said to be regular if all local degrees are the same number.
A graph G where all vertices have the same degree r is called an r-regular graph.
102
Week 13
v2 v1
v3 v4
Complete graph
A simple graph where every pair of vertices is adjacent. Complete graphs with n vertices
are represented by the symbol Kn .
Figure 33 shows an example of a complete graph with 8 vertices.
103
Week 13
8 2
7 3
6 4
104
Week 14
Learning Objectives
• Define the adjacency matrix of a graph.
Essential Reading
• Rosen, K.H. Discrete mathematics and its applications. (New York: McGraw-Hill,
2012) 7th edition, pp.632–636, pp.643–650, pp.652–663 and pp.681–688.
• Exercises
pp.641–642 exercises 17–23
pp.650–652 exercises 1–4, 6–18, 22–24 and 40–44
pp.663–664 exercises 1–3, 7, 16 and 17
pp.688–689 exercises 2–5, 13 and 14.
105
Week 14
1 2 3 4 5
a b c d e
Bipartite graphs are 2-colourable, meaning 2 colours are enough to color the graphs in a
way that adjacent nodes do not have the same colour.
There are no odd-length cycles in bipartite graphs.
Matching
A Matching is a set of pairwise non-adjacent edges, none of which are loops. Meaning
no two edges share the same endpoint.
A vertex is matched (or saturated) if it is an endpoint of one of the edges in the matching.
Otherwise, the vertex is unmatched.
Maximum matching
A matching of maximum size such that if any edge is added, it is no longer a matching.
In a single bipartite graph, there may be many possible maximal matchings.
106
Week 14
1. M ← ∅
2. While there is an augmenting path P
a) Use BFS to build layers that terminate at free vertices
b) Start at free vertices in C, use DFS
3. Return M
Adjacency list
A list of all the vertices of G and their corresponding individual adjacent vertices. Table
0.1 shows the adjancency list for the graph in figure 35.
107
Week 14
e2
A C
e7
e1 e5 E
e3
e6
B e4 D
Note that we can draw a graph from its adjacency list alone.
Example
Given the adjacency list in table 0.2, let’s draw the graph:
We know, from table 0.2 that the graph has 5 vertices. So we can start our drawing with
only 5 vertices drawn, without any edges. That’s shown below:
v3
v4 v1 v2
v5
108
Week 14
v3
v4 v1 v2
v5
v3
v4 v1 v2
v5
v3
v4 v1 v2
v5
Lastly, we look at v5 :
109
Week 14
v3
v4 v1 v2
v5
Now that all vertices are done, the final graph is:
v3
v4 v1 v2
v5
Adjacency matrix
A graph can be represented by its adjacency matrix. Given the graph is figure 36, we
can produce its adjacency matrix as shown below:
2 1 1
M (G) = 1 2 2
1 2 0
v1 v1 v1 v2 v1 v3
M (G) = v2 v1 v2 v2 v2 v3
v3 v1 v3 v2 v3 v3
Note that in the leading diagonal, we have the loops which are counted twice. One
interesting observation is that sum of all the edges in the undirected graph, is equal to
110
Week 14
half the sum of all the elements in its adjacency matrix. The sum of the degree sequence
is equal to the sum of the adjacency matrix.
v3
v1 v2
The adjacency matrix can also be produced for a directed graph, but we need to in mind
that v1 being adjacent to v2 does not imply v2 being adjacent to v1 .
v3
2
3
1
1
v1 v2
It can be used to model the distance between cities, response time in a network or the
cost of a transaction, among other things.
Dijstra’s algorithm
In 1956, Edsger Dijkstra designed an algorithm for finding the shortest path between any
two nodes in a weighted graph. This algorithm is now know as Dijkstra’s Algorithm.
111
Week 15
Learning Objectives
• Define a tree.
• Define spanning trees.
• Define non-isomorphic spanning trees.
Essential Reading
• Rosen, K.H. Discrete mathematics and its applications. (New York: McGraw-Hill,
2012) 7th edition, pp.715–717, pp.753–762 and pp.764–769.
• Exercises
p.725 exercises 1 and 11
p.763 exercises 1–3, 5 and 6
p.769 exercises 1–5.
Definition of a tree
A tree is a connected acyclic undirected graph. Figure 38 depicts a sample tree. A tree
cannot have loops or parallel edges.
112
Week 15
root
left right
child child
Definition of a forest
A forest is a cycle-free disconnected graph.
Theorem 1
An undirected graph is a Tree if and only if there is a unique simple path between any
two of its vertices.
Well, if there are more than one path, we have a cycle.
Theorem 2
A tree with n vertices has n − 1 edges.
Rooted trees
A Rooted Tree is a tree in which one vertex has been designated as the root. Every edge
is directed away from the root.
113
Week 15
4 2
114
Week 15
v1 v2
v4 v3
v1 v2
v4 v3
v1 v2
v4 v3
Figure 42: Break all cycles but keep the tree connected
115
Week 15
2
A C
5 2 E
3
B D
1
116
Week 16
Learning Objectives
• Define minimum spanning trees.
• Define rooted trees and binary trees, and find the height of binary trees.
Essential Reading
• Rosen, K.H. Discrete mathematics and its applications. (New York: McGraw-Hill,
2012) 7th edition, pp.717–725 and pp.726–729.
• Exercises
p.725–726 exercises 2–8, 12, 13, 24 and 26
p.738 exercises 1–4.
117
Week 16
a b
c d e f g h
i j
Theorem
A directed tree is a rooted tree if and only if one vertex has in-degree 0 and all the other
vertices have in-degree 1.
118
Week 16
The height of a node in a tree is the longest from that node to a leaf.
• height of r is 3
• height of b is 2
• height of a and h is 1
• height of c, d, e, f, g, i, j is 0
The depth or height of a tree is the maximum path length across all its nodes. The
height of the graph in figure 44 is 3.
Special trees
Binary Tree A tree in which every vertex has 2 or fewer children
Ternary Tree A tree in which every vertex has 3 or fewer children
m-ary Tree A tree in which every vertex has m or fewer children
Properties
• An m-ary tree has at most mh vertices at level h
Isomorphic trees
Two trees T1 and T2 are isomorphic if there is a bijection:
f : V (T1 ) → V (T2 )
which preserves adjacency and non-adjacency. This means that if uv is in E(T1 ) then
f (u)f (v) is in E(T2 ).
Notation T1 ∼
= T2 means T1 and T2 are isomorphic.
Properties
• Two trees with different degree sequences are not isomorphic
• Two trees with the same degree sequence are not necessarily isomorphic
119
Week 16
Properties
Two trees which are isomorphic may or may not be isomorphic as rooted trees.
Example
The tree depicted by figure 45 is a Binary Search Tree.
4 12
2 6 10 14
1 5 7 9 11 13 15
Applications
BST are good data stores for modifiable data. It allows very fast insertion, deletion and
searching.
120
Week 16
2h−1 < n + 1 ≤ 2h
h − 1 < log2 (n + 1) ≤ h
h = ⌈log2 (n + 1)⌉
It should be clear that both of these will give the same result and are equivalent.
121
Week 17
Learning Objectives
• Define a relation.
• Define a relation digraph.
• Describe the properties of a relation.
Essential Reading
• Rosen, K.H. Discrete mathematics and its applications. (New York: McGraw-Hill,
2012) 7th edition, pp.553–561
• Exercises
p.561 exercises 1–12
p.562 exercises 20-22
9.101 Introduction
A binary relation over two sets A and B is a subset of the Cartesian product A × B. We
say that the element a of A is related to the element b of B, if and only if the ordered
pair (a, b) is belongs to the set.
This same idea can be extended to more than two sets by considering the cartesian
product with rank k. Instead of an ordered pair, we would have k-tuples. The relation
in this case is referred to as finitary relation or n-ary relation.
In mathematics we study relationships such as:
• Relation between a positive integer and one it divides
• Relation between a real number and one larger than it
• Relation between a real number x and the value f (x), where f is a function
122
Week 17
Cartesian product
If we have two sets A and B, as depicted below:
A B
3 6
2 4
1 2
The Cartesian Product A × B is defined by a set of ordered pairs (a, b) where a ∈ A and
b ∈ B.
123
Week 17
A × B = {(a, b) | a ∈ A ∧ b ∈ B}
For example, from our sets A and B shown in figure 46, we have:
A × B = {(1, 2), (1, 4), (1, 6), (2, 2), (2, 4), (2, 6), (3, 2), (3, 4), (3, 6)}
Definition of relation
A binary relation over two sets A and B is a subset of the Cartesian product A × B. In
other words, R⊆ A × B. This means that R is the set of ordered pairs (a, b) where a ∈ A
and b ∈ B.
(a, b) ∈R means a R b.
Relations on a set
When A = B, we have a relation from A to A, or R⊆ A × A.
Example
Let A = {1, 2, 3, 4}. Let R be a relation on A.
x, y ∈ A, x R y if and only if x < y. Therefore: 1 R 2, 1 R 3, 1 R 4, 2 R 3, 2 R 4, 3 R 4.
We can see that R= {(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)}.
(
1 if(ai , bj ) ∈R
mij =
0 if(ai , bj ) ∈R
/
Example
Let A = {Sofia, Samir, Sarah} and $B = \ CS100, CS101, CS102, CS103\. Consider the
relation of who’s enrolled in which class defined in the table below:
124
Week 17
Combining relations
Union The union of two relations is the same as the union of two sets as defined in
section Union (∪). The union produces a new set containing all ordered pairs that
are in at least one relation. The union of two relations R and S is written as R ∪S
or R orS
Intersection Works the same as defined in section Intersection (∩). Contains all the
elements that are in both R and S. Written as R ∩S or R andS
125
Week 17
Example
Let A = {1, 2, 3, 4}, let R= {(x, y) | x|y}. The relation R can be represented by the
digraph below:
1 2
3 4
Example
Let R be the relation:
R= {(a, b) ∈ Z2 | a ≤ b}
126
Week 17
It’s easy to see that this relation is reflexive. Well take any arbitrary element x in Z, we
can show that x ≤ x, which means x R x, hence (x, x) ∈R.
This implies that this relation R is reflexive.
Conversely, the relation:
R= {(a, b) ∈ Z2 | a < b}
Is not reflexive because x 6< x, hence xRx.
a0 a1
a2 a3
Definition of symmetry
A relation R in a set S is symmetric if and only if ∀a, b ∈ S, a R b → b R a.
127
Week 17
a0 a1
a2 a3
Definition of anti-symmetric
A relation R is anti-symmetric if and only if ∀a, b ∈ S, (a R b ∧ b R a) → a = b.
128
Week 17
a0 a1
a2 a3
Examples
1. R= {(x, y) ∈ N2 | x ≤ y}
Transitive if x ≤ y and y ≤ z, then x ≤ z.
2. R= {(2, 3), (3, 2), (2, 2)}
Not Transitive 3 R 2 and 2 R 3 but 3R3
129
Week 17
a b
d c
We can see that a R b and b R c but aRc, therefore we must add a new edge from a to
c, as depicted in figure 52.
a b
d c
We can also see that b R c and c R d, but bRd, therefore we must add a new edge from
b to d.
a b
d c
This relation is still not transitive. When we added the new edge depicted in figure 52,
we created a new situation where a R c and c R d but aRd, therefore we must add a new
edge from a to d.
130
Week 17
a b
d c
Finally, we have a transitive relation which is called the Transitive Closure of the
original relation R.
131
Week 18
Learning Objectives
• Define an equivalence relation.
• Define partial and total order.
Essential Reading
• Rosen, K.H. Discrete mathematics and its applications. (New York: McGraw-Hill,
2012) 7th edition, pp.570–575, pp.587–594 and pp.597–601.
• Exercises
pp.575–576 exercises 1–4 and 14–22
pp.594–595 exercises 1–6, 9, 17–23, 25 and 32
p.609 exercises 1, 5–7 and 12–15.
Example
Let R be a relation of elements in Z:
R= {(a, b) ∈ Z2 | a mod 2 = b mod 2}
This relation is:
Reflexive a R a, ∀a ∈ Z
Symmetric ∀a, b ∈ Za R b → b R a
Transitive ∀a, b, c ∈ Z(a R b ∧ b R c) → a R c
∴R is an equivalence relation.
132
Week 18
Example
Let S = {1, 2, 3, 4} and R be a relation on elements in S:
R= {(a, b) ∈ S 2 | a mod 2 = b mod 2}
R is an equivalence relation with 2 equivalence classes:
• [1] = [3] = {1, 3}
• [2] = [4] = {2, 4}
Graphically:
1 2
3 4
1
In Rosen’s book, the notation a ∽ b is used instead of a R b
133
Week 18
Example
Let R be a relation of elements in Z
R= {(a, b) ∈ Z2 | a ≤ b}
This relation is:
Reflexive ∀a ∈ Za ≤ a
Transtivie ∀a, b, c ∈ Z(a ≤ b ∧ b ≤ c) → a ≤ c
Anti-symmetric ∀a, b ∈ Z(a ≤ ∧b ≤ a) → a = b
∴R is a partial order.
Example
Let R be a relation of elements in Z
R= {(a, b) ∈ Z2 | a ≤ b}
This relation is:
• A partial order (see previous example)
• ∀a, b ∈ Z(a ≤ b ∨ b ≤ a)
134
Week 19
Learning Objectives
• Apply the addition principle and the multiplication principle to count objects when
they are sampled with or without replacement.
Essential Reading
• Rosen, K.H. Discrete mathematics and its applications. (New York: McGraw-Hill,
2012) 7th edition, pp.375–385 and pp.395–401.
• Exercises
pp.386–387 exercises 1–5, 7, 8, 14–17, 30, 32 and 40
pp.394–395 exercises 1–6, 14, 15, 19 and 28
pp.402–403 exercises 1–10, 16, 17, 20, 21, 32 and 34.
10.101 Introduction
Combinatorics is a branch of Discrete Mathematics concerned with the study of finite
or countable discrete structures. It’s the study of collections or arrangements of objects.
Combinatorics finds applications in computer science, economics, physics, and many
other fields.
135
Week 19
Addition Rule
Let’s assume that we have two independent tasks. Task 1 can be completed in n ways and
task 2 can be completed in m ways. Because these tasks are independent (i.e. completing
task 1 or not has no effect on task 2), the total number of ways of completing both tasks
is n + m.
Example
Let’s assume that a University has to choose either a staff member or a student to be
a University representative. Let’s also assume that there are 77 students and 10 staff
members and nobody is both a student and a staff member. How many ways are there
to choose a representative?
77 + 10 = 87
136
Week 19
Subtraction rule
Suppose a task can be done in either one of n1 ways or one of n2 ways. Then the total
number of ways to do the task is n1 + n2 minus the number of ways common to the two
different ways.
This is also known as the Pinciple of Inclusion-Exclusion.
|A ∪ B| = |A| + |B| − |A ∩ B|
Division rule
Suppose a task can be done using a procedure that can be carried out in n ways, and for
n
every way w, exactly d of the n ways correspond to w. Then this task can be done in
d
ways.
In terms of sets, if the finite set A is the union of n pair-wise disjoint subsets each with
|A|
d elements, then n = .
d
In terms of functions, if f is a function from A to B, where both A and B are finite sets,
and for every value b ∈ B there are exactly d values a ∈ A such that f (a) = b, then
|A|
|B| = .
d
137
Week 20
Learning Objectives
• Calculate the number of permutations of length r chosen from a set of n objects.
• Demonstrate how to use combination formulae to count the number of unordered
subsets of r objects taken from a set of n distinct objects.
• Distinguish between combinations and permutations.
• Apply the techniques learnt in new counting problems.
Essential Reading
• Rosen, K.H. Discrete mathematics and its applications. (New York: McGraw-Hill,
2012) 7th edition, pp.403–409, pp.410–419 and pp.422–425.
• Exercises
pp.409–410 exercises 1–7 and 13–15
pp.419–421 exercises 1–8, 27, 28, 30–32, 44 and 45.
p.425 exercises 1–3.
138
Week 20
Binomial theorem
The complexity of an expanded binomial expressions grows with the power.
(x + y)1 = x + y
(x + y)2 = x2 + 2xy + y 2
(x + y)3 = x3 + 3x2 y + 3x y 2 + y 3
(x + y)4 = x4 + 4x3 y + 6x2 y 2 + 4xy 3 + y 4
...
n
n
X n
(x + y) = xk y n−k
k
k=0
Example
What is the coefficient of x8 y 7 in the expansion of (3x − y)15 ?
This expression can be re-written as (3x + (−y))15 . By the binomial theorem we can
describe this expression as:
15
X 15
(3x + (−y)) =n
(3x)k (−y)15−k
k
k=0
15 8 15−8 15 8
3 (−1) = 3 (−1)7
8 8
15!
= −38 ·
8!7!
Pascal’s identity
Pascal’s identity helps us simplify complicated binomial coefficients.
It states that for positive natural numbers n and k:
139
Week 20
n n n+1
+ =
k k−1 k
Pascal’s triangle
Using Pascal’s identity, we can organise binomial coefficients in a trigular shape called
Pascal’s Triangle.
In this triangle, the element an,r is the binomial coefficient nr .
0
n = 0: 0
1 1
n = 1: 0 1
2 2 2
n = 2: 0 1 2
3 3 3 3
n = 3: 0 1 2 3
4 4 4 4 4
n = 4: 0 1 2 3 4
We can also show the same triangle with coeffiecients pre-calculated, as follows:
n = 0: 1
n = 1: 1 1
n = 2: 1 2 1
n = 3: 1 3 3 1
n = 4: 1 4 6 4 1
140
Week 20
Choice of formulas
n! n!
Repetition is not permitted (n−k)! k!(n−k)!
(n+k−1)!
Repetition is permitted nk k!(n−1)!
141