TITLE: Kernels in $\mathbf{Top}$
QUESTION [18 upvotes]: There is a following well-known theorem for abelian categories (at least the ones I know, Ab, $R$-mod and so on... not so familiar with categorical language to be honest) which states the following : 
If $X,Y,Z$ are objects and $f : X \to Y$, $g : X \to Z$ morphisms with $g$ surjective, then there exists a unique morphism $h : Z \to Y$ such that the diagram commutes if and only if $\ker g \subseteq \ker f$. (Draw the diagram, won't do it here :D )
Now I was getting started doing algebraic topology in Allen Hatcher's book and some question wanted me to work out homotopies and I realized I implicitly used the following. 
If $X,Y,Z$ are topological spaces and $f : X \to Y$, $g : X \to Z$ continuous maps with $g$ being a surjective quotient map (quotient map means $U \subseteq Z$ is open if and only if $g^{-1}(U)$ is open in $X$), then there exists a unique continuous map $h : Z \to Y$ such that the diagram commutes if and only if 
$$
\ker g \overset{def}= \{ (x_1,x_2) \in X^2 \, | \, g(x_1) = g(x_2) \} \subseteq \{ (x_1,x_2) \in X^2 \, | \, f(x_1) = f(x_2) \} \overset{def}= \ker f.
$$ 
(The map $h$ is obviously defined by $f \circ g^{-1}$ and the condition makes sure that everything works out. I am not sure how to prove that $f \circ g^{-1}$ will be continuous in general or what conditions precisely should be added, I did it in the case of a projection (i.e. $g$ was just a map that "glued points together" and $Z$ was $X / \sim$ for some equivalence relation that glued points). Maybe this is not as general as one could wish. )
My question is : I feel like I didn't totally imagine this notion of kernel in Top, I think I've read it somewhere but I am not sure and I have no idea how to look it up online, since "kernel" redirects to the well-known notion and not to this one. Anyone knows if this kind of kernel is useful in a more general setting, or if some results that are true in Ab also hold in Top with this tweak in a similar way that I did?

REPLY [2 votes]: In universal algebra this concept is also known as the kernel of a morphism $f : X\to Y$. However, topological spaces are not universal algebras and calling these things "kernels" is not a good idea, because the term is reserved for a better known concept already.
Incidentally, in a typical "concrete category of sets with some structure", like $\mathsf{Top}$, this kind of "kernel" is a particular case of a pullback $(P,p_1 : P \to X_1, p_2 : P \to X_2)$ of morphisms $f_1 : X_1 \to Y$ and $f_2 : X_2\to Y$ with common codomain. It can be constructed via:
$$P = \{ (x_1,x_2)\in X_1\times X_2 : f_1(x_1) = f_2(x_2)\}$$
and choosing $p_1,p_2$ to be canonical projections. 
It should be clear, that you get this "kernel" by choosing $f = f_1 = f_2$. 
A kernel pair of a morphism $f$ in a category is the pullback of $f$ along itself. This is standard modern terminology for the notion you are interested in. 
Is this notion really important in a more general context? Yes, definitely! In a category with finite limits (that is: pullbacks and a terminal object) (such as $\mathsf{Top}$ or every algebraic category) a kernel pair is an internal equivalence relation. Yes, these are exactly what you think they are (in $\mathsf{Set}$ there are the equivalence relations, in algebraic categories they are congruence relations). And quotients by internal equivalence relations are taken by taking their coequalizer. It all works out nicely.
One might also be wondering about the relationship between kernel pairs and kernels (as in something like $\{x : f(x) = 1\}$), because in group theory for example they are more commonly used, when talking about quotients (there are exactly the normal subgroups). Kernels are actually examples of equalizers, that is: in a category with a zero object $0$ a kernel of a morphism $f$ is an equalizer of $f$ and the composite $A\to 0 \to B$.
Hence, if you know that something is a kernel, then there is always a morphism $f$ and if your category has finite limits, then $f$'s kernel pair is exactly the internal equivalence relation associated with that kernel (e.g. in group theory the relation $x \sim y \Leftrightarrow xy^{-1} \in \ker f$ is really just the kernel pair of $f$).
Remark:
Existence of pullbacks suffices to prove, that every kernel pair is an internal equivalence relation, but then the definition linked needs to be adjusted.