Let $S$ be a semigroup. Then $S$ is a group if and only if

$$aS=S=Sa$$

for all $a\in S$, where $aS=\{ as\in S\mid s\in S\}$ and $Sa=\{ sa\in S\mid s\in S\}$.


A semigroup $S$ is a group if there exists an $e$ in $S$ such that for all $a$ in $S$, $ea=a$ and for all $x$ in $S$ there exists a $y$ in $S$ such that $yx=e$.