Conditional Probability Question from Prob and Stats by Example - Suhov and Kelbert The following question is taken from Probability and Statistics by example by Yuri Suhov and Mark Kelbert.
Problem 1.9 At the station there are three payphones which accept 20p pieces. One
never works, another always works, while the third works with probability $1/2$. On my
way to the metropolis for the day, I wish to identify the reliable phone, so that I can use
it on my return. The station is empty and I have just three 20p pieces. I try one phone
and it does not work. I try another twice in succession and it works both times. What is
the probability that this second phone is the reliable one?
The initial part of the solution is as follows:
Solution Let $A$ be the even in question: the first phone tried did not work and second worked twice. Clearly:
$$ \mathbb{P}(A | \text{1st reliable}) = 0 $$
$$\mathbb{P}(A | \text{2nd reliable}) = \mathbb{P}(\text{1st never works} | \text{2nd reliable}) +\frac{1}{2}\mathbb{P}(\text{1st works half-time}|\text{2nd reliable})$$
...
I understand intuitively why the first line holds - clearly the first reliable contradicts it ever failing. However, I do not understand the second line or where it has come from. 
Any help would be appreciated!
 A: It is the Law of Total Probability: 
Let $N=n$ be the event for phone#$n$ never working, $H=n$ that it works half-times, and $R=n$ that it is always reliable.   (For $n\in\{1,2,3\}$ of course).   Note: Since the first cannot be reliable when the second is, therefore events $N=1,H=1$ partition $R=2$.
Take $A$: as the event for the data, "first did not work and second worked twice".   Now, the probability that this happens when the first never works and the second is reliable is $1$.   Whereas the probability for this when given the first is half reliable and the second is reliable is $1/2$.
$$\begin{split}\mathsf P(A\mid R{=}2) &=\mathsf P(A,N{=}1\mid R{=}2)+\mathsf P(A,H{=}1\mid R{=}2)\\ &=\mathsf P(A\mid R{=}2,N{=}1)\mathsf P(N{=}1\mid R{=}2)+\mathsf P(A\mid R{=}2,H{=}1)\mathsf P(H{=}1\mid R{=}2)\\&= \mathsf P(N{=}1\mid R{=}2)+\tfrac 12\mathsf P(H{=}1\mid R{=}2)\\&=\tfrac 12+\tfrac 12\tfrac 12\\&=\tfrac 34\end{split}$$
Similarly, and can you see why?
$$\begin{split}\mathsf P(A\mid R{=}3)&=\mathsf P(A\mid R{=}3,N{=}1,H{=}2)\mathsf P(N{=}1\mid R{=}3)+\mathsf P(A\mid R{=}3,H{=}1,N{=}2)\mathsf P(H{=}1\mid R{=}3)\\&= \tfrac 14\mathsf P(N{=}1\mid R{=}3)+0\mathsf P(H{=}1\mid R{=}3)\\&=\tfrac 18\end{split}$$
And as you already stated: $\mathsf P(A\mid R{=}1)=0$... because the data can never happen when the first phone is reliable.
So again by the Law of Total Probability, the (prior) proability for the data is:$$\begin{split}\mathsf P(A)&=\mathsf P(A\mid R{=}1)\mathsf P(R{=}1)+\mathsf P(A\mid R{=}2)\mathsf P(R{=}2)+\mathsf P(A\mid R{=}3)\mathsf P(R{=}3) \\ &=0+\tfrac 34\tfrac 13+\tfrac 18\tfrac 13\\&=\tfrac 7{24}\end{split}$$
A: Let $H,D,W$ be "half-work", "does not work" and "work" phones, respectively. 
Also, let "$X,Y$" be "not work" and "work", respectively. 
Refer to the probability tree diagram:

The required probability is:
$$\frac{\frac1{12}+\frac16}{\frac1{12}+\frac1{24}+\frac16}=\frac67.$$
A: I tried to follow the first answer but I'm not getting it. For example: trying to see how to calculate $ P(A\mid R{=}2)$ should consider getting the outcome A versus any other outcome when $R=2$. That is $0,1,1$ outcomes versus the only other possible $1,1,1$ outcome where $0$ is a failure and $1$ a success. For N(never) H(half) and R(reliable), the phone configurations are $1 3 2$ and $3 1 2$. 
Update: Ok, now I get it.

From the above table my answer is  $$P(A\mid R{=}2)= \frac{1+\frac{1}{2}}{1+\frac{1}{2}+\frac{1}{2}} = \frac{3}{4}$$
