I am trying to understand the proof of the following theorem: If $f:X \rightarrow Y$ is contiuous and let X be a connected space, then f(X) is a connected space.
In the proof, we construct another function $g:X \rightarrow Z$ obtained by restraigning X. Then, we show that if $Z$ is not connected, then X is not connected.
What I don't understand is why do we construct $g$. My guess is that $f(X) = Z$ but I am not sure about that equality.