A problem in deriving the Hamilton-Jacobi equation from a variational principle As I've already said, I have a problem in understanding a reasoning from which we derive the Hamilton–Jacobi equation from a variational principle. 
Let's take the Hamilton functional:
$$  S = \int_{t_0}^{t_1} [ p_{\alpha}\dot{q}^{\alpha} - H(q^{\alpha},p_{\alpha},t) ]\, dt  $$
The first variation on the phase space of this functional is, in the most general form:
$$ (\delta S)_{\bar{\gamma}} = [p_\alpha \delta q^{\alpha} - H \delta t]_{t_0}^{t_1} + \int_{t_0}^{t_1} \left\{ \left[ \dot{q}^{\alpha} - \frac{\partial H}{\partial p_\alpha} \right]_{\bar{\gamma}}\pi_\alpha - \left[ \dot{p}_{\alpha} + \frac{\partial H}{\partial q^\alpha} \right]_{\bar{\gamma}}\eta_\alpha \right\}\, dt $$
Where the variation of the functional S is evaluated on the deformation of the curve ${\bar{\gamma}} \to \gamma$ in the phase space:
$$ \bar{\gamma}:
\begin{cases}
q^{\alpha} = \overline{q}^{\alpha}(t) \\
p_{\alpha} = \overline{p}_{\alpha}(t) \\
A = \{ \overline{q}^{\alpha}(t_0);\overline{p}_{\alpha}(t_0) \} \\
B = \{ \overline{q}^{\alpha}(t_1);\overline{p}_{\alpha}(t_1) \} \\
\end{cases} \qquad t \in [t_0,t_1]
$$ 
$$ \gamma:
\begin{cases}
q^{\alpha} = \overline{q}^{\alpha}(t) + \lambda\eta_{\alpha}(t) \\
p_{\alpha} = \overline{p}_{\alpha}(t) + \lambda\pi_{\alpha}(t)\\
A' = \{ \overline{q}^{\alpha}(t_0 + \lambda \delta t_0) + \lambda \eta_{\alpha}(t_0 + \lambda \delta t_0) ; \overline{p}_{\alpha}(t_0 + \lambda \delta t_0) + \lambda \pi_{\alpha}(t_0 + \lambda \delta t_0) \} \\
B' = \{ \overline{q}^{\alpha}(t_1 + \lambda \delta t_1)+\lambda \eta_{\alpha}(t_1 + \lambda \delta t_1); \overline{p}_{\alpha}(t_1 + \lambda \delta t_1) + \lambda \pi_{\alpha}(t_1 + \lambda \delta t_1) \} \\
\end{cases} \qquad t \in [t_0 +\lambda \delta t_0,t_1 +\lambda \delta t_1]
$$
Where $\eta_{\alpha}$ and $\pi_{\alpha}$ are regular function.
Now, in my notes we choose $\bar{\gamma}$ e we let $A=A'$, so that we have an initial fixed point.
Then we say that on the curve chosen, are satisfied the Hamilton equation, so that the variation of S becomes only:
$$ (\delta S)_{\bar{\gamma}} = [p_\alpha \delta q^{\alpha} - H \delta t]_{t_0}^{t_1} $$
[First question Is this legit? If the Hamilton equation are derived from the same variational principle, can we say ``a priori'' that them are valid on a particular path on the phase space? ]
Then we consider the point B movable, so that it depends from time. In this way, S isn't a functional anymore, but instead is a function of time.
So the variation can be interpreted as a differential:
$$ dS= p_\alpha d q^{\alpha} - H d t  $$
[Second question I wish to have a mathematical proof for that, because for me isn't trivial as it sounds.]
Then we can prove that S is function of $S(q^{\alpha}(t), t ,q^{\alpha}(t_0), t_0 )$, so that:
$$ dS = \frac{\partial S}{\partial q^{\alpha}}d q^{\alpha} +\frac{\partial S}{\partial t} dt $$
Equating the two results, we obtain:
$$ \frac{\partial S}{\partial t} + H \left( q^{\alpha} , \frac{\partial S}{\partial q^{\alpha}}, t \right) = 0 $$
Which is the Hamilton-Jacobi equation.
Third question Is this reasoning formally correct ? It doesn't feel quite right to me.
And also, more importantly, do you know any book that treats the argument in this way, or similar, that is more rigorous?
 A: *

*On one hand, Hamilton's principal function $S(q,\alpha,t)$ and Hamilton-Jacobi (HJ) equation$$H(q,p,t)~=~-\frac{\partial S}{\partial t}, \qquad p_j~=~\frac{\partial S}{\partial q^j}, \tag{1}$$ 
is usually defined via a canonical transformation of type 2. Here $S=F_2$ is a generating function. The new momenta $P_i=\alpha_i$ are the integration constants, and constants of motion. The Kamiltonian $K\equiv 0$ vanishes identically. The total time derivative 
$$ \frac{dS}{dt}~=~\dot{q}^j\frac{\partial S}{\partial q^j}+\frac{\partial S}{\partial t}  ~\stackrel{(1)}{=}~ \dot{q}^jp_j-H~=~L \tag{2} $$
is equal to the Lagrangian $L$ on-shell. As a consequence, the Hamilton's principal function $S(q,\alpha, t)$ can be interpreted as an action on-shell.
See also this related Phys.SE post.

*On the other hand, the (Dirichlet) on-shell action $S(q_f,t_f;q_i,t_i)$ satisfies
$$h_f~=~-\frac{\partial S}{\partial t_f}, \qquad  p_f~=~\frac{\partial S}{\partial q_f}.\tag{3} $$
For a proof of eq. (3), see e.g. my Phys.SE answer here. 

*Eq. (3) looks deceptively like eq. (1). However, the devil is in the details. To lift eq. (3) to eq. (1), there still remains an identification problem of finding the new momenta $P_i=\alpha_i$ in terms the final and initial data $(q_f,t_f;q_i,t_i)$.  

*Finally let us mention that Caratheodory’s variational method of equivalent Lagrangians can be used to derive the HJ equation in a quite different approach, see Ref. 1. (There is a similar identification issue with this method.)
References:


*

*H.A. Kastrup, Canonical theories of Lagrangian dynamical systems in physics, Phys. Rep. 101 (1983) 1; Section 2.4.

