Set Theory
Set Theory
1
What is a set?
• A set is a group of “objects”
• People in a class: { Alice, Bob, Chris }
• Program offered by a AC: { CS 101, CS 202, … }
• Colors of a rainbow: { red, orange, yellow, green, blue, purple }
• States of matter { solid, liquid, gas, plasma }
• Towns in Batangas: { Agoncillo, Alitagtag, Bauan, … }
• Sets can contain non-related elements: { 3, a, red, Alitagtag}
2
Set properties 1
3
Set properties 2
4
Specifying a set 1
5
Specifying a set 2
• Can use an ellipsis (…): B = {0, 1, 2, 3, …}
• Can cause confusion. Consider the set C = {3, 5, 7, …}. What
comes 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
6
Specifying a set 3
7
Often used sets
8
The universal set 1
10
Venn diagrams
• Represents sets graphically
• The box represents the universal set
• Circles represent the set(s)
• Consider set S, which is
the set of all vowels in the b c d f
U
alphabet g h j S
• The individual elements k l m
11
Sets of sets
12
The empty set 1
• If a set has zero elements, it is called the empty
(or null) set
• Written using the symbol
• Thus, = { } VERY IMPORTANT
• If you get confused about the empty set in a
problem, try replacing by { }
• As the empty set is a set, it can be a element of
other sets
• { , 1, 2, 3, x } is a valid set
13
The empty set 1
•Note that ≠ { }
• The first is a set of zero elements
• The second is a set of 1 element (that one
element being the empty set)
14
Set equality
16
Subsets 2
18
Proper Subsets 1
19
Proper Subsets 2
20
Proper subsets: Venn diagram
SR
U
R
21
Set cardinality
22
Power sets 1
23
Power sets 2
• P() = { }
• Note that || = 0 and |P()| = 1
24
Tuples
• In 2-dimensional space, it is a (x, y) pair of numbers to
specify a location
• In 3-dimensional (1,2,3) is not the same as (3,2,1) –
space, it is a (x, y, z) triple of numbers
• In n-dimensional space, it is a +y
n-tuple of numbers
(2,3)
• Two-dimensional space uses
pairs, or 2-tuples
• Three-dimensional space uses
triples, or 3-tuples +x
27
Cartesian products 3
28
Cartesian products 4
29
Set Operations
30
Sets of Colors
Monitor gamut • Pick any 3 “primary” colors
(M) • Triangle shows mixable
color range (gamut) – the
Printer set of colors
gamut
(P)
31
Set operations: Union 1
Monitor gamut • A union of the sets contains
(M) all the elements in EITHER
set
Printer
gamut
(P)
• Union symbol is
usually a U
• Example:
C=MUP
32
Set operations: Union 2
AUB
U
A B
33
Set operations: Union 3
34
Set operations: Union 4
35
Set operations: Intersection 1
Monitor gamut • An intersection of the sets
(M) contains all the elements in
BOTH sets
Printer
gamut
(P)
• Intersection symbol
is a ∩
• Example:
C=M∩P
36
Set operations: Intersection 2
A∩B
U
A B
37
Set operations: Intersection 3
38
Set operations: Intersection 4
39
Disjoint sets 1
• Two sets are disjoint if the
have NO elements in
common
• Formally, two sets are
disjoint if their intersection
is the empty set
• Another example:
the set of the even
numbers and the
set of the odd
numbers
40
Disjoint sets 2
A B
41
Disjoint sets 3
• Formal definition for 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
• {New York, Washington} 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
42
Set operations: Difference 1
Monitor gamut • A difference of two sets is
(M) the elements in one set
that are NOT in the other
Printer
gamut
(P)
• Difference symbol is
a minus sign
• Example:
C=M-P
• Also visa-versa:
C=P-M 43
Set operations: Difference 2
A-A
B B
U
A B
44
Set operations: Difference 3
• Formal definition for the difference of two sets:
A-B={x|x _ A and x B }
A - B = A ∩ B Important!
• Further examples
• {1, 2, 3} - {3, 4, 5} = {1, 2}
• {New York, Washington} - {3, 4} = {New York,
Washington}
• {1, 2} - = {1, 2}
• The difference of any set S with the empty set will be the set S
45
Set operations: Symmetric Difference
1 •
Monitor gamut A symmetric difference of
(M) the sets contains all the
elements in either set but
Printer NOT both
gamut
(P)
• Symetric diff.
symbol is a
• Example:
C=MP
46
Set operations: Symmetric Difference
2
• Formal definition for the symmetric difference of two
sets:
A B = { x | (x A or x B) and x A ∩ B}
A B = (A U B) – (A ∩ B) Important!
• Further examples
• {1, 2, 3} {3, 4, 5} = {1, 2, 4, 5}
• {New York, Washington} {3, 4} = {New York, Washington,
3, 4}
• {1, 2} = {1, 2}
• The symmetric difference of any set S with the empty set will be the
set S
47
Complement sets 1
Monitor gamut • A complement of a set is all
(M) the elements that are NOT
in the set
Printer
gamut
(P)
• Difference symbol is
_ _the set
a bar above
name: P or M
48
Complement sets 2
_
A
B
U
A B
49
Complement sets 3
50
Complement sets 4
•A = A Complementation
law
•A U A = U Complement law
•A ∩ A = Complement law
51
A last bit of color…
52
Photo printers
53
Set identities
54
Set identities: DeMorgan again
A B A B
A B A B
55
How to prove a set identity
56
What we are going to prove…
A∩B=B-(B-A)
A B
B-(B-A)
A∩B B-A
57
Proof by using basic set identities
• Prove that A∩B=B-(B-A)
A B B-(B A ) Definition of difference
B (B A ) Definition of difference
B (B A ) DeMorgan’s law
B (B A) Complementation law
(B B ) (B A) Distributive law
(B A) Complement law
(B A) Identity law
A B
Commutative law 58
What is a membership table
62
Proof by showing each set
is a subset of the other 3
• Assume that xA∩B
• By definition of intersection, xA and xB
• Thus, we know that xB-A
• B-A includes all the elements in B that are also not in A not include
any of the elements of A (by definition of difference)
• Consider B-(B-A)
• We know that xB-A
• We also know that if xA∩B then xB (by definition of intersection)
• Thus, if xB and xB-A, we can restate that (using the definition of
difference) as xB-(B-A)
• Thus, if xA∩B then xB-(B-A)
63
Proof by set builder notation
and logical equivalences 1
64
Proof by set builder notation
and logical equivalences 2
B ( B A) Original statement
{x | x B x ( B A)} Definition of difference
{x | x B ( x ( B A))} Negating “element of”
{x | x B ( x B x A)} Definition of difference
{x | x B ( x B x A)} DeMorgan’s Law
{x | x B x B x B x A} Distributive Law
{x | x B ( x B) x B x A} Negating “element of”
{x | F x B x A} Negation Law
{x | x B x A} Identity Law
A B Definition of intersection
65
Proof by set builder notation
and logical equivalences 3
66