If a nonempty set of real numbers is open and closed, is it $\mathbb{R}$? Why/Why not?
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 > x_0$.
Then the set $Z = \{ x \in \mathbb{R} : x > 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 > z$, $|z - z_n| < \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}$.
You're trying to prove that $\mathbb{R}$ is connected. You can do as follow : if a set $\mathbf{A}$ is both open and closed, then you can check that $\mathbb{1}_\mathbf{A}$ (the characteristic function of $\mathbf{A}$) is continuous, because $\mathbb{1}_\mathbf{A}^{-1}(O)$ where O is open is either $A$, its complement, the empty set or $R$ depending on $1$ and/or $0$ being in $O$, and all these set are open.
But $\mathbb{1}_\mathbf{A}$ only takes values $1$ or $0$, so it's easy to see that if it's continuous, then it's constant (if it is not, by the Intermediate Value Theorem, then it should also take all values between $0$ and $1$). Hence it's either always $1$ or $0$. And so $\mathbf{A}$ is either $\mathbb{R}$ or the empty set.
Let $S$ be a nonempty subset of $\mathbb{R}$ that is both open and closed. Let's say that $S$ contains the element $s$. We want to show that no element of $\mathbb{R} - S$ can be bigger than or less than $s$, immediately implying that it is empty.
Suppose that there are elements of $\mathbb{R} - S$ bigger than $s$. We can construct the set $X$ of all such elements, and consider its infimum. Use the fact that $S$ is open and closed to derive a contradiction. A similar argument works to show there are no elements of $\mathbb{R} - S$ smaller than $s$.
Note: This argument crucially uses the structure of $\mathbb{R}$ in asserting the existence of infimums and supremums.
Because $\mathbb R$ is connected. Asume $U$ is a nonempty proper open and closed subset of $\mathbb R$, that is $V:=\mathbb R\setminus U$ is also nonempty and open. Let $u\in U$, $v\in V$. Wlog. $u<v$. Let $a=\sup([u,v]\cap U)$. As $[u,v]\cap U$ is a nonempty bounded closed set, $a\in([u,v]\cap U)$. Hence $u\le a<v$ (as $v\notin U$) and $U$ contains some $\epsilon$ neighbourhood of $a$. But then $\min\{a+\frac12\epsilon, v\}\in U\cap[u,v]$, contradiction to $a$ being the supremum.
I think I have a simpler proof using the border of $A$:
Let $A \subseteq R$ nonempty, open and closed, and assume $A \neq \mathbb{R}$.
Then $\partial A = \overline A \cap \overline{(\mathbb{R} \setminus A)} = $ ($A=\overline A$ since $A$ closed, same for $\overline{\mathbb{R} \setminus A}$) $ = A \cap (\mathbb{R} \setminus A) = \emptyset$ (the border is empty)
However $x = \sup A(=\overline A) \in \partial A$, a contradiction. $(\forall r>0) \langle x-r, x+r \rangle$ contains points both in $A$ and in $A \setminus \mathbb{R}$.