0% found this document useful (0 votes)
6 views

Discrete Structures Lecture 8

Uploaded by

rg709pk
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Discrete Structures Lecture 8

Uploaded by

rg709pk
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 37

Discrete Structures

(Discrete Mathematics)

Lecture -
8
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
Se
t•
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.
• 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
Set
Membership

∈ A.
•a is an element of the set A, denoted by a

by a ∉
•a is not an element of the set A, denoted

A.
Sets
(example)
• Example:
•Set D: 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
V b

I:
{0,1,
2,
…,99
}
50 ∈
I
Specifying a
Set
• Capital letters (A, B, S … ) for sets
• Italic lower-case letter for elements (a, x, y … )
• Easiest way: list all the elements
• A = {1, 2, 3, 4, 5}, Not always feasible!

• May use ellipsis ( … ) : 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 an odd positive integer less than 10}
O= {x ∈ 𝒁+ | x is odd and x<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,…}
• Set of rational numbers
𝐐 = {p/q | p ∈ 𝐙, q ∈ 𝐙, and
q ≠ 0}

• Set of real numbers


• 𝐑
Exampl
es
• S1 = { N, Z, Q, R }
• S1 has 4 elements, each of which is
a set.

= {x | x ∈ N and ∃k
∈ N, x = k 2 }
• S2 k

• 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)
• {1,2,3} and
{3,2,1}
{1,2,3} =
{3,2,1}
• 𝐙+ and
{0,1,2,…}
𝐙+ ≠ {0,1,2,
…}
The Universal
Set
• U is the universal set – the set of all of
elements (or the “universe”) from which given
any set is drawn
• 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
(example)
• Example:

• S = {x | x ∈ 𝑍+ and x
<0} S={}=Ø

• A set that has no


elements called empty
set, or null set.

• Ø and

≠ {Ø}
{Ø} Ø
Sets Of
Sets
• Sets can contain other sets
• S = { {1}, {2}, {3} }
• T = { {1}, {{2}}, {{{3}}} }
• V = { { {1}, {{2}} }, { {{3}} }, { {1},
{{2}}, {{{3}}} }
}
V has only 3 elements!
• Note that 1 ≠ {1} ≠ {{1}} ≠ {{{1}}}
• They are all different
Subs
et
• Let A and B be sets.

is also an element of B, denoted by A ⊆ B.


• A is a subset of B if and only if every element of A

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

• A = B, ∀ x (x ∈ A ↔ x
then

∈ B)
Subset
(example)

R Q⊆
• Q and

Z N⊆
• N and

|x∈
• A = {x

𝐙+
Subs
• Show ∀ set S, Ø ⊆ S.
et

We want to show ∀x (x ∈ Ø  x ∈ S).


• Proof:

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


• Hypothesis of conditional statement is

x ∈ Ø  x ∈ S is true.
false, so

• Thus, ∀x (x ∈ Ø  x ∈ S) is true.
Subs
• Show ∀ set S, S ⊆ S.
et
• 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).
Exampl
e
• 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 like the difference between “less
than or equal to” and “less than” for numbers
• Is ∅ ⊆

• Is ∅ ∈
{1,2,3}?

• Is ∅ ⊆
{1,2,3}?

• Is ∅ ∈
{∅,1,2,3}?

{∅,1,2,3}?

• Is x ∈ {x}
• Is {x} ⊆ {x}
• Is ∅ ⊆ {1,2,3}?

• Is ∅ ∈ {1,2,3}?
Yes!

• Is ∅ ⊆ {∅,1,2,3}?
No!

• Is ∅ ∈ {∅,1,2,3}?
Yes!

Yes!

• Is x ∈ {x}
• Is {x} ⊆ {x}
Size of
Sets
• Let S be a set.

• The cardinality of a set is the number of elements


in a set S
• cardinality of S, denoted by |S|.
Exampl
e
• 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({Ø})
=?
The Cardinality of the
Power Set
• Assume A is
finite.
• |P(A)| = ?

Solution:
• A = {a} P(A) = {Ø, {a}} |P(A)| =
•A= P(A) = {Ø, {a}, {b}, 2
{a,b} {a,b}} |P(A)| =
•A= 4
P(A)={Ø,{a},{b},{c},{a,b},{a,c},{b,c},
{a,b,c}
{a,b,c}} |P(A)|
=8

• |A|
Cartesian
Product
Let A and B be sets.

B, is the set of all ordered pairs (a,b), where a ∈


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

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),

So, A x B ≠ B x A.
(b,1),(b,2)}
The Cardinality of Cartesian
Product
Assume A and B are
finite.
|AxB| = ?
•Solution:
A = {a} B={
AxB = 0} |AxB| =
{(a,0)} B={ 1
• A = {a,b} 0}
AxB = {(a,0), |AxB| = 2
(b,0)} AxB={(a,0),(a,1),(b,0),
• A = {a,b} (b,1)}
B={0,1}
• |AxB|
|AxB| ==|A|.|B|
4
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

(a1, a2, … , an), where ai ∈ Ai for i = 1,2,…,n.


ordered n-tuples

• 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} A x B x
C=?

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 Cardinality of Cartesian
product
Assume A, B and C are
finite.
|AxBxC| =
•? A = {a} B={0} AxBxC =
Solution:
C={x} {(a,0,x)}
|AxBxC| = 1 AxBxC = {(a,0,x),
• A = {a,b} (b,0,x)}
B={0} C={x}
|AxB| = 2
AxB={(a,0,x),(a,1,x),(b,0,x), |AxBxC| =
• A = {a,b}
(b,1,x)} 4
B={0,1} C={x}
• |AxBxC| = |A|.|B|.|C|
Exercise
Questions

Chapter # 2
Topic # 2.1
Question #
1,3,5,6,7,9,12,19,20,23,32,43,44

You might also like