Generating function for canonical transformation Short version: 
I've been reading through some notes on integrable systems/Hamiltonian dynamics, and am stuck on a problem: Show that the coordinate transformation derived via the generating function method gives you a canonical transformation.
Long version: 

A coordinate change $(\vec{q},\vec{p})\to (\vec{Q},\vec{P})$ is called canonical if it leaves Hamilton's equations invariant, i.e. the equations in the original coordinates
  $$\dot{\vec{q}}=\frac{\partial H}{\partial\vec{p}},\quad \dot{\vec{p}}=-\frac{\partial H}{\partial\vec{q}}$$
  are equivalent to
  $$\dot{\vec{Q}}=\frac{\partial\tilde{H}}{\partial\vec{P}}, \quad \dot{\vec{P}}=-\frac{\partial\tilde{H}}{\partial\vec{Q}}$$
  where $\tilde{H}(\vec{Q},\vec{P})=H(\vec{q},\vec{p})$.

The generating function method:

Suppose we have a function $S:\mathbb{R}^{2n}\to\mathbb{R}.$ Write its arguments $S(\vec{q},\vec{P})$. Now set
  $$\vec{p}=\frac{\partial S}{\partial \vec{q}}, \quad \vec{Q}=\frac{\partial S}{\partial \vec{P}}.$$
  The first equation lets us to solve for $\vec{P}$ in terms of $\vec{q},\vec{p}$. The second equation lets us solve for $\vec{Q}$ in terms of $\vec{q},\vec{P}$, and hence in terms of $\vec{q},\vec{p}$. The new coordinates $\vec{Q}$, $\vec{P}$ we find this way will give a canonical transformation. Checking this is just a careful application of the chain rule.

My Problem:
So I decided to try and work out this 'careful application of the chain rule', i.e. prove that the transformation obtained via this generating function method is canonical. I have been unable to do so, and help with this problem would be greatly appreciated.


****my progress****
e.g. try to prove $\dot{\vec{P}}=-\frac{\partial\tilde{H}}{\partial\vec{Q}}$.
Thinking of $H$ as $H(\vec{q}(\vec{Q},\vec{P}),\vec{p}(\vec{Q},\vec{P}))$, and using the chain rule,
$$\frac{\partial\tilde{H}}{\partial Q_i}=\frac{\partial H}{\partial q_j}\frac{\partial q_j}{\partial Q_i}+\frac{\partial H}{\partial p_j}\frac{\partial p_j}{\partial Q_i}=-\dot{p}_j\frac{\partial q_j}{\partial Q_i}+\dot{q}_j\frac{\partial p_j}{\partial Q_i}$$
using the original Hamilton equations.
Meanwhile, 
$$-\dot{P}_i=-\frac{\partial P_i}{\partial q_j}\dot{q}_j-\frac{\partial P_i}{\partial p_j}\dot{p}_j,$$
so it will suffice to show 
$$\frac{\partial P_i}{\partial p_j}=\frac{\partial q_j}{\partial Q_i},\quad
\frac{\partial P_i}{\partial q_j}=-\frac{\partial p_j}{\partial Q_i}.$$
I've been able to show 
$$\frac{\partial p_j}{\partial P_i}=\frac{\partial Q_i}{\partial q_j}$$
using chain rule and symmetry of partial derivatives. This then gives us the first desired equality, by inverting the Jacobian matrix:
$$\left[\frac{\partial p_j}{\partial P_i}\right]^{-1}
=\left[\frac{\partial Q_i}{\partial q_j}\right]^{-1} \implies 
\left[\frac{\partial P_i}{\partial p_j}\right]
=\left[\frac{\partial q_j}{\partial Q_i}\right]$$
However, I'm not sure how to show
$$\frac{\partial P_i}{\partial q_j}=-\frac{\partial p_j}{\partial Q_i}.$$
 A: *

*Recall that a coordinate transformation 
$$(q^i,p_i)~~\mapsto~~ \left(Q^i(q,p,t),P_i(q,p,t)\right)\tag{1}$$
with generating function $F$ is of the form$^1$
$$\lambda\underbrace{(\sum_{i=1}^np_i\mathrm{d}q^i-H\mathrm{d}t)}_{~=:~\mathbb{L}_H}
~=~\underbrace{(\sum_{i=1}^nP_i\mathrm{d}Q^i -K\mathrm{d}t)}_{~=:~\mathbb{L}_K}
~+~\mathrm{d}F,\tag{2}$$
where $\lambda\neq 0$ is a non-zero constant.

*Since the 2 Lagrangian 1-forms $\mathbb{L}_H$ and $\mathbb{L}_K$ are the same off-shell up to a total derivative and an over-all multiplicative constant $\lambda$, they yield the same Euler-Lagrange (EL) equations, which clearly are Hamilton's equations in both cases. Hence the coordinate transformation (2) leaves Hamilton's equations form-invariant.

*Eqs. (2) represent a notion of a canonical transformation (CT), cf. e.g. this Phys.SE post.
--
$^1$ OP's generator $F=S(q,P,t)-\sum_{i=1}^nP_iQ^i$ is of type 2 and in OP's case $\lambda=1$.
A: What you have found is basically another way to describe canonical transformations. Let's start by calculating
$$\dot{Q}_i = \frac{\partial Q_i}{\partial q_j} \dot{q}_j + \frac{\partial Q_i}{\partial p_j} \dot{p_j} = \frac{\partial Q_i}{\partial q_j} \frac{\partial H}{\partial p_j} - \frac{\partial Q_i}{\partial p_j} \frac{\partial H}{\partial p_j}.$$
This has to be equal to 
$$\frac{\partial H}{\partial P_i} = \frac{\partial H}{\partial q_j} \frac{\partial q_j}{\partial P_i} + \frac{\partial H}{\partial P_j}\frac{\partial p_j}{\partial P_i}.$$
Comparing these two equations yields 
$$\frac{\partial H}{\partial p_j} \left( \frac{\partial Q_i}{\partial q_j} - \frac{\partial p_j}{\partial P_i}\right) = \frac{\partial H}{\partial q_j}\left(\frac{\partial q_j}{\partial P_i} + \frac{\partial Q_i}{\partial p_j}\right).$$
Since neither $\partial H / \partial p_j$ nor $\partial H / \partial q_j$ are identical 0, the expressions in the brackets need to equal 0. In your case, you will have to show that the generating function $S$ yields a transformation that abides these equations (a similar argument for $\dot{P}_i$ yields the identiy in your question). 
From a more theoretical point of few, a transformation is canonical if the poisson brackets are preserved:
$$\{Q_i, Q_j\} = 0, \qquad \{P_i, P_j\} = 0, \qquad \{Q_i, P_j\} = \delta_{ij}.$$
And from a even more abstract point of few, someone might show that a transformation is canonical by checking if it preserves the symplectic structure of Hamilton's equations. If $J$ is the Jacobian matrix and $E$ the $2n\times 2n$ matrix
$$ E = \begin{pmatrix}
0 &\delta_{ij}   \\
-\delta{ij} & 0 
\end{pmatrix} $$
then the symplectic structure is preserved iff
$J E J^\top = E$. Incidentally, $J$ is called symplectic in that case. 
A canonical transformation induced by the generating function $S$ has to satisfy all three conditions, but since they are equivalent, you just need to check that one of them is true. 
