TITLE: A semigroup $X$ is a group iff for every $g\in X$, $\exists! x\in X$ such that $gxg = g$
QUESTION [100 upvotes]: The following could have shown up as an exercise in a basic Abstract Algebra text, and if anyone can give me a reference, I will be most grateful.
Consider a set $X$ with an associative law of composition, not known to have an identity or inverses. Suppose that for every $g\in X$, there is a unique $x\in X$ with $gxg=g$. Show that $X$ is a group.
Note that I’m not asking for a proof (though a really short one would please me!), just some place where this has been published.

REPLY [23 votes]: I am just putting some sources here. Bill Dubuque already did all the work:
This book may be of some interest: Mark V. Lawson, Inverse Semigroups: The Theory of Partial Symmetries, at Google Books
I came across this book in this Wikipedia article, which gives some of the history of Inverse Semigroups.
Also, there is this shorter PDF by the author of the book whose link I gave above, and what you state is probably Proposition 2.4 in the notes (although it is stated in a different way) after some other things have already been proved.