Let $G$ and $H$ be finitely generated free groups, and let $f:G\to H$ be a homomorphism specified by giving the images of the generators of $G$. 


Is there an algorithm which takes such an $f$ and a word $w\in H$ and tells if $w \in f(G)$? 


Is there such an algorithm in the special case where $G=H$? 


Thanks-



Algorithm for image of a free group homomorphism
You are asking whether an element in a free group lies in the span of a set of elements (the images of the generators). This is the *generalized word problem* which is known to be decidable for free groups (for an algorithm, see, for example: Stallings' "Topology of finite graphs" (Inventiones, 1983), though the result is several decades older.


