Image of a connected space under a continuous map is connected, proof In Munkres' Topology there is a theorem which states that the image of a connected space under a continuous map is connected.
In the proof of this, they let $f: X \rightarrow Y$ be continuous, where $X$ is connected, and prove that $Z = f(X)$ is connected. It says that since the restricted map to $Z$ is also continuous, it suffices to consider $g: X \rightarrow Z$. Supposing that $Z = A \cup B$ is a separation, then $g^{-1}(A)$ and $g^{-1}(B)$ are disjoint nonempty open sets whose union is $X$. And then they form a separation of $X$ which is contradicting the fact that $X$ is connected.
So here is my question: The reason we know that $g^{-1}(A)$ and $g^{-1}(B)$ are nonempty is because $g$ is a surjection (according to the book). But how do we know for sure that $g$ is a surjection? We are told that $f$ is continuous and that $g$ is a restriction to $Z$, but what if $f$ is injective, couldn't $g$ be injective as well? 
 A: To say that $Z=f(X)$ means that $Z = \{f(x) \,|\, x \in X\}$. The restriction of the function $f : X \to Y$ to the subset $Z \subset Y$ is the function $g : X \to Z$ defined by $g(x)=f(x)$ for all $x \in X$ (sometimes this is called a "range restriction", as opposed to the usual notion of restriction which might be called a "domain restriction").
If we take any element $z \in Z$, then applying the definition of $Z$ we have $z=f(x)$ for some $x \in X$, and then applying the definition of $g$ we have $z=g(x)$. In other words, for each $z \in Z$ there exists $x \in X$ such that $g(x)=z$. This is exactly what it means for the function $g$ to be surjective.
By the way, $g$ might well be injective, but you asked about surjectivity which is different than (and logically independent from) injectivity.
A: Usually when we speak of restricting a function, we mean taking a subset of the domain of a function. I do not know what you call it when you change the target (codomain) of funtion to the image of the function.
In any case, if you change the target of a function to its image, then the new function (sure looks like the old one) will always be surjective.
So your function is surjective onto its image (with subspace topology) by definition. Of course it could be injective as well, but that does not change the claim that connected sets go to connected sets.
A: $g^{-1}(A)$ and $g^{-1}(B)$ are disjoint because $A$ and $B$ are disjoint.
