Suppose that $X$ is a Hausorff and compact space. Moreover, suppose that $\Delta:=\{(x,x):x\in X\}$ is a $G_{\delta}$ set. I need to show that $X$ has a countable basis.
As $X$ is Hausdorff, $\Delta$ is closed in $X\times X$, moreover, as $X\times X$ is compact and Hausdorff then it is a normal space. Now, as $\triangle$ is a $G_{\delta}$ closed set, there exists a continuous function $f:X\times X\to \mathbb{R}$ such that $f^{-1}(\{0\})=\Delta$ (It follows by Urysohn's lemma). Let $\mathcal{B}:=\{B_n\mid n\in\omega\}$ be a countable basis for $\mathbb{R}$ and consider the set $\{f^{-1}(B_n)\mid n\in\omega\}$. I claim that this set is a basis for $X\times X$.
As $f$ is continuous with compact domain and Hausdorff image, $f$ is a closed function. Let $G\subseteq X\times X$ be an open set. So $\mathbb{R}\setminus f[(X\times X)\setminus G]$ is a open set in $\mathbb{R}$. Let $n\in\omega$ such that $B_n\subseteq \mathbb{R}\setminus f[(X\times X)\setminus G]$, so we have that $f^{-1}(B_n)\subseteq G$. Then $X\times X$ has a countable basis, so $X$ has a countable basis too.
I think that there is a mistake in my proof because I don't use the fact that $\Delta$ is $G_{\delta}$ in a significant way. Can someone tell me where I am wrong?