Solution (source code)

= Solution
{c}

If the barrier is reached, path <continuity> gives $S_{\tau_B}=B$ and the early payment is $K-B$. If it is not reached, the terminal payment is exactly the <down-and-out put> payoff. When $r=0$, moving a fixed payment from the hitting time to expiry does not change its value. Hence the <barrier-triggered put> price is
$$
\boxed{E_B(S,t)=G(S,t)+(K-B)H(t,S),\qquad r=0.}
$$
Here $G,H$ are evaluated with zero interest rate. If the barrier has already been hit, the exploding put has been exercised and has no remaining value after its payment; the displayed replication concerns an initially alive contract and its cash flows.