I am stuck on a problem on page 242 of Arnold's book "Mathematical Methods of Classical Mechanics". The problem statement is as follows:
Let $g(t): \mathbb{R}^{2 n} \rightarrow \mathbb{R}^{2 n}$ be a canonical transformation of phase space depending on the parameter $t$, giving new coordinates $\mathbf{P}$ and $\mathbf{Q}$ defined by $$g(t)(\mathbf{p}, \mathbf{q})=(\mathbf{P}(\mathbf{p}, \mathbf{q}, t), \mathbf{Q}(\mathbf{p}, \mathbf{q}, t)).$$ Show that in the variables $\mathbf{P}, \mathbf{Q}, t$ the canonical equations (Hamilton's equations) have the canonical form with new hamiltonian function $$ K(\mathbf{P}, \mathbf{Q}, t)=H(\mathbf{p}, \mathbf{q}, t)+\frac{\partial S}{\partial t} $$ where $$ S\left(\mathbf{p}_{1}, \mathbf{q}_{1}, t\right)=\int_{\mathbf{p}_{0}, \mathbf{q}_{0}}^{\mathbf{p}_{1}, \mathbf{q}_{1}} \mathbf{p} d \mathbf{q}-\mathbf{P} d \mathbf{Q} \quad(d \mathbf{Q} \text { for fixed } t). $$
The problem is a generalisation of the previous theorem so the solution should follow similarly to its proof. There we instead had a map $g: \mathbb{R}^{2 n} \rightarrow \mathbb{R}^{2 n}$, so $g(t)$ but at some fixed time. It was found that due to $g$ being canonical $$ S\left(\mathbf{p}_{1}, \mathbf{q}_{1}\right):=\int_{\mathbf{p}_{0}, \mathbf{q}_{0}}^{\mathbf{p}_{1}, \mathbf{q}_{1}} \mathbf{p} d \mathbf{q}-\mathbf{P} d \mathbf{Q} $$ is well defined giving the differential form $dS = \mathbf{p}d\mathbf{q}- \mathbf{P}d\mathbf{Q}$. This can be extended to $\mathbb{R}^{2n+1}$, so that we have the relation $$\mathbf{p}\,d\mathbf{q}-H\,dt = \mathbf{P}d\mathbf{Q}-H\,dt+dS.$$ Then by a corollary on the previous page we see that in the coordinates $(\mathbf{P}, \mathbf{Q})$ the canonical equations have the canonical form $$ \frac{d \mathbf{P}}{d t}=-\frac{\partial K}{\partial \mathbf{Q}} \quad \frac{d \mathbf{Q}}{d t}=\frac{\partial K}{\partial \mathbf{P}} $$ with hamiltonian function: $K(\mathbf{P}, \mathbf{Q}, t)=H(\mathbf{p}, \mathbf{q}, t)$.
All of this would carry over to the problem with $g(t)$ except that $S$ depends on time so in the exterior derivative on $\mathbb{R}^{2n+1}$ we have $$dS = \mathbf{p}d\mathbf{q}- \mathbf{P}d\mathbf{Q}+\frac{\partial S}{\partial t}dt.$$ My problem with this is that it seems that the same is true for $\mathbf{Q}(\mathbf{p},\mathbf{q},t)$ so this should instead read $$dS = \mathbf{p}d\mathbf{q}- \mathbf{P}\left(d\mathbf{Q}-\frac{\partial\mathbf{Q}}{\partial t}dt\right)+\frac{\partial S}{\partial t}dt.$$ Why is the latter incorrect while the former is correct (giving the required solution)?