$E[Y|X]$ is a function of $X$, which can be translated as follows: Let $Y$ and $X$ be two random variables defined on a common probability space $\{\Omega,\mathcal{F},P\}$, and let $\mathcal{F}_{X}$ be the $\sigma$-algebra generated by $X$, $\mathcal{F}_{X}=\{X^{-1}(B), B \in \mathcal{B}\}$, where $X^{-1}(B)$ is a shorthand notation for the set $\{\omega \in \Omega: X(\omega) \in B\}$ and $\mathcal{B}$ is the Euclidean Borel field. Then,
$Z=E[Y|X]$ is measurable $\mathcal{F}_{X}$,
which means that, for all Borel sets $B$, $\{\omega \in \Omega: Z(\omega) \in B\}\in \mathcal{F}_{X}$. We also have
$E[(Y-E[Y|X])I(X \in B)]=0$ for all Borel sets $B$.$\cdots \cdots$(1)
Because $\mathcal{F}_{X}=\{X^{-1}(B)\in B, B \in \mathcal{B}\}$, property (1) is equivalent to
$\int_{A}(Y(\omega)-Z(\omega))dP(\omega)=0$ for all $A\in \mathcal{F}_{X}$.$\cdots \cdots$(2)
I am trying to understand the above text that suggests property (1) and (2) are equivalent.
My attempt is as follows.
$\forall A \in \mathcal{F}_{X}$
$0=\int_{A}(Y(\omega)-E(Y|X)(\omega))dP(\omega)$
$=\int_{\Omega}(Y(\omega)-E(Y|X)(\omega))I(\omega \in A)dP(\omega)$
$=\int_{\Omega}(Y(\omega)-E(Y|X)(\omega))I(X(\omega)\in B)dP(\omega)$ since $\mathcal{F}_{X}=\{X^{-1}(B)\in B, B \in \mathcal{B}\}$
$=E[(Y-E(Y|X))I(X \in B)]=0$ $\forall B \in \mathcal{B}$
Did I got this proof right?