# Proving functions are injective and surjective

I am having trouble with the following problem:

For nonempty sets $A$ and $B$ and functions $f:A \rightarrow B$ and $g:B \rightarrow A$ suppose that $g\circ f=i_A$, the identity function of $A$. Prove that $f$ is injective and $g$ is surjective.

Work: Since $g\circ f=i_A$, then $g\circ f:A\rightarrow A$.

After this point, I don't know how to proceed.

• That's not much work. What is the definiton of injective and surjective? Then the solution is very simple. – mathse Apr 9 '14 at 23:27

Well as a start, look to the definitions of injective and surjective.

Then from there you may have a see how to prove it, when you see what it is exactly that you are supposed to show.

So, for injective, f : A $\rightarrow$ B is injective if, for x, y $\in$ A, $$f(x) = f(y)$$ if and only if $$x = y$$

That is to say, each element in the codomain is the image of exactly one element in the domain.

Then, f : A $\rightarrow$ B is surjective if, for each z $\in$ B, $$z = f(x)$$ for some x $\in$ A.

That is to say, each element of the codomain is the image of some element in the domain.

Then apply the extra information that you have a see where you can get...

Claim. $f: A \to B$ is injective.

Assume for $a, b \in A$ that $f(b) = f(a)$. Then, $g(f(b)) = g(f(a))$, which implies that $(g \circ f)(b) = (g \circ f)(a)$, or $b = a$ by the definition of the identity function. Hence, $f$ is injective.

I'll have you try the other one.

• For the other one...$a\in A \Rightarrow g \circ f(a)=g(f(a))=g(b)=a$. Therefore, this means that for any $a\in A$, there is a $b$ such that $g(b)=a$. Hence, $g$ is surjective. Is this correct? – mauna Jul 18 '14 at 16:24
• It's been a while since I've done surjectivity proofs, but that looks fine. – Clarinetist Jul 18 '14 at 16:26

If $f$ weren't injective then $f(x_1)= f(x_2)$ for some $x_1\neq x_2$ in $A$.

So that $x_1=g\circ f\;(x_1)=g\circ f\;(x_2)=x_2$, since $g\circ f$ is the identity function on $A$.

Similarly, if $g$ weren't surjective then for some $a\in A$ there is no $b\in B$ such that $g(b)=a$. But $g\circ f\;(a)=a$.