Conditional expectation and equality in law Let $\mu$ be a probability measure on $(\mathbb{R}, \mathcal{B}(\mathbb{R}))$ and let $X : \mathbb{R} \rightarrow \mathbb{R}$ be the identity mapping on $\mathbb{R}$. Then $X$ can be viewed as a random variable with law $\mu$. Let $A \in \mathcal{B}(\mathbb{R})$ and assume that $\mathcal{G} \subset \mathcal{B}(\mathbb{R})$ is a sub-$\sigma$-algebra and consider the conitional expectation
$$
\mathbb{E}[1_A (X) | \mathcal{G}] \tag{1}
$$
Now consider a random variable $Y : \Omega \rightarrow \mathbb{R}$ on some probability space $(\Omega, \mathcal{F}, \mathbb{P})$ which is equal in law to $X$.

Is there an analogue of the conditional expectation in $(1)$ for $Y$? One can observe that $\mathcal{G} = X^{ -1 } ( \mathcal{G} )$, which may motivate to consider
$$
\mathbb{E}[1_A (Y) | Y^{ - 1 } ( \mathcal{G} ) ]. \tag{2}
$$
Is it possible to show that $(1)$ and $(2)$ are equal in distribution? If so, can a statement be made beyond their equality in distribution?

 A: Yes, they have the same distribution. More generally, a similar result holds for any measurable function $h:\mathbb{R}\rightarrow\mathbb{R}$  (you can use $h(x)=1_A(x)$ if you like).
Setup:
Let $X:\mathbb{R}\rightarrow\mathbb{R}$ be the identity function, considered a random variable on the probability space $(\mathbb{R}, \mathcal{B}(\mathbb{R}), \mu)$. Let $Y:\Omega\rightarrow\mathbb{R}$ be a random variable on a probability space $(\Omega, \mathcal{F}, P)$. Let $\mathcal{G}$ be a subsigma algebra of $\mathcal{B}(\mathbb{R})$. Recall that $Y^{-1}(\mathcal{G})$ is the sigma algebra of all events in $\mathcal{F}$ of the type $\{Y \in C\}$ for some $C \in \mathcal{G}$.
Claim:
Suppose $Y$ and $X$ have the same distribution. Let $h:\mathbb{R}\rightarrow\mathbb{R}$ be a measurable function and assume $E[|h(X)|]<\infty$. If $W=E[h(X)|\mathcal{G}]$ then
$$W(Y)=E[h(Y)|Y^{-1}(\mathcal{G})]$$
Further, $W$ and $W(Y)$ have the same distribution.
Proof:
Suppose
$W = E[h(X)|\mathcal{G}]$.
By definition of conditional expectation, $W:\mathbb{R}\rightarrow\mathbb{R}$ is a $\mathcal{G}$-measurable function, meaning that
$$ W^{-1}(B) \in \mathcal{G} \quad \forall B \in \mathcal{B}(\mathbb{R})$$
Since $X:\mathbb{R}\rightarrow\mathbb{R}$ is the identity function, every $C \in \mathcal{G}$ can be viewed as the event $\{X \in C\}$ on the probability space $(\mathbb{R}, \mathcal{B}(\mathbb{R}), \mu)$. Since $W=E[h(X)|\mathcal{G}]$ we have for each $C \in \mathcal{G}$:
$$E[W1_{X \in C}] = E[h(X)1_{X \in C}]\quad (*)$$
Since  $X:\mathbb{R}\rightarrow\mathbb{R}$ is the identity function, we can write $W=W(X)$, meaning that
$$W(x)=W(X(x)) \quad \forall x \in \mathbb{R}$$
Since $X$ has the same distribution as $Y$, and $W:\mathbb{R}\rightarrow\mathbb{R}$ is a measurable function, we know $W(X)$ and $W(Y)$ have the same distribution. In particular, $W$ has the same distribution as $W(Y)$.
It remains to show $W(Y)$ is a version of the conditional expectation $E[1_A(Y)|Y^{-1}(\mathcal{G})]$. First note that $W(Y)$ is a $Y^{-1}(\mathcal{G})$-measurable function. Indeed, for each $B \in \mathcal{B}(\mathbb{R})$ we have
\begin{align}
\{W(Y) \in B\} = \{Y \in W^{-1}(B)\} \in Y^{-1}(\mathcal{G})
\end{align}
where we have used the fact $W^{-1}(B) \in \mathcal{G}$.
Next, observe that every event in $Y^{-1}(\mathcal{G})$ has the form $\{Y \in C\}$ for some $C \in \mathcal{G}$.  Fix $C \in \mathcal{G}$. Then
\begin{align}
E[W(Y)1_{Y \in C}] &\overset{(a)}{=}E[W(X)1_{X \in C}]\\
&\overset{(b)}{=}E[W1_{X\in C}]\\
&\overset{(c)}{=}E[h(X)1_{X \in C}]\\
&\overset{(d)}{=}E[h(Y)1_{Y \in C}]
\end{align}
where (a) holds because $Y$ and $X$ have the same distribution; (b) holds because $W=W(X)$; (c) holds by (*); (d) holds because $Y$ and $X$ have the same distribution.  Thus, $W(Y)$ satisfies the requirements to be a version of the conditional expectation $E[h(Y)|Y^{-1}(\mathcal{G})]$. $\Box$
