lecture 18 6.5 & 6.6 inclusion-exclusion. 6.5 inclusion-exclusion a ab u it’s simply a matter...

15
Lecture 18 6.5 & 6.6 Inclusion- Exclusion

Upload: kiersten-tabler

Post on 14-Dec-2015

213 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Lecture 18 6.5 & 6.6 Inclusion-Exclusion. 6.5 Inclusion-Exclusion A AB U It’s simply a matter of not over-counting the blue area in the intersection

Lecture 18

6.5 & 6.6 Inclusion-Exclusion

Page 2: Lecture 18 6.5 & 6.6 Inclusion-Exclusion. 6.5 Inclusion-Exclusion A AB U It’s simply a matter of not over-counting the blue area in the intersection

6.5 Inclusion-Exclusion

AA B

U

A B | | | | | | | |A B A B A B

It’s simply a matter of not over-counting the blue area in the intersection.

Page 3: Lecture 18 6.5 & 6.6 Inclusion-Exclusion. 6.5 Inclusion-Exclusion A AB U It’s simply a matter of not over-counting the blue area in the intersection

Now three Sets

A B

C

A B

A C B CA B C

U

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 areacovered?

A=4+4+4 – 2 -2 -2 + 1 = 12 – 6 + 1 = 7.

area = 2-1=1

area = 1

area = 4-3=1

| | | | | | | | | | | | | | | |A B C A B C A B B C C A A B C

Page 4: Lecture 18 6.5 & 6.6 Inclusion-Exclusion. 6.5 Inclusion-Exclusion A AB U It’s simply a matter of not over-counting the blue area in the intersection

General Case

1 21 ( ) ( )

1

| ... | | | | | | | ...

( 1) | ... |

n

n i i j i j ki pairs ij triples ijk

ni j k n

A A A A A A A A A

A A A A

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-times=C(r,1).-The second term counts ‘a’ -C(r,2) times (there are C(r,2) pairs in a set of r elements).-The k’th term counts ‘a’ -C(r,k) times (there are C(r,k) k-subsets in a set of r elements).-...- If k=r then there are precisely (-1)^(r+1) C(r,r) terms.- For k>r ‘a’ is not in the intersection: it is counted 0 times.Total: C(r,1)-C(r,2)+...+(-1)^(r+1)C(r,r)

Now use: to show that each element is counted exactly once. 0

1

1

( 1) ( , ) 0

1 ( 1) ( , )

rk

k

rk

k

C r k

C r k

Page 5: Lecture 18 6.5 & 6.6 Inclusion-Exclusion. 6.5 Inclusion-Exclusion A AB U It’s simply a matter of not over-counting the blue area in the intersection

Applications of Incl.-Excl.We can use inclusion/exclusion to count the number of members of aset 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 propertiesPi, 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:

1 2 3

1 21 , 1 , , 1

| | | ... |

( ) ( , ) ( , , ) ... ( 1) ( , ,..., )

( , , ,...) | ... |

n

n n nn

i i j i j k ni i j i j k

i j i j k

i j k i j k

A A A A A

N N P N P P N P P P N P P P

with N P P P A A A

Page 6: Lecture 18 6.5 & 6.6 Inclusion-Exclusion. 6.5 Inclusion-Exclusion A AB U It’s simply a matter of not over-counting the blue area in the intersection

A Picture

A B

C

A B

A C B CA B C

U

| | | |U A B C

Page 7: Lecture 18 6.5 & 6.6 Inclusion-Exclusion. 6.5 Inclusion-Exclusion A AB U It’s simply a matter of not over-counting the blue area in the intersection

Examples

Compute the number of solutions to x1+x2+x3=11where x1,x2,x3 non-negative integers and x1 <=3, x2<=4, x4<=6. P1: x1 > 3 P2: x2 > 4P3: x3 > 6The solution must have non of the properties P1,P2,P3.

The solution of a problem x1+x2+x3=11 with constraints x1 > 3 is solved as follows:

x1 x2 x3

7 more balls

4 balls in basket x1already.

Total number of ways: C(7+3-1,7)=36

Therefore: N-N(P1)-N(P2)-N(P3)+N(P1,P2)+N(P2,P3)+N(P1,P3)-N(P1,P2,P3) C(11+3-1,11) – C(7+3-1,7) – C(6+3-1,6) ... – 0.

Page 8: Lecture 18 6.5 & 6.6 Inclusion-Exclusion. 6.5 Inclusion-Exclusion A AB U It’s simply a matter of not over-counting the blue area in the intersection

Connection with De Morgan’s law

1 1

11 ,1 1

1

| | | | | | | | ... ( 1) | ... |

n n

i ii i

n n n nn

i i i i j ni i ji i

i j

n

ii

A A

A U A U A A A A A

A

So we have 2 ways to solve the last example:x1+x2+x3 = 11 such that non of the following properties hold:P1: x1 > 3 P2: x2 > 4P3: x3 > 6

or x1+x2+x3=11 such all of the following properties hold: Q1=NOT P1: 0<x1<=3Q2=NOT P2: 0<x2<=4Q3=NOT P3: 0<x3<=6

Sometimes this is easier to compute.

Page 9: Lecture 18 6.5 & 6.6 Inclusion-Exclusion. 6.5 Inclusion-Exclusion A AB U It’s simply a matter of not over-counting the blue area in the intersection

Number of Onto-Functions

A B

fy

x

There is no element without incoming arrows

Onto or surjective functions:A function f from A to B is onto if for every element b in B there is anelement a in A with f(a)=b.

If we have m elements in A and n in B, how manyonto 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

Page 10: Lecture 18 6.5 & 6.6 Inclusion-Exclusion. 6.5 Inclusion-Exclusion A AB U It’s simply a matter of not over-counting the blue area in the intersection

Number of Onto-Functions

A B

fy

x

There is no element without incoming arrows

N-N(P1)-N(P2) ... + N(P1,P2) -...+(-1)^n N(P1,...,Pn).

N: number of function from A B: n^mN(Pi): number of functions that do not have y1 inits range: (n-1)^m.There are n=C(n,1) such terms.N(Pi,Pj): (n-2)^m with C(n,2) terms.

Total:n^m – C(n,1)(n-1)^m + C(n,2)(n-2)^m – ...+(-1)^(n-1)C(n,n-1)1^m.

Page 11: Lecture 18 6.5 & 6.6 Inclusion-Exclusion. 6.5 Inclusion-Exclusion A AB U It’s simply a matter of not over-counting the blue area in the intersection

DerangementsA derangement: is a permutation that leaves non of the elements in its place.

Example: (3,2,1) is not a derangement, but (2,3,1) is one.

Then: how many derangements are there of a set of n elements.This is the answer to the Hatcheck problem:If n people check in their hats and the employee randomly returns hats back to people: what is the probability no-one gets their own hat back:

P = number of derangements of n / total number of permutations = Dn / n!

Page 12: Lecture 18 6.5 & 6.6 Inclusion-Exclusion. 6.5 Inclusion-Exclusion A AB U It’s simply a matter of not over-counting the blue area in the intersection

Derangements

A B

permutation

A permutation is a one-to-one correspondence of a set A with n elementsto a B set n elements. There are n! such functions.

Call Pi the property that xi is mapped to yi at the same “position”.Then the total number of derangements is thenumber of permutation that do not haveproperties P1,P2,P3,...Pn.

Example:(1,2,3)A1: (1,2,3) & (1,3,2) A2: (1,2,3) & (3,2,1)A3: (1,2,3) & (2,1,3)A12: (1,2,3)A13: (1,2,3)A23: (1,2,3)A123: (1,2,3)

total = 6-3x2+3x1-1=2namely: (3,1,2) and (2,3,1)

Page 13: Lecture 18 6.5 & 6.6 Inclusion-Exclusion. 6.5 Inclusion-Exclusion A AB U It’s simply a matter of not over-counting the blue area in the intersection

Derangements

More generally we have:

N(Pi) = (n-1)! and there are C(1,n) such termsN(Pi,Pj) = (n-2)! and there are C(n,2) such terms.

Total:Dn = n! – C(n,1)(n-1)! + C(n,2)(n-2)! - ...+ (-1)^n C(n,n) (n-n)! = n! – [n!/1!(n-1)!] (n-1)! + [n!/2!(n-2)!](n-2)! ... = n!(1-1/1! + 1/2! -1/3!+...+(-1)^n 1/n!)

P(hatcheck) = 1-1/1!+1/2!-...(-1)^n1/n! = 0.368 if n is large.

so even if 1M people check in their hat there is a probability of 0.368 that no-one gets there hat returned correctly.

Page 14: Lecture 18 6.5 & 6.6 Inclusion-Exclusion. 6.5 Inclusion-Exclusion A AB U It’s simply a matter of not over-counting the blue area in the intersection

Excercises

On White Board.

Page 15: Lecture 18 6.5 & 6.6 Inclusion-Exclusion. 6.5 Inclusion-Exclusion A AB U It’s simply a matter of not over-counting the blue area in the intersection

THE END...

Next time we will do a review of the material you need to know for your final exam.

This will be useful if you want to know what kind of questionsto expect and on what topics.

I will also ask you to fill out evaluation forms.