The following is from Abstract Algebra (Dummit & Foote):
If $G$ is a finite group and $H$ is a subgroup of $G$ such that $H=\langle S\rangle$ for some $S\subseteq G$, then prove that $H\unlhd G$ iff $gSg^{-1}\subseteq H$ for all $g\in G$.
When considering the proof, it seems that the condition that $G$ is finite is never explicitly used, although there is a part of the proof that might be ambiguous in cases where $H$ is not finitely generated:
Proof ($\Leftarrow$): Suppose that $H\leq G$ and $H=\langle S\rangle$ for some $S\subseteq G$. Suppose also that $gSg^{-1}\subseteq H$ for all $g\in G$. Let $g\in G$, $h\in H$. Then $h=a_1^{n_1}\cdot a_2^{n_2}\cdots a_k^{n_k}$ for some collection of $a_i\in S$. Here, we compute $ghg^{-1}$ and show by induction (or semantics) that $ghg^{-1}\in H$ by sneaking a $g^{-1}g$ in between each term: $$ghg^{-1}=g\cdot a_1^{n_1}\cdot a_2^{n_2}\cdots a_k^{n_k}\cdot g^{-1}=ga_1g^{-1}ga_1\cdots ga_ng^{-1}\in H$$ My question is, does this argument fail if $H$ is not finitely generated? Why does the author use "G is finite" in the hypothesis, and is this condition necessary? If the condition is necessary, can anyone think of a clever counterexample for the infinite case?
Consider the set of elements $x \in G$, such that $gxg^{-1} \in H$ holds for any $g \in G$. This is a subgroup of $G$ (to be precise it is the intersection of pre-images of $H$ with respect to the conjugation with $g$ for all $g \in G$), which contains $S$ by assumption. Hence this subgroup contains $\langle S \rangle =H$. No need for $G$ to be finite or finitely generated.