Sets X. Zhang Dept. of Computer & Information Sciences - - PowerPoint PPT Presentation

sets
SMART_READER_LITE
LIVE PREVIEW

Sets X. Zhang Dept. of Computer & Information Sciences - - PowerPoint PPT Presentation

Sets X. Zhang Dept. of Computer & Information Sciences Fordham University 1 Outline on sets Basics Specify a set by enumerating all elements Notations Cardinality Venn Diagram Relations


slide-1
SLIDE 1

Sets

  • X. Zhang
  • Dept. of Computer & Information Sciences

Fordham University

1

slide-2
SLIDE 2

Outline on sets

2

Basics

Specify a set by enumerating all elements Notations Cardinality

Venn Diagram Relations on sets: subset, proper subset Set builder notation Set operations

slide-3
SLIDE 3

Set: an intuitive definition

3

A set is just a collection of objects, these objects are

called the members or elements of the set

One can specify a set by enclosing all its elements

with curly braces, separated by commas

Examples:

Set has 6 elements: letter a, letter b,

letter c, d, e, and f

Set has 5 elements: bob, 1, 8,

clown, hat.

} , , , , , { f e d c b a

} , , 8 , 1 , { hat clown bob

slide-4
SLIDE 4

4

{}

Called the empty set, or null set,

  • ften also denoted as

A set without elements is a special set:

φ

slide-5
SLIDE 5

Enumerating set elements

5

1.

You don’t list anything more than once

  • 2.

Order doesn’t matter

The following sets are identical (same)

} , , , , , { f e b a b a

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

slide-6
SLIDE 6

So what if I get tired of writing out all of these Sets?

Just as with algebra, we give name to a set. Typically we use single capital letters to

denote a set.

For example:

} , , , , , { f e d c b a A =

6

slide-7
SLIDE 7

Notations

7

A x∈

Two key symbols that we will see:

means “x is an element of set A”

A x∉

means “x is not an element of set A”

} , , { c b a a∈ } , , { 1 c b a ∉

slide-8
SLIDE 8

Cardinality

8

  • The cardinality of a set A is the number

elements in the set, denoted as |A|.

  • For example:

} , , , , , { f e d c b a A = | {} | 6 | | = = A

slide-9
SLIDE 9

Exercises

9

1.

What is |A|?

  • 3
  • 2.

What is |B|+|C|

  • 6
  • 3.

What is |D|+|E|-|A|?

  • 3+0-3=0

{} } 11 , 10 {}, {{}, }} , { }}, { , {{ } 10 , 5 , , 5 { } , , { = = = − = = E D d c b a C B gamma beta alpha A

slide-10
SLIDE 10

Outline on sets

10

Basics

Specify a set by enumerating all elements Notations Cardinality

Venn Diagram Relations on sets: subset, proper subset Set builder notation Set operations

slide-11
SLIDE 11
  • Venn Diagram is a diagram for

visualizing sets

  • a rectangle represents

universal set, U, the set contains all elements that we are interested in

  • Circles within it represent other

sets

Venn Diagram

11

A U

  • Ex: U: the set of all Fordham students
  • A: all freshman students, B: all female students,
  • C: all science major students
slide-12
SLIDE 12

Relations between sets

12

B A ⊆

If A is totally included in set B, i.e., every element of A is also an element of B, denoted as , read as A is a subset of B

A B B

} 5 , 4 , 3 , 2 , 1 { } 5 , 3 , 1 { ⊆

For example:

} 3 , 2 , 1 { } 3 , 2 , 1 { ⊆ } 5 , 4 , 3 , 2 , 1 { {} ⊆

Empty set is subset of any set Any set is a subset of itself

slide-13
SLIDE 13

Relations between sets

13

If A is not totally included in set B, i.e., there exists some element of A that is not an element

  • f B, then A is not a

subset of B, denoted as

B A B C

} 5 , 4 , 3 , 2 , 1 { } 6 , 3 , 1 { ⊆

For example:

} 5 , 4 { } 3 , 2 , 1 { ⊆

B A ⊆

slide-14
SLIDE 14

Proper subset

14

{ }

} 5 , 4 , 3 , 2 , 1 { } 5 , 3 , 1 { 5 , 4 , 3 , 2 , 1 } 5 , 4 , 3 , 2 , 1 { ⊂ ⊆

If A is a subset of B, and A≠B, then A is a

proper subset of B, denoted as

Analogy to ≤ and < relations between numbers

B A ⊂

slide-15
SLIDE 15

Exercise: True or False

1.

If , and , then

2.

If , and , then

3.

If , then

4.

If , then

5.

{} has no subset.

A x∈

B A ⊆

15

B x∈

B A ⊆ C B ⊆ C A ⊆ B A ⊆ | | | | B A ≤ | | | | B A ≤ B A ⊆

slide-16
SLIDE 16

Exercise

16

Find out all subsets of set A={1,2}

  • Find out all subsets of set A={a,b,c}
  • Find out all proper subsets of set A={a,b,c}
slide-17
SLIDE 17

Outline on sets

17

Basics

Specify a set by enumerating all elements Notations Cardinality

Venn Diagram Relations on sets: subset, proper subset Set builder notation Set operations

slide-18
SLIDE 18

Some well-known sets

18

N is the natural numbers {0, 1, 2, 3, 4, 5, …}

  • Z is the set of integers {…-2,-1,0,1,2,…}

Q is the set of rational numbers

Any number that can be written as a fraction, that is ,

where p and q are integers, and q≠0

e.g.

R is the set of real numbers

all numbers/fractions/decimals that you can imagine,

including , etc.

N ∈ 1

N ∉ −10 N ∉ 1415 . 3

q p

π

2

Q ∉ π

Q ∉ 2

slide-19
SLIDE 19

Some Well-known Sets: Variations

19

N+ is the set of positive natural numbers, { 1, 2, 3, 4,

5, …}

Z- is the set of negative integers {-1,-2,-3,…} Q>1 is the set of rational numbers that are greater

than 1

R<10 is the set of real numbers that are smaller than

10

slide-20
SLIDE 20

Set Builder Notation

20

} 10 and : { > ∈ x N x x

We don’t always have the ability or want to list every

element in a set.

Mathematicians have invented “Set Builder

Notation”. For example,

read as “a set contains all x’s such that x is an element of the set of natural numbers and … ”

} 10 3 and | { > ∈ x N x x

slide-21
SLIDE 21

Set Builder Notation

21

first half: what we want to include in our set

Second half: constrains on objects specified in first half for it to be an element of the set.

} 10 and : { > ∈ x N x x

slide-22
SLIDE 22

Reading set builder notations

22

} 5 2 : { = × x x

} 5 . 2 {

} 6 , 4 , 2 { ,...} 15 , 12 , 9 , 6 , 3 , {

} 3 and : { N x N x x ∈ ∈ }} 3 , 2 , 1 { and 2 : { ∈ = k k x x } y some for 2 | {

+

∈ = Z y x x

,...} 12 , 10 , 8 , 6 , 4 , 2 {

slide-23
SLIDE 23

More about set builder

23

}} 3 , 2 , 1 { and : { }} 3 , 2 , 1 { : 4 { } even is : { ∈ ∈ + ∈ + ∈ y A x y x x x x A x

  • First half: can be an expression, or

specify part of the constraints.

  • For example:
  • Let A={1,2,3,5}

} 7 , 6 , 5 { } 2 { = = } 8 , 7 , 6 , 5 , 4 , 3 , 2 { =

slide-24
SLIDE 24

Some exercise

24

} 4 and : 2 { ≤ ∈ = x N x x B

Find all elements of set B defined as follows:

slide-25
SLIDE 25

Outline on sets

25

Basics

Specify a set by enumerating all elements Notations Cardinality

Venn Diagram Relations on sets: subset, proper subset Set builder notation Set operations

slide-26
SLIDE 26

Set Operations

26

Just like in arithmetic, there are lots of ways we can

perform operation on sets. Most of these operations are different ways of combining two different sets, but some (like Cardinality) only apply to a single set.

slide-27
SLIDE 27

Union

27

B A∪

Create a new set by combining all of the elements or two sets, i.e.,

}

  • r

A | { : B x x x B A ∈ ∈ = ∪

The part that has been shaded. “is defined as”

slide-28
SLIDE 28

Union Examples

= ∪ A B

} 8 , 6 , 5 , 4 , 3 , 2 , 1 , {

{} } 15 , 10 , 5 , { } 8 , 6 , 4 , 2 , { } 5 , 4 , 3 , 2 , 1 { = = = = D C B A

28

= ∪ B A } 15 , 10 , 8 , 6 , 5 , 4 , 3 , 2 , 1 , { = ∪ D C } 8 , 6 , 5 , 4 , 3 , 2 , 1 , { = ∪ ∪ ∪ ) ( ) ( B D C A } 15 , 10 , 5 , {

slide-29
SLIDE 29

Intersection

29

B A∩

Create a new set using the elements the two sets have if common

} and A | { : B x x x B A ∈ ∈ = ∩

The part that has been shaded twice is

B A∩

“is defined as”

slide-30
SLIDE 30

Intersection Examples

= ∩ A B

} 4 , 2 {

{} } 15 , 10 , 5 , { } 8 , 6 , 4 , 2 , { } 5 , 4 , 3 , 2 , 1 { = = = = D C B A

30

= ∩ B A } 5 { = ∩ D C } 4 , 2 { = ∩ ∪ ∩ ) ( ) ( B D C A {}

slide-31
SLIDE 31

Difference

31

B A−

Create a new set that includes all elements of set A, removing those elements that are also in set B

} and A | { : B x x x B A ∉ ∈ = −

B A A-B: the part that is shaded in blue

slide-32
SLIDE 32

Difference Examples

= − A B

} 5 , 3 , 1 {

{} } 15 , 10 , 5 , { } 8 , 6 , 4 , 2 , { } 5 , 4 , 3 , 2 , 1 { = = = = D C B A

32

= − B A } 4 , 3 , 2 , 1 { = − D C } 8 , 6 , { = − − − ) ( ) ( B D C A } 15 , 10 , 5 , {

slide-33
SLIDE 33

Complement

33

The difference of universal set U (the set that includes everything) and A is also called the complement of A:

A U

A} x and | { : ∉ ∈ = − = U x x A U Ac

Colored area is U-A

slide-34
SLIDE 34

Set operations example

34

A is the set of all computer science majors.

B is the set of all physics majors. C is the set of all general science majors. D is the set of all female students. Using set operations, describe each of the following in terms of

the sets A, B, C and D:

Set of all male physics majors.

  • Set of all students who are female or general science majors.
  • Set of all students not majoring in computer science.
slide-35
SLIDE 35

Fenway Park or Yankee Stadium

Of the 28 students in a class,

23 have visited one or both 12 have visited Fenway 9 have visited Fenway and Yankee Stadium

How many have visited Yankee stadium? How many have visited only Fenway Park?

slide-36
SLIDE 36

Principle of Inclusion/Exclusion

| | | | | | | | B A B A B A ∩ − + = ∪ | | | | | | | | B A B B A A ∩ + − ∪ =

Also,

slide-37
SLIDE 37

Principle of Inclusion/Exclusion

37

= ∪ ∪ | | C B A

A B C

slide-38
SLIDE 38

Power Set

38

) (A P

is a set that consists of all subsets of set A.

  • e.g. P({1})=?

List all subsets of {1}: {},{1} Therefore P({1})={{},{1}}.

} : { : ) ( A x x A P ⊆ =

slide-39
SLIDE 39

Power Set Examples

= ) (B P

{}} }, 3 { }, 2 { }, 1 { }, 3 , 2 { }, 3 , 1 { }, 2 , 1 { }, 3 , 2 , 1 {{ } , , , { } 3 , 2 , 1 { d c b a B A = =

39

= ) (A P {}} }, { }, { }, { }, { }, , { }, , { }, , { }, , { }, , { }, , { }, , , { }, , , { }, , , { }, , , { }, , , , {{ d c b a d c d b c b d a c a b a d c b d c a d b a c b a d c b a

slide-40
SLIDE 40

Exercises on power set

40

= = = = P(C) } {} 1, {a, C . 2 ) ( {} . 1 A P A

slide-41
SLIDE 41

Cardinality of Power Set

41

If |A|=1, |P(A)|= ?

Try P({a})=

If |A|=2, |P(A)|=

Try P({a,b})

If set A has a certain number of subsets, after we

add one more element into A, how many subsets A has now ?

Every originally identified subsets are still valid Add the new element into each of them, and we get a

new subset.

The number of subsets doubles !

slide-42
SLIDE 42

Cardinality of Power Set

42

Set A with n elements has an subsets

  • We can find the closed form:
  • A set of cardinality n has 2n subsets

If |A|=n, |P(A)|=2n Or: |P(A)|=2|A| 1 1

2 2

= =

n n

a a a

n n

a 2 =

slide-43
SLIDE 43

Cartesian Product (Cross Product)

43

B A×

Create a new set consisting of all possible ordered pairs with the first element taking from A, and second element taking from B.

} and : ) , {( : B y A x y x B A ∈ ∈ = ×

slide-44
SLIDE 44

Ordered Pair

44

Its just like what you learned about when you learned

about graphing:

  • It’s different from set !
  • {1,2}={2,1}

x, and y can be numbers, names, anything you can

imagine

) 1 , 2 ( ) 2 , 1 ( ≠

) , ( y x

x y (1,2) (2,1)

slide-45
SLIDE 45

Example of Cartesian Product

45

I have two T-shirts: white, black

A={white shirt, black shirt}

I have three jeans: black, blue, green

B={black jean, blue jean, green jean}

All outfits I can make out of these ?

The set of all ordered-pairs, in the form (T-shirt, jean)…

slide-46
SLIDE 46

Cartesian Product Examples

= × A B

)} , 3 ( ), , 3 ( ), , 3 ( ), , 2 ( ), , 2 ( ), , 2 ( ), , 1 ( ), , 1 ( ), , 1 {( c b a c b a c b a

} , , { } 3 , 2 , 1 { c b a B A = =

46

= × B A )} 3 , ( ), 2 , ( ), 1 , ( ), 3 , ( ), 2 , ( ), 1 , ( ), 3 , ( ), 2 , ( ), 1 , {( c c c b b b a a a

slide-47
SLIDE 47

Cardinality of Cartesian Product

47

If A has m elements, B has n elements, how many

elements does AxB have ?

For every element of A, we pair it with each of the n

elements in B,. to get n ordered pairs in AxB

So we can form n*m ordered pairs this way So |AxB| = m*n = |A|*|B|

This is where the name Cartesian product comes

from.

slide-48
SLIDE 48

Exercises on Power Set/Cartesian Product

{} x {1,2}= P({a,b}) x {c,d} = Is it true that for any set A, Is it true that for any set A,

48

? ) ( {} A P ∈ ? ) ( {} A P ⊆

slide-49
SLIDE 49

Examples

A certain club is forming a recruitment committee consisting of five of

its members. They have calculated that there are 8,568 different ways to form such a committee. The club has two members named Jack and Jill. They have calculated that 2,380 of the potential committees have Jack on them, 2,380 have Jill, 1,820 have Jack but not Jill, 1,820 have Jill but not Jack, and 560 have both Jack and Jill.

1.

How many committees have either Jack or Jill?

2.

How many committees have neither Jack nor Jill?

3.

Jack and Jill are car-pooling, so they insist that if either one is on the committee, the other person must also be on the committee. How many committee meet this condition?

4.

Jack and Jill have had a fight. Jack says, “if Jill is on the committee, I won’t be.” Jill says,“Likewise.” How many of the committees meet this condition?

  • (Hint, draw a Venn diagram depicting the set of all possible committees as

the universal set…)

49

slide-50
SLIDE 50

Summary

50

Basics

Specify a set by enumerating all elements Notations Cardinality

Venn Diagram Relations on sets: subset, proper subset Set builder notation Set operations