Let X,Y denote the number of heads in the first and last two flips separately, and Z be the indicator random variable of the second flip. Given a fair coin and independently flip it three times.
\begin{equation} X = \begin{cases} 0 & \text{if there are 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} \begin{equation} Y = \begin{cases} 0 & \text{if there are no heads in the last two flips}\\ 1 & \text{if there is exactly one head in the last two flips}\\ 2 & \text{if there is exactly two heads in the last two flips} \end{cases} \end{equation} \begin{equation} Z = \begin{cases} 1 & \text{if the second flip is H}\\ 0 & \text{if the second flip is T}\\ \end{cases} \end{equation}
Show that, X is not independent to Y, but X and Y are conditionally independent given Z.
My attempt:
To show that X is not independent to Y is easy. We can take the case where $\{x,y\}=\{0,0\}$. Then we have that $$\mathbb{P}(X=0)\cdot\mathbb{P}(Y=0)=\frac{1}{4}\cdot\frac{1}{4}=\frac{1}{16}\neq\frac{1}{8}=\mathbb{P}(X\cap Y)$$
To prove that X and Y are conditionally independent given Z, I was thinking that we need to show that $\mathbb{P}(X=x|Z=z)\mathbb{P}(Y=y|Z=z)=\mathbb{P}(X=x,Y=y|Z=z)$ is true for all combinations of x,y,z. However, this would result in showing the equality is true $3\cdot3\cdot2=18$ times, which seems like a lot of work. Is there a more efficient way of showing this independence? Thank you.
Hint: When given the count for heads in the middle coin, the count for heads in the first and last two coins are each determined by the count for heads in the first and last coin, respectively, -- which are independent.
Let $U$ and $V$ be these counts, and so we have: $X=U+Z$ and $Y=V+Z$.
Thus $U,V,Z\overset{iid}\sim\mathcal U[0,1]$ and taking any $i,j,k$ from $\{0,1\}$, you may show: $$\mathsf P(X{=}i{+}k, Y{=}j{+}k\mid Z{=}k)=\mathsf P(X{=}i{+}k\mid Z{=}k)\mathsf P(Y{=}j{+}k\mid Z{=}k)$$