Video 1, chapter 19

Hilbert's Hotel

How Hilbert's Hotel, full yet able to take new guests, works through one-to-one correspondences, why a countably infinite set matches a proper subset of itself, and how a pairing function seats infinitely many buses.

  • Video 1, chapter 19
  • When infinity changes the rules

Video 1, chapter 19

Nothing loads from YouTube until you press play.

A hotel has one room for every positive integer, and every room has a guest in it. One more guest arrives and asks for a room. In a hotel with finitely many rooms the answer would be no, so can an infinite hotel do better without putting two people in one room or turning anyone away? This page writes down room assignments that make space for one guest, for a bus with infinitely many passengers and even for infinitely many such buses, checks that each assignment gives every person a room of their own, and explains why only an infinite hotel allows this.

Key terms

Hilbert’s Hotel

Definition Hilbert’s Hotel is an imaginary hotel with one room for each positive integer 1,2,3,…1, 2, 3, \dots and no last room, in which every room holds exactly one guest. When new people arrive, the manager announces a rule that names one room for every person, old guests and newcomers alike, and everyone moves to their room at the same moment. A rule works when every person gets exactly one room and no two people get the same room. Rooms may be left empty. The paradox is that the hotel is full, since no room is empty, and yet working rules exist for one new guest, for a bus with one passenger for each positive integer, and even for one such bus for each positive integer. The resolution is that “full” only says that every room is taken. In a hotel with finitely many rooms, a rule that gives the guests different rooms uses as many rooms as there are guests, so it uses every room and leaves none for a newcomer. With infinitely many rooms the old guests can be given different rooms that leave some rooms free, because after every room nn there is a room n+1n + 1. The hotel is a model of assignments between sets of numbers. It says nothing about a real building or about how long the moves would take. It is named after David Hilbert, who described it in a lecture in 1924.

In plain words A full infinite hotel can still take more guests, because the manager can move everyone along the hallway and the hallway never ends. Nobody is pushed out at the far end, since there is no far end.

Example One new guest arrives. The manager asks the guest in room nn to move to room n+1n + 1 and gives room 11 to the newcomer, so the guest in room 11 goes to room 22 and the guest in room 100100 goes to room 101101. This rule works. Old guests from different rooms n≠mn \ne m go to the different rooms n+1≠m+1n + 1 \ne m + 1. Each room r≥2r \ge 2 receives exactly one old guest, the one from room r−1r - 1, and room 11 receives only the newcomer.

Next a bus arrives with seats numbered 1,2,3,…1, 2, 3, \dots and a passenger in every seat. Moving everyone one room along frees only room 11, so the manager uses two rules at once. The old guest in room nn moves to room 2n2n, and the passenger in seat kk takes room 2k−12k - 1,

room n↦room 2n,seat k↦room 2k−1.\begin{aligned} \text{room } n &\mapsto \text{room } 2n, \\[0.4em] \text{seat } k &\mapsto \text{room } 2k - 1. \end{aligned}

The old guests fill the even rooms 2,4,6,…2, 4, 6, \dots and the passengers in seats 1,2,31, 2, 3 take rooms 1,3,51, 3, 5, and in general the passengers fill the odd rooms. Every positive integer is either even or odd and not both, so every room gets exactly one person and nobody is left without a room.

One-to-one correspondence

Definition A one-to-one correspondence, also called a bijection, between two sets AA and BB is a rule ff that gives each element aa of AA one partner f(a)f(a) in BB so that two conditions hold. First, no two elements share a partner, which means that f(a)=f(a′)f(a) = f(a') only when a=a′a = a'. Second, every element of BB is the partner of some element of AA. A rule with the first property is called injective, and in some books one-to-one, while a rule with the second property is called onto, or surjective. So a one-to-one correspondence is a rule that is both injective and onto. Two sets have the same size, or the same cardinality, when there is a one-to-one correspondence between them. For finite sets this means exactly that they have the same number of elements.

In plain words A one-to-one correspondence pairs off two sets so that everything on either side has exactly one partner. It compares sizes without counting, the way a theater in which every seat holds one person and nobody is standing shows that there are as many people as seats.

Example The rule f(n)=2n−1f(n) = 2n - 1 is a one-to-one correspondence between the positive integers and the odd positive integers 1,3,5,…1, 3, 5, \dots. It is injective, because 2n−1=2m−12n - 1 = 2m - 1 forces n=mn = m, and it is onto, because each odd number rr is the partner of the positive integer (r+1)/2(r + 1)/2. Two other rules on the positive integers show what can go wrong. The rule n↦n+1n \mapsto n + 1 is injective but not onto, since 11 is nobody’s partner. The rule that sends nn to the largest integer at most (n+1)/2(n + 1)/2, written ⌊(n+1)/2⌋\lfloor (n + 1)/2 \rfloor, gives 1,1,2,2,3,3,…1, 1, 2, 2, 3, 3, \dots, so it reaches every positive integer but is not injective, since 11 and 22 share the partner 11. As room assignments, the first rule leaves room 11 empty and the second puts two guests in every room.

Countably infinite set

Definition A set is countably infinite when there is a one-to-one correspondence between it and the set of positive integers {1,2,3,… }\{1, 2, 3, \dots\}. Equivalently, its elements can be written as an endless list a1,a2,a3,…a_1, a_2, a_3, \dots in which every element appears exactly once, each at some finite position. Some books start counting at 00, and that changes nothing, because n↦n+1n \mapsto n + 1 is a one-to-one correspondence between {0,1,2,… }\{0, 1, 2, \dots\} and the positive integers. A countably infinite set that gains one new element, or finitely many, or a whole countably infinite set of new elements, is still countably infinite, which is what the hotel shows. This does not make infinity a number that can be subtracted from itself. Removing a countably infinite set from the positive integers can leave infinitely many numbers, just one number or none, depending on which numbers are removed.

In plain words A set is countably infinite when its elements can be numbered first, second, third and so on forever, so that each element gets its own number. The rooms of the hotel, its guests and the passengers of each bus are such sets.

Example The integers …,−2,−1,0,1,2,…\dots, -2, -1, 0, 1, 2, \dots form a countably infinite set, listed as

0,  1,  −1,  2,  −2,  …0, \; 1, \; -1, \; 2, \; -2, \; \dots

In this list 00 is first, each positive integer nn is at position 2n2n and its negative −n-n is at position 2n+12n + 1, so every integer has exactly one place. Subtraction is a different matter. Taking the even numbers away from the positive integers leaves the odd numbers, infinitely many of them. Taking away 2,3,4,…2, 3, 4, \dots leaves only 11, and taking away every positive integer leaves nothing. Each time a countably infinite set was removed from the same countably infinite set, so an expression such as ∞−∞\infty - \infty has no single value.

Proper subset

Definition A set AA is a subset of a set BB when every element of AA is also an element of BB, and a proper subset when in addition BB has at least one element that is not in AA. A finite set is never in one-to-one correspondence with a proper subset of itself, because a proper subset of a set with NN elements has fewer than NN elements. A countably infinite set always is. If a1,a2,a3,…a_1, a_2, a_3, \dots lists it, the rule an↦an+1a_n \mapsto a_{n+1} is a one-to-one correspondence between the whole set and the proper subset that leaves out a1a_1.

In plain words Taking elements away from a finite collection always leaves fewer of them. An infinite collection can lose some of its elements, even infinitely many, and still match the whole collection one to one. Hilbert’s Hotel is this fact told as a story.

Example The even positive integers 2,4,6,…2, 4, 6, \dots form a proper subset of the positive integers, since 1,3,5,…1, 3, 5, \dots are missing, yet n↦2nn \mapsto 2n is a one-to-one correspondence between the two sets. It is injective because 2n=2m2n = 2m forces n=mn = m, and onto because each even number 2m2m is the partner of mm. This is why all the old guests fit into the even rooms. Compare a hotel with 55 rooms, all taken. The rule n↦n+1n \mapsto n + 1 would send the guest in room 55 to room 66, which does not exist. Any rule that gives the 55 guests different rooms among the 55 rooms uses all of them, so a newcomer cannot be placed.

Pairing function

Definition A pairing function is a one-to-one correspondence between the set of ordered pairs (b,s)(b, s) of positive integers, in which (1,2)(1, 2) and (2,1)(2, 1) count as different pairs, and the set of positive integers. The diagonal pairing used here orders the pairs by their sum b+sb + s, smallest sum first, and pairs with the same sum by increasing bb. The pairs with sum dd are (1,d−1),(2,d−2),…,(d−1,1)(1, d - 1), (2, d - 2), \dots, (d - 1, 1), which makes d−1d - 1 of them, and the smaller sums 2,3,…,d−12, 3, \dots, d - 1 account for 1+2+⋯+(d−2)=(d−2)(d−1)/21 + 2 + \dots + (d - 2) = (d - 2)(d - 1)/2 pairs. So the pair (b,s)(b, s) with sum d=b+sd = b + s gets the position

k=(d−2)(d−1)2+b.k = \frac{(d - 2)(d - 1)}{2} + b.

The pairs with sums 2,3,4,…2, 3, 4, \dots fill the positions in consecutive blocks of lengths 1,2,3,…1, 2, 3, \dots, so every positive integer is the position of exactly one pair. This is a version of the Cantor pairing function, shifted to start at 11. Listing the pairs one row at a time does not work, because the pairs (1,1),(1,2),(1,3),…(1, 1), (1, 2), (1, 3), \dots alone would take up every position, and (2,1)(2, 1) would never get one.

In plain words To put a grid with infinitely many rows and columns into one queue, read it along short diagonals. Each diagonal is finite, so the queue finishes it and moves on, and every entry of the grid is reached after only finitely many others.

Example Let bb be a bus number and ss a seat number, with one bus for each positive integer and one passenger in every seat. The queue begins

(1,1),  (1,2),  (2,1),  …(1, 1), \; (1, 2), \; (2, 1), \; \dots

and continues with (1,3)(1, 3), (2,2)(2, 2) and (3,1)(3, 1). The passenger in seat 44 of bus 33 has d=3+4=7d = 3 + 4 = 7, so

k=5⋅62+3=18.k = \frac{5 \cdot 6}{2} + 3 = 18.

The 1515 pairs with sums 22 to 66 come first, followed by (1,6)(1, 6), (2,5)(2, 5) and (3,4)(3, 4). To house all the buses, the manager sends the old guest in room nn to room 2n2n and the passenger at queue position kk to room 2k−12k - 1, so this passenger gets room 3535. Going backward, room 3535 is odd, so it belongs to queue position 1818. The positions up to 1515 belong to sums up to 66 and positions 1616 to 2121 to the sum 77, so position 1818 is the third pair with sum 77, which is (3,4)(3, 4).

Check yourself

  1. Three new guests arrive at the full hotel. Give a rule that makes room for them and check that it works.
Show the answer

Move the guest in room nn to room n+3n + 3 and give rooms 11, 22 and 33 to the newcomers. Old guests from different rooms stay in different rooms after adding 33. Each room r≥4r \ge 4 receives exactly one old guest, the one from room r−3r - 3, and rooms 11 to 33 hold one newcomer each, so every person has a room of their own. The same idea works for any finite number mm of newcomers with the rule n↦n+mn \mapsto n + m. In a finite hotel it fails, because the guests in the last mm rooms would have nowhere to go.

  1. A manager tries to seat one bus by sending the old guest in room nn to room 2n2n and the passenger in seat kk to room 3k3k. Does this rule work? What about sending passenger kk to room 2k+12k + 1 instead?
Show the answer

The first rule fails. Room 66 is assigned to the old guest from room 33, since 2⋅3=62 \cdot 3 = 6, and also to the passenger in seat 22, since 3⋅2=63 \cdot 2 = 6. In general room 6j6j receives both the old guest from room 3j3j and the passenger in seat 2j2j, so every multiple of 66 is assigned twice. The rule also leaves rooms such as 11, 55 and 77 empty, but empty rooms are allowed. The two people sharing a room are what break it.

The second rule works. Old guests go to even rooms and passengers to the odd rooms 3,5,7,…3, 5, 7, \dots, so no old guest meets a passenger, and different seats k≠jk \ne j give different rooms 2k+1≠2j+12k + 1 \ne 2j + 1. Everyone has a room of their own, and room 11 stays empty, which is allowed.

  1. Infinitely many buses arrive and the manager uses the diagonal queue from the pairing function. Which room does the passenger in seat 22 of bus 44 get, and who is in rooms 2020 and 2121 afterward?
Show the answer

The pair is (b,s)=(4,2)(b, s) = (4, 2) with sum 66, so its queue position is

k=4⋅52+4=14,k = \frac{4 \cdot 5}{2} + 4 = 14,

and the passenger gets room 2⋅14−1=272 \cdot 14 - 1 = 27.

Room 2020 is even, so it holds the old guest from room 1010. Room 2121 is odd, so it holds the passenger at queue position (21+1)/2=11(21 + 1)/2 = 11. The sums 22 to 55 account for 1+2+3+4=101 + 2 + 3 + 4 = 10 positions, so position 1111 is the first pair with sum 66, which is (1,5)(1, 5). Room 2121 holds the passenger in seat 55 of bus 11. The formula agrees, since (4⋅5)/2+1=11(4 \cdot 5)/2 + 1 = 11.

How this lesson connects