[proofplan]
We first prove the formula for nonnegative indicator functions from the defining property of the Radon--Nikodym derivative. Linearity then gives the formula for nonnegative simple functions, and the [monotone convergence theorem](/theorems/509) extends it to arbitrary nonnegative [measurable functions](/page/Measurable%20Functions). Finally, an integrable real-valued function is decomposed into its positive and negative parts; applying the nonnegative case to both parts proves both $\mathbb Q$-integrability of $hL$ and the stated identity.
[/proofplan]
[step:Verify the identity for indicator functions and nonnegative simple functions]
Let $A\in\mathcal S$, and let $\mathbb{1}_A:S\to\{0,1\}$ denote the indicator function of $A$. Since $L=d\mathbb P/d\mathbb Q$, the defining property of the Radon--Nikodym derivative gives
\begin{align*}
\int_S \mathbb{1}_A\,d\mathbb P(x)=\mathbb P(A)=\int_A L\,d\mathbb Q(x)=\int_S \mathbb{1}_A L\,d\mathbb Q(x).
\end{align*}
Now let $\varphi:S\to[0,\infty)$ be a nonnegative simple $\mathcal S$-measurable function. Choose $m\in\mathbb N$, coefficients $a_1,\dots,a_m\in[0,\infty)$, and sets $A_1,\dots,A_m\in\mathcal S$ such that
\begin{align*}
\varphi=\sum_{i=1}^m a_i\mathbb{1}_{A_i}.
\end{align*}
By finite linearity of the [Lebesgue integral](/page/Lebesgue%20Integral) for nonnegative simple functions and by the indicator identity just proved,
\begin{align*}
\int_S \varphi\,d\mathbb P(x)=\sum_{i=1}^m a_i\mathbb P(A_i)=\sum_{i=1}^m a_i\int_S \mathbb{1}_{A_i}L\,d\mathbb Q(x)=\int_S \varphi L\,d\mathbb Q(x).
\end{align*}
[/step]
[step:Extend the identity to nonnegative measurable functions by monotone convergence]
Let $f:S\to[0,\infty]$ be an $\mathcal S$-measurable function. By the approximation property of nonnegative measurable functions, there exists a sequence $(\varphi_n)_{n\in\mathbb N}$ of nonnegative simple $\mathcal S$-measurable functions $\varphi_n:S\to[0,\infty)$ such that $\varphi_n(x)\uparrow f(x)$ for every $x\in S$.
For each $n\in\mathbb N$, the simple-function case gives
\begin{align*}
\int_S \varphi_n\,d\mathbb P(x)=\int_S \varphi_n L\,d\mathbb Q(x).
\end{align*}
Since $L\geq 0$, the sequence $(\varphi_n L)_{n\in\mathbb N}$ is nondecreasing pointwise and converges pointwise to $fL$, with the convention $0\cdot\infty=0$. Applying the monotone convergence theorem to $(\varphi_n)$ on $(S,\mathcal S,\mathbb P)$ and to $(\varphi_nL)$ on $(S,\mathcal S,\mathbb Q)$ gives
\begin{align*}
\int_S f\,d\mathbb P(x)=\lim_{n\to\infty}\int_S \varphi_n\,d\mathbb P(x)=\lim_{n\to\infty}\int_S \varphi_nL\,d\mathbb Q(x)=\int_S fL\,d\mathbb Q(x).
\end{align*}
Thus the identity holds for every nonnegative $\mathcal S$-measurable function $f:S\to[0,\infty]$. Here we have used the monotone convergence theorem (citing a result not yet in the wiki: Monotone Convergence Theorem).
[guided]
The purpose of this step is to pass from functions with finitely many values to an arbitrary nonnegative measurable function. Let $f:S\to[0,\infty]$ be $\mathcal S$-measurable. The standard approximation theorem for nonnegative measurable functions provides a sequence $(\varphi_n)_{n\in\mathbb N}$ of nonnegative simple $\mathcal S$-measurable functions $\varphi_n:S\to[0,\infty)$ such that $\varphi_n(x)\uparrow f(x)$ for every $x\in S$.
For each $n\in\mathbb N$, the previous step applies to $\varphi_n$, so
\begin{align*}
\int_S \varphi_n\,d\mathbb P(x)=\int_S \varphi_nL\,d\mathbb Q(x).
\end{align*}
We now pass to the limit on both sides. On the $\mathbb P$ side, the functions $\varphi_n$ are nonnegative and increase pointwise to $f$, so the monotone convergence theorem gives
\begin{align*}
\lim_{n\to\infty}\int_S \varphi_n\,d\mathbb P(x)=\int_S f\,d\mathbb P(x).
\end{align*}
On the $\mathbb Q$ side, multiplication by $L\geq 0$ preserves pointwise monotonicity: for every $x\in S$, $\varphi_n(x)L(x)\leq \varphi_{n+1}(x)L(x)$. Also $\varphi_n(x)L(x)\to f(x)L(x)$ with the convention $0\cdot\infty=0$. Therefore the monotone convergence theorem applied on $(S,\mathcal S,\mathbb Q)$ gives
\begin{align*}
\lim_{n\to\infty}\int_S \varphi_nL\,d\mathbb Q(x)=\int_S fL\,d\mathbb Q(x).
\end{align*}
Combining these two limit identities with the equality already known for each $\varphi_n$ yields
\begin{align*}
\int_S f\,d\mathbb P(x)=\int_S fL\,d\mathbb Q(x).
\end{align*}
Thus the formula holds for every nonnegative measurable $f:S\to[0,\infty]$. The convergence result used here is the monotone convergence theorem (citing a result not yet in the wiki: Monotone Convergence Theorem).
[/guided]
[/step]
[step:Apply the nonnegative identity to the positive and negative parts of $h$]
Define the positive and negative parts $h^+:S\to[0,\infty)$ and $h^-:S\to[0,\infty)$ by
\begin{align*}
h^+(x)=\max\{h(x),0\},\qquad h^-(x)=\max\{-h(x),0\}.
\end{align*}
Then $h=h^+-h^-$ and $|h|=h^++h^-$. Since $h\in L^1(S,\mathcal S,\mathbb P)$,
\begin{align*}
\int_S h^+\,d\mathbb P(x)<\infty,\qquad \int_S h^-\,d\mathbb P(x)<\infty.
\end{align*}
Applying the nonnegative case to $h^+$ and $h^-$ gives
\begin{align*}
\int_S h^+L\,d\mathbb Q(x)=\int_S h^+\,d\mathbb P(x)<\infty.
\end{align*}
Similarly,
\begin{align*}
\int_S h^-L\,d\mathbb Q(x)=\int_S h^-\,d\mathbb P(x)<\infty.
\end{align*}
Therefore
\begin{align*}
\int_S |h|L\,d\mathbb Q(x)=\int_S h^+L\,d\mathbb Q(x)+\int_S h^-L\,d\mathbb Q(x)<\infty.
\end{align*}
Hence $hL\in L^1(S,\mathcal S,\mathbb Q)$. Since $hL=h^+L-h^-L$ $\mathbb Q$-a.e., subtracting the two finite identities gives
\begin{align*}
\int_S hL\,d\mathbb Q(x)=\int_S h^+L\,d\mathbb Q(x)-\int_S h^-L\,d\mathbb Q(x)=\int_S h^+\,d\mathbb P(x)-\int_S h^-\,d\mathbb P(x)=\int_S h\,d\mathbb P(x).
\end{align*}
This is the desired importance sampling identity.
[/step]