# Give a bijection

Give a bijection between the following sets:

(1) $\mathbb{Z}$ and $\mathbb{Z}\backslash \{0\}$

(2) $\mathbb{Q}$ and $\mathbb{Q}\backslash \{0\}$

I think that I can the problems with "Hilbert's paradox of the Grand Hotel". I think that the first (1) problem is pretty the same like the following:Suppose a new guest arrives and wishes to be accommodated in the hotel.

We can (simultaneously) move the guest currently in room 1 to room 2, the guest currently in room 2 to room 3, and so on, moving every guest from his current room n to room n+1.

After this, room 1 is empty and the new guest can be moved into that room. By repeating this procedure, it is possible to make room for any finite number of new guests.

It's clear that if a new guest arrives and we proceed just like the the method above we get a bijection, but how can I write it precisely?

I think that my method should work also for the second case(2), but I don't see which elements should I move.

• In the second case, treat the integers as you do in the first, and just map every non-integer to itself. – Henning Makholm Apr 12 '16 at 18:01
• For Q: I assume that you have already shown a bijection between Z and Q. Use that. This can be written quite neatly using the Calkin-Wilf sequence. The negative rationals are unchanged, 0 -> 1, and otherwise $q\to\frac{1}{2\lfloor q\rfloor - q + 1}$. – deinst Apr 12 '16 at 18:04

(1). Define $f:\mathbb{Z}\to \mathbb{Z}\setminus\{0\}$ as follows: $$f(n)= \begin{cases} n&&\text{ if }& n < 0\\ n+1&&\text{ if }& n\geq 0 \end{cases}$$
(2). Define $f:\mathbb{Q}\to \mathbb{Q}\setminus\{0\}$ as follows: $$f(q)= \begin{cases} q&&\text{if }& q\in\mathbb{Z}\text{ and }q < 0\\ q+1&&\text{if }& q\in\mathbb{Z}\text{ and }q\geq 0\\ q&&\text{if }&q\notin\mathbb{Z} \end{cases}.$$