Suppose we are holding a replicating portfolio $\Pi_t$ of long an option $f(S,t)$ and short some stock, so $$\Pi_t=f(S_t,t)-\Delta_t S_t$$ Suppose the stock follows geometric Brownian motion and pays continuous dividends at rate $q$, so $$d S_t = S_t((\mu-q)dt + \sigma dW_t$$ Naively, $$d\Pi_t = d f(S_t,t)-\Delta_t dS_t$$ However, because the stock pays a dividend, common sense and the literature tell us that $$d\Pi_t=df(S_t,t)-\Delta_t dS_t-\Delta_t S_t dt$$
Question: How do we rigorously arrive at the total derivative for $d\Pi_t$ which includes extra term $-\Delta_t S_t dt$, given that we know $\Pi_t=f(S_t,t)-\Delta_t S_t$, without appeal to common sense i.e., from the equations, without recalling the mechanics of how the stock works? Because, naively, I would not include the extra term, if I just knew the equation defining $\Pi_t$ and nothing about the mechanics of the stock.