**Theorem:**

**A metric space (X, d) is connected iff every continuous function \( f:X\to {\lbrace 0, 1\rbrace} \) is constant.**

**Proof**:

Let (X, d) be a connected metric space and suppose that there exists a continuous function \( f:X\to {\lbrace0, 1\rbrace} \).

__Claim__: f is constant.

Since, \( {\lbrace0, 1\rbrace} \) is finite w.r.t. usual metric, set \( {\lbrace 0\rbrace} \) and\( \lbrace 1 \rbrace \)are open and closed subsets of \( \lbrace 0, 1 \rbrace \),

\( \therefore f^{-1}\lbrace 0 \rbrace \) and \( f^{-1}\lbrace 1 \rbrace \) both are open and closed subset of X. (\( \because \) f is continuous)

\( f^{-1}{\lbrace 0 \rbrace} \cup f^{-1}{\lbrace 1\rbrace}=X \) and \( f^{-1}{\lbrace 0 \rbrace} \cap f^{-1}{\lbrace 1\rbrace}=\phi \).

Thus, X is union of disjoint sets.

But, by hypothesis,

X is connected and hence, either \( f^{-1}\lbrace 0 \rbrace=\phi \) or \( f^{-1}\lbrace 1 \rbrace=\phi \).

WLOG,

Suppose, \( f^{-1}\lbrace 0 \rbrace=\phi \).

\( \therefore f^{-1}\lbrace 1 \rbrace=X \)

\( \therefore f(X)=1 \)

i.e. f is constant.

Conversely,

Suppose that every continuous function \( f:X\to {\lbrace0, 1\rbrace} \) is constant.

__Claim__: Metric space (X, d) is connected.

Since, \( f:X\to {\lbrace0, 1\rbrace} \) is constant function,

either \( f(X)=\lbrace 0 \rbrace \) or \( f(X)=\lbrace 1 \rbrace \).

WLOG, suppose that .

Since, \( \lbrace 1 \rbrace \) is closed as well as open subset of \( {\lbrace0, 1\rbrace} \) w.r.t. usual metric and f is continuous function, \( f^{-1}\lbrace 1 \rbrace \) is closed as well as open.

But \( f^{-1}\lbrace 1 \rbrace=X \).

\( \therefore \) X is only nonempty set which is both open as well as closed in X.

\( \therefore \) X is connected.