Title: Inclusion-Exclusion Rosen 6.5
1Inclusion-Exclusion Rosen 6.5 6.6
- Longin Jan Latecki
- basd on Slides by
- Max Welling, University of California, Irvine
- Vardges Melkonian, Ohio University, Athens
26.5 Inclusion-Exclusion
Its simply a matter of not over-counting the
blue area in the intersection.
3Example on Inclusion/Exclusion Rule (2 sets)
- Question How many integers from 1 through 100
- are multiples of 3 or multiples of 7 ?
- Solution Let Athe set of integers from 1
through 100 which are multiples of 3 - B the set of integers from 1 through 100
- which are multiples of 7.
- Then we want to find n(A ? B).
- First note that A ? B is the set of integers
- from 1 through 100 which are multiples of 21 .
- n(A ? B) n(A) n(B) - n(A ? B) (by
incl./excl. rule) - 33 14 4 43 (by counting the elements
- of the three lists)
4Now three Sets
area 4-31
U
C
area 2-11
area 1
B
A
Image a blue circle has area 4. The intersections
between 2 circles have area 2 and the
intersection between three circles 1. What is the
total area covered? A444 2 -2 -2 1 12
6 1 7.
5Example on Inclusion/Exclusion Rule (3 sets)
- 3 headache drugs A,B, and C were tested on 40
subjects. The results of tests - 23 reported relief from drug A
- 18 reported relief from drug B
- 31 reported relief from drug C
- 11 reported relief from both drugs A and B
- 19 reported relief from both drugs A and C
- 14 reported relief from both drugs B and C
- 37 reported relief from at least one of the
drugs. - Questions
- 1) How many people got relief from none of the
drugs? - 2) How many people got relief from all 3 drugs?
- 3) How many people got relief from A only?
6Example on Inclusion/Exclusion Rule (3 sets)
- We are given n(A)23, n(B)18, n(C)31,
- n(A ? B)11, n(A ? C)19, n(B ? C)14 ,
- n(S)40, n(A ? B ? C)37
- Q1) How many people got relief from none of the
drugs? - By difference rule,
- n((A ? B ? C)c ) n(S) n(A ? B ? C)
40 - 37 3
S
7Example on Inclusion/Exclusion Rule (3 sets)
- Q2) How many people got relief from all 3 drugs?
- By inclusion/exclusion rule
- n(A ? B ? C) n(A ? B ? C)
- - n(A) - n(B) - n(C)
- n(A ? B) n(A ? C) n(B ? C)
- 37 23 18 31 11 19 14 9
- Q3) How many people got relief from A only?
- n(A (B ? C)) (by inclusion/exclusion
rule) - n(A) n(A ? B) - n(A ? C) n(A ? B ? C)
- 23 11 19 9 2
8The Principle of Inclusion-Exclusion
Proof We show that each element is counted
exactly once. Assume element a is in r sets out
of the n sets A1,...,An. -The first term counts
a r-timesC(r,1). -The second term counts a
-C(r,2) times (there are C(r,2) pairs in a set of
r elements). -The kth term counts a -C(r,k)
times (there are C(r,k) k-subsets in a set of r
elements). -... - If kr then there are precisely
(-1)(r1) C(r,r) terms. - For kgtr a is not in
the intersection it is counted 0 times. Total
C(r,1)-C(r,2)...(-1)(r1)C(r,r) Now use
to show that
each element is counted exactly once.
9Applications of Incl.-Excl.
We can use inclusion/exclusion to count the
number of members of a set that do not have a
bunch of properties P1,P2,...,Pn. Call
N(Pi,Pj,Pk,...) the number of elements of a set
that do have properties Pi, Pj, Pk,.... and N the
total number of elements in the set. By
inclusion/exclusion we then have Theorem Let
Ai be the subset of elements of a set A that has
property Pi. The number of
elements in a set A that do not have
properties P1,...Pn is given then
by
10A Picture
U
C
B
A
11Examples
Compute the number of solutions to
x1x2x311 where x1,x2,x3 non-negative integers
and x1 lt3, x2lt4, x4lt6. P1 x1 gt 3 P2 x2 gt
4 P3 x3 gt 6 The solution must have non of the
properties P1,P2,P3. ?The solution of a problem
x1x2x311 with constraints x1 gt 3 is solved as
follows
7 more balls
4 balls in basket x1 already.
Total number of ways C(73-1,7)36
x1 x2 x3
Therefore N-N(P1)-N(P2)-N(P3)N(P1,P2)N(P2,P3)N
(P1,P3)-N(P1,P2,P3) C(113-1,11) C(73-1,7)
C(63-1,6) C(43-1,4) 0.
12Connection with De Morgans law
So we have 2 ways to solve the last
example x1x2x3 11 such that non of the
following properties hold P1 x1 gt 3 P2 x2 gt
4 P3 x3 gt 6 or x1x2x311 such all of the
following properties hold Q1NOT P1
0ltx1lt3 Q2NOT P2 0ltx2lt4 Q3NOT P3 0ltx3lt6
Sometimes this is easier to compute.
13Number of Onto-Functions
Onto or surjective functions A function f from A
to B is onto if for every element b in B there is
an element a in A with f(a)b.
If we have m elements in A and n in B, how
many onto functions are there? ?We want all yi
in the range of the function f. Call Pi the
property that yi is not in the range of the the
function f. Then we are looking for the number of
functions that has none of the properties
P1,...,Pn
x
y
f
A
B
There is no element without incoming arrows
14Number of Onto-Functions
N(P1P2P3) N-N(P1)-N(P2) ... N(P1,P2)
-...(-1)n N(P1,...,Pn). N number of function
from A ? B nm N(Pi) number of functions that
do not have y1 in its range (n-1)m. There are
nC(n,1) such terms. N(Pi,Pj) (n-2)m with
C(n,2) terms. Total nm C(n,1)(n-1)m
C(n,2)(n-2)m ...(-1)(n-1)C(n,n-1)1m. m6
and n3 N(P1P2P3) 36 C(3,1)26
C(3,2)16 540
x
y
f
A
B
There is no element without incoming arrows