How to prove $\left\{ \omega|X(\omega)=Y(\omega)\right\} \in\mathcal{F}$ is measurable, if $X$ and $Y$ are measurable? Given a probability space $(\Omega ,\mathcal{F} ,\mu)$. Let $X$ and $Y$ be $\mathcal{F}$-measurable real valued random variables.  How would one proove that $\left\{ \omega|X(\omega)=Y(\omega)\right\} \in\mathcal{F}$ is measurable.
My thoughts: Since $X$ and $Y$ are measurable, it is true, that for each $x\in\mathbb{R}:$ $\left\{ \omega|X(\omega)<x\right\} \in\mathcal{F}$ and $\left\{ \omega|Y(\omega)<x\right\} \in\mathcal{F}$.
It follows that $\left\{ \omega|X(\omega)-Y(\omega)\leq x\right\} \in\mathcal{F}$
Therefore $\left\{ -\frac{1}{n}\leq\omega|X(\omega)-Y(\omega)\leq \frac{1}{n} \right\} \in\mathcal{F}$, for $n\in\mathbb{N}$.
Therefore $0=\bigcap_{n\in\mathbb{N}}\left\{ -\frac{1}{n}\leq\omega|X(\omega)-Y(\omega)\leq \frac{1}{n} \right\} \in\mathcal{F}$.
Am working towards the correct direction? I appreciate any constructive answer!
 A: $$[X\ne Y]=\bigcup_{q\in\mathbb Q}\left([X\lt q]\cap[Y\geqslant q]\right)\cup\left([X\geqslant q]\cap[Y\lt q]\right)=\bigcup_{q\in\mathbb Q}\left([X\lt q]\Delta[Y\lt q]\right)
$$
A: Let $Z\colon \Omega\to\mathbb R^2$ defined by $Z(\omega)=(X(\omega),Y(\omega))$, where $\mathbb R^2$ is endowed with the Borel $\sigma$-algebra $\mathcal B(\mathbb R^2)$. 


*

*Show that the fact that the projections are measurable implies that so is $Z$. 

*Show that the set $\{(x,x)\in\Bbb R\times \Bbb R)$ is $\mathcal B(\mathbb R^2)$-measurable. 

A: We would want to try to do something like this:

If $X$, $Y$ are $\mathcal F-$measurable, then $X^{-1}(B), Y^{-1}(B) \in \mathcal F$ for any $B \in \mathscr B(\mathbb R)$. Choose $B = \{b\}$ for some $b \in \mathbb R$.
Then $$\{X=Y\} = \bigcup_{b \in \mathbb R} \{X=Y=b\} = \bigcup_{b \in \mathbb R} [\{X=b\} \cap \{Y=b\}]$$
Now $\{X=Y\} \in \mathcal F \iff \{X \ne Y\} \in \mathcal F$

Unfortunately, our union is uncountable, and $\sigma-$algebra's, for good reason, aren't closed under uncountable unions. So, let's try something with a countable set like $b \in \mathbb Z$. The ranges of $X$ or $Y$ could be non-$\mathbb Z$ valued so we'll have to choose a non-singleton for $B$ namely $(-\infty,b]$ and its complement.
Then $$\{X<Y\} = \bigcup_{b \in \mathbb Z} [\{X \le b\} \cap \{Y>b\}]$$ and $$\{X>Y\} = \bigcup_{b \in \mathbb Z} [\{X > b\} \cap \{Y \le b\}]$$ and $$\{X<Y\} \cup \{X>Y\} = \{X \ne Y\}$$
