Lecture 9 he Principle of Inclusion/Exclusion hese notes are based on a pair of lectures originally written by (Manchester s own) Prof. Nige Ray. Reading: he Principle of Inclusion/Exclusion appears in the first year module Foundations of Pure Mathematics, but it is also a standard technique in Combinatorics and so is discussed in many other books 1. he Wikipedia article, which gives a version of the proof in Section 9.2.2 below, is also a good place to start. 9.1 Introduction: a familiar example Suppose we have some finite universal set U and two subsets, 1 U and 2 U. If the subsets are disjoint then it s easy to work out the number of elements in their union: 1 \ 2 ; ) 1 [ 2 1 + 2. he case where the subsets have a non-empty intersection provides the simplest instance of the result we re going to develop today, the Principle of Inclusion/Exclusion. You may already know a similar result from Probability. Lemma 9.1 (Inclusion/Exclusion for two sets). If 1 and 2 are finite sets then 1 [ 2 1 + 2 1 \ 2. (9.1) Note that this formula, which is illustrated in Figure 9.1, works even 1 \ 2 ;, as then 1 \ 2 0. Proof. o prove this result, note that the sum 1 + 2 counts each member of the intersection 1 \ 2 twice, once as a member of 1 and then again as a member 1 See, for example, Dossey, Otto, Spence, and Vanden Eynden (2006), Discrete Mathematics or, for a short, clear account, Anderson (1974), A First Course in Combinatorial Mathematics. 9.1
U U 1 2 1 1 2 2 Figure 9.1: In the example at left 1 \ 2 ;, so 1 [ 2 1 + 2, but in the example at right 1 \ 2 6 ; and so 1 [ 2 1 + 2 1 \ 2 < 1 + 2. U 1 \ 2 1 2 2 \ 1 Figure 9.2: Here 1 \ 2 and 1 \ 2 are shown in shades of blue, while 2 \ 1 is in yellow. of 2. Subtracting 1 \ 2 corrects for this double-counting. Alternatively, for those who prefer proofs that look more like calculations, begin by defining 1 \ 2 {x 2 U x 2 1, but x/2 2 }. hen, as is illustrated in Figure 9.2, 1 ( 1 \ 2 ) [ ( 1 \ 2 ). Further, the sets 1 \ 2 and 1 \ 2 are disjoint by construction, so 1 1 \ 2 + 1 \ 2 or 1 \ 2 1 1 \ 2. (9.2) Similarly, 1 \ 2 and 2 are disjoint and 1 [ 2 ( 1 \ 2 ) [ 2 so 1 [ 2 1 \ 2 + 2 1 1 \ 2 + 2 1 + 2 1 \ 2 where, in passing from the first line to the second, we have used (9.2). he last line is the result we were trying to prove, so we are finished. 9.2 Principle and proof Before moving to the general case, let s consider one more small example, this time with three subsets 1, 2 and 3 : we can handle this case by clever use 9.2
U 1 2 1 2 3 Figure 9.3: In the diagram above all of the intersections appearing in Eqn. (9.3) are nonempty. of Lemma 9.1 from the previous section. If we regard ( 1 [ 2 )asasinglesetand 3 as a second set, then Eqn. (9.1) says ( 1 [ 2 ) [ 3 ( 1 [ 2 ) + 3 ( 1 [ 2 ) \ 3 ( 1 + 2 1 \ 2 )+ 3 ( 1 [ 2 ) \ 3 1 + 2 + 3 1 \ 2 ( 1 [ 2 ) \ 3 Focusing on the final term, we can use standard relations about unions and intersections to say ( 1 [ 2 ) \ 3 ( 1 \ 3 ) [ ( 2 \ 3 ). hen, applying Eqn. (9.1) to the pair of sets ( 1 \ 3 )and( 2 \ 3 ), we obtain ( 1 [ 2 ) \ 3 ( 1 \ 3 ) [ ( 2 \ 3 ) 1 \ 3 + 2 \ 3 ( 1 \ 3 ) \ ( 2 \ 3 ) 1 \ 3 + 2 \ 3 1 \ 2 \ 3 where, in going from the second line to the third, we have used ( 1 \ 3 ) \ ( 2 \ 3 ) 1 \ 2 \ 3. Finally, putting all these results together, we obtain the analogue of Eqn. (9.1) for three subsets: ( 1 [ 2 ) [ 3 1 + 2 + 3 1 \ 2 ( 1 [ 2 ) \ 3 1 + 2 + 3 2 \ 3 ( 1 \ 3 + 2 \ 3 ( 1 \ 2 \ 3 ) ( 1 + 2 + 3 ) ( 1 \ 2 + 1 \ 3 + 2 \ 3 ) + 1 \ 2 \ 3. (9.3) Figure 9.3 helps make sense of this formula and prompts the following observations: 9.3
Elements of 1 [ 2 [ 3 that belong to exactly one of the j are counted exactly once by the sum ( 1 + 2 + 3 ) and do not contribute to any of the terms involving intersections. Elements of 1 [ 2 [ 3 that belong to exactly two of the j are doublecounted by the sum, ( 1 + 2 + 3 ), but this double-counting is corrected by the term involving two-fold intersections. Finally, elements of 1 [ 2 [ 3 that belong to all three of the sets are triple-counted by the initial sum ( 1 + 2 + 3 ). his triple-counting is then completely cancelled by the term involving two-fold intersections. hen, finally, this cancellation is repaired by the final term, which counts each such element once. 9.2.1 he general case he Principle of Inclusion/Exclusion generalises the results in Eqns. (9.1) and (9.3) to unions of arbitrarily many subsets. heorem 9.2 (he Principle of Inclusion/Exclusion). If U is a finite set and { j } n j1 is a collection of n subsets, then n[ j 1 [ [ n j1 or, more concisely, 1 + + n 1 \ 2 n 1 \ n + 1 \ 2 \ 3 + + n 2 \ n 1 \ n +( 1) m 1.. 1applei 1 apple applei mapplen i1 \ \ im +( 1) n 1 1 \ \ n (9.4) 1 [ [ n One can prove this in at least two ways: I {1,...,n},I6;( 1) I 1 \ i2i i (9.5) by induction, with a calculation that is essentially the same as the one used to obtain the n 3case Eqn.(9.3) fromthen 2one Eqn.(9.1); by showing that each x 2 1 [ [ n contributes exactly one to the sum on the right hand side of Eqn. (9.5). he first approach is straightforward, if a bit tedious, and so is left as an exercise, but the second is more interesting and so it s the one we ll study here. 9.4
9.2.2 Proof he key idea is to think of the the elements of 1 [ [ n individually and ask what each one contributes to the sum in Eqn. (9.5). Suppose that an element x 2 1 [ [ n belongs to exactly of the subsets, with 1 apple apple n: we will prove that x makes a net contribution of 1. For the sake of concreteness, we ll say x 2 i1,..., i where i 1,...,i are distinct elements of {1,...,n}. As we ve assumed that x belongs to exactly of the subsets j, it contributes atotalof to the first row, 1 + + n, of the long sum in Eqn. (9.4). Further, x contributes a total of to the sum in the row involving two-way 2 intersections 1 \ 2 n 1 \ n. o see this, note that if x 2 j \ k then both j and k must be members of the set {i 1,...,i}. Similar arguments show that if k apple, then x contributes a total of! k k!( k)! to the sum in the row of Eqn. (9.4) that involves k-fold intersections. Finally, for k> there are no k-fold intersections that contain x and so x makes a contribution of zero to the corresponding rows in Eqn. (9.4). Putting these observations together we see that x make a net contribution of +... +( 1) 1 (9.6) 2 3 his sum can be made to look more familiar by considering the following application of the Binomial heorem: hus or 0 (1 1) ( 1) j (1) j j j0 1 + +... +( 1). 2 3 0 1 apple + 2 + 2 3 3... +( 1) 1 1.... +( 1) 1 he left hand side here is the same as the sum in Eqn. (9.6) and so we ve established that any x which belongs to exactly of the subsets j makes a net contribution of 1 to the sum on the right hand side of Eqn. (9.5). And as every x 2 1 [ [ n must belong to at least one of the j, this establishes the Principle of Inclusion/Exclusion. 9.5
9.2.3 Alternative proof Students who like proofs that look more like calculations may prefer to reformulate the arguments from the previous section in terms of characteristic functions (sometimes also called indicator functions) ofsets.ifwedefine : U! {0, 1} by 1 if s 2 (s) 0 otherwise then we can calculate for a subset U as follows: (x) x2u! (x) + x2 x/2 x2 (x)! (x) (9.7) where, in passing from the second to third lines, I have dropped the second sum because all its terms are zero. hen the Principle of Inclusion/Exclusion is equivalent to x2 1 [ [ n 1 [ [ n (x) i 1) I {1,...,n},I6;( \ I 1 i2i ( 1) I 1 I {1,...,n},I6; n x2 i2i i 0 @ i2i i (x) x2 i2i i 1 i2i (x) A i which I have obtained by using of Eqn. (9.7) to replace terms in Eqn. (9.5) with the corresponding sums of values of characteristic functions. We can then rearrange the expression on the right, first expanding the ranges of the sums over elements of k-fold intersections (this doesn t change the result since (x) 0 for x /2 ) andtheninterchangingtheorderofsummationsothat the sum over elements comes first. his calculation proves that the Principle of Inclusion/Exclusion is equivalent to the following: x2 1 [ [ n 1 [ [ n (x) n x2 1 [ [ n n 9.6 x2 1 [ [ n i2i i (x)! i2i (x) (9.8) i
Arguments similar to those in Section 9.2.2 then establish the following results, the last of which, along with Eqn. (9.8), proves heorem 9.2. Proposition 9.3. If an element x 2 1 [ [ n belongs to exactly of the sets { j } n j1 then for k apple we have i2i (x) i k! k!( k)! while if k> i2i (x) 0 i Proposition 9.4. For an element x 2 1 [ [ n we have n i2i i (x) n k 1. Lemma 9.5. he characteristic function 1 [ [ n of the set 1 [ [ n satisfies 1 [ [ n (x) 9.3 An example n i2i i (x). How many of the integers n with 1 apple n apple 150 are relatively prime to 70? his is a job for the Principle of Inclusion/Exclusion. First note that the prime factorization of 70 is 70 2 5 7. Now consider a universal set U {1,...,150} and three subsets 1, 2 and 3 consisting of multiples of 2, 5 and 7, respectively. A member of U that shares a prime factor with 70 belongs to at least one of the j and so the number we re after is U 1 [ 2 [ 3 U ( 1 + 2 + 3 ) +( 1 \ 2 + 1 \ 3 + 2 \ 3 ) 1 \ 2 \ 3. 150 (75 + 30 + 21) + (15 + 10 + 4) 2 150 126 + 29 2 51 (9.9) where I have used the numbers in able 9.1 which lists the various cardinalities that we need. 9.7
Set Description Cardinality 1 multiples of 2 75 2 multiples of 5 30 3 multiples of 7 21 1 \ 2 multiples of 10 15 1 \ 3 multiples of 14 10 2 \ 3 multiples of 35 4 1 \ 2 \ 3 multiples of 70 2 able 9.1: Eqn. (9.9). he sizes of the various intersections needed for the calculation in 9.8