# Derivation of Conditional Causal Probabilities

In Causal Inference in Statistics: an Overview, Pearl presents an equation describing distribution from a graphical model presented in figure 3:

The author arrives at equality (20) - see image above. This is fine, I understand this. However, later on , the author derives equation (23):

I cannot seem to get that, here is my shot at the problem: \begin{align} \begin{split} P(y |do(x_0)) &= \sum_{z_1,z_2,z_3} P(z_1) P(z_2) P(z_3 |z_1,z_2) P(y |z_2,z_3,x_0) \text{ equation (20)}\\ &=\sum P(z_1) P(z_3,z_2 |z_1) P(y |z_2,z_3,x_0) \text{ since z_2 \perp z_1}\\ &=\sum_{z_1,z_2,z_3} P(z_1) P(y,z_2,z_3 |x_0,z_1) \text{ not sure why}\\ &=\sum_{z_1,z_2,z_3} P(z_1) P(y,z_3 |x_0, z_1) \text{ marginalize over z_2}\\ &=\sum_{z_1,z_2,z_3} P(z_1) P(y|z_1,z_3,x_0)P(z_3|z_1,x_0) \text{ cond. probability} \\ &= \sum_{z_1,z_3} P(z_1) P(z_3 |z_1) P(y |z_1,z_3,x_0) \text{ I doubt this step is correct} \end{split} \end{align}

There is a more straightforward way to derive the total causal effect to be $$P(y|do(x))=\sum\limits_{z_1,z_3}P(Z_1=z_1)P(Z_3=z_3|Z_1=z_1)P(Y=y|Z_1=z_1,Z_3=z_3,X=x)$$
Because the set {$$Z_1,Z_3$$} satisfies the backdoor criterion, we can get the causal effect of $$X$$ on $$Y$$ by conditionalizing the conditional probability $$P(Y=y|X=x)$$ on the set {$$Z_1,Z_3$$} (in the book "Causal Inference in Statistics: A Primer" he calls this the adjustment rule): $$P(Y=y|do(X=x))=\sum\limits_{z_1,z_3}P(Y=y|X=x,Z_1=z_1,Z_3=z_3)P(Z_1=z_1,Z_3=z_3)$$ As a last step, we use the causal graph to express $$P(Z_1=z_1,Z_3=z_3)$$ as $$P(Z_1=z_1)P(Z_3=z_3|Z_1=z_1)$$ and we arrive at the desired expression:
$$P(y|do(x))=\sum\limits_{z_1,z_3}P(Z_1=z_1)P(Z_3=z_3|Z_1=z_1)P(Y=y|Z_1=z_1,Z_3=z_3,X=x)$$