A person makes first turn at $X$, then $Y$, then $Z$. Turning Right gives value$ =1$ and Turning left gives a value $= 0.$ What conditional distribution would you require in order to give you the probability that a person turned right at X given that they had turned left at Z? Express this conditional distribution in terms of $p(X = x), p(Y = y|X = x)$ and $p(Z = z|X = x, Y = y)$.
Here's what i managed to do so far:
$p(X = x|Z = z) = $$\sum_{y} p(X = x, Y = y|Z = z)$= $\sum_{y} p(X = x, Y = y, Z = z)/p(Z = z)$$
$=1/p(Z = z) \sum_{y} p(X = x)p(Y = y|X = x)p(Z = z|X = x, Y = y)$
and i found $p(Z=z)= \sum_{x} \sum_{y} p(X = x)p(Y = y|X = x)p(Z = z|X = x, Y = y)$
so i got:$$(\sum_{y} p(X = x)p(Y = y|X = x)p(Z = z|X = x, Y = y))/ (\sum_{x} \sum_{y} p(X = x)p(Y = y|X = x)p(Z = z|X = x, Y = y))$$
I'm not sure if i'm correct and i don't know how to cancel out the terms(the summations if possible). Would really appreciate the help.
You're correct:
The first equality holds by the law of total probability, and the second by the definition of conditional probability.
The third holds by pulling the $\frac 1 {P(Z= z)}$ out of the summation, and replacing $P(X = x, Y = y, Z = z)$ with $P(Z = z|X = x, Y = y)P(Y = y, X = x)$ and replacing that last $P(Y = y, X = x)$ with $P(X = x)P(Y = y | X = x)$. Both these replacements are again the definition of conditional probability.
Your expression for $P(Z= z)$ is obtained by the same principles.
As for cancellation the numerator has two terms in it (for the two values $Y$ can take on), and the denominator has 4 terms in it, given by the four combinations of values $X$ and $Y$ can take on, but because of the extra two terms in the denominator, cancellation cannot be done in general (unless you have some more information about the problem).