Please help me find the mistake I made in a set theory exercise.
I have a function $f:\Bbb N\times\Bbb N\to\Bbb N$ defined by
$$f((a,b))=\frac{(a+b)(a+b+1)}2+a\;.$$
I'm trying to prove that $f$ is bijective. This is my proof:
Let's look at the set $f$, $$f=\left\{((a,b),c) \mid (a,b)\in\Bbb N\times\Bbb N, c=\frac{(a+b)(a+b+1)}2+a\in\Bbb N\right\}\;.$$ Let's define a new function $g:\Bbb N\to\Bbb N\times\Bbb N$ by $g(c)=(a,b)$. (The set looks like this $g=\{(c,(a,b))\}$ ).
Let's check $(f\circ g)(\Bbb N)=\operatorname{Id}(\Bbb N)$?
I say that to all $n\in\Bbb N$ exists $k,m\in\Bbb N$ such that $\frac{(k+m)(k+m+1)}2 + k=n$ (induction with respect to $n$): For $n=0$, there exists $k=m=0$. Lets assume true for $n$, and prove for $n+1$: Looking for $k',m'\in\Bbb N$ - for $k'=k+1, m'=m-1$ the expression equals $n+1$. $(f\circ g)(\Bbb N)=\operatorname{Id}(\Bbb N)$.Let's check $(g\circ f)(\Bbb N\times\Bbb N)=\operatorname{Id}(\Bbb N\times\Bbb N)$?
I say that to all $k,m\in\Bbb N$ exists $n\in\Bbb N$ such that $g(n)=\frac{(k+m)(k+m+1)}2 + k$ (induction with respect to $k,m$): For $k,m=0$, exists $n=0$. Lets assume true for $k,m$, and prove for $k+1,n+1$: Looking for $n'$ so that $g(n')=\frac{(k+1+m+1)(k+1+m+1+1)}2 +k+1$
For $n'=(n+k+m+4)$ which is clearly a natural number the expression is true. $(g\circ f)(\Bbb N\times\Bbb N)=\operatorname{Id}(\Bbb N\times\Bbb N)$.
Therefore $f$ is a bijective function. And $f^{-1}=g$.
Please help find why I'm a fool and where is the mistake.