Skip to content

Add MultiIndex API for local field-theory foundations#1021

Merged
jstoobysmith merged 3 commits intoleanprover-community:masterfrom
juanjfndz:codex/pr1-multiindex
Apr 6, 2026
Merged

Add MultiIndex API for local field-theory foundations#1021
jstoobysmith merged 3 commits intoleanprover-community:masterfrom
juanjfndz:codex/pr1-multiindex

Conversation

@juanjfndz
Copy link
Copy Markdown
Contributor

Summary

This PR is the first 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:

This first PR only introduces the reusable MultiIndex API needed later to index jet coordinates and iterated derivatives.

What This PR Adds

This PR adds PhysLean/Mathematics/DataStructures/MultiIndex.lean, with a small API for finitely supported multi-indices on Fin n.

Concretely, it provides:

  • the type MultiIndex n := Fin n → ℕ,
  • the order |I| = Σ_i I_i,
  • the zero multi-index,
  • increment and add operations,
  • basic lemmas about order and coordinates.

Why This Is Needed

Later PRs will use multi-indices to write the local jet coordinates

u^a_I

and iterated derivatives

∂^I = ∂_1^{I_1} ... ∂_n^{I_n}.

They also appear in the local Euler--Lagrange expression

E_a(L) = Σ_{|I| ≤ k} (-D)^I (∂L / ∂u^a_I).

So even though this first PR is small and purely reusable, it is the indexing layer that the rest of the local field-theory stack will build on.

Design Notes

I have placed this in Mathematics.DataStructures rather than under ClassicalFieldTheory, since it is meant to be reusable outside the field-theory namespace as well. That follows the earlier Zulip suggestion to keep the reusable pieces out of the domain-specific layer where possible.

Build

Locally checked with:

  • python3 scripts/lint-style.py PhysLean/Mathematics/DataStructures/MultiIndex.lean
  • lake build PhysLean.Mathematics.DataStructures.MultiIndex
  • lake build PhysLean

-/

/-- A multi-index on `n` source coordinates. -/
abbrev MultiIndex (n : ℕ) := Fin n → ℕ
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 personally would make this an structure with a single field corresponding to Fin n -> Fin d where d is the dimension. Using a structure initially will make things more difficult, as you have to define instances on it for e.g. Add, but, it gives you much more flexibility. Everytime I haven't used a structure initially I have gone on to regret it.

@juan-fernandez-gotherlabs
Copy link
Copy Markdown

Thanks — both comments made sense to me.

I have now reworked this locally so that:

  • MultiIndex is a structure (with underlying map Fin n → ℕ) rather than an abbrev,
  • the file lives under PhysLean/SpaceAndTime/Space/Derivatives/MultiIndex.lean,
  • and the import-order issue from CI is also fixed.

I will push that update to the PR branch next.

@jstoobysmith
Copy link
Copy Markdown
Member

We renamed ./PhysLean to ./Physlib which is why there is a merge conflict on this PR now. If you could fix it, that would be great, but if you need help feel free to let me know.

@juanjfndz juanjfndz force-pushed the codex/pr1-multiindex branch from 0f873ac to 5e2d986 Compare April 6, 2026 11:14
@juanjfndz
Copy link
Copy Markdown
Contributor Author

juanjfndz commented Apr 6, 2026

I have now updated the PR branch to the current Physlib tree as well.

Concretely:

  • the MultiIndex API remains under Space.Derivatives,
  • the branch is now aligned with the PhysLean -> Physlib rename,
  • and the local checks now pass again (lint-style.py, lake build Physlib.SpaceAndTime.Space.Derivatives.MultiIndex, and lake exe check_file_imports).

So this one should be back in a sane state now.


namespace MultiIndex

variable {n : ℕ}
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.

mentioned above, but could we replace n here with d since it is meant to be the dimension of Space.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good point — I have now changed this to d in the MultiIndex API so that it matches the ambient space-dimension convention more closely.

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! Many thanks! This now looks good to me. I've approved this PR, but you might have to take it out of "draft" mode.

@juanjfndz juanjfndz marked this pull request as ready for review April 6, 2026 13:18
@jstoobysmith jstoobysmith added the ready-to-merge This PR is approved and will be merged shortly label Apr 6, 2026
@jstoobysmith
Copy link
Copy Markdown
Member

Thanks - I will merge shortly :).

@jstoobysmith jstoobysmith merged commit a206948 into leanprover-community:master Apr 6, 2026
4 checks passed
@juanjfndz
Copy link
Copy Markdown
Contributor Author

Many thanks!

I'll move on to the next one tomorrow:

  • PR 2: Iterated derivatives

@jstoobysmith
Copy link
Copy Markdown
Member

Great! Looking forward to it!

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.

3 participants