\begin{align} f: X \longrightarrow Y \\ g: Y \longrightarrow Z \\ g \circ f: X \longrightarrow Z \tag{is bijective} \end{align} The bijective conditions only applies to $ g \circ f$. I already managed to show that in this case $f$ must be injective too, I did it the following way (maybe you can check if I did it correct):
Suppose: $f$ is not injective, then $x, x' \in X$ such that $f(x)=f(x') , \ x\neq x'$. For the composition this means that $(g \circ f) (x) = (g \circ f)(x') \implies x=x'$ because the composition is by definition a bijection and this statement would lead to a contradiction. Thus $f$ is a injection.
I am content so far with this proof, however if I want to analyze the properties of $f$ whether it's also surjective or not I get stuck.
Question: is $f$ surjective?
I assume that $f$ is also surjective and therefore a bijection. This means that $\forall y \in Y \exists x \in X : f(x)=y$, I also know that the composition is surjective, because it's bijective, this means that $\forall z \in Z \exists x \in X: g(f(x))=z$
So I can say that $g(f(x))=z=g(y)$ Is this a contradiction I should notice here? Because I have read (also from other posts on here) that $f$ must not necessarily be surjective, but I couldn't come up with a complete proof on my own so far.
Edits: Improved formatting as suggested by @Thomas Andrews, corrected a mathematical false statement as suggested by @Michael Albanese