is the inner map of a surjective composition surjective?

Let $f:X\rightarrow Y$ and $g:Y\rightarrow Z$ and let $g \circ f(x):X \xrightarrow{f} Y \xrightarrow{g} Z$ be surjective. I can prove that $g$ is surjective. However I am unsure which reasoning for $f$ is correct. 1: $f$ is surjective because $g$ is well defined, so in order for $g$ to be well defined ($Y\xrightarrow{g} Z$) the whole domain must be on the image of $f$. 2: I am taking the above notation too literally the map $g$ is only mapping the restricted domain onto $Z$, so $g\circ f: X\xrightarrow{f} Y\xrightarrow{g}Z$ really means $g\circ f: X\xrightarrow{f} f(X)\xrightarrow{g|_{f(X)}}Z$. As a counter example: let $X$, $Y$ and $Z$ be sets. Where $X$ and $Z$ each have 1 element and $Y$ has 2. $X$ is mapped to either of $Y$'s and both of $Y$'s are mapped to $Z$'s. So the composition maps the single $X$ to the only $Z$ element (so both the composition and $g$ are surjective but not $f$).

You mean $Y$ has $2$ elements (you wrote "one"). Yes, it seems your TA has provided you with a counterexample. .. $f$ cannot be surjective when $Y$ has more elements than $X$... yet $g$ and $g\circ f$ will be when $X$ and $Z$ are $1$ element sets...
As an example, consider the notion of vector field.. It is defined as any smooth section of the tangent bundle, $i:M\to TM$ That is, its composition with the projection, $\pi\circ i$ is the identity map $id:M\to M$. Here $\pi$ and $\pi\circ i$ are surjections; but $i$ certainly isn't . ..
Or, better yet, consider the way of writing the restriction of a mapping $g$ as its composition with the inclusion of a proper subset, $i:X\to Y$. .. all we need is that $g (X)=Z$... See the following .
• but could you elaborate on why 1 is wrong? is it just implicit that in $g\circ f: X\xrightarrow{f} Y\xrightarrow{g}Z$ means $g\circ f: X\xrightarrow{f} f(X)\xrightarrow{g|_{f(X)}}Z$? Oct 25 '17 at 13:37