Solution (source code)

= Solution

For <events> $A_n$, define their <limit superior> by
$$
A_\infty=\limsup_n A_n=\bigcap_{N\geq1}\bigcup_{n\geq N}A_n.
$$
It is the <event> that infinitely many $A_n$ occur. The two <Borel-Cantelli lemmas> are as follows: if $\sum_n\mathbb P(A_n)<\infty$, then $\mathbb P(A_\infty)=0$, without any independence assumption; if the $A_n$ are independent and $\sum_n\mathbb P(A_n)=\infty$, then $\mathbb P(A_\infty)=1$.

For the first assertion, the <union bound> gives, for every $N$,
$$
\mathbb P(A_\infty)\leq\mathbb P\!\left(\bigcup_{n\geq N}A_n\right)
\leq\sum_{n\geq N}\mathbb P(A_n).
$$
The tail of a convergent nonnegative <series> tends to zero, proving the first <Borel-Cantelli lemma>.

For the second assertion, independence and $1-u\leq e^{-u}$ for $0\leq u\leq1$ give
$$
\mathbb P\!\left(\bigcap_{n=N}^K A_n^c\right)
=\prod_{n=N}^K(1-\mathbb P(A_n))
\leq\exp\!\left(-\sum_{n=N}^K\mathbb P(A_n)\right)\longrightarrow0.
$$
By <continuity of probability>, $\mathbb P(\bigcap_{n\geq N}A_n^c)=0$. The <event> that only finitely many $A_n$ occur is the countable <union> of these zero-probability <events> over $N$. Its <probability> is zero. This proves the second <Borel-Cantelli lemma>, and hence both requested assertions:
$$
\boxed{\sum_n\mathbb P(A_n)<\infty\Rightarrow\mathbb P(A_\infty)=0,\qquad
\text{independence and }\sum_n\mathbb P(A_n)=\infty\Rightarrow\mathbb P(A_\infty)=1.}
$$