Counterexample: $g \circ f $ is the identity function, then $g$ is the inverse function for $f$

1.7k Views Asked by At

I have just proved the following:

$f: X \to Y$ and $g: Y \to X$, also $g \circ f = f \circ g$ is the identity function, then $g$ is the inverse function for $f$.

I am trying to see that in the theorem above just "$g \circ f $ is the identity function" or "$f \circ g$ is the identity function" is not enough.

So am looking for examples of $X,Y,g,f$ such that only one equality is true, and $g$ is not the inverse function for $f$.

What I found so far is: $X = \{x^*\}$, $Y$ is a set such that $|Y| >1$, $f(x^*)=y^*$ and $g(y)=x^*, \forall y \in Y$, then $g \circ f$ is the identity function, $f \circ g$ is not the identity function and $f$ does not have an inverse function.

I am looking for an example (if any exists) such that $X =Y$.

Edit

In my example $f$ does not have the inverse function at all, so also would be good to find an example (where possibly $X \ne Y$) $f$ has an inverse but it is not $g$.

3

There are 3 best solutions below

2
On BEST ANSWER

For an example in which $X=Y$, we can take $X=Y=\mathbb{N}$, $f:\mathbb{N}\to\mathbb{N}$ defined by $f(n)=n+1$ and $g:\mathbb{N}\to\mathbb{N}$ defined by $$g(n)=\begin{cases}n-1 &\text{if $n\neq 0$}\\ 0 & \text{if $n=0$}\end{cases}$$

This function satisfies that $g\circ f=id_{\mathbb{N}}$, but $f$ neither $f$ nor $g$ are invertible since $f$ is not surjective and $g$ is not injective.

Now, if $X=Y$, $g\circ f=id$ and $f$ is surjective, then $f$ is bijective and you will necessarily have that $g=f^{-1}$.

0
On

Hint

Start with $X = Y =$ the natural numbers, and the function $x \mapsto x + 1$.

0
On

Consider $X = Y = \mathbb Z$ and define $f\colon \mathbb Z \to \mathbb Z$ by $f(n) = 2n$ and define $g\colon \mathbb Z \to \mathbb Z$ by: $$ g(m) = \begin{cases} m/2 &\text{if $m$ is even} \\ 42 &\text{if $m$ is odd} \end{cases} $$ Then observe that $g \circ f = \text{id}_\mathbb Z$, since for any $n \in \mathbb Z$: $$ g(f(n)) = g(2n) = n $$ However, $f \circ g \neq \text{id}_\mathbb Z$, since for example: $$ f(g(7)) = f(42) = 84 \neq 7 $$