Solution (source code)

= Solution

The <Kolmogorov axioms> for a <probability measure> $\mathbb P$ are nonnegativity, normalization $\mathbb P(\Omega)=1$, and <countable additivity> on pairwise disjoint events. For $\mathbb P(B)>0$, <conditional probability> is defined by
$$
\mathbb P(A\mid B)=\frac{\mathbb P(A\cap B)}{\mathbb P(B)}.
$$
Because the events $A\cap B_i$ are pairwise disjoint and their union is $A$, countable additivity gives the <law of total probability>
$$
\mathbb P(A)=\sum_{i=1}^{\infty}\mathbb P(A\cap B_i)
=\sum_{i=1}^{\infty}\mathbb P(A\mid B_i)\mathbb P(B_i).
$$
For any $j$ with $\mathbb P(A)>0$, the definition of conditional probability and this identity give <Bayes' theorem>:
$$
\boxed{\mathbb P(B_j\mid A)=
\frac{\mathbb P(A\mid B_j)\mathbb P(B_j)}
{\sum_i\mathbb P(A\mid B_i)\mathbb P(B_i)}}.
$$