The set of points where two maps agree is closed?

Let $f,g\colon X \to Y$ be continuous maps. Let $Y$ be Hausdorff. Is the set $$A := \{x\in X \, : \, f(x)=g(x) \}$$ necessarily closed ?


Yes. Suppose that $f(x)\ne g(x)$. Since $Y$ is Hausdorff, there are disjoint open sets $U$ and $V$ such that $f(x)\in U$ and $g(x)\in V$. Let $W=f^{-1}[U]\cap g^{-1}[V]$; then $W$ is an open neighborhood of $x$. (Why?) What can you say about $f(p)$ and $g(p)$ if $p\in W$?


The set $A$ is the inverse image under $h:X\to Y^2: x\mapsto(f(x),g(y))$ of the diagonal $\{(y,y)\mid y\in Y\}$ of $Y^2$, which is closed since $Y$ is Hausdorff.