# 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. Apr 9, 2014 at 23:27

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? Jul 18, 2014 at 16:24
• It's been a while since I've done surjectivity proofs, but that looks fine. Jul 18, 2014 at 16:26

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...

• "That is to say, each element in the codomain is the image of exactly one element in the domain." This is false in general for injective functions. It is possible there exists an element in the codomain which has no element in the domain being mapped to it. Though, it's true if $f:A \to B$ is an injection and $b \in B$ is the image of some element $a \in A$, then $b$ is not the image of any other element in $A$. Possible revision: "Each element in the codomain is the image of at most one element in the domain." This allows for the possibility of elements in the codomain having no preimage.
– john
Nov 3, 2019 at 4:42
• Also the placement of 'if and only if' in your definition of injection seems out of place. Better: $f: A \to B$ is injective if and only if for all $x,y \in A$, $f(x)=f(y)$ implies $x=y$.
– john
Nov 3, 2019 at 4:49

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$.