Group identities and inverses A set is a set. A magma is a set with a binary operator. A semigroup is a magma with an associative binary operator. A monoid has a two-sided identity. And a group has two-sided inverses.
I am wondering about one-sided verses two-sided. Under what conditions is an identity element necessarily two-sided? Under what conditions is an inverse necessarily two-sided? And what are the simplest proofs for these?

Theorems I have so far:


*

*A magma may have multiple distinct left-identities or multiple distinct right-identities, but can never have a distinct left and right identity. [1: $\forall x. lx=x$. 2: $\forall x. xr=x$. 1 implies that $lr=r$ while 2 implies that $lr=l$. So either $l=r$ or at least one of 1 or 2 is false.]

*Associativity plus the existence of a two-sided inverse is enough to imply that any inverse is two-sided. [If $y$ is the left-inverse of $x$ then $xyx = x(yx)=xi=x$. By associativity, $xyx=(xy)x=x$, which implies that $xy=i$. In other words, $y$ is also the right-inverse of $x$.]
I have a feeling that an associative magma cannot have one-sided identities - but I cannot prove this.

Cancellativity is a strong condition which implies that one-sided identities and inverses are two-sided in semigroups. Let $S$ be a semigroup. We say $S$ is cancellative when $$\begin{eqnarray}ac=bc\implies a=b,\\ca=cb\implies a=b.\end{eqnarray}$$
We say $e\in S$ is idempotent when $e^2=e.$ Let $S$ be a cancellative semigroup.
Fact 1. Let $e\in S$ be idempotent. Then $e$ is a two-sided identity element.
Proof. $ex=e^2x$ and so by cancellativity $x=ex.$ Analogously $x=xe.$
Fact 2. Let $e\in S$ be a two-sided identity element. Any left or right inverse with respect to $e$ in $S$ is a two-sided inverse.
Proof. Let $xy=e.$ Then $xyx=ex=x=xe,$ and so by cancellativity $yx=e.$
Fact 3. Let $e\in S$ be such an element that there exists $x\in S$ such that $ex=x$ or $xe=x.$ Then $e$ is a two-sided identity element in $S.$
Proof. Suppose $ex=x.$ For any $y\in S,$ we have $yx=yex,$ whence by cancellativity $y=ye.$ Therefore $e$ is a right identity element. But then $e=e^2$ so $e$ is idempotent. Thus $e$ is a two-sided identity element. It works analogously for the assumption that $xe=x.$
Note that Fact 3. is much stronger than the statement that one-sided identity elements are automatically two-sided.
In fact, when $S$ is finite, we can prove that it's a actually a group. 
Proof. Let $S=\{x_1,\ldots,x_n\}$ and $x\in S.$ Let $L=\{xx_1,\ldots,xx_n\}.$ Then it is easy to see that cancellativity implies $$S=L.$$
Therefore there is $i$ such that $x=xx_i.$ From Fact 3. it follows that $x_i$ is a two-sided identity element in $S$. But also, there must be $j$ such that $x_i=xx_j.$ Therefore $x$ has a right inverse. But then it must also be a left-inverse by Fact 2. Therefore $S$ is a group. 
$(\{0,1,2,\ldots\},+)$ is an example of a cancellative monoid which isn't a group. The identity element is $0$ and it's two-sided as the facts above require, but there are no units (invertible elements) except $0.$
