sets. set builder notation n = {0,1,2,3,…} the “natural numbers” r = reals z = {…...

45
Sets

Upload: andrea-susanna-hines

Post on 18-Jan-2016

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 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

Sets

Page 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
Page 3: 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
Page 4: 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
Page 5: 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
Page 6: 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

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

}0 |{ xxN

}2,1,3{}3,2,1{}3,2,1,3,2,1{

0| qZqZpq

pQ

Page 7: 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

Set builder notation

)}( |{ xPxS

},3,2,1,0,1,2,3,{ Z

S contains all elements from U (universal set)That make predicate P true

Brace notation with ellipses (wee dots)

Page 8: 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

Set Membership

Sx

Sy

x is in the set S (x is a member of S)

y is not in the set S (not a member)

Page 9: 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

Am I making this up?

Page 10: 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
Page 11: 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
Page 12: 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
Page 13: 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

Set operators

CB

CB

CBA

CBA

}4,3,2,1{

}7,5,3,1{

C

B

Page 14: 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

Set empty

{}

The empty set

Page 15: 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

The universal set

U

Page 16: 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

Venn Diagram

U

B

A

U is the universal setA is a subset of B

BA

Page 17: 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

Venn Diagram

U

B

A

U is the universal setA united with B

BA

Page 18: 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

Venn Diagram

U

B

A

U is the universal setA intersection B

BA

Page 19: 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

Cardinality of a set

The number of elements in a set (the size of the set)

5

}9,7,3,2,1{

S

S

Page 20: 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

Power Set

The set of all possible sets

}}3,2,1{},3,2{},3,1{},2,1{},3{},2{},1{{{},)(

}3,2,1{

SP

S

Page 21: 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

Power Set

The set of all possible sets

?)(

nP

nS

Page 22: 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

Power SetThe set of all possible sets

We could represent a set with a bit string

10101011}7,5,3,1,0{

0th element

},,{111

},{011

},{101

}{001

},{110

}{010

}{100

{}000

cba

ba

ca

a

cb

b

c

cba

Page 23: 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

Is this true for a set S?

S

SS

Page 24: 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

Cartesian Product

)},4(),,4(),,4(),,3(),,3(),,3(),,2(),,2(),,2(),,1(),,1(),,1{(

},,{

}4,3,2,1{

cbacbacbacbaBA

cbaB

A

A set of ordered tuples

}|),{( BbAabaBA

ABBA

Page 25: 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

(improper) Subset

BABxAxx )(

• is empty {} a subset of anything?• Is anything a subset of {}?• We have an implication, what is its truth table?• Note: improper subset!!

Page 26: 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

(proper) Subset

BAAyByyBxAxx )()(

Consequently A is strictly smaller than B|A| < |B|

Page 27: 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

Equal sets? BABxAxx )(

Two show that 2 sets A and B are equal we need to show that

BABxAxx )(

And we know that )()( pqqpqp

ABBA

AxBxBxAxxBA

)]()[(

Page 28: 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

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

Page 29: 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

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

}51|12{ xx

}51|{ 2 xx

}44|2{ xx

Page 30: 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

How might a computer represent a set?

Remember those bit operations?

Page 31: 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

Computer Representation (possible}

10101011}7,5,3,1,0{ A

10010101}7,4,2,0{ B

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?)

Page 32: 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

Power set

Try this

Compute the power set of

• {1,2}• {1,2,3}• {{1},{2}}• {}

Page 33: 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

Power setCompute the power set of

• {1,2}• {1,2,3}• {{1},{2}}• {}

Think again … how might we represent sets?

Page 34: 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

Cartesian Product

}|),{( BbAabaBA

A set of ordered tuples

• note AxB is not equal to BxA

Just reminding you (and me)

Page 35: 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

Try This

Let A={1,2,3} and B={x,y}, find

• AxB• BxA• if |A|=n and |B|=m what is |AxB|

Page 36: 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

My answer

Let A={1,2,3} and B={x,y}, find

• AxB• BxA• if |A|=n and |B|=m what is |AxB|

Page 37: 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
Page 38: 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
Page 39: 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
Page 40: 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

BABxAxx )(

Page 41: 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

ABBA

AxBxBxAxxBA

)]()[(

Page 42: 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

}|),{( BbAabaBA

Page 43: 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

Power Set PS(A)

1 0

11 01

111 011 101 001

10

110 010 100 000

00

Go left: takeGo right: don’t take

The thinking behind the code

Page 44: 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

Power Set PS(A)The thinking behind the code

▪▪▪▫▫▫

▪▪▫▫▫▪ ▪▪▫▫▫▫

select don’t select

▪▫▫▫▪▪ ▪▫▫▫▫▪ ▪▫▫▫▪▫ ▪▫▫▫▫▫

▫▫▫▪▫▪ ▫▫▫▫▫▪

Page 45: 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