TITLE: Question 6 of the 2nd round of the 15th Iran mathematical olympiad.
QUESTION [5 upvotes]: I came across this question the other day on an old Iran MO. The question goes as follows,

Let $P$ be the set of all points in $R^n$ with rational coordinates. For points $A,B ∈ P$, one can move from $A$ to $B$ if the distance $|AB|$ is $1$. Prove that every point in $P$ can be reached from any other point in $P$ by a finite sequence of moves if and only if $n ≥ 5$.

I have tried a few things such as polar coordinates and vectors but didn't make a huge amount of progress. Any advice or a solution would be greatly appreciated.

REPLY [4 votes]: We first show that not every point can be reached from $(0,0)$ for $n \le 4$. That it can be done for $n \ge 5$ will be shown afterwards. That this solves the general problem follows from the symmetry of the "move from A to B" definition.
Part 1:  $n \le 4$
Let the rational units be defined as
$$RU_n=\{r=(r_1,\ldots,r_n) \in P| \text{ satisfying } |r|^2=r_1^2+\ldots+r_n^2=1\}.$$
A move can be made from $A\in P$ to $B \in P$ iff $B-A \in RU_n$, where the difference is made component-wise. That means the points in $P$ that can be reached from $(0,0)$ in a finite series of moves are exactly those that can be expressed as a finite sum
$$x=\sum_{i=1}^k x_i, \text{ where } \forall i \in \{1,\ldots,k\}: x_i \in RU_n. \tag{*}\label{eq0}$$
We'll now show no component of a rational unit can have a denominator divisible by $4$ (in reduced form) if $n \le 4$.
Assume otherwise, then there exists a $r \in RU_n$ and writing $\forall i=1,\ldots,n: r_i=\frac{a_i}{b_i}$ in reduced form, we assume w.l.o.g that $b_1$ contains (one of) the highest powers of $2$ among the $b_i$, so $b_1=2^kb'_1, 2\nmid a_1, 2 \nmid b'_1, k \ge2 $. Note that $d=lcm (b_1,\ldots,b_n)$ is then of the form $d=2^ko$ with odd $o$. Using the definition of rational units we get
$$\sum_{i=1}^n \frac{a_i^2}{b_i^2}=1$$
and if we multiply this with $d^2$ we get
$$ \sum_{i=1}^n c_i^2=d^2, \text { where } c_i=a_i\frac{d}{b_i}\in \mathbb Z. \tag{1} \label{eq1}$$
As we noted above $2\nmid a_1$ and since $\frac{d}{b_1}=\frac{o}{b'_1}$ is also odd, so is $c_1$! Since $n \le 4$, we can add $0^2$ terms to the left side of \eqref{eq1} to fill up to 4 summands if necessary, sowie finally get
$$\sum_{i=1}^4 c_i^2 = d^2=16d'^2 \tag{2} \label{eq2}$$
Considering \eqref{eq2} mod 4, and remembering that $0$ and $1$ are the only possible quadratic residues mod 4, the only solutions are $c_1^2\equiv c_2^2 \equiv c_3^2 \equiv c_4^2 \equiv 0 \pmod 4$ and $c_1^2\equiv c_2^2 \equiv c_3^2 \equiv c_4^2 \equiv 1 \pmod 4$. Since we know that $c_1$ is odd, only the second option is possible, so all the $c_i$ are odd.
Considering \eqref{eq2} now mod 16, and remembering that the only odd quadratic residues mod 16 are $1$ and $9$, we see that \eqref{eq2} is impossible to fullfil with all odd $c_i$ mod 16, because the only options are $4\times 1, 3\times 1 + 1\times 9, 2\times 1 + 2\times 9,1\times 1 + 3\times 9$ and $4\times 9$, which are $\equiv 4, 12, 4, 12, 4 \pmod {16}$ in that order, so never $0$.
Ok, so we proved that no component of a rational unit has a denominator that is a multiple of $4$. But \eqref{eq0} shows that each component of a point that is reachable from $(0,0)$ is the sum of components of rational units. But such a sum can never be $\frac14$. Because if it were, then
$$\frac14=\sum_{i=1}^k \frac{a_i}{b_i},$$
where $\frac{a_i}{b_i}$ is the reduced form of a component of a rational unit, so $4\nmid b_i$ and hence $4\nmid lcm(b_1,\ldots,b_k)$. Multiplying the above equation with $lcm(b_1,\ldots,b_k)$ gives an integer result on the right hand side, but not an integer on the left hand side, as $lcm(b_1,\ldots,b_k)$ cannot "cancel" the $4$ in the denominator.
So any point in $P$ where one cordinate is $\frac14$ cannot be reached from $(0,0)$ for $n \le 4$.
This concludes the proof for part 1.
Part 2: $n \ge 5$
We use an old theorem from number theory, Lagrange's four-square theorem, that every natural number can be represented as the sum of four integer squares.
That means for every integer $k \ge 1$ we have for integers $a_k, b_k, c_k, d_k$ such that
$$a_k^2 + b_k^2+ c_k^2 + d_k^2 = 4k^2 -1,$$
and thus
$$\left(\frac{1}{2k}\right)^2 + \left(\frac{a_k}{2k}\right)^2 + \left(\frac{b_k}{2k}\right)^2 + \left(\frac{c_k}{2k}\right)^2 + \left(\frac{d_k}{2k}\right)^2  = 1.$$
That means for $n\ge 5$ there exists a rational unit $r_1$ with $\frac1{2k}$ as first component (if $n > 5$, just fill up with zeros). Since the definition of the rational unit only uses the square of each component, changing any number of signs in a rational unit makes the resulting number also a rational unit. Let $r_2$ be the rational unit obtained from $r_1$ by flipping all the signs, expcept on the first component. That means
$$r_1+r_2=(\frac1k,0,0,\ldots).$$
Obviously $((-r_1) + (-r_2)=(-\frac1k,0,0,\ldots)$, and similar by permutating the components rational units can be found such that the sum of 2 of them produces the zero vector except for a given component, where the component is $\frac1k$ or $-\frac1k$.
But each vector from $p\in P$ can be obtained as a finite sum of vector with only one component.
$$p=(p_1,\ldots,p_n) = (p_1,0,\ldots,0) + (0,p_2,0,\ldots) + \ldots + (0,\ldots,0,p_n), \tag{3}\label{eq3}$$
and if $p_1=\frac{a}{b}, b > 0$, then
$$(p_1,0,\ldots,0)=\sum_{i=1}^{|a|}(\pm\frac1b,0,\ldots,0),$$
with the signs before the fraction chosen the same as $a$. The same can of course be done for the other summands in \eqref{eq3}. But the summands thus calculated are exactly of the type that we proved are the sum of 2 rational units, so each $p=(p_1,\ldots,p_n) \in P$ is the sum of a finite number of rational units, so can be reached from $(0,0)$.
This concludes part 2 of the proof.