3

It is a well-known fact that the set of rationals $\mathbb{Q}$ is countable. The proof for $\mathbb{Q^+}$, the strictly positive rationals, is the classic "snaking" pattern detailed in a bunch of textbooks and internet sources, e.g here. ProofWiki has 4 (!) different proofs outlined here, but the proofs of (2), (3) and (4) all assume proofs that the cartesian product of countable sets is also countable, or that the union of $k$ countable sets is also countable. My Discrete Math class will not have been exposed to those facts at the time that I discuss the countability of $\mathbb{Q^+}$, whereas proof (1) is an informal, non-rigorous proof of the "snaking" pattern which is not particularly satisfying to me (or to my best students).

What I'm interested in is a mathematically accurate characterization of the "snaking" pattern; i.e I'm looking to find the formula $f(n)$ for a bijection $f$ from $\mathbb{N}^*$ (strictly positive integers) to $\mathbb{Q^+}$.

Jason
  • 199
  • 1
  • 7
  • This is not so easy. An explicit function going from $(p,q)$ to a unique integer is easy to obtain, but that easy function is not a bijection bevause (for example) 2/4 will map to a different integer than 1/2. An explicit function from the integers to the rationals that skips all reducible fractions is not at all easy to come up with. – Mark Fischler Nov 28 '16 at 23:52
  • I don’t know of any nice closed form description of the snaking pattern after the fractions are reduced. This answer and the answer to this question demonstrate two bijections, and this question and answer demonstrate another. – Brian M. Scott Nov 28 '16 at 23:55
  • Of course, if you were willing to consider 2/4 as bing distinct from 1/2, the Cantor pairing function works fine. But since that covers only the positive rationals, remember to modify it to cover the negatives as well. – Mark Fischler Nov 28 '16 at 23:55
  • It's easier and sufficient to find $f:Q^+-> N\times N$ where $f$ is injective sof $f(Q) \subset N\times N$ via if $f(a,b) = (a,b)$ so $f(Q) =\ {(a,b)|a,b \in N \gcd(a,b) = 1}\subset N\times N$. f, though not surjective is injective. Meanwhile $g:N\times N -> N$ via then snake can be shown to be bijective. $h: N->Q$ via $h(n) = n$ is injective. So $ – fleablood Nov 28 '16 at 23:57
  • Apologizes. I misread the question. You can find an explicit characterization of the "snaking" pattern in an answer to my question here. Though perhaps this isn't entirely satisfying since it doesn't deal with equivalent fractions. – MathematicsStudent1122 Nov 29 '16 at 00:01
  • Maybe using the binary representation of rationals and naturals. You can try too terminating series of Cantor, that represent rationals numbers. – Masacroso Nov 29 '16 at 00:48

3 Answers3

5

Define $$g(n)=(-1)^n \Big\lceil\frac{n}{2}\Big\rceil,$$

and then set $$f(p_1^{e_1}\dots p_k^{e_k})=p_1^{g(e_1)}\dots p_k^{g(e_k)},$$ where $p_1,\dots,p_k$ are distinct primes. (Since an empty product equals $1,$ we have $f(1)=1.)$

The function $f$ is a bijection from $\mathbb{N^+}$ to $\mathbb{Q^+}.$

This isn't the same as the snaking pattern that one often sees, but it is an easily-defined formula for a bijection between the two sets.

Mitchell Spector
  • 9,917
  • 3
  • 16
  • 34
0

If we assume the Natural numbers include $0$;

Fact 1: $f:\mathbb N \times \mathbb N \rightarrow \mathbb N; f(a,b) = a+\sum_{i=0}^{a+b} i$ is a bijection.

Pf: Suppose $f(a,b) = f(c,d)$. If $a+b = c+d$ then $a+\sum_{i=0}^{a+b} i + c+\sum_{i=0}^{a+b} i$ so $a = c$ and $b = d$. If $a+b < c+d$ then $f(c,d) = c+ \sum_{i=0}^{a+b} i + \sum_{k=a+b+1}^{c+d}k > c+\sum_{i_0}^{a+b} i + a > f(a,b)$ which is a contradiction. If $a+b > c+d$ we get a similar contradiction by the same argument. So $f$ is injective.

If $n \in \mathbb N$ then there exist $m$ so that $sum_{i=0}^m i \le n < \sum_{i=0}^{m+1} i$ so let $k = n - sum_{i=0}^m i$ and we have $k \le m$ so $f(k,m-k) = \sum_{i=0}^m i + k = n$ so $f$ is surjective.

Fact 2: if the natural numbers don't contain $0$ $\mathbb N$ is still bijective with $\mathbb N \times N$.

Let $f$ be as in Fact 1. Let $g:\mathbb N \times N \rightarrow \mathbb N$ via $g(a,b) = f^{-1}(a-1,b-1) + 1$ which is clearly a bijection.

Fact 3: if $q = a/b; a,b \in \mathbb Z^+; \gcd(a,b) = 1$ then $h(q) = (a,b)$ $h:\mathbb Q^+ \rightarrow \mathbb N\times \mathbb N: h(q=a/b) = (a,b)$ is injective although not surjective.

Pf: if $r = a/b$ and $q \ne a/b$ then $h(q) \ne (a,b)= h(r)$.

Fact 4: $k:\mathbb N \rightarrow \mathbb Q^+: k(n) = n$ is an injection.

So we have $g\circ h:\mathbb Q^+ \rightarrow \mathbb N$ is an injection. and we have $k: \mathbb N \rightarrow Q^+$ is an injection.

So $\mathbb Q^+$ and $\mathbb N$ have same cardinality.

So my question... Do you still want to find the precise bijection.

fleablood
  • 124,253
  • Be careful with your notions: $\mathbb Q^+$ and $\mathbb N$ are certainly not isomorphic, unless you use a very obscure definition of that term. There is a bijection, which is the point of the question, but that only tells something about the cardinality of the sets. An isomorphism implies structural similarity (essentially, the underlying structures are the same up to renaming of the elements). This is not the case for the rationals vs. the integers: most prominently, each element in $\mathbb Q^+$ has a multiplicative inverse, which is not the case for $\mathbb N$. – akobel Nov 29 '16 at 10:43
0

For a rational $r$, let

$$\begin{cases}p(r):=r\arg\min_n(rn\in\mathbb N),\\q(r):=p(r)/r\end{cases}$$ which turns it to an irreducible fraction, and let $$\phi(p,q)=\begin{cases}\gcd(p,q)=1\to1\\\gcd(p,q)>1\to0\end{cases}$$ which tests for irreducibility of a fraction.

Then

$$n(r):=\sum_{s=2}^{p(r)+q(r)-1}\sum_{i=1}^{s-1}\phi(i,s-i)+\sum_{i=1}^{p(r)}\phi(i,p(r)+q(r)-i)$$ formally defines the bijection from $\mathbb Q^+$ to $\mathbb N^*$.

For example, $n(1.25)=25$.