21 Pie: The Principal of Inclusion and Exclusion: (This Section Optional)
21 Pie: The Principal of Inclusion and Exclusion: (This Section Optional)
Cargal
21
PIE:
The Principal of Inclusion and Exclusion
(This section optional)
The rationale is precisely the same as for the law of addition. Since the Nab objects are counted
by both Na and Nb we must subtract Nab once.
1
Chapter 21 out of 37 from Discrete Mathematics for Neophytes: Number Theory, Probability, Algorithms, and Other Stuff by J. M. Cargal
The general pattern of the formula is that for each set of properties, s, we add or subtract Ns. If
the number of properties in s is odd, we add Ns, otherwise we subtract Ns. If we denote by N0
the number of objects with none of the properties, we have N0 = N ! Vabc...n. A proof of the
formula of inclusion and exclusion is given in the next paragraph for those of you who are hardy.
The rest of you should feel free to skip to the following examples.
Consider an arbitrary object, call it X, out of our set of N objects. Suppose that this
object has k properties (out of however many properties we have). To prove that the formula
given by the principal of inclusion and exclusion is correct, we need only to show that X is
counted once and only once by the formula. X is counted k (= ) times by terms of the form
Nz. It is then counted times by terms of the form Nyz. In general it is counted times
Example Suppose we flip a coin 5 times. We would like to know how many ways can we
do this such that there is a sequence of exactly 3 heads in a row (4 heads in a row
doesn't count). Let Ni be the number of sequences of tosses with a sequence of
exactly 3 heads beginning on the i'th throw. We want to calculate V12345.
However, this is equal to V123 since a sequence of 3 heads cannot start on the 4'th
or 5'th throws. Applying the PIE formula we get
. Only the first 3 terms can be non-
zero since the other terms are self-contradictory. (Since for example we can't
have sequences of heads beginning on the first and the second throws.) N1 is the
2
Chapter 21 out of 37 from Discrete Mathematics for Neophytes: Number Theory, Probability, Algorithms, and Other Stuff by J. M. Cargal
number of sequences beginning with exactly 3 heads. The fourth throw must be
tails and this leaves two possibilities for the fifth throw. Hence, N1 = 2.
Similarly, if there is a sequence of exactly 3 heads beginning with the second toss
then both the first and fifth tosses must be tails. Hence, N2 = 1. Lastly if such
a sequence of heads begins on the third throw, the second throw must be tails and
the first throw can be either heads or tails. This gives N3 = 2. Hence,
V12345 = V123 = 5.
Example Consider the previous example except that we want to know the number of
sequences with 3 heads in a row or more. Now we want Ni to be the number of
sequences of tosses with a sequence of 3 or more heads beginning on the i'th
throw. As before, V12345 = V123 and .
Also as before, only the first three terms can be non-zero. This time N1 = 4 since
the fourth and fifth tosses can each be heads or tails. N2 = 2 since the fifth throw
can be heads or tails. Similarly, N3 = 2 because the first throw can be heads or
tails (but the second throw must be tails). V12345 = V123 = 8.
Example Consider the same problems as in the previous two examples but for eight tosses
of the coin. In the first case, we will count the number of sequences containing
exactly three heads in a sequence. For this we get
. These terms are 24, 23, 23,
23, 23, 24, 1, 1, and 1 respectively. The total is 61. In the second case, we will
count the number of sequences containing three heads or more in a sequence.
Again, we get . This time
however the terms are 25, 24, 24, 24, 24, 24, 2, 2, and 1 respectively for a total of
107.
3
Chapter 21 out of 37 from Discrete Mathematics for Neophytes: Number Theory, Probability, Algorithms, and Other Stuff by J. M. Cargal
own, then the probability of no one getting back his own is . Let
Nabc be the number of ways that the prods can be handed back without persons
a, b, or c getting back their own prods. Then, the number of ways, N0, that no
o n e g e t s b a c k h i s o w n p r o d i s
. This can be simplified
general if we have n professors, the probability that a professor gets his own prod
4
Chapter 21 out of 37 from Discrete Mathematics for Neophytes: Number Theory, Probability, Algorithms, and Other Stuff by J. M. Cargal
back is . The probability that all n professors get back their own prods is .
But for n over about 5, the probability that no one gets back his own prod is