I am taking a first course in Real Analysis and reading Tao's book that spends a lot time on building basic concepts. I would like someone to verify if I am using the definitions correctly and the steps in my proof are okay.
Exercise 3.3.5. Let $f:X\rightarrow y$ and $g:Y \rightarrow Z$ be functions. Show that if $g \circ f$ is injective, then $f$ must be injective. Is it true that $g$ must be injective?
Show that if $g \circ f$ is surjective, then $g$ must be surjective. Is it true that $f$ must also be surjective?
Proof.
(1) Injectivity. Let $x_1,x_2$ be two distinct elements in $X$. $x_1 \ne x_2$. Suppose $f$ is not injective. Assume $x_1 \mapsto y$ and $x_2 \mapsto y$. Because $g$ is well defined, the image of $y$ under $g$ must be unique. Therefore, $g(f(x_1))=g(f(x_2))$. Stringing everything together, we find $x_1 \ne x_2 \implies g(f(x_1))=g(f(x_2))$. This is equivalent to saying that $g \circ f$ is not injective. The injectivity of $f$ is a necessary condition.
$g \circ f$ is injective $\implies$ $f$ is injective.
Asking if $g$ should also be injective is bit more involved. Suppose $f$ is injective. Assume $x_1 \ne x_2$. $x_1 \mapsto y_1$, $x_2 \mapsto y_2$. In order, $g \circ f$ to be injective, we require $g(y_1) \ne g(y_2)$. But, there may be other elements in $Y$, but not in $range(f)$, such that $g$ maps two elements to one in $Z$. So, $g \circ f$ can be injective, without $g$ being injective.
(2) Surjectivity.
Suppose $g \circ f$ is surjective. For all $z \in Z$, there exists atleast one $x \in X$, such that $z =g(f(x))$. $range(g \circ f)=Z$. But, this must necessarily mean, $range(g) = Z$. So, $g$ must be surjective.
Suppose, $f$ sends all elements in $X$ to $S \subset Y$. $f:X \rightarrow S$. And $g$ for instance sends all elements in $S$ to $Z$. $g: S \subset Y \rightarrow Z$. We find that, $\forall z \in Z$, $\exists x \in X$, such that $z=g(f(x))$, yet $f$ is not surjective. So, $g \circ f$ can be surjective, without $f$ being surjective.
No, not in generality. A surjective function $f: X \rightarrow Y$ implies that $Im_f = Y$.
Let us denote $Im_f(X')$ , $X' \subset X$ to be for a function $f:X \rightarrow Y$ to be the set $f(X')$
A composition $g \circ f$ where $g: Y \rightarrow Z$ is surjective $\Rightarrow$ that $Im_g(Im_f(X)) = Z$
But if $im_f(X)$ can be chosen arbitrarily to be a $Y' \subset Y$.
So there is your answer.