Conditional probability on 3 events. Say you have 3 events $A, B$, and $C$. Then you have to calculate the probability of $B$ given $A$.
The formula that the answer key states:
$$P(B|A)=P(B|A,C)P(C) + P(B|A,C^\complement)P(C^\complement)$$
I understand that for just two events $B$ and $A$ it is:
$$P(B)=P(B|A)P(A) + P(B|A^\complement)P(A^\complement)$$
How do you derive the first formula?

Sometimes it's easier to work with intersections rather than conditionals. The key formula here is that $$ P(A)  = P(A\cap B)+P(A\cap B^c)$$ which follows from the fact that $A = (A\cap B)\cup(A\cap B^c)$ and $(A\cap B)\cap(A\cap B^c) = \emptyset$ and that disjoint unions are additive. The second formula that you write down is just this with the definition of conditional probability $P(A|B) = P(A\cap B)/P(B)$ used on the RHS.
So you can write $$ P(A\cap B) = P(A\cap B\cap C)+P(A\cap B\cap C^c) $$ and by definition of conditional probability, $$ P(B\mid A)P(A) = P(B\mid A\cap C)\,P(A\cap C) + P(B\mid A\cap C^c)\,P(A\cap C^c)$$
and dividing both sides by $P(A)$ and using the definition again. $$ P(B\mid A) = P(B\mid A\cap C)\,P(C\mid A)+P(B\mid A\cap C^c)\,P(C^c\mid A).$$
It appears that your first formula only applies to when $C$ and $A$ are independent so that $P(C\mid A) = P(C)$ and $P(C^c\mid A)=P(C^c).$ So unless that's an assumption of the problem, the formula is wrong.
