2

I am struggling to find an explicit bijection $\mathbb{N} \times \mathbb{N} \to \mathbb{N}$ when $\mathbb{N}$, by definition, includes $0$. If $\mathbb{N}$ were to exclude $0$, I could note that any positive integer can be written uniquely in the form $2^{a-1} (2b - 1)$ and then map $(a,b) \to n$. Including $0$, I have to change $a - 1$ to $a$ and $2b - 1$ to $2b + 1$, but I still run into the issue of what to map to $0$. I can't map $(0,0)$ to $0$, for example, because $2^{0} (2(0) - 1) = 1$ is the unique element of the form $2^{a-1} (2b - 1)$ mapping to $1$.

Does anyone have any tips for how to repair this bijection?

JeremyS
  • 1,345
  • 2
    Can you find a bijection between $\mathbb{N}$ and $\mathbb{N}\cup{0}$? If you can, you can just run that bijection 'both ways' — on the input, go $\mathbb{N}\cup{0}\to\mathbb{N}$ to translate your inputs into the ones you know how to handle, and then on the output go $\mathbb{N}\to\mathbb{N}\cup{0}$ to map back. – Steven Stadnicki Apr 26 '21 at 18:51
  • If you have bijection $f:\mathbb N_+ \times \mathbb N_+ \to \mathbb N_+$ and by $g:\mathbb N_+ \to \mathbb N$ you denote bijection $g(n) = n-1$, similarly with $h:\mathbb N \times \mathbb N \to \mathbb N_+ \times \mathbb N_+$ by formula $h(n,m) = (n+1,m+1)$ then composition $g \circ f \circ h : \mathbb N \times \mathbb N \to \mathbb N$ will work – Presage Apr 26 '21 at 18:51
  • 1
    See https://math.stackexchange.com/questions/1179491/explicit-bijection-between-mathbb-n-and-mathbb-n-times-mathbb-n or https://math.stackexchange.com/questions/222709/inverting-the-cantor-pairing-function for some other bijections that work. – Gary Moon Apr 26 '21 at 18:52
  • So am I correct in thinking that if I want to include $0$, I need to in some sense 'compose bijections', i.e., this map can't be defined piece-wise? That came to mind, but I was hoping there was a simpler approach. By injectivity of the original map, it makes sense to me that this wouldn't be possible. – JeremyS Apr 26 '21 at 18:55
  • " I can't map (0,0) to 0, for example, because 20(2(0)−1)=1 is the unique element of the form 2a−1(2b−1) mapping to 1." So juist subtract $1$ from the results. – fleablood Apr 26 '21 at 19:10
  • You've got something mapping to $N$ without $0$. SO just substract $1$ from every result and you get somthing mapping to $N$ with the $0$. – fleablood Apr 26 '21 at 19:11
  • You do $\mathbb N_0\to \mathbb N_1$ via $n+1$ and $N_1 \to N_0$ via $n-1$. So.... just do it. $N_1 \to N_1 \to N_1$ via $2^a(2b-1)$ works. So $N_0\to N_0\to N_1$ via $2^{a+1}(2b+1)$ works and $N_0\to N_0 \to N_0$ via $2^{a+1}(2b+1)-1$. – fleablood Apr 26 '21 at 19:16
  • "compose bijections', i... That came to mind, but I was hoping there was a simpler approach. " As one of the bijections being composed is "adding/subtracting one" the composition is pretty dang simple. You just add one to the $a,b$ and then subtract one from the result. – fleablood Apr 26 '21 at 19:19

1 Answers1

5

Just.... combine.

You have $f:\mathbb N_{1} \times \mathbb N_1 \to \mathbb N_1$ via $f(a,b) = 2^{a-1}(2b-1)$.

And you have $g:\mathbb N_0 \to \mathbb N_1$ via $g(n) = n+ 1$.

So you have $g\times g: \mathbb N_0 \times \mathbb N_0 \to \mathbb N_1 \times \mathbb N_1$ via $g\times g(a,b) = (g(a), g(b)) = (a+ 1, b+1)$ and

You have $f\circ g\times g: \mathbb N_0 \times \mathbb N_0 \to \mathbb N_1 \times \mathbb N_1 \to \mathbb N_1$ via $f\circ g\times g (a, b) = f(a+1, b+1) = 2^a(2b + 1)$.

And you have $g^{-1}\circ f\circ g\times g: \mathbb N_0 \times \mathbb N_0 \to \mathbb N_1 \times \mathbb N_1 \to \mathbb N_1\to \mathbb N_0$ via $g^{-1}\circ f\circ g\times g(a,b) = g^{-1} (f(a+1,b+1)) = 2^a(2b+1) -1$.

======

Alternatively the other standard bijection (that works on the cross product of any two countable sets) is to simply list pairs by weaving a diagonal path:

$(1,1), (2,1), (1,2), (3,1), (2,2),(1,3),(4,1), (3,2),(2,3),(1,4), (5,1),(4,2).....(4,2),(1,5), (6,1),(5,2)....,(2,5),(1,6),(7,1).....\to$

$1,2,3,4,5,7......$

Then just adding the index $0$ does not change anything significant.

$(0,0),(1,0),(0,1),(2,0),(1,1),(0,2),(3,0),..... \to $

$0,1,2,3,4,5,6....$

The trouble is we aren't actually explicitely defining what the algebraic expression of the bijection is; just showing intuitively it must exist. But then again there is nothing in the definition that says we have to define what the bijection is and if we can demonstrate via induction that it exists that is fine.

But with little math we can get the first one is:

For any $(1,k)$ we map $(1,k) \to \sum_{j=0}^k = j$. And so for the following next batch $(k+1, 1)$ to $(1, k+1)$ we map $(a=(k+1)-(b-1), b)\mapsto (\sum_{j=0}^k j) + b$.... of $(a,b)\to [\sum_{j=0}^{a+b-1} j] + b = \frac {(a+b-1)(a+b)}2 + b= \frac {(a+b)^2+(b-a)}2$.

The second is similar.

If $k = a+ b+ 1$ then $(0, a+b)\mapsto [\sum_{j=0}^k j]-1 = \frac {(a+b+1)(a+b+2)}2 - 1 = \frac{(a+b)^2 +3(a+b)}2 + 1$ and $(a,b)\mapsto \frac{(a+b)^2 +3(a+b)}2 + 1- a = \frac {(a+b)^2 + (a+3b) +2}2$

It may or may not be worth noting with shifiting indexes.

The first $\frac {(a+b)^2+(b-a)}2$ becomes $\frac {(a+1+b+1)^2 - (b-1-a+1)}2-1$ is the same as the same as the second.

fleablood
  • 124,253