I'm trying to prove the following claim.
Let $S$ be a nonempty finite set, equipped with an associative operation $*: S \times S \to S$ such that, for every $x,y \in S$, there exists $z \in S$ such that $x * z = y$, and there exists $z' \in S$ (possibly different from $z$) such that $z' * x = y$. Show that $(S, *)$ is a group.
By definition, $*$ is closed and associative, so I only need to check that there exists an identity element and that $S$ contains inverses. I'm a bit stumped on how to do this.
Identity. Fix $a \in S$. I need to show that there exists $e \in S$ such that $a * e = a = e * a$. One possibility is to try to "create" this element $e$. I can apply the first given fact with $x = y = a$ to find a $z \in S$ such that $a * z = a$ and then the second given fact with $x = y = a$ to find a $z' \in S$ such that $z' * a = a$. I therefore have $$ a * z = a = z' * a. $$ These elements $z$ and $z'$ are secretly the identity element, but I don't know how to show that because the order of quantifiers is wrong. I want to show $$ \exists e \in S, \; \forall a \in S, \; a*e = e*a = a $$ but instead I've shown $$ \forall a \in S, \; \exists e \in S, \; a*e = e*a = a. $$ I haven't shown either that (1) $z =z'$ or (2) that this common element works for every $a \in S$.
Inverses. I surely have to establish the existence of an identity first. Suppose that I have one, $e$, with $a*e = a = e*a$. Then I can find, by the first given with $x = a$ and $y = e$, some $z$ such that $a * z = e$ and, using the second given with $x = a$ and $y = e$, some $z' \in S$ such that $z' * a = e$. Then $z,z'$ are secretely $a^{-1}$, but I again haven't shown that they're equal. In this case, I believe it suffices to show that $z = z'$. I can find an element, say $t$, such that $z*t = z'$ and an element $t''$ such that $z'*t' = t$ (or similarly by multiplying $z$ and $z'$ on the left), and $t$ and $t'$ are secretely $e$, but I can't figure out how to show this.
Any help on how to proceed would be greatly appreciated.