[proofplan]
We first check that the Brownian exit expectation is meaningful: boundedness of $U$ forces finite exit time almost surely, and the killing factor is bounded by one because $q\ge0$. We then prove uniqueness of bounded classical solutions by the elliptic maximum principle. For the representation, we stop [Brownian motion](/page/Brownian%20Motion) in compact subdomains of $U$, apply [Itô's formula](/theorems/2099) to the killed process $\exp(-\int q)\,v(W)$ only up to those stopping times, and use the PDE to cancel the drift. Passing first to the boundary and then to infinite time identifies the classical solution with the probabilistic formula.
[/proofplan]
[step:Verify that the exit expectation is well-defined]
Fix $x\in U$. Since $U$ is bounded, choose $R>0$ such that $U\subset B(0,R)$. If $\tau_U=\infty$, then $W_t\in U\subset B(0,R)$ for every $t\ge0$. Hence, for each $t>0$,
\begin{align*}
\mathbb P^x(\tau_U=\infty)\le \mathbb P^x(W_t\in B(0,R)).
\end{align*}
The random vector $W_t$ has density
\begin{align*}
y\mapsto \frac{1}{(2\pi t)^{n/2}}\exp\left(-\frac{|y-x|^2}{2t}\right)
\end{align*}
with respect to $\mathcal L^n$, so
\begin{align*}
\mathbb P^x(W_t\in B(0,R))
=\int_{B(0,R)}\frac{1}{(2\pi t)^{n/2}}\exp\left(-\frac{|y-x|^2}{2t}\right)\,d\mathcal L^n(y)
\le \frac{\mathcal L^n(B(0,R))}{(2\pi t)^{n/2}}.
\end{align*}
Letting $t\to\infty$ gives $\mathbb P^x(\tau_U=\infty)=0$.
Because Brownian paths are continuous and $U$ is open, $W_{\tau_U}\in\partial U$ almost surely. Since $f$ is continuous on the compact set $\partial U$, there is a constant $M_f\ge0$ such that
\begin{align*}
|f(y)|\le M_f\qquad\text{for every }y\in\partial U.
\end{align*}
The integral
\begin{align*}
\int_0^{\tau_U}q(W_s)\,d\mathcal L^1(s)
\end{align*}
uses only times $s<\tau_U$ up to a $\mathcal L^1$-null endpoint, and for those times $W_s\in U$, so $q(W_s)$ is defined. Since $q\ge0$,
\begin{align*}
0\le \exp\left(-\int_0^{\tau_U}q(W_s)\,d\mathcal L^1(s)\right)\le1.
\end{align*}
Therefore
\begin{align*}
f(W_{\tau_U})\exp\left(-\int_0^{\tau_U}q(W_s)\,d\mathcal L^1(s)\right)
\end{align*}
is a bounded measurable random variable, and its expectation is well-defined.
[/step]
[step:Prove uniqueness by the elliptic maximum principle]
Let $v_1,v_2\in C(\overline U)\cap C^2(U)$ be bounded classical solutions with the same boundary data, and define
\begin{align*}
h:\overline U&\to\mathbb R\\
y&\mapsto v_1(y)-v_2(y).
\end{align*}
Then $h\in C(\overline U)\cap C^2(U)$, $h=0$ on $\partial U$, and
\begin{align*}
-\frac12\Delta h+qh=0\qquad\text{in }U.
\end{align*}
The [Weak Maximum Principle for Elliptic Operators](/theorems/100) applies to the operator $Lh=-\frac12\Delta h+qh$: the domain is bounded, the principal coefficient matrix is $\frac12 I_n$, which is uniformly elliptic, and the zeroth-order coefficient $q$ is non-negative. Hence
\begin{align*}
\sup_{\overline U}h\le \sup_{\partial U}h=0.
\end{align*}
Applying the same maximum principle to $-h$ gives
\begin{align*}
\sup_{\overline U}(-h)\le \sup_{\partial U}(-h)=0.
\end{align*}
Thus $h\le0$ and $h\ge0$ on $\overline U$, so $h=0$. Therefore the bounded classical solution is unique if it exists.
[/step]
[step:Stop inside the domain and cancel the killed drift]
Fix $x\in U$, and let $v\in C(\overline U)\cap C^2(U)$ be the bounded classical solution from the hypothesis. For each sufficiently large $k\in\mathbb N$ with $x\in U_k$, define
\begin{align*}
U_k:=\{y\in U:\operatorname{dist}(y,\partial U)>1/k\}
\end{align*}
and the interior exit time
\begin{align*}
\tau_k:\Omega&\to[0,\infty]\\
\omega&\mapsto \inf\{t\ge0: W_t(\omega)\notin U_k\}.
\end{align*}
The sets $U_k$ increase to $U$, and continuity of Brownian paths gives $\tau_k\uparrow\tau_U$ almost surely.
For $t\ge0$, define the stopped killing functional
\begin{align*}
A_{k,t}:\Omega&\to[0,\infty)\\
\omega&\mapsto \int_0^{t\wedge\tau_k(\omega)}q(W_s(\omega))\,d\mathcal L^1(s).
\end{align*}
This definition only evaluates $q$ while $W_s\in U_k\subset U$. Fix $T>0$. Since $\overline{U_k}$ is compactly contained in $U$, the functions $v$, $\nabla v$, $\Delta v$, and $q$ are bounded on $\overline{U_k}$. Choose an open set $V_k$ with $\overline{U_k}\subset V_k\Subset U$. A $C^2$ extension of $v|_{V_k}$ to $\mathbb R^n$ agrees with $v$ on $V_k$, so [Itô's Formula](/theorems/2099) applies to the stopped path up to $\tau_k$.
Define
\begin{align*}
Y_{k,t}:\Omega&\to\mathbb R\\
\omega&\mapsto \exp(-A_{k,t}(\omega))\,v(W_{t\wedge\tau_k(\omega)}(\omega)).
\end{align*}
The finite-variation product rule and [Itô's formula](/theorems/2099) give, for $0\le t\le T$,
\begin{align*}
Y_{k,t}
=v(x)
&+\int_0^{t\wedge\tau_k}\exp(-A_{k,s})\nabla v(W_s)\cdot dW_s\\
&+\int_0^{t\wedge\tau_k}\exp(-A_{k,s})
\left(\frac12\Delta v(W_s)-q(W_s)v(W_s)\right)\,d\mathcal L^1(s).
\end{align*}
For $s<\tau_k$, the point $W_s$ lies in $U$, and the PDE gives
\begin{align*}
\frac12\Delta v(W_s)-q(W_s)v(W_s)=0.
\end{align*}
Therefore
\begin{align*}
\exp(-A_{k,t})v(W_{t\wedge\tau_k})
=v(x)+\int_0^{t\wedge\tau_k}\exp(-A_{k,s})\nabla v(W_s)\cdot dW_s.
\end{align*}
The stopped integrand is bounded and progressively measurable on $[0,T]$, so the stochastic integral is a square-integrable martingale with expectation zero. Taking expectations at $t=T$ yields
\begin{align*}
v(x)=\mathbb E^x\left[\exp(-A_{k,T})v(W_{T\wedge\tau_k})\right].
\end{align*}
[/step]
[step:Pass to the boundary and then to infinite time]
First let $k\to\infty$ in
\begin{align*}
v(x)=\mathbb E^x\left[\exp(-A_{k,T})v(W_{T\wedge\tau_k})\right].
\end{align*}
Since $\tau_k\uparrow\tau_U$ almost surely, the stopped times $T\wedge\tau_k$ converge to $T\wedge\tau_U$. Continuity of Brownian paths and continuity of $v$ on $\overline U$ give
\begin{align*}
v(W_{T\wedge\tau_k})\to v(W_{T\wedge\tau_U})
\end{align*}
almost surely. Also
\begin{align*}
A_{k,T}
=\int_{[0,T]}\mathbb{1}_{[0,\tau_k]}(s)q(W_s)\,d\mathcal L^1(s).
\end{align*}
The integrand converges pointwise $\mathcal L^1$-almost everywhere to $\mathbb{1}_{[0,\tau_U]}(s)q(W_s)$ and is bounded by $\|q\|_\infty$. The [Dominated Convergence Theorem](/theorems/4) gives
\begin{align*}
A_{k,T}\to A_{U,T}:=\int_{[0,T\wedge\tau_U]}q(W_s)\,d\mathcal L^1(s)
\end{align*}
almost surely. Since the random variables inside the expectations are bounded by $\|v\|_\infty$, another application of the [Dominated Convergence Theorem](/theorems/4) yields
\begin{align*}
v(x)=\mathbb E^x\left[\exp(-A_{U,T})v(W_{T\wedge\tau_U})\right].
\end{align*}
Now let $T\to\infty$. The first step gives $\tau_U<\infty$ almost surely. Hence $T\wedge\tau_U\to\tau_U$,
\begin{align*}
W_{T\wedge\tau_U}\to W_{\tau_U},
\end{align*}
and
\begin{align*}
A_{U,T}\to \int_0^{\tau_U}q(W_s)\,d\mathcal L^1(s)
\end{align*}
almost surely. The integrand in the expectation remains bounded by $\|v\|_\infty$, so the [Dominated Convergence Theorem](/theorems/4) gives
\begin{align*}
v(x)
&=\mathbb E^x\left[
\exp\left(-\int_0^{\tau_U}q(W_s)\,d\mathcal L^1(s)\right)v(W_{\tau_U})
\right]\\
&=\mathbb E^x\left[
f(W_{\tau_U})\exp\left(-\int_0^{\tau_U}q(W_s)\,d\mathcal L^1(s)\right)
\right],
\end{align*}
because $W_{\tau_U}\in\partial U$ almost surely and $v=f$ on $\partial U$.
[/step]
[step:Conclude regularity and uniqueness of the probabilistic formula]
The previous step proves that the probabilistically defined function $u$ agrees with the classical solution $v$ at every $x\in U$. On $\partial U$, both functions equal $f$ by definition. Therefore
\begin{align*}
u=v\qquad\text{on }\overline U.
\end{align*}
Since $v\in C(\overline U)\cap C^2(U)$, the same regularity holds for $u$. The uniqueness step shows that no other bounded classical solution with boundary data $f$ can exist, so $u$ is the unique bounded classical solution.
[/step]