Let $(X, T_X)$ be a topological space and $\sim$ an equivalence relation on $X$, let $Q = X / \sim$ be the quotient space and let $q : X \to Q$ be the quotient map.
Let $Z$ be a topological space and let $f : X \to Z$ be a continuous map such that, for all $x, x' \in X$, we have $x \sim x' \Rightarrow f(x) = f(x')$. Prove that there exists a unique continuous map $g : Q \to Z$ such that $f = g \circ q$.
For me, proving uniqueness is easy; it's the existence that troubles me. I can give a (somewhat informal) constructive proof. We define $g$ as follows: let $y \in Q$ be arbitrary, so $y$ is an equivalence class, and this means that there exists an $x \in X$ such that $q(x) = y$. We then define $g(y) = f(x)$. This makes $g$ well-defined, since although there can be uncountably infinite elements of $X$ which, under $q$, map to $y$, they are always related, i.e., if $x, x' \in X$ with $q(x) = q(x') = y$, then $g(y) = f(x)$ and $g(y) = f(x')$, but we also have $x \sim x'$, which means that $f(x) = f(x')$, hence $g$ is well-defined .
I could turn this into a formal proof (or maybe it already is?) but it just doesn't feel right. I'm sure that proving the existence of this map can be done in a nicer, more beautiful way. Everytime I get questions like this, I can give either a simple informal or very complicated formal proof (always constructive) while I feel that there is a simple formal proof (which doesn't have to be constructive).
Is there a general approach to this type of question? (Like when you have to prove that two sets $A$ and $B$ are the same, you can write a thousand pages explaining why they are (that's how my constructive "proof" feels to me), or you can just prove $A \subset B$ and $B \subset A$.) I'm an undergruate student in mathematics following courses in Topology. Thanks in advance!