Conditional probability (example) 
Suppose that the probability of a random traffic light displaying
  light of a specific color when the previous traffic light is
  displaying the same color is $p$. The first light is red with
  probability $a$ and green with probability $1-a$. What's the
  probability of the third being green?

Let $P(X_n)$ represent the probability that the $n$-th light is displaying the color $X=R$ or $G$.
From hypothesis: 
$$P(R_2|R_1)=P(R_3|R_2)=p$$ 
$$P(R_1)=a$$
 $P(R_3)$ is needed to find $P(G_3)=1-P(R_3)$, but Bayes' theorem gives too many unknowns such as $P(R_1|R_2)$ for example. What's the right approach for this problem?
 A: Perhaps you are familiar with the notion of a probability tree, but just in case you aren't (or for anyone else reading this), I will include a brief description. If several random variables exist and we know something about their conditional probabilities, we can compute probabilities of events by a tree. In this case, we have three random variables ($C_1$, the color of the first light, $C_2$, the color of the second, $C_3$, the color of the third). We make a probability tree with four levels (where the initial level is just a trivial node, the root node). Since $C_1$ can either be red or green, there are two branches away from the root node onto the nodes $R_1$, $G_1$ on the second level. Traveling down a branch means we are realizing a particular color of the first light. 
From each of those nodes, we draw two further branches to two successor nodes ($R_2$ and $G_2$). Traveling down one of those nodes is realizing a color of the second light. Similarly, each node on the third level has two successors ($R_3$ and $G_3$) on the fourth level, corresponding to one of the two values of the third light.  
Each possible outcome corresponds to a path from the root node to one of the terminal nodes. The path from the top to the bottom using $R_1, R_2, R_3$ corresponds to the outcome $R_1\cap R_2\cap R_3$. Between the first and second levels of the trees, we put the probabilities of the two event $R_1$ and $G_1$ on the branches. The branch to $R_1$ gets probability $a$ (this is given), and the complement $G_1$ gets $1-a$. 
For the other levels of the tree, we label the branch with the conditional probability of the lower node given the upper node. For example, the branch from $R_1$ to $R_2$ is labeled with $P(R_2|R_1)=p$. 
For a particular outcome (say $R_1\cap R_2\cap R_3$), we look at the path from the top of the tree to the bottom going through the nodes $R_1, R_2, R_3$ and multiplying the numbers on the branches of the path (which are $a, p,p$). Thus $P(R_1\cap R_2\cap R_3)=ap^2$. 
Now in our tree, four of the nodes at the bottom are $G_3$, so we need to find the probability of each and add. These four nodes at the bottom labeled $G_3$ correspond to the four exclusive events $R_1\cap R_2\cap G_3$, $R_1\cap G_2\cap G_3$, $G_1\cap R_2\cap G_3$, $G_1\cap G_2\cap G_3$ (and each event corresponds to the nodes used in a path from the top to the bottom for that event). That is, the first of the four nodes labeled $G_3$ is the end result of the path using the nodes $R_1, R_2$, and $G_3$, and so that corresponds to the outcome $R_1\cap R_2\cap G_3$. 
So what we should do is for each of the four nodes labeled $G_3$, take the path from the top to that node and multiply the weights on those branches in the path. For the first node going through the nodes $R_1, R_2, G_3$, the weights on the edges down that path are $a, p, 1-p$, and so $P(R_1\cap R_2\cap G_3)=ap(1-p)$. Do the same thing for the other three nodes labeled $G_3$ and add all the results to get $P(G_3)$. 
