Show that a function is onto or one-to-one If $f\colon X \to Y$ is bijective then there exists $g \colon Y \to X$ such that (i)
$g\circ f = \operatorname{Id}_X$ and (ii) $f\circ g = \operatorname{Id}_Y$.
Conversly show that if (i) is true then $f$ is one to one
and if (ii) is true then $f$ is onto.
I'm struggling to go about solving this. I understand that the identity function is one where when you compose it with anything it doesn't change it.
I've been working along the lines of $g(f(x))=f^{-1}(f(x))$ and therefore $g(x)=f^{-1}(x)$ and so $g\colon Y\to X$?
Any help at all would be appreciated.
 A: Proposition 1: Let $f : X \to Y$ be a function. Then $f$ is injective iff $f$ has a left inverse, that is, there exists a function $g : Y \to X$ such that $g \circ f = Id_{X}$.
You want a proof of the $[\Longleftarrow]$ part.
Proof of the $[\Longleftarrow]$ part: Let $x_1, x_2 \in X$ s.t. $f(x_1) = f(x_2)$. Hence $(g \circ f)(x_1) = g(f(x_1)) = g(f(x_2)) = (g \circ f)(x_2)$. But $g \circ f = Id_X$ therefore $x_1 = x_2$, which shows $f$ is injective. $\blacksquare$
Proposition 2: Let $f:X\to Y$ be a function. Then $f$ is surjective iff $f$ has a right inverse, that is, there exists a function $g:Y \to X$ such that $f \circ g = Id_Y$.
You want a proof of the $[\Longleftarrow]$ part.
Proof of the $[\Longleftarrow]$ part: Let $y \in Y$. Then $(f \circ g)(y) = Id_Y(y) = y$. But $(f \circ g)(y) = f(g(y))$ also, therefore $x:=g(y) \in X$ is an element s.t. $f(x) = y$, which shows $f$ is surjective. $\blacksquare$
Note that these results are very general. Therefore there is not much choice on how to proceed to prove them...
A: If there exists $g:Y\to X$ such that $g\circ f=id_X$ then $f$ is injective because:
$$f(x_1)=f(x_2)\implies x_1=id_X(x_1)=(g\circ f)(x_1)=(g\circ f)(x_2)=id_X(x_2)=x_2.$$
If there exists $g:Y\to X$ such that $f\circ g=id_Y$ then $f$ is surjective because for any $y\in Y$ there exists $x\in X$ such that $f(x)=y.$ Indeed, $x=g(y):$ 
$$y=id_Y(y)=(f\circ g)(y)=f(g(y)).$$
