TITLE: The generalized word problem on groups
QUESTION [5 upvotes]: Given some group $G$ that is generated by $a$ and $b$, each of which has infinite order, and some free subgroup $N$ generated by $a^k$ and $b^k$, is there any algorithm that tells me if some $x \in G$ is also in $N$? If not generally, what about for $k=2,3,4$?

REPLY [10 votes]: The answer is "no". Take the free group of rank 2 $F=<a,b>$. Take an infinite  recursively enumerable non-recursive set $X=\{u_1,u_2,...\}$, a subset of a recursive set $X'$ of words in $a,b$ satisfying the small cancelation condition $C'(1/12)$ and containing neither $a^2$ nor $b^2$. Take another infinite set of words $Y$ in $a^2,b^2$ satisfying $C'(1/12)$, $Y=\{v_1,v_2,...\}$. Consider the factor group $G$ of $F$ by relations $u_1=v_1,u_2=v_2,...$. Then the subgroup $H$ of $G$ generated by the images of squares $a^2,b^2$ is free and the membership problem for $H$ is undecidable.
The group $G$ is infinitely presented, the question does not ask for a finitely presented example, which is more difficult and I do not know the answer in that case. If rank can be assumed bigger than 2, the question might be manageable.
In the above construction one can replace $a^2, b^2$ by $a^m,b^n$ for any $m,n>1$.