If a nonempty set of real numbers is open and closed, is it $\mathbb{R}$? Why/Why not? In other words, are $\emptyset$ and $\mathbb{R}$ the only open and closed sets in $\mathbb{R}$? Why/Why not?

I tried by assuming a set is equal to its interior points and contains its limit points.

A bounded set will not do since stuff like $[1,4]$ and $\{5\}$ will not work, though that is not really proof. Help please?

Anyway, it must then be unbounded.

If $a$ is a real number then $(a,\infty)$, $(-\infty,a)$, $[a,\infty)$ and $(-\infty,a]$ don't seem to cut it so it must be $\mathbb{R}$.
Suppose $X \subset \mathbb{R}$ is nonempty, open and closed. Let $x_0 \in X$. Finally suppose that $X \neq \mathbb{R}$; then there is some $y \not\in X$; WLOG we can assume that $y &gt; x_0$.

Then the set $Z = \{ x \in \mathbb{R} : x &gt; x_0, x \not\in X \}$ is bounded below (by $x_0$) and nonempty ($y \in Z$). Therefore $\inf Z = z$ exists.


Suppose $z \in X$. Then since $X$ is open, it contains an open neighborhood $(z - \epsilon, z + \epsilon)$. This contradicts the definition of $z = \inf Z$, because there would be a sequence $z_n &gt; z$, $|z - z_n| &lt; \frac{1}{n}$, $z_n \in Z \Rightarrow z_n \not \in X$. This is not possible, because $[z, z + \epsilon) \subset X$.
Suppose $z \not \in X$. Then since $X$ is closed, its complement is open, therefore there is an open neighborhood $(z - \epsilon, z + \epsilon)$ contained in $\mathbb{R} \setminus X$. Then $z - \frac{\epsilon}{2}$ contradicts the $\inf$ definition of $z$.


It follows that $X = \mathbb{R}$.
If $A$ is open, $A$ is ($\emptyset$ or) a disjoint union of a countable collection of open intervals. If $A$ is the latter, then $A$ is closed if and only $A=\mathbb R$ because otherwise, $A$ would have nonempty border, violating the rule that Set is Clopen iff Boundary is Empty.

Note: This is more in line with my thinking that $A$ has something to do with intervals, but unfortunately the first sentence of this post was not proven (or stated) in one of my elementary real analysis textbooks, namely the one by Trench. Luckily: 1 - it is an exercise in the other textbook, namely the one by Lay. 2 - it is a proposition in my advanced real analysis textbook by Royden and Fitzpatrick.