Solution (source code)

= Solution

A <large deviation principle> for random elements $X^L$ in a <Hausdorff space> $E$, at <large-deviation speed> $a_L\to\infty$, has a <lower semicontinuous> <rate function> $I:E\to[0,\infty]$. For every <open set> $G$ and every <closed set> $F$,
$$
-\inf_G I\le\liminf_L\frac1{a_L}\log\mathbb P(X^L\in G),
\qquad
\limsup_L\frac1{a_L}\log\mathbb P(X^L\in F)\le-\inf_F I.
$$
Equivalently, for every <Borel set> $A$, the lower and upper bounds use its <interior> and <closure>, respectively. The conventions are $\inf\varnothing=+\infty$ and $\log0=-\infty$. A <good rate function> has <compact sublevel sets> $\{I\le r\}$ for every finite $r$. Here take $a_L=L$; the different speeds in the <moderate deviation principle> are stated explicitly when used.