Do-Calculus for Causal Diagram 7.5 from "The Book of Why" (napkin problem) In "The Book of Why" the below causal diagram is described as the "simplest model" where estimation of the causal effect goes beyond front and back-door adjustment and thus requires do-calculus.

Here, $W$, $X$, $Y$, $Z$ are all observed, and $U_1$ and $U_2$ are Unobserved.
I have played around a bit with the rules, about which I am still shaky, but haven't come up with a solution for $P(Y|do(X))$ that can be estimated from the diagram. Could someone better than me help come up with a  solution?
 A: I answered this once on twitter,  I can reproduce the answer here.

Derivation (graphs licensing each step are provided below).
$$
\begin{align}
    P(y|do(x)) &= P(y|do(x), do(z)) \qquad &\text{Rule 3: $(Y \perp\!\!\!\perp  Z|X)_{G_\overline{XZ}}$}\\
    &= P(y |x, do(z)) \qquad &\text{Rule 2: $(Y\perp\!\!\!\perp   X)_{G_{\overline{Z}\underline{X}}}$}\\
    &= \frac{P(y, x|do(z))}{P(x|do(z))} \qquad &\text{Def. of conditional probability}\\
    &= \frac{\sum_{w}P(y, x|z, w)P(w)}{\sum_{w}P(x|z,w)P(w)}\qquad &\text{Backdoor using with $W$: $(\{Y, X\}\perp\!\!\!\perp   Z|W)_{G_{\underline{Z}}}$}
\end{align}
$$
What does each step mean of the derivation means in plain English?

*

*Step 1 simply states that, when $X$ is held fixed (by intervention),
manipulating $Z$ has no effect on $Y$;

*Step 2 states that, when $Z$
is held fixed (by intervention),  there is no confounding between $X$
and $Y$;

*Step 3 is just applying the definition of conditional
probability; and, finally,

*Step 4 notes that adjusting for $W$ is
sufficient to identify the causal effect of $Z$ on $X$ and $Y$. This
is because $W$ blocks all confounding paths from $Z$ to $X$ and $Y$
(backdoor paths). So we can use vanilla backdoor adjustment here.

Modified Graphs

A: In the following github repo, we provide Python software that assigns random probabilities to the nodes of the Napkin Bayesian Network. The software then does the marginalizations necessary to calculate P(y|x) and the right hand side of the Adjustment Formula given by Cinelli above. We find that they are always equal, no matter what the random probabilities are. Hence, Cinelli's Adjustment Formula reduces to P(y|do(x))=P(y|x)
https://github.com/rrtucci/napkin-do-calc
