-
Notifications
You must be signed in to change notification settings - Fork 88
Add iterated Space derivatives indexed by multi-indices #1027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
juanjfndz
wants to merge
3
commits into
leanprover-community:master
Choose a base branch
from
juanjfndz:codex/pr2-iterated-derivatives-i
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| /- | ||
| Copyright (c) 2026 Juan Jose Fernandez Morales. All rights reserved. | ||
| Released under Apache 2.0 license as described in the file LICENSE. | ||
| Authors: Juan Jose Fernandez Morales | ||
| -/ | ||
| module | ||
|
|
||
| public import Physlib.SpaceAndTime.Space.Derivatives.Basic | ||
| public import Physlib.SpaceAndTime.Space.Derivatives.MultiIndex | ||
| /-! | ||
| # Iterated derivatives on `Space d` | ||
|
|
||
| ## i. Overview | ||
|
|
||
| This module defines iterated coordinate derivatives on `Space d` indexed by multi-indices. | ||
|
|
||
| The implementation is intentionally modest. A multi-index is first expanded into a canonical list | ||
| of coordinate directions, and the iterated derivative is then defined by repeated application of | ||
| `Space.deriv` along that list. | ||
|
|
||
| ## ii. Key results | ||
|
|
||
| - `Space.iteratedDeriv` : iterated coordinate derivatives on `Space d`. | ||
| - `∂^[I] f` : notation for the iterated derivative indexed by the multi-index `I`. | ||
|
|
||
| ## iii. Table of contents | ||
|
|
||
| - A. Iterated derivatives on `Space d` | ||
|
|
||
| ## iv. References | ||
|
|
||
| -/ | ||
|
|
||
| @[expose] public section | ||
|
|
||
| namespace Space | ||
|
|
||
| open Physlib | ||
|
|
||
| variable {M : Type} {d : ℕ} | ||
|
|
||
| /-! | ||
| ## A. Iterated derivatives on `Space d` | ||
|
|
||
| -/ | ||
|
|
||
| /-- The iterated coordinate derivative on `Space d` indexed by a multi-index. -/ | ||
| noncomputable def iteratedDeriv [AddCommGroup M] [Module ℝ M] [TopologicalSpace M] | ||
| (I : MultiIndex d) (f : Space d → M) : Space d → M := | ||
| I.toList.foldr (fun i g => deriv i g) f | ||
|
|
||
| @[inherit_doc iteratedDeriv] | ||
| macro "∂^[" I:term "]" : term => `(iteratedDeriv $I) | ||
|
|
||
| @[simp] | ||
| lemma iteratedDeriv_zero [AddCommGroup M] [Module ℝ M] [TopologicalSpace M] | ||
| (f : Space d → M) : ∂^[0] f = f := by | ||
| simp [iteratedDeriv, Physlib.MultiIndex.toList_zero] | ||
|
|
||
| @[simp] | ||
| lemma iteratedDeriv_increment_zero [AddCommGroup M] [Module ℝ M] [TopologicalSpace M] | ||
| (I : MultiIndex d.succ) (f : Space d.succ → M) : | ||
| ∂^[MultiIndex.increment I 0] f = ∂[0] (∂^[I] f) := by | ||
| simp [iteratedDeriv, Physlib.MultiIndex.toList_increment_zero] | ||
|
|
||
| @[simp] | ||
| lemma iteratedDeriv_single [AddCommGroup M] [Module ℝ M] [TopologicalSpace M] | ||
| (i : Fin d) (f : Space d → M) : | ||
| ∂^[MultiIndex.increment 0 i] f = ∂[i] f := by | ||
| simp [iteratedDeriv, Physlib.MultiIndex.toList_single] | ||
|
|
||
| end Space | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be nice to define some notation for this, so we don't have to use
iteratedDeriveverywhere.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense. Before changing the API, two notation candidates that seem most natural to me here are:
∂^[I] f, to stay close to the standard mathematical notation∂^I fwhile still making the multi-index argument visually explicit in Lean;∂[I] f, as the lighter-weight option, in continuity with the existing first-order notation∂[i] f.My preference would currently be the first one, but I would be happy to go with either if you think one fits PhysLib style better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the first one is good, keeping the brackets might make it easier to define.