Skip to content

Add iterated Space derivatives indexed by multi-indices#1027

Merged
jstoobysmith merged 3 commits intoleanprover-community:masterfrom
juanjfndz:codex/pr2-iterated-derivatives-i
Apr 8, 2026
Merged

Add iterated Space derivatives indexed by multi-indices#1027
jstoobysmith merged 3 commits intoleanprover-community:masterfrom
juanjfndz:codex/pr2-iterated-derivatives-i

Conversation

@juanjfndz
Copy link
Copy Markdown
Contributor

@juanjfndz juanjfndz commented Apr 7, 2026

Summary

This PR is the second step in a planned local Classical Field Theory development for PhysLib, aimed at a formalization of the local Euler--Lagrange criterion appearing as Theorem 5.2 in Cortés--Haupt, Chapter 5.

The overall local stack is intended to proceed through:

  • multi-indices and iterated derivatives,
  • admissible compactly supported variations,
  • local jets,
  • total derivatives,
  • local lagrangians and the action functional,
  • the local Euler--Lagrange operator,
  • and finally the first-variation criterion.

The Zulip discussion for this development is here:

The previous PR, #1021, introduced the reusable MultiIndex API. This PR extends that API with the canonical ordered list of directions associated to a multi-index, and then uses it to define iterated coordinate derivatives on Space d.

What This PR Adds

This PR adds Physlib/SpaceAndTime/Space/Derivatives/Iterated.lean, updates Physlib/SpaceAndTime/Space/Derivatives/MultiIndex.lean, and adds the corresponding import in Physlib.lean.

Concretely, it provides:

  • MultiIndex.tail,
  • MultiIndex.toList,
  • MultiIndex.length_toList,
  • the definition Space.iteratedDeriv,
  • the notation ∂^[I] f,
  • and the first basic lemmas identifying the order-zero and one-step cases.

In particular, the API already gives the expected specializations

∂^[0] f = f

and

∂^[increment I 0] f = ∂[0] (∂^[I] f)

as well as the single-direction case

∂^[increment 0 i] f = ∂[i] f.

Why This Is Needed

The previous PR, #1021, provided the combinatorial indexing layer. This PR supplies both the canonical ordered realization of a multi-index and the corresponding analytic notion of iterated coordinate derivative.

Later PRs will use iterated derivatives to define the local jet evaluation

j^k_x f

by collecting the derivative coordinates of a field up to order k.

These derivatives are also the local analytic input for the jet coordinates

u^a_I

and hence for local lagrangians depending on derivatives up to order k.

So this PR is the first analytic bridge between the reusable indexing object from MultiIndex and the later local field-theory constructions.

Scope Of This PR

This PR is intentionally limited to the core definition and its first basic recursion/specialization lemmas.

It does not yet add:

  • linearity lemmas,
  • smoothness preservation lemmas,
  • or support lemmas for iterated derivatives.

Those will appear in the follow-up PR, so that the basic notion of iterated derivative can be reviewed separately before adding the later technical API needed for local jets and first variation.

Build

Locally checked with:

  • python3 scripts/lint-style.py Physlib/SpaceAndTime/Space/Derivatives/MultiIndex.lean Physlib/SpaceAndTime/Space/Derivatives/Iterated.lean
  • lake build Physlib.SpaceAndTime.Space.Derivatives.MultiIndex Physlib.SpaceAndTime.Space.Derivatives.Iterated
  • lake build Physlib
  • lake exe check_file_imports

-/

/-- The tail of a multi-index on `d + 1` coordinates, dropping the `0`-th coordinate. -/
def tail (I : MultiIndex d.succ) : MultiIndex d := ⟨fun i => I i.succ⟩
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.

These results about MultiIndex are probably best placed in that file not this one.

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

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 it would be nice to define some notation for this, so we don't have to use iteratedDeriv everywhere.

Copy link
Copy Markdown
Contributor Author

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 f while 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.

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 the first one is good, keeping the brackets might make it easier to define.

@juanjfndz
Copy link
Copy Markdown
Contributor Author

juanjfndz commented Apr 7, 2026

Thanks — I have now updated this accordingly.

Concretely:

  • the purely combinatorial MultiIndex material (tail, toList, and the associated lemmas) has been moved into Physlib/SpaceAndTime/Space/Derivatives/MultiIndex.lean,
  • and the iterated-derivative notation has been added in the form ∂^[I].


@[simp]
lemma iteratedDeriv_zero [AddCommGroup M] [Module ℝ M] [TopologicalSpace M]
(f : Space d → M) : iteratedDeriv (0 : MultiIndex d) f = f := by
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.

could use the notation here aswell.

@juanjfndz
Copy link
Copy Markdown
Contributor Author

juanjfndz commented Apr 7, 2026

Sorry — this should have been consistent already.

I have now made the notation consistent in Iterated.lean as well, and updated the PR description so that it matches the current diff.

Copy link
Copy Markdown
Member

@jstoobysmith jstoobysmith left a comment

Choose a reason for hiding this comment

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

Great - approved. Many thanks, will merge shortly

@jstoobysmith jstoobysmith marked this pull request as ready for review April 7, 2026 18:40
@jstoobysmith jstoobysmith added the ready-to-merge This PR is approved and will be merged shortly label Apr 7, 2026
@jstoobysmith jstoobysmith merged commit 5645042 into leanprover-community:master Apr 8, 2026
4 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants