The Principle of Inclusion and Exclusion

advertisement
The Principle of Inclusion and Exclusion
Pat Derr
Omaha Public Schools
In partial fulfillment of the requirements for the Master of Arts in Teaching with a Specialization in
the Teaching of Middle Level Mathematics in the Department of Mathematics
Dr. David Fowler, Advisor
July 2010
Combinatorics is the branch of discrete mathematics that explores counting, combining and
arranging the elements of sets. Enumeration may be thought of as “counting” but in a broader sense
it is often included with combination and permutation as one aspect of combinatorics, with graph
theory being the other aspect. In combinatorics counting may be a simple process of adding the
number of elements of two disjoint sets, or it may be a more complex process, as we will see when
we discuss the Principle of Inclusion and Exclusion. Combinations are collections of new sets of
elements. Permutations are the arrangement of elements within sets. A mathematician working in
combinatorics bases his/her work on a finite, or discrete, system of numbers. Within this structure,
numbers or things are selected, arranged and counted to solve problems. The field of combinatorics
has practical applications in computer science, probability and cryptology.
The origin of combinatorics goes far back in history. Ancient Egyptian papyri detail
mathematical problems about finding the sum of the events in seven houses, each with seven cats,
where each cat killed seven mice, each mouse ate seven grains of barley, and each grain of barley
could produce seven hekat. (A hekat is an ancient Egyptian unit of volume equivalent to just under
five liters.) Magic squares, arrays where columns, rows and diagonals all sum to the same number,
were popular subjects of mathematical study in medieval times. Jewish and Arab mathematicians in
the early middle ages focused on combinatorial problems that counted the number of possibilities in
a situation and evaluated their probability. They also helped bring the Hindu number system
(Arabic numerals) to Europe. Fibonacci, Pascal, Fermat and Euler all brought combinatorial
approaches to problem solving. Euler is sometimes considered the father of graph theory due to his
work on the Konigsberg Bridge problem. More recently, Gian-Carlo Rota (1932-1999), an Italian
who found his way to the United States after fleeing Italy during World War II, has been noted for
his work in modern combinatorics.
The origins of the Principle of Inclusion and Exclusion are murky. Richard Stanley, in
Enumerative Combinatorics, Volume 1, quotes P. Stein that the Principle of Inclusion and Exclusion
“is doubtless very old; its origin is probably untraceable.” Stanley goes on to attribute the
probabilistic form to De Moivre or perhaps Bernoulli. The Principle of Inclusion and Exclusion is
sometimes referred to as “Poincare’s Theorem.” Sylvester and da Silva are the two mathematicians
associated with the combinatorial form of the principle. Derangements were first solved by
Montmort, and the series of derangement numbers for n sets are called Montmort numbers. Euler’s
name also appears in the area of derangement.
Let’s illustrate our definition with an example of a basic combinatorics problem. You have
12 songs in your iTunes library. You want to burn a mini-CD that will only hold just three songs.
How many collections of three different songs are possible? In a previous Math in the Middle
course, we found we can count the number of collections where order does not matter
(combinations) by using the formula
12!
n!

 220 , where n is the number of songs
r!(n  r)! 3!(12  3)!
in your library and r is the size of the set selected from n. This can also be stated as C(n,r), where n
is the total number of sets or items and r is how many you select each time. There are 220 different
combinations of three songs that can be put on the mini-CD. If the order does matter to us, we may
want to arrange the three songs in a specific way. This is called a permutation. Let A be the first
song, B is the second song, and C is the third song. For each unique three song combination, there
are six possible arrangements: ABC, ACB, BAC, BCA, CAB and CBA. Thus for our 12 song
library, there are 6 * 220 = 1,320 different arrangements of three songs. This is a simple example,
but combinatorics allows us to solve more complex problems. The strength of combinatorics is the
ability to generalize an intuitive process and apply the generalization to complex problems.
The Principle of Inclusion and Exclusion is a way of thinking about combining sets with
overlapping elements. First, let’s consider two sets: the set of girls in a classroom and the set of
boys in a classroom. These are disjoint sets. They share no elements in common; a student could
not be a member of both sets. The Addition Principle states that if two sets are disjoint, the size of
the union of both sets equals the number of elements of the first set plus the number of elements in
the second set. This can be stated as | A  B | = | A | + | B |. In our classroom example we will
assume that set A contains 10 girls and set B contains 12 boys.
So | A  B | = | A | + | B | = 10 + 12 = 22
There are 22 items in the set | A  B |.
Set A
Set B
10
12
Now let’s consider two different classroom sets: The set of challenge students and the set of
band students. Let A be the set of band students; there are 8 students in this set. Let B be the set of
challenge students, and there are 6 students in this set. Can we combine the two sets and use the
Addition Principle to count 14 students in the set of | A  B |? In this example, the sets are not
disjoint. It is quite possible for a challenge student to also be a band student. We cannot use the
Addition Principle, but the Principle of Inclusion and Exclusion gives us a strategy. Let’s follow a
visual representation to our solution.
First we will count all the members
Set A
of set A and combine that with all
the members of set B. In
combining these two sets, we are






Set B






obviously over-counting the total, since two students belong to both sets. To compensate, we will
subtract the number of students who are in both set A and set B. We started by including all
elements, then excluded elements common to both sets. Putting numbers to the words we have 8 +
6 – 2 = 12 band and challenge students. Conceptually we have a basic form of the principle of
inclusion and exclusion:
|AB|=|A|+|B| |AB|
Let’s expand our example to three sets that are not disjoint: band students, challenge
students, and strings students. Let A be the
set of band students, B is the set of challenge



Set A



Set B
 
We can start by adding the members of all


three sets


Set C
students, and C is the set of strings students.

| A | + | B | + | C | = 8 + 6 + 5 = 19. In
counting all members of the three sets we
have obviously over-counted again. We will
compensate by subtracting out, or excluding,
the members that are in both band and challenge, or | A  B | = 2. Likewise, we will exclude the
common members of band and strings, | A  C | = 2, and the common members of challenge and
strings, | B  C | = 3. Consider the overachiever in band, challenge, and strings. We have added
him/her in three times as a member of the individual sets, but we have also subtracted her/him out
three times as a common member of all three groups. We need to add this student back in, or | A 
B  C | = 1. We have 8 + 6 + 5 – 2 – 2 – 3 + 1 = 13 total students.
Stringing together our process we have:
|ABC|=|A|+|B|+|C| |AB||AC||BC|+|ABC|
Given n = the number of finite sets Ai where 1  i  n, we can generally state the Principle
of Inclusion and Exclusion as:
n
n
 Ai   A i 
i 1
i 1
 A A
1i  j  n
i
j

 A A
1i  j  k  n
i
j
 A k  ...  (1) n1 A1  ...  A n
As the Principle of Inclusion and Exclusion is extended to a greater number of sets, it
remains a process of including everything in all sets, then excluding the overlap of items common to
sets. A five set example would include all the individual items in all five sets, exclude the
intersection of each pair of sets, include the intersection of each triplet of sets, exclude the
intersection of each quadruple of sets, and finally include the intersection of the quintuple of sets.
The Principle of Inclusion and Exclusion, as generally stated above, can be proved through
mathematical induction. Using this approach, we show that the statement is true for a base value of
n, where n is the number of sets. If n = 1, then | Ai | = | Ai |. This is true but not particularly
enlightening. We previously showed the statement holds for n = 2 when we counted the number of
band and challenge students. Now we need to show that our statement is true for n + 1 or n – 1. Let
A1, A2,…, An be finite sets. Our induction hypothesis states:
k
k
A  A
j
j 1
j 1
j

A
1 j1  j 2  k
j1
 A j2  ... (1)
k 1
k
A
j
(1)
j 1
This is true for k = 1:
1
UA
j
 A1

j1
and we have previously shown for k = 2:
(2)
2
UA
j
 A1  A2  A1  A2
(3)

j1
Suppose the principle holds for k = n + 1:
n1 
A

Ai  An

U
U
i


i1
i1

n
(4)
We can apply our experience with two sets |AB| = |A| + |B| - |AB|
 n

A

A


U
U j  An 1
j
j1 
j1
n 1

n
UA
j
 An 1
j1
 n

 U A j  An 1
j1 
(5)

and rewrite the intersection of unions as the union of intersections


n
n
j1
j1
U A j  An 1  U(A j  An 1)
(6)
And apply the principle to the first and last terms
n
n
j 1
j 1
 Aj   Aj 

n
A j1  A j2  ...  (1) n 1  A j
1 j1  j 2  n
n
n
j 1
j 1
(7)
j 1
 ( Aj  An1 )   Aj  An1 

n 1
A j1  A j2  An 1  ...  (1) n 1  A j (8)
1 j1  j 2  n
j 1
We will rewrite (6) as
n
  Aj 
j 1
A
1 j1  j 2  n
n
j1
 A j2  ...  (1) n 1  A j
j 1
 An 1
n
 ( A j  An 1 
j 1
(9)

n 1
A j1  A j2  An 1  ...  (1) n 1  A j )
1 j1  j2  n
and move a few terms around
j 1
n
  A j  An 1
j 1


1 j1  j 2  n
A

n
n
j 1
j 1
A j1  A j2  ...  (1) n 1  A j   A j  An 1
1 j1  j 2  n
j1
 A j2  An 1  ...  (1)
n 1
(10)
n 1
A
j
j 1
Note that in the first line of (10)
n 1
n
 A j  An 1   A j
j1
(11)
j1
Lines 2 and 3 of (10) combine to become


n
A j1  A j2   A j  An 1
1 j1  j 2  n
j 1
 A A

1i  j  k  n
i
j
 Ak 
A
1 j1  j 2  n
j1
 A j2  An 1
 ...
(12)
n 1
 (1) n 1  A j
j 1


1 j1  j2  n 1
A j1  A j2 

n 1
Ai  A j  Ak  ...  (1) n 1  A j
1i  j  k  n 1
j 1
Combining (11), and (12) gives us
k
k
j 1
j 1
 Aj   Aj 

A j1  A j2  ... (1)
1 j1  j 2  k
which was our original hypothesis.
k 1
k
A
j
j 1

Another method of proving the Principle of Inclusion and Exclusion uses a combinatorial
approach. Let us consider x, an element of set S. x belongs to r subsets of S, which we will call Ai.
We do not need to consider any Ai that does not contain x, as they do not contribute to the union of
sets we are attempting to count. We want to count x once on the left side of the equation in the
union of sets, so we need to count x one time on the right side of the equation. Since x is in r
subsets, the first term of the right hand side of the equation is r. The second term subtracts all
occurrences of x in the intersection of all paired sets within r, the third term adds back in
occurrences of x in the intersection of three sets, the fourth term subtracts occurrences of x in fourset intersections, etc. We can show the number of occurrences for each term as C(r,k) and state this
as:
1  C(r,1)  C(r,2)  C(r,3)  ... (1) r1 C(r,r)
or 1 C(r,1)  C(r,2)  C(r,3)  ... (1) r C(r,r)  (11) r  0 by the Binomial Theorem,
showing that both sides of the equality are the same. This confirms we are adding x appropriately
when using the Principle of Inclusion and Exclusion.
Another form of the Principle of Inclusion and Exclusion can be used to find the size of the
complement of a set. If we let Ai represent the subsets of larger set X, such that each Ai contains
elements of X that share a common characteristic, then the complement of the union of all Ai
represents the elements of X that do not have this characteristic. This can be stated as:
C
n
 n 
  Ai   X   A i   Ai  A j   Ai  A j  A k  ...  (1) n A1  ...  A n
i 1
1i  j  n
1 i  j  k  n
 i 1 
It can be seen that we are taking all the possible elements of X and subtracting the union of sets that
share the property in question.
Derangements are permutations of a set where none of the original positions of the elements
are duplicated. Consider the set A = {1, 2, 3}. A derangement will exist when the set is rearranged
such that the “1” is not in the first position, the “2” is not in the second position, and the “3” is not
in the third position. There are, in fact, two derangements of this set: {3, 1, 2} and {2, 3, 1}.
We can develop a general formula for counting the number of derangements for a given
sized set based on the Inclusion-Exclusion Principle. Let X represent a set containing all the
permutations of m elements, so | X | = m! Then consider the set of permutations, A1, where one
element is fixed but others are not. | A1 | = (m – 1)! There are C(m,1), or m, of these permutations.
The set of permutations, A2, where two elements are fixed is | A2 | = (m – 2)! There are C(m,2) of
these permutations. The number of derangements, |Dm|, is the complement of the union of sets that
have a “fixed” property. We can state this as:
C
Dm
m 
   Ai   m!C (m,1)  (m  1)!C (m,2)  (m  2)!C (m,3)  (m  3)!...  (1) m C (m, m)
 i 1 
1 1 1
(1) m
)
and this can be reduced to Dm  m!(1    ...
m!
1! 2! 3!
Let’s apply the Principle of Inclusion and Exclusion in some typical situations. Our first
investigation concerns prime factors. Given the set of positive integers from 1 to 1000, how many
integers are evenly divisible by a single digit prime number?
To evaluate the size of sets A, B, C, and D we need to count the factors when 1000 is divided
by the prime numbers in question. If we divide 1000 by our number and truncate any remainder,
we have the quantity we are looking for. There is an appropriate notation for this, the greatest
integer, or floor, function  , which returns the greatest integer less than the value inside the half
10 
brackets. If we wanted to know how many times 3 will divide into 10, then   3 is how we can
3 
calculate and show the result.
The Principle of Inclusion and Exclusion gives us the strategy to solve our problem. We
will start by including all numbers divisible by 2, 3, 5, or 7. But in doing so we will over-count.
For example, the number 30 will appear in the set of numbers divisible by 2, the set of numbers
divisible by 3, and the set of numbers divisible by 5. We will compensate by subtracting the
elements appearing in all two set intersections, then we will add back in the elements that are
member of three set intersections, and finally subtract any four set intersections. We can express
this as:
Let N = {1, 2, …, 1000}
Let A = {x  N | x is divisible by 2}
Let B = {x  N | x is divisible by 3}
Let C = {x  N | x is divisible by 5}
Let D = {x  N | x is divisible by 7}
(A  B  C  D)  A  B  C  D
 (A  B)  (A  C)  (A  D)  (B  C)  (B  D)  (C  D)
 (A  B  C)  (A  B  D)  (A  C  D)  (B  C  D)
 (A  B  C  D)
We will use the process noted above to determine the size of the sets. For the size of the set
intersections, we will consider that an integer is divisible by both a and b when and only when it is
divisible by the LCM (least common multiple) of a and b.
1000 
1000 
1000 
1000 
 500 , B  
 333 , C  
 200 , D  
 142 ,
A  



 2 
 3 
 5 
 7 

1000 
1000 
1000 
 166 , ( A  C )  
 100 , ( A  D)  
 71
( A  B)  


 6 
 10 
 14 

1000 
1000 
1000 
 66 , ( B  D)  
 47 , (C  D)  
 28
( B  C)  


 15 
 21 
 35 

1000 
1000 
1000 
 33 , ( A  B  D)  
 23 , ( A  C  D)  
 14 ,
( A  B  C )  


 30 
 42 
 70 

1000 
1000 
 9 , ( A  B  C  D)  
4
( B  C  D)  

105 
210 

Placing our values into our formula we have:
(A  B  C  D)  500  333  200  142
166 100  71 66  47  28
33 2314  9
4  772
So 772 integers from set N are divisible by a single digit prime number. We can also say that the
size of the complement, 228 numbers from set N, are not divisible by a single digit prime number.
Our next example uses the Principle of Inclusion and Exclusion in a similar way. Consider a
trio of golden summer evenings at the College World Series. The attendance gate for the three
championship College World Series games was 75,012. A survey showed that 60,834 individuals
attended at least one championship game and 2,578 attended all three. How many fans attended
exactly two games of the championship?
Let A be the set of people who attended game 1
Let B be the set of people who attended game 2
Let C be the set of people who attended game 3
The Principle of Inclusion and Exclusion states that the union of these three sets, that is,
the number of people who attended at least one game of the series, is equivalent to the sum
of | A |, | B |, and | C | less the sum of the individuals who attended two games plus the
people who attended all three games. So,
| A  B  C | = | A | + | B | + | C |  (| A  B | + | A  C | + | B  C |) + | A  B  C |
| A  B  C | = 60,834 fans attended at least one championship game
| A | + | B | + | C | = the gate for the three games = 75,012 fans
| A  B  C | = 2,578 fans attended all three games
So
60,834 = 75,012 – x + 2,578 and x = 16,756
So although we can’t say which two games they attended, we do know that 16,756 people
attended at least two College World Series championship games. Of these 16,756 people
who attended at least two games, 2,578 attended all three. So 14,178 fans attended exactly
two games.
In example three we will investigate the habits of Fred, a city dweller who likes to walk to
work every morning. Fred likes to explore the city and wants to take as many different paths to
work as possible, as long as they are the shortest options. Fred also frequents one of the three
coffee shops between his apartment and place of employment on a daily basis. Fred is curious
about how many different paths to work are possible if he plans on stopping by at least one of the
coffee shops.
First we will represent Fred’s situation on a rectangular grid.
s
h is Fred’s home,
s is his workplace,
y
uv are the endpoints of the
block where coffee shop 1
is located,
w
wx are the endpoints of the
block where coffee shop 2
is located,
u
yz are the endpoints of the
block where coffee shop 3
is located,
h
v
x
z
We can find the number of paths from point a to point b in a rectangular grid by using a
n 
n!
where n is the total number of blocks to be traversed and r is
binomial coefficient,  
r  r!(n  r)!
the number of blocks in either direction. In our example, for Fred to walk from home to work is 8 +
8 = 16 blocks, traveling 8 blocks in one direction and 8 blocks in the other. The total number of
16
16!
 12,870 . Go Fred.
ways Fred could walk to work is  
8  8!(16  8)!
Now let’s consider a shortest route that goes past coffee shop 1 on block uv. We can see
that we need to account for getting from point h to point u, point u to point v, and point v to point s.
Let’s call the set of all these shortest routes A.
A shortest route that goes past coffee shop 2 on block wx consists of the ways to get from
point h to point w, point w to point x, and point x to point s. We will call this set B.
Shortest routes that pass coffee shop 3 must proceed from point h to point y, point y to point
z, and point z to point s. These routes are contained in set C. For all three of our sets we can use the
Multiplicative Property to total the number of shortest routes.
Although it would be tempting at this juncture to just add the number of routes in each set,
we would be over-counting the total. We would not be accounting for identical routes that pass two
coffee shops, and thus have been double counted. In eliminating the duplicated routes from the
total, we are also eliminating routes that go past all three coffee shops, and these will need to be
added back in. This is the Principle of Inclusion and Exclusion in action.
We will evaluate | A |.
3
3!
3
There are  
2 2!(3  2)!
ways to go from point h
to point u.
s
There is one way to go from
point u to point v.
There are
12
12!
 924
 
6  6!(12  6)!
y
w
z
x
ways to go from
point v to point s.
u
v
| A | = 3*1*924 = 2,772 ways
for Fred to walk to work that pass by
coffee shop 1.
h
7 8 
| B | =  1   2,450 ways for Fred to walk to work that pass by coffee shop 2.
3 4 
11 4 
| C | =  1   1,848 ways for Fred to walk to work that pass by coffee shop 3.
6  1 
Now we need to account for the paired intersections that were over-counted. | A  B | will
consist of the possibilities from point h to point u, point u to point v, point v to point w,
point w to point x, and point x to point s. | A  C | and | B  C | will be similarly found.
3 3 8 
A  B   1  1   630 paths passing coffee shops A and B.
1 1 4 
3 7 4 
A  C   1  1   420 paths passing coffee shops A and C.
1 4  1 
7 3 4 
B  C   1  1   420 paths passing coffee shops B and C.
3 2 1 
Finally we will account for the intersection of sets A, B, and C.
3 3 3 4 
A  B  C   1  1  1   108 paths passing coffee shops A, B, and C.
1 1 2 1 
Using the Principle of Inclusion and Exclusion
A BC  A  B  C  A B  AC  BC  A BC
= 2,772 + 2,450 + 1,848 – 630 – 420 – 420 + 108
= 5,708 paths that will pass by at least one coffee shop.
Fred has many choices.
In our next example, we will consider an important question: the distribution of Christmas
presents. Every year my family gathers to celebrate the holiday. Each person brings a small
exchange gift, which through a random process is distributed to another family member such that no
one has the gift they brought. Someone always asks if anyone has the same gift they brought. We
are concerned about derangement in my family. The question is, “How much derangement are we
talking about?” There are 15 members of my family. In my next life I will hope for a smaller
family or a different major.
We have a method for finding the number of derangements that was previously discussed.
1 1 1
(1) m
Dm  m!(1    ...
)
m!
1! 2! 3!
For a family of 1, there are no derangements. You get what you brought. Merry Christmas.
For a family of 2, there is 1 derangement. You exchange gifts.
For a family of 3, there are 2 derangements. Let’s start a table, where m is the number of
family members and dm is the number of derangements. While we are at it, we will calculate the
probability of a random distribution being a derangement, P(dm), after finding the total number of
permutations m! for each set.
m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
dm
0
1
2
9
44
265
1854
14833
133496
1334961
14684570
176214841
2290792932
32071101049
481066515714
m!
1
2
6
24
120
720
5040
40320
362880
3628800
39916800
479001600
6227020800
87178291200
1307674368000
P(dm)
0.0000
0.5000
0.3333
0.3750
0.3667
0.3681
0.3679
0.3679
0.3679
0.3679
0.3679
0.3679
0.3679
0.3679
0.3679
That was painful at the end. We exceeded the capacity of Excel and my trusty TI-84 Plus
Silver Edition. So my family has 481,066,515,714 ways to distribute our 15 gifts such that no one
receives the gift they brought. It amazes me that the 15 of us can generate a set of possibilities that
large. I also get a kick out of the fact that there are exactly that many possibilities, not one more or
less – we have found every potential derangement. I suspect our family will grow. My nephews
are in their family-building years. Fortunately we have a way to estimate the number of
derangements for a given family size. Note that the percentage of derangements seems to converge
to
1
= 0.367879…, so five kids from now I can find 20! and just take 36% of that.
e
Works Cited
Bolgomolnv, A. (2010) The Inclusion Exclusion Principle, downloaded from www.cut-theknot.org/arithmetic/.../InclusionExclusion.shtml on July 1, 2010.
Counting: Supplementary Notes and Solutions Manual. The Principle of Inclusion and Exclusion,
downloaded from www.worldscibooks.com/etextbook/6201/6201_chap01.pdf on July 1, 2010.
Powepoint Lecture 9 dated June 18, 2003, downloaded from
students.cis.edu/chenyh/CS250/Section3_2.ppt on July 1, 2010.
Smith, G. (1998) The Inclusion Exclusion Counting Principle, downloaded from
www.bath.ac.uk/~masgcs/book1/amplifications/inc_exc.pdf on July 20, 2010.
Trapa, P. (2005) The Inclusion-Exclusion Principle, downloaded from
www.math.utah.edu/mathcircle/notes/inclusion.pdf on July 22, 2010.
Download