Functions such that $f(g(x)) = x$ but $g(f(x)) \neq x $ I want to find functions  $f: A \to B$ and $g: B \to A$ such that $g(f) = i_A$ but $f(g) \neq i_B$. 
Is this possible? An exercise for one of my classes is to actually prove that if $g(f) = i_A$, then $f(g) = i_B$. 
I've found functions where $f(g(x)) = x$ for most $x$, but failed for an exceptional choice of $x$. Would that be a counter example? 
Are there examples where $g(f(x)) = x$ for all $x \in A$ and $f(g(x)) \neq x$ for all $x \in B$?

If your counterexample satisfies what you claim it does, it is a valid counterexample. Either there is a mistake in your exercise, or there is some condition that you've forgotten to tell us [e.g. $A$ and $B$ are finite sets of same cardinality].
As long as $A$ and $B$ are both non-empty, there are no functions so that $g(f(a)) = a$ and $f(g(b)) \ne b$ for all $a \in A, b \in B$. This can be seem by choosing an arbitrary $a \in A$ and setting $b = f(a)$. Then $f(g(b)) = f(g(f(a)) = f(a) = b$.
