Solution (source code)

= Solution

For Brownian motion started at $x\in D$, the <Itô formula> and $\Delta u=0$ show that
$$
u(B_{t\wedge\tau})
$$
is a local martingale. Since $D$ is bounded and $u$ is continuous on the compact set $\overline D$, the stopped process is bounded and hence a true martingale. Brownian motion exits every bounded domain almost surely, so $t\wedge\tau\to\tau$. The <dominated convergence theorem>, continuity at the boundary, and $u=f$ on $\partial D$ give the <Brownian representation of the Dirichlet problem>
$$
u(x)=\mathbb E_xu(B_{t\wedge\tau})
\longrightarrow\mathbb E_xu(B_\tau)
=\mathbb E_xf(B_\tau).
$$