Why do irrationality proofs of $\sqrt x$ not apply when $x$ is a perfect square?

The statement $x|a^2\Rightarrow x|a$ is not generally true (Counter-example : $8|4^2$ but we have not $8|4$).

The proof works for $x$ prime, because, then, this statement is true by Euclid's lemma.


The proof will work for any integer $\rm\,x\,$ (or rational) that is not a perfect square, since it will have a prime factor occurring to an odd power, which is precisely what's needed for the proof to succeed. From $\rm\:a^2 = x b^2\:$ we deduce, by unique prime factorization, that the power of every prime $\rm\:p\:$ dividing $\rm\:x\:$ must be even, being the difference of two even integers (the power of $\rm\:p\:$ in $\rm\:a^2\:$ minus the power in $\rm\:b^2$).

Generally it is not true that $\rm\:x\:|\:a^2\:\Rightarrow\:x\:|\:a\ $ (e.g. let $\rm\:x = a^2 > 1)$. In fact this property is true iff $\rm\:x\:$ is squarefree, which is why the proof works for $\rm\:x\:$ prime (or a product of distinct primes) which, having at least one prime to the power one, certainly does have a prime occurring to an odd power. The general case reduces to this case by pulling the square part of $\rm\:x\:$ out of $\rm\:\sqrt{x},\:$ i.e. if $\rm\:x = n^2 y,\:$ with $\rm\:y\:$ squarefree then we have $\rm\:\sqrt{x} = \sqrt{n^2 y} = n\sqrt{y}\in \mathbb Q\iff\sqrt{y}\in\mathbb Q.$ Therefore your method of proof will work if you first reduce this way to the case where $\rm\:x\:$ is squarefree.


Another way to think about this is to reformulate your proof to go through the following statement:

If $\gcd(a,b)=1$, then $\gcd(a^2, b^2)=1$.

This follows immediately from unique factorization (or with a little more work from Euclidean-algorithm-type arguments). It also directly implies that any rational square root of an integer is itself an integer. Say $(a/b)^2=n$ with $a/b$ in lowest terms, then $\gcd(a,b)=1$. Thus $\gcd(a^2,b^2)=1$, so $a^2/b^2$ is a fraction in lowest terms which is also equal to an integer, and hence $b= \pm 1$.

I like this way of thinking about it because it does apply to rational roots of integers; it just gives a different conclusion (that they're integers, rather than that they're irrational).