Complicated comparing sets Consider the open interval $(0, 1)$ and the closed interval $[0, 1]$. We claim that $[0, 1] ≈ (0, 1)$.
We deduced the equipotence $[0, 1] ≈ (0, 1)$ by invoking the Schr¨oder–Bernstein theorem, but we didn’t actually construct a bijection $[0, 1] → (0, 1).$

(a) Verify that the function $h$ given by the following scheme is such a bijection: $$0\overset{h}{\longmapsto}\frac12\qquad\qquad\qquad\qquad\qquad\qquad\quad\,{}\\\frac1n\longmapsto\frac1{n+2}\qquad\text{for each integer }n\ge 1\\x\longmapsto x\qquad\qquad\qquad\qquad\quad\;\text{otherwise}$$


(b) The function $h$ in part (a) acts on $[0, 1]$ in a way that resembles the strategy of the hotel manager in the text below. How?

Now imagine that there is a hotel with infinitely many rooms along an unending corridor: a first room, a second room, and so on. Imagine further that there is a person occupying each room; so we can reasonably say that there are exactly as many guests as there are rooms. You arrive at the hotel seeking a room, and the manager tells you, “At the moment the rooms are all occupied, but we always have room for one more.” Whereupon she speaks into an intercom connected to all the rooms, saying, “At the sound of the bell, each guest should step out into the corridor and move into the next room in line.” This clears out the first room, and you have a place to stay. Notice that although you thought you had enlarged the collection of guests by your presence, there are still as many hotel rooms as there are guests.


My work is below:

We are given function $h$ $$h(x)=\begin{cases}\cfrac1{n+2} & \text{for }x=\cfrac1n,n\ge 1\\\cfrac12 & \text{for }x=0\\x & \text{otherwise}\end{cases}$$
We know that a function from $A$ (the domain) to $B$ (the range) is both one-to-one and onto when no element of $B$ is the image of more than one element of $A,$ and all elements in $B$ are used.
Functions that are both one-to-one and onto are referred to as bijective. Here we can say that $h(x)$ is an identity function as $x,$ in the form of $\frac1n$ and $x\ne0.$
We know that an identity function is bijective.
For $x\ne\frac1n$ and $x\ne 0,$ $h(x)$ is bijective.
Let us consider $x_1=\frac{1}{n_1},x_2=\frac{1}{n_2}$ and assume that $h(x_1)=h(x_2),$ so $h\left(\frac{1}{n_1}\right)=h\left(\frac{1}{n_2}\right).$ Then, $$\frac{1}{n_1+2}=\frac{1}{n_2+2}\iff n_1+2=n_2+2$$
Therefore, $n_1=n_2,$ thus $x_1=x_2$ which proves that $h(x)$ is one-to-one.
For $n\ge 1,$ $\frac{1}{n+2}\ne\frac{1}{2}$
Thus, only $x=0$ maps to $\frac12.$
Let us check identity function for the numbers $y=\frac1n,n>2.$
If we have $y=\frac1n,$ then there exists an element $x$ such that $\frac1n=h\left(\frac{1}{n-2}\right),$ $x=\frac1{n-2}$
Therefore, $h(x)$ is onto, so we conclude that $h(x)$ is bijective.

This question is driving me nuts. Please give me some advice on how to answer it concisely. Thank you so much!
 A: Here is how the  construction of that bijection mirrors the freeing of the first two rooms in Hilbert's Hotel.
The function $h$ matches the rational numbers
$$
0, 1/1, 1/2, 1/3, 1/4, 1/5, \ldots
$$
in order to the rational numbers
$$
1/2, 1/3, 1/4, 1/5, 1/6, 1/7, \ldots
$$
That says the inverse function $h^{-1}$ creates "rooms" for the extra guests $0$ and $1$ by shifting the guests $1/n$ over two rooms.
All the other real numbers in the interval stay fixed.
A: You haven't quite shown that $h$ is one-to-one or onto, but you're very close! You have shown that two restrictions of $h$ are one-to-one, that no two elements map to $\frac12,$ and that infinitely-many elements of $(0,1)$ are in the range of $h,$ but that's not enough. You've hinted around the rest, but it should be made explicit.
I would proceed in a slightly different way, which I will outline here:

*

*Let $A:=\{0\}\cup\left\{\frac1n:n\in\Bbb Z,n>0\right\},$ $B:=\left\{\frac1n:n\in\Bbb Z,n>1\right\}.$

*Show that $[0,1]\setminus A=(0,1)\setminus B,$ and remark that $h\restriction_{[0,1]\setminus A}$ is an identity function, so bijective.

*Show that $h\restriction_A:A\to B$ is a bijection.

*Use the fact that $A$ and $B$ are both disjoint from $[0,1]\setminus A=(0,1)\setminus B$ to conclude that $h$ is a bijection.


As for the parallel to the infinite hotel (if you want to look into it further, see "Hilbert's hotel"), I would say that it is similar, but not quite the same. I'd argue that it would be more accurate to imagine that the hotel had two wings, one with a countable infinity of rooms, the other with as many rooms as there are real numbers. Then along come two new guests who want rooms (corresponding to $0$ and $1$). The manager announces on the PA in the countable wing: "At the sound of the bell, all guests in the countable wing please step out of your rooms and move two rooms down." Do you see the parallel when put in those terms?
