Show that $\varphi(\langle n, k\rangle) = \frac{1}{2}(n+k+1)(n+k)+n $ is injective How to show that the following function is an injective function?

$ \varphi : \mathbb{N}\times \mathbb{N} \rightarrow \mathbb{N} \\
\varphi(\langle n, k\rangle) = \frac{1}{2}(n+k+1)(n+k)+n$

I'm starting with $ \frac{1}{2}(a+b+1)(a+b)+a = \frac{1}{2}(c+d+1)(c+d)+c$, but how am I supposed to show from this equality that $\langle a, b\rangle = \langle c, d\rangle$, where $\langle a, b\rangle \in \mathbb{N}\times \mathbb{N}$ ?
Here are two arguments.  The first should make the statement "visually obvious" while the second is more formal.

Construct a grid displaying the value of $\phi(n,k)$ for each value of $n$ and $k$:
$$\begin{matrix}
  \color{red}{\phantom{k={}}4}&amp;14\cr
  \color{red}{\phantom{k={}}3}&amp;9&amp;13\cr
  \color{red}{\phantom{k={}}2}&amp;5&amp;8&amp;12\cr
  \color{red}{\phantom{k={}}1}&amp;2&amp;4&amp;7&amp;11\cr
  \color{red}{n=0}&amp;0&amp;1&amp;3&amp;6&amp;10\phantom{=n}\cr
  &amp;\color{blue}{0}&amp;\color{blue}{1}&amp;\color{blue}{2}&amp;\color{blue}{3}&amp;\color{blue}{\!\!\!\!\!\!\!\!4\rlap{{}=k}}
\end{matrix}$$
This should make it pretty clear what is going on.  A formal proof could be as follows.

First, suppose that $n_1+k_1&gt;n_2+k_2$.  Since we are talking about integers, this means that $n_1+k_1\ge n_2+k_2+1$ and we have
$$\eqalign{\phi(n_1,k_1)
  &amp;=\tfrac12(n_1+k_1+1)(n_1+k_1)+n_1\cr
  &amp;\ge\tfrac12(n_2+k_2+2)(n_2+k_2+1)+n_1\cr
  &amp;=\tfrac12(n_2+k_2+1)(n_2+k_2)+n_2+k_2+1+n_1\cr
  &amp;&gt;\phi(n_2,k_2)\ .\cr}$$
Now suppose that $\phi(n_1,k_1)=\phi(n_2,k_2)$.  By the above argument we cannot have $n_1+k_1&gt;n_2+k_2$, by a symmetrical argument we cannot have $n_2+k_2&gt;n_1+k_1$, therefore $n_1+k_1=n_2+k_2$.  Hence
$$\eqalign{\phi(n_1,k_1)=\phi(n_2,k_2)\ 
  &amp;\Rightarrow\ \tfrac12(n_1+k_1+1)(n_1+k_1)+n_1=\tfrac12(n_2+k_2+1)(n_2+k_2)+n_2\cr
  &amp;\Rightarrow\ \tfrac12(n_1+k_1+1)(n_1+k_1)+n_1=\tfrac12(n_1+k_1+1)(n_1+k_1)+n_2\cr
  &amp;\Rightarrow\ n_1=n_2\ ,\cr}$$
and so $k_1=k_2$.  Thus $\phi$ is injective.
It might be easier to start by letting $(n, k)$ be such that $\varphi( \langle n, k\rangle ) = 0$. Then, $(n + k + 1)(n+k) + 2n = 0$, and since $n, k \in \mathbb{N}$, $(n + k + 1)(n + k), 2n \ge 0$, so $2n = n = 0$, so $k = 0$, and since $(n, k) = (0, 0)$, $\varphi$ is injective.