Not quite isomorphisms? Sorry, I'm back with the elementary questions. I've been reading up on the introduction to category theory, and paused over the definition of an isomorphism:
An isomorphism in a category is a morphism $f \colon X \rightarrow Y$ for which
there exists a morphism $g \colon Y \rightarrow X$ so that $g f = 1_X$ and $f g = 1_Y$.
However, knowing the congenital sneakiness of mathematicians, presumably there are cases where only 'one side' is true, eg. $g f = 1_X \wedge f g \neq 1_Y$? Or maybe put better, $g f = 1_X$ does not imply $f g = 1_Y$?
 A: Yes. Suppose that we are working in the category of sets and that the morphisms are the functions. Consider a set $X$ with a single element $a$ and a set $Y$ with more than one element, one of which is $a$. Define $f\colon X\longrightarrow Y$ by $f(a)=a$ and let $g\colon Y\longrightarrow X$ be the constant function $a$. Then $g\circ f=1_X$, but $f\circ g\neq1_Y$.
A: You are absolutely right, such pairs $f, g$ do indeed exist.
As a particular example, take $f, g : \mathbb N \rightarrow \mathbb N$ (in the category Set of sets and functions), defined by
$$f(n) = n+1$$
$$g(n) = \begin{cases}
0 \,\, \text{if} \,\,n=0 \\
n-1 \,\, \text{otherwise}
\end{cases}$$
Then,
$$(g \circ f)(n) = g(f(n)) = n = \operatorname{id}_{\mathbb N}(n)$$
but
$$(f\circ g)(n) = \begin{cases}
1 \,\, \text{if} \,\,n=0 \\
n \,\, \text{otherwise}
\end{cases}$$
which is clearly ${\color{red}\neq}\operatorname{id}_{\mathbb N}(n)$
A: If $f:X\to Y$ and $g:Y\to X$ are morphisms such that $f\circ g=\text{id}_Y$, then we call $g$ a section of $f$ and $f$ a retraction of $g$.
A standard case is sections of a vector bundle $(E,B,\pi)$ where $\pi:E\to B$ is the projection map, and a section is a map $s:B\to E$ such that $\pi\circ s=\text{id}_B$.
A: A more illuminating definition of $X\xrightarrow{f}Y$ being an isomorphism is that it has both a right inverse and a left inverse.
Definition. Given a morphism $X\xrightarrow{f}Y$, we say a morphism $X\xleftarrow{f^{-1}}Y$ is a right inverse (also called a section) of $X\xrightarrow{f}Y$ if $f\circ f^{-1}=\mathrm{id}_Y$. Similarly, we say $X\xleftarrow{{}^{-1}}Y$ is a left inverse (also called a retraction) of $X\xrightarrow{f}Y$ if ${}^{-1}f\circ f=\mathrm{id}_X$. A morphism $X\xrightarrow{f}Y$ is an isomorphism if it has both a left inverse and a right inverse.
Example 1. Most functions labeled inverses in basic mathematics are actually right inverses: $\mathbb R_{\geq0}\xrightarrow{\sqrt(x)}\mathbb R$ is a right inverse of $\mathbb R\xrightarrow{x^2}\mathbb R_{\geq0}$ because $(\sqrt{x})^2=x$, $(-1,1)\xrightarrow{\arcsin(x)}\mathbb R$ is a right inverse of $\mathbb R\xrightarrow{\sin(x)}(-1,1)$ because $\sin(\arcsin(x))=x$. These right inverses are also not unique: we also have $(-\sqrt{x})^2=x$, $\sin(\pi-\arcsin(x))=x$, and $\sin(\arcsin(x)+2\pi)=x$.
Lemma. If $X\xrightarrow{f}Y$ has both a left and a right inverse (i.e. if it is an isomorphism), then the two inverses coincide, i.e. $f^{-1}={}^{-1}f$. In particular, if $X\xrightarrow{f}Y$ is an isomorphism, it has a unique left inverse and a unique right inverse, these coincide, and are themselves an isomorphism.
Example 2. Since $\mathbb R\xrightarrow{x^2}\mathbb R_{\geq0}$ has multiple distinct right inverses, it is not an isomorphism. Consequently, its right inverse $\mathbb R\xleftarrow{\sqrt x}\mathbb R_{\geq0}$ is also not an isomorphism.
Remark. For general categories it is not enough for a morphism $X\xrightarrow{f}Y$ to have a unique right or left inverse for it to be an isomorphism, but in some categories (like the category of sets, and I think the category of vector spaces) this suffices.
