Week 5 - Sets
Week 5 - Sets
4 SETS
Why do you need to learn Set Theory? Why is it important to learn Computer Science? Set Theory and
Logic is indivisible. Set Theory is as important as Logic in Computer Science. Almost all mathematics can
be formalized in Set Theory. This module will introduce you to Set Theory that would facilitate your
ability to think abstractly. This module will also provide you with a foundation on which to build a firm
understanding and analysis of the new ideas in Computer Science.
Objectives:
DISCRETE STRUCTURES 1 22
Sets
• The words set and element are undefined terms of set theory just as sentence, true, and false
are undefined terms of logic.
Characteristics of Sets
It means that a set should not contain duplicates; the ordering of elements is
insignificant; and you should be able to determine whether or not a certain element belongs to
the set.
Example:
Letters = {a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z}
Vowels = {a, e, i, o, u}
Bits = {0, 1}
– A={1, 1, 2, 3}
– B={1, 2, 3, 3}
– X={2, 3, 1, 3}
Since set should not contain duplicates, the sample sets stated above can be simply
written as set with three elements, {1, 2, 3}
• If the elements can be counted or enumerated, then the set is said to be finite. Otherwise, it is
infinite.
Example:
Finite set
– A={1, 1, 2, 3}
– B={1, 2, 3, 3}
Infinite Set - the symbol “…”, ellipsis, is a short for “and so forth.”
– A={1, 2, …}
– B={1, 2, 3, 3…}
DISCRETE STRUCTURES 1 23
Sets
Exercise
1. Negative integers
5. ASCII characters
Set Representation
• Tabular Form
• Descriptive Form
Tabular Form
• Listing all the elements of a set, separated by commas and enclosed within braces or curly
brackets { }.
Example:
Descriptive Form
Example:
DISCRETE STRUCTURES 1 24
Sets
• All elements in the set are characterized by stating the property or properties they must
have to be members.
Example:
Exercise
b. {a, e, i, o, u}
DISCRETE STRUCTURES 1 25
Sets
Set Representation
• For instance, suppose you’re to represent the set of all real numbers between 0 and 1. It’s
impossible to list down all the elements of this set. Thus, you can only use the rule method to
describe this set.
These sets, each denoted using a boldface letter, play an important role in discrete mathematics:
– N = {1, 2, 3, … }
– W = {0, 1, 2, 3, … }
Z – Set of Integers
– Z = {0, ±1, ± 2, ± 3, …}
– {“Z” stands for the first letter of the German word for integer: Zahlen.}
– E = {0, ±2, ± 4, ± 6, …}
– Q = {x | x = p/q ; p, q Z, q 0}
DISCRETE STRUCTURES 1 26
Sets
Example:
Subset
• If A and B are two sets, A is called a subset of B, written A B, if, and only if, any element of A is
also an element of B.
Symbolically
A B x (xA xB)
The phrase A is contained in B and B contains A are alternative ways of saying that A is a
subset of B.
When A is not subset of B, then there exists at least one x A such that x B.
Example:
Let
A = {1, 3, 5}
B = {1, 2, 3, 4, 5}
C = {1, 2, 3, 4}
D = {3, 1, 5}
Then
Example:
A D (Because every element of A is also an element of D and also note that every element of
D is in A so D A)
DISCRETE STRUCTURES 1 27
Sets
Example:
Let
A = {1}
B = {{1}}
C = { 1, {1} }
AC
Then
BC
A B since 1 {{1}}
Exercise
Suppose that A = {2, 4, 6}, B = {2, 6}, C = {4, 6}, and D = {4, 6, 8}. Determine which of these sets are
subsets of other sets.
Proper Subset
• Let A and B be sets. A is a proper subset of B. If, and only if, every element of A is in B but there
is at least one element of B that is not in A, it is denoted as A B.
Example:
Let
A = {1, 3, 5}
B = {1, 2, 3, 5}
Then
Set Equality
• Two sets A and B are equal if, and only if, every element of A is in B and every element of B is in
A and is denoted as A = B.
Symbolically:
A = B if A B and B A
DISCRETE STRUCTURES 1 28
Sets
Example:
Let
A = {1, 2, 3, 6}
C = {3, 1, 6, 2}
D = {1, 2, 2, 3, 6, 6, 6}
Then
Null Set
• A set which contains no element is called a null set, or an empty set or a void set. It is denoted
by the Greek letter (phi) or { }.
Example:
Exercise
1. x {x}
2. {x} {x}
3. {x} {x}
4. {x}
5. {x}
DISCRETE STRUCTURES 1 29
Sets
Universal Set
The set of all elements under consideration is called the Universal Set. The Universal Set is
usually denoted by U and is represented by a rectangle.
Venn Diagram
Venn diagrams are often used to indicate the relationships between sets.
The Universal Set is represented by the interior of a rectangle, and the other sets are
represented by circle within the rectangle.
Draw a Venn Diagram that represents V, the set of vowels in the English Alphabet.
We draw a rectangle to indicate the universal set U, which is the set of the 26 letters of the
English alphabet. Inside this rectangle, we draw a circle to represent V. Inside this circle we
indicate the elements of V with points
Example:
AB
DISCRETE STRUCTURES 1 30
Sets
Example:
AB
AB
AB
DISCRETE STRUCTURES 1 31
Sets
Operations on Sets
Union
The union of A and B, denoted A U B, is the set of all elements that are in at least one of A or B.
A U B = {x U | x A or x B}
Example:
Let
U = {a, b, c, d, e, f, g}
A = {a, c, e, g}
B = {d, e, f, g}
Then
A U B = {a, c, d, e, f, g}
Intersection
The intersection of A and B, denoted A ∩ B, is the set of all elements that are common to both A
and B.
A ∩ B = {x U | x A and x B}
Example:
Let
U = {a, b, c, d, e, f, g}
A = {a, c, e, g}
B = {d, e, f, g}
Then
A ∩ B = {e, g}
DISCRETE STRUCTURES 1 32
Sets
Difference
The difference of A minus B (or relative complement of A in B), denoted A − B, is the set of all
elements that are in A and not B.
A – B = {x U | x A and x B}
Example:
Let
U = {a, b, c, d, e, f, g}
A = {a, c, e, g}
B = {d, e, f, g}
Then
A – B = {a, c}
Example:
Let
U = {a, b, c, d, e, f, g}
A = {a, c, e, g}
B = {d, e, f, g}
Then
B – A = {d, f}
DISCRETE STRUCTURES 1 33
Sets
Symmetric Difference
The symmetric difference of A and B, denoted A B, is the set of all elements that are in either
A or B but not both or the union of the difference of A and B and B and A.
A B = {x U | x A and x B} U {x U | x B and x A}
Example:
Let
U = {a, b, c, d, e, f, g}
A = {a, c, e, g}
B = {d, e, f, g}
Then
A B = {a, c, d, f}
Complement
The complement of A, denoted Ac, is the set of all elements in U that are not in A.
Ac = {x U | x A}
Empty sets and universal set are related by C=U and Uc=
Example:
Let
U = {a, b, c, d, e, f, g}
A = {a, c, e, g}
Then
Ac = {b, d, f}
DISCRETE STRUCTURES 1 34
Sets
Exercise
Let A = {1, 3, 5, 7, 9}, B = {3, 6, 9}, and C = {2, 4, 6, 8}. Find each of the following and draw a Venn
Diagram representing each operation.
1. B – A 6. B C
2. A U B 7. A B
3. A – B 8. A U C
4. A ∩ B 9. A U C U C
5. B U C 10. A – C
Partitions of Set
In many applications of set theory, sets are divided up into non-overlapping (or disjoint) pieces.
Such a division is called a partition.
Two sets are called disjoint if, and only if, they have no elements in common.
A∩B=
Example:
Let
A = {1, 3, 5}
B = {2, 4, 6}
Then
A ∩ B = {1, 3, 5} ∩ {2, 4, 6}
A∩B=
Power Set
There are various situations in which it is useful to consider the set of all subsets of a particular
set.
The power set axiom guarantees that this is a set.
Given a set A, the power set of A, denoted by P(A), is the set of all subsets of A.
DISCRETE STRUCTURES 1 35
Sets
Example:
Let
A = {1, 2}
Then
Exercise
1. A={a, b, c, d}
2. B={2, 3, 5, 7, 9}
A set is called finite if, and only if, it is the empty set or there is one-to-one correspondence from
{1,2,3, …, n} to it, where n is a positive integer.
A non empty set that cannot be put into one-to-one correspondence with {1, 2, 3,…, n}, for any
positive integer n, is called infinite set.
Set Cardinality
The number of elements in a finite set A is termed as the cardinality of set A, denoted by |A|.
Thus, if A = {1, 2, 3} then |A| = 3.
Let A and B be any sets. A has the same cardinality as B if, and only if, there is a one-to-one
correspondence from A to B (Cardinality means “the total number of elements in a set”) .
When A and B have the same cardinality, we write |A| = |B|.
DISCRETE STRUCTURES 1 36
Sets
Exercise
1. {1}
2. {1, {1}}
3. {{1}}
Cartesian Product
The order of elements in a collection is often important. Because sets are unordered, a different
structure is needed to represent ordered collections. This is provided by ordered n-tuples.
The ordered n-tuple (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.
Given sets A1, A2, . . . , An, the Cartesian product of A1, A2, . . . , An denoted A1 × A2 × . . . × An,
is the set of all ordered n-tuples (a1, a2, . . . , an) where a1 ∈ A1, a2 ∈ A2, . . . , an ∈ An.
A1 × A2 ×· · ·× An = {(a1, a2, . . . , an) | a1 ∈ A1, a2 ∈ A2, . . . , an ∈ An}.
Let A and B be sets. The Cartesian product of A and B, denoted A x B (read “A cross B”), is
the set of all ordered pairs (a, b), where a is in A and b is in B.
A x B = {(a, b)| a A and b B}
If set A has m elements and set B has n elements, then A x B has m x n elements.
DISCRETE STRUCTURES 1 37
Sets
Example:
Let
A = {1, 2}
B = {a, b, c}
Then
B x A = {(a,1), (a,2), (b, 1), (b, 2), (c, 1), (c, 2)}
Ax=xA=
| A x B| = |A| x |B|
Exercise
Let
A = {x, y}
B = {1, 2, 3}
C = {a, b}
1. A x B
2. A x B x C
3. A x C
4. B x A
DISCRETE STRUCTURES 1 38
Sets
Set Identities
An identity is an equation that is universally true for all elements in some set.
Example:
The equation a + b = b + a is an identity for real numbers because it is true for all real numbers a
and b.
Example:
A − (B ∩ C) = (A − B) U (A − C)
Solution:
Exercise
(A − B) U C = (A U C) − (B − C)
DISCRETE STRUCTURES 1 39
Sets
References:
1. Kenneth H. Rosen. Discrete Mathematics and Its Applications, 7th Edition. McGrawHill, 2012
2. Gary Weiss Damian Lyons, et al., Fundamentals of Discrete Structures, 2nd edition, Pearson
Learning Solutions, 2012.
3. Susanna S. Epp, Discrete Mathematics with Applications, Brooks Cole; 4th edition, 2011.
4. James L. Hein, Discrete Structures, Logic, and Computability, 3rd edition, Jones & Bartlett
Publishers, 3rd edition, 2009.
5. Kolman, B., Busby, R. C., Ross, S. C. Discrete Mathematical Structures, 6th Edition. Prentice Hall,
2008.
DISCRETE STRUCTURES 1 40