The answer to the title question is that the problem is unsolvable. See p. 194 of Lyndon and Schupp's Combinatorial Group Theory, where it is called the "generating problem." It is unsolvable even when $G$ is the direct product of free groups of rank at least 6.
John Stillwell
- 12.4k
- 15
- 96
- 118