Sets and Functions
Nguyen An Khuong,
Huynh Tuong Nguyen
Chapter 4
Sets and Functions
Contents
Sets
Discrete Structures for Computer Science (CO1007) on Ngày
7 tháng 10 năm 2016
Set Operation
Functions
One-to-one and Onto
Functions
Sequences and
Summation
Recursion
Nguyen An Khuong, Huynh Tuong Nguyen
Faculty of Computer Science and Engineering
University of Technology, VNU-HCM
4.1
Contents
Sets and Functions
Nguyen An Khuong,
Huynh Tuong Nguyen
1 Sets
Contents
Sets
2 Set Operation
Set Operation
Functions
3 Functions
One-to-one and Onto
Functions
Sequences and
Summation
Recursion
4 One-to-one and Onto Functions
5 Sequences and Summation
6 Recursion
4.2
Set Definition
Sets and Functions
Nguyen An Khuong,
Huynh Tuong Nguyen
• Set is a fundamental discrete structure on which all discrete
structures are built
• Sets are used to group objects, which often have the same
properties
Contents
Sets
Set Operation
Example
• Set of all the students who are currently taking Discrete
Mathematics 1 course.
• Set of all the subjects that K2011 students have to take in
Functions
One-to-one and Onto
Functions
Sequences and
Summation
Recursion
the first semester.
• Set of natural numbers N
Definition
A set is an unordered collection of objects.
The objects in a set are called the elements (phần tử ) of the set.
A set is said to contain (chứa) its elements.
4.3
Notations
Sets and Functions
Nguyen An Khuong,
Huynh Tuong Nguyen
Definition
• a ∈ A: a is an element of the set A
• a∈
/ A: a is not an element of the set A
Contents
Sets
Set Operation
Functions
One-to-one and Onto
Functions
Definition (Set Description)
• The set V of all vowels in English alphabet, V = {a, e, i, o, u}
Sequences and
Summation
Recursion
• Set of all real numbers greater than 1???
{x | x ∈ R, x > 1}
{x | x > 1}
{x : x > 1}
4.4
Equal Sets
Sets and Functions
Nguyen An Khuong,
Huynh Tuong Nguyen
Contents
Definition
Sets
Two sets are equal iff they have the same elements.
Set Operation
Functions
• (A = B) ↔ ∀x(x ∈ A ↔ x ∈ B)
One-to-one and Onto
Functions
Sequences and
Summation
Example
Recursion
• {1, 3, 5} = {3, 5, 1}
• {1, 3, 5} = {1, 3, 3, 3, 5, 5, 5, 5}
4.5
Venn Diagram
Sets and Functions
Nguyen An Khuong,
Huynh Tuong Nguyen
Contents
• John Venn in 1881
• Universal set (tập vũ trụ) is
represented by a rectangle
• Circles and other
geometrical figures are used
to represent sets
Sets
Set Operation
Functions
One-to-one and Onto
Functions
Sequences and
Summation
Recursion
• Points are used to represent
particular elements in set
4.6
Special Sets
Sets and Functions
Nguyen An Khuong,
Huynh Tuong Nguyen
Contents
Sets
Set Operation
• Empty set (tập rỗng ) has no elements, denoted by ∅, or {}
• A set with one element is called a singleton set
Functions
One-to-one and Onto
Functions
• What is {∅}?
Sequences and
Summation
• Answer: singleton
Recursion
4.7
Subset
Sets and Functions
Nguyen An Khuong,
Huynh Tuong Nguyen
Definition
The set A is called a subset (tập con) of B iff every element of A
is also an element of B, denoted by A ⊆ B.
Contents
Sets
Set Operation
Functions
If A = B, we write A ⊂ B and say A is a proper subset (tập con
thực sự) of B.
One-to-one and Onto
Functions
Sequences and
Summation
Recursion
• ∀x(x ∈ A → x ∈ B)
• For every set S,
(i) ∅ ⊆ S, (ii) S ⊆ S.
4.8
Cardinality
Sets and Functions
Nguyen An Khuong,
Huynh Tuong Nguyen
Definition
If S has exactly n distinct elements where n is non-negative
integers, S is finite set (tập hữu hạn), and n is cardinality (bản
số ) of S, denoted by |S|.
Contents
Sets
Set Operation
Example
• A is the set of odd positive integers less than 10. |A| = 5.
• S is the letters in Vietnamese alphabet, |S| = 29.
• Null set |∅| = 0.
Functions
One-to-one and Onto
Functions
Sequences and
Summation
Recursion
Definition
A set that is infinite if it is not finite.
Example
• Set of positive integers is infinite
4.9
Power Set
Sets and Functions
Nguyen An Khuong,
Huynh Tuong Nguyen
Definition
Given a set S, the power set (tập lũy thừa) of S is the set of all
subsets of the set S, denoted by P (S).
Contents
Sets
Set Operation
Functions
Example
What is the power set of {0, 1, 2}?
P ({0, 1, 2}) = {∅, {0}, {1}, {2}, {0, 1}, {0, 2}, {1, 2}, {0, 1, 2}}
One-to-one and Onto
Functions
Sequences and
Summation
Recursion
Example
• What is the power set of the empty set?
• What is the power set of the set {∅}
4.10
Sets and Functions
Power Set
Nguyen An Khuong,
Huynh Tuong Nguyen
Contents
Sets
Set Operation
Functions
Theorem
n
If a set has n elements, then its power set has 2 elements.
One-to-one and Onto
Functions
Sequences and
Summation
Prove using induction!
Recursion
4.11
Ordered n-tuples
Sets and Functions
Nguyen An Khuong,
Huynh Tuong Nguyen
Definition
The ordered n-tuple (dãy sắp thứ tự) (a1 , a2 , . . . , an ) is the
ordered collection that has a1 as its first element, a2 as its second
element, . . ., and an as its nth element.
Contents
Sets
Set Operation
Functions
One-to-one and Onto
Functions
Definition
Two ordered n-tuples (a1 , a2 , . . . , an ) = (b1 , b2 , . . . , bn ) iff ai = bi ,
for i = 1, 2, . . . , n.
Sequences and
Summation
Recursion
Example
2-tuples, or ordered pairs (cặp), (a, b) and (c, d) are equal iff
a = c and b = d
4.12
Cartesian Product
Sets and Functions
Nguyen An Khuong,
Huynh Tuong Nguyen
• René Descartes (1596–1650)
Contents
Definition
Sets
Let A and B be sets. The Cartesian product (tích Đề-các) of A
and B, denoted by A × B, is the set of ordered pairs (a, b), where
a ∈ A and b ∈ B. Hence,
A × B = {(a, b) | a ∈ A ∧ b ∈ B}
Set Operation
Functions
One-to-one and Onto
Functions
Sequences and
Summation
Recursion
Example
Cartesian product of A = {1, 2} and B = {a, b, c}. Then
A × B = {(1, a), (1, b), (1, c), (2, a), (2, b), (2, c)}
Show that A × B = B × A
4.13
Sets and Functions
Cartesian Product
Nguyen An Khuong,
Huynh Tuong Nguyen
Definition
Contents
Sets
A1 ×A2 ×· · ·×An = {(a1 , a2 , . . . , an ) | ai ∈ Ai for i = 1, 2, . . . , n}
Set Operation
Functions
One-to-one and Onto
Functions
Example
Sequences and
Summation
A = {0, 1}, B = {1, 2}, C = {0, 1, 2}. What is A × B × C?
Recursion
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)}
4.14
Sets and Functions
Union
Nguyen An Khuong,
Huynh Tuong Nguyen
Definition
The union (hợp) of A and B
Contents
Sets
A ∪ B = {x | x ∈ A ∨ x ∈ B}
Set Operation
Functions
One-to-one and Onto
Functions
A∪B
Sequences and
Summation
Recursion
A
B
• Example:
• {1,2,3} ∪ {2,4} = {1,2,3,4}
• {1,2,3} ∪ ∅ = {1,2,3}
4.15
Sets and Functions
Intersection
Nguyen An Khuong,
Huynh Tuong Nguyen
Definition
The intersection (giao) of A and B
Contents
Sets
A ∩ B = {x | x ∈ A ∧ x ∈ B}
Set Operation
Functions
One-to-one and Onto
Functions
A∩B
Sequences and
Summation
Recursion
A
B
Example:
• {1,2,3} ∩ {2,4} = {2}
• {1,2,3} ∩ N = {1,2,3}
4.16
Union/Intersection
Sets and Functions
Nguyen An Khuong,
Huynh Tuong Nguyen
Contents
Sets
Set Operation
Functions
n
and Onto
Ai = A1 ∪ A2 ∪ ... ∪ An = {x | x ∈ A1 ∨ x ∈ A2 ∨ ... ∨ x ∈ An } One-to-one
Functions
i=1
Sequences and
Summation
n
Recursion
Ai = A1 ∩ A2 ∩ ... ∩ An = {x | x ∈ A1 ∧ x ∈ A2 ∧ ... ∧ x ∈ An }
i=1
4.17
Sets and Functions
Difference
Nguyen An Khuong,
Huynh Tuong Nguyen
Definition
The difference (hiệu) of A and B
Contents
Sets
A − B = {x | x ∈ A ∧ x ∈
/ B}
Set Operation
Functions
One-to-one and Onto
Functions
A−B
Sequences and
Summation
Recursion
A
B
Example:
• {1,2,3} - {2,4} = {1,3}
• {1,2,3} - N = ∅
4.18
Sets and Functions
Complement
Nguyen An Khuong,
Huynh Tuong Nguyen
Definition
The complement (phần bù) of A
Contents
A = {x | x ∈A}
/
Sets
Set Operation
Functions
One-to-one and Onto
Functions
Example:
• A = {1,2,3} then A = ???
• Note that A - B = A ∩ B
Sequences and
Summation
Recursion
4.19
Sets and Functions
Set Identities
Nguyen An Khuong,
Huynh Tuong Nguyen
Contents
A∪∅
A∩U
=
=
A
A
Identity laws
Luật đồng nhất
A∪U
A∩∅
=
=
U
∅
Domination laws
Luật nuốt
One-to-one and Onto
Functions
A∪A
A∩A
=
=
A
A
Idempotent laws
Luật lũy đẳng
Recursion
¯
(A)
=
A
Complementation law
Luật bù
Sets
Set Operation
Functions
Sequences and
Summation
4.20
Sets and Functions
Set Identities
Nguyen An Khuong,
Huynh Tuong Nguyen
Contents
A∪B
A∩B
=
=
B∪A
B∩A
A ∪ (B ∪ C)
A ∩ (B ∩ C)
=
=
(A ∪ B) ∪ C
(A ∩ B) ∩ C
Associative laws
Luật kết hợp
One-to-one and Onto
Functions
A ∪ (B ∩ C)
A ∩ (B ∪ C)
=
=
(A ∪ B) ∩ (A ∪ C)
(A ∩ B) ∪ (A ∩ C)
Distributive laws
Luật phân phối
Recursion
A∪B
A∩B
=
=
A∩B
A∪B
Commutative laws
Luật giao hoán
Sets
Set Operation
Functions
Sequences and
Summation
De Morgan’s laws
Luật De Morgan
4.21
Method of Proofs of Set Equations
Sets and Functions
Nguyen An Khuong,
Huynh Tuong Nguyen
Contents
Sets
To prove A = B, we could use
• Venn diagrams
• Prove that A ⊆ B and B ⊆ A
• Use membership table
Set Operation
Functions
One-to-one and Onto
Functions
Sequences and
Summation
Recursion
• Use set builder notation and logical equivalences
4.22
Example (1)
Sets and Functions
Nguyen An Khuong,
Huynh Tuong Nguyen
Contents
Sets
Set Operation
Functions
One-to-one and Onto
Functions
Sequences and
Summation
Recursion
Example
Verify the distributive rule P ∪ (Q ∩ R) = (P ∪ Q) ∩ (P ∪ R)
4.23
Example (2)
Sets and Functions
Nguyen An Khuong,
Huynh Tuong Nguyen
Example
Prove: A ∩ B = A ∪ B
(1) Show that A ∩ B ⊆ A ∪ B
Suppose that x ∈ A ∩ B
By the definition of complement, x ∈
/ A∩B
So, x ∈
/ A or x ∈
/B
¯
Hence, x ∈ A¯ or x ∈ B
We conclude, x ∈ A ∪ B
Or, A ∩ B ⊆ A ∪ B
Contents
Sets
Set Operation
Functions
One-to-one and Onto
Functions
Sequences and
Summation
Recursion
(2) Show that A ∪ B ⊆ A ∩ B
4.24
Sets and Functions
Example (3)
Nguyen An Khuong,
Huynh Tuong Nguyen
Contents
Sets
Prove: A ∩ B = A ∪ B
Set Operation
A
B
A∩B
A∩B
¯
A¯ ∪ B
1
1
0
0
1
0
1
0
1
0
0
0
0
1
1
1
0
1
1
1
Functions
One-to-one and Onto
Functions
Sequences and
Summation
Recursion
4.25