Prove that if $A$ is both open and closed, $A=\mathbb R$. Suppose $A$ is a non-empty subset of $\mathbb R$. Prove that if $A$ is both open and closed, $A=\mathbb R$.
I think I'm supposed to assume that $A$ is not equal to $\mathbb R$ and derive a contradiction. Would that mean $A$ complement is also both closed and open? I'm not sure if that would be the right approach to the proof. Any help is greatly appreciated!
 A: Suppose that $A \neq \mathbb{R}$, then there is a point $y \in \mathbb{R}$ such that $y \not\in A$. Since $A$ is closed, this means that $\mathbb{R}\setminus A$ is open. Moreover, $\mathbb{R} \setminus A$ is also closed, since $A$ is open.
Suppose without loss of generality that the set $A_{< y} = \{ a \in A : a < y \}$ is not empty. Let $x = \sup A_{<y}$. We know that $x \in A$ since $A$ is closed. Given $\delta > 0$, what can we say about $B_\delta(x)$?

Since $y \in \mathbb{R}\setminus A$, there is an $\epsilon > 0$ such that $(y - \epsilon, y + \epsilon)$ is disjoint from $A$. This means that $x < y$. Now for any $\delta >0$ the interval $(x-\delta, x+\delta)$ contains numbers larger than $x$ but less than $y$. By our definition, $x$ is the largest real number in $A$ less than $y$, and therefore $(x-\delta, x+ \delta)$ is not contained in $A$ for any $\delta>0$. Therefore $A$ is not open, and this is a contradiction.
A: Suppose that $x\notin A$.
Since $A$ is closed we can find some open, maximal interval $I\ni x$ disjoint from $A$. (Why?).
Since $A$ is not empty, there will be some $y\in A$. Suppose, for example, that $y>x$. Then $I$ has an upper bound, and let $z=\sup I$. Then $z$ must be in $A$. But every open neighbourhood of $z$ intersects $I$, and this contradicts the fact that $A$ is open.
Same if $y<x$, taking $z=\inf I$.
A: Suppose $A \ne \mathbb{R}$. Choose any point $x \in A$. Suppose $A \ne \mathbb{R}$. Then either $[x,\infty) \not\subseteq A$ or $(-\infty,x] \not\subseteq A$. Consider the case where $[x,\infty)\not\subseteq A$ (the case where $(-\infty,x] \not\subseteq A$ is similarly handled.) For this case, define
$$
                 Y = \sup\{ y \in \mathbb{R} : [x,y]\subseteq A \}.
$$
$Y$ is finite because $[x,y]\not\subseteq A$ for some $y$.
And $Y$ is in the closure of $A$ because there is a monotone increasing sequence $\{ x_{n} \}_{n=1}^{\infty}\subset A$ that converges to $Y$. Becuase $A$ is closed, then $Y \in A$. However, $A$ is also open, which gives an open interval about $Y$, say $(Y-\delta,Y+\delta)$, which is contained in $A$; but that contradicts the definition of $Y$ because $Y+\delta/2 > Y$ and $Y+\delta/2 \in A$. Therefore, $Y=\infty$.
