inclusion-exclusion formula

18
Inclusion-Exclusion Inclusion-Exclusion Formula Formula

Upload: rivka

Post on 07-Jan-2016

30 views

Category:

Documents


2 download

DESCRIPTION

Inclusion-Exclusion Formula. S k. Let A 1 , A 2 , …, A n be n sets in a universe U of N elements. Let: S 1 = |A 1 | + |A 2 | + …+ |A n | S 2 = |A 1 A 2 | + |A 1 A 3 | + …+ |A n-1 A n |, i.e., the size of all A i A j for i  j. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Inclusion-Exclusion Formula

Inclusion-Exclusion FormulaInclusion-Exclusion Formula

Page 2: Inclusion-Exclusion Formula

SSkk

• Let A1, A2, …, An be n sets in a universe U of N elements. Let: • S1 = |A1| + |A2| + …+ |An|

• S2 = |A1 A2| + |A1 A3| + …+ |An-1 An|, i.e., the size of all AiAj for i j.

• Sk = |A1 A2 …Ak| + |A1 A2 …Ak+1| + …+ |An-k+1 An-k+2 … An-1An|, i.e., the sizes of all k-ary intersections of the sets.

• How many terms are there in S1 , S2 , Sn , Sk?

Page 3: Inclusion-Exclusion Formula

The Inclusion-Exclusion FormulaThe Inclusion-Exclusion Formula

The # of elements in none of the sets is:

| A1 A2 …An | = N - S1 + S2 - S3 + …+(-1)n Sn

Proof

• We show that the formula counts each element in:

• none of the sets once

• 1 or more of the sets a net of 0 times.

Page 4: Inclusion-Exclusion Formula

Case: An element that is in none.• Such an element is added once in the 1st term: N

• Since this element is in none of the Ais, it is in none of the Si, thus is counted a net of 1 time.

• Case: An element is in exactly 1 of the Ais.

• It is added once in the 1st term, N.

• It is subtracted once in S1.

• It is in no other term, thus is counted a net of 0.

Page 5: Inclusion-Exclusion Formula

• Case: An element is in exactly 2 of the Ais.

• It is added once in the 1st term, N.

• It is subtracted twice in S1.

• It is added once in S2.

• It is in no other term, thus is counted a net of 0

times.

Page 6: Inclusion-Exclusion Formula

• Case: An element is in exactly k of the Ais.

• It is added once in the 1st term, N.

• It is subtracted C(k, 1) times in S1.

• It is added C(k,2) times in S2.

• It is subtracted C(k,3) times in S3. . . .

• An element in exactly k sets cannot be in any

intersection of more than k of the Ais.

Page 7: Inclusion-Exclusion Formula

• The net count for such an element is:

• This binomial sum equals (1 + x)k, for x = -1.

• Thus, its value is exactly 0.

• In general, the formula counts elements in 1

or more of the sets exactly 0 times.

11 2 3

1 1

k k k k

j

k

kj k... ( ) ... ( )

Page 8: Inclusion-Exclusion Formula

CorollaryCorollary

|A1 + A2 +. . .+ An| = S1 - S2 + S3 - S1 - ...+ (-1)n-1Sn.

Proof:

• A1 + A2 +. . .+ An = U - A1 A2 …An

• Thus, a count is:

N - [N - S1 + S2 - S3 + …+(-1)n Sn]

= S1 - S2 + S3 - S1 - ...+ (-1)n-1Sn.

Page 9: Inclusion-Exclusion Formula

Inclusion-Exclusion PatternInclusion-Exclusion Pattern

To count the elements of a set that has: property 1 and property 2 and … and property n

Define: A1 as the set of elements that do not have property 1

A2 as the set of elements that do not have property 2

etc.

Then, A1 A2 …An is the set of all elements that have property 1 and property 2 and … and property n.

Page 10: Inclusion-Exclusion Formula

Inclusion-Exclusion PatternInclusion-Exclusion Pattern

To count the elements of a set that has: property 1 or property 2 or … or property n

Define: A1 as the set of elements that have property 1

A2 as the set of elements that have property 2

etc.

Then, A1 + A2 +. . .+ An is the set of all elements that have property 1 or property 2 or … or property n.

Page 11: Inclusion-Exclusion Formula

Example 1Example 1

How many ways are there to roll 10 distinct dice so

that all 6 faces appear?

• Let Ai be the set of ways that face i does not appear.

• Then, we want |A1 A2 A3 A4 A5 A6 | =

N - S1 + S2 - S3 + S4 - S5 + S6 =

610 - C(6,1)510 + C(6,2)410 + C(6,3)310 + C(6,4)210 + C(6,5)110

Page 12: Inclusion-Exclusion Formula

Example 2Example 2

What is the probability that a 10-card hand has at least one 4-of-a-kind?

• Let A1 be the set of all 10-card hands with 4 aces. …

• Let AK be the set of all 10-card hands with 4 kings.• Then, we want |A1+ A2+ . . . AK| = S1 - S2 + S3 - . . . S13 = C(13,1)C(48,6) - C(13,2)C(44,2)

The probability = [C(13,1)C(48,6) - C(13,2)C(44,2)] / C(52,10)

Page 13: Inclusion-Exclusion Formula

Example 3Example 3

How many integer solutions of

x1 + x2 + x3 + x4 = 30 are there with:

0 xi, x1 5, x2 10, x3 15, x4 21 ?

• Let A1 be the set of solutions where x1 6.

• Let A2 be the set of solutions where x2 11.

• Let A3 be the set of solutions where x3 16.

• Let A4 be the set of solutions where x4 22.

• We want |A1 A2 A3 A4| = N - S1 + S2 - S3 + S4

Page 14: Inclusion-Exclusion Formula

N = C(30 + 4 - 1, 4 - 1)

A1 = C(30 - 6 + 4 - 1, 4 - 1)

A2 = C(30 - 11 + 4 - 1, 4 - 1)

A3 = C(30 - 16 + 4 - 1, 4 - 1)

A4 = C(30 - 22 + 4 - 1, 4 - 1)

A1 A2 = C(30 - 17 + 4 - 1, 4 - 1)

A1 A3 = C(30 - 22 + 4 - 1, 4 - 1)

A1 A4 = C(30 - 28 + 4 - 1, 4 - 1)

A2 A3 = C(30 - 27 + 4 - 1, 4 - 1)

A2 A4 = 0 = A3 A4

All 3-intersections & 4-intersections have 0 elements in them.

Page 15: Inclusion-Exclusion Formula

DerangementsDerangementsWhat is the probability that if n people randomly reach

into a dark closet to retrieve their hats, no person receives their own hat?

• Let Ai be the set outcomes where person i receives his/her own hat.

• We need |A1 A2 ... An| = N - S1 + S2 - S3 + … + (-1)n Sn

• N = n!• |Ai| = (n-1)!, |AiAj| = (n-2)!, …, |A1A2... An|= 0!

Page 16: Inclusion-Exclusion Formula

• N - S1 + S2 - S3 + … + (-1)n Sn=

• n! - C(n,1)(n-1)! + C(n,2)(n-2)! - … + (-1)n C(n,n)0!

• Since C(n,k) = n!/[k!(n-k)!], C(n,k) (n-k)! = n!/k!.

• Thus, the sum equals

n! - n!/1! + n!/2! - n!/3! + … + (-1)n n!/n! =

n kk

k

n

! ( ) / ! 1

0

Page 17: Inclusion-Exclusion Formula

• This sum is the number of good outcomes.

• The probability, then, is this number over

all possible outcomes (n!) :

( ) / ! 1

0

k

k

n

k

Page 18: Inclusion-Exclusion Formula

This is the 1st n + 1 terms of the power series for

• This power series converges quickly.

• The numerator of the probability, the number of permutations that leave no element fixed, denoted Dn, is called the number of derangements of n elements.

e kk

k

1

0

1( ) / !