Let $\mathbb{Z} \subset \mathbb{R}$ with the discrete topology prove that $X$ is connected if and only if $f: X \rightarrow \mathbb{Z}$ is constant

connectednessgeneral-topologysolution-verification

Let $\mathbb{Z} \subset \mathbb{R}$ with the discrete topology prove that $X$ is connected if and only if for every continuous function $f: X \rightarrow \mathbb{Z}$ is constant function.

Attempt

Suppose that $X$ is connected and consider an arbitrary continuous function $f: X \rightarrow \mathbb{Z}$
since $X$ is connected then $f(X)\subset \mathbb{Z}$ is connected, and $f(X)$ is an open set since we be considering the discrete topology, that is $f(X) \subset \mathbb{Z}$ is open in the subespace topology
if for any $x\in X$ $f(x)=\mathbb{Z} \cap \mathbb{R}$for all $x\in X$.This is $f$ is a constant function.

Conversely assume that for every continuous function $f:X \rightarrow \mathbb{Z}$ is constant we should prove that $X$ is connected.

Assume that $X$ is not conected, then Exists $U,V\subset X$ such that $U,V \neq \emptyset$ and $U \cup V=X$,but $U \cap V = \emptyset$ then consider the function
$h_1:U \rightarrow \mathbb{Z}$ given by $h_1(x)=1$ which is continuous function.
And consider $h_2:V \rightarrow \mathbb{Z}$ given by $h_2(x)=0$ which is continuous function.
Notice that $U\cap V= \emptyset$ implies that $h_1$ and $h_2$ are equal in their points of intersections.
Consider $h:U \cup V=X \rightarrow \mathbb{Z}$ given by
$$h(x)=\begin{cases}
h_1(x) if\, x\in U&\\
h_2(x)if\, x\in V
\end{cases}$$

Which is non constant continuous function then not every continuous function $f:X \rightarrow \mathbb{Z}$ is constant which is a contradiction, then $X$ is connected.
Is my proof right?

Best Answer

For the first part of the proof the fact that $f[X]$ is open in $\Bbb Z$ is irrelevant: all that matters is that the only non-empty, connected subsets of $\Bbb Z$ are the singletons.

The other direction is fine, though it can be done more simply without the pasting lemma. Just prove the contrapositive. If $X$ is not connected, there is a continuous function $f$ mapping $X$ onto the discrete two-point space $\{0,1\}$. Clearly this $f$ can be viewed as a continuous function from $X$ to $\Bbb Z$, and it is not constant.