Prove that [0,1] is connected.

You're probably not looking for the answer still after a year, but for those who come across this in the future, it may be helpful. You are pretty much right about your proof, but here is a more formal way of writing it.

That is that "If $a<b$, then the subspace $[a,b]$ of $E^1$ is connected".

Let $a<b$ and let $[a,b]$ be a subspace of $R$ with the $E^{1}$ topology. For the sake of contradiction, assume that $[a,b]$ is not connected. Then $[a,b]= U \cup V$, where $U$ and $V$ are nonempty disjoint open sets in $[a,b]$. Without loss of generality we may assume that $b \in V$. Because $U$ is nonempty and bounded above (by $b$), the axiom of completeness states that $U$ has a least upper bound $s$. We will prove that $s$ is not an element of either $U$ or $V$, and this will yield a contradiction. Suppose $s \in U$. Since $U$ is open, there exists an $\epsilon> 0$ such that $B_{\epsilon}(s) \subseteq U$. Thus, since $s+ \frac{\epsilon}{2} \in U$ and $s<s+ \frac{\epsilon}{2}$, there exists an element in $U$ that is greater than $s$. Therefore, $s$ is not an upper bound for $U$. This is a contradiction. Thus, $s \not \in U$. Now suppose $s \in V$. Then, because $V$ is open, there exists an $\epsilon>0$ such that $B_{\epsilon}(s) \subseteq V$. Then $s- \frac{\epsilon}{2}$ is an upper bound for $U$. But $s- \frac{\epsilon}{2}<s$, which is a contradiction because $s$ is the \emph{least} upper bound for $U$. So $s \not \in V$. Thus, $s \not \in U \cup V$, which is a contradiction. Therefore, $[a,b]$ is connected.


TheoremA topological space $X$ is connected iff every continuous function $f: X \to\{±1\}$ is a constant function.

ProofLet $X$ be a connected space and $f: X \to \{±1\}$ a continuous function. We want to show that $f$ is a constant function. If $f$ is non-constant, then it is onto. Let $A = f^-{1}(1)$ and $B = f^{-1}(-1)$. Then $A$ and $B$ are disjoint non-empty subsets of $X$ such that $A$ and $B$ are both open and closed subsets of $X$ and $X = A U B$.(Why?). This is a contradiction. Therefore $f$ is constant.

Conversely, let us assume that $X$ is not connected. Therefore there exist two disjoint proper non-empty subsets $A$ and $B$ in $X$ such that $A$ and $B$ are both open and closed in $X$ and $X = AU B$. Now we define a map $f: X \to \{±1\}$ as

$f (x) = \begin{cases} 1,&x\in A\\-1,& x \in B\end{cases} $$ $.

Then $f: X \to\{±1\}$ is a continuous non-constant function. (Why?) This completes the proof.

Now I am giving you a shorter proof of your problem.

Suppose $j$ is any interval if $f: J \to\{±1\}$ is an onto Continuous function, then there exist $x,y\in J$ such that $f(x) = -1$ and $f (y) = 1$. By the intermediate value theorem, there exists $z$ between $x$ and $y$ such that $f(z) = 0$, a contradiction to our assumption that $f$ takes only the values $\pm 1$. Hence no such $f$ exists and hence $J$ is connected. It follows that any interval is connected.