34
Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science University of KwaZulu-Natal Pietermaritzburg Campus Semester 1, 2013 Tong-Viet (UKZN) MATH236 Semester 1, 2013 1 / 34

Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

  • Upload
    others

  • View
    12

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

Discrete Mathematics with ApplicationsMATH236

Dr. Hung P. Tong-Viet

School of Mathematics, Statistics and Computer ScienceUniversity of KwaZulu-Natal

Pietermaritzburg Campus

Semester 1, 2013

Tong-Viet (UKZN) MATH236 Semester 1, 2013 1 / 34

Page 2: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

Table of contents

1 Combination with repetition

2 The inclusion-Exclusion Principle

3 Infinite Sets

Tong-Viet (UKZN) MATH236 Semester 1, 2013 2 / 34

Page 3: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

Combination with repetition

Combinations with repetition

Example

Suppose that a cookies shop has four different kinds of cookies. Howmany different ways can six cookies be chosen? Assume that only the typeof cookie, and not the individual cookies or the order in which they arechosen, matters.

Tong-Viet (UKZN) MATH236 Semester 1, 2013 3 / 34

Page 4: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

Combination with repetition

Combinations with repetition

Proof.

1 As the order in which each cookie is chosen does not matter and eachkind of cookies can be chosen as many as 6 times, the number ofways these cookies can be chosen is the number of 6-combinationwith repetition allowed from a set with 4 distinct elements.

2 We use 3 ‘bar’ to separate each type of cookies

3 each cookie is represented by a star

4 The choice of six cookies correspond to placing 6 stars into thecompartment separated by the three bars

5 Thus, there are(3+6

3

)=(3+6

6

)ways to choose six cookies from four

different kinds of cookies.

Tong-Viet (UKZN) MATH236 Semester 1, 2013 4 / 34

Page 5: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

Combination with repetition

Combinations with repetition

Theorem

There are (n + r − 1

r

)=

(n + r − 1

n − 1

)r -combinations from a set with n distinct elements when repetition ofelements is allowed.

Proof.

1 Each r -combination of a set with n elements when repetition isallowed can be represented by a list of n − 1 bars and r stars

Tong-Viet (UKZN) MATH236 Semester 1, 2013 5 / 34

Page 6: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

Combination with repetition

Combinations with repetition

Proof.

1 The n − 1 bars are used to mark off n different cells with the ith cellcontaining a star for each time the ith element of the set occurs inthe combination

2 Each different list containing n − 1 bars and r stars corresponds to anr -combination of the set with n elements when repetition is allowed

3 Clearly, the number of such list is(n+r−1

n−1

)because each list

corresponds to a choice of the n − 1 positions to place n − 1 bars OR

4(n+r−1

r

)because each list corresponds to a choice of the r positions

to place the r stars from the n + r − 1 positions that contains r starsand n − 1 bars.

Tong-Viet (UKZN) MATH236 Semester 1, 2013 6 / 34

Page 7: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

Combination with repetition

Combinations with repetition

Example

How many solutions does the equation

x1 + x2 + x3 = 10

have, where x1, x2, x3 are nonnegative integers?

Tong-Viet (UKZN) MATH236 Semester 1, 2013 7 / 34

Page 8: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

Combination with repetition

Combinations with repetition

Proof.

Each solution corresponds to a way of selecting 10 items from a setwith three different elements, where we have chosen

x1 items of type 1

x2 items of type 2 and

x3 items of type 3

Hence, the number of solutions is equal to the number of10-combinations with repetition allowed from a set with threeelements. It follows that there are(

10 + 3− 1

10

)solutions.

Tong-Viet (UKZN) MATH236 Semester 1, 2013 8 / 34

Page 9: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

Combination with repetition

Permutations with indistinguishable objects

In cases when some elements may be indistinguishable in countingproblems. We should be more careful as the same things may be countedmore than once.

Example

How many different words can be made by reordering the letters of theword SUCCESS ?

Tong-Viet (UKZN) MATH236 Semester 1, 2013 9 / 34

Page 10: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

Combination with repetition

Permutations with indistinguishable objects

Proof.

As some of the letters of SUCCESS are the same, the answer is notgiven by the number of permutations of seven letters

There are three Ss, two Cs and one U and one E

The three Ss can be placed among 7 positions in(7

3

)ways

This leaves four different positions free

Then the two Cs can be placed in(4

2

)ways

This leaves two free positions

The U can be placed in(2

1

)ways, leaving just one position free.

Hence E can be placed in(1

1

)ways

Therefore, by the Multiplication Principle, there are(7

3

)·(

4

2

)·(

2

1

)·(

1

1

)=

7!

3!2!1!1!

different words.Tong-Viet (UKZN) MATH236 Semester 1, 2013 10 / 34

Page 11: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

Combination with repetition

Permutations with indistinguishable objects

Theorem

The number of different permutations of n objects, where there are n1

indistinguishable objects of type 1, n2 indistinguishable objects of type 2,· · · , and nk indistinguishable objects of type k , is

P(n; n1, n2, · · · , nk) =n!

n1!n2! · · · nk !.

Tong-Viet (UKZN) MATH236 Semester 1, 2013 11 / 34

Page 12: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

The inclusion-Exclusion Principle

The Inclusion-Exclusion Principle

The Addition Principle gives a formula for the number of objects in aunion of sets provided that the sets do not overlap

The Inclusion-Exclusion Principle gives a more general formula thatcan be applied to collections of sets with nonempty intersections

Let S be a set, each of whose objects may have one or both of twoproperties, P1 or P2

Suppose we want to count the number of objects of S that haveneither property P1 nor property P2

Tong-Viet (UKZN) MATH236 Semester 1, 2013 12 / 34

Page 13: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

The inclusion-Exclusion Principle

The Inclusion-Exclusion Principle

This number is obtained by taking the number of objects in the set S

subtracting from that the number of objects with property P1 and thenumber of objects with property P2

noting that those objects which have both properties P1 and P2 weresubtracted twice

So we add back in that number of objects

In other words, if S1 and S2 are the sets of all objects with propertiesP1,P2, respectively

|S1 ∩ S2| = |S | − |S1| − |S2|+ |S1 ∩ S2|

Tong-Viet (UKZN) MATH236 Semester 1, 2013 13 / 34

Page 14: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

The inclusion-Exclusion Principle

The Inclusion-Exclusion Principle

Theorem

The number of objects of S that have none of the propertiesP1,P2, · · · ,Pn is given by

|S1 ∩ S2 ∩ · · · ∩ Sn| = |S | −∑|Si |+

∑|Si ∩ Sj | −

∑|Si ∩ Sj ∩ Sk |

+ · · ·+ (−1)n|S1 ∩ S2 ∩ · · · ∩ Sn|

Tong-Viet (UKZN) MATH236 Semester 1, 2013 14 / 34

Page 15: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

The inclusion-Exclusion Principle

The Inclusion-Exclusion Principle

Proof.

We prove this result by establishing that

(i) every element of S1 ∩ S2 ∩ · · · ∩ Sn makes a net contribution of 1 to theright hand side

(ii) every other element makes a net contribution of 0 to the right handside

Consider first an element x ∈ S1 ∩ S2 ∩ · · · ∩ Sn

Then x ∈ S but x 6∈ Si for all i

Thus the contribution that x makes to the right hand side is

1− 0 + 0 + · · ·+ (−1)n0 = 1

Tong-Viet (UKZN) MATH236 Semester 1, 2013 15 / 34

Page 16: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

The inclusion-Exclusion Principle

The Inclusion-Exclusion Principle

Consider y 6∈ S1 ∩ S2 ∩ · · · ∩ Sn.

Suppose that y satisfies t ≥ 1 of the properties P1,P2, · · · ,Pn

Then y makes a contribution of 1 =(t

0

)to |S |

It contributes 1 to(t

1

)of the quantities |Si |

and 1 to(t

2

)of the quantities |Si ∩ Sj |

and 1 of the quantities |Si ∩ Sj ∩ Sk | and so on.

Thus, its net contribution to the right hand side is(t

0

)−(

t

1

)+

(t

2

)+ · · ·+ (−1)t

(t

t

)The result follows as this expression is 0.

Tong-Viet (UKZN) MATH236 Semester 1, 2013 16 / 34

Page 17: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

The inclusion-Exclusion Principle

Example

Example

How many permutations of the letters

i , n, t, h, e, d , o, c , k

are such that none of the words in, the, and dock occur as consecutiveletters?

Let S be the set of all permutations of the letters{i , n, t, h, e, d , o, c , k}.Let P1 be the property that the word in occurs

P2 be the property that the word the occurs

P3 be the property that the word dock occurs

Let Si be the number of words that has property Pi

Tong-Viet (UKZN) MATH236 Semester 1, 2013 17 / 34

Page 18: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

The inclusion-Exclusion Principle

Example

Every permutation in S1 is a permutation of the eight symbols

in, t, h, e, d , o, c , k

Thus |S1| = 8!

Similarly, every permutation in S2 is a permutation of the sevensymbols

the, i , n, d , o, c, k

So, |S2| = 7!

Similarly, |S3| = 6!

Now S1 ∩ S2 consists of all permutations of the six symbols

in, the, d , o, c , k

Tong-Viet (UKZN) MATH236 Semester 1, 2013 18 / 34

Page 19: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

The inclusion-Exclusion Principle

Example

so |S1 ∩ S2| = 6!

Similarly, |S1 ∩ S3| = 5! and |S2 ∩ S3| = 4!

Finally, S1 ∩ S2 ∩ S3 consists of all permutations of the three symbols

in, the, dock

This implies that |S1 ∩ S2 ∩ S3| = 3!

Applying the previous theorem, we obtain that|S1 ∩ S2 ∩ S3| = 9!− 8!− 7!− 6! + 6! + 5! + 4!− 3!

Tong-Viet (UKZN) MATH236 Semester 1, 2013 19 / 34

Page 20: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

The inclusion-Exclusion Principle

Inclusion-Exclusion Principle

Corollary

The number of objects of S that has at least one of the propertiesP1,P2, · · · ,Pn is given by

|S1∪S2∪· · ·∪Sn| =∑|Si |−

∑|Si ∩Sj |+ · · ·+(−1)n+1|S1∩S2∩· · ·∩Sn|

Tong-Viet (UKZN) MATH236 Semester 1, 2013 20 / 34

Page 21: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

The inclusion-Exclusion Principle

Inclusion-Exclusion Principle

Example

How many numbers between 0 and 100 are divisible by 2, 3 or 5?

Proof.

Let P2 be the property that a number is divisible by 2

Let P3 be the property that a number is divisible by 3, and

Let P5 be the property that a number is divisible by 5.

For i = 2, 3, 5, let Si be the numbers between 0 and 100 that hasproperty Pi

We need to find |S2 ∪ S3 ∪ S5|,

Tong-Viet (UKZN) MATH236 Semester 1, 2013 21 / 34

Page 22: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

The inclusion-Exclusion Principle

Inclusion-Exclusion Principle

Proof.

There are 51 numbers between 0 and 100 with property P2,

34 with property P3

21 with property P5

A number is divisible both both 2 and 3 iff it is divisible by 6

There are 17 such numbers and so |S2 ∩ S3| = 17

Similarly, |S2 ∩ S5| = 11 and |S3 ∩ S5| = 7.

FInally, |S2 ∩ S3 ∩ S5| = 4

Tong-Viet (UKZN) MATH236 Semester 1, 2013 22 / 34

Page 23: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

The inclusion-Exclusion Principle

Inclusion-Exclusion Principle

Proof.

By the Inclusion-Exclusion Principle, we have

|S2 ∪ S3 ∪ S5| = |S2|+ |S3|+ |S5| − |S2 ∩ S3| − |S2 ∩ S5| − |S3 ∩ S5|+|S2 ∩ S3 ∩ S5|

= 51 + 34 + 21− 17− 11− 7 + 4= 75

Tong-Viet (UKZN) MATH236 Semester 1, 2013 23 / 34

Page 24: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

Infinite Sets

Infinite sets

In this section, we briefly consider how to count infinite sets

Recall that a function f : X −→ Y is onto if for every y ∈ Y , thereexists x ∈ X such that f (x) = y or equivalently, if ranf = Y .

A function is called a bijection if it is both one-to-one and onto

When we count, we establish a bijection between the set we arecounting and the set of natural numbers.

Definition

Two sets A and B have the same cardinality, written |A| = |B| if there is abijection between them.

Tong-Viet (UKZN) MATH236 Semester 1, 2013 24 / 34

Page 25: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

Infinite Sets

Infinite sets

Example

Let A = {3, 4, 5, 6} and B = {5, 6, 7, 8}. Then the function f : A −→ Bwith the rule f (x) = x + 2 is a bijection, so |A| = |B|.

Example

Let A = {2, 3, 4, 5} and B = {1, 2, 3}. Then there is no bijection betweenthese two sets because any one-to-one function with domain A must havea range with cardinality at least 4, but B has only 3 elements.

Example

Let A = N be the set of positive integers and B = {2, 4, 6, · · · } be the setof all positive even integers. Notice that B is a proper subset of A.However, the function f : A −→ B with the rule f (x) = 2x is a bijectionfrom A to B. Thus A and B have the same cardinality.

Tong-Viet (UKZN) MATH236 Semester 1, 2013 25 / 34

Page 26: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

Infinite Sets

Infinite sets

Example

Consider the function f : (0, 1) −→ R given by f (x) = tan(πx − π/2).This function is a bijection between (0, 1) and R. Thus |(0, 1)| = |R|.

We introduce some new notation:

|N| = ℵ0

and

|R| = ℵ1

Tong-Viet (UKZN) MATH236 Semester 1, 2013 26 / 34

Page 27: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

Infinite Sets

Infinite sets

Definition

A set with cardinality ℵ0 is denumerable.

A set that is either finite or denumerable is countable

A set that is not countable is uncountable

Theorem

ℵ0 6= ℵ1.

Tong-Viet (UKZN) MATH236 Semester 1, 2013 27 / 34

Page 28: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

Infinite Sets

Infinite sets

Proof.

We know that |(0, 1)| = |R| = ℵ1

It suffices to show that there is no bijection from N to (0, 1)

Suppose to the contrary that there is a bijection f : N −→ (0, 1)

For any x ∈ N, f (x) ∈ (0, 1) i.e., a number that can be writtenuniquely in the form 0.x1x2x3 · · · .Here we identify 0.199999999 · · · with 0.2 and so on.

Tong-Viet (UKZN) MATH236 Semester 1, 2013 28 / 34

Page 29: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

Infinite Sets

Infinite sets

Proof.

f (1) = 0.x11x12x13x14x15 · · ·f (2) = 0.x21x22x23x24x25 · · ·f (3) = 0.x31x32x33x34x35 · · ·f (4) = 0.x41x42x43x44x45 · · ·f (5) = 0.x51x52x53x54x55 · · ·...

......

f (n) = 0.xn1xn2xn3xn4xn5 · · ·

Tong-Viet (UKZN) MATH236 Semester 1, 2013 29 / 34

Page 30: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

Infinite Sets

Infinite sets

Proof.

Define y = 0.y1y2y3 · · · as follows:

yi =

{1 if xii 6= 12 if xii = 1

Notice that y ∈ (0, 1) and there is no n ∈ N such that f (n) = ybecause the nth digits of f (n) and y are not equal.

Hence f is not onto, which contradicts our assumption that f is abijection.

Thus there is no bijection from N to (0, 1)

Therefore, ℵ0 6= ℵ1.

Tong-Viet (UKZN) MATH236 Semester 1, 2013 30 / 34

Page 31: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

Infinite Sets

Infinite sets

Theorem

|Q| = ℵ0.

Proof.

We first show that the positive rational numbers Q+ are countable

Construct a table in which the entry in row i and column j is therational number i

j

Every positive rational number occurs somewhere in the table

Tong-Viet (UKZN) MATH236 Semester 1, 2013 31 / 34

Page 32: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

Infinite Sets

Infinite sets

1 2 3 4 · · ·1 1

112

13

14 · · ·

2 21

22

23

24 · · ·

3 31

32

33

34 · · ·

4 41

42

43

44 · · ·

... · · · · · · · · · · · · . . .

Tong-Viet (UKZN) MATH236 Semester 1, 2013 32 / 34

Page 33: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

Infinite Sets

Infinite sets

We now define a bijection f : N −→ Q+.

Let f (1) = 11

Then follow the arrow on the table from 11 , we obtain f (2) = 1

2

Notice that each rational number may occur more than once.

When we trace our way through the table, if we come across arational number we’re already met, we omit it

Thus, we have a bijection f : N −→ Q+.

It remains to establish a bijection between N and Q.

Tong-Viet (UKZN) MATH236 Semester 1, 2013 33 / 34

Page 34: Discrete Mathematics with Applications MATH236 11.pdf · Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science

Infinite Sets

Infinite sets

We define a function g as follows:

g(1) = 0g(2) = f (1)g(3) = −f (1)g(4) = f (2)g(5) = −f (2)

......

...

Thus this is clearly a bijection from N to Q.

Tong-Viet (UKZN) MATH236 Semester 1, 2013 34 / 34