Skip to content

feat(tensors): prove the Levi-Civita contraction identities - #1565

Open
Robby955 wants to merge 3 commits into
leanprover-community:masterfrom
Robby955:levicivita-contractions
Open

feat(tensors): prove the Levi-Civita contraction identities#1565
Robby955 wants to merge 3 commits into
leanprover-community:masterfrom
Robby955:levicivita-contractions

Conversation

@Robby955

Copy link
Copy Markdown
Contributor

Proves the two remaining epsilon-epsilon identities for the Lorentzian Levi-Civita tensor,
leviCivita_contract_self and leviCivita_contract_three, left as stated goals in #1348. Both
statements are unchanged.

The route is through components. Both sides are compared under (Tensor.basis _).repr and the
contractions collapse to finite sums over Fin 1 ⊕ Fin 3, where the product of two symbols is a
generalizedKroneckerDelta and the contraction machinery from #1335 gives the 24 and the 6. The
sign comes out of the metric: when the symbol is nonzero the index map is injective, hence a
bijection on a four-element type, so the four diagonal metric factors multiply to the determinant,
which is minus one in this signature.

Two component lemmas that did not exist before carry the argument and may be useful beyond it:
toDualMapAtIndex_basis_repr, the basis representation of index lowering, and
unitTensor_down_repr, the basis representation of the unit tensor of color down. The rest of the
new material is rank-four bookkeeping for this file.

The proofs elaborate within the default heartbeat budget, so no maxHeartbeats option is needed.
The nolint checkType on leviCivita_contract_self stays: that linter re-typechecks the statement,
which this change does not alter, and its comment now names the current toolchain. The Tensors API
map entry for these identities is flipped to done with a real location.

One question on placement. The two component lemmas would sit naturally next to their definitions,
toDualMapAtIndex_basis_repr in Dual.lean in particular, rather than in this file. I kept
everything local so the diff stays reviewable, and can move them wherever you prefer, here or in a
follow-up.

@github-actions github-actions Bot added the large label Aug 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for this pull-request (PR). If this is your first PR, welcome to the community!

Below is what will happen next. Please read carefully if you are not familiar with the process. You may open other PRs while this one is being reviewed, and can stack PRs on top of each other, so don't let these steps slow you down.

  1. Some automated checks will be run on your PR. You can see the results of these checks at the buttom of your PR page. If any of these checks fail, you will need to fix the issues before your PR can be merged. You can learn more about these here, including how to run them locally, which is sometimes quicker than relying on the GitHub Actions. If you have never had a PR merged before, you may have to wait for a reviewer to manually start these checks (this is for security).

  2. A reviewer will look at your PR and may ask you to make changes. This may happen a couple of days after you submit your PR, so you may need to be patient. But it should not be longer than that - if it is please bring it to the attention of the community on the Zulip. The level of review will depend on where your PR is submitted. If it is submitted to ./Physlib or ./QuantumInfo, the review will be more thorough than if it is submitted to ./PhyslibAlpha. You can find out more about what the review process is looking for in our review guidelines. If a reviewer adds an awaiting-author label to your PR, address the review comments, then please remove that label by adding a comment with -awaiting-author. This helps us keep track of reviews.

  3. The reviewer will either approve your PR, or request more changes (in which case we return to step 2). Once your PR is approved, it will be merged by a maintainer, this should happen shortly after approval, though you may get more comments at this stage.

Tip: The easiest way to get have a fast review is to submit a PR that is small and self-contained, and has clear documentation explaining why things are the way they are in your chages.

If you have any problems or questions, please reach out to the community on the Zulip.

@github-actions github-actions Bot added the t-relativity Relativity label Aug 22, 2026
@Robby955
Robby955 marked this pull request as ready for review August 22, 2026 23:17
@jstoobysmith

Copy link
Copy Markdown
Member

Will try and give a proper review tomorrow, but I think this could do with lemmas moved around bit. For example there are some IsReindexing lemmas here which should likely be in the corresponding file not here

@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.

Some more things to move.

There are also lots of small definitions/lemmas that are:

  1. Either not needed,
  2. Can be reframed in terms of useful physics API.

rw [Finset.sum_congr rfl (fun v _ => epsEtaSummand_eq v), Finset.sum_neg_distrib, h]

set_option backward.isDefEq.respectTransparency false in
lemma unitTensor_down_repr {d : ℕ}

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 be moved to the unitTensor file

exact Fintype.sum_equiv (Equiv.arrowCongr (Equiv.refl (Fin 4))
(finSumFinEquiv : (Fin 1 ⊕ Fin 3) ≃ Fin 4)) _ _ (fun _ => rfl)

lemma prod_eta_diag_of_injective {v : Fin 4 → Fin 1 ⊕ Fin 3} (hv : Function.Injective v) :

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.

Should be moved to the minkowskiMatrix file

simp only [Fintype.sum_prod_type]
rfl

lemma sum_reindex_finSumFinEquiv {M : Type} [AddCommMonoid M] (F : (Fin 4 → Fin 4) → M) :

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 is not likely needed as a sperate lemma, similar with a lot of otherr small definitions here.

rw [IsReindexing.inv_equiv_symm_eq, ← Fin.append_succAbove_const_eq_cycleIcc i,
Fin.append_right]

lemma metricTensor_repr_apply {d : ℕ} (cc : Color)

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.

MOve e.g. to the metricTensor file

simp only [basisIdxCongr_eq_refl, Equiv.refl_apply]
exact congrArg b (IsReindexing.inv_id_eq _ _)

lemma crossToSlot_basis_repr {d nA : ℕ} {c : Fin (nA+1) → Color} {cM : Fin 2 → Color}

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.

Move to crossToSlot file.

@jstoobysmith

Copy link
Copy Markdown
Member

awaiting-author

@github-actions github-actions Bot added the awaiting-author A reviewer has asked the author a question or requested changes label Aug 24, 2026
@jstoobysmith

Copy link
Copy Markdown
Member

(May also help to split this PR up into smaller bits each touching a single file)

Move reusable contraction, metric, unit, Minkowski, and Kronecker component lemmas into their owning modules. Keep the finite-index proof scaffolding private and the headline identities in LeviCivita/Contractions.
@Robby955

Copy link
Copy Markdown
Contributor Author

Thanks for the review. I have reorganized the proof around the owning APIs in ab91a437.

  • The crossToEnd and crossToSlot component formulas now live in dedicated RealTensor/Contraction modules.
  • Generic metric and unit component bridges now live in MetricTensor.lean and UnitTensor.lean; their Minkowski and Kronecker-delta specializations live in RealTensor/Metrics/Basic.lean and the new RealTensor/Units/Basic.lean.
  • The diagonal metric product has been generalized to arbitrary spatial dimension and moved to MinkowskiMatrix.lean.
  • The one-use sum-reindexing lemma was removed. The reusable free-last generalized Kronecker-delta contraction is now in KroneckerDelta/Contraction.lean.
  • The two Lorentzian identities and their private component proof now live in LeviCivita/Contractions.lean; LeviCivita/Basic.lean is again limited to the definition, components, and antisymmetry.

The exact one-sum and Kronecker/Minkowski formulas are specific to the real Lorentz bases. Putting those statements directly in the generic tensor files would either create an import cycle or require basis/contraction compatibility not present in TensorSpecies, so the generic bridges and real specializations are separated.

The two headline theorem statements are unchanged. The targeted build, full lake build Physlib, changed-file style checks, API-map check, and declaration linters pass.

-awaiting-author

@github-actions github-actions Bot removed the awaiting-author A reviewer has asked the author a question or requested changes label Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants