chapter 6 the inclusion-exclusion principle and …myweb.scu.edu.tw/~wchuang/chapter6.pdfthe...

59
Chapter 6 The Inclusion-Exclusion Principle and Applications 1 The Inclusion-Exclusion Principle 2 Combinations with repetition 3 Derangements 4 Surjective Functions and The Euler Phi Function 5 Permutations with Forbidden Position Problem 6 Rook Polynomial 7 Another Forbidden Position Problem 8 Generalization of Inclusion-Exclusion Principle November 21, 2016 1 / 59

Upload: dinhdat

Post on 21-Mar-2018

283 views

Category:

Documents


1 download

TRANSCRIPT

Chapter 6 The Inclusion-Exclusion Principle andApplications

1 The Inclusion-Exclusion Principle2 Combinations with repetition3 Derangements4 Surjective Functions and The Euler Phi Function5 Permutations with Forbidden Position Problem6 Rook Polynomial7 Another Forbidden Position Problem8 Generalization of Inclusion-Exclusion Principle

November 21, 2016 1 / 59

The Inclusion-Exclusion PrincipleLet S be a finite set, and let A, B, C be subsets of S. Then

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

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

Let P1,P2, · · · ,Pn be properties to the objects in S. For 1 ≤ i ≤ n,

Ai = {x ∈ S | x has the property Pi}.

.Theorem..

......

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

|A1 ∩ A2 ∩ · · · ∩ An| = |S| −∑

i|Ai|+

∑i<j

|Ai ∩ Aj| −∑

i<j<k|Ai ∩ Aj ∩ Ak|

+ · · ·+ (−1)n|A1 ∩ A2 ∩ · · · ∩ An|

November 21, 2016 2 / 59

The Inclusion-Exclusion Principle

Proof. To show the identity by showing that an object with none of theproperties makes a net contribution of 1 to the right side, and for anobject with at least one of the properties makes a net contribution of 0 tothe right side.

1 x without any properties. Then x to the right side of is

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

2 x with exactly r properties. Then x to the right side is(r0

)−(

r1

)+

(r2

)−(

r3

)+ · · ·+ (−1)r

(rr

)= (1− 1)r = 0

November 21, 2016 3 / 59

The Inclusion-Exclusion Principle

.Corollary..

......

The number of objects of S which have at least one property ofP1,P2, · · · ,Pn is given by

|A1 ∪ A2 ∪ · · · ∪ An| =∑

i|Ai| −

∑i<j

|Ai ∩ Aj|+∑

i<j<k|Ai ∩ Aj ∩ Ak|

− · · ·+ (−1)n+1|A1 ∩ A2 ∩ · · · ∩ An|

Proof. By the DeMorgan law,

|A1 ∪ A2 ∪ · · · ∪ An| = |S| − |A1 ∪ A2 ∪ · · · ∪ An|= |S| − |A1 ∩ A2 ∩ · · · ∩ An|

The formula is obtained by the result of above theorem.

November 21, 2016 4 / 59

The Inclusion-Exclusion Principle.Example..

......Find the number of integers between 1 and 1000 that are not divisible by5, 6, and 8.

Let S = {1, 2, · · · , 1000}.P1: integer in S that is divisible by 5.P2: integer in S that is divisible by 6.P3: integer in S that is divisible by 8.Then the number of integers in S not divisible by 5, 6, and 8 whichhave none of the properties P1, P2, and P3.Ai = {x ∈ S | x has property Pi}, 1 ≤ i ≤ 3.

|A1 ∩ A2 ∩ A3| = |S| − (|A1|+ |A2|+ |A3|) + (|A1 ∩ A2|+|A1 ∩ A3|+ |A2 ∩ A3|)− |A1 ∩ A2 ∩ A3|

November 21, 2016 5 / 59

The Inclusion-Exclusion Principle

Integer in |A1 ∩ A2| are divisible by 5 and 6 (i.e. divisible by lcm{5,6}).lcm{5, 6}=30lcm{5, 8}=40lcm{6, 8}=24lcm{5, 6, 8}=120

|S| = 1000|A1| = ⌊10005 ⌋ = 200|A2| = ⌊10006 ⌋ = 166|A3| = ⌊10008 ⌋ = 125

|A1 ∩ A2| = ⌊100030 ⌋ = 33|A1 ∩ A3| = ⌊100040 ⌋ = 25|A2 ∩ A3| = ⌊100024 ⌋ = 41

|A1 ∩ A2 ∩ A3| = ⌊1000120 ⌋ = 8|A1 ∩A2 ∩A3| = 1000− (200+166+125)+ (33+25+41)− 8 = 600

November 21, 2016 6 / 59

The Inclusion-Exclusion Principle.Example..

......

How many permutations of the letters

M,A,T,H, I,S,F,U,N

are there such that none of the words MATH, IS, and FUN occur?

Let S is the set of permutation of 9 letters.P1: permutation in S containing MATH.P2: permutation in S containing IS.P3: permutation in S containing FUN.Ai = {π ∈ S | π has property Pi}, 1 ≤ i ≤ 3.

|A1 ∩ A2 ∩ A3| = |S| − (|A1|+ |A2|+ |A3|) + (|A1 ∩ A2|+|A1 ∩ A3|+ |A2 ∩ A3|)− |A1 ∩ A2 ∩ A3|

November 21, 2016 7 / 59

The Inclusion-Exclusion Principle|S|=9!=362880π ∈ A1 is permutations of six symbols

MATH, I,S,F,U,NHence |A1| = 6! = 720

π ∈ A2 is permutations of eight symbolsM,A,T,H, IS,F,U,N

Hence |A2| = 8! = 40320

π ∈ A3 is permutations of seven symbolsM,A,T,H, I,S,FUN

Hence |A3| = 7! = 5040

π ∈ A1 ∩ A2 is permutations of five symbolsMATH, IS,F,U,N

Hence |A1 ∩ A2| = 5! = 120

November 21, 2016 8 / 59

π ∈ A1 ∩ A3 is permutations of four symbols

MATH, I,S,FUN

Hence |A1 ∩ A3| = 4! = 24

π ∈ A2 ∩ A3 is permutations of six symbols

M,A,T,H, IS,FUN

Hence |A2 ∩ A3| = 6! = 720

π ∈ A1 ∩ A2 ∩ A3 is permutations of three symbols

MATH, IS,FUN

Hence |A1 ∩ A2 ∩ A3| = 3! = 6

|A1 ∩ A2 ∩ A3| =362880− (720 + 40320 + 5040) + (120 + 24 + 720)− 6 = 317658

November 21, 2016 9 / 59

The Inclusion-Exclusion Principle

若 Ai1 ∩ Ai2 ∩ · · · · · ·Aik 只與 k 有關, 與此 k 個集合無關.Let

α0 = |S|α1 = |A1| = |A2| = · · · = |An|α2 = |A1 ∩ A2| = |A1 ∩ A3| = · · · = |An−1 ∩ An|· · ·αn = |A1 ∩ A2 ∩ · · · ∩ An|

Then

|A1∩A2∩· · ·∩An| = α0−(

n1

)α1+

(n2

)α2−

(n3

)α3+ · · ·+(−1)n

(nn

)αn

November 21, 2016 10 / 59

The Inclusion-Exclusion Principle.Example..

......How many intergers between 0 and 99999(inclusive) both have the digits2, 5, and 8? (245823, 2258=02258, 25825 YES; 25254, 57913, ... NO)

Let S is the set of integers between 0 and 99999.P1: integers in S not containing 2.P2: intergers in S not containing 5.P3: integers in S not containing 8.Ai = {k ∈ S | k has property Pi}, 1 ≤ i ≤ 3.We want to count

|A1 ∩ A2 ∩ A3| = α0 −(3

1

)α1 +

(3

2

)α2 −

(3

3

)α3

α0 = 105

November 21, 2016 11 / 59

The Inclusion-Exclusion Principle

α1 = |A1| = |A2| = |A3| = 95

α2 = |A1 ∩ A2| = |A2 ∩ A3| = |A1 ∩ A3| = 85

α3 = |A1 ∩ A2 ∩ A3| = 75

|A1 ∩ A2 ∩ A3| = 105 − 3× 95 + 3× 85 − 75 = 4350

November 21, 2016 12 / 59

Combinations with Repetition

.Example..

......Find the number of 10-combinations of multiset M = {3a, 4b, 5c}.

Let S be the set of 10-combinations of the multisetM′ = {∞a,∞b,∞c}.P1: 10-combination of M′ with more than 3 a’sP2: 10-combination of M′ with more than 4 b’sP3: 10-combination of M′ with more than 5 c’sThen the number of 10-combinations of M is the number of10-combinations of M′ which have none of the properties P1, P2, andP3.Ai = {X ∈ S | X has property Pi}, 1 ≤ i ≤ 3.

November 21, 2016 13 / 59

Combinations with Repetition

|A1 ∩ A2 ∩ A3| = |S| − (|A1|+ |A2|+ |A3|) + (|A1 ∩ A2|+|A1 ∩ A3|+ |A2 ∩ A3|)− |A1 ∩ A2 ∩ A3|

|S| = H310 =

(3+10−1

10

)=

(1210

)= 66

|A1| = H36 =

(3+6−1

6

)=

(86

)= 28

|A2| = H35 =

(3+5−1

5

)=

(75

)= 21

|A3| = H34 =

(3+4−1

4

)=

(64

)= 15

|A1 ∩ A2| = H31 =

(3+1−1

1

)=

(31

)= 3

|A1 ∩ A3| = H30 =

(3+0−1

0

)=

(20

)= 1

|A2 ∩ A3| = 0|A1 ∩ A2 ∩ A3| = 0

|A1 ∩ A2 ∩ A3| = 66− (28 + 21 + 15) + (3 + 1 + 0)− 0 = 6

Remark: The six 10-combinations are listed as follows {3a,4b,3c}, {3a, 3b,4c}, {3a, 2b, 5c}, {2a, 4b, 4c}, {2a, 3b, 5c}, {a, 4b, 5c}

November 21, 2016 14 / 59

Combinations with Repetition.Example..

......

Find the number of integral solutions of the equation

x1 + x2 + x3 + x4 = 15

which satisfy the conditions

2 ≤ x1 ≤ 6,−2 ≤ x2 ≤ 1, 0 ≤ x3 ≤ 6, 3 ≤ x4 ≤ 8

Let y1 = x1 − 2, y2 = x2 + 2, y3 = x3, and y4 = x4 − 3.Find the number of nonnegative integral solutions of the equation

y1 + y2 + y3 + y4 = 12

which satisfy the conditions

0 ≤ y1 ≤ 4, 0 ≤ y2 ≤ 3, 0 ≤ y3 ≤ 6, 0 ≤ y4 ≤ 5

November 21, 2016 15 / 59

Combinations with RepetitionLet S be the set of all nonnegative integral solutions of the equationy1 + y2 + y3 + y4 = 12.|S| = H4

12 =(4+12−1

12

)=(1512

)= 455

P1: the property that y1 ≥ 5P2: the property that y2 ≥ 4P3: the property that y3 ≥ 7P4: the property that y4 ≥ 6Let Ai denote the subset of S consisting of the solutions satisfying theproperty Pi, 1 ≤ i ≤ 4.For A1,

y1 + y2 + y3 + y4 = 12

which satisfy the conditionsy1 ≥ 5, y2 ≥ 0, y3 ≥ 0, y4 ≥ 0

(y1 − 5) + y2 + y3 + y4 = 12− 5 = 7

|A1| = H47 =

(4+7−1

7

)=(107

)= 120

November 21, 2016 16 / 59

Combinations with Repetition

|A2| = H48 =

(4+8−1

8

)=

(118

)= 165

|A3| = H45 =

(4+5−1

5

)=

(85

)= 56

|A4| = H46 =

(4+6−1

6

)=

(96

)= 84

For A1 ∩ A2,y1 + y2 + y3 + y4 = 12

which satisfy the conditions

y1 ≥ 5, y2 ≥ 4, y3 ≥ 0, y4 ≥ 0

(y1 − 5) + (y2 − 4) + y3 + y4 = 12− 5− 4 = 3

|A1 ∩ A2| = H43 =

(4+3−1

3

)=(63

)= 20

|A1 ∩ A3| = 1, |A1 ∩ A4| = 4, |A2 ∩ A3| = 4, |A2 ∩ A4| = 10

November 21, 2016 17 / 59

Combinations with Repetition

For |A3 ∩ A4| = 0 by

y1 + y2 + (y3 − 7) + (y4 − 6) = 12− 7− 6 = −1

|A1 ∩ A2 ∩ A3| = 0, |A1 ∩ A2 ∩ A4| = 0, |A1 ∩ A3 ∩ A4| = 0,|A2 ∩ A3 ∩ A4| = 0, |A1 ∩ A2 ∩ A3 ∩ A4| = 0

|A1∩A2∩A3∩A4| = 455−(120+165+56+84)+(20+1+4+4+10) = 69

.Definition..

......

A permutation π on {1, 2, · · · , n} is called a derangement of order n ifπ(i) ̸= i, for all 1 ≤ i ≤ n.Denote by Dn the number of derangements of {1, 2, · · · , n}.

Remark: D1 = 0,D2 = 1,D3 = 2, i.e.(2, 3, 1), (3, 1, 2),D4 = 92 1 4 32 3 4 12 4 1 3

3 1 4 23 4 1 23 4 2 1

4 1 2 34 3 1 24 3 2 1

November 21, 2016 18 / 59

Derangements.Theorem........For n ≥ 1, Dn = n!(1− 1

1! +12! −

13! · · ·+ (−1)n 1

n!)

Let S be the set of all permutations of {1, 2, · · · , n}. Then |S| = n!Pi: the property that π ∈ S with π(i) = i, for 1 ≤ i ≤ n.Ai = {π ∈ S | π satisfying the property Pi}, where 1 ≤ i ≤ n.Dn = |A1 ∩ A2 ∩ · · · ∩ An|For π ∈ A1, then π = 1i2i3 . . . in. Therefore π can be written apermutation of the set {2, 3, · · · , n}, thus |A1| = (n − 1)!.For π ∈ A1 ∩ A2, then π = 12i3 . . . in. Therefore π can be written apermutation of the set {3, 4 · · · , n}, thus |A1 ∩ A2| = (n − 2)!.For each π ∈ Ai1 ∩ Ai2 ∩ · · · ∩ Aik , then π(ij) = ij for 1 ≤ j ≤ k.Therefore π can be written a permutation of the set{1, 2, · · · , n} \ {i1, i2, · · · , ik}. Thus |Ai1 ∩ Ai2 ∩ · · · ∩ Aik | = (n − k)!

November 21, 2016 19 / 59

Derangements

Dn = |A1 ∩ A2 ∩ · · · ∩ An|

= |S|+n∑

k=1

(−1)k∑

i1<i2<···<ik|Ai1 ∩ Ai2 ∩ · · · ∩ Aik |

= n! +n∑

k=1

(−1)k∑

i1<i2<···<ik(n − k)!

= n! +n∑

k=1

(−1)k(

nk

)(n − k)! = n!

n∑k=0

(−1)k

k!

.Example..

......

At a party there are n men and n women. How many ways can the nwomen choose male partners for the first dance? How many ways arethere for the second dance if everyone has to change partners?

November 21, 2016 20 / 59

Derangements.Recurrence relation of Dn..

......

Dn = (n − 1)(Dn−1 + Dn−2), n ≥ 3

andDn = nDn−1 + (−1)n, n ≥ 2

Let Sk denote the set of derangements of order n with the patternka2a3 · · · an, where k = 2, 3, · · · , n.Sk can be partitioned into two types: ka2a3 · · · ak · · · an (ak ̸= 1) andka2a3 · · · ak−11ak+1 · · · an (ak = 1)The first type can be considered as derangements on{2, 3, · · · , k − 1, k, k + 1, · · · , n} with n − 1 symbols, relacing k by 1.The second type can be considered as derangements of{2, 3, · · · , k − 1, k + 1, · · · , n} with n − 2 symbols.We thus obtain the recurrence relation

Dn = (n − 1)(Dn−1 + Dn−2), n ≥ 3

November 21, 2016 21 / 59

Derangements

Rewrite Dn − nDn−1 = −(Dn−1 − (n − 1)Dn−2), n ≥ 3

Dn − nDn−1 = (−1)2(Dn−2 − (n − 2)Dn−3)

Dn − nDn−1 = (−1)i(Dn−i − (n − i)Dn−i−1), 1 ≤ i ≤ n − 2

Dn − nDn−1 = (−1)n−2(D2 − 2D1) = (−1)n

HenceDn = nDn−1 + (−1)n

.Example..

......

n men and n women at party check their hats before dance. At the end ofthe party, their hats are returned randomly.

With no restrictions, how many ways can the hats be returned?With man gets a male hat and women gets a female hat, how manyway can the hats be returned?With man gets a male hat, women gets a female hat and no one getsthe correct hat, how many way can the hats be returned?

November 21, 2016 22 / 59

Surjective FunctionsLet X be a m-set and Y a n-set. Then the number of functions from X toY is nm. The number of injective functions from X to Y is(

nm

)m! = P(n,m)

Let C(m, n) denote the number of surjective functions from X to Y. Whatis C(m, n)?.Theorem..

......C(m, n) =

n∑k=0

(−1)k(

nk

)(n − k)m

Let S be the set of all functions of X to Y, whereY = {y1, y2, · · · , yn}.Let Ai be the set of all functions f ∈ S such that yi ̸∈ f(X), where1 ≤ i ≤ n.

November 21, 2016 23 / 59

Surjective Functions

Then C(m, n) = |A1 ∩ A2 ∩ · · · ∩ An|A1 is the set of functions f from X to Y \ {1}. Thus |A1| = (n − 1)m

A1 ∩ A2 is the set of functions f from X to Y \ {1, 2}. Thus|A1 ∩ A2| = (n − 2)m

Ai1 ∩Ai2 ∩ · · · ∩Aik ,·1 ≤ i1 < i2 < · · · < ik ≤ n, is the set of functionsf from X to the complement Y \ {i1, i2, · · · , ik}. Thus|Ai1 ∩ Ai2 ∩ · · · ∩ Aik | = (n − k)m

|A1 ∩ A2 ∩ · · · ∩ An| = |S|+n∑

k=1

(−1)k∑

i1<i2<···<ik|Ai1 ∩ Ai2 ∩ · · · ∩ Aik |

= nm +n∑

k=1

(−1)k∑

i1<i2<···<ik(n − k)m

=n∑

k=0

(−1)k(

nk

)(n − k)m

November 21, 2016 24 / 59

The Euler Phi Function

.Definition..

......Let n be a positive integer. φ(n) is the number of positive integers lessthan n which are coprime to n. φ called the Euler phi function.

.Theorem..

......

Let n be a positive integer factorized into the form n = pe11 pe2

2 · · · perr ,where p1, p2, · · · , pr are distinct primes and e1, e2, · · · , er ≥ 1. Then theEuler function φ(n) is given by

φ(n) = nr∏

i=1

(1− 1

pi)

November 21, 2016 25 / 59

The Euler Phi Function

Let S = {1, 2, · · · , n}.Let Pi be the property for integers of S having pi as a factorAi = {x ∈ S | pi|x}, where 1 ≤ i ≤ r.Then φ(n) = |A1 ∩ A2 ∩ · · · ∩ Ar|Ai = {pi, 2pi, 3pi, · · · , n

pipi}, 1 ≤ i ≤ r. Thus |Ai| = n

pi.

More generally, if 1 ≤ i1 < i2 < · · · < ik ≤ r, thenAi1 ∩ Ai2 ∩ · · · ∩ Aik = {q, 2q, 3q, · · · , n

qq}, where q = pi1pi2 · · · pik .|Ai1 ∩ Ai2 ∩ · · · ∩ Aik | = n

q = npi1pi2 ···pik

,

Remark: (1− x1)(1− x2) · · · (1− xn) = 1− (x1 + x2 + · · ·+ xn)+(x1x2 + x1x3 + · · ·+ xn−1xn)−(x1x2x3 + x1x2x4 + · · ·+ xn−2xn−1xn)+ · · ·+ (−1)nx1x2 · · · xn

November 21, 2016 26 / 59

The Euler Phi Function

|A1 ∩ A2 ∩ · · · ∩ Ar| = |S|+n∑

k=1

(−1)k∑

i1<i2<···<ik|Ai1 ∩ Ai2 ∩ · · · ∩ Aik |

= n +n∑

k=1

(−1)k∑

i1<i2<···<ik

npi1pi2 · · · pik

= n[1− (1

p1+

1

p2+ · · ·+ 1

pr)

+(1

p1p2+

1

p1p3+ · · ·+ 1

pr−1pr)

−(1

p1p2p3+

1

p1p2p4+ · · ·+ 1

pr−2pr−1pr)

+ · · ·+ (−1)r 1

p1p2 · · · pr]

= nr∏

i=1

(1− 1

pi)

November 21, 2016 27 / 59

Permutations with Forbidden PositionsLet S = {1, 2, · · · , n}, X1,X2, · · · ,Xn be subsets (maybe ∅) of S.

P(X1,X2, · · · ,Xn) = {a1a2 · · · an ∈ P(S) | a1 ̸∈ X1, a2 ̸∈ X2, · · · , an ̸∈ Xn}

Let p(X1,X2, · · · ,Xn) = |P(X1,X2, · · · ,Xn)|.Example........Xi = {i}, then p(X1,X2, · · · ,Xn) = Dn = n!

∑ni=0

(−1)i

i!

.Example..

......

X1 = {1, 2}, X2 = {2, 3}, X3 = {3, 4}, and X4 = {1, 4}P(X1,X2,X3,X4) = {a1a2a3a4 ∈ P({1, 2, 3, 4}) | a1 ̸= 1, 2, a2 ̸=2, 3, a3 ̸= 3, 4, a4 ̸= 1, 4}a1 = 3, 4; a2 = 1, 4; a3 = 1, 2; a4 = 2, 3

P(X1,X2,X3,X4) = {3412, 4123}

November 21, 2016 28 / 59

Permutations with Forbidden Positions.

......一個在 P(X1,X2, · · · ,Xn) 中的排列, 對應一個將 n 個不互相攻擊的騎士放在 n-by-n 棋盤上, 使得第 i 列的騎士位置不落於 Xi 上.

The board of above example with forbidden positions as follows.

..

1

.

2

.

3

.4

.

1

.

2

.

3

.

4

with solutions

..

1

.

2

.

3

.4

.

1

.

2

.

3

.

4

.

×

.

×

.

×

..

1

.

2

.

3

.4

.

1

.

2

.

3

.

4

.

×

.

×

.

×

November 21, 2016 29 / 59

Permutations with Forbidden Positions

Let S be the set of all placements of n non-attacking rooks on ann × n-board.A rook placement in S satisfy the property Pi if the rook in the ithrow having column index in Xi (i = 1, 2, · · · , n).Let Ai be the set of rook placements satisfying the property Pi(i = 1, 2, · · · , n).Then by the Inclusion-Exclusion Principle we have

p(X1,X2, · · · ,Xn) = |A1 ∩ A2 ∩ · · · ∩ An|

= n!−n∑

k=1

|Ak|+∑i<j

|Ai ∩ Aj|

− · · ·+ (−1)k∑

i1<i2<···<ik|Ai1 ∩ Ai2 ∩ · · · ∩ Aik |

+ · · ·+ (−1)n|A1 ∩ A2 ∩ · · · ∩ An|

November 21, 2016 30 / 59

Permutations with Forbidden Positions

.Example..

......Let n = 5 and X1 = {1, 2}, X2 = {3, 4}, X3 = {1, 5}, X4 = {2, 3} andX5 = {4, 5}

.∑nk=1 |Ak| = 2 · 4! + 2 · 4! + 2 · 4! + 2 · 4! + 2 · 4! = 10 · 4!

|A1 ∩ A2| = |A2 ∩ A3| = |A3 ∩ A4| = |A4 ∩ A5| = |A1 ∩ A5| = 4 · 3!|A1 ∩ A3| = |A1 ∩ A4| = |A2 ∩ A4| = |A2 ∩ A5| = |A3 ∩ A5| = 3 · 3!

November 21, 2016 31 / 59

Permutations with Forbidden Positions

|A1 ∩ A2 ∩ A3| = |A1 ∩ A2 ∩ A5| = |A1 ∩ A4 ∩ A5|= |A2 ∩ A3 ∩ A4| = |A3 ∩ A4 ∩ A5|= 6 · 2!

..

=

.

2+

.

4

|A1 ∩ A2 ∩ A4| = |A1 ∩ A3 ∩ A4| = |A1 ∩ A3 ∩ A5|= |A2 ∩ A3 ∩ A5| = |A2 ∩ A4 ∩ A5|= 4 · 2!

..

=

.

3+

.

1

November 21, 2016 32 / 59

Permutations with Forbidden Positions

|A1 ∩ A2 ∩ A3 ∩ A4|=|A1 ∩ A2 ∩ A3 ∩ A5|=|A1 ∩ A2 ∩ A4 ∩ A5|=|A1 ∩ A3 ∩ A4 ∩ A5|=|A2 ∩ A3 ∩ A4 ∩ A5|=5 · 1!

..

=

.

1+

.

2+

.

0+

.

2

|A1 ∩ A2 ∩ A3 ∩ A4 ∩ A5| = 2

..

=

.

1+

.

1

♯ = 5!− 10 · 4! + 35 · 3!− 50 · 2! + 25 · 1!− 2 = 13

November 21, 2016 33 / 59

Permutations with Forbidden Positions

p(X1,X2, · · · ,Xn) = |A1 ∩ A2 ∩ · · · ∩ An|

= |S|+n∑

k=1

(−1)k∑

1≤i1<i2<···<ik≤n|Ai1 ∩ Ai2 ∩ · · · ∩ Aik |

= n! +n∑

k=1

(−1)k∑

1≤i1<i2<···<ik≤nr(i1, i2, · · · , ik)(n − k)!

其中 r(i1, i2, · · · , ik) 是將 k 個不互相攻擊的騎士放在第 i1, i2, · · · , ik 列,使得第 i1 列的騎士位置落於 Xi1 , 第 i2 列的騎士位置落於 Xi2 , · · · , 且第ik 列的騎士位置落於 Xik 的方法數.

p(X1,X2, · · · ,Xn) = n! +n∑

k=1

(−1)k(n − k)!(∑

1≤i1<i2<···<ik≤nr(i1, i2, · · · , ik))

= n! +n∑

k=1

(−1)k(n − k)!rk

November 21, 2016 34 / 59

Permutations with Forbidden Positions

其中 rk = (∑

1≤i1<i2<···<ik≤n r(i1, i2, · · · , ik)) (1 ≤ k ≤ n) 表示 k 位騎士落在禁置區的個數.Theorem..

......

The number of ways to place n non-attacking rooks on an n × n-boardwith forbidden positions is given by

p(X1,X2, · · · ,Xn) =n∑

k=0

(−1)krk(n − k)!

其中 rk 表示 k 位騎士落在禁置區的個數.

November 21, 2016 35 / 59

Permutations with Forbidden Positions

.Example..

......

Find the number of ways to place 6non-attacking rooks on thefollowing 6× 6-board with forbiddenposition as shown.

.The forbidden position can be partitioned into two independent parts,

F1 :

.and F2 :

.r1 = 7

November 21, 2016 36 / 59

Permutations with Forbidden Positions

r2 : Two in F1, or Two in F2, or One in F1 and one in F2

r2 = 1 + 2 + 3× 4 = 15

r3 : Two in F1 and one in F2, or One in F1 and two in F2

r3 = 1× 4 + 3× 2 = 10

r4 : Two in F1 and two in F2

r4 = 1× 2 = 2

r5 = r6 = 0

p(X1,X2,X3,X4,X5,X6) = 6!−7×5!+15×4!−10×3!+2×2! = 184

November 21, 2016 37 / 59

Rook Polynomials

.Definition..

......

Let C be a board. Each square of C is referred as a cell. Let rk(C) be thenumber of ways to arrange k rooks on the board C so that no one can takeanother. We assume r0(C) = 1. The rook polynomial of C is

R(C, x) =∞∑

k=0

rk(C)xk

R(.

, x) = 1 + 3x + x2

R(.

, x) = 1 + 4x + 2x2

R(F, x) = (1+3x+x2)(1+4x+2x2) = 1+(3+4)x+(1 + 2 + 3× 4)x2+(1× 4 + 3× 2)10x3 + (1× 2)x4 = 1 + 7x + 15x2 + 10x3 + 2x4

p(X1,X2, · · · ,X6) = 6!− 7× 5! + 15× 4!− 10× 3! + 2× 2! = 184

November 21, 2016 38 / 59

Rook Polynomials

.Theorem..

......Let C1 and C2 be independent boards. ThenR(C1 ∪ C2, x) = R(C1, x)R(C2, x)

Let C = C1 ∪ C2.Then rk(C1 ∪ C2) =∑k

i=0 ri(C1)rk−i(C2)

R(C, x) =∞∑

k=0

rk(C)xk =∞∑

k=0

k∑i=0

ri(C1)rk−i(C2)xk

=

∞∑i=0

∞∑k=i

ri(C1)rk−i(C2)xk =

∞∑i=0

ri(C1)

∞∑k=i

rk−i(C2)xk

=∞∑i=0

ri(C1)∞∑

k=0

rk(C2)xk+i =∞∑i=0

ri(C1)xi∞∑

k=0

rk(C2)xk

= R(C1, x)R(C2, x)

November 21, 2016 39 / 59

Rook Polynomials

.Example..

......

Find the number of ways to place 6non-attacking rooks on thefollowing 6× 6-board with forbiddenposition as shown.

.R(.

, x) = 1 + 2xR(F, x) = (1 + 2x)3 = 1 + 6x + 12x2 + 8x3

p(X1,X2, · · · ,X6) = 6!− 6× 5! + 12× 4!− 8× 3! = 240

November 21, 2016 40 / 59

Rook Polynomials

.Example..

......

Find the number of ways to place 6non-attacking rooks on thefollowing 6× 6-board with forbiddenposition as shown.

.

R(.

, x) = 1 + 4x + 2x2

R(F, x) = (1+4x+2x2)3 = 1+12x+54x2+112x3+108x4+48x5+8x6

p(X1,X2, · · · ,X6) =6!− 12× 5! + 54× 4!− 112× 3! + 108× 2!− 48× 1! + 8 = 80

November 21, 2016 41 / 59

Rook Polynomials

.Example..

......

Find the number of ways to place 6non-attacking rooks on thefollowing 6× 6-board with forbiddenposition as shown.

.R(F, x) = R(. , x)R(

., x) = (1 + 5x + 4x2)(1 + 4x + 2x2) =

1 + 9x + 26x2 + 26x3 + 8x4

p(X1,X2, · · · ,X6) = 6!− 9× 5! + 26× 4!− 26× 3! + 8× 2! = 124

November 21, 2016 42 / 59

Rook Polynomials.Theorem..

......

Let C be a board. For each cell σ of C, let Cσ denote the board obtainedfrom C by deleting all cells on the row and column that contains the cellσ, and let C \ σ denote the board obtained from C by deleting the cell σ.Then

rk(C) = rk(C \ σ) + rk−1(Cσ)

Equivalently,R(C, x) = R(C \ σ, x) + xR(Cσ, x)

rk(C) = rk(C \ σ)︸ ︷︷ ︸no take σ

+ rk−1(Cσ)︸ ︷︷ ︸take σ

R(C, x) =∞∑

k=0

rk(C)xk =∞∑

k=0

(rk(C \ σ) + rk−1(Cσ))xk

=

∞∑k=0

rk(C \ σ)xk +∞∑

k=0

rk−1(Cσ)xk = R(C \ σ, x) + xR(Cσ, x)

November 21, 2016 43 / 59

Rook Polynomials

.Example..

......Find the rook polynomial of the board . .

R(..

×

,x)=R(..

×

,x)+xR( . ,x)

=[R(. ,x)+xR(. ,x)]+xR(. ,x)

=R(. ,x)+2xR(. ,x)= (1 + 6x + 6x2) + 2x(1 + 4x + 2x2)= 1 + 8x + 14x2 + 4x3

November 21, 2016 44 / 59

Rook Polynomials.Example..

......

Let A = {1, 2, 3, 4} and B = {u, v,w, x, y, z}. How many one-to-onefunctions from A to B satisfy none of the following conditions: f(1) ̸= u orv; f(2) ̸= w; f(3) ̸= w or x; f(4) ̸= x, y or z.

Let S = the set 1-1 function from A to B, |S| = P(6, 4) = 6!2!

f ∈ S has property P1 if f(1) = u or v;f ∈ S has property P2 if f(2) = w;f ∈ S has property P3 if f(3) = w or x;f ∈ S has property P4 if f(4) = x, y or z.

|A1 ∩ A2 ∩ A3 ∩ A4| = |S| − (|A1|+ |A2|+ |A3|+ |A4|)+(|A1 ∩ A2|+ |A1 ∩ A3|+ · · ·+ |A3 ∩ A4|)−(|A1 ∩ A2 ∩ A3|+ · · ·+ |A2 ∩ A3 ∩ A4|)+|A1 ∩ A2 ∩ A3 ∩ A4|

November 21, 2016 45 / 59

Rook Polynomials

..

4

.

3

.

2

.

1

.

u

.

v

.

w

.

x

.

y

.

z

Consider forbidden Position as followsR(C, x) = (1 + 2x)(1 + 6x + 9x2 + 2x3) = 1 + 8x + 21x2 + 203 + 4x4

|A1 ∩ A2 ∩ A3 ∩ A4| =6!

2!− 8 · 5!

2!+ 21 · 4!

2!− 20 · 3!

2!+ 4 · 2!

2!= 76

November 21, 2016 46 / 59

Another Forbidden Position Problem

十位小孩排成一隊出遊,隔天十位小孩又再排成一排,希望每位向前看的人均不同,共有幾種排法? 設小孩為 1,2,3,4,5,6,7,8,9,10, 其亦為{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} 上的 permutation,但沒有 12, 23, 34, 45, 56,67, 78, 89, 9(10) 出現。

November 21, 2016 47 / 59

Another Forbidden Position Problem.Definition..

......Let Qn denote the number of permutations of {1, 2, ..., n} in which no ofpatterns 12, 23, · · · , (n−1)n occurs.

We have Q1 = 1(1),Q2 = 1(21),Q3 = 3(213, 321, 132),Q4 = 134 1 3 23 2 1 42 4 3 11 3 2 4

4 3 2 13 2 4 12 4 1 31 4 3 2

4 2 1 32 1 4 33 1 4 2

.Theorem..

......Qn = n!−(n−1

1

)(n−1)!+

(n−12

)(n−2)!−

(n−13

)(n−3)!+· · ·+(−1)n−1

(n−1n−1

)1!

Let S be the set of all permutations of {1, 2, · · · , n}. Then |S| = n!Pi: the property that π ∈ S with the pattern i(i+1), for 1 ≤ i ≤ n−1.Ai = {π ∈ S | π satisfying the property Pi}, where 1 ≤ i ≤ n − 1.Qn = |A1 ∩ A2 ∩ · · · ∩ An−1|

November 21, 2016 48 / 59

Another Forbidden Position Problem|Ai| = (n−1)!, 1 ≤ i ≤ n−1. For π ∈ A1 iff π has the pattern 12.Therefore π can be regarded as a permutation of the set{12, 3, · · · , n}, thus |A1| = (n − 1)!.|Ai ∩ Aj| = (n−2)!, 1 ≤ i < j ≤ n−1.

1 For π ∈ A1 ∩A2 iff π has the patterns 12 and 23. π can be regarded asa permutation of the set {123, 4, 5, · · · , n}, thus |A1 ∩ A2| = (n − 2)!.

2 For π ∈ A1 ∩A3 iff π has the patterns 12 and 34. π can be regarded asa permutation of the set {12, 34, 5, · · · , n}, thus |A1 ∩ A3| = (n − 2)!.

|Ai ∩ Aj ∩ Ak| = (n−3)!, 1�i ≤ j < k ≤ n−1.1 For π ∈ A1 ∩ A2 ∩ A3 iff π has the patterns 12, 23 and 34. π can be

regarded as a permutation of the set {1234, 5, · · · , n}, thus|A1 ∩ A2 ∩ A3| = (n − 3)!.

2 For π ∈ A1 ∩ A2 ∩ A4 iff π has the patterns 12, 23 and 45. π can beregarded as a permutation of the set {123, 45, 6 · · · , n}, thus|A1 ∩ A2 ∩ A4| = (n − 3)!.

3 For π ∈ A1 ∩ A3 ∩ A5 iff π has the patterns 12, 34 and 56. π can beregarded as a permutation of the set {12, 34, 56, 7 · · · , n}, thus|A1 ∩ A3 ∩ A5| = (n − 3)!.

general, |Ai1 ∩Ai2 ∩ · · · ∩Aik | = (n−k)!, 1 ≤ i1 ≤ i2 < · · · < ik ≤ n−1.November 21, 2016 49 / 59

Another Forbidden Position Problem

Qn = |A1 ∩ A2 ∩ · · · ∩ An−1|= |S| −

∑i|Ai|+

∑i<j

|Ai ∩ Aj| −∑

i<j<k|Ai ∩ Aj ∩ Ak|

+ · · ·+ (−1)n|A1 ∩ A2 ∩ · · · ∩ An−1|

= n!−(

n − 1

1

)(n − 1)! +

(n − 1

2

)(n − 2)!−

(n − 3

3

)(n − 3)!

+ · · ·+ (−1)n−1

(n − 1

n − 1

)1!

=

n−1∑k=0

(−1)k(

n − 1

k

)(n − k)!

.Theorem..

......Qn = Dn + Dn−1, for n ≥ 2.November 21, 2016 50 / 59

Another Forbidden Position Problem

Dn + Dn−1 = n!n∑

k=0

(−1)k

k! + (n − 1)!

n−1∑k=0

(−1)k

k!

= (n − 1)!

(n + n

n∑k=1

(−1)k

k! +

n∑k=1

(−1)k−1

(k − 1)!

)

= (n − 1)!

(n +

n∑k=1

(−1)knk! −

n∑k=1

(−1)kkk!

)

= n! + (n − 1)!n∑

k=1

(−1)k

k! (n − k)

= n! +n−1∑k=1

(−1)k(

n − 1

k

)(n − k)!

=n−1∑k=0

(−1)k(

n − 1

k

)(n − k)! = Qn

November 21, 2016 51 / 59

Another Forbidden Position Problem

.

......Q5 = 5!−

(4

1

)4! +

(4

2

)3!−

(4

3

)2! +

(4

4

)1! = 53

.

......

From D4 = 9 and Dn = nDn−1 + (−1)n,

D5 = 5× 9− 1 = 44,D6 = 6× 44 + 1 = 265

.

......From

Q6 = D6 + D5 = 264 + 44 = 309

November 21, 2016 52 / 59

Generalization of Inclusion-Exclusion PrincipleLet P1,P2, · · · ,Pn be properties to the objects in finite set S.For 1 ≤ m ≤ n, E(m) denote the number of element of S that haveexactly m of the n properties.ω(Pi1 ,Pi2 , · · · ,Pim) denote the number of element of S that have theproperties Pi1 ,Pi2 , · · · ,Pim .

ω(m) =∑

1≤i1<i2<···<im≤nω(Pi1 ,Pi2 , · · · ,Pim)

.Theorem..

......

The number of objects of S which have exactly m of the propertiesP1,P2, · · · ,Pn is given by

E(m) = ω(m)−(

m + 1

m

)ω(m + 1) +

(m + 2

m

)ω(m + 2)

− · · · (−1)n−m(

nm

)ω(n) =

n∑k=m

(−1)k−m(

km

)ω(k)

November 21, 2016 53 / 59

Generalization of Inclusion-Exclusion PrincipleProof. To show the identity by showing that an object contributes thesame count, either 0 or 1, to each side of the equality. Let x ∈ S hasexactly t properties

1 t < m. Clearly, count x with zero times to both side.2 t = m. Count x once in left side. On the other side, Count x once in

ω(m) but zero to ω(r) for r > m3 t > m. Count x zero in left side. For the right side, x is counted( t

m)

times in ω(m)( tm+1

)times in ω(m + 1)

...(tt)

times in ω(t)but x contributes 0 to ω(r), for r > t.Thus the count of x in the RHS is given by(

tm

)−(

m + 1

m

)(t

m + 1

)+

(m + 1

m

)(t

m + 1

)−· · ·+(−1)t−m

(tm

)(tt

)November 21, 2016 54 / 59

Generalization of Inclusion-Exclusion PrincipleFrom

(nk)(k

r)=(n

r)(n−r

k−r), we have

(tm

)−(

m + 1

m

)(t

m + 1

)+

(m + 1

m

)(t

m + 1

)−· · ·+(−1)t−m

(tm

)(tt

)

=

(tm

)−(

tm + 1

)(m + 1

m

)+

(t

m + 1

)(m + 1

m

)−· · ·+(−1)t−m

(tt

)(tm

)=

(tm

)−(

tm

)(t − m1

)+

(tm

)(t − m2

)− · · ·+ (−1)t−m

(tm

)(t − mt − m

)=

(tm

){1−

(t − m1

)+

(t − m2

)− · · ·+ (−1)t−m

(t − mt − m

)} = 0

1 E(1) = ω(1)− 2 · ω(2) + 3 · ω(3)− · · · (−1)n−1n · ω(n)2 E(2) = ω(2)−

(32

)ω(3) +

(42

)ω(4)− · · · (−1)n−2

(n2

)ω(n)

3 E(3) = ω(3)−(43

)ω(4) +

(53

)ω(5)− · · · (−1)n−3

(n3

)ω(n)

November 21, 2016 55 / 59

Generalization of Inclusion-Exclusion Principle.Theorem..

......

The number of objects of S which have at least m of the propertiesP1,P2, · · · ,Pn is given by

L(m) = ω(m)−(

mm − 1

)ω(m + 1) +

(m + 1

m − 1

)ω(m + 2)

− · · ·+ (−1)n−m(

n − 1

m − 1

)ω(n) =

n∑k=m

(−1)k−m(

k − 1

m − 1

)ω(k)

Induction on mm = 1 L(1) = ω(1)− ω(2) + ω(3)− · · ·+ (−1)nω(n)Assume it is true for m i.e. L(m) =

∑nk=m(−1)k−m( k−1

m−1

)ω(k)

L(m) = E(m) + L(m + 1) ⇒ L(m + 1) = L(m)− E(m)= (∑n

k=m(−1)k−m( k−1m−1

)ω(k))− (

∑nk=m(−1)k−m( k

m)ω(k))

=∑n

k=m(−1)k−m(( k−1

m−1

)−( k

m))ω(k) =

∑nk=m(−1)k−m−1

(k−1m)ω(k)

=∑n

k=m+1(−1)k−m−1(k−1

m)ω(k)

November 21, 2016 56 / 59

Generalization of Inclusion-Exclusion Principle

1 L(1) = ω(1)− ω(2) + ω(3)− · · · (−1)n−1ω(n) = |S| − E(0)2 L(2) = ω(2)− 2 · ω(3) + 3 · ω(4)− · · · (−1)n−2(n − 1) · ω(n)3 L(3) = ω(3)−

(32

)ω(4) +

(42

)ω(5)− · · · (−1)n−3

(n−12

)ω(n)

LetAi = {x ∈ S | x has the property Pi}

, for 1 ≤ i ≤ n.E(0) = ω(0)− ω(1) + ω(2)− · · · (−1)nω(n) =

∑nk=0(−1)kω(k)

ω(0) = |S|ω(1) =

∑ni=1 |Ai|

ω(2) =∑

1≤i<j≤n |Ai ∩ Aj|ω(n) = |A1 ∩ A2 ∩ · · · ∩ An|

E(0) = |S| −n∑

i=1

|Ai|+∑

1≤i<j≤n|Ai ∩ Aj| − · · · (−1)n|A1 ∩ A2 ∩ · · · ∩ An|

= | ∩ni=0 Ai|

November 21, 2016 57 / 59

Generalization of Inclusion-Exclusion Principle.Example..

......Find the number of integers between 1 and 1000 that are divisible by (a)exactly one of 5, 6, and 8, (b) exactly two of 5, 6, and 8.

Let S = {1, 2, · · · , 1000}.integer x in S with Property P1 that is divisible by 5.integer x in S with Property P2 that is divisible by 6.integer x in S with Property P3 that is divisible by 8.ω(1) =

∑3i=1 ω(Pi) = ω(P1) + ω(P2) + ω(P3) =

⌊10005 ⌋+ ⌊10006 ⌋+ ⌊10008 ⌋ = 200 + 166 + 125 = 491

ω(2) =∑

1≤i<j≤3 ω(Pi,Pj) = ω(P1,P2) + ω(P1,P3) + ω(P2,P3) =

⌊100030 ⌋+ ⌊100040 ⌋+ ⌊100024 ⌋ = 33 + 25 + 41 = 99

ω(3) = ω(P1,P2,P3) = ⌊1000120 ⌋ = 8

(a) E(1) =∑3

k=1(−1)k−1(k1

)ω(k) = ω(1)− 2ω(2) + 3ω(3) =

491− 2× 99 + 3× 8 = 317

(b) E(2) =∑3

k=2(−1)k−2(k2

)ω(k) = ω(2)− 3ω(3) = 75

November 21, 2016 58 / 59

Generalization of Inclusion-Exclusion Principle.Example..

......

Consider the arrangement of the letters in SURREPTITIOUS, what is thenumber that it contains (a) exactly three pairs of consecutive identicalletters, (b) at most three pairs of consecutive identical letters.

Let S = { arrangement of SURREPTITIOUS}, |S| = 13!(2!)5

. (Byrepeated S, R, T, I, U )π in S with Property P1 that SS appear in π.π in S with Property P2 that RR appear in π.π in S with Property P3 that TT appear in π.π in S with Property P4 that II appear in π.π in S with Property P5 that UU appear in π.ω(1) =

(51

)12!(2!)4

, ω(2) =(52

)11!(2!)3

, ω(3) =(53

)10!(2!)2

, ω(4) =(54

)9!2! ,

ω(5) = 8!E(3) = ω(3)−

(43

)ω(4) +

(53

)ω(5) =

(53

)10!(2!)2

− 4(54

)9!2! + 10 · 8!

|S| − L(4) = |S| − [ω(4)−(43

)ω(5)] = 13!

(2!)5−(54

)9!2! +

(43

)8!

November 21, 2016 59 / 59