Suppose we can express any positive raional number $x$ uniquely as $x = \frac{p}{q}$, where $\gcd(p,q)=1$ and $p, q \in \mathbb{N}$.
Define the mapping $\mathbb{Q} \to \mathbb{N}$ by the following:
$ g(x) = \begin{cases} 1 &\text{if}\, x=0;\\ 2((p+q)^{2} + q) &\text{if}\,x=\frac{p}{q}>0, \gcd(p,q)=1;\\ 1+g(-x) &\text{if}\,x<0. \end{cases} $
I am trying to show that this mapping is injective.
This is what I've done so far:
$g(0) = 1$ by definition, $\displaystyle g\left( \frac{q}{p}\right) \neq 1$ $\forall p, q$, clearly, and $g(x) = 1+g(-x) = 1$ only when $g(-x)=0$, which it cannot be since $g: \mathbb{Q} \to \mathbb{N}$, and $0 \notin \mathbb{N}$. So, only $x = 0 \mapsto 1$.
Now, I am trying to show that if $\displaystyle g\left(\frac{p}{q} \right) = g\left(\frac{m}{n}\right)$ for $m, n \in \mathbb{Q}$, $\gcd(m,n)=1$ as well, then we must have $\displaystyle \frac{p}{q} = \frac{m}{n}$.
So, I set $(p+q)^{2} + q = (m+n)^{2}+n$, and am now trying to derive $\frac{p}{q} = \frac{m}{n}$, but I am not having much luck.
What do I need to do to get what I want to pop out?
To show that $g$ is injective reduces to checking that the function $f(m,n)=(m+n)^2 +n$ defined on positive integers $m,n$ is injective.
Observe that $$(m+n)^2< f(m,n)<f(m,n)+n+2m+1=(m+n+1)^2.$$ Therefore $m+n=\lfloor\sqrt{f(m,n)}\rfloor$. Thus $$n=f(m,n)-\lfloor\sqrt{f(m,n)}\rfloor^2,\quad m=\lfloor\sqrt{f(m,n)}\rfloor-n$$ determines both $m$ and $n$ uniquely from $f(m,n)$.