# proof about connectedness and constant function

#### ianchenmu

##### Member
Let $E∈\mathbb{R}^{n}$ be a non-empty subset. Prove that $E$ is connected if and only if any continuous function $f : E→${$0$, $1$} is constant.

#### Fernando Revilla

##### Well-known member
MHB Math Helper
Let $E∈\mathbb{R}^{n}$ be a non-empty subset. Prove that $E$ is connected if and only if any continuous function $f : E→${$0$, $1$} is constant.
$\Rightarrow)$ Continuous images of connected sets are connected. If $f:E\to \{0,1\}$ is continuous, $f(E)\subset \{0,1\}$ is connected so, $f(E)=\{0\}$ or $f(E)=\{1\}$. This means that $f$ is constant.

$\Leftarrow)$ If $E$ is not connected, there exist non empty open subsets $U,V$ of $E$ (open relative to $E$) such that $U\cap V=\emptyset$ and $U\cup V=E$. Clearly the function $f:E\to \{0,1\}$ defined by $f(U)=\{1\}$ and $f(V)=\{0\}$ is continuous and no constant (contradiction).