This is my first attempt at a formally written proof so I would appreciate any pointers as far as proof-writing technique or the validity of the actual proof itself.
Note: I have not formally taken abstract algebra or a proof-writing course so I am sure that I am lacking in many proof-writing aspects, so I would really love a lot of constructive criticism both on the actual proof itself, and the way I wrote the proof. I also go into greater detail than might be appropriate for this type of proof because I am shaky on a lot of the math foundations so I figure that any imperfections in my knowledge will be more easily seen with a more explicit construction of this proof. Thank you all in advance.
Let $G$ be a finite group, and let $S$ be a nonempty subset of $G$. Suppose $S$ is closed with respect to multiplication. Prove that $S$ is a subgroup of $G$. (HINT: It remains to prove that $S$ contains $e$ and is closed with respect to inverses. Let $S$ = {$a_1$ ... $a_n$}. If $a_i$ $∈$ $S$, consider the distinct elements $a_ia_1$, $a_ia_2$, $...$ $a_ia_n$
Proof:
First we will define a function $A_1 : S \rightarrow S$ that maps $s \mapsto a_1s$. This function is injective because $$a_1y = a_1x$$ $$a^{-1}_1a_1y = a^{-1}_1a_1x$$ $$y = x$$
The function is then surjective because $A_1(S) \subseteq S$ and since $A_1$ is injective, it contains $|S|$ elements. Therefore $A_1$ maps onto every element in $S$ and is therefore surjective as well.
This means that $a_1$ is in the image of $A_1$. Therefore $$A_1(a_1) = a_1$$ $$a_1s = a_1$$ $$s = e$$
Since $S$ is closed under multiplication, $e \in S$.
Next, we will define a function $A_2 : S \rightarrow S$ that maps $s \mapsto a^2_1s$. This function is also injective $$a^2_1x = a^2_1y$$ $$x = y$$
It follows that this function is also surjective since it too is injective and contains |S| elements.
This means that $a_1$ is in the image of $A_2$ as well. Therefore $$A_2(z) = a_1$$ $$a^2_1z = a_1$$ $$z = a^{-1}_1$$
Since $S$ is closed under multiplication $a^{-1}_1 \in S$.
Therefore $e, a^{-1}_1 \in S$ so $S$ is a subgroup of $G$.
Please tear this apart! Thanks in advance.
You don't need to use the second map $A_2$. Once you know that $e \in S$, you know by the first part of your proof that $A_1$ is surjective, so for some $s \in S, a_1s=e$. Then $s=a^{-1}$.
Another way to prove this result, by the way, is to just take all possible powers of $a_1$, which all are contained within $S$ because $S$ is multiplicatively closed. They have to repeat at some point because $S$ is finite. If $a^m=a^{m+k}=a^ma^k$, then $a^k=e \in S$, and $aa^{k-1}=a^k=e \Rightarrow a^{k-1}=a^{-1} \in S$.
As for proof-writing, one small nit. I don't think the line $A_1(a_1) = a_1$ conveys your intended meaning. I think you mean to say $a_1 \in A_1(S)$.