When does a semigroup homomorphism preserve identities on monoids

abstract-algebraformal-languagesmonoidsemigroup-homomorphismsemigroups

Let $X,Y$ be monoids, with identities $e_X,e_Y$, respectively. Let $f:X\to Y$ be a semigroup homomorphism. That is, any function which satisfies
$$f(xy)=f(x)f(y)\quad\forall x,y \in X\tag{1}$$

I know that $f$ is not necessarily a monoid homomorphism, where the definition of a monoid homomorphism is the same as a semigroup homomorphism, but with the additional requirement that it preserve identities:
$$f(e_X)=e_Y\tag{2}$$
This second property is required [see, e.g., the discussion in a number of other math.SE threads, such as this one or this one for examples where $(1)$ holds but $(2)$ does not.]

The reason I'm interested: In formal language theory, one deals with the set of all finite strings over some alphabet, which forms a monoid under concatenation, with the empty string being the identity (the "free monoid"). In this area, it is common to state that the identity-preserving property $(2)$ can be derived from the semigroup homomorphism property $(1)$ (see for example Kozen 1997, Lecture 10, or Kurz's lecture notes, Lecture 7). I know this must be due to something about the structure of this kind of monoid, since it isn't true in general.

My question is: what must be true about monoids $X$ and $Y$ such that all semigroup homomorphisms mapping $X$ to $Y$ preserve the identity (and as such are monoid homomorphisms)?

Best Answer

We claim that all semigroup homomorphisms mapping $X$ to $Y$ preserve the identity if and only if $Y$ has exactly one element satisfying $y^{2} = y$ (which has to be $e_{Y}$).

Suppose $Y$ has only one solution to $y^{2} = y$ (which has to be $e_{Y}$). Note that $f(e_{X})f(e_{X}) = f(e_{X}e_{X}) = f(e_{X})$, so we must have $f(e_{X}) = e_{Y}$. This proves one direction.

For the other direction, suppose $Y$ contains an element $y$ such that $y^{2} = y$ but $y \neq e_{Y}$. Then $f \colon X \to Y$ sending all of $X$ to $y$ is a semigroup homomorphism, because for all $x _{1}, x_{2} \in X$ we have $f(x_{1})f(x_{2}) = y^{2} = y = f(x_{1}x_{2})$. This semigroup homomorphism $f$ does not send $e_{X}$ to $e_{Y}$. This proves the other direction.