CHAPTER 2
(PART 1)
SETS
LEARNING OUTCOME
Students should be able to:
Able to solve problems related to sets, functions and relations
OUTLINE
Empty Set and Universal Set
Subsets and Set Equality
Cartesian Product
Set Operations
Set Identities
Set Cardinality
SETS
A set is an unordered collection of objects.
the students in this class
the chairs in this room
The objects in a set are called the elements, or members of the set. A set is said to
contain its elements.
The notation a ∈ A denotes that a is an element of the set A.
If a is not a member of A, write a ∉ A
DESCRIBING A SET: ROSTER METHOD
S = {a,b,c,d}
Order not important
S = {a,b,c,d} = {b,c,a,d}
Each distinct object is either a member or not; listing more than once does not
change the set.
S = {a,b,c,d} = {a,b,c,b,c,d}
Elipses (…) may be used to describe a set without listing all of the members
when the pattern is clear.
S = {a,b,c,d, ……,z }
ROSTER METHOD
Set of all vowels in the English alphabet:
V = {a,e,i,o,u}
Set of all odd positive integers less than 10:
O = {1,3,5,7,9}
Set of all positive integers less than 100:
S = {1,2,3,……..,99}
Set of all integers less than 0:
S = {…., -3,-2,-1}
SOME IMPORTANT SETS
N = natural numbers = {0,1,2,3….}
Z = integers = {…,-3,-2,-1,0,1,2,3,…}
Z⁺ = positive integers = {1,2,3,…..}
R = set of real numbers
R+ = set of positive real numbers
C = set of complex numbers.
Q = set of rational numbers
SET-BUILDER NOTATION
Specify the property or properties that all members must satisfy:
S = {x | x is a positive integer less than 100}
O = {x | x is an odd positive integer less than 10}
O = {x ∈ Z⁺ | x is odd and x < 10}
A predicate may be used:
S = {x | P(x)}
Example: S = {x | Prime(x)}
Positive rational numbers:
Q+ = {x ∈ R | x = p/q, for some positive integers p,q}
[a,b] = {x | a ≤ x ≤ b}
[a,b) = {x | a ≤ x < b}
INTERVAL (a,b] = {x | a < x ≤ b}
NOTATION
(a,b) = {x | a < x < b}
closed interval [a,b]
open interval (a,b)
UNIVERSAL SET AND EMPTY SET
John Venn (1834-1923)
Cambridge, UK
The universal set U is the set containing everything currently under
consideration.
Sometimes implicit
Sometimes explicitly stated. Venn Diagram
Contents depend on the context.
U
The empty set is the set with no
elements. Symbolized ∅, but V aei
ou
{} also used.
Sets can be elements of sets.
{{1,2,3},a, {b,c}}
{N,Z,Q,R}
SOME
THINGS TO
The empty set is different from a set
REMEMBER containing the empty set.
∅ ≠{∅}
SET EQUALITY
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
We write A = B if A and B are equal sets.
{1,3,5} = {3, 5, 1}
{1,5,5,5,3,3,1} = {1,3,5}
SUBSETS
Definition: The set A is a subset of B, if and only if every element of A is
also an element of B.
The notation A ⊆ B is used to indicate that A is a subset of the set
B.
A ⊆ B holds if and only if is true.
PROVING METHOD
To Show that A is a Subset of B:
To show that A ⊆ B, show that if x belongs to A, then x also belongs to B.
To Show that A is not a Subset of B:
To show that A ⊈ B, find an element x ∈ A with x ∉ B. (Such an x is a counterexample
to the claim that x ∈ A implies x ∈ B.)
Examples:
1. The set of all computer science majors at your school is a subset of all students
at your school.
2. The set of integers with squares less than 100 is not a subset of the set of
nonnegative integers.
EQUALITY OF SETS
Recall that two sets A and B are equal, denoted by A = B, iff
Using logical equivalences we have that A = B iff
This is equivalent to
A⊆B and B⊆A
PROPER SUBSETS
Definition: If A ⊆ B, but A ≠B, then we say A is a proper subset of B,
denoted by A ⊂ B. If A ⊂ B, then
is true.
U
B
Venn Diagram A
SET CARDINALITY
Definition: If there are exactly n distinct elements in S where n is a nonnegative
integer, we say that S is finite. Otherwise it is infinite.
Definition: The cardinality of a finite set A, denoted by |A|, is the number of
(distinct) elements of A.
Examples:
1. |ø| = 0
2. Let S be the letters of the English alphabet. Then |S| = 26
3. |{1,2,3}| = 3
4. |{ø}| = 1
5. The set of integers is infinite.
POWER SETS
Definition: The set of all subsets of a set A, denoted P(A), is called the power set
of A.
Example: If A = {a,b} then
P(A) = {ø, {a},{b},{a,b}}
If a set has n elements, then the cardinality of the power set is 2ⁿ.
TUPLES
The ordered n-tuple (a1,a2,…..,an) is the ordered collection that has a1 as its first
element and a2 as its second element and so on until an as its last element.
Two n-tuples are equal if and only if their corresponding elements are equal.
2-tuples are called ordered pairs.
The ordered pairs (a,b) and (c,d) are equal if and only if a = c and b = d.
René Descartes
(1596-1650)
CARTESIAN PRODUCT
Definition: The Cartesian Product of two sets A and B, denoted by
A × B is the set of ordered pairs (a,b) where a ∈ A and b ∈ B .
Example:
A = {a,b} B = {1,2,3}
A × B = {(a,1),(a,2),(a,3), (b,1),(b,2),(b,3)}
Definition: A subset R of the Cartesian product
A × B is called a relation from the set A to the set B.
CARTESIAN PRODUCT
Definition: The cartesian products of the sets A1,A2,……,An, denoted by A1 × A2 × …… ×
An , is the set of ordered n-tuples (a1,a2,……,an) where ai belongs to Ai for i = 1, …
n.
Example: What is A × B × C where A = {0,1}, B = {1,2} and C = {0,1,2}
Solution: 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),
CARTESIAN PRODUCT
Suppose that A = {1, 2}, then a relation A x A i.e. from a set A to itself is called a
relation on A.
Find A3
CARTESIAN PRODUCT
What are the ordered pairs in the less than or equal to relation, which contains (a,
b) if a ≤ b, on the set {0, 1, 2, 3}?
𝐴={( 0 , 0 ) , ( 0 ,1 ) , ( 0 , 2 ) , ( 0 , 3 ) , ( 1 ,1 ) , ( 1 , 2 ) , ( 1 , 3 ) , ( 2 ,2 ) , ( 2 , 3 ) , ( 3 , 3 ) }
SET OPERATIONS
SECTION SUMMARY
Set Operations
Union
Intersection
Complementation
Difference
Set Identities
Proving Identities
Membership Tables
UNION
Definition: Let A and B be sets. The union of the sets A and B, denoted by A ∪ B,
is the set:
Example: What is {1,2,3} ∪ {3, 4, 5}?
Venn Diagram for A ∪ B
Solution: {1,2,3,4,5}
U
A B
INTERSECTION
Definition: The intersection of sets A and B, denoted by A ∩ B, is
Note if the intersection is empty, then A and B are said to be disjoint.
Example: What is? {1,2,3} ∩ {3,4,5} ?
Solution: {3}
Example:What is? Venn Diagram for A ∩B
{1,2,3} ∩ {4,5,6} ?
U
Solution: ∅
A B
COMPLEMENT
Definition: If A is a set, then the complement of the A (with respect to U), denoted
by Ā is the set U - A
Ā = {x ∈ U | x ∉ A}
(The complement of A is sometimes denoted by Ac .)
Example: If U is the positive integers less than 100, what is the complement of {x |
x > 70}
Venn Diagram for Complement
Solution: {x | x ≤ 70} U
Ā
A
DIFFERENCE
Definition: Let A and B be sets. The difference of A and B, denoted by A – B, is
the set containing the elements of A that are not in B. The difference of A and B is
also called the complement of B with respect to A.
A – B = {x | x ∈ A x ∉ B} = A ∩B
U
A Venn Diagram for A − B
B
THE CARDINALITY OF THE UNION OF
TWO SETS
U
• Inclusion-Exclusion
A B
|A ∪ B| = |A| + | B| - |A ∩ B|
• Also known as disjoint
Venn Diagram for A, B, A ∩ B, A ∪ B
• Example: Let A be the math majors in your class and B be the CS majors. To count the
number of students who are either math majors or CS majors, add the number of math
majors and the number of CS majors, and subtract the number of joint CS/math majors.
REVIEW QUESTIONS
Example: U = {0,1,2,3,4,5,6,7,8,9,10} A = {1,2,3,4,5}, B ={4,5,6,7,8}
1. A ∪ B
Solution: {1,2,3,4,5,6,7,8}
2. A ∩ B
Solution: {4,5}
3. Ā
Solution: {0,6,7,8,9,10}
4.
Solution: {0,1,2,3,9,10}
5. A – B
Solution: {1,2,3}
SYMMETRIC DIFFERENCE (OPTIONAL)
Definition: The symmetric difference of A and B, denoted by is the set
Example:
U = {0,1,2,3,4,5,6,7,8,9,10}
A = {1,2,3,4,5} B ={4,5,6,7,8}
U
What is ?
A B
Solution: {1,2,3,6,7,8}
Venn Diagram
SET IDENTITIES
Identity laws
Domination laws
Idempotent laws
Complementation law
Commutative laws
Associative laws
Distributive laws
SET IDENTITIES
De Morgan’s laws
Absorption laws
Complement laws
PROVING SET IDENTITIES
Different ways to prove set identities:
1. Prove that each set (side of the identity) is a subset of the other.
2. Use set builder notation and propositional logic.
3. Membership Tables:
*Verify that elements in the same combination of sets always either belong or do not
belong to the same side of the identity.
*Use 1 to indicate it is in the set and a 0 to indicate that it is not.
PROOF OF SECOND DE MORGAN LAW
Example: Prove that
Solution: We prove this identity by showing that:
1) and
2)
Continued on next slide
PROOF OF SECOND DE MORGAN LAW
These steps show that:
Continued on next slide
PROOF OF SECOND DE MORGAN LAW
These steps show that:
SET-BUILDER NOTATION: SECOND DE
MORGAN LAW
MEMBERSHIP TABLE
Example: Construct a membership table to show that the distributive law holds.
Solution:
A B C
1 1 1 1 1 1 1 1
1 1 0 0 1 1 1 1
1 0 1 0 1 1 1 1
1 0 0 0 1 1 1 1
0 1 1 1 1 1 1 1
0 1 0 0 0 1 0 0
0 0 1 0 0 0 1 0
0 0 0 0 0 0 0 0
MEMBERSHIP TABLE EXAMPLE
Prove (AB)B = AB.
A B AB (AB)B AB
0 0 0 0 0
0 1 1 0 0
1 0 1 1 1
1 1 1 0 0
MEMBERSHIP TABLE EXERCISE
Prove (AB)C = (AC)(BC).
A B C A B ( A B ) C A C BC (AC)(BC)
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
GENERALIZED UNIONS AND
INTERSECTIONS
Let A1, A2 ,…, An be an indexed collection of sets.
We define:
These are well defined, since union and intersection are associative.
For i = 1,2,…, let Ai = {i, i + 1, i + 2, ….}. Then,
For any sets A, B, C Í U, by using the following diagram,
show that:
(A È B) Ç C = (A Ç B) È C.
Each region in the set is labelled as 1, 2, 3, 4, 5, 6, 7, and 8.
1A
2 5
3 B
7 6
Region 3 is A Ç B Ç C 8
4
Region 7 is A Ç B Ç C
C
A È B comprises regions 2, 3, 5, 6, 7, 8 and C comprises of regions 4, 6, 7, 8.
Therefore, (A È B) Ç C comprises regions 6, 7, 8.
Consequently, (A È B) Ç C is made up of regions 1, 2, 3, 4, 5.
A = 1, 3, 4, 6, B = 1, 2, 4, 7, C = 1, 2, 3, 5 and A Ç B = 1, 4
Therefore, (A Ç B) È C = 1, 2, 3, 4, 5 is equal to (A È B) Ç C .
\ (A Ç B) È C = (A È B) Ç C.
Example:
Simplify the expression (A ÈB ) Ç C È B.
(A È B) Ç C È B Reasons
= ((A È B) Ç C) Ç B DeMorgan’s Law
= ((A È B) Ç C) Ç B Law of Double Complement
= (A È B) Ç (C Ç B) Associative Law of Intersection
= (A È B) Ç (B Ç C) Communicative Law of Intersection
= [(A È B) Ç B] Ç C Associative Law of Intersection
=BÇC Absorption Law
Example:
Express A – B in terms of È and .
By definition: A – B = {x½x Î A Ù x ÏB} = A Ç B.
Therefore ,
A-B=AÇB Reasons
=AÈB DeMorgan’s Law
=AÈB Law of Double Complement
CLASS ACTIVITY
1. Show that (AÇB) È (AÇB) = A.
2. Show that A È (B-A) = AÈB.
ACTIVITY 1: SOLUTION
ACTIVITY 2: SOLUTION
ACTIVITY 3
Shade the region of (AÈB) Ç (C - A)
ACTIVITY 4
Among a group of 165 students, 8 are taking calculus,
psychology, and computer science; 33 are taking calculus and
computer science; 20 are taking calculus and psychology; 24
are taking psychology and computer science; 79 are taking
calculus; 83 are taking psychology; and 63 are taking
computer science. How many are taking none of the three
subjects?
Activity 4: Solution
ACTIVITY 5
In a class of 50 college freshman, 30 are studying
C++, 25 are studying java, and 10 are studying both
languages. How many freshmen are studying either
computer language?
ACTIVITY 5: SOLUTION
INCLUSION-EXCLUSION PRINCIPLE
How many elements are in AB?
|AB| = |A| |B| |AB|
Example: How many students are on our class email list?
Consider set E I M,
I = {s | s turned in an information sheet}
M = {s | s sent the TAs their email address}
Some students did both!
|E| = |IM| = |I| |M| |IM|
COMPUTER REPRESENTATION OF SETS
Various ways to represent sets using a computer.
One method is to store the elements of the set in an unordered
fashion. However, if this is done, the operations of computing the
union, intersection, or difference of two sets would be time-
consuming, because each of these operations would require a large
amount of searching for elements.
Alternative method for storing elements using an arbitrary ordering of
the elements of the universal set. This method of representing sets
makes computing combinations of sets easy.
COMPUTER REPRESENTATION OF SETS
Let U = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, and the ordering of elements of U has the
elements in increasing order; that is, ai = i.
What bit strings represent the subset of all odd integers in U?
Ans: {1, 3, 5, 7, 9} represent by 10 1010 1010
What bit strings represent the subset of all even integers in U?
Ans: {2, 4, 6, 8, 10} represent by 01 0101 0101
What bit strings represent the subset of integers not exceeding 5 in U?
Ans: {1, 2, 3, 4, 5} represent by 11 1110 0000
Note: Using bit strings to represent sets, it is easy to find complements of sets and
unions, intersections, and differences of sets .
COMPLEMENT OF A BIT
To find the bit string for the complement of a set from the bit string
for that set, simply change each 1 to a 0 and each 0 to 1, because x ∈
A if and only if x A.
Example:
The bit string for the set {1, 3, 5, 7, 9} (with universal set {1, 2, 3, 4, 5,
6, 7, 8, 9, 10}) is 10 1010 1010.
What is the bit string for the complement of this set?
Solution: The bit string for the complement of this set is obtained by
replacing 0s with 1s and vice versa.
Ans: 01 0101 0101 which corresponds to the set {2, 4, 6, 8, 10}.
UNION AND INTERSECTION OF TWO SET
To obtain the bit string for the union and intersection of two sets, perform bitwise
Boolean operations on the bit strings representing the two sets.
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.
Solution:
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}.
The bit string for the intersection of these sets is
11 1110 0000 ∧ 10 1010 1010 = 10 1010 0000, which corresponds to the set {1, 3, 5}.