Inclusion and Exclusion Principle Tutor: Zhang Qi Systems Engineering and Engineering Management qzhang@se.cuhk.edu.hk November 2014 Tutor: Zhang Qi (SEEM) Tutorial 7 November 2014 1 / 14
Review Theorem (Addition Version) S 1... S m = m i=1 S i 1 i<j m S i S j + 1 i<j<k m S i S j S k... + ( 1) m 1 S 1... S m Theorem (Subtraction Version) S 1... S m = S S 1... S m The second term of RHS can be computed by addition version. Tutor: Zhang Qi (SEEM) Tutorial 7 November 2014 2 / 14
Example 1 A total of 1232 students have taken a course in Spanish, 879 have taken a course in French, and 114 have taken a course in Russian. Further, 103 have taken courses in both Spanish and French, 23 have taken courses in both Spanish and Russian, and 14 have taken courses in both French and Russian. If 2092 students have taken at least one of those three courses, how many students have taken all three courses? Tutor: Zhang Qi (SEEM) Tutorial 7 November 2014 3 / 14
Solution: Let S, F, R be sets of students who have taken a course in Spanish, French and Russian respectively. We want to get S F R. Then S = 1232, F = 879, R = 114 As S F = 103, S R = 23, F R = 14 S F R = 2092 S F R = S + F + R S F S R F R + S F R we have 2092 = 1232 + 879 + 114 103 23 14 + S F R S F R = 7 Tutor: Zhang Qi (SEEM) Tutorial 7 November 2014 4 / 14
Example 2 How many onto functions are there from a set with six elements to a set with three elements? (Definition: a function f from set X to set Y is onto function if every element y in Y has a corresponding element x in X so that f(x)=y.) Hint: Suppose the three elements are b 1, b 2, b 3, and P 1, P 2, P 3 are properties that b 1, b 2, b 3 are not in the range of the function respectively. Note that a function is onto if and only if it has none of the properties P 1, P 2, P 3. Tutor: Zhang Qi (SEEM) Tutorial 7 November 2014 5 / 14
Solution: The number of onto functions from a set with six elements to a set with three elements is N(P 1 P 2 P 3 ). According to the inclusion-exclusion principle, N(P 1 P 2 P 3 ) = N N(P 1 P 2 P 3 ) = N [N(P 1 ) + N(P 2 ) + N(P 3 )] + [N(P 1 P 2 ) + N(P 1 P 3 ) + N(P 2 P 3 )] N(P 1 P 2 P 3 ) Tutor: Zhang Qi (SEEM) Tutorial 7 November 2014 6 / 14
Solution Cont : Firstly,N = 3 6 as there are three choices for the value of the function at each element of the domain. As N(P i ) is the number of functions that do not have b i in their range, there are two choices for the value of the function ( ) at each element of the 3 domain. Hence N(P i ) = 2 6 and there are of terms of this kind. 1 On the other hand N(P i P j ) is the number of functions that do not have b i, b j in their range, there are only one choice for the value of the function ( ) 3 at each element of the domain. Hence N(P i P j ) = 1 6 and there are 2 of terms of this kind. Last,N(P 1 P 2 P 3 ) = 0. So N(P 1 P 2 P 3 ) = 3 6 ( ) 3 2 6 + 1 ( ) 3 1 6 = 540 2 Tutor: Zhang Qi (SEEM) Tutorial 7 November 2014 7 / 14
Example 3 How many ways are there to assign five different jobs to four different employees if every employee is assigned at least one job? Hint: Consider it as a function from the set of five jobs to the set of four employees. As every employee gets at least one job, the function is a onto function. Solution: It follows from example 2 that ( ) 4 4 5 3 5 + 1 ( ) 4 2 5 2 ( ) 4 1 5 = 240 3 Tutor: Zhang Qi (SEEM) Tutorial 7 November 2014 8 / 14
Example 4 Find the number of integers between 1 and 1000, inclusive, that are not divisible by 5,6, and 8. Hint: Let P 1, P 2, P 3 be the property that an integer is divisible by 5,6 and 8 respectively and A i be the set consisting of those integers in S(1 to 1000) with property P i. We wish to find the number of integers in A 1 A 2 A 3. Notation: For r R, we let [r] be the largest integer less than or equal to r. We use lcm{a, b, c} to stand for the least common multiple of integers. Tutor: Zhang Qi (SEEM) Tutorial 7 November 2014 9 / 14
Firstly, A 1 = [ 1000 5 ] = 200, A 2 = [ 1000 6 ] = 166, A 3 = [ 1000 8 ] = 125. Next, integers in the set A 1 A 2 are divisible by both 5 and 6, which is equivalent to divisible by lcm{5, 6} = 30, so A 1 A 2 = [ 1000 30 ] = 33. Similarly, we have lcm{5, 8} = 40, lcm{6, 8} = 24, lcm{5, 6, 8} = 120. Thus A 1 A 3 = [ 1000 40 ] = 25, A 2 A 3 = [ 1000 24 ] = 41 By inclusion and exclusion principle, A 1 A 2 A 3 = [ 1000 120 ] = 8 A 1 A 2 A 3 = 1000 (200 + 166 + 125) + (33 + 25 + 41) 8 = 600 Tutor: Zhang Qi (SEEM) Tutorial 7 November 2014 10 / 14
Example 5 How many permutations of the letters m,a,t,h,i,s,f,u,n are there such that none of the words math, is, and fun occur as consecutive letters? Hint: We let S be the set of all permutations. P 1 be the property that a permutation in S contains the word math as consecutive letters. And P 2, P 3 be the property that a permutation in S contains the word is and fun as consecutive letters respectively. Let A i be the set of those permutations in S satisfying property P i. We want to find the number of permutations in A 1 A 2 A 3. Tutor: Zhang Qi (SEEM) Tutorial 7 November 2014 11 / 14
Solutions: Firstly, S = 9! Next, we observe that the permutations in A 1 can be thought of as permutations of the following six elements: math, i, s, f, u, n where we treat math as a whole element to make sure for consecutive letters. Hence A 1 = 6! Similarly, we have A 2 = 8!, A 3 = 7! Tutor: Zhang Qi (SEEM) Tutorial 7 November 2014 12 / 14
Solutions Cont : The permutations in A 1 A 2 are permutations of five elements: math, is, f, u, n where we treat math and is as two whole elements at the same time to make sure for consecutive letters. Hence A 1 A 2 = 5! Similarly, we have A 1 A 3 = 4!, A 2 A 3 = 6! Finally,A 1 A 2 A 3 are permutations of math, is and fun A 1 A 2 A 3 = 3! Thus, A 1 A 2 A 3 = 9! 6! 8! 7! + 5! + 4! + 6! 3! = 317658 Tutor: Zhang Qi (SEEM) Tutorial 7 November 2014 13 / 14
Thank you for your time! Tutor: Zhang Qi (SEEM) Tutorial 7 November 2014 14 / 14