TITLE: What's the cokernel of a monoid homomorphism?
QUESTION [8 upvotes]: Let $f:A\to B$ be a monoid homomorphism. Where can I find an explicit description of the its cokernel? Are there any books on this topic?
By the cokernel of $f$, I mean the universal arrow which postcomposes with $f$ to give the trivial homomorphism. (Sorry for not including this from the start, I just thought there's no risk of ambiguity.)
If anyone cares, here's my motivation. In the category of groups, the cokernel of the kernel of a group homomorphism $f$ is the quotient of the domain by the kernel, which is comprised of the cosets of the kernel. The first isomorphism theorem says this quotient is isomorphic to the image. This makes sense because the multiplicative kernel action has strongly connected components (because of the existence of inverses), so the cosets of the kernel are the fibers.
For monoids there's no first isomorphism theorem because the kernel is largely uninformative. However, some monoid epimorphisms are known to be the cokernels of their kernels (namely Schreier split monoid epimorphisms), and I would like to see what this means concretely.

REPLY [5 votes]: First of all, the construction is as for all (pointed) algebraic structures. Let $\sim$ be the congruence relation generated by $f(a) \sim 1$ for $a \in A$. Here, congruence relation means an equivalence relation on the underlying set of $B$ satisfying $b \sim b' \Rightarrow x b \sim x b' \wedge  b x \sim b' x$ for all $b,b',x \in B$. Then $\mathrm{coker}(f)$ is the quotient monoid $B/{\sim}$, i.e. the set of equivalene classes of $\sim$ equipped with the monoid structure which is uniquely determined by the property that $B \to B/{\sim}$, $b \mapsto [b]$ is a homomorphism.
It remains to give an explicit description of $\sim$. In the commutative case (more generally, when $f:A \to B$ is central), we have the following:
$b \sim b' \Longleftrightarrow \exists a,a' \in A ( f(a) b = f(a') b')$
In the non-commutative case, the description is much more complicated. You basically have to work with chains of relations and longer products as in the general description of generated congruences. More explicitly, $\sim$ is the transitive closure of the following relation:
$b \approx b' \Longleftrightarrow \exists n \in \mathbb{N} \, \exists a_i,a'_i,c_i,c'_i \in A \, \exists b_i,b'_i \in B: \\ b = b_1 f(a_1) \dotsc b_n f(a_n), ~  b' = b'_1 f(a'_1) \dotsc b'_n f(a'_n),\\ b_1 f(c_1) \dotsc b_n f(c_n) = b'_1 f(c'_1) \dotsc b'_n f(c'_n).$
That being said, it should be pretty clear that you are lost when you want (or have) to use elements instead of the universal property.
Let me mention that the Grothendieck group resp. the universal enveloping group (this is what it's sometimes called in the non-commutative case) of a monoid $A$ is just the cokernel of the diagonal $A \to A \times A$.