Sum rule of probability applied to a conditional probability x is a binary variable that follows a Bernoulli distribution of parameter $\mu$ . In a demonstration I see this equality :
$$
\mathsf p(x=1|D) = \int_{0}^{1} p(x=1 | \mu) p(\mu | D) d\mu
$$
I don't really understand how to apply the sum rule of probability to get this result. Could you help me ?
 A: A previous answer had the main ideas using shorthand notation. That answer also emphasized that an additional assumption about conditional independence is needed.   That answer was deleted. I will give an alternative derivation that is a bit longer.

Preliminary facts: Let $A$ and $D$ be events with positive probability. Let $X$ be a continuous random variable with density $f_X(x)$.  Then
\begin{align}
1. &P[A|X=x] = \frac{f_{X|A}(x)P[A]}{f_X(x)}\quad \mbox{(assuming $f_X(x)>0$)} \\
2. &P[A] = \int_{-\infty}^{\infty} P[A|X=x]f_X(x)dx\\
3. &P[A|D] = \int_{-\infty}^{\infty} P[A|X=x, D]f_{X|D}(x)dx 
\end{align}
Fact 3 is a conditioned version of Fact 2. Intuitively, Fact 3 holds because a conditional probability measure, given $D$, is still a valid probability measure.

Let $M$ be a continuous random variable that determines the probability that $X=1$:
$$ P[X=1|M=\mu] = \mu \quad \forall \mu \in [0,1]$$
Method 1 (Using fact 3):
$$P[X=1|D] = \int_0^1 P[X=1|M=\mu, D]f_{M|D}(\mu)d\mu$$
This is as far as we can go.  But if we know that the events $\{X=1\}$ and $D$ are conditionally independent given $M$, then
$$ P[X=1|M=\mu, D] = P[X=1|M=\mu] \quad \forall \mu \in [0,1]$$
and we get the desired result
$$ P[X=1|D] = \int_0^1 P[X=1|M=\mu]f_{M|D}(\mu)d\mu$$
Method 2 (Using only facts 1 and 2):
We have
\begin{align}
P[X=1|D] &\overset{(a)}{=} \frac{P[\{X=1\}\cap D]}{P[D]}\\
&\overset{(b)}{=}\frac{1}{P[D]}\int_0^1 P[\{X=1\}\cap D|M=\mu]f_M(\mu)d\mu\\
\end{align}
where (a) holds by definition of conditional probability; (b) holds by Fact 2. This is as far as we can go. But if we know that $\{X=1\}$ and $D$ are conditionally independent given $M$ then
$$P[\{X=1\}\cap D| M=\mu] = P[X=1|M=\mu]P[D|M=\mu]$$
and so
\begin{align}
P[X=1|D] &= \frac{1}{P[D]}\int_0^1 P[X=1|M=\mu]P[D|M=\mu]f_M(\mu)d\mu\\
&= \int_0^1 P[X=1|M=\mu] \left(\frac{P[D|M=\mu]f_M(\mu)}{P[D]}\right)d\mu\\
&=\int_0^1 P[X=1|M=\mu] f_{M|D}(\mu)d\mu
\end{align}
where the last equality uses Fact 1.
