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

Post on 18-Jan-2016

216 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

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

}0 |{ xxN

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

0| qZqZpq

pQ

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)

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)

Am I making this up?

Set operators

CB

CB

CBA

CBA

}4,3,2,1{

}7,5,3,1{

C

B

Set empty

{}

The empty set

The universal set

U

Venn Diagram

U

B

A

U is the universal setA is a subset of B

BA

Venn Diagram

U

B

A

U is the universal setA united with B

BA

Venn Diagram

U

B

A

U is the universal setA intersection B

BA

Cardinality of a set

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

5

}9,7,3,2,1{

S

S

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

Power Set

The set of all possible sets

?)(

nP

nS

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

Is this true for a set S?

S

SS

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

(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!!

(proper) Subset

BAAyByyBxAxx )()(

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

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

)]()[(

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

}51|12{ xx

}51|{ 2 xx

}44|2{ xx

How might a computer represent a set?

Remember those bit operations?

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

Power set

Try this

Compute the power set of

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

Power setCompute the power set of

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

Think again … how might we represent sets?

Cartesian Product

}|),{( BbAabaBA

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|

BABxAxx )(

ABBA

AxBxBxAxxBA

)]()[(

}|),{( BbAabaBA

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

Power Set PS(A)The thinking behind the code

▪▪▪▫▫▫

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

select don’t select

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

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

top related