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
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
Hung-Yu Kao (高宏宇) Department of Computer Science and Information Engineering, N l Ch K U National Cheng Kung University
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
For a given finite set S (|S| = N) with conditions C
2 1 2 1 2 1
) and (
2 1
c c N
2 1 1
2 1 2 1 2 1
)
( c c N
2 1c
)
(
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 – – 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 − + + +
Ex 8.3 :
)] ( ) ( ) ( ) ( ) ( ) ( [ )] ( ) ( ) ( ) ( [ ) (
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
) ( )] ( ) ( ) ( ) ( [ )] ( ) ( ) ( ) ( ) ( ) ( [ )] ( ) ( ) ( ) ( [ ) (
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
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
] 1 1 ) 1 1 ( 1 [
2 2 1 2
= + − = + + − =
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
= − + − = − + + + + + − =
] 1 [
4 4 3 4 2 4 1 4
= + − + − =
Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring
5
Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring
6
Theorem 8.1:
|S| = N conditions c 1≤ i ≤ t |S| = N, conditions ci, 1≤ i ≤ t
2 1 t
1 1 1 t k j i k j i t j i j i t i i
≤ < < ≤ ≤ < ≤ ≤ ≤
3 2 1 t t j j
Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring
7
Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring
8
Corollary 8.1: Some notation for simplifying Theorem 8.1
. )
...
(
2 1
N N c c c N
t
− =
Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring
9
Ex 8.4 : Determine the number of positive integers
Condition c if n is divisible by 2 Condition c1 if n is divisible by 2. Condition c2 if n is divisible by 3.
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 = − + + + + + − =
Ex 8.5 : Determine the number of nonnegative integer
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
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 }
range. in their have that in functions
number the is ) ( Then
1 i
b S c N
). ...... (
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
Ex 8.7 : In how many ways can the 26 letters of the
Ex 8.8 : Let φ(n) be the number of positive integers m,
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
N = S0 = n; N(ci) = n/pi; N(cicj) = n/(pipj); …
Then the answer to this problem is
4 3 2 1
Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring
13
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
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
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
Ex 8.10 : In a certain area of the countryside are five villages.
Let ci denote the condition that a system of these
C(5,2) C(4,2)
Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring
16
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
− − −
⋅ ⋅ ⋅ + ⋅ ⋅ ⋅ + ⋅ ⋅ ⋅ + ⋅ ⋅ ⋅ = ⋅ ⋅ ⋅ + ⋅ ⋅ ⋅ + ⋅ ⋅ ⋅ + ⋅ ⋅ ⋅ =
= S1-2S2+3S3 =
2 3 2 1 2 1
S S S + −
= S2 - 3S3 =
1 3 2
S S −
Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring
17
4 3 2 1 1
3 4 3 2 3 2 1 2 1
2 4 3 1 3 2 4 3 2 2
1 4 3 4 3 3 2 1
4 4
Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring
18
2 1 t m t m m
− + +
2 2 2 1 1 1 t m t t m t m m m m m m
− − + + + +
Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring
19
Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring
20
Let Lm denotes the number of elements in S that satisfy at
Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring
21
⋅ ⋅ ⋅ + − + − = − = = ⋅ ⋅ ⋅ + + + + =
∞ = − ∞ =
! 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
The general formula:
1
−
P=d /n!
Ex 8 14 : Peggy has seven books and hires seven
P=dn/n!
Ex 8.14 : Peggy has seven books and hires seven
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
In Fig. 8.6, we want to determine the number of ways in
3 2 1 4 5 6
Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring
24
In Fig. 8.6, we have r0=1, r1= 6, r2= 8, r3= 2 and rk= 0 for
Rook polynomial: r(C, x) = 1+6x+8x2+2x3. For each k ≥
3 2 1 3 2 1 4 5 6
Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring
25
Break up a larger board into smaller subboards. In Fig. 8.7, the chessboard contains two disjoint
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
r3 for C In general, if C is a chessboard made up of pairwise
1 2 n
1
Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring
27
rook here, or (c) do not use this square.
r (C) = r
(C )+r (C )
rk(C) = rk-1(Cs)+rk(Ce)
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
r0(Cs)x0 typo in p405
Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring
29
use * not use * use * not use *
Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring
30
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
(| | )
Let ci be the condition that
Ri is seated in a forbidden position but at different tables.
T1 T2 T3 T4 T5 R1
p
1
R2 R
4! + 4!
S1 = 7(4!)
R3 R4
4! + 4!
Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring
31
number of shaded squares
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.
i i
Decompose C into the disjoint subboards in the upper left and lower
right corners.
( , ) ( )( )
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
E 8 16 W ll di i i h i d di d h h
die.
(4, 5) and (6, 6).
die?
One of solutions is like (1, 1), (2, 3), (4, 4), (3, 2), (5, 6), (6, 5).
(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
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
Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring
35
B
Ex 8.17 : How many
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 ( :
) 1 ( :
2 1
= =
A
4
z y x f c x w f c f
, , ) 4 ( :
) 3 ( : ) (
4 3 2
= =
r(C, x) = (1+2x)(1+6x+9x2+2x3) = 1+8x+21x2+20x3+4x4
P(5,3)
Discrete Mathematics Discrete Mathematics – – CH8 CH8 2009 Spring 2009 Spring
36
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
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