Professional Documents
Culture Documents
Lecture 1 - Sets and Sets Operations - Updated PDF
Lecture 1 - Sets and Sets Operations - Updated PDF
Computer Sciences
Department
Lecture 1: Set and Sets Operations
Lecture Contents
2
Sets Definition.
Some Important Sets.
Notation used to describe membership in sets.
How to describe a set?
Sets.
Venn diagrams.
Subset.
Finite and Infinite Sets.
Cardinality.
Sets Operations.
Exercises.
The sets {1,3,5} and {3,5,1} are equal , because they have
the same elements.
Singleton set
A set with one element is called a singleton set.
Computer Science
Note that the concept of a data type, or type, in
computer science is built upon the concept of a set. In
particular, a data type is the name of a set, together
with a set of operations that can be performed on
objects from that set.
Example:
Boolean is the name of the set {0, 1} together with
operators on one or more elements of this set, such as
AND, OR, and NOT.
Example:
A Venn diagram that represents V = {a, e, i, o, u}
Proper subset:
When a set A is a subset of a set B but A ≠ B,
A B, and A B
We write A B and say that A is a proper subset of B
For A B to be true, it must be the case that
x ((x A) (x B)) x ((x B) (x A))
Quick Examples:
{1,2,3} {1,2,3,4,5}
{1,2,3} {1,2,3,4,5}
Is {1,2,3}? Yes!
Is {1,2,3}? No!
Is {,1,2,3}? Yes!
Is {,1,2,3}? Yes!
Quiz Time:
Is {x} {x,{x}}?
Yes!
Is {x} {x,{x}}? Yes!
Is {x} {x}? Yes!
Is {x} {x}? No!
Finite set
Let S be a set. If there are exactly n distinct elements in S
where n is a nonnegative integer, we say that S is a finite
set and that n is the cardinality of S.
The cardinality of S is denoted by |S|.
| A B | = | A| + | B| - | A B|
Find
S = {1,2,3}, |S| = 3.
S = {3,3,3,3,3}, |S| = 1
S = , |S| = 0.
Example:
What is the power set of the set {0, 1, 2}?
P({0,1,2}) is the set of all subsets of {0, 1, 2}
P({0,1,2})= { , {0},{1},{2},{0,1},{0,2},{1,2},{0,1,2}}
What is the power set of the empty set? What is the
power set of the set {} ?
P()= {} N.B. the power set of any subset
has at least two elements
P({})= {,{}} The null set and the set itself
Quick Quiz:
Find the power set of the following:
S = {a}, P(S)= {, {a}}.
S = , P(S) = {}.
Example:
What is the Cartesian product A × B × C, where
A = {0, 1}, B = {1, 2}, and C = {0, 1, 2}?
A B = {1,2,3,4}
B
A
A B = {Lucy} B
A
If A = {x : x is a US president}, and
B = {x : x is deceased}, then
A B = {x : x is a deceased US president}
B
A
B
A
Sets whose intersection
is empty are
called disjoint sets
U =U
A
and
U=
A-B={x:xAxB}
A-B=AB
ഥ
= (A - B) (B - A)
U
Like
A “exclusive or”
B
Example:
Let A = {1,2,3,4,5,6,7} B = {3,4,p,q,r,s}
Then we have
A B=
{1,2,3,4,5,6,7,p,q,r,s}
AB=
{3,4}
We get AB= {1,2,5,6,7,p,q,r,s}
Computer Sciences Department
TABLE 1: Set Identities
Identity Name
AU =A
Identity laws
37
AU=A
AU U=U
Domination laws
A=
A A=A
Idempotent laws
AA=A
(A) = A Complementation laws
A B=B A
Commutative laws
AB=BA
A (B C) = (A B) C
Associative laws
A (B C) = (A B) C
A (B U C) = (A B) (A C)
Distributive laws
A (B C) = (A U B) (A U C)
AUB=AB
De Morgan’s laws
AB=AUB
A (A B) = A
Absorption laws
A (A B) = A
A A=U
Complement lawsDepartment
Computer Sciences
AA=
38
A B C
b) {{a}}
1
c) {∅, {∅}}
2
A B
B
Given the Universal set U={positive integers not larger than 12},
and the sets : A={positive integers not more than 6}
B={3,4,6,7} , C={5,6,7,8,9,10} , Find :
i) A U B =
{1,2,3,4,5,6,7}
ii) | A−B |=
3
iii) P(A‐B)=Power set of (A‐B)=
{ф,{1},{2},{5},{1,2},{1,5},{2,5},{1,2,5}}