If $f,g:X \to Y$ are continuous and $Y$ is $T_2$, then $\{x \in X\,|\,f(x)=g(x)\}$ is closed

I'd like to know if the following proof is valid. The only thing I'm not sure about (though I can't see why it's invalid if it is) is if we can always use the Hausdorfness of $Y$ to separate an open set from $f(C)=g(C)$.

"Let $X$ be a space, $Y$ a $T_2$-space, and $f,g:X \to Y$ continuous functions. Prove that $C:=\{x \in \,|\,f(x)=g(x)\}$ is a closed subset of $X$."

Let $x \in X$ be such that $f(x) \ne g(x)$. Since $Y$ is $T_2$, there are open sets $U_\alpha \ni f(x)$ and $V_\alpha \ni g(x)$ such that $U_\alpha \cap O_\alpha=V_\alpha \cap O_\alpha=\varnothing$ for all $\alpha \in A$ where $A$ is the set indexing the points of $f(C)=g(C)$, and $O_\alpha$ is an open set containing $x_\alpha \in f(C)=g(C)$. Let $U:=\displaystyle\bigcap_{\alpha \in A} U_\alpha$ and $V:=\displaystyle\bigcap_{\alpha \in A} V_\alpha$. Then $U \cap f(C)=V \cap f(C)=\varnothing$. Therefore, since $f,g$ are continuous, $f^{-1}(U)$ and $g^{-1}(V)$ are open sets in $X$ disjoint from $C$. Since $X\setminus A$ is the union of such open sets, it is open itself and therefore $C$ is closed.

Thanks.


If $f,g \colon X \to Y$ are continuous, then $(f,g)\colon X\to Y\times Y$ is continuous. The set $\{x\colon f(x) = g(x) \}$ is the counter-image by means of $(f,g)$ of the diagonal $\Delta = \{ (y,y) \colon y\in Y\}$ of $Y\times Y$. So it is enough to check that the diagonal is a closed set.

Let's prove that any point $(x,y)\not \in \Delta$ has a neighborhood which does not intersect $\Delta$. In fact Hausdorff property of $Y$ states that $x$ and $y$ (being different points) have two non overlapping neighbourhoods $U$, $V$. Hence $U\times V$ is a neighbourhood of $(x,y)$ not touching $\Delta$.