Solution (source code)

= Solution

Let $p_0=\Pr(\theta\in\Theta_0)$ and $p_1=1-p_0$, assuming both are positive. The <prior odds> are $\alpha=p_0/p_1$. Given data $x$, the <posterior odds> are
$$
O_{01}(x)=\frac{\Pr(H_0\mid x)}{\Pr(H_1\mid x)}.
$$
With conditional joint <likelihood> $L(\theta;x)=\prod_i f(x_i\mid\theta)$, define the hypothesis-conditional marginal densities
$$
m_0(x)=\frac1{p_0}\int_{\Theta_0}L(\theta;x)\,\pi(d\theta),\qquad
m_1(x)=\frac1{p_1}\int_{\Theta\setminus\Theta_0}L(\theta;x)\,\pi(d\theta).
$$
The <Bayes factor> for $H_0$ relative to $H_1$ is $B=m_0(x)/m_1(x)$. The normalizations $p_0,p_1$ matter: the <prior distribution> within each hypothesis must have total probability one. <Bayes' theorem> now gives
$$
O_{01}(x)=\frac{p_0m_0(x)}{p_1m_1(x)}=\alpha B.
$$
Converting <posterior odds> to <posterior probability> therefore gives
$$
\boxed{\Pr(H_0\mid x)=\frac{\alpha B}{1+\alpha B}.}
$$