# Does this injective function have an inverse?

Suppose that $$f: A \to B$$ is injective, $$A = \{5, 7\}, B = \{9, 10\}$$ and $$f(5) = 9$$, $$f(7) = 10$$.

Now construct $$g: B \to A | g(9) = 7, g(10) = 5$$.

Does this function $$f$$ have a left inverse $$g$$, i.e. $$g(f(a)) = a$$ for all $$a \in A$$?

• How can $f(5) = 9$ be if $9 \notin B$? Or $f(7) = 10$ if $7 \notin A$? – Martin R Feb 10 at 17:47
• You have confused notation here. In your definition $f$ is not $A \rightarrow B$. – Alvis Nordkovich Feb 10 at 17:48
• @MartinR please see edit. – Jossie Calderon Feb 10 at 18:03
• @Alvis see edit. – Jossie Calderon Feb 10 at 18:03
• $g(f(5)) = g(9) = 7 \ne 5$ and $g(f(7)) = g(10) = 5 \ne 7$ – lightxbulb Feb 10 at 18:06

The function $$g(9) = 7, g(10) = 5$$ is not an inverse to $$f$$, as you can easily verify by computing $$g(f(5)) = g(9) = 7 \ne 5$$. On the other hand both $$g$$ and $$f$$ are bijections so they have well-defined inverses: $$f^{-1}(9) = 5, f^{-1}(10) = 7$$ $$g^{-1}(7) = 9, g^{-1}(5) = 10$$ If you want to construct an inverse to a discrete injective function $$h:C\rightarrow D$$ then $$\forall c \in C : h(c) = d \in D$$ define $$h^{-1}(d) = c$$. Then by construction the function $$h^{-1}$$ satisfies $$h^{-1}(d) = h^{-1}(h(c)) = c$$.

• My error was in thinking that it was necessary for f to have a left inverse. – Jossie Calderon Feb 10 at 18:58
• but why does f need to be one to one for it to hold true? – Jossie Calderon Feb 10 at 19:15
• would this suffice? let f: A-> B, and a in A. Then f(a) = b in B. Let g: B-> A s.t. g(b) = f^-1(b). If f^-1(b) =/= a then two elements exist in the fiber of B, but that violates the claim that f is injective. Thus f has a left inverse. – Jossie Calderon Feb 10 at 19:21
• @JossieCalderon Well you have an inverse precisely because of the injectivity yes. If you want an example specific to right-left inverse: math.stackexchange.com/questions/507279/… Suppose that a function is not injective. That is you have $a_1,a_2 \in A$ such that $a_1\ne a_2$ but $f(a_1) = f(a_2) = b \in B$. Then you can't have an inverse function of this form, since it will violate the definition of function. However the inverse set mapping always exists (the set $f^{-1}(b) = \{a_1,a_2\}$, however that's a set and not a function anymore). – lightxbulb Feb 10 at 19:25

Your question caused a lot of confusion. So let us prove the following which is probably that what you really mean:

A function $$f : A \to B$$ is injective if and only if it has a left inverse $$g : B \to A$$. Here, $$A,B$$ are any two sets.

1) Let $$f$$ be injective. Choose any $$a_0 \in A$$ and define $$g : B \to A, g(b) = \begin{cases} a & b = f(a) \in f(A) \\ a_0 & b \in B \setminus f(A) \end{cases}$$ Note that by injectivity of $$f$$ for each $$b \in f(A)$$ there exists a unique $$a \in A$$ such that $$b = f(a)$$. By definition $$(g \circ f)(a) = g(f(a)) = a$$.

2) Let $$g$$ be a left inverse for $$f$$. If $$f(a) = f(a')$$, then $$a = g(f(a)) = g(f(a')) = a'$$. This means that $$f$$ is injective.