Let $G$ be a semigroup and for each $x \in G$ there exists a unique element $y \in G$ such that $xyx = x$. Prove that $G$ is a group.
Since G is a semigroup the properties of a closure and associativity hold, so all we need to prove is the existence of a unique identity and inverse for each element. For identity, since $xyx = x$ can we say that $yx = e$ and $xy = e$ and since $x \in G$ and $y \in G$ therefore $yx \in G$ and $xy \in G$ and hence $e \in G$. This proves that identity exists.
Again, for inverse, $yx = e$ and $xy = e$ proves that $y = x^{-1}$.
Therefore $G$ is a group. Can someone please tell me if my approach is correct.
Thanks in advance!