Integral identity of lemma contained in infoGAN paper I've come across a lemma in the infoGAN paper. I do not understand the derivation of Lemma 5.1 in the addendum of the paper. It goes as follows (included as png):

I do not understand the last step. Why can one pull $f(x,y)$ into the inner-most integral, transforming it into $f(x',y)$? What are the suitable regularity conditions of $f$?
 A: Consider the difference
$$
D = \int_x \int_y P(x,y) \int_{x'} P(x'|y) \left[ f(x,y) - f(x',y) \right] \, dx' dx dy
$$
obtained by moving $f(x,y)$ into the $x'$ integral, and taking the difference with $x$ replaced by $x'$.
Conditionalizing $x$ on $y$,
$$
D = \int_y P(y) \int_x \int_{x'} P(x|y) P(x'|y) \left[ f(x,y) - f(x',y) \right] \, dx' dx dy.
$$
This interior object
$$
\delta = \int_x \int_{x'} P(x|y) P(x'|y) \left[ f(x,y) - f(x',y) \right] \, dx' dx
$$
is antisymmetric after swapping the dummy variables $x$ and $x'$, becoming its own negative, and so it is equal to zero.
I suspect that the regularity conditions are simply those that prevent these integrals from diverging.
A: Or, after the third row
\begin{align}
&=\int_x\int_yp(x|y)p(y)f(x,y)\int_{x'}p(x'|y)dx'dydx\\
&=\int_x\int_yp(x|y)f(x,y)\int_{x'}p(x',y)dx'dydx.
\end{align}
Swap $x$ and $x'$ then exchange the order of variables. Done
A: Well, I think it will be more intuitive if we derive the equation reversely as
\begin{align*}
E_{x \sim X, y \sim Y|x, x' \sim X|y} \left[ f(x', y) \right]
& = \int_x p(x) \int_y p(y|x) \int_{x'} p(x'|y) f(x', y) dx'dydx \\
& = \int_y p(y) \int_x p(x|y) \int_{x'} p(x'|y) f(x', y) dx'dxdy \\
& = \int_y p(y) \int_{x'} p(x'|y) f(x', y) \underbrace{\int_x p(x|y) dx}_{=1}dx'dy \\
& = \int_y p(y) \int_{x} p(x|y) f(x, y) dxdy \\
& = \int_x p(x) \int_{y} p(y|x) f(x, y) dydx \\
& = E_{x \sim X, y \sim Y|x} \left[ f(x, y) \right]
\end{align*}
A: The assertion
$$
E_{x \sim X, y \sim Y|x} \left[ f(x, y) \right]
=
E_{x \sim X, y \sim Y|x, x' \sim X|y} \left[ f(x', y) \right]\tag1
$$
is really saying:

If the random vector $(X,Y,X')$ has joint distribution $$P_{X,Y,X'}(x,y,z)=P_X(x)P_{Y|X}(y|x)P_{X|Y}(z|y),\tag2$$ then $E[f(X,Y)] = E[f(X',Y)]$.

The result follows from the fact that $(X,Y)$ has the same distribution as $(X',Y)$, which is seen from:
$$P_{X'|Y}(z|y)=\int_x\frac{ P_{X,Y,X'}(x,y,z)}{P_Y(y)}\,dx\stackrel{(2)}=
\int_x P_{X|Y}(x|y)P_{X|Y}(z|y)\,dx=P_{X|Y}(z|y).$$
Not much regularity is required here besides the existence of the expectation $Ef(X,Y)$.
