Suppose $X$ and $Y$ are random variables on $(\Omega, \mathcal{F})$ with values in $(\mathcal{X},\mathcal{A})$. I would like to prove that if the diagonal
$$\Delta:=\{(x,y)\in \mathcal{X}^2:x=y\}$$
is $\mathcal{A}\otimes \mathcal{A}$-measuable, then
$$M=\{\omega:X(\omega)=Y(\omega)\}\in\mathcal{F}.$$
I cannot see why. I know this diagonal condition guarantees that every singleton $\{x\}\subset\mathcal{X}$ is in $\mathcal{A}$. But if $\mathcal{X}$ is uncountable, then
$$M=\{\omega:X(\omega)=Y(\omega)\} = \bigcup_{x\in\mathcal{X}} (X^{-1}(\{x\})\cap Y^{-1}(\{x\}))$$
is an uncountable union of measurable sets. How can we guarantee that this set is measurable?
The mapping
$$(X,Y)\colon \Omega \to \mathcal{X}^2, \quad \omega\mapsto (X(\omega),Y(\omega)),$$
is $\mathcal{F}-\mathcal{A}\otimes\mathcal{A}$-measurable and hence $\Delta \in\mathcal{A}\otimes\mathcal{A}$ implies
$$ \{\omega\in\Omega:X(\omega)=Y(\omega)\}=\{\omega\in\Omega:(X,Y)(\omega)\in\Delta\} = (X,Y)^{-1}(\Delta) \in\mathcal{F}.$$