Sets Functions Sequences Exercises
Sets Functions Sequences Exercises
2.1 Sets:
Introduction: In this section, we study the fundamental discrete structure on which all other
discrete structures are built, namely, the set. Sets are used to group objects together. Often,
but not always, the objects in a set have similar properties. For instance, all the students who
are currently enrolled at any school/college, make up a set. Likewise, all the students currently
taking a discrete mathematics course make up a set. In addition, those currently enrolled
students, who are taking a course in discrete mathematics form a set that can be obtained by
taking the elements common to the first two collections.
Definition: A set is an unordered collection of objects, called elements or members of the set.
A set is said to contain its elements. We write a ∈ A to denote that a is an element of the set A.
The notation a ∉ A denotes that a is not an element of the set A.
It is common for sets to be denoted using uppercase letters. Lowercase letters are usually
used to denote elements of sets.
There are several ways to describe a set. One way is to list all the members of a set, when
this is possible. We use a notation where all members of the set are listed between braces. For
example, the notation {a, b, c, d} represents the set with the four elements a, b, c, and d. This
way of describing a set is known as the roster method.
EXAMPLE 1 The set V of all vowels in the English alphabet can be written as V = {a, e, i, o, u}.
EXAMPLE 2 The set O of odd positive integers less than 10 can be expressed by
O = {1, 3, 5, 7, 9}.
Sometimes the roster method is used to describe a set without listing all its members. Some
members of the set are listed, and then ellipses (. . .) are used when the general pattern of the
elements is obvious.
EXAMPLE 3: The set of positive integers less than 100 can be denoted by {1, 2, 3, . . . , 99}.
Page 1 of 22
Another way to describe a set is to use set builder notation. We characterize all those
elements in the set by stating the property or properties they must have to be members. For
instance, the set O of all odd positive integers less than 10 can be written as
O = {x | x is an odd positive integer less than 10}, or, specifying the universe as the set of
positive integers, as O = {x ∈ Z+ | x is odd and x < 10}.
We often use this type of notation to describe sets when it is impossible to list all the elements
of the set. For instance, the set Q+ of all positive rational numbers can be written as
𝑝
Q+ = {x ∈ R | x = 𝑞 , for some positive integers p and q}.
These sets ( common Universal sets), each denoted using a boldface letter, play an important
role in discrete mathematics:
N = {0, 1, 2, 3, . . .}, the set of natural numbers
Z = {. . . ,−2,−1, 0, 1, 2, . . .}, the set of integers
Z+ = {1, 2, 3, . . .}, the set of positive integers
Q = {p/q | p ∈ Z, q ∈ Z, and q _= 0}, the set of rational numbers
R, the set of real numbers
R+, the set of positive real numbers
C, the set of complex numbers.
Definition: Two sets are equal if and only if they have the same elements. Therefore, if A and
B are sets, then A and B are equal if and only if ∀x(x ∈ A ↔ x ∈ B). We write A = B if A and B
are equal sets.
EXAMPLE 4: The sets {1, 3, 5} and {3, 5, 1} are equal, because they have the same elements.
Note that the order in which the elements of a set are listed does not matter. Note also that it
does not matter if an element of a set is listed more than once, so {1, 3, 3, 3, 5, 5, 5, 5} is the
same as the set {1, 3, 5} because they have the same elements.
The empty set: There is a special set that has no elements. This set is called the empty set,
or null set, and is denoted by ∅. The empty set can also be denoted by { }
Definition: The set A is a subset of B if and only if every element of A is also an element of B.
We use the notation A ⊆ B to indicate that A is a subset of the set B.
Page 2 of 22
The Size of a Set
Sets are used extensively in counting problems, and for such applications we need to discuss
the sizes of sets.
Definition: Let S be a set. If there are exactly n distinct elements in S where n is a nonnegative
integer, we say that S is a finite set and that n is the cardinality of S. The cardinality of S is
denoted by |S|.
EXAMPLE 5 Let A be the set of odd positive integers less than 10. Then |A| = 5.
EXAMPLE 6 Let S be the set of letters in the English alphabet. Then |S| = 26.
EXAMPLE 7 Because the null set has no elements, it follows that |∅| = 0.
Definition: Given a set S, the power set of S is the set of all subsets of the set S. The power set
of S is denoted by P(S).
Note: If a set has n elements, then its power set has 2n elements.
Definition: Let A and B be sets. The Cartesian product of A and B, denoted by A × B, is the set
of all ordered pairs (a, b), where a ∈ A and b ∈ B. Hence, A × B = {(a, b) | a ∈ A ∧ b ∈ B}.
EXAMPLE 10 What is the Cartesian product A × B × C, where A = {0, 1}, B = {1, 2}, and
C = {0, 1, 2} ?
Solution: The Cartesian productA × B × C consists of all ordered triples (a, b, c), where a ∈ A,
b ∈ B, and c ∈ C.
Hence, A × B × C = {(0, 1, 0), (0, 1, 1), (0, 1, 2), (0, 2, 0), (0, 2, 1), (0, 2, 2), (1, 1, 0), (1, 1, 1),
(1, 1, 2), (1, 2, 0), (1, 2, 1), (1, 2, 2)}.
Page 3 of 22
Note : When A, B, and C are sets, (A × B) × C is not the same as A × B × C
We use the notation A2 to denote A × A, the Cartesian product of the set A with itself.
Similarly, A3 = A × A × A, A4 = A × A × A × A, and so on. More generally,
An = {(a1, a2, . . . , an) | ai ∈ A for i = 1, 2, . . . , n}.
EXAMPLE 11 Suppose that A = {1, 2}. It follows that A2 = {(1, 1), (1, 2), (2, 1), (2, 2)} and
A3 = {(1, 1, 1), (1, 1, 2), (1, 2, 1), (1, 2, 2), (2, 1, 1), (2, 1, 2), (2, 2, 1), (2, 2, 2)}.
Page 4 of 22
Exercise 2.1
1. List the members of these sets.
a) {x | x is a real number such that x2 = 1}
b) {−3,−2,−1, 0, 1, 2, 3}
c) {m, n, o, p}
c) ∅, {∅}
4. For each of the following sets, determine whether 2 is an element of that set.
a) {x ∈ R | x is an integer greater than 1}
c) {2,{2}}
Page 5 of 22
5. What is the cardinality of each of these sets?
a) {a}
b) {{a}}
c) {a, {a}}
6. Find the power set of each of these sets, where a and b are distinct elements.
a) {a}
b) {a, b}
c) {∅, {∅}}
a) A × B.
b) B × A.
b) C × B × A.
c) C × A × B.
d) B × B × B.
9. Find A2 if
a) A = {0, 1, 3}.
b) A = {1, 2, a, b}.
Page 6 of 22
10. Find A3 if
a) A = {a}.
b) A = {0, a}.
Page 7 of 22
2.2 Set Operations:
Introduction: Two, or more, sets can be combined in many different ways. For instance,
starting with the set of Computer Science majors at your school and the set of Business majors
at your school, we can form the set of students who are Computer Science majors or Business
majors, the set of students who are joint majors in Business and Computer science, the set of
all students not majoring in Computer Science, and so on.
Definition: Let A and B be sets. The union of the sets A and B, denoted by A ∪ B, is the set
that contains those elements that are either in A or in B, or in both.
An element x belongs to the union of the sets A and B if and only if x belongs to A or x belongs
to B. This tells us that A ∪ B = {x | x ∈ A ∨ x ∈ B}.
EXAMPLE 12 The union of the sets {1, 3, 5} and {1, 2, 3} is the set {1, 2, 3, 5};
that is, {1, 3, 5} ∪ {1, 2, 3} = {1, 2, 3, 5}.
Definition: Let A and B be sets. The intersection of the sets A and B, denoted by A ∩ B, is the
set containing those elements in both A and B.
An element x belongs to the intersection of the sets A and B if and only if x belongs to A and
x belongs to B. This tells us that A ∩ B = {x | x ∈ A ∧ x ∈ B}.
EXAMPLE 13 The intersection of the sets {1, 3, 5} and {1, 2, 3} is the set {1, 3};
that is, {1, 3, 5} ∩ {1, 2, 3} = {1, 3}.
Definition: Let A and B be sets. The difference of A and B, denoted by A − B, is the set
containing those elements that are in A but not in B. The difference of A and B is also called the
complement of B with respect to A.
An element x belongs to the difference of A and B if and only if x ∈ A andx /∈ B. This tells us
That A − B = {x | x ∈ A ∧x /∈ B}.
EXAMPLE 14 The difference of {1, 3, 5} and {1, 2, 3} is the set {5}; that is, {1, 3, 5} − {1, 2, 3} =
{5}. This is different from the difference of {1, 2, 3} and {1, 3, 5}, which is the set {2}.
Page 8 of 22
Definition: Let U be the universal set. The complement of the set A, denoted by 𝐴̅, is the
complement of A with respect to U. Therefore, the complement of the set A is U − A.
EXAMPLE 15 Let A = {a, e, i, o, u} (where the universal set is the set of letters of the English
alphabet). Then A = {b, c, d, f, g, h, j, k, l,m, n, p, q, r, s, t, v,w, x, y, z}.
Page 9 of 22
Exercise 2.2
1. Let A = {1, 2, 3, 4, 5} and B = {0, 3, 6}. Find
a) A ∪ B.
b) A ∩ B.
c) A − B.
d) B − A.
b) A − B.
c) B − A.
d) A ∩ B.
b) A ∪ B ∪ C.
c) (A ∪ B) ∩ C.
d) (A ∩ B) ∪ C.
4. What can you say about the sets A and B if we know that
a) A ∪ B = A?
b) A ∩ B = A?
c) A − B = A?
d) A ∩ B = B ∩ A?
Page 10 of 22
2.3 Functions
Introduction : In many instances we assign to each element of a set a particular element of a
second set (which may be the same as the first). For example, suppose that each student in a
discrete mathematics class is assigned a letter grade from the set {A,B,C,D, F}. And suppose that
the grades are A for Adams, C for Chou, B for Goodfriend, A for Rodriguez, and F for Stevens.
This assignment of grades is illustrated in Figure 1.
Adams A
Chou B
Goodfriend C
Rodriguez D
Stevens F
FIGURE 1: Assignment of Grades in a Discrete Mathematics Class.
Definition: If f is a function from A to B, we say that A is the domain of f and B is the codomain
of f. If f (a) = b, we say that b is the image of a and a is a preimage of b. The range, or image,
of f is the set of all images of elements of A. Also, if f is a function from A to B, we say that f
maps A to B.
EXAMPLE 16 What are the domain, codomain, and range of the function that assigns grades to
students described in the first paragraph of the introduction of this section?
Solution: Let G be the function that assigns a grade to a student in our discrete mathematics
class. Note that G(Adams) = A, for instance.
The domain of G is the set {Adams, Chou, Goodfriend, Rodriguez, Stevens}, and
the codomain is the set {A,B,C,D, F}.
The range of G is the set {A,B,C, F}, because each grade except D is assigned to some student.
Page 11 of 22
Definition: Let f be a function from A to B and let S be a subset of A. The image of S under
the function f is the subset of B that consists of the images of the elements of S. We denote the
image of S by f (S), so f (S) = {t | ∃s ∈S (t = f (s))}.
We also use the shorthand {f (s) | s ∈ S} to denote this set.
EXAMPLE 17 : Let A = {a, b, c, d, e} and B = {1, 2, 3, 4} with f (a) = 2, f (b) = 1, f (c) = 4, f (d) = 1,
and f (e) = 1. The image of the subset S = {b, c, d} is the set f (S) = {1, 4}.
a 1
b 2
c 3
d 4
5
FIGURE 2: A One-to-One Function.
Solution: The function f is one-to-one because f takes on different values at the four elements
of its domain.
Page 12 of 22
Definition: A function f from A to B is called onto, or a surjection, if and only if for every
element b ∈ B there is an element a ∈ A with f (a) = b. A function f is called surjective if it is
onto.
a 1
b 2
c 3
d
FIGURE 3: An Onto Function.
EXAMPLE 19 : Let f be the function from {a, b, c, d} to {1, 2, 3} defined by f (a) = 3, f (b) = 2, f (c)
= 1, and f (d) = 3. Is f an onto function?
Solution: Because all three elements of the codomain are images of elements in the domain, we
see that f is onto. Note that if the codomain were {1, 2, 3, 4}, then f would not be onto.
EXAMPLE 20: Let f be the function from {a, b, c, d} to {1, 2, 3, 4} with f (a) = 4, f (b) = 2, f (c) = 1,
and f (d) = 3. Is f a bijection?
Solution: The function f is one-to-one and onto. It is one-to-one because no two values in
the domain are assigned the same function value. It is onto because all four elements of the
codomain are images of elements in the domain. Hence, f is a bijection.
Page 13 of 22
Definition: Let g be a function from the set A to the set B and let f be a function from the set
B to the set C. The composition of the functions f and g, denoted for all a ∈ A by f ◦ g, is
defined by (f ◦ g)(a) = f (g(a)).
EXAMPLE 21: Let g be the function from the set {a, b, c} to itself such that g(a) = b, g(b) = c, and
g(c) = a.
Let f be the function from the set {a, b, c} to the set {1, 2, 3} such that f (a) = 3, f (b) = 2, and
f (c) = 1. What is the composition of f and g, and what is the composition of g and f ?
EXAMPLE 22: Let f and g be the functions from the set of integers to the set of integers defined
by f (x) = 2x + 3 and g(x) = 3x + 2. What is the composition of f and g? What is the composition
of g and f ?
Page 14 of 22
Exercise 2.3
Page 15 of 22
2. Determine whether each of these functions from Z to Z is one-to-one.
a) f (n) = n − 1
b) f (n) = n2 + 1
c) f (n) = n3
Page 16 of 22
4. Determine whether each of these functions is a bijection from R to R.
a) f (x) = 2x + 1
b) f (x) = x2 + 1
c) f (x) = x3
Page 17 of 22
2.4 Sequences and Summations
Introduction: Sequences are ordered lists of elements, used in discrete mathematics in many
ways. They are also an important data structure in computer science. We will often need to
work with sums of terms of sequences in our study of Discrete Mathematics.
The terms of a sequence can be specified by providing a formula for each term of the
Sequence. Identifying a sequence when the first few terms are provided is a useful skill when
solving problems in discrete mathematics.
Definition: A sequence is a function from a subset of the set of integers (usually either the set
{0, 1, 2, . . .} or the set {1, 2, 3, . . .}) to a set S. We use the notation an to denote the image of
the integer n. We call an a term of the sequence
1
EXAMPLE 23: Consider the sequence {an}, where an = 𝑛
The list of the terms of this sequence, beginning with a1, namely,
1 1 1 1
a1, a2, a3, a4, . . . , starts with 1 , 2 , 3 , 4 , ……… etc
Page 18 of 22
EXAMPLE 25 Let {an} be a sequence that satisfies the recurrence relation
an = an−1 − an−2 for n = 2, 3, 4, . . . , and suppose that a0 = 3 and a1 = 5. What are a2 and a3?
Summations :
Next, we consider the addition of the terms of a sequence. For this we introduce summation
notation. We begin by describing the notation used to express the sum of the terms
am, am+1, . . . , an from the sequence {an}.We use the notation
𝑛
∑ 𝑎𝑗
𝑗=𝑚
Here, the variable j is called the index of summation, and the choice of the letter j as the
variable is arbitrary; that is, we could have used any other letter, such as i or k.
EXAMPLE 26 Use summation notation to express the sum of the first 100 terms of the
1
sequence {aj }, where aj = 𝑗 for j= 1, 2, 3, . . . .
Solution: The lower limit for the index of summation is 1, and the upper limit is 100.We write
this sum as
100
1
∑
𝑗
𝑗=1
Page 19 of 22
EXAMPLE 28: What is the value of ∑8𝑘=4(−1)𝑘 ?
Solution: We have
8
∑(−1)𝑘
𝑘=4
Page 20 of 22
Exercise 2.4
1. Find these terms of the sequence {an}, where an = 2 ・ (−3)n + 5n.
a) a0 b) a1 c) a4 d) a5
a) 2n−1? b) 7?
3. What are the terms a0, a1, a2, and a3 of the sequence {an}, where an equals
a) 2n + 1?
b) (−2)n ?
c) 7 + 4n?
Page 21 of 22
4. Find the first five terms of the sequence defined by each of these recurrence relations and
initial conditions.
a) an = 6an−1, a0 = 2
b) an = a2n−1, a1 = 2
c) an = an−1 + 3an−2, a0 = 1, a1 = 2
a) ∑5𝑘=1(𝑘 + 1)
b) ∑4𝑗=0(−2)𝑗
Page 22 of 22