You are currently browsing the tag archive for the ‘inclusion-exclusion principle’ tag.
The solutions are in! We had a good response to last week’s problem:
- Consider a rectangle with sides of integer lengths and , subdivided into unit squares, and a diagonal line from corner to corner. Show that the number of unit squares that the line crosses is . (Count only those cases where the line crosses the interior of a square.)
- What would be the -dimensional analogue of the previous problem? How would you prove it?
The solution below is due to Paul Shearer (University of Michigan):
Solution to POW-2: We’ll solve part 2, which subsumes part 1.
Let be the vector of box sidelengths, and the number of boxes crossed by the diagonal going from 0 to a. Then we claim
where denotes the cardinality of a set . [Note that for , this simplifies to , the result of part 1.]
Proof: Parametrize the diagonal by the function for , and let denote the coordinate of . Defining  , we have
[Proof: let < < … < be the set on the right-hand side. Each corresponds to an interval where the line is in the interior of exactly one box, since a point in a box is interior if none of its coordinates is an integer. Hence there is a bijection between ‘s and boxes crossed.]
For , let . Then
by the inclusion-exclusion principle, so we need only verify that . Indeed, given , will be an integer for all if and only if for , i.e. for different values of .
Remarks: Philipp Lampe notes that the case is given by Andreescu and Feng, A Path to Combinatorics for Undergraduates: Counting Strategies (Birkhäuser, 2004). He also gave a solution from which a proof of the inclusion-exclusion principle (which involves binomial coefficients) can be extracted. A number of people gave the correct formula for general , but full credit was given only for complete proofs.
Also solved by Sune Jakobsen, Philipp Lampe. Solutions to part 1. were given by Jimbo Doe, Jason Dyer, and Marni Sheppeard.
After having understood the inclusion-exclusion principle by working out a few cases and examples in my earlier post, we are now ready to prove the general version of the principle.
As with many things in mathematics, there is a “normal” way of doing proofs and there is the “Polya/Szego” way of doing proofs. (Ok, ok, I admit it’s just a bias I have.) I will stick to the latter. Ok, let’s state the principle first and follow it up with its proof in a step-by-step fashion.
Inclusion-Exclusion Principle: Let there be a set of objects. Suppose out of these objects, there are objects of type , objects of type objects of type and objects of type . Also, suppose denote the number of objects that are simultaneously of type AND AND AND AND respectively. Then, the number of objects that are NOT of type is
— Notation —
Let (finite or infinite) be the universe of discourse. Suppose . Then, the characteristic function of is defined as
and otherwise, for all .
For example, suppose . Let (i.e. even integers.) Then, , and so on.
Note: and for all . Here, denotes the empty set. Due to this, we will use and interchangeably from now.
Lemma 1: iff for all .
Proof: We first prove the “only if”part. So, suppose . Let . If , then . But, we also have , in which case, . If, on the other hand, , then . Hence, in either case, for all .
We now prove the “if” part. So, suppose for all . Let . Then, , which forces , which implies . Hence, , and this completes our proof.
Note: If is finite, then .
for all . (Here, is the complement of .)
Proof: The proof for each case is elementary.
Lemma 3: Suppose is finite. If , then the characteristic function of is , i.e.
for all .
Proof: Note the above is an extension of the third part of lemma . A simple induction on the number of subsets of proves the result.
— Proof of the inclusion-exclusion principle —
Now, suppose are subsets of objects of type , respectively. Observe that the set of objects that are NOT of type is simply the region outside of all the oval regions! (Look at the previous post to see what this means.) And this region is simply the subset . Using the first part of lemma , we see that the characteristic function of this outside region is , which from lemma is the same as
Expand the last expression to get
Now, sum over all the elements of and use the second part of lemma to obtain the desired result. And this completes our proof.
A couple of weeks ago, my friend John (from UK) asked me if I could explain the Inclusion-Exclusion Principle to him. Wikipedia contains an article on the same topic but John felt that it wasn’t a very helpful introduction. So, as promised, here is the post on that topic, though I managed to finish it only after some delay. (Sorry, John!)
As the title of this post suggests, the inclusion-exclusion principle can simply be described as counting all the objects outside the oval regions! We will use Venn diagrams to explain what that means.
Note: denotes the greatest integer less than .
Ok, let’s now “build” the principle step by step.
1. Suppose there are objects out of which there are exactly objects of type . How many objects are NOT of type ? The answer is obvious: . The Venn diagram below depicts the answer pictorially. The rounded rectangular region (with the orange border) is the set of all objects, and the oval region (with the blue border) is the set of all objects of type . Then, the remaining white region that is outside the oval region denotes the set of all objects that are NOT of type , and clearly, there are of ‘em.
Indeed, let us take a simple example. Consider the set of first thirty natural numbers: . So, . Now, out of these thirty integers, let be the number of integers divisible by . Then, . It is easy to see that the number of integers NOT divisible by equals , which is what we would expect if we were to list all the integers not divisible by . Indeed, those integers are .
2. Now, suppose there are objects out of which there are exactly objects of type and objects of type . Also, suppose there are exactly objects that are of both type AND . Then, how many objects are NOT of type OR ? The Venn diagram below illustrates this case.
Again, we are counting the number of objects outside the two oval regions. To answer the above question, we first need to determine the number of objects inside the two oval regions, and then subtract this number from the total, which is . Now, one might be tempted to think that the number of objects inside the two oval regions is simply . But this is only true if the two oval regions don’t intersect (i.e. they have no objects in common.) In the general case, however, the expression counts twice! And so, we must subtract from the expression to get as the exact number of objects inside the two oval regions. We can now see that the number of objects outside the two oval regions equals , and we are done.
Continuing with our example used earlier, let be the number of integers divisible by . Also, let be the number of integers divisible by AND (i.e. we count multiples of .) Now, note that , and .
Thus, using the formula derived above, the number of integers that are NOT divisible by OR equals . In fact, we can list these ten integers: and ; and this confirms our answer.
3. Now, suppose there are objects out of which there are exactly objects of type , objects of type and objects of type . Also, let denote the number of objects of type AND , the number of objects of type AND , the number of objects of type AND , and the number of objects of type AND . Then, how many objects are NOT of type OR ? This case is illustrated by the Venn diagram shown below.
Once again, let us ask, what is the number of objects inside the three oval regions. A possible answer is . Now this will only be true if the three oval regions are pairwise disjoint. In the general case, however, we will have to take care of overcounting, just as we did in earlier. A brief thought will reveal that in the above expression, we have counted each of and twice and thrice! To take care of this overcounting, we subtract each of and once from the expression, but in doing so, we also end up subtracting thrice! We thus need to add back into the expression to get , and this expression yields the exact number of objects inside the three oval regions. Therefore, the number of objects outside the three oval regions equals . And, we are done.
Again, continuing with our earlier example, let denote the number of integers divisible by . Then, . Also, let denote the number of integers divisible by AND (i.e. we are counting multiples of ); then, . Again, let denote the number of integers divisible by and ; then . And, finally, let denote the number of integers divisible by and ; then .
So, the number of integers NOT divisible by OR equals
. Indeed, those eight integers are and .
It isn’t very hard to deduce the formula for the general case when we have a set of objects, out of which there are objects of type , objects of type , and so on. The proof of the general formula will follow in the next post, which may include a couple of problems/solutions involving this principle.