Professional Documents
Culture Documents
Lecture 14 Sets
Lecture 14 Sets
Lecture - 14
Sets
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
• Example:
Z is the set of integers.
Set Membership
• Ali ∈ D
• Saad ∉ D
Sets (example)
• Example:
V: {a,e,i,o,u}
a∈V
b∉V
I: {0,1,2,…,99}
50 ∈ I
100 ∉ I
S: {a,2,class}
2∈S
room ∉ S
Set Builder
• Set builder:
Characterize all elements in the set by stating properties they
must have.
• Example:
O= {x | x is an odd positive integer less than 10}
O= {x ∈ 𝒁+ | x is odd and x<10}
O= {1,3,5,7,9}
Important Sets
• Set of natural numbers
• 𝐍 = {1,2,3,…}
• Set of integers
• 𝐙 = {…,-2,-1,0,1,2,…}
• Set of positive integers
• 𝐙+ = {1,2,3,…}
• Set of rational numbers
• 𝐐 = {p/q | p ∈ 𝐙, q ∈ 𝐙, and q ≠ 0}
• S1 = { N, Z, Q, R }
• S1 has 4 elements, each of which is a set.
• S2 = {x | x ∈ N and ∃k k ∈ N, x = k 2 }
• Set of squares of natural numbers
Equality of Sets
• 𝐙+ and {0,1,2,…}
𝐙+ ≠ {0,1,2,…}
Venn Diagrams
• Sets can be represented graphically using Venn diagram.
Venn diagram
Venn Diagrams
• Draw a Venn diagram that represents V, the set of vowels
in the English alphabet.
Empty Set (example)
• Example:
• S = {x | x ∈ 𝑍+ and x < 0 }
S={}=Ø
• Ø and {Ø}
Ø ≠ {Ø}
Subset
• Let A and B be sets.
• ∀ set S,
Ø⊆S
S⊆S
Subset and Equality
• A ⊆ B, ∀ x (x ∈ A → x ∈ B)
and
• B ⊆ A, ∀ x (x ∈ B → x ∈ A)
then
• A = B, ∀ x (x ∈ A ↔ x ∈ B)
Subset (example)
• Q and R
Q⊆R
• N and Z
N⊆Z
• A = {x | x ∈ 𝐙+ and x<10}
B = {x | x ∈ 𝐙+ , x is even and x<10}
B⊆A
Subset
• Show ∀ set S, Ø ⊆ S.
• Proof:
We want to show ∀x (x ∈ Ø → x ∈ S).
• B=Ø
|B| = 0
• C = {Ø}
|C| = 1
• R
R is infinite.
The Power Set
• Let S be a set.
• Example:
P({ a ,b }) = {Ø ,{a} ,{b} ,{ a ,b }}
The Power Set (example)
• What is P({1,2,3})?
• Solution:
P({1,2,3}) = { Ø, {1}, {2}, {3}, {1,2}, {2,3}, {1,3}, {1,2,3} }
• P(Ø) = ?
P(Ø) = {Ø}
• 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)| = 2|A|
Ordered n-tuple
• Example:
Solution:
• a = a but b ≠ c and c ≠ b.
• So, (a,b,c) and (a,c,b) are not equal.
Cartesian Product
Let A and B be sets.
• AxB = {(a,b) | a ∈ A ˄ b ∈ B}
Cartesian Product (example)
A = {0,1,2}
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)}
B x A = {(a,0),(a,1),(a,2),(b,0),(b,1),(b,2)}
So, A x B ≠ B x A.
The Cardinalityof Cartesian Product
Assume A and B are finite.
|AxB| = ?
Solution:
• A = {a} B={0}
AxB = {(a,0)} |AxB| = 1
• A = {a,b} B={0}
AxB = {(a,0),(b,0)} |AxB| = 2
• A = {a,b} B={0,1} AxB={(a,0),(a,1),(b,0),(b,1)}
|AxB| = 4
• |AxB| = |A|.|B|
Cartesian Product
• Let A1, A2, … , An be sets.
Solution:
• |AxBxC| = |A|.|B|.|C|
Using Set Notation with Quantifiers
• x P(x) domain: S
• x ∈ S (P(x))
• x (x ∈ S → P(x))
Using Set Notation with Quantifiers
• x P(x) domain: S
• x ∈ S (P(x))
• x (x ∈ S ˄ P(x))
Example
• What does the following statement mean?
x ∈ R (x2 ≥ 0)
Solution:
• For every real number x, (x2 ≥ 0).
• The square of every real number is nonnegative.
Example
• What does the following statement mean?
∃x ∈ Z (x2 = 1)
Solution:
• There is an integer x such that x2 = 1.
• There is an integer whose square is 1.
Truth Sets of Predicates
Solution:
Solution:
Solution:
Chapter # 2
Topic # 2.1
Question # 1,3,4,5,6,7,10,17,18,21,28,35