TITLE: Injectiveness and surjectiveness of $f$ and of $g$, respectively, of the composition $g\circ f$.
QUESTION [5 upvotes]: a) If $f: E \to F$ and $g: F \to E \ $  are functions such that $g \circ f$ is injective, then $f$ is injective
b) If $f: E \to F$ and $g: F \to E \ $  are functions such that $g \circ f$ is surjective, then $g$ is surjective.

Proof:
a) Assume $g \circ f$ is injective but $f$ is not injective. Then there exist $x_1, x_2 \in E$ such that $x_1 \neq x_2$ but $f(x_1) = f(x_2)$. Then $g(f(x_1)) = g(f(x_2))$. Since $g\circ f$ is injective, $x_1 = x_2$, a contradiction! Therefore $f$ is injective.
b) Assume $g \circ f$ is surjective but $g$ is not surjective. Then there exists $e_1 \in E$ such that $e_1 \neq g(z)$ for all $z \in f$. Since $g\circ f$ is surjective, there exists $x_1 \in E$ such that $g(f(x_1)) = e_1$. But this is a contradiction to the hypothesis that $g$ is not surjective, since $f(x_1) = y_1 \in F$! Therefore $g$ is surjective.
Is everything here correct or did I make a mistake somewhere? If anyone has a cleaner proof I'd appreciate it as well, since I have still not convinced myself of the validity of the one I wrote above.

REPLY [2 votes]: 1) Injectivity has been dealt with.
2) Surjectivity:
$f: E \rightarrow F$; $g: F \rightarrow E.$
Show that:
If $g \circ f$ is surjective then $g$ is surjective:
$g\circ f$ : $E \rightarrow E.$
Let $e_2 \in E$, then,
since $g \circ f$ surjective, there is an $e_1 \in E$ such that 
$(g\circ f)(e_1)=g(f(e_1))=e_2$, i.e.
there is an element $z= f(e_1) \in F$ with
$g(z)=e_2$, hence surjective.