450 likes | 713 Views
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.
E N D
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)
Set empty The empty set
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 0th element
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 AxB is not equal to BxA Just reminding you (and me)
Try This • Let A={1,2,3} and B={x,y}, find • AxB • BxA • if |A|=n and |B|=m what is |AxB|
My answer • Let A={1,2,3} and B={x,y}, find • AxB • BxA • if |A|=n and |B|=m what is |AxB|
The thinking behind the code Power Set PS(A) 0 1 10 00 01 11 011 101 001 010 100 111 110 000 Go left: take Go right: don’t take
The thinking behind the code Power Set PS(A) ▫▫▫ ▪▪▪ ▫▫▪ ▪▪▫ ▫▫▫ ▫▫▫ ▫▪▫ ▪▫▫ ▪▫▫ ▪▪▫ ▪▫▪ ▫▫▪ ▫▫▪ ▪▫▫ ▫▫▫ ▫▫▫ don’t select select ▫▪▪ ▪▫▫