Show that X and Y given Z are not conditionally independent. Given a fair coin and independently flip it three times.
\begin{equation}
  X =
    \begin{cases}
      1\;\text{if the first flip is H}\\
      0\;\text{if the first flip is T}\\
    \end{cases},\;\;\;
Y =
    \begin{cases}
      1\;\text{if the second flip is H}\\
      0\;\text{if the second flip is T}\\
    \end{cases}      
\end{equation}
\begin{equation}
 Z=
    \begin{cases}
      0\;\text{if there is no heads in the first two flips}\\
      1\;\text{if there is exactly one head in the first two flips}\\
2\;\text{if there is exactly two heads in the first two flips}
    \end{cases}  
\end{equation}
Show that X and Y are not conditionally independent given
Z.
My attempt:
\begin{align*}
            \mathbb{P}(X=x\;|\;Z=z)&=\mathbb{P}(X=0\;|\;Z=0)+\mathbb{P}(X=0\;|\;Z=1)+\mathbb{P}(X=0\;|\;Z=2)\\
            &+\mathbb{P}(X=1\;|\;Z=0)+\mathbb{P}(X=1\;|\;Z=1)+\mathbb{P}(X=1\;|\;Z=2)\\
            &=1+\frac{1}{2}+0+0+\frac{1}{2}+1=3
        \end{align*}
Same process for Y and Z. My concern is that the probability for $\mathbb{P}(X=x\;|\;Z=z)$ is greater than $1$, which shouldn't be the case. Can someone point out what I did wrong in this case?
After I figure out these probabilities, I can show that $$\mathbb{P}(X=x,\;Y=y\;|\;Z=z)\neq\mathbb{P}(X=x\;|\;Z=z)\mathbb{P}(Y=y\;|\;Z=z)$$
to show that they are not independent.
 A: *

*First to point out something you did. Notice your sum was 3. This suggests that there are 3 complete, well, probability spaces in there. Indeed, you can observe that $P(X=0|Z=0)+P(X=1|Z=0)=1+0=1$, $P(X=0|Z=1)+P(X=1|Z=1)=\frac 1 2+\frac 1 2=1$, and $P(X=0|Z=2)+P(X=1|Z=2)=0+1=1$. Look at it for a bit and you will see that conditioned on an event, say Z=0, you range over all the possible values of X, and they sum to 1. This happens for each possible value of Z.


*To show that X and Y are not conditionally independent given Z, it suffices to find one instance such that $P(X=x,Y=y|Z=z)\ne P(X=x|Z=z)P(Y=y|Z=z)$. Let's choose $$P(X=1,Y=1|Z=1)=0$$
compared with
$$P(X=1|Z=1)P(Y=1|Z=1)=\frac 1 2\cdot \frac 1 2=\frac 1 4$$
So X and Y are not independent given Z.

*

*Notice that if you had tried $P(X=0,Y=1|Z=0)=0,P(X=0|Z=0)P(Y=1|Z=0)=1*0=0$ you would've found equivalent evaluations of the expressions. But you can't conclude that X and Y are conditionally independent given Z because you need this to hold over all possible combinations of X=x, Y=y, Z=z.

