showing a rational interval is disconnected I am trying to show that the rational interval $ S= \{x \in \mathbb Q : a \leq x \leq b\} $ is disconnected in the metric space $(X,d)$ where $X=\mathbb R$ and $d$ is the standard metric ( $ d(x,y)=|x-y| \; \forall \; x,y \in \mathbb R$ )
The definition of disconnected I would like to use is: a metric space $(X,d)$ is disconnected if there are non-empty, open, disjoint sets $A, B$ such that $X=A \cup B$.
If $a,b \notin \mathbb Q$ I think I have shown the above by what follows.
Any rational interval contains an irrational number (assume known). Let $c$ be an irrational number and $a<c<b$. Let $A=\{x\in \mathbb Q : a<x<c \}$ and $B=\{x\in \mathbb Q : c<x<b \}$.
$A$ and $B$ are disjoint and open. $A$ and $B$ are non-empty as every interval contains a rational number (assume known). As $c \notin \mathbb Q$ $S=A \cup B$ and so S is disconnected.
If either $a$ or $b$ do belong to $\mathbb Q$ then I don't know how to construct the sets $A$ and $B$ so that they are both open, disjoint and their union is $S$. As if for example if $A=\{x\in \mathbb Q : a\leq x<c \}$ then this is neither open nor closed I think.
How could this problem be solved?
 A: As I mentioned in the comments, you don't have to worry about $a$ and $b$ being in $\mathbb{Q}$, since you're looking at the set $S$ with subspace topology from $\mathbb{R}$. So you want to show that $S$ is a disjoin union of non-empty open sets in this topology, and not in the topology of $\mathbb{R}$. Recall that a set $U\subset S$ is open in $S$ if there exists an open $V\subset \mathbb{R}$ so that $U=V\cap S$. 
Everything else is fine in your proof. Just choose $A=\{x\in\mathbb{Q}:a\leq x<c\}$ and $B=\{x\in\mathbb{Q}:c<x\leq b\}$ instead. Why are these open in $S$? By choosing for example $V=]a-1,c[$, which is open in $\mathbb{R}$, it follows that
\begin{equation*}
]a-1,c[\cap S=]a-1,c[\cap[a,b]\cap\mathbb{Q}=[a,c[\cap\mathbb{Q}=\{x\in\mathbb{Q}:a\leq x<c\}=A,
\end{equation*}
so $A$ is of the form $V\cap S$ for some open $V$ in $\mathbb{R}$. Similarly you can see that $B$ is an open set in $S$.
A: Hint: Prove the following easy
Claim: A topological space $\,X\,$ is not connected iff there exists a continuous, surjective function $\,f: X\to \{0,1\}\,$ , with the latter space having the topology inherited from the usual one in $\,\Bbb R\,$ ( it is thus a discrete space)
Finally, just check 
$$f:S\to\{0,1\}\,\,,\,f(x)=\begin{cases}0\;\;,&\text{ if}\,\;\;\;x\leq\frac{b-a}{2}\\{}\\1\;\;,&\text{ if}\,\;\;\;x>\frac{b-a}{2}\end{cases}\;\;\;\;\;\;\;\;,\;\;x\in S$$
