Problem: Let $X$ be a topological space. Show that $X$ is Hausdorff if and only if the diagonal
\[
\Delta \coloneqq \{ (x,x) \mid x \in X \}
\]
is closed subset of $X \times X$ with the product topology.
Show that $\Delta^c$ is open. For that note that using the Hausdorff property of $X$, you can find open set $U$ and $V$ in $X$ such that $ u \cap V = \emptyset$.
Use $\Delta^c$ is open to find two open sets $U$ and $V$.
Solution: Let $X$ be a hausdorff space. We need to show that $\Delta $ is closed in $X \times X$. We will show that $\Delta ^c\coloneqq X\times X \setminus \Delta $ is open in $X\times X$. Let $(x,y) \in \Delta ^c$ which implies $x \neq y$. Since $x$ and $y$ are two distinct points of $X$ and $X$ is Hausdorff, we can find open sets $U_x$ and $U_y$ containing $x$ and $y$ respectively, such that $U_x \cap U_y = \emptyset $. Then the set $U\coloneqq U_x \times U_y$ is open in $X \times X$ in the product topology. We now claim that $U \cap \Delta = \emptyset $, which will prove that $\Delta ^c$ is open. If $(a,b) \in U \cap \Delta $, then $a = b$. This implies $(a,a) \in U_x \times U_y$, a contradiction as $U_x \cap U_y = \emptyset $. Thus, $\Delta$ is closed in $X \times X$.
On the other hand, let $\Delta $ is closed in $X \times X$ and we need to show that $X$ is Hausdorff. Let $x, y \in X$ such that $x \neq y$, which implies $(x,y) \notin \Delta $. As $\Delta $ is closed implies $\Delta^c $ is open, so we can find basic open sets $(x,y) \in U \times V \subseteq X \times X$ such that $U \times V \subseteq \Delta ^c$. Note that if $z \in U \cap V$, then $(z,z) \in U \times V \in \Delta ^c$, which is not possible and hence $D \cap V = \emptyset $. Thus, $X$ is Hausdorff.