-2

A set $S$ is countably infinite if there exists a bijective function $f$ from $S$ to the natural numbers $ℕ$ (https://en.wikipedia.org/wiki/Countable_set#Definition). I know that the cartesian product $A×B$ of two countably infinite sets $A,B$ is countably infinite.

Let $A=B=ℤ$ be the set of all integers. I am asking about an explicit formula of the function $f:ℤ×ℤ→ℕ$

Henno Brandsma
  • 242,131
Safwane
  • 3,840
  • @XanderHenderson: In fact the link does not answer my question. – Safwane Mar 29 '20 at 15:12
  • Safwane, try modifying the function given in Xander’s comment. The solution there can be changed accordingly to produce a function you seek. – Clayton Mar 29 '20 at 15:18

1 Answers1

2

Start with the Cantor pairing function

$$\pi:\Bbb N\times\Bbb N\to\Bbb N:\langle m,n\rangle\mapsto\frac12(m+n)(m+n+1)+n\;.$$

(Note that $\Bbb N=\Bbb Z^+\cup\{0\}$.) Suppose that we can find a bijection $h:\Bbb Z\to\Bbb N$. Then we can define

$$\varphi:\Bbb Z\times\Bbb Z\to\Bbb N\times\Bbb N:\langle m,n\rangle\mapsto\langle h(m),h(n)\rangle\;,$$

and $\pi\circ\varphi:\Bbb Z\times\Bbb Z\to\Bbb N$ will be the desired function.

One natural way to enumerate $\Bbb Z$ is in the order $0,-1,1,-2,2,-3,3,\ldots\;$:

$$\begin{array}{c|cc} h(n)&0&1&2&3&4&5&6&\ldots\\ n&0&-1&1&-2&2&-3&3&\ldots \end{array}$$

By inspection the corresponding $h$ is

$$h:\Bbb Z\to\Bbb N:n\mapsto\begin{cases} 2n,\text{ if }n\ge 0\\ |2n|-1,\text{ if }n<0\;. \end{cases}$$

Brian M. Scott
  • 616,228