CSC102 - Discrete Structures
(Discrete Mathematics)
Lecture # 16-17
Chapter 2.1,2.2,8.5
Set
Lecture Outline
• Sets
– Set Terminologies
– Power Set
– Cartesian Product
– Set notation with Quantifier
– Set Operations
– Set Identities
– Membership Tables
– Inclusion-Exclusion Principle of Sets (8.5 From Rosen 8th
ed.)
06/13/2025 CSC102 - Discrete Structures 3
Application of Sets
• Databases
• Data-type or type in computer programming
• Constructing discrete structures
• Finite state machine
• Modeling computing machine
• Representing computational complexity of
algorithms
Set
• 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.
Example:
– Cities in the Pakistan: {Lahore, Karachi, Islamabad, … }
– Sets can contain non-related elements: {3, a, red, Gilgit }
Properties:
• Order does not matter
– {1, 2, 3, 4, 5} is equivalent to {3, 5, 2, 4, 1}
• Sets do not have duplicate elements
– Consider the list of students in this class
– It does not make sense to list somebody twice
Specifying a Set
• Capital letters (A, B, S…) for sets
• Italic lower-case letter for elements (a, x, y…)
• Two ways of specifying set
– Roster method
– Set builder notation
Roster method
• Easiest way: list all the elements within curly braces, “{“ and “}”
– A = {1, 2, 3, 4, 5}, Not always feasible!
• May use ellipsis (…) to describe a set without listing all of its
elements : B = {0, 1, 2, 3, …}
May cause confusion. C = {3, 5, 7, …}. What’s next?
If the set is all odd integers greater than 2, it is 9
If the set is all prime numbers greater than 2, it is 11
Set Builder
• Set builder:
Characterize all elements in the set by stating properties they must
have.
• Example:
O= {x ∈ | x is odd and x<10}
O= {x | x is an odd positive integer less than 10}
O= {1,3,5,7,9}
The vertical bar means “such that”
Important Sets
• Set of natural numbers
• = {1,2,3,…}
• Set of integers
• = {…,-2,-1,0,1,2,…}
• Set of positive integers
• = {1,2,3,…}
• = {p/q | p ∈ , q ∈ , and q ≠ 0}
• Set of rational numbers
• Set of real numbers
•
Set Membership
• a is an element of the set A, denoted by a A.
• a is not an element of the set A, denoted by a A.
• S1 = { N, Z, Q, R }
– S1 has 4 elements, each of which is a set.
• S2 = {x | x ∈ N and k k ∈ N, x = }
– Set of squares of natural numbers
Sets Membership (example)
•
Equality of Sets
•
The Universal Set
• U is the universal set – the set containing all
objects or elements under consideration, and
of which all other sets are subsets
– For the set {-2, 0.4, 2}, U would be the real numbers
– For the set {0, 1, 2}, U could be the N, Z, Q, R depending on
the context
– For the set of the vowels of the alphabet, U would be all
the letters of the alphabet
Venn Diagrams
• Sets can be represented graphically using Venn diagram.
• The box represents the universal set
• Circles represent the set(s)
• Consider set S, which is the set of all vowels in the
alphabet
• The individual elements are usually not written in a
Venn diagram
Empty Set and Singleton Set
•
Sets Of Sets
• Sets can contain other sets
S = { {1}, {2}, {3} }
T = { {1}, {{2}}, {{{3}}} }
V = { { {1}, {{2}} } , {{{3}}} , { {1}, {{2}}, {{{3}}} } }
• Note that 1 ≠ {1} ≠ {{1}} ≠ {{{1}}}
• They are all different
Subset- Notation
• Let A and B be sets, A is a subset of B if and only if
every element of A is also an element of B, denoted by
AB.
• A B if and only if x (x A x B).
• Every non-empty set S is guaranteed to have at least
two subsets, the empty set and the set itself; i.e.
set S,
• Ø S
• S S
Subset
• Show set S, Ø S.
We want to show x (x ∈ Ø x ∈ S).
Proof:
• Ø contains no element, so x ∈ Ø is false.
• Hypothesis of conditional statement is false,
x ∈ Ø x ∈ S is true.
so
• Thus, x (x ∈ Ø x ∈ S) is true.
Subset
• Show set S, S S.
We want to show x (x ∈ S x ∈ S).
Proof:
• If x ∈ S is true, then hypothesis and conclusion of
conditional statement are both true and (x ∈ S x
∈ S) is true.
• If x ∈ S is false, then hypothesis and conclusion of
conditional statement are both false and (x ∈ S x
∈ S) is true.
• Thus, x (x ∈ S x ∈ S) is true.
Subset and Equality
IF A ⊆ B, x (x A x B)
B ⊆ A, x (x B x A)
and
then
Equality holds for A and B
A = B, x (x A x B)
Subset (example)
Q⊆R
• Q and R
N⊆Z
• N and Z
• A = {x | x and x<10}
B⊆A
B = {x | x x is even and x<10}
Proper Subset
Let A and B be sets.
• A is a proper subset of B if and only if A ⊆ B
but A B, denoted A B.
• A B if and only if x (x ∈ A x ∈ B) x (x ∈ B
x A).
Subset Example
• If S is a subset of T, and S is not equal to T, then S is a
proper subset of T
Let T = {0, 1, 2, 3, 4, 5} and S = {1, 2, 3}
• S is not equal to T, and S is a subset of T
• Let Q = {4, 5, 6}. Q is neither a subset of T nor a proper
subset of T
• The difference between “subset” and “proper subset”
is to , as < is to .
Subset Example
•
Subset Example
•
Subset Example
•
Size of Sets-Cardinality
•
Example-Cardinality
Compute cardinality.
1. |{1, -13, 4, -13, 1}|
2. |{3, {1,2,3,4}, }|
3. |{}|
4. |{ {}, {{}}, {{{}}} }|
Example-cardinality
Hint: After eliminating the redundancies just look at
the number of top level commas and add 1 (except
for the empty set).
1. |{1, -13, 4, -13, 1}| = |{1, -13, 4}| = 3
2. |{3, {1,2,3,4}, }| = 3. To see this, assume S = {1,2,3,4}.
Compute the cardinality of {3,S, }
3. |{}| = || = 0
4. |{ {}, {{}}, {{{}}} }| = |{ , {}, {{}}| = 3
cardinality
The set S is said to be finite if its cardinality is a
nonnegative integer. Otherwise, S is said to
be infinite.
EG: N, Z, Z+, R, Q are each infinite.
Note: We’ll see later that not all infinities are
the same. In fact, R will end up having a
bigger infinity-type than N, but surprisingly,
N has same infinity-type as Z, Z+, and Q.
The Power Set
• Let S be a set, the power set of S is the set of all
subsets of S, denoted by P(S).
Examples:
P({ a ,b }) = {Ø ,{a} ,{b} ,{ a ,b }}
P({1,2,3}) = { Ø, {1}, {2}, {3}, {1,2}, {2,3}, {1,3}, {1,2,3} }
P(Ø) = {Ø}
P({Ø}) = {Ø, {Ø}}
The Cardinality of the Power Set
• Assume A is finite.
• |P(A)| = ?
Solution:
• A = {a} P(A) = {Ø, {a}} |P(A)| = 2
• A = {a,b} P(A) = {Ø, {a}, {b}, {a,b}} |P(A)| = 4
• A = {a,b,c} P(A)={Ø,{a},{b},{c},{a,b},{a,c},{b,c},{a,b,c}} |P(A)| =
8
• |P(A)| = ; If a set has n elements , then its power set will have 2n
elements
Cartesian Product
Let A and B be sets, the Cartesian product of A
pairs (a,b), where a ∈ A and b ∈ B.
and B, denoted by A x B, is the set of all ordered
• A x B = {(a,b) | a ∈ A ˄ b ∈ B}
Cartesian Product- Order Matters
• As opposed to sets, repetition and ordering do
matter with cartesian product.
(11, 11, 11, 12, 13) ( 11, 12, 13 )
Example:
A = {0,1,2} and B = {a,b}
Are A x B and B x A equal?
Solution:
A x B = {(0,a),(0,b),(1,a),(1,b),(2,a),(2,b)}
So, A x B ≠ B x A.
B x A = {(a,0),(a,1),(a,2),(b,0),(b,1),(b,2)}
Cartesian Product
• Let A1, A2, …, An be sets.
• The Cartesian product of A1, A2, …, An , denoted
by
(a1, a2, …, an), where ai ∈ Ai for i = 1,2,…,n.
A1 x A2 x …x An, is the set of all ordered n-tuples
• A1 x A2 x …x An = {(a1, a2, …, an) | ai ∈ Ai , i ∈ {1,2,
…,n}}
Ordered n-tuple
• The ordered n-tuple is the ordered collection
that has as its first element, as its second
element, …, and as its nth element.
• Example:
(a,b) is an ordered 2-tuple (ordered pair).
(a,b,c) is an ordered 3-tuple.
Ordered n-tuple (example)
• Assume c b.
• Are ordered 3-tuples (a,b,c) and (a,c,b) equal?
Solution:
• a = a but b c and c b.
• So, (a,b,c) and (a,c,b) are not equal.
The Cardinality of Cartesian Product
Assume A and B are finite. |AxB| = ?
1. A = {a} B={0}
AxB = {(a,0)} |AxB| = 1
2. A = {a,b} B={0}
AxB = {(a,0),(b,0)} |AxB| = 2
3. A = {a,b} B={0,1}
AxB={(a,0),(a,1),(b,0),(b,1)} |AxB| = 4
• |AxB| = |A|.|B|
The Cardinality of Cartesian product
A = {1,2}, B = {3,4}, C = {5,6,7}
A B C = { (1,3,5), (1,3,6), (1,3,7),
(1,4,5), (1,4,6), (1,4,7),
(2,3,5), (2,3,6), (2,3,7),
(2,4,5), (2,4,6), (2,4,7) }
|AxBxC| = |A|.|B|.|C|
• The cardinality of the Cartesian product is the
product of the cardinalities:
| A1 A2 … An | = |A1||A2| … |An|
Using Set Notation with Quantifiers
• x P(x) where domain: S
x ∈ S (P(x))
x (x ∈ S P(x))
Using Set Notation with Quantifiers
• x P(x) where domain: S
x ∈ S (P(x))
x (x ∈ S ˄ P(x))
Example
x ∈ R ( 0)
• What does the following statement mean?
Solution:
• For every real number x, ( 0).
• The square of every real number is
nonnegative.
Example
• What does the following statement mean?
x Z ( = 1)
Solution:
• There is an integer x such that = 1.
• There is an integer whose square is 1.
Truth Sets of Predicates
• Let P be a predicate and D is a domain.
• The truth set of P is the set of elements x in D
for which P(x) is true.
• The truth set of P(x) is {x D | P(x)}.
Example
Let P(x) be |x| = 1 where the domain is the set of integers.
What is the truth set of P(x)?
Solution:
The truth set of P(x) is {-1,1}.
Let R(x) be |x| = x where the domain is the set of integers.
What is the truth set of R(x)?
Solution:
The truth set of R(x) is .
Let Q(x) be = 2 where the domain is the set of integers.
What is the truth set of Q(x)?
Solution:
The truth set of Q(x) is Ø.
Truth Set of Quantifiers
• x P(x) is true over the domain D if and only if
the truth set of P is the set D.
• x P(x) is true over the domain D if and only if
the truth set of P is nonempty.
Exercises
• List the member of the set
C = {x | x is the square of an integer and x<100}
• Determine Subset
The set of people who speak English, the set of
people who speak English with an Australian accent
The set of students studying discrete mathematics,
the set of students studying data structures
• How many elements does P(P(Ø)) set have.
Exercises
• Translate each of these quantifications into
English and determine its truth value.
∃ x∈R (x3 = -1)
∀ x∈Z (x - 1 ∈ Z)
• Find the truth set of each of these predicates
where the domain is the set of integers.
P(x): x3= 1
R(x):2x + 1 = 0
Set Operations
• Two sets can be combined in many different
ways.
• Set operations can be used to combine sets.
Set Operations-Union
• Let A and B be sets, the union of A and B, denoted by AB,
is the set containing those elements that are either in A
or in B, or in both.
A B = {x | x A ˅ x B}
• Examples
• {1, 2, 3} {3, 4, 5} = {1, 2, 3, 4, 5}
• {a, b} {3, 4} = {a, b, 3, 4}
• {1, 2} = {1, 2}
Set Operations-Union
Properties of the union operation
A=A Identity law
AU=U Domination law
AA=A Idempotent law
AB=B A Commutative law
A (B C) = (A B) C Associative law
The Cardinality of the Union of Sets
Example:
Let
51
Set Operations-Intersection
• Let A and B be sets, the intersection of A and B,
denoted by A B, is the set containing those
elements in both A and B.
A B = {x | x A ˄ x B}
Examples
{1, 2, 3} ∩ {3, 4, 5} = {3}
{a, b} ∩ {3, 4} =
{1, 2} ∩ =
Set Operations-Intersection
Properties of the intersection operation
A∩U=A Identity law
A∩= Domination law
A∩A=A Idempotent law
A∩B=B∩A Commutative law
A ∩ (B ∩ C) = (A ∩ B) ∩ C Associative
Set Operations-Disjoint Sets
• Two sets are called disjoint if their intersection is empty.
• Examples
{even integers} and {odd integers} are disjoint
{a, b} and {3, 4} are disjoint
{1, 2} and are disjoint
Complement
• Let U be the universal set and A be a set, the
complement of A, denoted by , is U - A.
•
Examples:
assuming U = Z
{1, 2, 3}c = { …, -2, -1, 0, 4, 5, 6, … }
{a, b}c = Z
Properties of complement sets
(Ac)c = A Complementation law
A Ac = U Complement law
A ∩ Ac = Complement law
Set Operations-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. (also called complement of B with
respect to A).
• A - B = {x | xA ˄ x B}
= A Bc
Examples:
{1, 2, 3} - {3, 4, 5} = {1, 2}
{a, b} - {3, 4} = {a, b}
{1, 2} - = {1, 2}
The difference of any set S with the empty set will be the set S
Summary Set Operations
Operation Notation
Union AB = {x | x A ˅ x B}
Intersection A B = {x | x A ˄ x B}
Difference A - B = {x | xA ˄ x B}
Complement (U - A)
Set identities
A=A
Identity Law
AU=A
AA=A
Idempotent Law
AA=A
AU=U
Domination law
A=
(Ac)c = A Complementation Law
A (A B) = A
Absorption Law
A (AB) = A
A Ac = U A Ac =
Complement Law
Uc = c= U
Set identities
AB=BA
Commutative Law
AB=BA
A (B C) = (A B) C
Associative Law
A (B C) = (A B) C
(A B)c = Ac Bc
De Morgan’s Law
(A B)c = Ac Bc
A (B C) = (A B) (A C)
Distributive Law
A (B C) = (A B) (A C)
A B C iff A C and B C Subset Laws
C A B iff C A and C B
A – B = A Bc Set Difference
How to Prove a Set Identity
Four methods:
• Use membership tables
• Use the basic set identities
• Prove each set is a subset of the other
• Use set builder notation and logical equivalences
What is a membership table
• Membership tables show all the combinations
of sets an element can belong to
• 1 means the element belongs, 0 means it does not
• Consider the following membership table:
A B A B A B A-B
1 1 1 1 0
1 0 1 0 1
0 1 1 0 0
0 0 0 0 0
Proof using Membership Table
A(B C) = (AB) (AC)
Distributive Law
A B C BC A(B C) AB AC (AB) (AC)
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
Proof using Set Identities (example)
Proof using Set Identities (example)
Solution:
Proof using Set Identities
A ( B A) A B
L.H .S A ( B A)
A ( B A) Difference Law
( A B ) ( A A) Distribution Law
( A B ) Complement Law
A B Identity Law
R.H .S
Proof by showing each set is a subset
of the others
(A B)c = Ac Bc
We need to show that
(A B)c Ac Bc and Ac Bc (A B)c
(i) x (A B)c
x (A B)
(x A B)
(x A x B )
(x A) (x B)
xAxB
x Ac x B c
x Ac B c
(ii) Similarly we show that Ac Bc (A B)c
Proof by set builder notation
(A B)c ={x | x A B} by definition of complement
={x |¬(x ∈ (A B))} by definition of membership
={x |¬(x ∈ A ∧ x ∈ B)} by definition of intersection
={x |¬(x ∈ A) ∨¬(x ∈ B)} by the first De Morgan law
={x | x A ∨ x B} by definition of membership
={x | x ∈ Ac ∨ x ∈ Bc} by definition of complement
={x | x ∈ Ac Bc } by definition of union
= Ac B c by meaning of set builder notation
Inclusion-Exclusion Principle of
Sets
The Cardinality of the Union of Sets
Generalization of union of any arbitrary number
of sets is called Principle of inclusion-exclusion.
Example:
Let
69
Inclusion-Exclusion Principle of Sets
For 2 set
|A B| = |A| + |B| - |A B|
For 3 set
|A B C | = |A| + |B| +|C| - |A B| - |A C| - |B C| + |A B C |
2 - Set Venn Diagram
• Region I represents the elements in set A that are not
in set B.
• Region II represents the elements in both sets A and B.
• Region III represents the elements in set B that are not
in set A.
• Region IV represents the elements in the universal set
that are in neither set A nor set B.
2 – Set Example
Suppose a list A contains the 30 students in a
mathematics class, and a list B contains the 35 students in
an English class, and suppose there are 20 names on both
lists. Find the number of students:
• only on list A
• only on list B
• on list A or B (or both)
• on exactly one list.
2 – Set Example
A contains the 30 students in a mathematics
B contains the 35 students in an English
20 names on both lists.
• only on list A 30 − 20 = 10 names are only on list A.
• only on list B 35 − 20 = 15 are only on list B.
• on list A or B (or both)
• |A ∪ B|= |A| + |B| − |A B| = 30 + 35 − 20 = 45.
• on exactly one list.
• 10 + 15 = 25 names are only on one list; that is,
• |A ⊕ B| = 25.
3 - Set Venn Diagram
• Region I represents the elements in set A but not in set B or set C.
• Region II represents the elements in set A and set B but not in set C.
• Region III represents the elements in set B but not in set A or set C.
• Region IV represents the elements in sets A and C but not in set B.
• Region V represents the elements in sets A, B, and C.
• Region VI represents the elements in sets B and C but not in set A.
• Region VII represents the elements in set C but not in set A or set B.
• Region VIII represents the elements in the universal set U, but not in set A,
B, or C.
3 - Set Example
Consider the following data for 120 mathematics
students at a college concerning the languages French,
German, and Russian:
65 study French, 45 study German,
42 study Russian , 20 study French and German,
25 study French and Russian, 15 study German and
Russian. 8 study all three languages.
Determine how many students study exactly 1 language
course and fill the correct numbers of students in each
eight region of Venn diagram shown in figure.
U 120
F 65
G 45
R 42
F G = 20
F R =25
G R =15
F G R =8
¿ 𝑹 𝟏=𝟔𝟓 −𝟏𝟐 −𝟖 −𝟏𝟕=𝟐𝟖
¿ 𝑹 𝟑=𝟒𝟓 − 𝟏𝟐 −𝟖 −𝟕=𝟏𝟖
¿ 𝑹 𝟕=𝟒𝟐 − 𝟏𝟕 −𝟖 −𝟕=𝟏𝟎
¿ 𝑹 𝟐=𝟐𝟎 −𝟖=𝟏𝟐
𝑹 𝟒= 𝟐𝟓 −𝟖=𝟏𝟕
𝑹 𝟔=𝟏𝟓 −𝟖=𝟕
¿ 𝑹 𝟓=𝟖
¿ |𝑭 ∪ 𝑮 ∪ 𝑹|=65+45+42−20−25−15+8=100
¿ 𝑹 𝟖 −|𝑼|−|𝑭 ∪ 𝑮 ∪ 𝑹|=𝟏𝟐𝟎 − 𝟏𝟎𝟎=𝟐𝟎
Example
• Total number of students exactly registered in
one course = 28+18+10=56
Exercise
• In a class of 50 , there are 30 girls, and there
are 35 students with dark hair. Show that
there are at least 15 girls with dark hair.
Chapter Reading and Exercise Questions
Topic # 2.1
Question # 1-11,2122,23,32 33,34,45-48
Topic # 2.2
Question # 1- 6,15,16, 19- 27