Skip to content

feat(ClassicalMechanics): add geometric kinetic energy for the harmonic oscillator#1369

Merged
jstoobysmith merged 2 commits into
leanprover-community:masterfrom
nateabr:harmonic-oscillator-geometric-metric
Jul 7, 2026
Merged

feat(ClassicalMechanics): add geometric kinetic energy for the harmonic oscillator#1369
jstoobysmith merged 2 commits into
leanprover-community:masterfrom
nateabr:harmonic-oscillator-geometric-metric

Conversation

@nateabr

@nateabr nateabr commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator

I add a geometric notion of kinetic energy for the harmonic oscillator in a new file, building on the geometric ConfigurationSpace. The metric-induced kinetic energy is defined coordinate-free and parametric in any pseudo-Riemannian metric, and I then construct the oscillator's own mass metric and show it reproduces the standard KE formula.

Some challenges I ran into:

  • No inner product on tangent spaces. My first version wrote ⟪v, w⟫ directly on velocities, which doesn't compile, as Mathlib deliberately withholds inner-product/normed instances from TangentSpace. I resolved this with an explicit coordinate identification tangentCoord. I tried installing instances but the instance route creates diamonds.
  • Smoothness of the metric. fun_prop couldn't discharge this, because it can't see that the global chart inverse has identity derivative. I added a dedicated lemma establishing exactly that, which collapses the metric to a constant in the chart, after which smoothness is immediate.
  • Declaration ordering / defeq. The tangent identification and its finite-dimensional instance had to precede geometricKineticEnergy (whose type already demands them), and I needed a file-scoped set_option backward.isDefEq.respectTransparency false for the tangent≡model identification.

Developed with assistance from AI; all mathematics and proofs were reviewed and verified to compile.

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Thank you for this PR, which will now be reviewed. If submitting to ./Physlib or ./QuantumInfo, please see our review guidelines if you are not familiar with the process. You should expect a back and forth with a reviewer before your PR is merged. See also that link for how to add appropriate labels to your PR. The PR will also go through a number of automated checks. You can learn more about these here, including how to run them locally.

If you are submitting to ./PhyslibAlpha there will be a lighter review process, though your PR must still pass the automated checks.

If you want to bring attention to this PR, please write a message on this thread of the Lean Zulip.

Important: If a reviewer adds an awaiting-author label to your PR, once you have addressed the review comments, please remove that label by adding a comment with -awaiting-author. This helps us keep track of reviews.

@nateabr nateabr force-pushed the harmonic-oscillator-geometric-metric branch from 920d025 to 5d128ba Compare July 5, 2026 17:03
@nateabr

nateabr commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator Author

t-classical-mechanics

@github-actions github-actions Bot added the t-classical-mechanics Classical mechanics label Jul 5, 2026
set_option backward.isDefEq.respectTransparency false

/-- The Euclidean coordinate model for the harmonic oscillator configuration space. -/
abbrev Model := EuclideanSpace ℝ (Fin 1)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think abbreviation is wrong here, I think you should be using local notation.

/-- The chart-induced continuous linear equivalence from the tangent space at `q` to the
Euclidean coordinate model. It sends a tangent vector to its coordinate representative in
`Model`. -/
def tangentCoord (q : ConfigurationSpace) :

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should likely go in the Basic.lean file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Along with the results below (they are not about the kinetic energy)

/-- For a pseudo-Riemannian metric `g` on `Q`, the kinetic-energy function
`K_g(q, v) = 1 / 2 * g.inner q v v` on the tangent bundle `TQ`. -/
noncomputable def geometricKineticEnergy
(g : PseudoRiemannianMetric

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Mathlib now has RiemannianMetric, so we should probably use this. But should we define an explicit version of this on ConfigurationSpace rather than keeping it a free variable (i.e. move below the definition of the metric).

/-- The mass-scaled pullback of the Euclidean inner product, as a pseudo-Riemannian metric on
the oscillator configuration space. -/
noncomputable def massPseudoRiemannianMetric (S : HarmonicOscillator) :
PseudoRiemannianMetric

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would probably make this a RiemannianMetric. Also would collapse this down to one line, instead of having the arguments spread across different lines.

@jstoobysmith jstoobysmith added the awaiting-author A reviewer has asked the author a question or requested changes label Jul 6, 2026
@nateabr nateabr force-pushed the harmonic-oscillator-geometric-metric branch from fdddc99 to b52e2a6 Compare July 6, 2026 20:27
@nateabr

nateabr commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator Author

Thank you for your comments @jstoobysmith. I hope I have addressed them in the latest commit.

I have moved the parts not pertaining to KE into basic.lean.

Moving to the mathlib remannian metric required a significant rewrite and a new set of proof obligations, therefore I would appreciate if you could take another look to see if I've done things correctly.

I do believe that it was the right design choice to switch as it did not lead to any diamonds, maybe we should rethink physlib's own implementation of the metric in light of this.

-awaiting-author

@github-actions github-actions Bot removed the awaiting-author A reviewer has asked the author a question or requested changes label Jul 6, 2026

@jstoobysmith jstoobysmith left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good! We probably actually want such a metric on things like Space aswell. I agree we need to rethink the pseudo-reimannian metric in Physlib.

@jstoobysmith jstoobysmith added the ready-to-merge This PR is approved and will be merged shortly label Jul 7, 2026
@nateabr

nateabr commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

I will try to add a todo with regards to this after scoping out the relevant files.

Thank you for your review.

@jstoobysmith jstoobysmith merged commit 539c6da into leanprover-community:master Jul 7, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge This PR is approved and will be merged shortly t-classical-mechanics Classical mechanics

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants