58
Pigeonhole

Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

  • View
    247

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

Pigeonhole

Page 2: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

Pigeonhole principle

• If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons.

…but then why have just pigeons, why not rats?

• A function from one finite set to a smaller finite set cannot be one-to-one: there must be at least two elements in the domain that have the same image in the co-domain.

• If f is a function from a finite set X to a smaller finite set Y, then f cannot be one-to-one. That is, there must be two distinct elements x1, x2 X such that f(x1) = f(x2).

f

Finite set Finite setn elements m elements>

Page 3: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

• You might say that you already know this. Then why does one need to narrate it in such arcane mathematical lingo?• that is because even though PHP looks simple, it is foolish to underestimate it.The difficulty is NOT the PHP.The difficulty is that YOU CAN’T SEE WHAT ARE THE PIGEONS AND WHAT ARE THE HOLES. It’s a problem with your observation powers…and hence the application of the principle.

Page 4: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

• Prove that in any group of eight people, at least two have birthdays which fall on the same day of the week in any given year.

X

p1

p2

p3

p4

p5

p6

p7

p8

Let X be the set of people.

|X| = 8.

Let Y be the set of days in the week.

|Y| = 7.

Define f : X Y, such that f maps the person to the day of week in which he was born.

By PHP, at least two people will have birthdays which fall on the same day of the week.

Mon

Tue

Wed

Thur

Fri

Sat

Sun

Y

f

Page 5: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

• Given any set of four integers, there must be at least two that have the same remainder when divided by three.

X

a

b

c

d

0

1

2

Y

f Let X be the set of any four integers selected.

|X| = 4.

Let Y be the set of possible remainders when divided by 3.

|Y| = 3.

Define f : X Y, such that f(x) = y if x leaves a remainder of y when divided by 3.

By PHP (|X|>|Y|), at least two integers will have the same remainder when divided by 3.

Page 6: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

• A man has 10 pairs of socks in his sock drawer. Five pairs are white and five pairs are black. He is selecting socks in the dark. How many socks must he choose to ensure that he has at least one pair of the same color?

• Forget about PHP for a moment.

• Take out first sock. What color could it be?

• Take out second sock. What if it is the same color as the first one?

• What if it is not?

Page 7: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

• Let A = {1,2,3,4,5,6,7,8}. Prove that if 5 distinct integers are selected from A, at least one pair of integers have a sum of 9.

• Try some examples: – select 1,3,4,6,7. Then we can find at least a pair: 3+6 = 9– select 2,3,5,6,7. Then we can find at least a pair: 2+7 = 9 (Of course,

we can also find another: 3+6 = 9 but it’s ok… the claim is that you can find at least one pair).

• So can you see the pigeons? And the holes?

Page 8: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

f Let X be the set of any five distinct integers selected from 1 to 8. |X| = 5.

Let Y = { {1,8}, {2,7}, {3,6}, {4,5} }. |Y| = 4.

Define f : X Y, such that f(x) = y if x y.

By PHP (|X|>|Y|), at least two elements (say a and b) in X will map to one element {i,j} in Y.

Meaning that a {i,j} and b {i,j}.

Since a b,then either a=i and b=j or vice versa.

In any case, a + b = 9.

Y

{1,8}

{2,7}

{3,6}

{4,5}

X

a

b

c

d

e

Page 9: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

• How many integers must we select from 1 to 100 to ensure that two of them add up to 101?

•Divide the numbers 1 to 100 into 50 pairs: {1, 100}, {2, 99}, …, {50, 51}.

•If we select 51 numbers, then at least 2 of them must come from the same pair.

Page 10: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

• During a month with 30 days, a baseball team plays at least 1 game a day, but no more that 45 games in total for that month. Show that there must be a period of some number of consecutive days, during which the team must play exactly 14 games.

• Try an example:

– Day 1: 1 Day 7: 1 Day 13: 2 Day 19: 2 Day 25: 1– Day 2: 2 Day 8: 2 Day 14: 2 Day 20: 1 Day 26: 1– Day 3: 1 Day 9: 1 Day 15: 1 Day 21: 1 Day 27: 1– Day 4: 2 Day 10: 3 Day 16: 2 Day 22: 1 Day 28: 1– Day 5: 1 Day 11: 3 Day 17: 1 Day 23: 1 Day 29: 1– Day 6: 2 Day 12: 1 Day 18: 2 Day 24: 1 Day 30: 1

• Total = 43 games

Hmmm… 13 games (or 15 if extend to day 10)

Page 11: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

• Try an example:

– Day 1: 1 Day 7: 1 Day 13: 2 Day 19: 2 Day 25: 1– Day 2: 2 Day 8: 2 Day 14: 2 Day 20: 1 Day 26: 1– Day 3: 1 Day 9: 1 Day 15: 1 Day 21: 1 Day 27: 1– Day 4: 2 Day 10: 3 Day 16: 2 Day 22: 1 Day 28: 1– Day 5: 1 Day 11: 3 Day 17: 1 Day 23: 1 Day 29: 1– Day 6: 2 Day 12: 1 Day 18: 2 Day 24: 1 Day 30: 1

• Total = 43 games

Hmmm… 12 games (or 15 if extend to day 10)

– Day 1: 1 Day 7: 1 Day 13: 2 Day 19: 2 Day 25: 1– Day 2: 2 Day 8: 2 Day 14: 2 Day 20: 1 Day 26: 1– Day 3: 1 Day 9: 1 Day 15: 1 Day 21: 1 Day 27: 1– Day 4: 2 Day 10: 3 Day 16: 2 Day 22: 1 Day 28: 1– Day 5: 1 Day 11: 3 Day 17: 1 Day 23: 1 Day 29: 1– Day 6: 2 Day 12: 1 Day 18: 2 Day 24: 1 Day 30: 1

• Total = 43 games

Hmmm… 12 games (or 16 if extend to day 11)

Page 12: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

– Day 1: 1 Day 7: 1 Day 13: 2 Day 19: 2 Day 25: 1– Day 2: 2 Day 8: 2 Day 14: 2 Day 20: 1 Day 26: 1– Day 3: 1 Day 9: 1 Day 15: 1 Day 21: 1 Day 27: 1– Day 4: 2 Day 10: 3 Day 16: 2 Day 22: 1 Day 28: 1– Day 5: 1 Day 11: 3 Day 17: 1 Day 23: 1 Day 29: 1– Day 6: 2 Day 12: 1 Day 18: 2 Day 24: 1 Day 30: 1

• Total = 43 games

Found it! Day 8 – Day 14: Exactly 14 games.

Page 13: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

• Try ANOTHER example

– Day 1: 1 Day 7: 1 Day 13: 3 Day 19: 1 Day 25: 1– Day 2: 1 Day 8: 1 Day 14: 2 Day 20: 1 Day 26: 1– Day 3: 1 Day 9: 1 Day 15: 3 Day 21: 1 Day 27: 1– Day 4: 1 Day 10: 1 Day 16: 2 Day 22: 1 Day 28: 1– Day 5: 1 Day 11: 1 Day 17: 3 Day 23: 1 Day 29: 1– Day 6: 1 Day 12: 2 Day 18: 4 Day 24: 1 Day 30: 1

• Total = 42 games

Day 3 – Day 13: Exactly 14 games.

• So can you see the pigeons? And the holes? (Not obvious right?)

Page 14: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

• We will have to ‘extract out’ the pigeons and the holes.

• Let the number of games played on the i-th day by ai.

• Let bi be the total number of games played from the first day to the i-th day. – Meaning that…

• b1 = a1

• b2 = a1 + a2

• b3 = a1 + a2 + a3

• …

• b30 = a1 + a2 + … + a30

• So we know that (1) b1 < b2 < b3 < …< b30 ; (2) 1 bi 45

Page 15: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

• We therefore form another increasing sequence:• b1 + 14

• b2 + 14

• b3 + 14

• …

• b30 + 14

And this will also have the property that – (1) b1 + 14 < b2 + 14 < b3 + 14 < … < b30 + 14;

– (2) 15 bi+14 59 (Since 1 bi 45)

Page 16: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

Let X be the set{b1 , … , b30 , b1+14 , … , b30+14}. |X| = 60.

Let Y be the set of {1,2,…,59}. |Y| = 59.

Define f : X Y, s.t. f(x) = y iff x = y

X Y

b1

b2

b3

b30

b1+14

b2+14

b3+14

b30+14

f

1

2

3

4

59

By PHP (|X|>|Y|), at least two elements in X will map to the the same element in Y. Q: Which two elements?

Both of the elements cannot be of the form of bi and bj since the sequence of bi’s are strictly increasing (bi bj).

Similarly, both of the elements cannot be of the form of bi+14 and bj +14.

Page 17: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

b1

b2

b3

b30

b1+14

b2+14

b3+14

b30+14

f

1

2

3

4

59

Therefore one of the elements is of the form bi and the other is of the form bj +14.

So bi = bj +14

Which means that bi - bj = 14

So the 14 games are played from day j+1 to day i.

Page 18: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

Generalized Pigeonhole Principle

Page 19: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

GENERALIZED Pigeonhole principle

• If n pigeons fly into m pigeonholes and n > km, (where k is some positive integer) then at least one hole must contain k+1 or more pigeons.

• For any function f from a finite set X to a finite set Y such that |X| > k.|Y|, then there is some y in Y such that y is the image of at least k+1 (or ceiling of |X| / |Y|) distinct elements of X.

• (Contrapositive form) For any function f from a finite set X to a finite set Y, if for each y in Y, f -1(y) has at most k elements, then X has at most k.|Y| elements.

Page 20: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

GENERALIZED Pigeonhole principle• If n pigeons fly into m pigeonholes and n > km, (where k is

some positive integer) then at least one hole must contain k+1 or more pigeons.

• Example:– If 32 pigeons fly into 10 pigeonholes, then at least one hole must

contain 4 or more pigeons (4 = 32/10 and take the ceiling).

– (contrapositive form) If each pigeonhole has at most 7 pigeons, then 10 pigeonholes have at most 70 pigeons.

Page 21: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

• (Eg. 1) There are 44 chairs in a room and five tables. Prove that some table must have at least 9 chairs around it.

Let X be the set of 44 chairs. |X| = 44.

Let Y be the set of tables. |Y| = 5.

Define f : X Y, such that f(x) = (y) if chair x is placed at table y.

f

Y

holes are the 5 tables

X

pigeons are the 44 chairs

By Generalized PHP (|X|> 8|Y|), there is a yY (some table) such that y is the image of at least 9 distinct points in X… meaning that there is a table with at least 9 chairs around it.

Page 22: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

• (Eg. 2) In a group of 85 people, at least 4 must have the same last initial.

Let X be the set of people. |X| = 85.

Let Y be the set of alphabets. |Y| = 26.

Define f : X Y, such that f(x) = (y) if the last initial of person x is y.

f

X

pigeons are the 85 people

By Generalized PHP (|X|> 3|Y|), there is a yY (some alphabet) such that y is the image of at least 4 distinct points in X… meaning that there is a group of at least 4 people who have the same last initial.

Y

holes are the 26 alphabets

Page 23: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

• (Eg. 3) There are 42 students who are to share 12 computers. Each student uses exactly 1 computer, and no computer is used by more that 6 students. Show that at least 5 computers are used by 3 or more students.

Let X be the set of 42 students. |X| = 42.Let Y be the set of 12 computers. |Y| = 12.Define f : X Y, such that f(x) = y if x uses computer y.

f

We can divide the computers in Y into those which are used by 3 or more students (k), and those used by 2 or less (12-k).

k computers serve at most 6k students. 12-k computers serve at most 2(12-k) students.

By Generalized PHP (Contrapositive form), 6k + 2(12-k) |X|. (Now, |X|=42)

So k 4.5 … And since k is an integer, k 5.

X

pigeons are the 42 students

Y

holes are the 12 computers

k

Page 24: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

• (Eg. 4) Assume that in a group of 6 people, each pair of individuals consists of two friends or two enemies. Show that there are either 3 mutual friends or 3 mutual enemies

Let X be the set of the other 5 people. |X| = 5.

Let Y be the set of {0,1}. |Y| = 2.

Define f : X Y, such that f(x) = 1 if x is a friend of A; otherwise f(x) = 0.

f

By Generalized PHP (|X|> 2|Y|), there is a yY such that y is the image of at least 3 distinct points in X… meaning that A has either at least 3 friends or at least 3 enemies.

(We’re not done yet… )

Let A be one of the 6 people.

X

pigeons are the other 5 people

B

C

D

E

F

Y

2 holes – friend or enemy with A

A’s friend

A’s enemy

Page 25: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

• (Eg. 4) Assume that in a group of 6 people, each pair of individuals consists of two friends or two enemies. Show that there are either 3 mutual friends or 3 mutual enemies

• Ok, we know that A has either at least 3 friends or at least 3 enemies. But are these who are friends with A, also friends with each other? (keyword ‘mutual’)… still some more to prove…

• Case 1: (A has at least 3 friends)– Without loss of generality, say these 3 friends are B, C, D.

– Either there is or there is not a friendship between two persons in the group B, C, D.• If there is a friendship between two persons in the group B, C, D, then those two persons,

together with A, form the 3 mutual friends.• If there is NO friendship between two persons in the group B, C, D, then B, C, D, form the 3

mutual enemies.

• Case 2: (A has at least 3 enemies)– …for you to fill in…reasoning similar with case 1…

• In either case, we have shown that there are either 3 mutual friends or 3 mutual enemies.

Page 26: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

Composition of Functions

• Let f : A B and g : B C be functions.• The composition of f and g is a function g f : A C, defined

by(g f)(x) = g(f(x)).

• Let f : R R by f(x) = 1 – x.

• Let g : R – {0} R by g(x) = 1 – 1/x.

• Then (g f)(x) = 1 – 1/(1 – x) = x/(x – 1).

• Also, (f g)(x) = 1 – (1 – 1/x) = 1/x.

• What is the domain of g f?• What is the domain of f g?

Page 27: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

• Begin with the month in which you were born (Jan = 1, Feb = 2, …)• Multiply it by 4.• Add 13.• Then multiply that by 25.• Subtract 200.• Add to this the day of the month on which you were born.

• Double that number.

• Subtract 40.

• Multiply by 50.

• Add to this the last two digits of the year in which you were born.

• Subtract 10500.

• What is the result?

Page 28: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

• Let f(m) = 4m + 13.

• Let g(x) = 25x – 200.

• Let h(x, d) = 50(2(x + d) – 40).

• Let k(x, y) = x + y – 10500.

• Compose these function, where m = month, d = day, and y = year in which you were born.

10,000m +100d+94

Page 29: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

Identity function

• Let A be any set.

• The identity function iA is the function

iA : A A

defined by

iA(x) = x.

Page 30: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

• Let f : R to R by f(x) = 1 – x.

• Then f f = iR.

• Let g : R – {0} to R – {1} by g(x) = 1 – 1/x.

• Then g g g = iR – {0}.

• Also, g f g f = iR – {1}.

• Theorem: Let f : A B. Then

– iA f = f.

– f iB = f.

• Theorem: Let f : A B be a one-to-one correspondence. Then

– f –1 f = iA.

– f f –1 = iB.

Page 31: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

• Let f : R to R by f(x) = 1 – x.

• Let g : R – {0} to R – {1} by g(x) = 1 – 1/x.

• Then

f = f –1,

g g = g–1,

g f = (g f)–1.

• Theorem: Let f : A B and g : B A. If g f = iA, then f is one-to-one.

• Proof:• Suppose that g f = iA.

• Let x1, x2 A.

• Suppose that f(x1) = f(x2).

• Then g(f(x1)) = g(f(x2)).

• So, iA(x1) = iA(x2).

• This is the same as x1 = x2.

• Thus, f is one-to-one.

Page 32: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

• Theorem: Let f : A B and g : B A. If f g = iB, then f is onto.• Proof:

– Suppose that f g = iB.– Let y B.– Then g(y) A. Call it x.– Then f(x) = f(g(y)) = iB(y) = y.– Therefore, f is onto.

• Corollary: Let f : A B. Then f is a one-to-one correspondence if and only if there exists a function g : B A such that g f = iA and f g = iB.

Page 33: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

• Let f : R – {1/3} R – {2/3} by f(x) = 2x/(3x – 1).

• Define g : R – {2/3} R – {1/3} by g(x) = x/(3x – 2).

• Then g(f(x)) = x for all x R – {1/3} and f(g(x)) = x for all x R – {2/3}

• Therefore, g = f –1 and f is a one-to-one correspondence.

• Theorem: If f : A B is one-to-one and g : B C is one-to-one, then g f : A C is one-to-one.

• Proof #1:– Let x1, x2 A and suppose g(f(x1)) = g(f(x2 )).– Then f(x1) = f(x2), since g is one-to-one.– And then x1 = x2, since f is one-to-one.– Therefore, g f is one-to-one.

Page 34: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

• Proof #2:

– There exist functions h : C B and k : B A such that k f = iA and h g = iB.

– Therefore, (k h) (g f) = k (h g) f= k iB f

= k f= iA.

– Therefore, g f is one-to-one.• Theorem: If f : A B is onto and g : B C is onto, then g f : A C is onto.

• Proof #1:– Let z C.– Then there exists y B such that g(y) = z.– Then there exists x A such that f(x) = y.– So, (g f)(x) = g(f(x)) = g(y) = z.– Therefore, g f is onto.

Page 35: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

• Proof #2:

– There exist functions h : C B and k : B A such that f k = iB and g h = iC.

– Therefore, (g f) (k h) = g (f k) h= g iB h

= g h= iC.

– Therefore, g f is onto.

Corollary: If f : A B is a one-to-one correspondence and g : B C is a one-to-one correspondence, then g f : A C is a one-to-one correspondence.

Page 36: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

Section 7.6

Cardinality with Applications to Computability

Page 37: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

Cardinality of Finite Sets

• For finite sets, the cardinality of a set is the number of elements in the set.

• For a finite set A, let |A| denote the cardinality of A.

Page 38: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

Cardinality of Infinite Sets

• We wish to extend the notion of cardinality to infinite sets.

• Rather than talk about the “number” of elements in an infinite set, for infinite sets A and B, we will speak of– A having the same cardinality as B, or– A having a lesser cardinality than B, or– A having a greater cardinality than B.

Page 39: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

Definition of Same Cardinality

• Two sets A and B have the same cardinality if there exists a one-to-one correspondence from A to B.

• Write |A| = |B|.

• Note that this definition works for finite sets, too.

Page 40: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

Definition of Lesser Cardinality

• Set A has a cardinality less than or equal to the cardinality of a set B if there exists a one-to-one function from A to B.

• Write |A| |B|.

• Then |A| < |B| means that there is a one-to-one function from A to B, but there is not a one-to-one correspondence from A to B.

Page 41: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

Example: Equal Cardinalities

• Theorem: |2Z| = |Z|, where 2Z represents the even integers.

• Proof:– Define f : Z 2Z by f(n) = 2n.– Clearly, f is a one-to-one correspondence.– Therefore, |2Z| = |Z|.

Page 42: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

Cardinality of Z+

• Theorem: |Z+| = |Z|, where Z+ represents the positive integers.

• Proof:– Define f : Z to Z+ by f(n) = 2n if n > 0 and

f(n) = 1 – 2n if n 0.– Verify that f is a one-to-one correspondence.– Therefore, |Z+| = |Z|.

Page 43: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

Order Relations Among Infinite Sets

• Corollary: If |A| |B| and |B| |C|, then |A| |C|.• Corollary: If |A| = |B| and |B| = |C|, then |A| = |C|.• We may define |A| |B| to mean that there exists

an onto function from A to B.• Corollary: |A| |B| if and only if |B| |A|.• Corollary: If |A| |B| and |B| |C|, then |A| |C|.• Theorem: If |A| |B| and |B| |A|, then |A| = |B|.

Page 44: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

Cardinality of the Interval (0, 1)

• Theorem: The interval (0, 1) has the same cardinality as R.

• Proof:– The function f(x) = (x – ½) establishes that

|(0, 1)| = |(–/2, /2)|.– The function g(x) = tan x establishes that

|(–/2, /2)| = |R|.– Therefore, |(0, 1)| = |R|.

Page 45: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

Countable Sets

• A set is countable if it either is finite or has the same cardinality as Z+.

• Examples: 2Z and Z are countable.

• To show that an infinite set is countable, it suffices to give an algorithm for listing the elements in such a way that each element appears exactly once in the list.

Page 46: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

Example: Countable Sets

• Theorem: Q is countable.

• Proof:– Arrange the rationals in an infinite two-

dimensional array.

1/1 1/2 1/3 1/4 …

2/1 2/2 2/3 2/4 …

3/1 3/2 3/3 3/4 …

4/1 4/2 4/3 4/4 …

: : : :

Page 47: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

Proof of Countability of Q

• Then list the numbers by diagonals

1/1 1/2 1/3 1/4 …

2/1 2/2 2/3 2/4 …

3/1 3/2 3/3 3/4 …

4/1 4/2 4/3 4/4 …

: : : :

Page 48: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

Proof of Countability of Q

• We get the list

1/1, 2/1, 1/2, 3/1, 2/2, 1/3, 4/1, 2/3, 3/2,

1/4, 5/1, 4/2, 3/3, 2/4, 1/5, …• Then remove the repeated fractions, i.e., the

unreduced ones

1/1, 2/1, 1/2, 3/1, 1/3, 4/1, 2/3, 3/2, 1/4,

5/1, 1/5, …• In what position will we find 3/5?

Page 49: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

False Proof of the Countability of Q

• Incorrect listing– List all fractions with denominator 1 first.– Follow that list with all fractions with

denominator 2.– And so on.

• In what position will we find 3/5?

Page 50: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

Uncountable Sets

• A set is uncountable if it is not countable.• Theorem: R is uncountable.• Proof:

– It suffices to show that the interval (0, 1) is uncountable.

– Suppose (0, 1) is countable.– Then we may list its members 1st, 2nd, 3rd, and

so on.

Page 51: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

Proof, continued

– Label them x1, x2, x3, and so on.

– Represent each xi by its decimal expansion.

x1 = 0.d11d12d13…

x2 = 0.d21d22d23…

x3 = 0.d31d32d33…

and so on, where dij is the j-th decimal digit of xi.

Page 52: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

Proof, concluded

– Form a new number x = 0.d1d2d3… as follows.

• Define di = 1 if dii 0.

• Define di = 2 if dii = 0.

– Then x (0, 1), but x is not in the list x1, x2, x3, …

– This is a contradiction.– Therefore, R is not countable.

Page 53: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

Number of Computer Programs

• Any subset of a countable set is countable

• Theorem: The number of computer programs is countable.

• Proof:– Once compiled, a computer program is a finite

string of 0s and 1s.– The set of all computer programs is a subset of

the set of all finite binary strings.

Page 54: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

Proof, concluded

– This set may be listed

, 0, 1, 00, 01, 10, 11, 000, 001, 010, …, 111,

0000, 0001, 0010, 0011, …, 1111, …– Therefore, it is countable.– As a subset of this set, the set of computer

programs is countable.

Page 55: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

Functions from Z+ to Z+

• Theorem: The number of functions

f : Z+ Z+ is uncountable.

• Proof:– Suppose there are only countably many.

– List them f1, f2, f3, …

Page 56: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

Proof, concluded

– Define a function f : Z+ Z+ as follows.• f(i) = 1 if fi(i) 0.

• f(i) = 2 if fi(i) = 0.

– Then f(i) fi(i) for all i in Z+.

– Therefore, f is not in the list.– This is a contradiction.– Therefore, the set is uncountable.

•.•.

1f

2f

3f

nf

.

.

.

Page 57: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

Computability of Functions

• Corollary: There exists a function f : Z+ Z+ which cannot be computed by any computer program.

• Page 422

Page 58: Pigeonhole. Pigeonhole principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons. …but then why

Hierarchy of Cardinalities

• Beginning with Z+, consider the sets

Z+, (Z+), ((Z+)), …

• Each set has a cardinality strictly greater than its predecessor.

|Z+| < |(Z+)| < |((Z+))| < …

• These cardinalities are denoted 0,1,2, …(aleph-naught, aleph-one, aleph-two, …)