Closure of a connected set is connected

PROP Let $E\subseteq X$ be connected. Then $\overline E$ is connected.

P Let $f:\overline E\to\{0,1\}$ be continuous. Since $E$ is connected, $f\mid_E$ is constant. But $E$ is dense in $\overline E$, so $f$ is constant, since continuous functions are entirely determined on a dense subset of their domain whenever the codomain is Hausdorff. And $\{0,1\}$ with the discrete topology is metrizable, hence Hausdorff, the claim follows.

ADD There is a more general claim. Let $(X,\mathscr T)$ be a topological space. If $E$ is connected and $K$ is such that $E\subseteq K\subseteq \overline E$, then $K$ is connected.

P Consider $K$ as a subspace of $X$. Then $E$ is dense in the space $K$. Let $f:K\to\{0,1\}$ be continuous. Then $f\mid_E$ is constant. It follows $f$ is constant, so $K$ is connected.

Here is the proof of

PROP Let $X$, $Y$ be topological spaces, $Y$ Hausdorff. Suppose $D$ is dense in $X$ and $f,g:X\to Y$ are continuous. If $f$ and $g$ agree on $D$, then $f=g$.

P By contradiction. Thus, assume there exists $x\in X\smallsetminus D$ such that $f(x)\neq g(x)$. Then there exist open nbhds of $N_1$ of $f(x)$ and $N_2$ of $g(x)$ with $N_1\cap N_2=\varnothing$. By continuity, $M_1=f^{-1}(N_1)$ and $g^{-1}(N_2)=M_2$ are open. Then so is $M=M_1\cap M_2\neq \varnothing$ since $x\in M$. Thus, there exists $y\in M\cap D$, and $f(y)=g(y)$. But this is impossible, since this gives $f(y)\in f(M)\subset ff^{-1}(N_1)\subset N_1$ and $g(y)\in g(M)\subset gg^{-1}(N_2)\subseteq N_2$.


Following Daniel Fischer's suggestion:

Suppose that $E$ is a connected subspace of $X$ and $E \subseteq K \subseteq \overline E$.

Consider $K$ as a subspace of $X$. Then $E$ is a dense, connected subspace of $K$.

Let $C$ and $D$ be open sets in $K$ that separate $K$.

Then $C$ and $D$ are nonempty, and thus each must contain an element of $E$, so $C\cap E$ and $D \cap E$ separate $E$.


Suppose that $X$ is a space and $E\subset X$ is a connected subset.

Let $A$ be a clopen subset of $\overline E$ such that $A\cap\overline E\not=\emptyset$.

Since $A$ is open in $\overline E$, $A\cap E\not=\emptyset$.

Note that $A\cap E$ is nonempty and clopen in $E$.

Since $E$ is connected, $E=A\cap E\subset A$.

Since $A$ is closed in $\overline E$, $\overline E\subset A$.

So $A=\overline E$, showing $\overline E$ to be connected.