Professional Documents
Culture Documents
DM Set03 Sets
DM Set03 Sets
DM Set03 Sets
Tassos Dimitriou
CpE-203
Discrete Structures
Set 3
Tassos Dimitriou
Outline
Definitions
Common operations on sets
Representing set
Proving identities about sets
1
1/17/2019
Tassos Dimitriou
What is a set?
Fundamental discrete structure on which all other discrete
structures are built.
Sets are used to group objects together. Often, but not always,
the objects in a set have similar properties
Tassos Dimitriou
What is a set?
Properties
Order does not matter
{1, 2, 3, 4, 5} is equivalent to {3, 5, 2, 4, 1}
2
1/17/2019
Tassos Dimitriou
Specifying a Set
Capital letters (A, B, S…) for sets. Italic lower-case letter for
elements (a, x, y…)
Tassos Dimitriou
3
1/17/2019
Tassos Dimitriou
Note that [a, b] is called the closed interval from a to b and (a, b)
is called the open interval from a to b.
Tassos Dimitriou
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
4
1/17/2019
Tassos Dimitriou
Is the same as { }?
The first is a set of zero elements
The second is a set of 1 element
Tassos Dimitriou
Venn diagrams
Represent sets graphically
The box represents the universal set
Circles represent the set(s)
U
S
Consider set S, which is
the set of all vowels in the e i
a
alphabet
o u
5
1/17/2019
Tassos Dimitriou
Tassos Dimitriou
Proper Subsets
If S is a subset of T, and S is not equal to T, then S is a
proper subset of T
Can be written as: R T and R T
Let T = {0, 1, 2, 3, 4, 5}
If S = {1, 2, 3}, S is not equal to T, and S is a subset of T
A proper subset is written as S T
Let Q = {4, 5, 6}. Q is neither a subset or T nor a proper subset
of T
6
1/17/2019
Tassos Dimitriou
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}. Then |R| = 5
|| = 0
Let S = {, {a}, {b}, {a, b}}. Then |S| = 4
Tassos Dimitriou
Power Sets
Many problems involve testing all combinations of elements of
a set to see if they satisfy some property. To consider all such
combinations of elements of a set S, we build a new set that
has as its members all the subsets of S.
Denoted by P(S) or 2S
7
1/17/2019
Tassos Dimitriou
What is P()?
Tassos Dimitriou
A 1 2 3 4 5 6 7 8
x x x x x x x x x
y y y y y y y y y
z z z z z z z z z
8
1/17/2019
Tassos Dimitriou
Cartesian Product
The ordered n-tuple (a1, a2, a3, …, an) is an ordered collection
of objects.
Two ordered n-tuples (a1, a2, a3, …, an) and (b1, b2, b3, …, bn) are equal
if and only if they contain exactly the same elements in the same order,
i.e. ai = bi for 1 i n.
Tassos Dimitriou
9
1/17/2019
Tassos Dimitriou
Set Operations
Tassos Dimitriou
Union
Formal definition for the union of two sets:
A B = { x | x A or x B }
Further examples
{1, 2, 3} {3, 4, 5} = {1, 2, 3, 4, 5}
{a, b} {3, 4} = {a, b, 3, 4}
{1, 2} = {1, 2}
10
1/17/2019
Tassos Dimitriou
Intersection
Formal definition for the intersection of two sets:
A ∩ B = { x | x A and x B }
Examples
{1, 2, 3} ∩ {3, 4, 5} = {3}
{a, b} ∩ {3, 4} =
{1, 2} ∩ =
Tassos Dimitriou
Union, Intersection
Using Venn diagrams
11
1/17/2019
Tassos Dimitriou
Disjoint sets
Two sets are disjoint if their intersection is the empty set.
Further examples
{1, 2, 3} and {3, 4, 5} are not disjoint
{a, b} and {3, 4} are disjoint
{1, 2} and are disjoint
Their intersection is the empty set
and are disjoint!
Their intersection is the empty set
How can we express the cardinality of the union of two sets A and
B?
Tassos Dimitriou
Difference
Formal definition for the difference of two sets:
A – B = { x | x A and x B }
Examples
{1, 2, 3} - {3, 4, 5} = {1, 2}
{a, b} - {3, 4} = {a, b}
{1, 2} - = {1, 2}
The difference of any set S with the empty set will be the set S
12
1/17/2019
Tassos Dimitriou
Complements of sets
Formal definition for the complement of a set:
A = { x | x A } = Ac
Or U – A, where U is the universal set
Tassos Dimitriou
Set identities
A = A AU = U
Identity Law Domination law
AU = A A =
AA = A Idempotent Complement
(Ac)c = A
AA = A Law 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)
Law Distributive Law
A(BC) A(BC) =
= (AB)C (AB)(AC)
A(AB) = A Absorption A Ac = U Complement
A(AB) = A Law A Ac = Law
13
1/17/2019
Tassos Dimitriou
Four methods:
Use the basic set identities
Use set builder notation and logical equivalences
Use membership tables
Prove each set is a subset of each other
Tassos Dimitriou
A B
B-(B-A)
A∩B B-A
14
1/17/2019
Tassos Dimitriou
Tassos Dimitriou
x (A B)c
x (A B)
(x A B)
(x A x B)
(x A) (x B)
xAxB
x Ac x Bc
x Ac Bc
15
1/17/2019
Tassos Dimitriou
Tassos Dimitriou
16
1/17/2019
Tassos Dimitriou
Set Operations
Take-home message:
Tassos Dimitriou
Examples
Let A, B, and C be sets. Show that:
(A ∪ B) (A ∪ B ∪ C)
(A ∩ B ∩ C) (A ∩ B)
(A-B)-C A-C
(A-C) ∩ (C-B) =
17
1/17/2019
Tassos Dimitriou
18