Semimartingale property of function of Brownian motion

I have stumbled upon the exercise in Jean-François Le Gall's book. I would be highly thankful for any comments:

Let $f$ be twice differentable and $g$ be a continuos function. Verify that the process $X_t=f(B_t)\exp\left(-\int_0^t g(B_s)ds\right)$ is a a sum of local martingale and finite variation process (i.e. semimartingale) and prove that $X$ is a local martingale if and only if $f$ satisfies $$f''=2gf$$

I tried to solve it in special case $g(x)=x$. Rewrite $X_t=f(B_t)\exp(-Y_t)$ where $Y_t= \int_0^t g(B_s)ds$. By Itô's formula $X_t$ is indeed a semimartingale and admits the following decomposition as a sum of local martingale and finite variation process: $$X_t=X_0+\int_{0}^{t}f'(B_s)\exp(-Y_s)dB_s-\int_0^tf(B_s)\exp(-Y_s)dY_s+$$ $$+\frac{1}{2}\left[\int_0^t f''(B_s)\exp(-Y_s)d\langle B,B\rangle_s + f'(B_s)\exp(-Y_s)d\langle B,Y\rangle_s-f(B_s)\exp(-Y_s)d\langle B,Y\rangle_s+f(B_s)\exp(-Y_s)d\langle Y,Y\rangle_s\right]$$

After some computations we come to (here I want to thank user Did for point out the fatal error) $$\langle B,Y\rangle_s=0.$$ $$\langle Y,Y\rangle_s=0.$$ and of course $\langle B,B\rangle_s=s$ and importantly (thanks again for Did to pointing this out) $dY_s=d\int_0^tg(B_s)ds=B_tdt$ therefore substituting everything back to the decomposition of $X_t$ we have $$X_t=X_0+\int_{0}^{t}f'(B_s)\exp(-Y_s)dB_s-\int_0^tf(B_s)\exp(-Y_s)B_sds +\frac{1}{2}\int_0^t f''(B_s)\exp(-Y_s)ds$$ which means that $X_t$ is a local martingale when $2f(B_s)B_s-f''(B_s)=0$ Therefore $f$ must solve differential equation $$f''(x)=2f(x)x$$

• Actually, $$\langle B,B\rangle_s=s\qquad\langle B,Y\rangle_s=\langle Y,Y\rangle_s=0$$ – Did May 31 '17 at 8:44
• Thanks a lot! I manage to derive that quadratic variation $\langle Y,Y\rangle_s$ and covariation $\langle B,Y\rangle_s$ are both zero, but this actually means that $X_t$ will be a local martingale when $f''=0$ (which again is not in line with the statement of exercise). Is exercise incorrect? – Mushtandoid May 31 '17 at 10:45
• Look better: there are two terms involved, not only the term $f''(B_s)\exp(-Y_s)d\langle B,B\rangle_s$. – Did May 31 '17 at 11:06