# Right inverse implies surjective function

Hi I am trying to formulate a proof for this proposition:

Let $$A$$ and $$B$$ be sets and $$f$$ a map such that $$f:A \to B$$

$$f$$ has a right inverse $$\implies$$ $$f$$ is surjective

Proof(Attempt)

The statement $$f$$ has a right inverse $$\implies$$ $$\exists$$ a function $$g:B\to A$$

such that $$f\circ g(b) = id_B$$ $$\forall b \in B$$

I'm concerned about my logic here:

"This statement implies that every element of $$B$$ lies in the pre-image of $$f$$

thus $$f$$ is surjective as $$\forall b \in B$$ $$\exists$$ $$a \in A$$ such that $$f(a) = b$$"

I feel this logic is not water tight and don't know how to formulate it.

Thanks!

Let $$b \in B$$. Our goal is to prove that it has a pre-image under $$f$$. Notice that $$f(g(b)) = b$$, since $$f \circ g = \text{Id}_B$$. Therefore $$g(b)$$ is a pre-image for $$b$$ under $$f$$, because $$f$$ maps $$g(b)$$ to $$b$$.
Let $$A, B, C$$ be sets and $$\;f:A\longrightarrow B$$, $$\;g:B\longrightarrow C$$. Then
• If $$g\circ f$$ is injective, $$f$$ is injective.
• If $$g\circ f$$ is surjective, $$g$$ is surjective.