



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
The Principle of Inclusion and Exclusion (PIE) is a formula used to calculate the size of the union of n finite sets. It is a generalization of the familiar formulas for the union of two sets and can be expressed compactly using intersections. an explanation of the PIE principle and demonstrates its application through examples.
What you will learn
Typology: Lecture notes
1 / 5
This page cannot be seen from the preview
Don't miss anything!
The Principle of Inclusion and Exclusion
The Principle of Inclusion and Exclusion, hereafter called PIE, gives a formula for the size of the union of n finite sets. Usually the universe is finite too. It is a generalisation of the familiar formulas |A ∪ B| = |A| + |B| − |A ∩ B| and |A ∪ B ∪ C| = |A| + |B| + |C| − |A ∩ B| − |A ∩ C| − |B ∩ C| + |A ∩ B ∩ C|.
Theorem PIE. If P 1 , P 2 ,... , Pn be are finite sets, then |P 1 ∪ P 2 ∪ · · · ∪ Pn| =
|P 2 | + · · · + |Pn|
|P 1 ∩ P 2 | + |P 1 ∩ P 3 | + · · · |Pk− 1 ∩ Pn|
P 4 | + · · · + |Pn− 2 ∩ Pn− 1 ∩ Pn|
+... + (−1)n|P 1 ∩ P 2 ∩... ∩ Pn|
That is, the cardinality of the union P 1 ∪ P 2 ∪... ∪ Pk can be calculated by including (adding) the sizes of all of the sets together, then excluding (subtracting) the sizes of the intersections of all pairs of sets, then including the sizes of the intersections of all triples, excluding the sizes of the intersections of all quadruples, and so on until, finally, the size of the intersection of all of the sets has been included or excluded, as appropriate. If n is odd it is included, and if n is even it is excluded. The formula can be expressed more compactly as |P 1 ∪ P 2 ∪ · · · ∪ Pn| =
∑k i=1(−1)k^
1 ≤i 1 <i 2 <···<ik ≤n |Pi^1 ∩^ Pi^2 ∩ · · · ∩^ Pik^ |. It is important to remember that all sets involved must be finite.
To prove PIE, both sides count only elements that belong to some positive number of the sets. Each of these is counted once on the LHS. To determine the number of times it is counted on the RHS, suppose it belongs to t ≥ 1 of the sets, and calculate the contribution it makes to each intersection. You’ll end up making use of the Binomial Theorem expansion of (1 +( −1))t.
When to use PIE. Vaguely speaking, you should try PIE when you are trying to count something described by a bunch of conditions, any number of which might hold at the same time, and you can’t see how to organise the counting by cases. Often PIE is used in conjunction with counting the complement. That is, you use it to count the number of objects in the universe that you don’t want, and subtract this from the size of the universe (which needs to be finite!).
In applying PIE, the setup is of great importance. You need to be clear about what the sets are (what it means to belong to one or more of them), what the universe is, and how the principle gives you what you want. Once you’ve done this, things often reduce to more or less straightforward counting problems.
Example PIE 1. Count the number of sequences of 10 distinct letters that contain none of THE, MATH, and QUIZ.
Here we’re are asked to count sequences of 10 distinct letters that have some special properties, so a good choice for the universe is the set of all sequences of 10 distinct letters. Thus, |U| = 26!/16!. Let’s try to set up some sets whose union will contain the sequences we don’t want, and then we can determine the number that we do want by subtraction. Let A, B and C be the set of all sequences in U that contain THE, MATH, and QUIZ, respectively. Then, by the definition of union, A∪B∪C is the set of all sequences that contain at least one of THE, MATH, and QUIZ, so the number we want is |U| − |A ∪ B ∪ C| = 26!/16! − |A ∪ B ∪ C|, where the last term can be determined using PIE. Each of the terms on the RHS of |A∪B ∪C| = |A|+|B|+|C|−|A∩B|−|A∩C|−|B ∩C|+|A∩B ∩C| can be determined by a straightforward counting argument, so long as we are clear about what it means to belong to each intersection. For example, a sequence belongs to B∩C if and only if it contains both MATH and QUIZ. To determine the number of such sequences, use glue. After doing the counting, we find that |A∪B ∪C| =
7
6
6
5
3
2
1
Thus, the number of sequences of 10 distinct letters that contain none of THE, MATH, and QUIZ equals 26!/16! −
7
6
6
5
3
2
1
Example PIE 2. Determine the number of integer solutions to x 1 + x 2 + x 3 + x 4 ≤ 70 such that 1 ≤ x 1 ≤ 12 , 0 ≤ x 2 ≤ 10 , − 3 ≤ x 3 ≤ 13 , 5 ≤ x 4 ≤ 35.
After making a change of variables (let y 1 = x 1 − 1, etc.) and adding a slack variable, this is equivalent to determining number of integer solutions to y 1 + y 2 + y 3 + y 4 + y 5 = 67 such that 0 ≤ y 1 ≤ 11 , 0 ≤ y 2 ≤ 10 , 0 ≤ y 3 ≤ 16 , 0 ≤ y 4 ≤ 30, and y 5 ≥ 0. Under this setup we’re asked to count non-negative integer solutions to an equation that satisfy certain constraints. This suggests that the universe should be the set of all non- negative integer solutions to y 1 +y 2 +y 3 +y 4 +y 5 = 67. Thus, |U| = (67+4)!/(67!4!) =
4
(use bars and stars). Let’s set up some sets whose union will contain the solutions we don’t want, that is, the ones that violate at least one of the upper bound constraints. Then, the number of solutions we do want can be obtained by subtraction. To do this, let Y 1 be the set of solutions where y 1 ≥ 12, Y 2 be the set of solutions where y 2 ≥ 11, Y 3 be the set of solutions where y 3 ≥ 17, and Y 4 be the set of solutions where y 4 ≥ 31. (There are only four sets because there is no upper bound constraint on y 5 .) Then, by definition of union, Y 1 ∪ Y 2 ∪ Y 3 ∪ Y 4 is the set of solutions where one or more constraints are violated. Thus we want |U| − |Y 1 ∪ Y 2 ∪ Y 3 ∪ Y 4 |, where the last term is determined by PIE. Again, the counting is straightforward once it is clear what it means for a solution to belong to an intersection of several of the sets. For example, a solution belongs to
the term which is included or excluded is
(n k
times the size of the intersection of k sets. Note that |Xi| can be thought of as the size of an intersection of one set.
Two classic examples of quantities that can be counted using PIE are onto functions and derangements. Since these are thoroughly discussed in most textbooks, (and in class) they will not be dealt with in detail here. Since you should be able to do these calculations, a very brief discussion of each topic is included.
Example PIE 4. Find the number of functions from {x 1 , x 2 ,... xm} onto {y 1 , y 2 ,... , yn}.
Remember that a function f from {x 1 , x 2 ,... xm} to {y 1 , y 2 ,... , yn} is onto if every y ∈ {y 1 , y 2 ,... , yn} is f (x) for some x ∈ {x 1 , x 2 ,... xm}. (Notice how this corresponds to rephrasing the conditions, as discussed above.) Now if m < n the answer is zero, so assume m ≥ n. We’re counting functions, so the universe should be the set of all functions from {x 1 , x 2 ,... xm} to {y 1 , y 2 ,... , yn}. To figure out |U|, remember how to count functions. For i = 1, 2 ,... , n let Pi be the set of functions where yi is not f (x) for any x ∈ {x 1 , x 2 ,... xm}. (Notice how this uses the “new” description of the conditions to set up the sets.) Then P 1 ∪ P 2 ∪ · · · ∪ Pn is the set of functions that are not onto, so we want |U| − |P 1 ∪ P 2 ∪ · · · ∪ Pn|. After counting, and recognising that the second and third important points also apply here, the answer is
∑n k=0(−1)k
(n k
(n − k)m.
Problems in which every thing in a first collection of distinct objects is assigned to some thing in a second collection of distinct objects can be thought of as problems involving functions. (The functions in question are from the first collection of objects to the second, and if x is an object in the first collection, then f (x) should be the object in the second collection to which it is assigned.) If the assignments are such that no object in the second collection (the one “being assigned to”) is left out, then the problem involves onto functions, and hence you can write the solution down without resorting to PIE. For example, the number of ways that Dr. M. can assign 7 different projects to his research team consisting of himself and 3 graduate students equals the number of functions from the set of 7 projects onto the 4 people, which is
k=0(−1)k
k
(4 − k)^7. If he must keep 3 projects for himself and distribute the remainder to his students, then the number of ways is
3
k=0(−1)k
k
(3 − k)^4 (choose the 3 he keeps as the first step, then proceed as above).
A derangement of a set X = {x 1 , x 2 ,... , xn} is a permutation y 1 y 2... yn of the elements of X so that yi = xi for i = 1, 2 ,... , n.
Example PIE 5. Determine d(n), the number of derangements of X = {x 1 , x 2 ,... , xn}.
We’re counting permutations, so the universe should be the set of all permutations of x 1 , x 2 ,... , xn. For i = 1, 2 ,... , n, let Pi be the set of permutations y 1 y 2... yn in which yi = xi. Then we want |U| − |P 1 ∪ P 2 ∪ · · · ∪ Pn|. This turns out to equal
∑n k=0(−1)k
(n k
(n − k)!.
It is sometimes the case that a given problem can be recognised as one involving derange- ments, and thus solved without resorting to PIE. For example, suppose 8 people check their coat and their hat at an event. In how many ways can these be returned so that no one gets back either of his posessions? There are d(8) ways to return the coats so that no one gets his own coat, and for each of these there are d(8) ways to return the hats so that no one gets his own hat. Thus the answer is d(8)^2 =
k=0(−1)k
k
(8 − k)!
Curiosity. Notice that d(n) =
∑n k=0(−1)k
(n k
(n − k)! =
∑n k=0(−1)k^ k!(nn−!k)! (n^ −^ k)! = n!
∑n k=0(−1)k^ k^1!. ¿From calculus we know that^ ex^ =^
k=0 x
k k!. Thus,^ e−^1 =^
k=
(−1)k k!. On comparing this with the final summation we have for d(n), we notice that d(n) equals n! times the sum of the first n +1 terms (it starts at 0) in a series that converges (quickly!) to e−^1. Thus d(n)/n! ≈ e−^1 or, equivalently, d(n) ≈ n!/e. The approximation is quite good from n = 5 onwards. This says, for example, that if n people check their coat at a party and they are returned at random the probability that no one gets his own coat back is about e−^1 , and thus (essentially) independent of n.