I have been given the problem: "Say $$f:X→Y$$ and $$g:Y→Z$$are functions so that $$g◦f:X→Z$$ is bijective and $f$ is surjective. Can you deduce that $g$ is bijective?
My proof went as follows, I am not sure if this is valid?
Since $f$ is surjective then for any $y\in Y$ there exists and $x \in X$ such that $$f(x)=y$$ and $gf$ is bijective so it is surjective and injective so holds for: $$g(f(x))=z$$for any $x$ and $$gf(x_1)=g(f(x_2)) \Rightarrow x_1=x_2$$
Then since we know $gf$ is surjective so $gf(x)=z$, since $f(x)=y$, then $g(y)=z$, so for any $z \in Z$ there exists $y \in Y$ such that $g(y)=z$, so $g$ is surjective.
Finally we say $$x_1=x_2$$ and call $h=gf$. Since $h$ is injective and surjective $$h(x_1)=h(x_2), g(f(x_1))=g(f(x_2))$$. Since we know that $f$ is surjective so $f(x)=y$ then $g(y_1)=g(y_2)$ so it is injective. Then since we have proven $g$ is both injective and surjective then it is bijective.