Suppose $f, g : X \to Y$ are continuous maps and $Y$ is Hausdorff. Show that the set $\{x\in X: f(x)=g(x)\}$ is closed in $X$.
Is my proof valid?
Proof: Suppose $f: X \to Y$ and $g: X\to Y$ are continuous and $Y$ is Hausdorff. Let $A=\{x\in X: f(x)=g(x)\}$. Let $h: X\to Y$ be defined by $h(x)=f(x)-g(x)$. Then $h$ is continuous and $A=\{x \in X: h(x)=0\}$. Also, $X\setminus A=\{x \in X: h(x) \ne 0\}$.
If $a \in X\setminus A$, then $h(a) \ne 0$, say $h(a)=p$. Since $Y$ is Hausdorff, there exists disjoint neighborhoods $U$ of $0$ and $V$ of $p$. So, $h(a) \in V$ and $a \in h^{-1}(V)$. So, $X\setminus A \subset h^{-1}(V)$. But for all $x \in h^{-1}(V)$, we have $h(x) \ne 0$. So, $x \in X\setminus A$. So, $h^{-1}(V) \subset X$. Thus, $X\setminus A=h^{-1}(V)$. Since $h$ is continuous $X\setminus A=h^{-1}(V)$ is open. So, $A$ is closed.
$Y$ is "only" a topological space, hence no arithmetic operations are defined on $Y$ !!.
Let $a \in X \setminus A$. Then $f(a) \ne g(a)$. Since $Y$ is Hausdorff, there are neighborhoods $U$ and $V$ of $f(a)$, resp. $g(a)$ with $U \cap V = \emptyset$.
Then we find a neigborhood $U_1 \subset X$ of $a$ such that $f(x) \in U$ for all $x \in U_1$. We also find a neigborhood $V_1 \subset X$ of $a$ such that $g(x) \in V$ for all $x \in V_1$.
Put $U_2:= U_1 \cap V_1$. Then $U_2$ is a neighborhood of $a$ and $U_2 \subseteq X \setminus A$. This shows that $X \setminus A$ is open.