Discrete Mathematics Sets Relations Functions
Discrete Mathematics Sets Relations Functions
2.1 SETS
Definition
A set is an unordered collection of objects.
The objects in a set are called the elements, or members of the set. A set is said to contain
its elements.
denotes a is an element of a set A.
denotes a is not an element of a set A.
Use braces notation { } to describe a set and all the elements of the set are listed in { }.
Example 1: A = {1, 2, 3, 4}, where A denotes the set and 1, 2, 3, and 4 are elements of the
set A. Thus, we can write 1, 2, 3, 4 A.
n(A) or |A| denote the number of elements of a set A, thus using the set A of example 1,
n(A) = 4 or |A| = 4.
Equality of Sets
Let A and B be sets. Then (A = B)
Example 2: A = {a, b, c, d, e} and B = {c, a, a, b, c, e, d, b, d, e, e, c}. Then A = B
A set with one element is called a singleton set.
Example 3: {1} is a singleton set whose only element is 1, whereas 1 denotes the number
1 itself, and {1} 1.
The set { 1, {1}} contains two elements which are number 1 and the set {1}.
Let Un = {-n, n}. Thus, the number of elements of the set Un must only 2 elements.
Example 4: U3 = {-3, 3}, only two elements which are number -3 and number 3.
Empty Set
The unique set with no elements is called the empty set, denoted by or { }.
is the set with no elements. is a set with 1 element, namely the empty set.
Subsets
Let A and B be sets. A is called a subset of B, denoted by A , if and only if every
element of A is also an element of B. That is,
A = B if and only if A B and B A
For every set A, and A A
Proper Subsets
Let A and B be sets, A is called a proper subset of B, denoted by A , if and only if A
B but A B.
Example 5: S = {1, 2, 3}. Find the subsets of S.
, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}
Power Sets
Give a set S, the power set of S is the set of all subsets of the set S, denoted by P(S).
Example 6: What is the power set of the set S = {1, 2, 3}(Example5).
P(S) = 2|s| = 23 = 8
Venn Diagrams
Set can be represented graphically using Venn Diagrams.
In Venn diagrams the universal set U, which contains all the objects under
consideration, is represented by a rectangle.
Inside the rectangle, circles or other geometrical figures are used to represent sets.
Example 7: Draw a Venn diagram to represent the set S = {1, 2, 3, 4}.
U
1
2
3
4
Set Operation
Two sets can be combined in many different ways.
At this lesson, we will learn five set operation:-
Union
Intersection
Disjoint
Difference
Complement
Symmetric Difference
Union
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 union of the sets A and B if and only if x belongs to A or x
belongs to B. Hence, A B = {x | x A x B}.
Venn diagram representing the union of A and B.
Prepared By Chiang Yoke Yen (2012) Page 2
DISCRETE MATHEMATICS BA202
U
A B
A B is shaded.
Example 8: Let set B = {1, 2, 5} and set D = {2, 6, 8}, then the union of sets B and D is
B D = {1, 2, 5, 6, 8}. n(B D) = 5 or |B D| = 5.
Intersection
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 intersection of the sets A and B if and only if x belongs to A and
x belongs to B. Hence, A B = {x | x A x B}.
Venn diagram representing the intersection of A and B.
U
A B
A B is shaded
Example 9: Let set A = {1, 3, 5, 6} and set B = {5, 6, 7, 8, 9}, then the intersection of sets
A and B is A B = {5, 6}. n(A B) = 2 or |A B| = 2.
Disjoint
Two sets are called disjoint if their intersection is the empty set, denoted by A B= .
U
A B
Difference
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 and x B. Hence,
A B = {x | x A x B}.
U
A B
A B is shaded
Example 10: Let set E = {1, 3, 5} and set F = {1, 2, 3}, then the difference of the sets E
and F is E F = {5}. n(E F) = 1 or |E F| = 1
Example 11: Let set E = {1, 3, 5} and set F = {1, 2, 3}, then the difference of the sets F
and E is F E = {2}. n(F E) = 1 or |F E| = 1
Hence, from the example 10 and 11, we find that E F F E.
Complement
Let U be the universal set. The complement of the set A, denoted by A or , is the
complement of A with respect to U.
Hence, the complement of the set A is U A.
An element belongs to A if and only if x A. Therefore, A = {x | x A}.
U
A
A is shaded
Example 12: Let A be the set of positive integers greater than 10 (with universal set is the
set of all positive integers.) Then A = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}.
Symmetric Difference
Let A and B be sets. The symmetric difference of A and B, denoted by A B, is the set
containing those elements in either A or B, but not in both A and B.
U A B
Example 13: Let A = {1, 3, 5} and B = {1, 2, 3}, then the symmetric difference of the sets
A and B is A B = {2, 5}. n(A B) = 2 or | A B | = 2.
De Morgans Laws
For any two sets A and B:-
(A B) = A B - De Morgans Law First Law
(A B) = A B De Morgans Law Second Law
2. Use a Venn diagram to illustrate the set of all months of the year whose names do not
contain the letter R in the set of all months of the year.
3. Let A = {1, 2, 3, 4, 5}, B = {0, 3, 6}, C ={a, b, c, d, e} and D = {a, d, g, m, p}. Find
a) AB b) AB
c) A B d) B A
e) C D f) B C
g) C D h) D C
i) A C j) D B
k) A B l) C D
4. Find the sets A and B if A B = {1, 5, 7, 8}, B A = {2, 10} and A B = {3, 6, 9}.
6. Draw the Venn diagrams for each of these combinations of the sets A, B and C.
a) A (B C)
b) (A B) (A C)
c) (A B) (A C)
2.2 RELATIONS
Definition
Let A and B be sets. A binary relation from A to B is a subset of A B.
R A B. If a A, b B, we write a R b, a is related to b to denote (a, b) R.
If R is a relation from a set A to itself (R A A), we say R is a relation on A.
Example 1: Suppose that A = {0, 1, 2, 3, 4}, B = {0, 1, 2, 3}. Let R be the relation from A
to B, define a relation R = {a A, b B | a R b a < b}.
A B = {(0,0), (0,1), (0,2), (0,3), (1,0), (1,1), (1,2), (1,3), (2,0), (2,1), (2,2), (2,3),
(3,0), (3,1), (3,2), (3,3), (4,0), (4,1), (4,2), (4,3)}
R A B which must satisfy the condition a < b, thus
R = {(0,1), (0,2), (0,3), (1,2), (1,3), (2,3)}
Example 2: Let A = {1, 2, 3, 4}. Define a relation R = {(a, b) | (a / b) 1}
It is because has set A only, thus R A A which a A, b A and satisfy
condition (a / b) 1.
R = {(1,1), (2,1), (2,2), (3,1), (3,2), (3,3), (4,1), (4,2), (4,3), (4,4)}
Properties of Relations
These are several properties that are used to classify relations on a set:-
Reflexive
Symmetric
Antisymmetric
Transitive
Digraphs can use to prove the properties of relations.
A relation may contain more than one property of relations.
Reflexive
A relation R on a set A is called reflexive if (a, a) R for every element a A.
Using quantification, the relation R on the set A is reflexive if a ((a, a) R), where the
universe of discourse is the set of all elements in A.
Example 4: Consider the following relations on {1, 2, 3, 4}:
R1 = {(1,1), (1,2), (2,1), (2,2), (3,4), (4,1), (4,4)}
R2 = {(1,1), (1,2), (2,1)}
R3 = {(1,1), (1,2), (1,4), (2,1), (2,2), (3,3), (4,1), (4,4)}
Symmetric
A relation R on a set A is called symmetric if (b, a) R whenever (a, b) R, for all a, b
A.
Using quantification, the relation R on the set A is symmetric if and only if ab((a, b)
R (b, a) R).
Example 5: Which of the relations from example 4 are symmetric?
The relations R2 and R3 are symmetric, because in each case (b, a) belongs to the
relation whenever (a, b) does.
For R2, the only thing to check is that both (2,1) and (1,2) are in the relation.
For R3, it is necessary to check that both (1,2) and (2,1) belong to the relation, and
(1,4) and (4,1) belong to the relation.
Digraph: A relation is symmetric if and only if for every edge between distinct vertices
in its digraph there is an edge in the opposite direction (parallel edges), so that (y, x) is in
the relation whenever (x, y) is in the relation.
Antisymmetric
A relation R on the set A such that for all a, b A, if (a, b) R and (b, a) R, then a = b
is called antisymmetric.
The relation R on the set A is antisymmetric if ab (((a, b) R (b, a) R) (a = b)).
A relation is antisymmetric if and only if there are no pairs of distinct elements a and b
with a related to b and b related to a.
The term symmetric and antisymmetric are not opposites, because a relation can have both
of these properties or may lack of them.
A relation cannot both symmetric and antisymmetric if it contains some pair of the form
(a, b), where a b.
Example 6: Which of the relations from example 4 are antisymmetric?
R4, R5 and R6 are all antisymmetric. For each of these relations there is no pair of
elements a and b with a b such that (a, b) and (b, a) belong to the relation.
Digraph: A relation is antisymmetric if and only if there are never two edges in opposite
directions between distinct vertices.
Transitive
A relation R on a set A is called transitive if whenever (a, b) R and (b, c) R, then (a, c)
R, for all a, b, c A.
Using quantification, the relation R on a set A is transitive if have abc(((a, b) R
(b, c) R) (a, c) R).
Example 7: Which of the relations from example 4 are transitive?
R4, R5 and R6 are transitive. Because if (a, b) and (b, c) belong to the relation, then (a,
c) also does.
R4 is transitive because (3,2) and (2,1), (4,2) and (2,1), (4,3) and (3,1), and (4,3) and
(3,2) are the only such sets of pairs, and (3,1), (4,1), and (4,2) belong to R4.
Digraph: A relation is transitive if and only if whenever there is an edge from a vertex x
to a vertex y and an edge from a vertex y to vertex z, there is an edge from x to z.
Equivalence Relations
A relation on a set A is called an equivalence relation if it is reflexive, symmetric, and
transitive.
Two elements a and b that are related by an equivalence relation are called equivalent.
The notation a ~ b is often used to denote that a and b are equivalent elements with
respect to a particular equivalence relation.
Example 12: Let R be the relation on the set of real numbers such that a R b if and only if
a b Z. Is R an equivalence relation?
We must show that R satisfies the properties reflexive, symmetric and transitive.
Because a a = 0 is an integer for all real numbers a, a R a for all real numbers a.
Hence, R is reflexive.
Suppose that a R b. Then a b is an integer, so b a is also an integer. Hence, b R a.
Thus, R is symmetric.
If a R b and b R c, then a b and b c are integers. Therefore, a c = (a b) + (b c)
is also an integer. Hence, a R c. Thus, R is transitive.
Consequently, R is an equivalence relation.
1. List the ordered pairs in the relation R from A = {0, 1, 2, 3, 4} to B = {0, 1, 2, 3}, where
(a, b) R if and only if
a) a=b
b) a+b=4
c) a>b
2. a) List all the ordered pairs in the R = {(a, b)|a2<b+2} on the set {1, 2, 3, 4, 5, 6}.
b) Represent this relation with a digraph.
3. Draw the directed graph to represent each of these relations on the set {1, 2, 3, 4}. Then,
determine whether it is reflexive, symmetric, antisymmetric and/or transitive.
a) {(2,2), (2,3), (2,4), (3,2), (3,3), (3,4)}
b) {(1,1), (1,2), (2,1), (2,2), (3,3), (4,4)}
c) {(1,3), (1,4), (2,3), (2,4), (3,1), (3,4)}
4. List the ordered pairs in the relations on represented by the directed graph and determine
whether it is equivalence relation.
2.3 FUNCTIONS
Definition
Let A and B be nonempty sets. A function f from A to B denoted by f : A B.
Functions is a rule that assigns to each element a A with exactly one element b B, that
is f(a) = b.
If f is a function from A to B, then A is the domain of f and B is the codomain of f.
If f(a) = b, then b is the image of a and a is the preimage of b.
The range of f is the set of all images of elements of A.
Example 1: Given f : A B and let f(a) = 2, f(b) = 3, f(c) = 1, and f(d) = 4, determine the
domain of f , the codomain of f and the image.
Domain of f = {a, b, c, d} and codomain of f = {1, 2, 3, 4}
2 is image of a, 3 is image of b, 1 is image of c, and 4 is image of 4.
From the function f below, find the range of the f.
f
a 1
2
b
3
c 4
A B
Because just 1, 2, and 4 is the image of domains elements, thus the range of f is
{1,2,4}.
Properties of Functions
In this topic, we will learn four properties of functions:-
One-to-one (Injective) functions
Onto (Surjective) functions
Inverse functions
Composition functions
One-to-one Functions
A function f is said to be one-to-one, or injection, if and only if f(a1) = f(a2) implies that a1
= a2 for all a1 and a2 in the domain of f. [a1a2(f(a1) = f(a2) a1 = a2)].
A function f also said as one-to-one if and only if f(a1) f(a2) whenever a1 a2.
[[a1a2(a1 a2 f(a1) f(a2))]
Example 2: Determine whether the function f from {a, b, c, d} to {1, 2, 3, 4, 5} with f(a)
= 4, f(b) = 5, f(c) = 1, and f(d) = 3 is one-to-one.
The function f is one-to-one because f takes on different values at the four elements of
its domain.
Example 3: Determine whether the function f(x) = x2 from the set of integers to the set of
integers is one-to-one.
The function f(x) = x2 is not one-to-one because, for instance, f(1) = f(-1)= 1 but 1 -1.
Prepared By Chiang Yoke Yen (2012) Page 10
DISCRETE MATHEMATICS BA202
Onto Functions
A function f from A to B is called onto, or surjective, if and only if for every element b
B there is an element a A with f(a) = b.[xy(f(x) = y), where the universe of discourse
for x is the domain of f and the universe discourse of y is the codomain of f.]
Example 4: 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?
Because all three elements of the codomain are images of elements in the domain,
thus f is onto.
Inverse Functions
Let f : A B ne a one-to-one correspondence function. The inverse function of f, denoted
by f -1, is the function that assigns to an element b B, a unique element a A such that
f(a) = b. Hence, f -1(b) = a.
If f : A B, then f -1 : B A.
Example 6: Let f be the function from {a, b, c} to {1, 2, 3} such that f(a) = 2, f(b) = 3 and
f(c) = 1. Find the inverse functions.
f(a) = 2, then f -1(2) = a
f(b) = 3, then f -1(3) = b
f(c) = 1, then f -1(1) = c
Example 7: Let f(x) = 2x 1,find the inverse function, f -1
Let y = 2x 1
y + 1 = 2x
(y + 1) / 2 = x
f -1 (y) = (y + 1) / 2
f -1 (x) = (x + 1) / 2
Composition Functions
Let g be a function from the set A to the set B and let f be the function from the set B to
the set C. The composition of the functions f and g, denoted by f g.
Is defined by (f g)(a) = f(g(a)) = f(b) = c, where a A, b B and c C.
f g is not defined if the range of g is not a subset of the domain of f.
(f g)(a)
g(a)
f (g(a))
a f(g(a))
g(a)
g f
A B C
Example 8: 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.
(f g)(a) = f(g(a)) = f(b) = 2
(f g)(b) = f(g(b)) = f(c) = 1
(f g)(c) = f(g(c)) = f(a) = 3
g f is not defined because the range of f is not a subset of the domain g, like:
g f(a) = g(f(a)) = g(3). Thus, g f is not defined.
Example 9: Let f(x) = x + 2 and g(x) = 2x 1. Find
(a) fg
(b) g2
(c) gf(5)
fg(x) = f[g(x)]
= f(2x 1)
= (2x 1) + 2
= 2x + 1
2
g (x) = g[g(x)]
= g(2x 1)
= 2(2x 1) 1
= 4x- 3
gf(5) = g[f(5)] or gf(x) = g[f(x)]
= g(5 + 2) = g(x + 2)
= g(7) = 2(x + 2) - 1
= 2(7) 1 = 2x + 3
= 13 gf(5) = 2(5) + 3 = 13
Graph Functions
Let f be a function from the set A to the set B. The graph of the function f is the set of
ordered pairs {(a, b) | a A and f(a) = b}.
Example 11: Display the graph of the function f(x) = 2x + 1 from the set of integers to the
set of integers.
The graph of f is the set of order pairs of the form (x, 2x + 1), where x is an integer.
The graph is displayed as below:-
(2, 5)
(1, 3)
(0, 1)
(-1, -1)
Floor Function
The floor function assigns to the real number x the largest integer that is less than or equal
to x.
The value of the floor function at x is denoted by x.
Example 12: These are some values of the floor functions:
0.5 = 0 -0.5 = -1 3.1 = 3 7 = 7
Ceiling Function
The ceiling function assigns to the real number x the smallest integer that is greater than
or equal to x.
The value of the floor function at x is denoted by x.
Example 14: These are some values of the ceiling functions:
0.5 = 1 -0.5 = 0 3.1 = 4 7 = 7
Example 16: Find the value of the function 3.6 + 4.1 2.8 5.7.
3.6 = 3
4.1 2.8 =1.3 = 2
3.6 + 4.1 2.8 5.7 = 3 + 2 5.7
= - 0.7
=-1
1. Determine whether each of these functions from {a, b, c, d} to itself is one-to-one, onto
or one-to-one correspondence (bijection).
a) f(a) = b, f(b) = a, f(c) = c, f(d) = d
b) f(a) = b, f(b) = b, f(c) = d, f(d) = c
c) f(a) = d, f(b) = b, f(c) = c, f(d) = d
6. If f(x) = 3x + 4, find the function g such that gf(x) = 9x2 + 24x + 22.