Solution (source code)

= Solution

For constant coefficients, the density process $Y_tB_t/B_0$ is a true exponential martingale and defines the <risk-neutral measure> $Q$. Under $Q$,
$$
dS_t=rS_tdt+\sigma S_t dW_t^Q.
$$
The minimal value process is therefore
$$
V(t,s)=e^{-r(T-t)}
\mathbb E^Q[g(S_T)\mid S_t=s].
$$
The <Markov property> and the lognormal transition law make this a deterministic function of $(t,s)$, and
$$
\boxed{V(t,S_t)=\phi_tB_t+\pi_tS_t.}
$$