# Proof about composed functions (elementary number theory)

Let f : X → Y and g : Y → X be functions and assume $g ◦ f = I_X$. Prove of g is injective then $f ◦ g = I_Y$.

Approach if g is the left inverse of f then there exists $x\in X$ and $y \in Y$ such that $f(x)=y$ and $g(y)=x$.

I am confused about the left inverse of f. How is it possible that the left inverse of f is not its right inverse. If g is not one to one, this would imply that f is not a function or such g doesn't exist. I think that for $g ◦ f = I_X$ to be true g has to be injective.

In my approach, I think that a good start is to say that f(g(y))=y, but how can this be true? or how can this be false?

The key here is the fact that $g$ is injective (this is the crucial point, without that this will not go through).

Assume (i) $g\circ f = I_X$ and (ii) $g$ is injective. We want to establish $f\circ g = I_Y$, i.e. $f\circ g(y) = y$ for all $y\in Y$.

Take any $y\in Y$, and consider $z\stackrel{\rm def}{=} f\circ g(y)\in Y$. We want to show $z=y$, which reminds a lot of what injectivity can help proving -- so let us use the injective function we have by (ii), $g$: $$g(z) = g( f\circ g(y) ) = g\circ f\circ g(y) = (g\circ f)( g(y ) ) = g(y)$$ the last equality by (i).

So $g(z)=g(y)$... but by (ii) we know $g$ is injective, which implies $z=y$.

• woahhh nicee. I understand your proof pretty easy but still can't come up with solutions to these problems. How is the following true $I_x ∘ g(y)=g(y)$ – TheMathNoob May 26 '16 at 6:06
• It is because g(y) is in X, and I_X takes as input an element in X and returns this same element. So I_X (g(y))=g(y) (for any y). – Clement C. May 26 '16 at 6:22
• right.That's clear. I am new in number theory so I am just gonna keep working on it. – TheMathNoob May 26 '16 at 6:28
• No worries -- and yes, I'd say the best approach towards pretty much anything in math is to practice a lot.. making mistakes helps also, quite a bit. – Clement C. May 26 '16 at 6:31

I think that for $g \circ f = I_X$ to be true, $g$ has to be injective.

Not necessarily. For a counterexample, take $X = Y = \mathbb N$ and define $f\colon \mathbb N \to \mathbb N$ and $g\colon \mathbb N \to \mathbb N$ by: $$f(x) = 2x \qquad\text{and}\qquad g(y) = \begin{cases} y/2 &\text{if y is even} \\ 42 &\text{otherwise} \end{cases}$$ Observe that for all $x \in \mathbb N$, we have that $g(f(x)) = g(2x) = x$ so that $g \circ f = I_\mathbb N$. But $g$ is not injective, since for example: $$g(3) = 42 = g(5)$$

Show that if $g \circ f = I_X$ and $g$ is injective, then $f \circ g = I_Y$.

Given any $y \in Y$, we want to show that $f(g(y)) = y$. To this end, choose any $y \in Y$ and let $x = g(y)$. Then since $g \circ f = I_X$, we know that: $$g(f(x)) = x$$ In other words, we know that $g(f(g(y))) = g(y)$. But since $g$ is injective, we conclude that $f(g(y)) = y$, as desired. $~~\blacksquare$

• In your first counterexample, $$g\circ f(-1) = g((-1)^2) = g(1) = 1\neq -1$$ so $g\circ f\neq I_X$. A "correct" counterexample must have $f$ injective, and one can take say $f\colon \mathbb{R}\to (0,1)$ to be a bijection (and then $g$ can be arbitrary on $\mathbb{R}\setminus(0,1)$, even say constant, but $g\mid_{(0,1)}$ a bijection from $(0,1)\to\mathbb{R}$). – Clement C. May 26 '16 at 5:46
• @ClementC. Whoops, you're right. I changed my counterexample. – Adriano May 26 '16 at 5:53

For $g\circ f$ to be the identity, it is required that $f$ be injective and $g$ be surjective (but not necessarily that $g$ be injective or $f$ surjective). Prove this first. Then note that $f\circ g$ being the identity requires $g$ to be injective.