Lagrangian mechanics on : action, Lagrange's equations, constants of the motion
DefinitionClassicalDynamics_coreThe definition layer for Tong's Section 2, on an -dimensional configuration space (represented as functions ).
A Lagrangian is a function of time, position and velocity; it is smooth when it is jointly in all arguments. The velocity of a path is the coordinatewise derivative . Partial derivatives and are one-dimensional derivatives in a single coordinate slot, obtained by varying the -th entry and holding the others fixed.
A path is a motion when Lagrange's equations (Tong eq. 2.43) hold,
for every coordinate and every time, the time derivative being asserted to exist. The generalised momentum is (eq. 2.44) evaluated along a path, the Hamiltonian is (eq. 2.47), and the action over is (eq. 2.3).
A function of time is a constant of the motion when it takes the same value at all times (eq. 2.46). A one-parameter family of paths is a continuous symmetry of when for all and (eq. 2.52), and the associated Noether charge is evaluated at along the path (eq. 2.54).
import Mathlib
namespace ClassicalDynamics
/-- A Lagrangian `L(t, q, q̇)` on an `n`-dimensional configuration space `ℝⁿ`.
Tong writes it as `L(qᵢ, q̇ᵢ, t)`; here the time argument comes first. -/
abbrev Lagrangian (n : ℕ) : Type := ℝ → (Fin n → ℝ) → (Fin n → ℝ) → ℝ
/-- Smoothness of a Lagrangian, jointly in all of its arguments. -/
def IsSmoothLagrangian {n : ℕ} (L : Lagrangian n) : Prop :=
ContDiff ℝ (⊤ : ℕ∞) (fun p : ℝ × (Fin n → ℝ) × (Fin n → ℝ) => L p.1 p.2.1 p.2.2)
/-- The velocity `q̇(t)` of a path `q : ℝ → ℝⁿ`, computed coordinatewise. -/
noncomputable def vel {n : ℕ} (q : ℝ → Fin n → ℝ) (t : ℝ) : Fin n → ℝ :=
fun i => deriv (fun s => q s i) t
/-- The partial derivative `∂L/∂qᵢ` of a Lagrangian with respect to the `i`-th
coordinate, evaluated at `(t, q, v)`. -/
noncomputable def dLdq {n : ℕ} (L : Lagrangian n) (i : Fin n)
(t : ℝ) (q v : Fin n → ℝ) : ℝ :=
deriv (fun x : ℝ => L t (Function.update q i x) v) (q i)
/-- The partial derivative `∂L/∂q̇ᵢ` of a Lagrangian with respect to the `i`-th
velocity, evaluated at `(t, q, v)`. -/
noncomputable def dLdv {n : ℕ} (L : Lagrangian n) (i : Fin n)
(t : ℝ) (q v : Fin n → ℝ) : ℝ :=
deriv (fun x : ℝ => L t q (Function.update v i x)) (v i)
/-- The partial derivative `∂f/∂qᵢ` of a function `f(t, q)` of time and position. -/
noncomputable def dfdq {n : ℕ} (f : ℝ → (Fin n → ℝ) → ℝ) (i : Fin n)
(t : ℝ) (q : Fin n → ℝ) : ℝ :=
deriv (fun x : ℝ => f t (Function.update q i x)) (q i)
/-- Lagrange's equations (Tong, eq. 2.43): the path `q` satisfies
`d/dt (∂L/∂q̇ᵢ) = ∂L/∂qᵢ` at every time and in every coordinate, the derivative
being asserted to exist. -/
def IsMotion {n : ℕ} (L : Lagrangian n) (q : ℝ → Fin n → ℝ) : Prop :=
∀ (i : Fin n) (t : ℝ),
HasDerivAt (fun s : ℝ => dLdv L i s (q s) (vel q s))
(dLdq L i t (q t) (vel q t)) t
/-- The generalised momentum `pᵢ = ∂L/∂q̇ᵢ` (Tong, eq. 2.44) evaluated along a path. -/
noncomputable def momentum {n : ℕ} (L : Lagrangian n) (i : Fin n)
(q : ℝ → Fin n → ℝ) (t : ℝ) : ℝ :=
dLdv L i t (q t) (vel q t)
/-- The Hamiltonian `H = Σⱼ q̇ⱼ ∂L/∂q̇ⱼ − L` (Tong, eq. 2.47). -/
noncomputable def hamiltonian {n : ℕ} (L : Lagrangian n)
(t : ℝ) (q v : Fin n → ℝ) : ℝ :=
(∑ j : Fin n, v j * dLdv L j t q v) - L t q v
/-- The action `S = ∫ L dt` of a path over the time interval `[t₁, t₂]`
(Tong, eq. 2.3). -/
noncomputable def action {n : ℕ} (L : Lagrangian n) (q : ℝ → Fin n → ℝ)
(t₁ t₂ : ℝ) : ℝ :=
∫ t in t₁..t₂, L t (q t) (vel q t)
/-- A real-valued function of time is a constant of the motion when it takes the
same value at all times (Tong, eq. 2.46). -/
def IsConstantInTime (F : ℝ → ℝ) : Prop := ∀ t₁ t₂ : ℝ, F t₁ = F t₂
/-- A one-parameter family of paths `Q(s, t)` is a continuous symmetry of `L`
when `∂/∂s L(Q(s,t), Q̇(s,t), t) = 0` (Tong, eq. 2.52). -/
def IsContinuousSymmetry {n : ℕ} (L : Lagrangian n) (Q : ℝ → ℝ → Fin n → ℝ) : Prop :=
∀ s t : ℝ, deriv (fun u : ℝ => L t (Q u t) (vel (Q u) t)) s = 0
/-- The Noether charge `Σᵢ (∂L/∂q̇ᵢ)(∂Qᵢ/∂s)`, evaluated at `s = 0` along the
reference path `Q(0, ·)` (Tong, eq. 2.54). -/
noncomputable def noetherCharge {n : ℕ} (L : Lagrangian n)
(Q : ℝ → ℝ → Fin n → ℝ) (t : ℝ) : ℝ :=
∑ i : Fin n, dLdv L i t (Q 0 t) (vel (Q 0) t) * deriv (fun u : ℝ => Q u t i) 0
end ClassicalDynamics
Read-back
What the Lean code literally says, in plain math · Aristotle (Harmonic) — the drafting agent itself; see the notice above
Non-blind read-back — not independent testimony. This read-back was written by the same agent that drafted the Lean statements in this proposal, not by an independent blind auditor. Its author knew what the code was intended to say, so it cannot serve the usual purpose of catching a mismatch between intent and code. Treat it as an aid to reading the Lean, and obtain an independent blind read-back before relying on it during the audit.
This bundle fixes a natural number and works with the configuration space of -tuples of reals, indexed by .
A Lagrangian is any function taking a real time , an -tuple and an -tuple to a real number; no regularity is built into the type. A Lagrangian is declared smooth exactly when the function
on the product is in the finite sense (infinitely differentiable, not real-analytic).
For a path , its velocity at time is the -tuple whose -th entry is the ordinary derivative of the scalar function at . This derivative operator is total: at a point where the scalar function is not differentiable it returns rather than being undefined, so the velocity of a nowhere-differentiable path is the zero tuple.
Two partial derivatives of a Lagrangian are defined, both as ordinary one-variable derivatives in a single slot with all other entries frozen:
where is with its -th entry replaced by . The same construction is given for a function of time and position alone, producing . Again these are total operators returning at points of non-differentiability.
A path is said to be a motion for when, for every index and every real , the scalar function
is differentiable at with derivative exactly . Note that this is a has-derivative assertion: it demands both existence of the derivative and its value, at every time on the whole real line, with no interval restriction.
The momentum of index along a path is the function of time
and the Hamiltonian at a point is the real number
the sum running over all indices (an empty sum, hence , when ).
The action of a path over is the oriented interval integral ; it is a total operation as well, returning when the integrand is not integrable, and it changes sign when .
A real-valued function of time is constant in time exactly when for every pair of reals — constancy on the whole line, not merely local constancy or a vanishing derivative.
Given a two-parameter family of -tuples, is a continuous symmetry of exactly when, for every real and every real , the derivative in of
at equals , where is the time-derivative of the path in the sense above. Because the derivative operator is total, this condition is also satisfied when the map is not differentiable in at all.
The Noether charge of such a family is the function of time
the sum over all indices, evaluated along the member of the family.