You are on page 1of 4

ARML 2011 – Advanced Combinatorics: Principle of Inclusion-Exclusion

3/24/11
Andre Kessler

Combinatorics is unlike algebra, calculus, and number theory in that it does not have an explicitly
named “fundamental theorem.” Instead, there are probably about nine fundamental principles 1 .
Some of the principles or methods may seem almost trivial, but all have quite deep implications in
multiple areas of mathematics. Strictly speaking, the principle of inclusion-exclusion is part of a
more general group of sieve methods. The general idea of a sieve method is that we can approximate
what we want to enumerate by overcounting, then subtract off an overcounted estimate of our error
in counting, and repeat until we have converged to the exact answer. This is really the essence of
the principle of inclusion-exclusion, although it turns out that much more sophisticated results are
possible. In fact, in the most abstract sense, the statement of the principle of inclusion-exclusion
is simply the computation of the inverse of a certain matrix.

While it is virtually certain that you won’t ever need to know that for a high school math competi-
tion, it illustrates an important fact: the principle of inclusion exclusion is very general and widely
applicable. There are many ways you can manipulate the simple statement into other assertions
that are more useful in particular situations, and it is important to know when it’s useful to do
so. Thus, the purpose of this lecture is to demonstrate how to best apply the powerful tool of the
principle of inclusion-exclusion and to teach you when to use it.

1 The Principle Itself


Suppose we have n finite sets A1 , A2 , A3 , . . . , An . Then

|A1 ∪ A2 ∪ · · · ∪ An | = |A1 | + |A2 | + · · · + |An |


− |A1 ∩ A2 | − |A1 ∩ A3 | − · · · − |An−1 ∩ An |
+ |A1 ∩ A2 ∩ A3 | + |A1 ∩ A2 ∩ A4 | + · · · + |An−2 ∩ An−1 ∩ An |
...
+ (−1)n+1 |A1 ∩ A2 ∩ · · · ∩ An |
X
= (−1)r+1 |Aj1 ∩ Aj2 ∩ · · · ∩ Ajr |,

where the sum is taken over all nonempty subsets {j1 , j2 , . . . , jr } of the set {1, 2, 3, . . . , n}. Note
that since row r of the sum contains the summands associated with the r−subsets; thus, the total
number of summands on the right hand side of this equation is 2n − 1. For large n, the number of
terms in the formula grows too quickly for it to be all that useful. However, as we shall see, it is
frequently possible to simplify this to a number of summands on the order of n.

To prove this, consider an arbitrary element a ∈ A1 ∪ A2 ∪ · · · ∪ An and denote by Ak1 , Ak2 , . . . , Akm
those of the n given sets that contain the element a (clearly, m ∈ {1, 2, 3, . . . , n}). Which of the
sets of the type Aj1 ∩ Aj2 ∩ · · · ∩ Ajm contain element a? Clearly, this only occurs for sets of ji such
that {j1 , j2 , . . . , jm } ⊂ {k1 , k2 , . . . , km } and {j
 1,j2 , . . . , jm } is not empty. For each r in the range
m
1 . . . m, the element a is counted in exactly summands, so the final contribution of a single
r
1
Specifically: addition principle, multiplication principle, pigeonhole principle, parity, proof by bijection, method
of induction/recursion, invariants/monovariants, principle of inclusion-exclusion, and generating functions.

1
element a to the right-hand side of the equation is
     
m m m
− + · · · + (−1)m+1 = 1,
1 2 m
where the last step can be verified in any number of ways.

The principle of inclusion-exclusion is the most useful in problems where we are asked to de-
termine the number of objects that have at least one of a given set of properties.

Example 1. How many ways can we rearrange the letters in “CATHAT” if no two of the same
letters are to be next to each other?

Solution. Let n be the number we’re trying to find, and let n0 be the total number of ways
of rearranging the letters. Let A1 be the set of all arrangements in which the two letters ‘A’ are
next to each other and let A2 be the set of all arrangements in which the two letters ‘T’ are next
to each other. By the principle of inclusion-exclusion, we know that

n = n0 − |A1 ∪ A2 | = n0 − |A1 | − |A2 | + |A1 ∩ A2 |


6! 5!
We can easily obtain n0 = , |A1 | = |A2 | = , and |A1 ∩ A2 | = 4!. Therefore, we have
2·2 2
6! 5!
n= 2
− 2 · + 4! = 84.
2 2

2 Special Cases
Quite frequently, the summands for each row r in the statement of the principle of inclusion-
exclusion are all the same; say, some value A(r). This collapses a sum with an exponential number
of summands into a sum with n summands; specifically,
n  
r+1 n
X
|A1 ∪ A2 ∪ · · · ∪ An | = (−1) A(r).
r
r=1

Alternately, we can count the complement (“all things that don’t have the properties A1 , A2 , . . . , An ”)
to get the formula
n  
r n
X
A(0) − |A1 ∪ A2 ∪ · · · ∪ An | = (−1) A(r).
r
r=0
It’s important to note that the principle of inclusion-exclusion cannot always be reduced to this
form. However, it is often the case that at least some of the summands can be simplified or ignored
in this manner.

Example 2. Find the number of arrangements with repetitions of AABBCCDD · · · , where there
are n different pairs of two letters, such that no two letters that are the same are adjacent to each
other.

Solution. Let an be the desired number of arrangements, and let Ai be the set of all arrangements
in which the elements of the i-th type are adjacent. Then clearly
(2n)!
an = − |A1 ∪ A2 ∪ · · · ∪ An |.
2n

2
To determine the right-hand side specifically, we use the simplified form of the principle of inclusion-
exclusion. Note that the set Aj1 ∩ Aj2 ∩ · · · ∩ Ajr contains the arrangements in which a fixed set of
r letter pairs are adjacent to each other. Each such pair can be considered as a single object, and
the rest of the objects can be arranged in any arbitrary configuration. Our choice of the r letters
is clearly irrelevant, so

A(r) = |Aj1 ∩ Aj2 ∩ · · · ∩ Ajr |


(2n − r)!
= ,
2n−r
as the problem is now really finding the number of arrangements with repetitions of (n − r) pairs
of elements of the same type and r different new objects. Using the simplified inclusion-exclusion
formula, we get that
n   n  
(2n)! X r+1 n (2n − r)! r n (2n − r)!
X
an = n − (−1) = (−1) .
2 r 2n−r r 2n−r
r=1 r=1

Example 3. In how many ways can we select k elements, possibly with repetition, from a set of
n different types such that every selection contains at least one element of each type?

Solution. We’ll call this this number v0 (k, n). Clearly, if k < n, then v0 (k, n) = 0, so we can
assume that k ≥ n and let Ai denote the set of all of these selections of k elements with repetitions
that contain NO elements of the i-th type. Without the condition that each selection has at least
one element of each type, there are clearly nk ways to make the selection. Thus,

v0 (k, n) = nk − |A1 ∪ A2 ∪ · · · ∪ An |.

This situation seems familiar...convince yourself that A(r) = (n − r)k . This implies that

v0 (k, n) = nk − |A1 ∪ A2 ∪ · · · ∪ An |
n  
r+1 n
X
k
=n − (−1) (n − r)k
r
r=1
n  
r n
X
= (−1) (n − r)k .
r
r=0

and we’re done with the problem. However, we can consider some special cases for v0 (k, n). As we
noted earlier, if k < n, then v0 (k, n) = 0. Thus “for free” we get the identity
n  
X n
(−1)r (n − r)k = 0, k < n.
r
r=0

Additionally, if k = n, then clearly there can be absolutely no repetitions in the selection for
v0 (k, n), so v0 (n, n) = n! and we also obtain the curious result
n  
X n
n! = (−1)r (n − r)n .
r
r=0

3
3 Problems
Most problems involving the principle of inclusion-exclusion are not hard, if you know what you’re
looking for. Generally, the principle is good at dealing with problems involving conditions and
restrictions such as “there must be at least...” etc. However, if you don’t think of it, you might be
reduced to trying to enumerate by hand - which often takes much longer - and you’ll probably fail
anyways if the problem is decent. You should work on these problems so you can get comfortable
with the steps of a “PIE-bash”; it’s a very useful and pretty widely applicable technique.
1. How many of the positive integers less than 2011 are either a multiple of 3 or 17?
2. In how many ways can we place 3 mathletes, 3 debaters, and 3 football players in a row such
that no three persons doing the same activity are next to each other?
3. How many perfect powers are less than 2011?
4. Six people are in an elevator. In how many ways can they get off at four floors if at each floor
at least one person gets off?
5. In how many ways can seven different cows be placed into four separate barns, if each barn
must contain at least one cow?
6. A caravan consisting of 9 camels travels through the desert. In how many ways can the
caravan be assembled after a rest stop such that in front of each of the last 8 camels there is
a different one than before?
7. Kin Sim, Zuqing Yang, Xictoria Via, Leronica Vee, Poseph Jark, Rilly Bieger, and Lemy Ree
are riding on a carousel. They agree that for the next ride they will change their places in
such a way that in front of each person there is a different one than before. In how many
ways can this be done?
8. In how many ways can 8 rooks be placed on a standard 8 × 8 chessboard such that each free
field is threatened by at least one of the rooks?
9. Find the number of all placements of n rooks on an n × n chessboard such that no two rooks
threaten each other, and none is on the main diagonal.
10. A 150 × 324 × 375 rectangular solid is made by gluing together 1 × 1 × 1 cubes. An internal
diagonal of this solid passes through the interiors of how many of the 1 × 1 × 1 cubes?
11. How many six-digit integers have exactly three different digits?
12. We are given the nonnegative integers α1 , α2 , . . . , αn . Find the number bn of all k-element
combinations with repetitions from elements of n different types such that for each i =
1, 2, . . . , n the elements of the i-th type are repeated no more than αi times in the combina-
tions.
13. King Arthur invites n pairs of mutually hostile knights for dinner at his round table. In how
many ways can the royal butler place the knights around the table such that no two enemies
sit next to each other?
14. Let {ai }n0 and {bi }n0 be two sequences of complex numbers such that
m  
X m
am = bk for all 0 ≤ m ≤ n.
k
k=0
Determine a formula for bm in terms of a0 , a1 , . . . , am .

You might also like