4 Sets
4 Sets
Introduction
• In this section, we study the fundamental discrete structure on which all other
discrete structures are built, namely, the set.
• Although sets are usually used to group together elements with common
properties, there is nothing that prevents a set from having seemingly
unrelated elements.
• For instance, {a, 2, Fred, New Jersey} is the set containing the four elements a, 2,
Fred, and New Jersey.
Methods to represent Sets
set builder notation
• characterize all those elements in the set by stating the property or
properties they must have to be members.
• 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},
Examples for Sets
Standard” Sets:
• Natural numbers N = {0, 1, 2, 3, …}
• Integers Z = {…, -2, -1, 0, 1, 2, …}
• Positive Integers Z+ = {1, 2, 3, 4, …}
• Real Numbers R = {47.3, -12, , …}
• Rational Numbers Q = {1.5, 2.6, -3.8, 15, …}
Set Equality
•Sets A and B are equal if and only if they contain exactly the
same elements.
Examples:
•A = {9, 2, 7, -3}, B = {7, 9, -3, 2} : A=B
8
Cartesian Product
Example:
•A = {good, bad}, B = {student, prof}
•AB = {
(good, student), (good, prof), (bad, student), (bad, prof)}
Example:
A B = {(x, a), (x, b), (x, c), (y, a), (y, b), (y, c)} 9
Example
What is the Cartesian product of A = {1, 2} and B = {a, b, c}?
Solution: The Cartesian product A × B is
A × B = {(1, a), (1, b), (1, c), (2, a), (2, b), (2, c)}.
B × A = {(a, 1), (a, 2), (b, 1), (b, 2), (c, 1), (c, 2)}. This is not equal to A × B
Example
• What is the Cartesian product A × B × C, where A = {0, 1}, B = {1, 2},
and C = {0, 1, 2} ?
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)}.
Empty Set and Singleton 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 single element of the set {∅} is the empty set itself
Cardinality of Sets
Examples:
• A = {x, y, z}
P(A) = {, {x}, {y}, {z}, {x, y}, {x, z}, {y, z}, {x, y, z}}
Example
• What is the power set of the set {0, 1, 2}?
Sol:
P({0, 1, 2}) = {∅, {0}, {1}, {2}, {0, 1}, {0, 2}, {1, 2}, {0, 1, 2}}.
B
A C
16
Example
List the members of these sets.
a) {x | x is a real number such that X2 = 1}
b) {x | x is a positive integer less than 12}
c) {x | x is the square of an integer and x < 100}
d) {x | x is an integer such that X2 = 2}
Sol:
a) {1,-1}
b) {1,2,3,4,5,6,7,8,9,10,11}
c) { 1, 4, 9, 16, 25, 36, 49, 64, 81}
d) ∅( √2 is not an integer)
Example
Use set builder notation to give a description of each of these sets.
a) {0, 3, 6, 9, 12}
b) {−3,−2,−1, 0, 1, 2, 3}
c) {m, n, o, p}
Sol:
Example
For each of these pairs of sets, determine whether the first is a subset of the
second, the second is a subset of the first, or neither is a subset of the other.
a) the set of airline flights from NewYork to New Delhi, the set of nonstop
airline flights from New York to New Delhi
b) the set of people who speak English, the set of people who speak Chinese
c) the set of flying squirrels, the set of living creatures that can fly.
Example
For each of these pairs of sets, determine whether the first is a subset of the
second, the second is a subset of the first, or neither is a subset of the other.
a) the set of people who speak English, the set of people who speak English
with an Australian accent
b) the set of fruits, the set of citrus fruits
c) the set of students studying discrete mathematics, the set of students
studying data structures
Sol:
Example
Determine whether each of these pairs of sets are equal.
a) {1, 3, 3, 3, 5, 5, 5, 5, 5}, {5, 3, 1}
b) {{1}}, {1, {1}}
c) ∅, {∅}
Sol:
a) Yes; order and repetition do not matter.
b) No; the first set has one element, and the second has two elements.
c) No; the first set has no elements, and the second has one element
(namely the empty set).
Example
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 which other of these
sets.
Sol:
B is subset of A
C is subset of both A and D
Example
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}
b) {x ∈ R | x is the square of an integer}
c) {2,{2}}
d) {{2},{{2}}}
e) {{2},{2,{2}}}
f ) {{{2}}}
Example (class Test)
Suppose that A × B = ∅, where A and B are sets. What can you conclude?
Find A2 if:
a) A = {0, 1, 3}.
b) A = {1, 2, a, b}.
Find A3 if:
a) A = {a}.
b) A = {0, a}.
What is the cardinality of each of these sets?
a) {a}
b) {{a}}
c) {a, {a}}
d) {a, {a}, {a, {a}}}
Example (class Test)
Determine whether each of these sets is the power set of a set,
where a and b are distinct elements.
a) ∅
b) {∅, {a}}
c) {∅, {a}, {∅, a}}
d) {∅, {a}, {b}, {a, b}}
Set Operations
• Union
• Intersection
• Disjoint
• Compliment
• Difference
• Venn diagram representations
• Set identities
Set Operations
Union: AB = {x | xA xB}
Example :
Let A = {1, 3, 5, 7, 9} and B = {2, 4, 6, 8, 10}
A∩B=∅
Set Operations
Let U be the universal set. The complement of the set A, denoted by A, is the
complement of A with respect to U. Therefore, the complement of the set A is U - A.
Find:
a) A – B
b) B – A
c) A – C
d) C –A
e) A –A
f) U –A
Practice Task
• Let A be the set of students who live within one mile of school and let
B be the set of students who walk to classes. Describe the students in
each of these sets.
a) A ∩ B
b) A ∪ B
c) A – B
d) B - A
Set Proof
• Use a membership table to show that A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C).
Set Identities
Set Identities
Proof by Set Identities
Example
• Let A, B, and C be sets. Show that
Solution: We have
Generalized Unions and Intersections
• Because unions and intersections of sets satisfy associative laws, the sets A
∪ B ∪ C and A ∩ B ∩ C are well defined
Note that A ∪ B ∪ C contains those elements that are in at least one of the
sets A, B, and C, and that A ∩ B ∩ C contains those elements that are in all of
A, B, and C.
Venn representation of Generalized Unions and Intersections
Example
• Let A = {0, 2, 4, 6, 8}, B = {0, 1, 2, 3, 4}, and C = {0, 3, 6, 9}. What are A ∪ B ∪ C
and A ∩ B ∩ C?
A ∪ B ∪ C = {0, 1, 2, 3, 4, 6, 8, 9}.
A ∩ B ∩ C = {0}
Computer Representation of Sets
• There are various ways to represent sets using a computer.
The bit string for the complement of this set is obtained by replacing 0s with
1s and vice versa. This yields the string 01 0101 0101, which corresponds to
the set {2, 4, 6, 8, 10}.
Example
• The bit strings for the sets {1, 2, 3, 4, 5} and {1, 3, 5, 7, 9} are 11 1110 0000 and
10 1010 1010, respectively. Use bit strings to find the union and intersection of
these sets.
Sol:
• The bit string for the union of these sets is
11 1110 0000 ∨ 10 1010 1010 = 11 1110 1010 , which corresponds to the set {1, 2, 3,
4, 5, 7, 9}.
Soccer Tennis
a,c,d,h C,d,j
Example Cont… Union
a,c,d,h C,d,j
Example Cont… Difference
• Soccer = {a, c, d, h}
• Tennis = {c, d, j}
Soccer - Tennis = {a, h}
Soccer
Soccer Tennis Tennis
a, h
a,c,d,h C,d,j
Example
• Prove the first absorption law by showing that if A and B are sets,
then A ∪ (A ∩ B) = A.
Hence, A ∪ (A ∩ B) = A.
Example
• Find the sets A and B if A - B = {1, 5, 7, 8}, B - A = {2, 10}, and A ∩ B = {3, 6, 9}.
Sol:
A= { 1, 3, 5, 6, 7, 8, 9}
B= { 2, 3 , 6 , 9 , 10}
Example
• Prove the second De Morgan law by showing that if A and B are sets,
then (by showing each side is a subset of the other
side).
Thank You