Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
fe0dc12
refactor: golf TotalDerivativeEquivalence, HarmonicOscillator, Damped…
Vilin97 Jul 6, 2026
c59cf54
refactor: golf total-derivative equivalence proofs
Vilin97 Jul 6, 2026
0a13959
fix: repair damped helper extraction
Vilin97 Jul 6, 2026
d2396f4
refactor: golf HarmonicOscillator trajectory_velocity proof and QFT l…
Vilin97 Jul 6, 2026
e1aa480
refactor: golf isTotalTimeDerivative_explicit and fix IsExtrema proofs
Vilin97 Jul 7, 2026
7600eef
refactor: golf Lagrangian and Curl proofs
Vilin97 Jul 7, 2026
5a6b0fc
refactor: golf planeWave_differentiable_space
Vilin97 Jul 7, 2026
7cf3b52
refactor: golf planeWave and decompose proofs
Vilin97 Jul 8, 2026
fa8dde1
refactor: golf hamiltonian_eq_electricField_scalarPotential
Vilin97 Jul 8, 2026
5a1ac57
refactor: golf iteratedDeriv lemma extraction and exists_curl simplif…
Vilin97 Jul 8, 2026
ff17f0b
refactor: golf decompose_reduce proof
Vilin97 Jul 8, 2026
4b6e5cf
refactor: golf div_of_curl, curl_of_curl, deriv_beta_wrt_T, chain_rul…
Vilin97 Jul 8, 2026
5950932
refactor: golf wave_fderiv_inner_eq_inner_fderiv_proj proof
Vilin97 Jul 8, 2026
b502caa
refactor: golf repeat fun_prop → all_goals fun_prop in 6 files
Vilin97 Jul 8, 2026
f87ea6f
refactor: golf deriv_beta_wrt_T and chain_rule_T_beta proofs
Vilin97 Jul 8, 2026
2a7a4b1
refactor: golf eventually_pos_ofβ proof
Vilin97 Jul 8, 2026
8f6c773
refactor: golf deriv_add, deriv_sub, deriv_coord_add proofs
Vilin97 Jul 8, 2026
c850641
refactor: golf div_linear_map proof
Vilin97 Jul 8, 2026
eed8207
refactor: golf time_deriv_cross_commute proof
Vilin97 Jul 8, 2026
9943d54
refactor: golf HarmonicOscillator, Slice, TimeAndSpace proofs
Vilin97 Jul 8, 2026
2177452
refactor: golf wave_differentiable, planeWave_time/space_deriv proofs
Vilin97 Jul 8, 2026
297f0b0
refactor: golf deriv_sum_inl/inr, time_deriv_curl_commute proofs
Vilin97 Jul 8, 2026
e1461dc
refactor: golf solidSphere_mass proof
Vilin97 Jul 8, 2026
d1b2204
refactor: golf damped-velocity, trajectory-acceleration, time-deriv-c…
Vilin97 Jul 8, 2026
aa66fa7
refactor: golf potentialEnergy_deriv proof
Vilin97 Jul 8, 2026
2b53703
refactor: golf gradient_dist_normPowerSeries_zpow, log, and their ten…
Vilin97 Jul 8, 2026
5ee3484
refactor: golf distDiv_norm_zpow_smul_repr_self_eq_smul and distLapla…
Vilin97 Jul 8, 2026
d2f4d05
refactor: golf distLaplacian_fundamentalSolution_norm_zpow
Vilin97 Jul 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 26 additions & 43 deletions Physlib/ClassicalMechanics/DampedHarmonicOscillator/Solution.lean
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,13 @@ private lemma exp_decay_smul_velocity
∂ₜ (fun t : Time => exp (-a * t.val) • y t) =
fun t : Time => exp (-a * t.val) • (∂ₜ y t - a • y t) := by
funext t
rw [Time.deriv]
rw [fderiv_fun_smul (by fun_prop) (hy t)]
rw [fderiv_exp (by fun_prop), fderiv_fun_mul (by fun_prop) (by fun_prop)]
rw [Time.deriv, fderiv_fun_smul (by fun_prop) (hy t), fderiv_exp (by fun_prop),
fderiv_fun_mul (by fun_prop) (by fun_prop)]
simp only [add_apply, ContinuousLinearMap.smulRight_apply,
fderiv_fun_neg, fderiv_fun_const, Pi.zero_apply, Time.fderiv_val,
_root_.neg_apply, FunLike.coe_smul, Pi.smul_apply, smul_eq_mul]
rw [← Time.deriv_eq]
simp [smul_sub, smul_smul]
module
simp [smul_smul, sub_eq_add_neg]

private lemma exp_decay_smul_acceleration
(a μ : ℝ) (y : Time → EuclideanSpace ℝ (Fin 1))
Expand All @@ -197,11 +195,9 @@ private lemma exp_decay_smul_acceleration
(μ • y t - (2 * a) • ∂ₜ y t + a^2 • y t) := by
rw [exp_decay_smul_velocity a y hy]
funext t
rw [Time.deriv]
rw [fderiv_fun_smul (by fun_prop) (by fun_prop)]
rw [fderiv_exp (by fun_prop), fderiv_fun_mul (by fun_prop) (by fun_prop)]
rw [fderiv_fun_sub (hdy t) (by fun_prop)]
rw [fderiv_fun_const_smul (hy t)]
rw [Time.deriv, fderiv_fun_smul (by fun_prop) (by fun_prop),
fderiv_exp (by fun_prop), fderiv_fun_mul (by fun_prop) (by fun_prop),
fderiv_fun_sub (hdy t) (by fun_prop), fderiv_fun_const_smul (hy t)]
have hy''_t := congrFun hy'' t
rw [Time.deriv] at hy''_t
simp only [add_apply, _root_.sub_apply,
Expand All @@ -210,7 +206,7 @@ private lemma exp_decay_smul_acceleration
FunLike.coe_smul, Pi.smul_apply, smul_eq_mul]
rw [hy''_t, ← Time.deriv_eq]
simp [smul_add, smul_sub, smul_smul]
module
ext i; simp; ring

private lemma exp_decay_smul_equationOfMotion
(a μ : ℝ) (y : Time → EuclideanSpace ℝ (Fin 1))
Expand All @@ -219,11 +215,10 @@ private lemma exp_decay_smul_equationOfMotion
(hγ : S.γ = 2 * S.m * a) (hk : S.k = S.m * (a^2 - μ)) :
S.EquationOfMotion (fun t : Time => exp (-a * t.val) • y t) := by
intro t
rw [exp_decay_smul_acceleration a μ y hy hdy hy'']
rw [exp_decay_smul_velocity a y hy]
rw [hγ, hk]
rw [exp_decay_smul_acceleration a μ y hy hdy hy'', exp_decay_smul_velocity a y hy,
hγ, hk]
simp [smul_add, smul_sub, smul_smul]
module
ext i; simp; ring

/-!

Expand All @@ -234,12 +229,17 @@ polynomial, and hyperbolic base trajectories before the exponential decay factor

-/

private lemma fderiv_comp_val_eq_deriv {t : Time} (g : ℝ → ℝ)
(hg : DifferentiableAt ℝ g t.val) :
(fderiv ℝ (fun s : Time => g s.val) t) 1 = _root_.deriv g t.val := by
rw [fderiv_fun_comp t hg (by fun_prop), ContinuousLinearMap.comp_apply, Time.fderiv_val]
simp

private lemma criticallyDampedBase_velocity (IC : InitialConditions) :
∂ₜ (S.criticallyDampedBase IC) =
fun _ : Time => IC.v₀ + S.decayRate • IC.x₀ := by
funext t
change ∂ₜ (fun t : Time =>
IC.x₀ + t.val • (IC.v₀ + S.decayRate • IC.x₀)) t = _
unfold criticallyDampedBase
rw [Time.deriv_eq, fderiv_fun_add (by fun_prop) (by fun_prop),
fderiv_fun_const, fderiv_smul_const (by fun_prop)]
simp
Expand All @@ -262,11 +262,6 @@ private lemma underdampedBase_velocity (IC : InitialConditions) (hS : S.IsUnderd
(IC.v₀ + S.decayRate • IC.x₀) := by
have hΩ : S.angularFrequency ≠ 0 := S.angularFrequency_ne_zero_of_underdamped hS
funext t
have fderiv_comp_val_eq_deriv : ∀ g : ℝ → ℝ, DifferentiableAt ℝ g t.val →
(fderiv ℝ (fun s : Time => g s.val) t) 1 = _root_.deriv g t.val := by
intro g hg
rw [fderiv_fun_comp t hg (by fun_prop), ContinuousLinearMap.comp_apply, Time.fderiv_val]
simp
rw [Time.deriv_eq, fderiv_fun_add (by fun_prop) (by fun_prop),
fderiv_smul_const (by fun_prop), fderiv_smul_const (by fun_prop)]
simp only [add_apply, ContinuousLinearMap.smulRight_apply]
Expand All @@ -287,11 +282,6 @@ private lemma underdampedBase_acceleration (IC : InitialConditions) (hS : S.IsUn
have hΩ : S.angularFrequency ≠ 0 := S.angularFrequency_ne_zero_of_underdamped hS
rw [S.underdampedBase_velocity IC hS]
funext t
have fderiv_comp_val_eq_deriv : ∀ g : ℝ → ℝ, DifferentiableAt ℝ g t.val →
(fderiv ℝ (fun s : Time => g s.val) t) 1 = _root_.deriv g t.val := by
intro g hg
rw [fderiv_fun_comp t hg (by fun_prop), ContinuousLinearMap.comp_apply, Time.fderiv_val]
simp
rw [Time.deriv_eq, fderiv_fun_add (by fun_prop) (by fun_prop),
fderiv_smul_const (by fun_prop), fderiv_smul_const (by fun_prop)]
simp only [add_apply, ContinuousLinearMap.smulRight_apply]
Expand All @@ -312,11 +302,6 @@ private lemma overdampedBase_velocity (IC : InitialConditions) (hS : S.IsOverdam
(IC.v₀ + S.decayRate • IC.x₀) := by
have hΩ : S.angularFrequency ≠ 0 := S.angularFrequency_ne_zero_of_overdamped hS
funext t
have fderiv_comp_val_eq_deriv : ∀ g : ℝ → ℝ, DifferentiableAt ℝ g t.val →
(fderiv ℝ (fun s : Time => g s.val) t) 1 = _root_.deriv g t.val := by
intro g hg
rw [fderiv_fun_comp t hg (by fun_prop), ContinuousLinearMap.comp_apply, Time.fderiv_val]
simp
rw [Time.deriv_eq, fderiv_fun_add (by fun_prop) (by fun_prop),
fderiv_smul_const (by fun_prop), fderiv_smul_const (by fun_prop)]
simp only [add_apply, ContinuousLinearMap.smulRight_apply]
Expand All @@ -337,11 +322,6 @@ private lemma overdampedBase_acceleration (IC : InitialConditions) (hS : S.IsOve
have hΩ : S.angularFrequency ≠ 0 := S.angularFrequency_ne_zero_of_overdamped hS
rw [S.overdampedBase_velocity IC hS]
funext t
have fderiv_comp_val_eq_deriv : ∀ g : ℝ → ℝ, DifferentiableAt ℝ g t.val →
(fderiv ℝ (fun s : Time => g s.val) t) 1 = _root_.deriv g t.val := by
intro g hg
rw [fderiv_fun_comp t hg (by fun_prop), ContinuousLinearMap.comp_apply, Time.fderiv_val]
simp
rw [Time.deriv_eq, fderiv_fun_add (by fun_prop) (by fun_prop),
fderiv_smul_const (by fun_prop), fderiv_smul_const (by fun_prop)]
simp only [add_apply, ContinuousLinearMap.smulRight_apply]
Expand Down Expand Up @@ -375,8 +355,9 @@ lemma trajectory_equationOfMotion_of_criticallyDamped (IC : InitialConditions)
fun_prop)
(by
rw [S.criticallyDampedBase_velocity IC]
fun_prop) ?_ hγ hk
simpa using S.criticallyDampedBase_acceleration IC
fun_prop)
(by
simpa using S.criticallyDampedBase_acceleration IC) hγ hk

/-- In the underdamped regime, the selected trajectory satisfies the damped equation of
motion. -/
Expand All @@ -388,13 +369,14 @@ lemma trajectory_equationOfMotion_of_underdamped (IC : InitialConditions)
have hk : S.k = S.m * (S.decayRate^2 - (-S.angularFrequency^2)) := by
rw [S.k_eq_m_mul_ω_sq, S.angularFrequency_sq_of_underdamped hS]
ring
refine S.exp_decay_smul_equationOfMotion S.decayRate
(-S.angularFrequency^2) (S.underdampedBase IC)
refine S.exp_decay_smul_equationOfMotion S.decayRate (-S.angularFrequency^2)
(S.underdampedBase IC)
(by
unfold underdampedBase
fun_prop) ?_
(S.underdampedBase_acceleration IC hS) hγ hk
rw [show ∂ₜ (S.underdampedBase IC) = _ from S.underdampedBase_velocity IC hS]
unfold underdampedBase
rw [S.underdampedBase_velocity IC hS]
fun_prop

/-- In the overdamped regime, the selected trajectory satisfies the damped equation of
Expand All @@ -413,7 +395,8 @@ lemma trajectory_equationOfMotion_of_overdamped (IC : InitialConditions)
unfold overdampedBase
fun_prop) ?_
(S.overdampedBase_acceleration IC hS) hγ hk
rw [show ∂ₜ (S.overdampedBase IC) = _ from S.overdampedBase_velocity IC hS]
unfold overdampedBase
rw [S.overdampedBase_velocity IC hS]
fun_prop

/-- The selected trajectory satisfies the damped equation of motion. -/
Expand Down
12 changes: 3 additions & 9 deletions Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ lemma kineticEnergy_deriv (xₜ : Time → EuclideanSpace ℝ (Fin 1)) (hx : Con
congr 1
simp only [smul_add]
module
repeat fun_prop
all_goals fun_prop

lemma potentialEnergy_deriv (xₜ : Time → EuclideanSpace ℝ (Fin 1)) (hx : ContDiff ℝ ∞ xₜ) :
∂ₜ (fun t => potentialEnergy S (xₜ t)) = fun t => ⟪∂ₜ xₜ t, S.k • xₜ t⟫_ℝ := by
Expand All @@ -293,10 +293,7 @@ lemma potentialEnergy_deriv (xₜ : Time → EuclideanSpace ℝ (Fin 1)) (hx : C
congr 1
module
rw [real_inner_comm, ← inner_smul_right]
repeat fun_prop
apply Differentiable.differentiableAt
rw [contDiff_infty_iff_fderiv] at hx
exact hx.1
all_goals (first | fun_prop | exact (hx.contDiffAt (x := t)).differentiableAt (by simp))

lemma energy_deriv (xₜ : Time → EuclideanSpace ℝ (Fin 1)) (hx : ContDiff ℝ ∞ xₜ) :
∂ₜ (energy S xₜ) = fun t => ⟪∂ₜ xₜ t, S.m • ∂ₜ (∂ₜ xₜ) t + S.k • xₜ t⟫_ℝ := by
Expand All @@ -309,8 +306,7 @@ lemma energy_deriv (xₜ : Time → EuclideanSpace ℝ (Fin 1)) (hx : ContDiff
rw [potentialEnergy_deriv, kineticEnergy_deriv]
simp only
rw [← inner_add_right]
fun_prop
fun_prop
all_goals fun_prop

/-!

Expand Down Expand Up @@ -400,8 +396,6 @@ lemma gradient_inner_self (x : EuclideanSpace ℝ (Fin 1)) :
unfold gradient
rw [InnerProductSpace.toDual_symm_apply]
have hid : DifferentiableAt ℝ (fun y : EuclideanSpace ℝ (Fin 1) => y) x := differentiableAt_id
rw [show (fun y : EuclideanSpace ℝ (Fin 1) => ⟪y, y⟫_ℝ) =
fun y => ⟪(fun y => y) y, (fun y => y) y⟫_ℝ from rfl]
rw [fderiv_inner_apply (𝕜 := ℝ) hid hid]
simp only [fderiv_fun_id, ContinuousLinearMap.coe_id', id_eq, real_inner_comm, inner_smul_left',
ringHom_apply]
Expand Down
63 changes: 28 additions & 35 deletions Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean
Original file line number Diff line number Diff line change
Expand Up @@ -430,11 +430,9 @@ lemma trajectory_velocity (IC : InitialConditions) : ∂ₜ (IC.trajectory S) =
rw [fderiv_smul_const (by fun_prop), fderiv_smul_const (by fun_prop)]
have h1 : (fderiv ℝ (fun t => sin (S.ω * t.val) / S.ω) t) =
(1/ S.ω) • (fderiv ℝ (fun t => sin (S.ω * t.val)) t) := by
rw [← fderiv_mul_const]
congr
funext t
field_simp
fun_prop
rw [div_eq_mul_inv, ← fderiv_mul_const (hc := ?_)]
· congr; funext t; ring
· fun_prop
simp [h1]
rw [fderiv_cos (by fun_prop), fderiv_sin (by fun_prop),
fderiv_fun_mul (by fun_prop) (by fun_prop)]
Expand Down Expand Up @@ -507,8 +505,7 @@ lemma trajectory_equationOfMotion (IC : InitialConditions) :
ext
have hω : S.ω ≠ 0 := ω_ne_zero S
have hωm : S.ω ^ 2 * S.m = S.k := by
rw [ω_sq]
field_simp [m_ne_zero S]
rw [ω_sq]; field_simp [m_ne_zero S]
simp [trajectory_eq, smul_add, smul_smul, mul_comm]
rw [← hωm]
field_simp [hω]
Expand All @@ -529,57 +526,53 @@ for the given initial conditions.
position and velocity, the difference `y = x - IC.trajectory S` also solves the
equation of motion with zero initial conditions; energy conservation then forces
its energy, and hence `y`, to vanish identically, so `x = IC.trajectory S`. -/
private lemma timeDeriv_sub {f g : Time → EuclideanSpace ℝ (Fin 1)}
(hf : Differentiable ℝ f) (hg : Differentiable ℝ g) :
∂ₜ (fun t => f t - g t) = fun t => ∂ₜ f t - ∂ₜ g t := by
funext s; simp [Time.deriv_eq, fderiv_fun_sub (hf s) (hg s)]

lemma trajectories_unique (IC : InitialConditions) (x : Time → EuclideanSpace ℝ (Fin 1))
(hx : ContDiff ℝ ∞ x) :
S.EquationOfMotion x ∧ x 0 = IC.x₀ ∧ ∂ₜ x 0 = IC.v₀ →
x = IC.trajectory S := by
rintro ⟨hEOM, hx0, hv0⟩
have hTraj : ContDiff ℝ ∞ (IC.trajectory S) := by fun_prop
-- Time-derivative of a difference of differentiable functions, used below on `x - traj`.
have dsub : ∀ f g : Time → EuclideanSpace ℝ (Fin 1),
Differentiable ℝ f → Differentiable ℝ g →
∂ₜ (fun t => f t - g t) = fun t => ∂ₜ f t - ∂ₜ g t := by
intro f g hf hg
funext t
simp only [Time.deriv_eq, fderiv_fun_sub (hf t) (hg t), sub_apply]
-- The difference `y := x - traj` is smooth, again solves the equation of motion (the force is
-- linear), and has vanishing initial data; energy conservation then forces `y = 0`.
set y : Time → EuclideanSpace ℝ (Fin 1) := fun t => x t - IC.trajectory S t with hydef
have hyContDiff : ContDiff ℝ ∞ y := hx.sub hTraj
have hy_deriv : ∂ₜ y = fun t => ∂ₜ x t - ∂ₜ (IC.trajectory S) t :=
dsub x _ (hx.differentiable (by simp)) (hTraj.differentiable (by simp))
have hy_deriv2 : ∂ₜ (∂ₜ y) = fun t => ∂ₜ (∂ₜ x) t - ∂ₜ (∂ₜ (IC.trajectory S)) t := by
rw [hy_deriv]
exact dsub _ _ (deriv_differentiable_of_contDiff _ hx)
(deriv_differentiable_of_contDiff _ hTraj)
have hNewt_x := (S.equationOfMotion_iff_newtons_2nd_law x hx).1 hEOM
have hNewt_traj := (S.equationOfMotion_iff_newtons_2nd_law (IC.trajectory S) hTraj).1
(trajectory_equationOfMotion S IC)
have hEOM_y : S.EquationOfMotion y :=
(S.equationOfMotion_iff_newtons_2nd_law y hyContDiff).2 fun t => by
have hy_deriv2 : ∂ₜ (∂ₜ y) t = ∂ₜ (∂ₜ x) t - ∂ₜ (∂ₜ (IC.trajectory S)) t := by
have hy_deriv : ∂ₜ y = fun t => ∂ₜ x t - ∂ₜ (IC.trajectory S) t :=
timeDeriv_sub (hx.differentiable (by simp)) (hTraj.differentiable (by simp))
rw [hy_deriv]
exact congrFun (timeDeriv_sub
(deriv_differentiable_of_contDiff _ hx) (deriv_differentiable_of_contDiff _ hTraj)) t
rw [hy_deriv2]
simp [smul_sub, hNewt_x, hNewt_traj, hydef, force_eq_linear]
have hE : ∀ t, S.energy y t = 0 := fun t =>
(S.energy_conservation_of_equationOfMotion' y hyContDiff hEOM_y t).trans <| by
have hy0 : y 0 = 0 := by simp [hydef, hx0]
have hyv0 : ∂ₜ y 0 = 0 := by
rw [congrFun hy_deriv 0, hv0, trajectory_velocity_at_zero S IC]; simp
have hy_deriv : ∂ₜ y = fun t => ∂ₜ x t - ∂ₜ (IC.trajectory S) t :=
timeDeriv_sub (hx.differentiable (by simp)) (hTraj.differentiable (by simp))
rw [congrFun hy_deriv 0, hv0, trajectory_velocity_at_zero S IC]
simp
simp [HarmonicOscillator.energy, HarmonicOscillator.kineticEnergy,
HarmonicOscillator.potentialEnergy, hy0, hyv0, one_div, smul_eq_mul]
-- Both energies are nonnegative, so a vanishing total energy forces `y t = 0`.
HarmonicOscillator.potentialEnergy, hy0, hyv0]
funext t
have hk : 0 ≤ S.kineticEnergy y t := by
simp only [HarmonicOscillator.kineticEnergy]
exact mul_nonneg (mul_nonneg (by norm_num) S.m_pos.le) real_inner_self_nonneg
simp [HarmonicOscillator.kineticEnergy, mul_nonneg, S.m_pos.le]
have hp : 0 ≤ S.potentialEnergy (y t) := by
simp only [HarmonicOscillator.potentialEnergy, smul_eq_mul]
exact mul_nonneg (by norm_num) (mul_nonneg S.k_pos.le real_inner_self_nonneg)
have hpe : S.potentialEnergy (y t) = 0 := ((add_eq_zero_iff_of_nonneg hk hp).mp (hE t)).2
simp only [HarmonicOscillator.potentialEnergy, smul_eq_mul] at hpe
rcases mul_eq_zero.mp hpe with h | h
· norm_num at h
· have hyt : x t - IC.trajectory S t = 0 :=
inner_self_eq_zero.mp ((mul_eq_zero.mp h).resolve_left S.k_ne_zero)
simp [HarmonicOscillator.potentialEnergy, mul_nonneg, S.k_pos.le]
have hpe' : S.k * inner ℝ (y t) (y t) = 0 := by
have hpe : S.potentialEnergy (y t) = 0 := ((add_eq_zero_iff_of_nonneg hk hp).mp (hE t)).2
simpa [HarmonicOscillator.potentialEnergy, smul_eq_mul] using hpe
rcases eq_zero_or_eq_zero_of_mul_eq_zero hpe' with h | h
· exact (S.k_pos.ne' h).elim
· have hyt : x t - IC.trajectory S t = 0 := inner_self_eq_zero.mp h
exact sub_eq_zero.mp hyt

/-!
Expand Down
Loading
Loading