Is mapping generators to generators, and then extending, a well-defined homomorphism?

Any arbitrary map of generators to generators need not extend to a homomorphism, even if there is only one generator. For example, there is no nontrivial homomorphism between two cyclic groups of different prime orders.

The problem is that any combination of generators that results in the identity in the original group must also evaluate to the identity when you map to the target generators. Otherwise the map would not be a homomorphism, or even well defined (so actually not a function at all).


Look at it this way. If what you propose was well-defined in general, then your $\varphi$ would always have inverse $\psi\colon H\to G$ just by setting $\psi(x)=a$, $\psi(y) = b$. But not all groups generated by two elements are isomorphic. For example look at $\mathbb Z_2\times\mathbb Z_2$, $\mathbb Z\times \mathbb Z_2$, $\mathbb Z\times\mathbb Z$, $F_2$ (free group generated by two elements), and any dihedral group $D_n$.

In general, for the group $G$ to be generated by two elements, it means that there is an epimorphism $\varepsilon\colon F_2\to G$ and by the first isomorphism theorem $G\cong F_2/\ker\varepsilon$. So, to define $\varphi\colon G\to H$, you need to have a homomorhpism $\psi\colon F_2 \to H$ such that $\ker\varepsilon\subseteq \ker\psi$, by the fundamental homomorphism theorem.

To explain what it means precisely, let $F_2 = \langle x,y\rangle$ and $G = \langle a,b\rangle$. In this case, $\varepsilon$ is just $x\mapsto a$ and $y\mapsto b$. To specify $\psi$, it is enough to pick any two elements $h_1,h_2\in H$ and let $\psi(x) = h_1$, $\psi(y) = h_2$. This always does define homomorphism - this is by definition of a free group, and this is essentially what you wanted to do, but for group $G$. Now, condition $\ker\varepsilon\subseteq \ker\psi$ is equivalent to saying that for all $a^{\alpha_1}b^{\beta_1}\ldots a^{\alpha_n}b^{\beta_n} = e_G$, it must be that $h_1^{\alpha_1}h_2^{\beta_1}\ldots h_1^{\alpha_n}h_2^{\beta_n} = e_H.$ If that's true, you can set $\varphi(a) = h_1$, $\varphi(b) = h_2$, and it will be well-defined.

For more concrete example, let's take $G = \mathbb Z_2\times\mathbb Z_2$ and $H = \mathbb Z\times\mathbb Z$. Let $a = (1,0)$ and $b = (0,1)$. Note that $2a = 2b = (0,0)$ (I've switched to additive notation, as is customary). However, for any hypothetical $\varphi\colon G\to H$, $2\varphi(a) = \varphi(2a) = \varphi(0,0) = (0,0)$. Since the only $h\in H$ such that $2h = (0,0)$ is $h = (0,0)$, we need to have $\varphi(a) = (0,0)$ and similarly $\varphi(b) = (0,0)$. So, the only homomorphism is trivial.