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.

-
See this page for help. –  Clayton Jan 23 '13 at 23:28
It doesn't seem correct. In particular, how do you know that $U$ is open? –  David Mitra Jan 23 '13 at 23:29
This seems in the spirit of what you're trying to do: Assume $f(x)\ne g(x)$. Choose disjoint open sets $U$ and $V$ in $Y$ with $f(x)\in U$ and $g(x)\in V$. By continuity of the functions choose open sets $N_1$ and $N_2$ in $X$ both containing $x$ such that $f(N_1)\subset U$ and $g(N_2)\subset V$. Take $O=N_1\cap N_2$. Then $O$ is open, contains $x$, and is disjoint from $C$ (since $f(N_1)\subset U$, $g(N_2)\subset V$ and $U\cap V=\emptyset)$. So $C^c$ is open. –  David Mitra Jan 23 '13 at 23:36
One possible answer –  leo Jan 24 '13 at 0:21
@David: True, I should have realized that. That's the basic idea I was going for, yes. Thanks. –  Alex Petzke Jan 24 '13 at 2:17

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$.

-
Nice argument!  –  leo Jan 23 '13 at 23:34
Indeed it is a great exercise to show that $\Delta_Y$ is a closed subset of $Y\times Y$ if and only if $Y$ is Hausdorff. –  Thomas Andrews Jan 23 '13 at 23:58
Am I correct to think that if $C=\{x \in X \,|\,f(x)=g(x)\}$ then $(f,g)(C)=\Delta_Y$, and since $\Delta_Y$ is closed, its preimage in $X$ ($C$) is as well? –  Alex Petzke Jan 24 '13 at 2:13
@AlexPetzke we can ensure only that $(f,g)(C)\subset \Delta_Y$ –  leo Jan 24 '13 at 4:16
@leo: ok, I see that. But we still have $(f,g)^{-1}(\Delta_Y)=C$ is closed, by continuity? –  Alex Petzke Jan 24 '13 at 4:40

Different argument (assuming you did the exercise in the link before):

If $f,g:X\to Y$ are continuous and $Y$ is Hausdorff then by a closed graph theorem we have that $G_f=\{(x,f(x)):x\in X\}$ and $G_g=\{(x,g(x)) : x\in X\}$ are closed in $X\times Y$; therefore, $G_g\cap G_f = \{(x,f(x) ):x\in X , f(x)=g(x)\}$ is closed as well. But $F:X\to X\times Y$ given by $F(x)=(x,f(x))$ is continuous , whence $F^{-1}(G_f\cap G_g)=\{x : f(x)=g(x)\}$ is closed in $X$.

-