Professional Documents
Culture Documents
What Is A Set?: Unit 4
What Is A Set?: Unit 4
What Is A Set?: Unit 4
Unit 4
SETS
What is a set?
A set is a unordered collection of “objects”
People in a class: {Ahmed, Omar, Samy }
Cities in Jordan: {Amman, Tafila, Irbid, … }
Sets can contain non-related elements: {3, a, red, Sameer}
{ 2.1, π, 0, -6.32, e }
R is the set of real numbers (it includes all the whole numbers,
rational numbers, irrational numbers such as √2 (1.41421356...)
What is Q ? If Q = {p/q | p Z, q Z, q ≠ 0}
Q is the set of rational numbers
Any number that can be expressed as a fraction of two integers
(where the bottom one is not zero)
Venn Diagrams
Represents sets graphically
The rectangle represents the universal set
Circles represent the set(s)
Consider set V, which is the set of all vowels in the alphabet
The individual elements
are usually not written b c d f
in a Venn diagram g h j
k l m
n p q a e i
r s t o u
v w x
y z
≠ { } why ?
The first is a set of zero elements (Empty)
The second is a set of 1 element (Singleton)
Replace by { }, and you get: { } ≠ {{ }}
It’s easier to see that they are not equal that way
Prof. Eyad S. Hrayshat Mathematical Foundations of Computing 10
Set Equality, Subsets
Two sets are equal if and only if they have the same elements
x (x A x B)
{1, 2, 3, 4, 5} = {5, 4, 3, 2, 1}
{1, 2, 3, 2, 4, 3, 2, 1} = {4, 3, 2, 1}
Two sets are not equal if they do not have the same elements
{1, 2, 3, 4, 5} ≠ {1, 2, 3, 4}
Proper Subsets
If S is a subset of T, and S is not equal to T, then S is a
proper subset of T
A proper subset is written as S T
Let T = {0, 1, 2, 3, 4, 5}
If S = {1, 2, 3},
{1, 2, 3}?
Yes
{1, 2, 3}?
No
{, 1, 2, 3}?
Yes
{, 1, 2, 3}?
Yes
{x} {x}?
No
Prof. Eyad S. Hrayshat Mathematical Foundations of Computing Slide 13
Set Cardinality
The cardinality of a set is the number of elements
in a set, written as |A|
Examples
Let R = {1, 2, 3, 4, 5}. What’s |R|
|R| = 5
|| =
0
Let S = {, {a}, {b}, {a, b}}. What’s |S|
Then |S| = 4
Cartesian Product
A Cartesian product is a set of all ordered 2-tuples where each “part” is from
a given set.
Denoted by A x B, and uses parenthesis (not curly brackets)
NOTE THAT A x B ≠ B x A
Since B x A = { (0, a), (0, b), (1, a), (1, b) }
Example
A = {0, 1}
B = {1, 2}
C = {0, 1 2}
ABC={ (0, 1, 0), (0, 1, 1), (0, 1, 2),
(0, 2, 0), (0, 2, 1), (0, 2, 2),
(1, 1, 0), (1, 1, 1), (1, 1, 2),
(1, 2, 0), (1, 2, 1), (1, 2, 2) }
Further examples
{1, 2, 3} U {3, 4, 5} =
{1, 2, 3, 4, 5}
{a, b} U {3, 4} =
{a, b, 3, 4}
{1, 2} U =
{1, 2}
AU =
A Identity law
AU U=
U Domination law
AU A=
A Idempotent law
AU B=BUA Commutative law
AU (B U C) = (A U B) U C Associative law
=AUBUC
Examples
{1, 2, 3} ∩ {3, 4, 5} =
{3}
{a, b} ∩ {3, 4} =
{1, 2} ∩ =
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 = A ∩ B ∩ C Associative law
and are
disjoint! because their intersection is the empty set
Prof. Eyad S. Hrayshat Mathematical Foundations of Computing 23
{a, b}
{1, 2} - =
{1, 2}
A = Ac = { x | x A }
Or Ac = U – A, where U is the universal set
Example:
Assuming U = Z, find:
{1, 2, 3}c =
{ …, -2, -1, 0, 4, 5, 6, … }
{a, b} =
c
Z
Let U is the set of all positive integers and A = {x | x > 10} find AC
Ā = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
(Ac)c =
A Complementation law
A U Ac =
U Complement law
A ∩ Ac =
Complement law
AB = {x | (x Є A) (x Є B)} .
A B = (A U B) − (A ∩ B)
= (A − B) U (B − A)
Prof. Eyad S. Hrayshat Mathematical Foundations of Computing 27
Set identities
A = A AU = U
Identity Law Domination law
AU = A A =
AA = A Idempotent
(Ac)c = A Complement Law
AA = A Law
AB = BA Commutative (AB)c = AcBc
De Morgan’s Law
AB = BA Law (AB)c = AcBc
A(BC) A(BC) =
= (AB)C Associative (AB)(AC)
Distributive Law
A(BC) Law A(BC) =
= (AB)C (AB)(AC)
A(AB) = A Absorption A Ac = U
Complement Law
A(AB) = A Law A Ac =
A - B = A Bc
Prof. Eyad S. Hrayshat Mathematical Foundations of Computing 28
How to Prove a Set Identity
Four methods:
1. Use the set identities
A B
A∩B
B-(B-A) B-A
x (A B)c
x (A B)
(x A B)
(x A x B)
(x A) (x B)
xAxB
x A c x Bc
x A c Bc
A B {x | x A B} (def of complement)
{x | ( x ( A B ))} (def of not belong to)
{x | ( x A x B )} (def of intersecti on)
{x | ( x A) ( x B )} (De Morgan' s law)
{x | x A x B} (def of not belong to)
{x | x A x B} (def of complement)
{x | x A B} (def of union)
A B
Prof. Eyad S. Hrayshat Mathematical Foundations of Computing 33
{0,1,2,3,4,6,8,9}
A⋂B⋂C=
{0}
Prof. Eyad S. Hrayshat Mathematical Foundations of Computing 35
General Cases
n
A1 A2 An Ai
Union: i 1
n
Intersection A1 A2 An Ai
i 1
Union: A1 A2 An Ai
i 1
Intersection: A1 A2 An Ai
i 1
Example 1
Let U = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} and the
ordering of elements of U is in the increasing order,
that is, ai = i
What bit strings represent the following subsets of U:
1. All odd integers in U 12 3456 78910
10 1010 1010
2. All even integers in U
01 0101 0101
Example 2
let U = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}. If the bit string for
set A = {1, 3, 5, 7, 9} is 10 1010 1010, what is the bit
string for the complement of this set?
Solution
The bit string for the complement of this set is
01 0101 0101,
which corresponds to the set {2, 4, 6, 8, 10}
Solution
The bit string for the union of these sets is
11 1110 0000 10 1010 1010 = 11 1110 1010,
corresponds to the set {1, 2, 3,4, 5, 7, 9}