Sets
DEF: A set is a collection of elements.
A set is a new type of structure, representing
an unordered collection (group, plurality) of
zero or more distinct (different) objects.
Sets are the basic data structure out of which
most mathematical theories are built
L4 1
Sets
Curly braces ―{― and ―}‖ are used to denote
sets.
EG:
{ 11, 12, 13 }
{ , , }
L4 2
Sets
A set is defined only by the elements
which it contains. Thus repeating an
element, or changing the ordering of
elements in the description of the set,
does not change the set itself:
{ 11, 11, 11, 12, 13 } = { 11, 12, 13 }
{ , , }={ , , }
L4 3
Standard Numerical Sets
The natural numbers:
N = { 0, 1, 2, 3, 4, … }
The integers:
Z = { … -3, -2, -1, 0, 1, 2, 3, … }
The positive integers:
Z+ = {1, 2, 3, 4, 5, … }
The real numbers: R --contains any decimal
number of arbitrary precision
The rational numbers: Q --these are decimal
numbers whose decimal expansion repeats
Q: Give examples of numbers in R but not Q.
L4 4
Standard Numerical Sets
A: 2 , π, e, or any irrational number
L4 5
Venn Diagrams
2/10/2014 (c)2001-2003, Michael P. Frank 6
-Notation
The Greek letter ―‖ (epsilon) is used to denote
that an object is an element of a set. When
crossed out ―‖ denotes that the object is
not an element.‖
EG: 3 S reads:
―3 is an element of the set S ‖.
Q: Which of the following are true:
1. 3R
2. -3 N
3. -3 R
4. 0 Z+
L4
5. x xR x2=-5 7
-Notation
A: 1, 3 and 4
1. 3 R. True: 3 is a real number.
2. -3 N. False: natural numbers don’t
contain negatives.
3. -3 R. True: -3 is a real number.
4. 0 Z+. True: 0 isn’t positive.
5. x xR x2=-5 . False: square of a
real number is non-neg., so can’t be -5.
L4 8
Subset ()
DEF: A set S is said to be a subset of the set T
iff every element of S is also an element of
T. This situation is denoted by
ST
A synonym of ―subset‖ is ―contained by‖.
Definitions are often just a means of
establishing a logical equivalence which aids
in notation. The definition above says that:
ST x (xS ) (xT )
We already had all the necessary concepts, but
the ―‖ notation saves work.
L4 9
Proper (Strict) Subsets &
Supersets
ST (“S is a proper subset of T”) means
that ST but T / S . Similar for ST.
Example:
{1,2}
{1,2,3}
S
T
Venn Diagram equivalent of ST
2/10/2014 (c)2001-2003, Michael P. Frank 10
Subset Examples
Q: Which of the following are true:
1. NR
2. ZN
3. -3 R
4. {1,2} Z+
5.
6.
L4 11
Subset Examples
A: 1, 4 and 5
1. N R. All natural numbers are real.
2. Z N. Negative numbers aren’t natural.
3. -3 R. Nonsensical. -3 is not a subset but an
element! (This could have made sense if we
viewed -3 as a set –which in principle is the
case– in this case the proposition is false).
4. {1,2} Z+. This actually makes sense. The set
{1,2} is an object in its own right, so could be
an element of some set; however, {1,2} is not
a number, therefore is not an element of Z.
5. . Any set contains itself.
L4 6. . No set can contain itself properly. 12
The Empty Set
The empty set is the set containing no
elements. This set is also called the
null set and is denoted by:
{}
L4 13
Cardinality
The cardinality of a set is the number of
distinct elements in the set. |S |
denotes the cardinality of S.
Q: Compute each cardinality.
1. |{1, -13, 4, -13, 1}|
2. |{3, {1,2,3,4}, }|
3. |{}|
4. |{ {}, {{}}, {{{}}} }|
L4 14
Cardinality
Hint: After eliminating the redundancies just
look at the number of top level commas and
add 1 (except for the empty set).
A:
1. |{1, -13, 4, -13, 1}| = |{1, -13, 4}| = 3
2. |{3, {1,2,3,4}, }| = 3. To see this, set S =
{1,2,3,4}. Compute the cardinality of {3,S, }
3. |{}| = || = 0
4. |{ {}, {{}}, {{{}}} }|
= |{ , {}, {{}}| = 3
L4 15
Cardinality
DEF: The set S is said to be finite if its
cardinality is a nonnegative integer.
Otherwise, S is said to be infinite.
EG: N, Z, Z+, R, Q are each infinite.
L4 16
Power Set
DEF: The power set of S is the set of all
subsets of S.
Denote the power set by P (S ) or by 2s .
The latter weird notation comes from the
following.
Lemma: | 2s | = 2|s|
L4 17
Power Set –Example
To understand the previous fact consider
S = {1,2,3}
Enumerate all the subsets of S :
0-element sets: {} 1
1-element sets: {1}, {2}, {3} +3
2-element sets: {1,2}, {1,3}, {2,3} +3
3-element sets: {1,2,3} +1
Therefore: | 2s | = 8 = 23 = 2|s|
L4 18
Ordered n-tuples
Notationally, n-tuples look like sets except that
curly braces are replaced by parentheses:
( 11, 12 ) –a 2-tuple ordered pair
( , , ) –a 3-tuple
( , , , 11, Leo ) –a 5-tuple
L4 19
Ordered n-tuples
As opposed to sets, repetition and
ordering do matter with n-tuples.
(11, 11, 11, 12, 13) ( 11, 12, 13 )
( , , )( , , )
L4 20
Cartesian Product
The most famous example of 2-tuples are
points in the Cartesian plane R2. Here
ordered pairs (x,y) of elements of R describe
the coordinates of each point. We can think
of the first coordinate as the value on the x-
axis and the second coordinate as the value
on the y-axis.
DEF: The Cartesian product of two sets A
and B –denoted by A B– is the set of all
ordered pairs (a, b) where aA and bB .
Q: Describe R2 as the Cartesian product of two
sets.
L4 21
Cartesian Product
A: R2 = RR. I.e., the Cartesian plane is
formed by taking the Cartesian product
of the x-axis with the y-axis.
One can generalize the Cartesian product
to several sets simultaneously.
Q: If A = {1,2}, B = {3,4}, C = {5,6,7}
what is A B C ?
L4 22
Cartesian Product
A: A = {1,2}, B = {3,4}, C = {5,6,7}
A B C =
{ (1,3,5), (1,3,6), (1,3,7),
(1,4,5), (1,4,6), (1,4,7),
(2,3,5), (2,3,6), (2,3,7),
(2,4,5), (2,4,6), (2,4,7) }
Lemma: The cardinality of the Cartesian
product is the product of the cardinalities:
| A1 A2 … An | = |A1||A2| … |An|
Q: What does S equal?
L4 23
Cartesian Product
A: From the lemma:
|S | = |||S | = 0|S | = 0
There is only one set with no elements –
the empty set– therefore, S must be
the empty set .
One can also check this directly from the
definition of the Cartesian product.
L4 24
Set Builder Notation
Up to now sets have been defined using the curly
brace notation ―{ … }‖ or descriptively ―the set
of all natural numbers‖. The set builder
notation allows for concise definition of new
sets. For example
{ x | x is an even integer }
{ 2x | x is an integer }
are equivalent ways of specifying the set of all
even integers.
L5 25
Set Builder Notation
In general, one specifies a set by writing
{ f (x ) | P (x ) }
Where f (x ) is a function of x (okay we haven’t really
gotten to functions yet…) and P (x ) is a propositional
function of x. The notation is read as
―the set of all elements f (x ) such that P (x ) holds‖
Stuff between ―{― and ―|‖
specifies how elements look
Stuff between the ―|‖ and ―}‖
gives properties elements satisfy
Pipe symbol ―|‖ is
short-hand for ―such that‖.
L5 26
Set Builder Notation.
Shortcuts.
To specify a subset of a pre-defined set,
f (x ) takes the form xS. For example
{x N | y (x = 2y ) }
defines the set of all even natural numbers
(assuming universe of reference Z).
When universe of reference is understood,
don’t need to specify propositional function
EG: { x 3 | } or simply {x 3 } specifies the set
of perfect cubes
{0,1,8,27,64,125, …}
assuming U is the set of natural numbers.
L5 27
Set Builder Notation.
Examples.
Q1: U = N. { x | y (y x ) } = ?
Q2: U = Z. { x | y (y x ) } = ?
Q3: U = Z. { x | y (y R y 2 = x )} = ?
Q4: U = Z. { x | y (y R y 3 = x )} = ?
Q5: U = R. { |x | | x Z } = ?
Q6: U = R. { |x | } = ?
L5 28
Set Builder Notation.
Examples.
A1: U = N. { x | y (y x ) } = { 0 }
A2: U = Z. { x | y (y x ) } = { }
A3: U = Z. { x | y (y R y 2 = x )}
= { 0, 1, 2, 3, 4, … } = N
A4: U = Z. { x | y (y R y 3 = x )} = Z
A5: U = R. { |x | | x Z } = N
A6: U = R. { |x | } = non-negative reals.
L5 29
Set Theoretic Operations
Set theoretic operations allow us to build new sets
out of old, just as the logical connectives
allowed us to create compound propositions
from simpler propositions. Given sets A and B,
the set theoretic operators are:
Union ()
Intersection ()
Difference (-)
Complement (―—‖)
Symmetric Difference ()
give us new sets AB, AB, A-B, AB, andA .
L5 30
Venn Diagrams
Venn diagrams are useful in representing
sets and set operations. Various sets
are represented by circles inside a big
rectangle representing the universe of
reference.
L5 31
The Union Operator
For sets A, B, theirnion AB is the set
containing all elements that are either
in A, or (“”) in B (or, of course, in
both).
Formally, A,B: AB = {x | xA
xB}.
Note that AB is a superset of both A
and B (in fact, it is the smallest such
superset): (c)2001-2003, Michael P. Frank
2/10/2014 32
Union Examples
{a,b,c}{2,3} = {a,b,c,2,3}
{2,3,5}{3,5,7} = {2,3,5,3,5,7}
={2,3,5,7}
Think ―The United
States of America
includes every
person who worked
in any U.S. state last
year.‖ (This is how
the IRS sees it...)
2/10/2014 (c)2001-2003, Michael P. Frank 33
The Intersection Operator
For sets A, B, their intersection AB is
the set containing all elements that are
simultaneously in A and (“”) in B.
Formally, A,B: AB={x | xA xB}.
Note that AB is a subset of both A
and B (in fact it is the largest such
subset):
A, B: (AB A) (AB B)
2/10/2014 (c)2001-2003, Michael P. Frank 34
Intersection Examples
{a,b,c}{2,3} =___
{2,4,6}{3,4,5} ={4}
______
Think ―The
intersection of
University Ave. and
W 13th St. is just
that part of the road
surface that lies on
both streets.‖
2/10/2014 (c)2001-2003, Michael P. Frank 35
Disjointedness
Help, I’ve
Two sets A, B are called been
disjointed!
disjoint (i.e., unjoined)
iff their intersection is
empty. (AB=)
Example: the set of even
integers is disjoint with
the set of odd integers.
2/10/2014 (c)2001-2003, Michael P. Frank 36
Inclusion-Exclusion Principle
How many elements are in AB?
|AB| = |A| |B| - |AB|
Example: How many students are on our
class email list? Consider set E I M,
I = {s | s turned in an information sheet}
M = {s | s sent the TAs their email
address}
Some students did both!
|E| = |IM| = |I| |M| - |IM|
2/10/2014 (c)2001-2003, Michael P. Frank 37
Set Difference
For sets A, B, the difference of A and B,
written A-B, is the set of all elements
that are in A but not B. Formally:
A - B : x xA xB
x xA xB)
Also called:
The complement of B with respect to A.
2/10/2014 (c)2001-2003, Michael P. Frank 38
Set Difference Examples
{1,2,3,4,5,6} - {2,3,5,7,9,11} =
___________
{1,4,6}
Z - N {… , −1, 0, 1, 2, … } - {0, 1, …
}
= {x | x is an integer but not a
nat. #}
= {x | x is a negative integer}
= {… , −3, −2, −1}
2/10/2014 (c)2001-2003, Michael P. Frank 39
Set Difference - Venn Diagram
A−B is what’s left after B
“takes a bite out of A”
Chomp!
Set
A-B
Set A Set B
2/10/2014 (c)2001-2003, Michael P. Frank 40
Set Complements
The universe of discourse can itself be
considered a set, call it U.
When the context clearly defines U, we
say that for any set AU, the
complement
A of A, written , is the
complement of A w.r.t. U, i.e., it is U-A.
E.g., If U=N, {3,5} {0,1,2,4,6,7,...}
2/10/2014 (c)2001-2003, Michael P. Frank 41
More on Set Complements
An equivalent definition, when U is
clear:
A {x | x A}
A
A
U
2/10/2014 (c)2001-2003, Michael P. Frank 42
Set Identities
Identity: A = A = AU
Domination: AU = U , A =
Idempotent: AA = A = AA
Double complement:( A ) A
Commutative: AB = BA , AB =
BA
Associative: A(BC)=(AB)C ,
A(BC)=(AB)C
2/10/2014 (c)2001-2003, Michael P. Frank 43
DeMorgan’s Law for Sets
Exactly analogous to (and provable
from) DeMorgan’s Law for propositions.
A B A B
A B A B
2/10/2014 (c)2001-2003, Michael P. Frank 44
Proving Set Identities
To prove statements about sets, of the
form
E1 = E2 (where the Es are set
expressions), here are three useful
techniques:
1. Prove E1 E2 and E2 E1 separately.
2. Use set builder notation &
logical equivalences.
3. Use a membership
2/10/2014 (c)2001-2003, Michael table
P. Frank . 45
Method 1: Mutual subsets
Example: Show A(BC)=(AB)(AC).
Part 1: Show A(BC)(AB)(AC).
Assume xA(BC), & show x(AB)(AC).
We know that xA, and either xB or xC.
Case 1: xB. Then xAB, so x(AB)(AC).
Case 2: xC. Then xAC , so x(AB)(AC).
Therefore, x(AB)(AC).
Therefore, A(BC)(AB)(AC).
Part 2: Show (AB)(AC) A(BC). …
2/10/2014 (c)2001-2003, Michael P. Frank 46
Method 3: Membership Tables
Just like truth tables for propositional
logic.
Columns for different set expressions.
Rows for all combinations of
memberships in constituent sets.
Use “1” to indicate membership in the
derived set, “0” for non-membership.
Prove equivalence with identical
columns. (c)2001-2003, Michael P. Frank
2/10/2014 47
Membership Table Example
Prove (AB)-B = A-B.
A B AB (AB)-B A-B
0 0 0 0 0
0 1 1 0 0
1 0 1 1 1
1 1 1 0 0
2/10/2014 (c)2001-2003, Michael P. Frank 48
Membership Table Exercise
Prove (AB)-C = (A-C)(B-C).
A B C A B ( A B ) - C A - C B- C (A-C)(B-C)
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
2/10/2014 (c)2001-2003, Michael P. Frank 49
Quiz (explain your answers)
1. Consider the following statement:
S1 ( x, y ) : ( x 1 y -1 xy 0)
x, y real numbers
a. Is this statement a proposition ?
S (2, 2)
b. Is the following proposition true: 1 ?
c. Is the following proposition true: xy S1 ( x, y) ?
Next consider the statement:
S2 ( x, y ) : ( x 1 y -1 xy 0)
x, y real numbers
S2 (2, 2)
d. Is the following proposition true:
e. Is the following proposition true:
xy S2 ( x, y)
Answers Quiz Tu. April 13, 3.30-3.45 pm
S1 ( x, y ) : ( x 1 y -1 xy 0 )
1. Consider the following statement: x, y real numbers
a. Is this statement a proposition : No, the variables are not bound.
b. Is the following proposition true: S1 (2, 2) : Yes: FF =T
c. Is the following proposition true:xy S1 ( x, y:)
No, counter-example, x=1,y= -1/2 xy<0. FT=F
Next consider the statement: S2 ( x, y ) : ( x 1 y -1 xy 0)
x, y real numbers
d. Is the following proposition true:S2 (2, 2)
Yes, FF=T
e. Is the following proposition true:xy S2 ( x, y)
Yes. To show that we need to show that if the premises are true then
the conclusion must be true. (the proposition is always true if the premises are
false). Clearly, that is always the case.