2

I have to construct a bijection between $\Bbb N$ the natural numbers and $\Bbb S$, where $\Bbb S$ is the set of finite rows of natural numbers.

S=$\{(n_0,n_1,...,n_k)|k\in \Bbb N,n_i\in \Bbb N\}$ I did a similar problem here:bijection between natural numbers and set of strictly growing finite rows but can figure it out for this one.

3 Answers3

3

I will write rows with $[ ~~]$ brackets. (If you also admit an empty row $\emptyset$ you can just extend the bollow definition with $f(\emptyset) := 1$).

Then we can define a bijection $f : \mathbb{S} \rightarrow \mathbb{N}_{>1}$ by \begin{align} f([a_1, \dots, a_k]) := p_1^{a_1} \dots p_{k-1}^{a_{k-1}} \cdot p_k^{1 + a_k} \end{align} Where $p_k$ is the $k$-th prime. It is then easy to get a bijection $\mathbb{S} \rightarrow \mathbb{N}$ by combining $f$ with a bijection $\mathbb{N}_{>1} \to \mathbb{N}$.


Proof of Surjectivity:

Any $n > 1$ has a biggest ($k$-th) prime number $p_k$ with exponent $e > 0$ s.t. $n = x \cdot p_k^e$ and $p_k \not \mid x$.

If $x = 1$ we have $ f ([\underbrace{0, \dots ,0}_{k-1 \text{ times}},e-1] ) = p_k^{1 + (e-1)} = x \cdot p_k^e = n $

If $x > 1$ then we have $x < n$, and therefore by complete induction $x$ has a preimage $[x_1, \dots, x_l]$. Then we have \begin{align} f ( [ x_1 , \dots , 1 + x_l, ~\color{Blue}{0, \dots ,0}, ~e-1 ] ) = p_1^{x_1} \dots p_l^{1 + x_l} \cdot p_k^{1 + (e-1)} = x \cdot p_k^e = n \end{align} Where we need to put $\color{blue}{\text{$(k-l)-1$ zeros}}$ between $(1 + x_l)$ and $(e-1)$ to make sure the latter is the $k$-th entry of the tuple. Note that we must have $l < k$ since the biggest prime in $n$ was $p_k$ and all primes $p_l$ appearing in $x$ must be smaller. $\Box$


Proof of Injectivity:

Assume $f([a_1, \dots, a_n]) = f([b_1, \dots, b_m])$, then $$ p_1^{a_1} \dots p_n^{1 + a_n} = p_1^{b_1} \dots p_m^{1 + b_m} $$ where both sides are prime factorisations of the same number. Since $\color{Red}{\text{said number is bigger then } 1}$, we can conclude $n = m$ and $a_j = b_j$ by the uniqueness of prime factorizations. $\Box$


Note that it is in the proof for injectivity, that the (seemingly odd) $+1$ in the power of the last prime number $\color{Red}{\text{plays its crucial role}}$. Without it, the proof would not work.

Léreau
  • 3,246
1

For all $(n_0,\ldots,n_k) \in \mathbb{S}$ consider the sum $n = \sum_{i=0}^k (n_i+1)$. There are many finite elements of $\mathbb{S}$ that have that sum equal to a fixed $n \in \mathbb{N}$. We can order them in the following way

$$ (n_0,\ldots,n_k) \leq (m_0,\ldots,m_h) \Leftrightarrow \begin{cases} k \leq r \\ k=r, n_t < m_t \text{ and } n_i = m_i \forall i < t \text{ for some } t \leq k \end{cases} $$ It is now clear that we can put the elements of $\mathbb{S}$ in a sequence by considering first all the rows with sum equal to 1, then all the rows with sum equal to 2 and so on...

Kalhac
  • 443
1

Take the first $n$ prime numbers $\{ p_k \}_n$ (1 excluded). Then $$ \pi : \quad S \mapsto L= \prod_k p_k^{n_k} $$ is a bijection by the fundamental theorem of arithmetic.

user48672
  • 1,202
  • 1
    I think you need to add a $-1$ after the prime factorization to make sure that 1 gets hit. Also you might consider replacing gcd algorithm by "fundamental theorem of arithmetic". I'm not entirely clear how this follows from the Euclidean algorithm. Other than that looks good. – David Reed Nov 27 '17 at 01:33
  • Do you mean L-1? – user48672 Nov 28 '17 at 21:08
  • I mean that in terms of surjectivity I don't see any sequence that would be mapped to 1, unless 0 is allowed to be a natural number, in which case case I don't see anything that would be mapped to zero. I believe if you subtract 1 from the product it becomes bijective, but I haven't explicitly checked. – David Reed Nov 28 '17 at 21:22
  • Actually no I'm thinking it may not be fixable. If zero is not considered a natural number then numbers that have gaps in their prime factorization don't get hit ($e.g. \ 2*5=10$) because the exponent of 3 will always be positive. If you allow zero then any sequence consisting of only zeros gets sent to 1 and you lose injectivity. This IS the method by which one normally encodes sequences (godel numbering), but its designed to be injective and not necessarily bijective. – David Reed Nov 28 '17 at 21:36
  • For very large numbers and their long sequences, this method becomes a disaster, because generates incredibly huge numbers – ayr Apr 19 '23 at 04:13