Given two algebras $A$ and $B$ in any fixed variety $\mathbf{V}$ of algebras and any $\mathbf{V}$-homomorphism $f:A \to B$, define $f$ to be "quasi-injective" if for any $\mathbf{V}$-algebra $C$ and any map $g:C \to A$, if $f \circ g$ is a $\mathbf{V}$-homomorphism, then $g$ must itself be a $\mathbf{V}$-homomorphism.
Then, is it true that "quasi-injective $\mathbf{V}$-homomorphisms" are necessarily injective?
The following three properties are easily verified:
- The "quasi-injective $\mathbf{V}$-homomorphisms" form a wide subcategory of the category of $\mathbf{V}$-algebras and all homomorphisms.
- If $f \circ g$ is defined and a "quasi-injective $\mathbf{V}$-homomorphism", then so is $g$.
- Any injective $\mathbf{V}$-homomorphism is "quasi-injective".
Given the above three properties, it follows that it then suffices to look at "quasi-injective" quotient maps $A \to A/{\sim}$ and ask whether $\sim$ must then be the identity congruence.
The question then becomes the following:
Given any $\mathbf{V}$-algebra $A$ and any congruence $\sim$ on $A$, is it true that if any function from any $\mathbf{V}$-algebra to $A$ that is a "homomorphism" up to $\sim$ is in fact a homomorphism "on the nose", then $\sim$ must necessarily be the identity congruence?
In this question, the variety $\mathbf{V}$ must not be the varieties of sets with no operation, singleton sets (defined with a constant $p$ and the axiom $\forall x\, x=p$), or subsingleton sets (defined with the axiom $\forall x\, \forall y\, x=y$, which includes the empty algebra).
For the variety of groups, rings, or modules, let $K$ be the normal subgroup, ideal, or submodule, respectively, corresponding to the congruence $\sim$. Then, given any "honest" homomorphism $f:B \to A$, one can just redefine $f(e)$ (in the case of groups) or $f(0)$ (in the case of rings or modules) to be some random non-identity (so nonzero in the case of rings or modules) element of $K$ to get a non-homomorphism $B \to A$ that becomes an "honest" homomorphism after post-composing with the quotient map $A \to A/{\sim}=A/K$.
For general varieties, I'm not sure what the answer is.
Besides the trivial case you mention of sets with no operations, counterexamples more generally include any variety for which every function is a homomorphism. This is equivalent to every operation being a projection map onto one of the inputs.
Less trivially, consider the variety of pointed sets. Then any homomorphism with trivial kernel is quasi-injective, but such a homomorphism need not be injective. More generally, given an algebra $B$ over some variety, let $B'$ be the set of elements of $B$ that are in the image of some nontrivial operation (where a "trivial" operation is one which the axioms imply to be a projection). Then if $f:A\to B$ is any homomorphism whose restriction to $f^{-1}(B')$ is injective, $f$ is quasi-injective.