An exercise problem :
Consider the function $h: N \times N \rightarrow N$ so that $h(a,b) = (2a +1)2^b - 1$, where $N=\{0,1,2,3,\dots\}$ is the set of natural numbers.
(a) Prove that the function $h$ is an injection (one-one).
(b) Prove that it is also a Surjection (onto).
My attempt :
a. Let $h(a,b) = h(c,d) \\ \implies (2a +1)2^b - 1= (2c +1)2^d - 1\\ \implies (2a +1)2^b = (2c +1)2^d $
Now, $2a$ is even and hence $2a+1$ is odd and similarly $2c+1$. So, the only way the products can be same is when $a = c$ and $b=d$, which shows function is one-one.
b. Lets use induction to prove that every natural element is mapped to by $f$.
Base case:
$h(0,0) = 0$ is true.
Now, assume we have $a, b > 0$ for $h(a,b) = n$.
Now, we want to prove we have $c, d$ for $h(c,d) = n+1$
$h(c,d) = (2c+1) 2^d - 1 \\= n + 1 \\=(2a+1) 2^b - 1 + 1 (\because h(a,b) = n) \\ \implies (2c +1) 2^d = (2a+1) 2^b + 1$
The above equality is satisfied if we put $d = 0$ or $b = 0$ (otherwise LHS is even and RHS is odd) which gives $2c+1 = (2a+1) 2^b + 1 \\ \implies c = (2a+1) 2^{b-1}$
Thus we get $c = (2a+1) 2^{b-1}$ and $d = 0$ and our proof is complete.
Can you explain in formal way, please?