Subset of Real Numbers is Interval iff Connected

Theorem
Let the real number line $\R$ be considered as a topological space.

Let $S$ be a subspace of $\R$.

Then $S$ is connected iff $S$ is an interval of $\R$.

That is, the only subspaces of $\R$ that are connected are intervals.

Proof
From Rule of Transposition, we may replace the only if statement by its contrapositive.

Therefore, the following suffices:

Sufficient Condition
Suppose $S$ is an interval of $\R$.

Suppose further that $A \mid B$ is a separation of $S$.

Let $a \in A, b \in B$, and suppose WLOG that $a < b$.

Since $a, b \in S$, and $S$ is an interval, $\left[{a \,.\,.\, b}\right] \subseteq S$.

Let $A' = A \cap \left[{a \,.\,.\, b}\right]$ and $B' = B \cap \left[{a \,.\,.\, b}\right]$.

Then:

By the definition of a separation, both $A$ and $B$ are closed in $S$.

Hence by Closed Set in Topological Subspace, $A'$ and $B'$ are also closed in $\left[{a \,.\,.\, b}\right]$.

From Closed Set in Topological Subspace: Corollary, $A'$ and $B'$ are closed in $\R$.

Now, since $B' \ne \varnothing$, and $B$ is bounded below (by, for example, $a$), by the Continuum Property $b' := \inf \left({B'}\right)$ exists, and $b' \ge a$.

We have that $B'$ is closed in $\R$

Hence from Closure of Real Interval is Closed Real Interval:
 * $b' \in B'$

Since $a \in A'$ and $A \cap B = \varnothing$, it follows that $b' > a$.

Now let $A'' = A' \cap \left[{a \,.\,.\, b'}\right]$.

Using the same argument as for $B'$, we have that $a = \sup \left({A}\right)$ exists, that $a \in A$ and also $a'' < b'$.

Now $\left({a \,.\,.\, b'}\right) \cap A' = \varnothing$ or $a$ would not be an upper bound for $A''$.

Similarly, $\left({a \,.\,.\, b'}\right) \cap B' = \varnothing$ or $b'$ would not be a lower bound for $B$.

Thus $\left({a'' \,.\,.\, b'}\right) \cap \left({A' \cup B'}\right) = \varnothing$.

But since $a < a'' < b' < b$, we also have:
 * $\left({a'' \,.\,.\, b'}\right) \subseteq \left[{a \,.\,.\, b}\right]$, and
 * $\left({a'' \,.\,.\, b'}\right)$ is non-empty.

So, there is an element $z \in \left({a'' \,.\,.\, b'}\right)$, and hence in $\left[{a \,.\,.\, b}\right]$, which is not in $A' \cup B'$.

This contradicts $(1)$ above, which says that we have $A' \cup B' = \left[{a \,.\,.\, b}\right]$.

From this contradiction it follows that there can be no such separation $A \mid B$ on the interval $S$.

Therefore, by definition, $S$ is connected.

Necessary Condition
Suppose $S$ is not an interval of $\R$.

Then by Interval Defined by Betweenness, $\exists x, y \in S$ and $z \in \R \setminus S$ such that $x < z < y$.

Consider the sets $S \cap \left({-\infty \,.\,.\, z}\right)$ and $S \cap \left({z \,.\,.\, +\infty}\right)$.

Then $S \cap \left({-\infty \,.\,.\, z}\right)$ and $S \cap \left({z \,.\,.\, +\infty}\right)$ are open by definition of the subspace topology on $S$.

Neither is empty because they contain $x$ and $y$ respectively.

They are disjoint, and their union is $S$, since $z \notin S$.

Therefore $S \cap \left({-\infty \,.\,.\, z}\right) \mid S \cap \left({z \,.\,.\, +\infty}\right)$ is a separation of $S$.

It follows by definition that $S$ is disconnected.