Discrete Mathematics -- Chapter 8: The Principle of Ch t 8 Th P i - - PowerPoint PPT Presentation

discrete mathematics
SMART_READER_LITE
LIVE PREVIEW

Discrete Mathematics -- Chapter 8: The Principle of Ch t 8 Th P i - - PowerPoint PPT Presentation

Discrete Mathematics -- Chapter 8: The Principle of Ch t 8 Th P i i l f Inclusion and Exclusion Hung-Yu Kao ( ) Department of Computer Science and Information Engineering, N National Cheng Kung University l Ch K U Outline


slide-1
SLIDE 1

Discrete Mathematics

Ch t 8 Th P i i l f

  • - Chapter 8: The Principle of

Inclusion and Exclusion

Hung-Yu Kao (高宏宇) Department of Computer Science and Information Engineering, N l Ch K U National Cheng Kung University

slide-2
SLIDE 2

Outline

The Principle of Inclusion and Exclusion Generalization of the Principle Generalization of the Principle Derangements: Nothing Is in Its Right Place Rook Polynomials Arrangements with Forbidden Positions Arrangements with Forbidden Positions

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

2

slide-3
SLIDE 3

8.1 The principle of Inclusion and Exclusion

For a given finite set S (|S| = N) with conditions C

) ( )] ( ) ( [ ) (

2 1 2 1 2 1

c c N c N c N N c c N + + − =

  • For a given finite set S (|S| = N) with conditions Ci

) and (

2 1

c c N

) ( ) (

2 1 1

c c N c N − =

) ( ) ( ) (

2 1 2 1 2 1

c c N c c N N c c N ≠ − =

)

  • r

( c c N

) (

2 1c

c N ≠

)

  • r

(

2 1

c c N ) ( )] ( ) ( ) ( [ )] ( ) ( ) ( [ ) (

3 2 1 3 2 1

N N N N c N c N c N N c c c N + + − =

  • Discrete Mathematics

Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

3

) ( )] ( ) ( ) ( [

3 2 1 3 2 3 1 2 1

c c c N c c N c c N c c N − + + +

slide-4
SLIDE 4

Four sets

Ex 8.3 :

Four sets

)] ( ) ( ) ( ) ( ) ( ) ( [ )] ( ) ( ) ( ) ( [ ) (

4 3 4 2 3 2 4 1 3 1 2 1 4 3 2 1 4 3 2 1

c c N c c N c c N c c N c c N c c N c N c N c N c N N c c c c N + + + + + + + + + − =

For each element x∈S we have five cases:

) ( )] ( ) ( ) ( ) ( [ )] ( ) ( ) ( ) ( ) ( ) ( [

4 3 2 1 4 3 2 4 3 1 4 2 1 3 2 1 4 3 4 2 3 2 4 1 3 1 2 1

c c c c N c c c N c c c N c c c N c c c N c c N c c N c c N c c N c c N c c N + + + + − + + + + + +

For each element x∈S, we have five cases:

(0) x satisfies none of the four conditions; (1) x satisfies only one of the four conditions; (1) x satisfies only one of the four conditions; (2) x satisfies exactly two of the four conditions; (3) x satisfies exactly three of the four conditions;

(3) x satisfies exactly three of the four conditions;

(4) x satisfies all the four conditions.

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

4

slide-5
SLIDE 5

Four sets

) ( )] ( ) ( ) ( ) ( [ )] ( ) ( ) ( ) ( ) ( ) ( [ )] ( ) ( ) ( ) ( [ ) (

4 3 2 1 4 3 2 4 3 1 4 2 1 3 2 1 4 3 4 2 3 2 4 1 3 1 2 1 4 3 2 1 4 3 2 1

c c c c N c c c N c c c N c c c N c c c N c c N c c N c c N c c N c c N c c N c N c N c N c N N c c c c N + + + + − + + + + + + + + + − =

1.

x satisfies no condition. x is counted once in and once in N. [1=1]

2.

x satisfies c1. It is not counted on the left side. It is counted once in N and i ( ) [0 1 1 0]

) (

4 3 2 1

c c c c N

  • nce in N(c1). [0 = 1-1 = 0]

3.

x satisfies c2 and c4. It is not counted on the left side. It is counted once in N, N(c2), N(c4) and N(c2c4).

( ) ( )

2 2

4.

x satisfies c1, c2 and c4. It is not counted on the left side. It is counted

  • nce in N N(c1) N(c2) N(c4) N(c1c2) N(c1c4) N(c2c4) and N(c1c2c4)

( ) ( )

] 1 1 ) 1 1 ( 1 [

2 2 1 2

= + − = + + − =

  • nce in N, N(c1), N(c2), N(c4), N(c1c2), N(c1c4), N(c2c4) and N(c1c2c4).

5.

x satisfies all conditions. It is not counted on the left side. It is counted

( ) ( ) ( )

] 1 1 ) 1 1 1 ( ) 1 1 1 ( 1 [

3 3 2 3 1 3

= − + − = − + + + + + − =

  • nce in all the subsets on the right side.

( ) ( ) ( ) ( )

] 1 [

4 4 3 4 2 4 1 4

= + − + − =

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

5

slide-6
SLIDE 6

Four sets

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

6

slide-7
SLIDE 7

The Principle of Inclusion and Exclusion

Theorem 8.1:

|S| = N conditions c 1≤ i ≤ t |S| = N, conditions ci, 1≤ i ≤ t

  • denote the number of elements of S

that satisfy none of the conditions

) (

2 1 t

c c c N N ⋅ ⋅ ⋅ =

that satisfy none of the conditions.

(2) ) ( ) ( ) (

1 1 1 t k j i k j i t j i j i t i i

c c c N c c N c N N N ⋅ ⋅ ⋅ + − + − =

∑ ∑ ∑

≤ < < ≤ ≤ < ≤ ≤ ≤

) ( ) 1 (

3 2 1 t t j j

c c c c N ⋅ ⋅ ⋅ − +

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

7

slide-8
SLIDE 8

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

8

slide-9
SLIDE 9

The Principle of Inclusion and Exclusion

Corollary 8.1: Some notation for simplifying Theorem 8.1

. )

  • r

...

  • r
  • r

(

2 1

N N c c c N

t

− =

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

9

slide-10
SLIDE 10

The Principle of Inclusion and Exclusion

Ex 8.4 : Determine the number of positive integers

n where 1 ≤ n ≤100 and n is not divisible by 2, 3 n where 1 ≤ n ≤100 and n is not divisible by 2, 3

  • r 5.

Condition c if n is divisible by 2 Condition c1 if n is divisible by 2. Condition c2 if n is divisible by 3.

C di i if i di i ibl b 5

Condition c3 if n is divisible by 5. Then the answer to this problem is

⎣ ⎦

) ( )] ( ) ( ) ( [ )] ( ) ( ) ( [ ) (

3 2 1 3 2 3 1 2 1 3 2 1 3 2 1 3 2 1

− + + + + + − = − + − = c c c N c c N c c N c c N c N c N c N N S S S S c c c N

⎣ ⎦

16 ) 3 * 2 /( 100 =

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

10

. 26 3 ] 6 10 16 [ ] 20 33 50 [ 100 = − + + + + + − =

slide-11
SLIDE 11

The Principle of Inclusion and Exclusion

Ex 8.5 : Determine the number of nonnegative integer

solutions to the equation x1 + x2 + x3 + x4 = 18 and xi ≤ 7 for all i.

We say that a solution x1, x2, x3, x4 satisfies condition ci if xi > 7

(i.e., xi ≥ 8) .

Then the answer to this problem is

⎞ ⎛ 1 2 4

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

11

⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛ − + 18 1 18 4 ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛ − + 10 1 10 4

⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛ − + 2 1 2 4

slide-12
SLIDE 12

The Principle of Inclusion and Exclusion

Ex 8.6 : For finite sets A, B, where ⎪A⎪= m ≥ n = ⎪B⎪, and function

f: A→B, determine the number of onto functions f.

L A { } d B {b b b }

  • Let A = {a1, a2,…, am} and B = {b1, b2, …, bn}.
  • Let ci be the condition that bi is not in the range of f.

range. in their have that in functions

  • f

number the is ) ( Then

1 i

b S c N

  • Then the answer to this problem is

). ...... (

2 1 n

c c c N

( ) ( )

m n m m n m i m

S N n S n c N n S S N ) 2 ( ) 2 ( ) ( ) 1 ( ) 1 ( ) ( | |

1 1

− = ⇒ − = = = =

( )

m n m j i

n S n c c N ) 2 ( ) 2 ( ) (

2 2

− = ⇒ − =

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

12

slide-13
SLIDE 13

The Principle of Inclusion and Exclusion

Ex 8.7 : In how many ways can the 26 letters of the

alphabet be permuted so that none of the patterns car, dog, pun or byte occurs? pun, or byte occurs?

Ex 8.8 : Let φ(n) be the number of positive integers m,

where 1 ≤ m < n and gcd(m, n)=1, i.e., m and n are relatively prime. relatively prime.

Consider For 1 ≤ i ≤ 4, let ci denote that k is divisible by pi.

S ( ) / ( ) /( )

4 3 2 1

4 3 2 1 e e e e

p p p p n =

N = S0 = n; N(ci) = n/pi; N(cicj) = n/(pipj); …

Then the answer to this problem is

). (

4 3 2 1

c c c c N

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

13

slide-14
SLIDE 14

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

14

1 4 4 1 3 3 1 2 2 1 1 1

4 3 2 1

) 1 ( ) 1 ( ) 1 ( ) 1 (

− − − −

− − − −

e e e e

p p p p p p p p

slide-15
SLIDE 15

The Principle of Inclusion and Exclusion

Ex 8.9 : Six married couples are to be seated at a circular table. In how

many ways can they arrange themselves so that no wife sits next to her husband?

For 1≤ i ≤6, let ci denote the condition where a seating

arrangement has couple i seated next to each other. N(ci) = 2(11-1)! ( )

Then the answer to this problem is

). .... (

6 2 1

c c c N

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

15

slide-16
SLIDE 16

The Principle of Inclusion and Exclusion

8 10 i f h id fi ill

Ex 8.10 : In a certain area of the countryside are five villages.

An engineer is to devise a system of two-way roads so that after the system is completed, no village will be isolated. In y p g how many ways can he do this?

Let ci denote the condition that a system of these

roads isolates village a b c d and e respectively roads isolates village a, b, c, d, and e, respectively.

C(5,2) C(4,2)

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

16

slide-17
SLIDE 17

8.2 Generalizations of the Principle

  • Em denotes the number of elements in S that satisfy exactly m of the t

conditions.

  • )

( ) ( ) ( c c c c N c c c c N c c c c N E + + +

  • ).

( ) ( ) ( ). ( ) ( ) (

1 2 2 1 3 2 1 3 2 1 2 1 2 1 3 2 1 3 2 1 1 t t t t t t t t t

c c c c c N c c c c N c c c c N E c c c c N c c c c N c c c c N E

− − −

⋅ ⋅ ⋅ + ⋅ ⋅ ⋅ + ⋅ ⋅ ⋅ + ⋅ ⋅ ⋅ = ⋅ ⋅ ⋅ + ⋅ ⋅ ⋅ + ⋅ ⋅ ⋅ + ⋅ ⋅ ⋅ =

  • E1= 2+3+4=N(c1)+N(c2)+N(c3) - 2[N(c1c2)+ N(c1c3)+ N(c2c3)] + 3N(c1c2c3)

= S1-2S2+3S3 =

( ) ( ) 3

2 3 2 1 2 1

S S S + −

  • E2= 5+6+7=N(c1c2)+N(c1c3)+N(c2c3)-3N(c1c2c3)

= S2 - 3S3 =

  • E =8= N(c c c ) = S

( ) 3

1 3 2

S S −

  • E3=8= N(c1c2c3) = S3

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

17

slide-18
SLIDE 18

Generalizations of the Principle

( ) ( ) ( )

4 3 2 1 1

4 3 2 S S S S E − + − =

( ) ( ) ( ) 4

3 4 3 2 3 2 1 2 1

6 3 S S S E S S S S + − + − =

( ) ( ) 4

2 4 3 1 3 2 4 3 2 2

6 3 S S S S S S E + − = + − =

( ) ( ) ( ) 4

1 4 3 4 3 3 2 1

4 S S S S E + = − =

4 4

S E =

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

18

slide-19
SLIDE 19

Theorem 8.2

( ) ( ) ( )

(1) ) 1 (

2 1 t m t m m

S S S S E

− + +

( ) ( ) ( )

(1) . ) 1 (

2 2 2 1 1 1 t m t t m t m m m m m m

S S S S E

− − + + + +

− + ⋅ ⋅ ⋅ − + − =

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

19

slide-20
SLIDE 20

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

20

slide-21
SLIDE 21

Corollary 8.2

Let Lm denotes the number of elements in S that satisfy at

least m of the t conditions.

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

21

slide-22
SLIDE 22

8.3 Derangements: Nothing Is in Its Right Place

  • 1

⋅ ⋅ ⋅ + − + − = − = = ⋅ ⋅ ⋅ + + + + =

∑ ∑

∞ = − ∞ =

! 3 1 ! 2 1 1 1 ! ) 1 ( , ! ! 3 ! 2 1

1 3 2 n n n n x

n e n x x x x e

e-1=0.36788, 1-1+(1/2!)-(1/3!)+…-(1/7!) ≈ 0.36786

D t th t ll b i th iti

Derangement means that all numbers are in the wrong positions.

Ex 8.12 : Determine the number of derangements of 1, 2,…,10.

Let c be the condition that integer i is in the ith place Let ci be the condition that integer i is in the ith place.

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

22

slide-23
SLIDE 23

Derangements: Nothing Is in Its Right g g g Place

The general formula:

] 1 1 1 1 1 1 [ ! !

1

n e n d + + = =

P=d /n!

Ex 8 14 : Peggy has seven books and hires seven

] ! .... ! 4 ! 3 ! 2 1 1 [ ! ! n n e n dn − + − + − = =

P=dn/n!

Ex 8.14 : Peggy has seven books and hires seven

  • reviewers. She wants two reviewers per book. In how

many ways can she make the distributions? many ways can she make the distributions?

The first time: 7! ways The second time: d7=7!* e-1Ways (different position)

7

y ( p )

Totally, we have 7!×d7 ways

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

23

slide-24
SLIDE 24

8.4 Rook Polynomials

In Fig. 8.6, we want to determine the number of ways in

which k rooks can be placed on the unshaded squares of this chessboard so that no two of them can take each

  • ther—that is, no two of them are in the same row or

column of the chessboard C. This number is denoted as rk(C).

3 2 1 4 5 6

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

24

slide-25
SLIDE 25

Rook Polynomials

In Fig. 8.6, we have r0=1, r1= 6, r2= 8, r3= 2 and rk= 0 for

k ≥ 4.

Rook polynomial: r(C, x) = 1+6x+8x2+2x3. For each k ≥

0, the coefficient of xk is the number of ways we can place k nontaking rooks on chessboard C.

3 2 1 3 2 1 4 5 6

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

25

slide-26
SLIDE 26

Disjoint Subboards

Break up a larger board into smaller subboards. In Fig. 8.7, the chessboard contains two disjoint

g , j subboards that have no squares in the same column or row of C.

r(C, x) = r(C1, x) . r(C2, x)

2 4 1 ) (

2

C

C1

2 10 7 1 ) , ( 2 4 1 ) , (

3 2 2 2 1

x x x x C r x x x C r + + + = + + =

C2

) , ( ) , ( 4 28 56 40 11 1 ) , (

2 1 5 4 3 2

x C r x C r x x x x x x C r ⋅ = + + + + + =

2 Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

26

slide-27
SLIDE 27

Disjoint Subboards

f C

r3 for C In general, if C is a chessboard made up of pairwise

disjoint subboards C1, C2,…, Cn, then r(C, x) = r(C1, x). j

1 2 n

( ) (

1

) r(C2, x)…. r(Cn, x).

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

27

slide-28
SLIDE 28

Recursive Formula

  • Fig. 8.8 (a), For a given designated square (*), we either (b) place one

rook here, or (c) do not use this square.

r (C) = r

(C )+r (C )

rk(C) = rk-1(Cs)+rk(Ce)

  • Cs: denote the remaining smaller subboard (Fig. 8.8(b))
  • Ce: C with the one designed square eliminated (Fig. 8.8(c))

e

g q ( g ( ))

rk(C)xk = rk-1(Cs) xk + rk(Ce)xk for 1≤ k ≤ n.

use not use

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

28

slide-29
SLIDE 29

Recursive Formula

r0(Cs)x0 typo in p405

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

29

slide-30
SLIDE 30

Apply the Recursive Formula

use * not use * use * not use *

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

30

slide-31
SLIDE 31

8.5 Arrangements with Forbidden Positions

  • Ex 8.15 : In making seating arrangements, the shaded square of the figure

means relative Ri will not sit at table Tj.

Determine the number of ways that we can seat these four

y relatives at five different tables.

Let |S| be the total number of ways we can place the four

  • relatives. (|S| = 5!)

(| | )

Let ci be the condition that

Ri is seated in a forbidden position but at different tables.

T1 T2 T3 T4 T5 R1

p

  • N(c1) = 4! + 4! (R1→ T1 or R1→ T2)
  • N(c2) = 4! (R2→ T2)
  • N(c3) = ?

1

R2 R

4! + 4!

  • N(c4) = ?

S1 = 7(4!)

R3 R4

4! + 4!

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

31

number of shaded squares

slide-32
SLIDE 32

Arrangements with Forbidden Positions

  • S2 = 16(3!)

N(c1c2) = 3! (R1→ T1 or R2→ T2) N(c1c3) = 4(3!) N(c1c4) = ?, N(c2c3) = ?, N(c2c4) = ?, N(c3c4) = ?

Observation: 16 is the number of ways two nontaking rooks can be

placed on the shaded chessboard.

Let ri be the number of ways in which it is possible to place i nontaking

rooks on the shaded chessboard.

  • For all 0 ≤ i ≤ 4, Si = ri(5 - i)!

i i

Decompose C into the disjoint subboards in the upper left and lower

right corners.

  • r(C, x)=(1 + 3x + x2)(1 + 4x + 3x2) = 1 + 7x + 16x2 + 13x3 + 3x4

( , ) ( )( )

2 )! ( ) 1 ( ) ! 1 ( 3 ) ! 2 ( 13 ) ! 3 ( 16 ) ! 4 ( 7 ) ! 5 ( 1 ) (

4 4 3 2 1 4 3 2 1

+ − + − = + − + − = ∴

i

S S S S S c c c c N

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

32

25 )! 5 ( ) 1 ( = − − =∑

= i i i

i r

slide-33
SLIDE 33

Arrangements with Forbidden Positions

E 8 16 W ll di i i h i d di d h h

  • Ex 8.16 : We roll two dice six times, where one is red die and the other green

die.

  • We know the following pairs did not occur: (1, 2), (2, 1), (2, 5), (3, 4), (4, 1),

(4, 5) and (6, 6).

  • What is the probability that we obtain all six values both on red die and green

die?

One of solutions is like (1, 1), (2, 3), (4, 4), (3, 2), (5, 6), (6, 5).

  • In Fig. 8.10(b), chessboard C with seven shaded squares

(C ) (1+4 +2 2)(1+ )3 1+7 +17 2+19 3+10 4+2 5

r(C, x) = (1+4x+2x2)(1+x)3 = 1+7x+17x2+19x3+10x4+2x5 ci denotes that all six values occur on both the red and green dies,

but i on the red die is paired with one of the forbidden numbers on p the green die.

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

33

slide-34
SLIDE 34

Figure 8 10

1 2 3 4 5 6 1 5 3 4 2 6

(b) Figure 8.10 (a)

1 2 1 2 2 3 2 4 4 5 3 5 6 6

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

34

slide-35
SLIDE 35

Arrangements with Forbidden Positions Arrangements with Forbidden Positions

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

35

slide-36
SLIDE 36

Arrangements with Forbidden Positions

B

Ex 8.17 : How many

  • ne-to-one functions f: A → B

ti f f th f ll i

u v w x y z 1

B

satisfy none of the following conditions:

1 2 3

w f c v u f c ) 2 ( :

  • r

) 1 ( :

2 1

= =

A

4

z y x f c x w f c f

  • r

, , ) 4 ( :

  • r

) 3 ( : ) (

4 3 2

= =

r(C, x) = (1+2x)(1+6x+9x2+2x3) = 1+8x+21x2+20x3+4x4

  • P(6,4)

P(5,3)

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

36

slide-37
SLIDE 37

Arrangements with Forbidden Positions

1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

37

slide-38
SLIDE 38

Exercises

You should explain your answers in

detail, only one-line answer will be rated detail, only one line answer will be rated

8-1: 6, 13, 16

8-2: 5 8-2: 5 8-3: 6, 10 8-4,5: 5, 12 (add f(5)≠z)

How many integers n are such that 0≤n<10,000 and the sum of

Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring

38

y g , the digits is less than or equal to 27?