Sets Set builder notation N 0 1 2
Sets
Set builder notation • N = {0, 1, 2, 3, …} the “natural numbers” • R = reals • Z = {… -3, -2, -1, 0, 1, 2, 3, …} • Z+ = {1, 2, 3, 4, 5, …} • Q = the set of rational numbers
Set builder notation S contains all elements from U (universal set) That make predicate P true Brace notation with ellipses (wee dots)
Set Membership x is in the set S (x is a member of S) y is not in the set S (not a member)
Am I making this up?
Set operators
Set empty The empty set
The universal set U
Venn Diagram U B A U is the universal set A is a subset of B
Venn Diagram U B A U is the universal set A united with B
Venn Diagram U B A U is the universal set A intersection B
Cardinality of a set The number of elements in a set (the size of the set)
Power Set The set of all possible sets
Power Set The set of all possible sets
Power Set The set of all possible sets We could represent a set with a bit string 0 th element
Is this true for a set S?
Cartesian Product A set of ordered tuples
(improper) Subset • is empty {} a subset of anything? • Is anything a subset of {}? • We have an implication, what is its truth table? • Note: improper subset!!
(proper) Subset Consequently A is strictly smaller than B |A| < |B|
Equal sets? Two show that 2 sets A and B are equal we need to show that And we know that
Try This Using set builder notation describe the following sets • odd integers in the range 1 to 9 • the integers 1, 4, 9, 16, 25 • even numbers in the range -8 to 8
Answers Using set builder notation describe the following sets • odd integers in the range 1 to 9 • the integers 1, 4, 9, 16, 25 • even numbers in the range -8 to 8
How might a computer represent a set? Remember those bit operations?
Computer Representation (possible} How do we compute the following? • membership of an element in a set • union of 2 sets • intersection of 2 sets • compliment of a set • set difference (tricky? )
Power set Try this Compute the power set of • {1, 2} • {1, 2, 3} • {{1}, {2}} • {}
Power set Compute the power set of • {1, 2} • {1, 2, 3} • {{1}, {2}} • {} Think again … how might we represent sets?
Cartesian Product A set of ordered tuples • note Ax. B is not equal to Bx. A Just reminding you (and me)
Try This Let A={1, 2, 3} and B={x, y}, find • Ax. B • Bx. A • if |A|=n and |B|=m what is |Ax. B|
My answer Let A={1, 2, 3} and B={x, y}, find • Ax. B • Bx. A • if |A|=n and |B|=m what is |Ax. B|
Power Set PS(A) The thinking behind the code 0 1 111 10 01 11 011 101 001 110 Go left: take Go right: don’t take 00 010 100 000
- Slides: 45