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.
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.