We worked on a proof for countability of rational numbers in the analyis class. Even though an explanation is provided, I hit a dead end trying to understand it, and can't seem to find an appropriate explanation for it. To clarify, I want to understand this proof exactly, I've seen other ways to prove it.
We started by defining a set $\mathbb Q^+:= \{ r\in \mathbb{Q}: r > 0\}$ and $q=\frac nm$ where $n,m$ are coprime numbers. That means that there exists a bijective map $\varphi:\mathbb N \to \mathbb Q^+$ that satisfies $\varphi(1)=1$, $\varphi(2)=2$, $\varphi(3)=\frac 12$, $\varphi(4)=\frac 13$ and so on...
We are expanding this to a bijective map $\phi: \mathbb Z \to \mathbb Q$, and $\phi(n):=\varphi(n)$ if $n \in \mathbb N$, $0$ if $n=0$ and $-\varphi(-n)$ if $n \in \mathbb Z$ and $n<0$. For this there was a geometric sketch included that is I believe familiar to everybody, like coordinate system, but it follows the values of the function below, cantor's snake basically.
After that there was a "non-geometric" writing of the proof, so an algebraic approach that explains the function represented in the graph that goes as follows:
$A: 2k+1 \to 2k+2$ (Horizontal values in the graph)
$B: 2k+2 \to \frac{(2k+1)}{2} \to \frac{2k}{3} \to ....\to \frac{1}{2k+2}$ (Upward going diagonals)
$C: \frac{1}{2k+2} \to \frac{1}{2k+3}$ (Follows vertical values on the graph)
$D: \frac{1}{2k+3} \to \frac{2}{2k+2} \to \frac{3}{2k+1} \to \frac{2k+3}{1}$ (Downwards going diagonals)
Now the question presents itself, how is every rational number hit through this?We can say that if $n=1$ or $m=1$ the number lies in $A$ or $B$. If for example $n$ is even and $m$ is odd, or the other way around, then $n+m$ is odd and we can define $n+m=2l+1$, $l \in \mathbb N$.Then $\frac nm$ lies in B with $k=l-1$ (This is where I got lost, this makes no sense to me and what is $k$ actually, besides being defined through $l$?). Through this $k$ defined in such way with that $l$ there are all the fractions of the form $\frac{(2k+2-i)}{(1+i)}$ where $0\le i \le 2k=1$ or with $k=l-1$$\frac{(2l-i)}{(i+1)}=:M$ where $0 \le i \le 2l-1$ (In this part I don't understand why does i go between zero and $2l-1$).
If n and m are both even or both odd then it follows that $n+m$ is even or odd and it works in analogically for $B$ and $D$.
In the end we define a function $f_\mathbb Z: \mathbb N \to \mathbb Z$ where $2k \mapsto k$ and $2k+1 \mapsto -k$. I don't know if I made a mistake or wrote something wrong, but I really can't understand this attempt of explanation with these "$k$-steps" ($A,B,C,D$). I tried putting in k in order of natural numbers into those formulae but I don't understand what order should it exactly follow? I would be very thankful if someone could help me out, and I apologize for the bad notation, I'm not quite skilled with mathjax.