# Problem with proof from Pugh's Analysis book on the presence of both rationals and irrationals in every interval

Here there is a theorem (Theorem 7, p.20) from Pugh's "Real Mathematical Analysis" with its proof.

My problem lies in the text in blue: I don't see why it comes that the mapping $$T$$ sends rationals to rationals and irrationals to irrationals.

Of course I know this is an homeomorphism, so it actually does, but I don't see how, without getting into the homeomorphism side, the proof proves that the mapping actually does what is stated.

Theorem: Every interval $$(a,b)$$, no matter how small, contains both rational and irrational numbers. In fact it contains infinitely many rational numbers and infinitely many irrational numbers.

Proof: Think of $$a,b$$ as cuts $$a = A|A'$$, $$b = B|B'$$. The fact that $$a < b$$ implies the set $$B\setminus A$$ is a nonempty set of rational numbers. Choose a rational $$r \in B\setminus A$$. Since $$B$$ has no largest element, there is a rational $$s$$ with $$a < r < s < b$$. Now consider the transformation $$T :t \to r + (s−r)t.$$ It sends the interval $$[0, 1]$$ to the interval $$[r, s]$$. $$\color{blue}{\text{Since }r \text{ and } {s {−} r} \text{ are rational, }T \text{ sends rationals to rationals and irrationals to irrationals.}}$$ Clearly $$[0,1]$$ contains infinitely many rationals, say $$\frac{1}{n}$$ with $$n \in \mathbb{N}$$, so $$[r, s]$$ contains infinitely many rationals. Also $$[0, 1]$$ contains infinitely many irrationals, say $$\frac{1}{n\sqrt{2}}$$ with $$n \in \mathbb{N}$$, so $$[r, s]$$ contains infinitely many irrationals. Since $$[r, s]$$ contains infinitely many rationals and infinitely many irrationals, the same is true of the larger interval $$(a, b)$$.

Any feedback will be greatly appreciated.

As $$r$$ and $$s$$ are rationals, for every rational $$t$$, $$T(t)=r+(s-r)t$$ is a rational, right ?
Now if $$t$$ is irrational, $$T(t)=r+(s-r)t$$ can't be rational. Otherwise, $$t=\frac{T(t)-r}{s-r}$$ would be a rational too, which is excluded.
Hence, $$T$$ maps rationals to rationals, and irrationals to irrationals.
Let $$d \in \mathbb{Q}$$ and $$d>0$$.
We claim that if $$r \in \mathbb{Q}$$ and $$t \in \mathbb{Q}$$, then $$r+dt \in \mathbb{Q}$$, this is due to rational numbers are closed under multiplication and addition.
Also, $$r \in \mathbb{Q}$$ and $$t \notin \mathbb{Q}$$, then $$r+dt \notin \mathbb{Q}$$, suppose on the contrary that $$x=r+dt \in \mathbb{Q}$$, then $$t=\frac{x-r}{d} \in \mathbb{Q}$$ since rational numbers are closed under subtraction and remains a rational number upon dividing it by a rational number. However, this contradicts with the assumption that $$t \notin \mathbb{Q}$$.