Title: Inclusion/Exclusion
1Section 6.5
2Finding the number of elements in the union of 2
sets
- From set theory, we know that the number of
elements in the union of 2 sets is the sum of the
number of elements in each set minus the number
of elements in the intersection of the 2 sets - A ? B A B - A ? B
3Example 1
- A discrete math class consists of 4 students
taking Software Design, 3 students taking CS2, 2
students taking neither, and 1 student taking
both. How many students are in the class? - Let A in SD, B in CS2, C in
neither - So A?B taking both and A?B?C in
discrete - A ? B ? C A B C - A ? B
432-18
4Example 2
- How many positive integers not exceeding 100 are
divisible by 2 or 5? - A divisible by 2 ?100/2? 50
- B divisible by 5 ?100/5? 20
- A ? B divisible by both since they are
mutually prime, this is the numbers divisible by
25 ?100/10? 10 - So A ? B 50 20 - 10 60
5Example 3
- We can use similar means to find the number of
elements outside the union of 2 sets - A recent survey found that 96 of U.S. households
have at least one television, 98 have phone
service, and 95 have both what percentage of
households have neither?
6Solution for example 3
- Let A of households with TV (96) and B
of households with phone service (98) - We know that 95 have both this is A?B
- The total number of households that have either
TV or phone service, A?B is - A B - A?B 9698-95 99
- The total number of households is 100, so the
number that have neither TV nor phone is 100-99,
or 1
7Finding the number of elements in the union of 3
sets
- The sum A B C counts the number of
elements in one set once, the number in 2 sets
twice, and the number in all 3 sets 3 times - Subtracting the number of elements in any pair of
the sets eliminates the double counting - ABC - A?B - A?C - B?C
- But this also eliminates all elements appearing
in all 3 so we add those elements back in - ABC - A?B - A?C - B?C A?B?C
8Example 4
- Suppose there are 2504 computer science majors at
a school of these - 1876 have taken C, 999 have taken Java, 345
have taken C and - 876 have taken both Java and C, 231 have taken
C and C, and 290 have taken Java and C - How many CS majors have not taken any of these
languages?
9Example 4
- Let J be the number who have taken Java (999),
P be the number who have taken C (1876) and
C the number who have taken C (345) - Then
- J?P?C JPC - J?P - J?C - P?C
J?P?C - 9991876345 - 876 - 231 - 290 189 2012
- So 2504 - 2012 or 492 have taken none of these
languages
10Principle of Inclusion/Exclusion
- Let A1, A2, , An be finite sets then
- A1 ? A2 ? ? An
- ? Ai - ? Ai ? Aj
- 1?i?n 1?iltj?n
- ? Ai ? Aj ? Ak -
- 1?iltjltk?n
- (-1)n1A1 ? A2 ? ? An
11Proof
We want to show that each element in the union of
the sets is counted exactly once suppose a is a
member of exactly r of the sets A1 An where 1
? r ? n. This element is counted C(r,1) times
by ?Ai and C(r,2) times by ?Ai ? Aj and, in
general, C(r,m) times by summation involving m
of the sets So element a is counted
C(r,1)-C(r,2)C(r,3)- C(r,r) times
12Proof continued
Recall the binomial theorem (xy)n ?
C(n,j)xn-jyj (as j goes from 0 to n) We can show
from this theorem that ?(-1)kC(n,k) 0 (as k
goes from 0 to n) thus C(r,1) - C(r,2)
C(r,3)- (-1)rC(r,r) 0 Changing the exponent
of -1 in the last term to r1 gives us C(r,1) -
C(r,2) C(r,3)- (-1)r1C(r,r) 1 So each
element in the union is counted exactly once.