Sets PowerPoint PPT Presentation

presentation player overlay
1 / 41
About This Presentation
Transcript and Presenter's Notes

Title: Sets


1
Sets
2
(No Transcript)
3
(No Transcript)
4
(No Transcript)
5
(No Transcript)
6
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

7
Set builder notation
S contains all elements from U (universal
set) That make predicate P true
Brace notation with ellipses (wee dots)
8
Set Membership
x is in the set S (x is a member of S)
y is not in the set S (not a member)
9
Am I making this up?
10
(No Transcript)
11
(No Transcript)
12
(No Transcript)
13
Set operators
14
Set empty
The empty set
15
The universal set
U
16
Venn Diagram
U
B
A
U is the universal set A is a subset of B
17
Venn Diagram
U
B
A
U is the universal set A united with B
18
Venn Diagram
U
B
A
U is the universal set A intersection B
19
Cardinality of a set
The number of elements in a set (the size of the
set)
20
Power Set
The set of all possible sets
21
Power Set
The set of all possible sets
22
Power Set
The set of all possible sets
We could represent a set with a bit string
0th element
23
Is this true for a set S?
24
Cartesian Product
A set of ordered tuples
25
(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!!

26
(proper) Subset
Consequently A is strictly smaller than B A lt
B
27
Equal sets?
Two show that 2 sets A and B are equal we need to
show that
And we know that
28
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

29
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

30
Go do this in claire
  • build the sets we just mentioned
  • test if is a subset of itself
  • 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

31
How might a computer represent a set?
Remember those bit operations?
32
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?)

33
Power set
Try this
  • Compute the power set of
  • 1,2
  • 1,2,3
  • 1,2

34
Power set
  • Compute the power set of
  • 1,2
  • 1,2,3
  • 1,2

Do it in claire
Think again how might we represent sets?
35
Cartesian Product
  • A set of ordered tuples
  • note AxB is not equal to BxA

Just reminding you (and me)
36
Try This
  • Let A1,2,3 and Bx,y, find
  • AxB
  • BxA
  • if An and Bm what is AxB

37
My answer
Do it in claire
  • Let A1,2,3 and Bx,y, find
  • AxB
  • BxA
  • if An and Bm what is AxB

38
For the brave the claire code
39
member(eany,Aset) boolean -gt exists(x in A
x e) // // There exists some element x in A
such that // x e // subset(Aset,Bset)
boolean -gt forall(x in A member(x,B)) // //
All elements of A are in B. Sometimes called
"improper" subset // What does it do when A ?
Hint P -gt Q and P is false! //
40
PS(Aset) set -gt PS(A,) PS(A,Bset)
set -gt set(B) PS(Aset,Bset) void -gt let
x A1 in PS(delete(copy(A),x),add(copy(B),
x)) U PS(delete(copy(A),x),B) // // The
power set of A // NOTE U is the (claire) union
operator //
41
CP(Aset,Bset) set -gt let pairs
in (for x in A (for y in B pairs
add(pairs,list(x,y))), pairs) // // The
cartesian product of 2 sets A and B // Produce a
set of tuples (as a list) // // Demo
CP(1,2,3,1,5) // CP(1,2,3,"A","B") /
/
Write a Comment
User Comments (0)
About PowerShow.com