Diagonal of a metric space In topology we have the classic result,

A space $X$ is Hausdorff if and only if the diagonal $\Delta = \{(x ,x) : x \in X\}$ is closed in $X \times X$.

Proof. But note that the product topology is used in the proof (which is essential). In this case, we are thinking in the product space $X\times X$ in order to reach conclusions about the structure in the space $X$. But what if we think about the diagonal of a space that is a product between two sets?
More specifically, I would like to think of the similar result for metric spaces, that the diagonal is closed.

Let $M$ be a metric space. For all $z\in M\times M\setminus \Delta$ exist an open ball of center $z$ in $M\times M$ that is disjoint from $\Delta$.

Again in the proof of this result, a specific metric in the product space is used. So I would like to know if it is possible to generalize the results. In the sense that given a metric space $(M,d)$, where $M= X \times X$ for some $X\neq \emptyset$, for all $z=(x,y)\in M\setminus \Delta$ exist $B(z,r)$ such that $B(z,r) \cap \Delta = \emptyset$.
In other words, I'm thinking about a product space in a generic metric. I couldn't find any proof for this result using a generic metric, every proof involves the metric given in proof, or some topologically equivalent. This result may not be true in this case, but I couldn't think of a counterexample or a proof. But if it is false, what condition is it possible to put in space or in the metric for the result to be true?
 A: The short answer is that the set of metrics on $X\times X$ only really depend on the cardinality of $X,$ which is, when $X$ is infinite, the same as the cardinality of $X\times X.$ When $X$ is infinite, there is nothing about $\Delta$ which is different from any other set $S\subset X\times X$ such that $|S|=|X\times X\setminus S|=|X|.$
Assume $X=\mathbb R,$ and $d$ the usual metric on $\mathbb R\times\mathbb R.$
Define $f:X\times X\to X\times X$ as:
$$f(x_1,x_2)=\begin{cases}(0,1)&(x_1,x_2)=(0,0)\\
(0,0)& (x_1,x_2)=(0,1)\\
(x_1,x_2)&\text{otherwise}
\end{cases}$$
$f$ is a bijection.
Then define $d_2(u,v)=d(f(u),f(v))$ for $u,v\in X\times X.$
Since $f$ is a bijection, this makes $f$ a homeomorphism between $(X\times X,d_2)$ and $(X\times X,d)$ with $\Delta$ under $d_2$ corresponding to the set $$f(\Delta)=\Delta\setminus\{(0,0)\}\cup\{(0,1)\}$$ under $d,$ the usual metric. But that set isn’t closed, under the usual metric.

You can do this with any non-discrete metric space, $(X,d).$ Instead of $(0,0)$ and $(0,1)$ you’d use $(x_0,x_0)$ and $(x_0,x_1),$ here $x_0$ is a point such that $\{x_0\}$ is not open in $X.$

Any metric on a finite set is discrete, so if $X$ is finite, then $\Delta$ is closed under any metric on $X\times X,$ since every subset is closed.
A: If $(X,d)$ is a metric space, then $d: X \times X \to \Bbb R$ is continuous when $X \times X$ has the product topology wrt the topology induced by $d$ on $X$. This is a standard result that is proved several times on this site alone.
But then $\Delta_X= d^{-1}[\{0\}]$ is closed as the inverse image of a closed set under a continuous map. This also shows that $\Delta_X$ is a $G_\delta$ set in $X \times X$ as well, as $\{0\}$ is one in $\Bbb R$.
