This question is related (but not similar) to this old one of mine:
How to derive the two Friedmann-Lemaître equations from a Lagrangian?
Consider the Lagrangian of an isotropic-homogeneous spacetime (Robertson-Walker metric), containing a simple scalar field and a cosmological constant (this expression comes from the standard Hilbert-Einstein and scalar field action, in an isotropic-homogeneous spacetime. The space coordinates were integrated out and an hypersurface term was discarded) : \begin{equation}\tag{1} \mathcal{L} = -\: \frac{1}{8 \pi G} (3 \, a \, \dot{a}^2 - 3 k \, a + \Lambda \, a^3) + \frac{1}{2} \; \dot{\phi}^2 a^3 - \mathcal{V}(\phi) \, a^3. \end{equation} The function $\mathcal{V}(\phi)$ is the potential energy density of the scalar field. The action is simply $$\tag{2} S = \int_{t_1}^{t_2} \mathcal{L} \, dt. $$ Just for reference, the hypersurface term that was neglected is the following: $$\tag{1b} \mathcal{L}_{\text{surf}} =\frac{1}{8 \pi G} \, \frac{d}{dt} ( 3 \, a^2 \, \dot{a}). $$ It's easy to find the Hamiltonian: \begin{equation}\tag{3} \mathcal{H} \equiv \dot{a} \, \frac{\partial \mathcal{L}}{\partial \, \dot{a}} + \dot{\phi} \, \frac{\partial \mathcal{L}}{\partial \, \dot{\phi}} - \mathcal{L} = -\: \frac{3}{8 \pi G} \Big( \frac{\dot{a}^2}{a^2} + \frac{k}{a^2} - \frac{\Lambda}{3} \Big) \, a^3 + \Big( \frac{1}{2} \, \dot{\phi}^2 + \mathcal{V}(\phi) \Big) \, a^3. \end{equation} That Hamiltonian can be proved to be 0, by a transformation of the time variable $dt \Rightarrow N \, dt$, where $N$ is an arbitrary function of $t$ (the "lapse" function). This changes the lagrangian (1): \begin{equation}\tag{4} \tilde{\mathcal{L}} = -\: \frac{1}{8 \pi G} (3 \, a \, \dot{a}^2/N - 3 k \, a N + \Lambda \, a^3 N) + \frac{1}{2} \; \dot{\phi}^2 a^3 / N - \mathcal{V}(\phi) \, a^3 N. \end{equation} Since $N$ is arbitrary, we then could consider it as a new variable that can be varied. The Euler-Lagrange equation applied to the lapse function implies that $\mathcal{H} = 0$.
What confuses me is that this reasoning could also be applied to any other Lagrangian, starting from its action and applying an arbitrary time transformation that doesn't change the end points: $$\tag{5} S = \int_{t_1}^{t_2} L \Big(q, \frac{dq}{dt} \Big) \, dt = \int_{t_1}^{t_2} L \Big(q, \frac{1}{N} \, \frac{dq}{d\tilde{t}} \Big) \, N \, d\tilde{t}, $$ so that $$\tag{6} \tilde{L} = N \, L \Big(q, \frac{1}{N} \, \frac{dq}{d\tilde{t}} \Big). $$ Applying the Euler-Lagrange equation to $N$ (which is still arbitrary) then gives an absurdity: $H = 0$ for any Lagrangian! Of course, this cannot be true!
So two questions:
- Where did I made a stupid mistake in this reasoning? It certainly should be obvious, but I don't see it!
- I often read that $H = 0$ comes from the parameterization invariance of the action. But then, like most classical Lagrangians, (1) and (2) don't seem to be independent of the time parameterization (even if I bring back the surface term that was discarded at the beginning). So how can we show that (1)-(2) are actually independent of the time parameterization and show the relation to the Hamiltonian being zero?