Closure of a connected subset of $\mathbb{R}$ is connected?

Do you know any definition or property of connectivity? A good one is that if $X$ is connected then any continuous $f : X \to \{0, 1\}$ must be constant. Say $\forall x \in X$, $f(x) = 1$. How can you extend this to the closure of $X$ without destroying continuity? Note that this statement is not restricted to $\mathbb{R}$.


You can get started simply with definitions. You will need the definition of connectedness, and you will need to understand that we are using the subspace topology to determine connectedness of subsets.

Suppose $S$ is a connected subset of $X$, and that $O$ and $U$ are disjoint open subsets of $X$ such that $O\cup U\supseteq \overline{S}$. We will show that one of $O$ or $U$ contains $\overline{S}$ and the other does not intersect $\overline{S}$, proving that $\overline{S}$ is connected.

Certainly $O\cup U\supseteq S$, therefore by connectness of $S$ we have that (...?) (Draw conclusions about where $\overline{S}$ must live.)


Here is another proof by contradiction, using the definition of connectedness from Rudin's Principles of Mathematical Anaylsis.

Suppose $S$ is a connected set, where its closure $ \bar{S} $ is not connected. Therefore there exist two sets $A$ and $B$, such that $ \bar{A} \cap B = \bar{B} \cap A = \emptyset $ and $A\cup B = \bar{S} $. Define $ G:= A \cap S $ and $ H:= B\cap S $. Because $G$ is a subset of $A$ and $H$ is a subset of $B$, it is clear that $ \bar{G} \cap H = \bar{H} \cap G = \emptyset $. and $G\cup H = S$. So that $S$ is not connected, contrary to our first assumption. q.e.d.