An explicit bijection between $\mathbb{Q}^+$ and $\mathbb{Q}$

elementary-set-theoryreal-analysis

I was trying to show that $\vert \mathbb{Q}^+\vert=\vert \mathbb{Q}\vert$. An injection is so easy to find, but I’m having amhard time finding a surjection. Also, I don’t think there’s a similar question on stackexchange now…

Best Answer

For simplicity, we will define $\mathbb{Q}^+:=\{x\in \mathbb{Q}:x\ge 0\}$.

One explicit bijection between $\mathbb{R}$ and $\mathbb{R}^+$ is: $$f(q)=\begin{cases} 2\lfloor q\rfloor+\text{frac}(q)&\lfloor q\rfloor\ge0\\ -2\lfloor q\rfloor -1+\text{frac}(q)&\lfloor q\rfloor<0\\ \end{cases}$$

This function, if restricted to $\mathbb{Q}$, defines a bijection between $\mathbb{Q}$ and $\mathbb{Q}^+$ and if restricted to $\mathbb{Z}$ a bijection $\mathbb{Z}\leftrightarrow \mathbb{N}$.

More generally, given a bijection $g:\mathbb{Z}\leftrightarrow \mathbb{N}$, we can extend it to $\hat{g}:\mathbb{R}\leftrightarrow\mathbb{R}^+$ by $$\hat{g}(x)=g(\lfloor x \rfloor )+\text{frac}(x) $$ and this extension induces a bijection $\hat{g}_{|\mathbb{Q}}:\mathbb{Q}\leftrightarrow \mathbb{Q}^+$

Note: however to prove $|\mathbb{Q}|=|\mathbb{Q}^+|$, you do not need to find an explicit bijection. In fact, thanks to the Schroder-Bernstein theorem it suffices to show an injection $\mathbb{Q}^+\to \mathbb{Q}$ and viceversa.