180 likes | 475 Views
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.
E N D
Sk • 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?
The Inclusion-Exclusion Formula The # of elements in none of the sets is: | A1A2 …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.
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.
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.
Case: An element is in exactly k of the Ais. • It is added once in the 1st term, N. • It is subtractedC(k, 1) times in S1. • It is addedC(k,2) times in S2. • It is subtractedC(k,3) times in S3. . . . • An element in exactly k sets cannot be in any intersection of more than k of the Ais.
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.
Corollary |A1 + A2 +. . .+ An| = S1 - S2 + S3 - S1 - ...+ (-1)n-1Sn. Proof: • A1 + A2 +. . .+ An = U - A1A2 …An • Thus, a count is: N -[N - S1 + S2 - S3 + …+(-1)n Sn] = S1 - S2 + S3 - S1 - ...+ (-1)n-1Sn.
Inclusion-Exclusion Pattern To count the elements of a set that has: property 1andproperty 2and … andproperty 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, A1A2 …Anis the set of all elements that haveproperty 1andproperty 2and … andproperty n.
Inclusion-Exclusion Pattern To count the elements of a set that has: property 1orproperty 2or … orproperty n Define: A1 as the set of elements that haveproperty 1 A2 as the set of elements that haveproperty 2 etc. Then, A1 + A2 +. . .+ An is the set of all elements that haveproperty 1orproperty 2or … orproperty n.
Example 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 |A1A2A3A4A5A6 | = 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
Example 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)
Example 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 |A1A2A3A4| = N - S1 + S2 - S3 + S4
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.
Derangements What 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 |A1A2 ... An| = N - S1 + S2 - S3 + … + (-1)n Sn • N = n! • |Ai| = (n-1)!, |AiAj| = (n-2)!, …, |A1A2... An|= 0!
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)nn!/n! =
This sum is the number of good outcomes. • The probability, then, is this number over all possible outcomes (n!) :
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.