Proof (connected set in R)

Disconnected $\implies$ not an interval

Suppose $Y$ is disconnected. Then $Y = U \cup V$ for some $U,V\subseteq \R$ that are non-empty and satisfies $\overline{U} \cup V = \emptyset = U \cap \overline{V}$.

Pick some $x\in U$, $y\in V$, and WLOG assume $x<y$. Set $$ \begin{align*} z = \sup(U\cap [x,y]). \end{align*} $$ Note that $z\in \overline{U}$, and so $z\not\in V$. Also $x\leq z\leq y$. We have two cases:

  1. If $z\not\in U$, then $z\not\in U\cup V = Y$.

  2. Otherwise if $z\in U$, then $z\not\in \overline{V}$, so there exists a ball $(z-r, z+r)$ which is disjoint from $V$. Pick some $w\in (z,z+r)\subseteq (x,y)$. Then $w\not\in V$ since the ball is disjoint from $V$, and $w\not\in U$ since $w>z$. Thus $w\not\in U\cup V = Y$.

Not an interval $\implies$ disconnected

Suppose $x,y\in Y$ and $x<z<y$ but $z\not\in Y$.

Let $U = Y\cap (-\infty, z)$ and $V = Y\cap (z, \infty)$. They are disjoint, non-empty (since $x\in U$ and $y\in V$), open, and $Y = U \cup V$ (since $z\not\in Y$). Therefore $Y$ is disconnected.