Equivalence of Inverse Probability of Treatment Weights and Standardization: Hernan and Robins proof Hernan and Robins provide a proof for the equivalency of inverse probability weights and standardization for estimating the potential outcome mean that I am struggling to follow (technical point 2.3, page 24 of the first edition, excerpts pasted below).
There are two steps that I don't understand.
(1) Why is it that we can they rewrite the first term as the second, specifically replacing the $f[A|L]$ with $f[a|l]$. And then, why is it that we can replace the indicator function in the numerator with the expected value (i.e. $(I(A=a)Y)$ with $E[Y[A=a, L=l]]$ now that they are summing over $l$)? Canceling $f(a|l)$ from the numerator and denominator I understand.
$$\begin{align*}\text{E}\left[\frac{I(A=a)Y}{f\left[A|L\right]}\right] & = \sum_{l}{\frac{1}{f[a|l]}\{\text{E}[Y|A=a,L=l]\phantom{.}f[a|l]\phantom{.}\text{Pr}[L=l]\}}\\
& = \sum_{l}\{\text{E}[Y|A=a,L=a]\phantom{.}\text{Pr}[L=l]\}\end{align*}$$
(2) In the second line of this proof, again, I don't understand the implications of $f[A|L]$ as compared to $f[a|L]$, though I understand it's made possible by conditioning on $L$. And similarly, why is it that we can "move" $Y(a)$ out of the first expectation and multiply by $E[Y(a)|L]$ because of conditional exchangeability?
$$\text{E}\left[\frac{I(A=a)}{f[A|L]}Y\right]\text{ is equal to }\text{E}\left[\frac{I(A=a)}{f[A|L]}Y^{a}\right]\text{ by consistency.}$$
$$\begin{align*}&\text{Next, because positivity implies }f[a|L]\text{ is never 0, we have}\\\\
&\text{E}\left[\frac{I(A=a)}{f[A|L]}Y^{a}\right]= \text{E}\left\{\left[\frac{I(A=a)}{f[a|L]}Y^{a}\Big{|}L\right]\right\}= \text{E}\left\{\left[\frac{I(A=a)}{f[a|L]}\Big{|}L\right]\text{E}\left[Y^{a}|L\right]\right\}\\\\
& \text{(by conditional exchangeability).}\\\\
& = \text{E}\left\{\text{E}\left[Y^{a}|L\right]\right\}\text{(because }\text{E}\left[\frac{I(A=a)}{f[a|L]}\Big{|}L\right]=1\text{)}\\
& = \text{E}\left[Y^{a}\right]\end{align*}$$
Hernan/Robins discuss $f[A|L]$ as compared to $f[a|l]$ in technical point 2.2, which helps somewhat, but, I'm not sure I understand what it means to evaluate $A$ and $L$ at random arguments as opposed to fixed arguments.

Any help with the intuition, or the mathematical properties of expectations that make these steps possible would be greatly appreciated.
 A: I'm studying Hernan and Robins as well, and I was stuck on these steps as well. Here's my best attempt at explaining them.

*

*The expectation is actually being taken jointly over $Y, L, A$, and there's a lot of cancellations wrapped up in the equality. To see this, taking the expectation over the three variables yields the triple summation

$$\sum_\ell \sum_y \sum_{a'} \frac{I(A=a)}{f[a\mid \ell]} Y \; \mathbf{Pr}[Y = y, A = a, L = \ell].$$
The summands are zero for all $a'$ such that $a' \neq a$ ($A$ is discrete, but not necessarily dichotomous), so we can drop the summation in $a'$:
$$\sum_\ell \sum_y \frac{1}{f[a\mid \ell]} Y \; \mathbf{Pr}[Y = y, A = a, L = \ell].$$
Using the chain rule of probability (and rearranging some terms), we can then write
$$\sum_\ell \frac{1}{f[a\mid \ell]} \sum_y Y \;\mathbf{Pr}[Y = y \mid A = a, L = \ell]\;f[a \mid \ell]\; \mathbf{Pr}[L = \ell]$$
where I'm directly substituting in the shorthand $f[a \mid \ell] = \mathbf{Pr}[A = a \mid L = \ell]$.
After canceling, the summation in $y$ can be transformed into an expectation with respect to $Y$, and we end up with
$$\sum_\ell \mathbb{E}[Y \mid A = a, L = \ell] \; \mathbf{Pr}[L = \ell]$$ as needed.


*I think a point of confusion is that $f[A \mid L]$ is actually a conditional density function. Then $f[a \mid \ell]$ is that density function evaluated for values $A = a, L = \ell$. Similarly, $f[a \mid L]$ as used later in the proof is also a density function, but here $A$ is fixed as $a$.

For why we've replaced $f[A \mid L]$ with $f[a \mid L]$ in the proof, note that the inner expectation is over $L, A$ jointly. Similarly to part 1, any summand of the resultant expectation summation such that $A \neq a$ goes to 0. That is, the only "part" of $f[A \mid L]$ that we care about for the purposes of the proof is that in which $A = a$.
Then, for the 2nd part of your 2nd question on moving $Y^a$ out of the expectation, this is indeed due to conditional exchangeability ($Y^a \perp \!\!\! \perp A \mid L$). We have a product of a function of random variables $A$ and $Y^a$, so we can simply separate them as given in the textbook (conditioned on $L$).
Let me know if you have any questions about this!
