Consider a sports club in which people can play tennis or squash. Some members play both sports, some play only one, and some just drink at the bar. Suppose that members play tennis (and maybe squash as well), members play squash (and maybe tennis as well), and members play both sports. How many members play at least one sport?
Let be the set of members who play tennis, and let be the set of members who play squash. We are given that and and , and we need to find . For this, we need to fill in the numbers in the following Venn diagram:
Region is , which has elements, so we write there. Regions and together make up , which has elements, so we need elements in region to make the total correct. Regions and together make up , which has elements, so we need elements in region to make the total correct. Now consists of regions , and , so it has elements in total. In other words, there are members who play at least one sport.
Another way to describe the solution is as follows: we could just take , but that would count the people who play both sports twice, once as members of , and once more as members of . To compensate for this, we need to subtract the number of people who play both sports, which is . This gives
as before.
Now suppose instead that we have a club that offers tennis (t), squash (s) and badminton (b). We are given the following data:
10 members play | 5 members play and |
---|---|
15 members play | 4 members play and |
12 members play | 3 members play and |
2 members play , and | There are 40 members altogether. |
How many members play no sport at all?
This time we will give a more algebraic explanation. We write for the set of all members, and . We write for the set of members who play , and for the number of players who play , and similarly for , and so on. The initial data is then as follows:
Now let be the set of members who play and nothing else, and let be the set of members who play and and nothing else, and so on. To complete the pattern, we put , and we write for the set of members who play no sport at all, so our problem is to find . The people who play can be divided into four groups:
Those that play and nothing else
Those that play and but not
Those that play and but not
Those that play and and .
From this we get , and these sets do not overlap, so we get . By a similar analysis, we get the following equations:
These equations are easily solved to give
In particular, we have , so there are members who play no sport; this answers the original question.
We now want to discuss the Inclusion-Exclusion Principle (IEP), which generalises the last two problems. Suppose we have a finite set , together with a family of subsets for each in some set of labels. (For example, in Problem 5.2 we have a set , together with subsets , and , indexed by the set of available sports.) We put
In the common case where , this can be written as
The IEP tells us about and . To formulate it, we use the following notation. Given a subset , we put . This means that
and so on. For the case , we interpret this as . We will often abbreviate the notation, by writing for and so on.
For and as above, we have
In the case where , this can be written as
There is a single video covering the statement and proof of the IEP, together with two lemmas required for the proof:
.
The equation for is called the negative form of the IEP, and the equation for is called the positive form. Because we have , which makes it easy to see that the two forms are equivalent. For and the equations are as follows:
Problem 5.1 is just an example of the positive IEP with . Problem 5.2 is an example of the negative IEP with .
We will prove the IEP after some preliminary discussion.
Let be a finite set, and consider the sum . Then if is empty, and if is not empty.
If is empty, then the only term in the sum is for , and that term is , so . Suppose instead that , and put . Then there are possible choices of with , and this gives . This is just the binomial expansion of , so . Alternatively, we can choose an element , and put . For every we have a term in for , and another term for , and these terms cancel out. All the terms cancel in pairs in this way, so we are left with . ∎
In the context of the IEP, for an element , we put
For example, consider a member of the club in Problem 5.2. Then is just the set of sports that plays. For example, if plays tennis and badminton but not squash, then .
Consider the set and the corresponding set . Member does not lie in this set , because does not play s. Here .
Consider instead the set and the corresponding set . Member does not lie in this set , because does not play s. Here .
Now consider the set and the corresponding set . Member does lie in this set , because does not play both and b. Here .
Similarly, if then does lie in the set , and again .
For an arbitrary subset we find that iff plays all the sports in iff .
We record the obvious generalisation as a lemma:
Suppose we have a family of subsets as before, and an element , and a subset . Then iff .
By definition , so iff for all . However, we have iff , by the definition of . Thus, we can say that iff for all , we have . This is clearly equivalent to the condition . ∎
is empty iff .
We have iff . Thus is empty iff the condition is false for all , which means that lies in none of the sets , which means that . ∎
Put . We need to prove that this is the same as . We have , so we can rewrite the definition of as
Lemma 5.6 tells us that iff , so we can regroup this sum as
Now Lemma 5.4 tells us that is zero if , but is if . Using Lemma 5.7, we therefore see that is zero if , but is if . We now have
as required. This proves the negative form of the IEP. For the positive form, we note that
The term for in the sum cancels out the extra term of outside the sum. We can also bring the minus sign inside the sum to get
∎
Let be the set of all permutations of the set , so . A derangement of is a permutation with the property that for all we have . We write for the set of derangements, so . We also write (which is the probability that a randomly chosen permutation is a derangement).
This picture lists all possible permutations of the set . For example, the top right box contains , which refers to the permutation sending , and to , , and respectively. (In disjoint cycle notation, this would be .) The numbers and are sent to themselves, so they are underlined. As some numbers are sent to themselves, this is not a derangement. However, in the bottom right box we have the permutation . This does not send anything to itself, so no numbers are underlined, and we have a derangement. All the derangements are circled; there are of them. Thus, the fraction of derangements is .
Suppose that people arrive at a party, each wearing a hat. At the end of the party, no one can remember which hat they brought, so they pick one up at random. This means that guest picks up the hat belonging to guest , for some randomly chosen permutation . This permutation is a derangement iff no one gets the right hat. Thus, the probability that no one gets the right hat is . How does this change as increases? For any given guest, there are more hats to choose from, so the probability of getting the right hat goes down. On the other hand, as there are more guests, there are more chances for at least one guest to get the right hat. It is not obvious how these competing effects balance out, but the answer is given by our next result.
, and this converges to as .
Put
Note that a permutation is a derangement iff it lies in none of the sets , so in the usual notation of the IEP. We therefore have
Here is the set of permutations that fix all the elements of , but are free to permute the remaining elements of in any way. If we have so there are possible permutations of . This means that . On the other hand, there are possible choices of with . Putting this together, we get
However, we also have
so our previous expression simplifies to as claimed. As tends to infinity, this converges to , which is by the standard Taylor series for . ∎
Of the numbers , how many are coprime with ?
Put , and let be the subset of numbers that are coprime with . We need to find . Put , which is the set of primes that divide . For any , put
In the standard notation for the IEP, we have , and so . We therefore need to understand . Let be the product of the primes in (to be interpreted as in the case ). We note that divides , and is the set of multiples of in , so and . We now have
It is not hard to see that this factors as
Alternatively, we could say that the proportion of coprime numbers is .
The following more general statement can be proved in the same way:
Consider an integer , and let be the set of primes that divide . Put , and let be the proportion of numbers in that are coprime with . Then