Download as pdf or txt
Download as pdf or txt
You are on page 1of 45

DiscreteStructures

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

• 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:
Z is the set of integers.
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.
Sets (example)
• Example:
• Set D: all students taking Discrete Mathematics
course.
• Assume Ali is taking Discrete Mathematics course
and Saad is not taking Discrete Mathematics
course.

• 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}

• Set of real numbers


• 𝐑
Examples

• 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

• Let A and B be two sets.


• A and B are equal if and only if they have the same
elements, denoted by A = B.

• A and B are equal if and only if ∀x (x ∈ A ↔ x ∈ B).


Equality of Sets (examples)
• Example:

• {1,2,3} and {3,2,1}


{1,2,3} = {3,2,1}

• {1,2,3} and {1,1,2,2,2,3,3,3,3}


{1,2,3} = {1,1,2,2,2,3,3,3,3}

• 𝐙+ and {0,1,2,…}
𝐙+ ≠ {0,1,2,…}
Venn Diagrams
• Sets can be represented graphically using Venn diagram.

• Universal set U contains all objects under consideration.


• Other geometric figures are used to represent sets.
• Points are used to represent particular elements of sets.
Venn Diagrams (example)
• Show set A = { a, b, c } using Venn diagram.
• Universal Set = ?

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={}=Ø

• A set that has no elements called empty set, or null set.

• Ø and {Ø}
Ø ≠ {Ø}
Subset
• 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 A ⊆ B.

• A ⊆ B if and only if ∀x (x ∈ A → x ∈ B).

• ∀ 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).

• Ø contains no element, so x ∈ Ø is false.


• Hypothesis of conditional statement is false, so
x ∈ Ø → x ∈ S is true.
• Thus, ∀x (x ∈ Ø → x ∈ S) is true.
Subset
• Show ∀ set S, S ⊆ S.
• Proof:
We want to show ∀x (x ∈ S → x ∈ S).
• 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.
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).


Size of Sets
• Let S be a set.

• If there are exactly n distinct elements in S where n is


a nonnegative integer, then S is a finite set.

• n is the cardinality of S, denoted by |S|.

• If S is not finite, it is infinite.


Example
• Find cardinality of following sets.

• A = {x | x ∈ 𝐙+ , x is odd and x<10}


A = {1,3,5,7,9}
|A| = 5

• B=Ø
|B| = 0

• C = {Ø}
|C| = 1

• R
R is infinite.
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).

• 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

• The ordered n-tuple (𝑎1, 𝑎 2 , … , 𝑎 𝑛) is the ordered


collection that has 𝑎1 as its first element, 𝑎2 as its second
element, … , and 𝑎 𝑛 as its nth element.

• Example:

(a,b) is an ordered 2-tuple (ordered pair).


Ordered n-tuple
• Let 𝐴 = (𝑎1 , 𝑎2 , … , 𝑎𝑛 ) and 𝐵 = (𝑏1 , 𝑏2 , … , 𝑏𝑛 ) be ordered
n-tuples.

• A and B are equal if and only if each corresponding pair


of their elements are equal, denoted by 𝐴 = 𝐵.

• 𝐴 = 𝐵 if and only if 𝑎𝑖 = 𝑏𝑖 and ∀𝑖 ∈ {1,2, … , 𝑛}


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.
Cartesian Product
Let A and B be sets.

• The Cartesian product of A and B, denoted by A x B, is


the set of all ordered pairs (a,b), where a ∈ A and b ∈ B.

• 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.

• The Cartesian product of A1, A2, … , An , denoted by


A1 x A2 x … x An, is the set of all ordered n-tuples
(a1, a2, … , an), where ai ∈ Ai for i = 1,2,…,n.

• A1 x A2 x … x An = {(a1, a2, … , an) | ai ∈ Ai , ∀i ∈ {1,2,…,n}}


Cartesian Product
A = {a, b}
B = {1}
C = {x, y, z}
Ax B xC =?

Solution:

A x B x C = {(a,1,x), (a,1,y), (a,1,z), (b,1,x), (b,1,y),


(b,1,z)}
The Cardinalityof Cartesianproduct
Assume A, B and C are finite.
|AxBxC| = ?
Solution:
• A = {a} B={0} C={x} AxBxC = {(a,0,x)}
|AxBxC| = 1
• A = {a,b} B={0} C={x} AxBxC = {(a,0,x),(b,0,x)}
|AxB| = 2
• A = {a,b} B={0,1} C={x}
AxB={(a,0,x),(a,1,x),(b,0,x),(b,1,x)} |AxBxC| = 4

• |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

• 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}.


Example

• 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 N.


Example

• Let Q(x) be x2 = 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.
Exercise Questions

Chapter # 2
Topic # 2.1
Question # 1,3,4,5,6,7,10,17,18,21,28,35

You might also like