Prove dependency of variables in a Bayes net (CS188) I'm trying to understand how the conclusion of $P(x|z)=1, \forall x = z$ is reached.
I can understand it intuitively but I'm having a big trouble figuring out how to really 'chug the math'.
I've been noodling with CPT's and trying to juggle things algebraically but can't seem to reach the conclusion that $P(X|Z) \ne P(X)$.
How to approach a 'proof' of this statement? Here is a screenshot from the lecture:

 A: congrats for posting your first question :)
Here's my attempt at proving the statement: by chain rule you can write
$P(X|Z) = P(X|Y)P(Y|Z)$
and using Bayes' rule $P(Y|Z) = P(Z|Y)\frac{P(Y)}{P(Z)}$, and by virtue of $P(X|Y)=\delta_{xy}$ and $P(Z|Y)=\delta_{zy}$ we can write
$P(X|Z) = P(X|Y)P(Z|Y)\frac{P(Y)}{P(Z)} = \delta_{xy}\delta_{zy}\frac{P(Y)}{P(Z)} = \delta_{xz}\frac{P(Y)}{P(Z)}$
Here you can see that $P(X|Z)$ depends on $Z$ and therefore $X$ is dependent on $Z$
A: To prove the statement on the slide, we need to combine these points:


*

*$X, Y$, and $Z$ are binary variables.

*$P(X|Y) = 1$ if $x = y$, and $0$ otherwise.

*$P(Z|Y) = 1$ if $z = y$, and $0$ otherwise.

*The Bayesian network implies $P(X,Y,Z) = P(Y)P(X|Y)P(Z|Y)$
So now let's see what we know about $P(Z|X)$. I'll look at the case $P(Z = 1 | X = 1)$ but the same algebra can be used for the other possibilities.
Using the definition of conditional probability we see 
$P(Z = 1|X = 1) = \frac{P(X = 1,Z = 1)}{P(X = 1)} = \frac{\sum_{y = 0}^1 P(X = 1,Y = y, Z = 1)}{P(X = 1)} = $
$\frac{\sum_{y = 0}^1 P(Y = y)P(X = 1|Y = y)P(Z = 1 | Y = y)}{P(X = 1)} = $
$\frac{P(Y = 0) * 0 + P(Y = 1)*1}{P(X = 1)} = \frac{P(Y = 1)}{P(X = 1)}$.
Now we can use 
$P(X = 1) = \sum_{y = 0}^1 P(X = 1 | Y = y) P(Y = y)  = $
$P(Y = 0) * 0 + P(Y = 1) * 1 = P(Y = 1)$
So we end up with the conclusion
$P(Z = 1 | X = 1) = \frac{P(Y = 1)}{P(X = 1)} = \frac{P(Y = 1)}{P(X = 1)} = \frac{P(Y = 1)}{P(Y = 1)} = 1$.
Similarly we can show $P(Z = 0|X = 0) = 1$ 
and as a consequence we get 
$P(Z = 0 | X = 1) = P(Z = 1 | X = 0) = 0$.
So we see that $X$ and $Z$ are not independent.
