Let $G$ be a group defined by generators and relations, say:
\begin{equation} G = D_{2n} = \left\langle s, r\mid s^{2} = 1, r^{n} =1, sr =r^{-1} s \right\rangle \end{equation}
And an arbitrary group $H$ (with unit element $e$). Let $f$ be an homomorphism from $G$ to $H$ defined by providing the images of $r$ and $s$ by $f$, and saying that for each element $a, b$ of $D_{2n}$ the images must conform to the homomorphism rule $f(ab) = f(a)f(b)$.
Is this true:
$f$ is a homomorphism if and only if $\left\lbrace f(s)f(s) = e, f(r)^{n} =e, f(s)f(r) = f(r)^{-1} f(s)\right\rbrace$
The "only if" part of the assertion is trivial by applying the definition of an homomorphism to the relations.
But is the "if" part true ? It seems to me that if all the relations $\left\lbrace f(s)f(s) = e, f(r)^{n} =e, f(s)f(r) = f(r)^{-1} s)\right\rbrace$ are verified, then $f$ is well-defined. If this is not true, could you help me by providing a counter-example, maybe with different $G$, $H$ and $f$ ?
EDIT
Taking inspiration from a now deleted comment, I think I can express my question better. If $f$ is a function from $\{r, s\}$ to $G$, consider an hypothetical induced homomorphism $\tilde{f}$ from $G$ to $H$ such that its restriction to $\{r, s\}$ yields the same value than $f$. Then:
\begin{equation} \tilde{f} \textrm{ exists} \Leftrightarrow \left\lbrace f(s)f(s) = e, f(r)^{n} =e, f(s)f(r) = f(r)^{-1} f(s)\right\rbrace \end{equation}
It seems easy to prove. For the $\Rightarrow$ part, one can prove the contraposition that if $f$ does not satisfy those conditions, then no homomorphism $\tilde{f}$ can exist as any homomorphism would have to satisfy them. For the $\Leftarrow$ part, the induced homomorphism $\tilde{f}$ can be constructed from the evaluations of $f$ on $\{r, s\}$.
Is the equivalence in this new edited version true, for any $G$ ?
This isn't true. Consider the function $f:D_4\to (\mathbb Z,+)$ which sends $sr\mapsto1$ and sends anything else to $0$. This is clearly not a homomorphism since $f(sr)\neq f(s)f(r)=0$, but the conditions are satisfied.