Skip to content

feat(Tensors): HasContrDualBases, the dual-basis class, and the component formulas it collapses - #1722

Merged
jstoobysmith merged 2 commits into
leanprover-community:masterfrom
pariandrea:pr01-tensor-dual-bases
Oct 2, 2026
Merged

jstoobysmith merged 2 commits into
leanprover-community:masterfrom
pariandrea:pr01-tensor-dual-bases

Conversation

@pariandrea

Copy link
Copy Markdown
Contributor

The axioms of TensorSpecies do not say what S.contr gives on basis vectors. The general
component formula for a contraction therefore keeps S.contr (b x₁ ⊗ₜ b x₂) as an unevaluated
factor in a double sum, and each species proved its own single-sum formula by evaluating that
factor case by case. This PR states the missing fact once, as a class: at every color the basis at
S.τ c is dual to the basis at c under S.contr c, up to a bijection of labels. The real and
complex Lorentz species instantiate it, and their case-by-case proofs now follow from two general
lemmas (the −57 lines).

The class is a Prop asking only that some label bijection satisfies the δ law, so the label types
at c and S.τ c need not be equal (Fin 4 against Fin 1 ⊕ Fin 3 is allowed). Over a
nontrivial ring the bijection is unique, so the one picked by Classical.choose is canonical, each
species identifies it by a simp lemma, and the double-dual law is a theorem rather than a field.
The functionals v ↦ S.contr c (v ⊗ₜ b (S.τ c) x) are proved to be Module.Basis.dualBasis.

Added

Physlib/Relativity/Tensors/TensorSpecies/DualBasis.lean (new)

  • IsContrDualMatching S c e: the bijection e : basisIdx (S.τ c) ≃ basisIdx c satisfies the δ
    law, S.contr c (b c x₁ ⊗ₜ b (S.τ c) x₂) = if x₁ = e x₂ then 1 else 0.
  • IsContrDualMatching.unique: over a nontrivial ring two such bijections are equal.
  • HasContrDualBases: the class, with one field exists_matching : ∀ c, ∃ e, IsContrDualMatching S c e.
  • HasContrDualBases.contrDualIdxEquiv: the bijection, chosen by Classical.choose.
  • HasContrDualBases.contr_basis_eq_ite: the δ law for contrDualIdxEquiv.
  • HasContrDualBases.contrDualIdxEquiv_eq_of_isContrDualMatching: any bijection satisfying the δ
    law is contrDualIdxEquiv; this is how a species identifies it.
  • HasContrDualBases.contrDualIdxEquiv_tau: the bijection at S.τ c is the inverse of the one at
    c, through S.τ (S.τ c) = c, proved from contr_tmul_symm and uniqueness.
  • HasContrDualBases.contr_tmul_basis_eq_dualBasis: contracting with b (S.τ c) x is the
    Module.Basis.dualBasis functional at the matched label.

Physlib/Relativity/Tensors/TensorSpecies/Basic.lean

  • equivCast_basis: map_basis_eq with the cast written as Equiv.cast, the form
    contr_tmul_symm produces; used in contrDualIdxEquiv_tau.

Physlib/Relativity/Tensors/Contraction/Basis.lean

  • Pure.contrPCoeff_basisVector: the contraction coefficient of a basis vector is the δ.
  • contrT_basis_repr_apply_eq_sum_dual: a component of a contraction is a single sum over the
    labels at the first contracted index.

Physlib/Relativity/Tensors/RealTensor/Basic.lean

  • isContrDualMatching_refl, the instance, and contrDualIdxEquiv_eq_refl (simp): the
    bijection is the identity.
  • contrPCoeff_basis, contrT_basis_repr_apply_eq_fin: statements unchanged, proofs now two lines.

Physlib/Relativity/Tensors/ComplexTensor/Basic.lean

  • isContrDualMatching_finCongr, the instance, and contrDualIdxEquiv_eq_finCongr (simp): the
    bijection is finCongr repDim_tau.
  • contrPCoeff_basis: statement unchanged, proof now three lines.

Removed: none.

Reviewer map

  1. DualBasis.lean, sections A to C: the δ law, uniqueness, the class and the chosen bijection.
  2. DualBasis.lean, sections D and E, with equivCast_basis: the double-dual law and the link
    to Module.Basis.dualBasis.
  3. Contraction/Basis.lean: the two general lemmas.
  4. RealTensor/Basic.lean, then ComplexTensor/Basic.lean: the instances and the shortened proofs.

…nent formulas it collapses

Adds `TensorSpecies.HasContrDualBases`: at every color some bijection of labels
(`IsContrDualMatching`) makes the basis at `S.τ c` dual to the basis at `c` under `S.contr c`.
Over a nontrivial ring the bijection is unique (`IsContrDualMatching.unique`), so
`contrDualIdxEquiv`, chosen by `Classical.choose`, is identified per species through
`contrDualIdxEquiv_eq_of_isContrDualMatching`, and the double-dual law `contrDualIdxEquiv_tau` is
a theorem. `contr_tmul_basis_eq_dualBasis` relates the class to `Module.Basis.dualBasis`.

`Pure.contrPCoeff_basisVector` and `contrT_basis_repr_apply_eq_sum_dual` give the contraction
coefficient and components for any such species. The real and complex Lorentz species
instantiate the class, with the identity and `finCongr repDim_tau`, and their `contrPCoeff_basis`
and `contrT_basis_repr_apply_eq_fin` now follow from the general lemmas with unchanged statements.

Co-authored-by: Claude Opus 5.5 <no-reply+claude-opus-5-5@anthropic.com>
@github-actions github-actions Bot added the medium label Oct 2, 2026
@github-actions

github-actions Bot commented Oct 2, 2026

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 Oct 2, 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.

One small comment here. Otherwise this looks good.

/-- A complex Lorentz color and its dual have the same representation dimension (`repDim_tau`),
and the matching `finCongr repDim_tau` satisfies the δ law: it is the basis contraction of each of
the six Weyl and Lorentz pairings. -/
lemma isContrDualMatching_finCongr (c : complexLorentzTensor.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.

I think the doc-string of this result can be made a bit simpler.

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.

I simplified the docstring. I did the same for the RealTensor too.

@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 Oct 2, 2026
…r and isContrDualMatching_refl

State only the result: the bases at a color and its dual are dual bases under the given matching.

Co-authored-by: Claude Opus 5.5 <no-reply+claude-opus-5-5@anthropic.com>
@pariandrea

Copy link
Copy Markdown
Contributor Author

-awaiting-author

@github-actions github-actions Bot removed the awaiting-author A reviewer has asked the author a question or requested changes label Oct 2, 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.

Approved. Will merge shortly. Many thanks.

@jstoobysmith jstoobysmith added the ready-to-merge This PR is approved and will be merged shortly label Oct 2, 2026
@jstoobysmith
jstoobysmith added this pull request to the merge queue Oct 2, 2026
Merged via the queue into leanprover-community:master with commit d630c36 Oct 2, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

medium ready-to-merge This PR is approved and will be merged shortly t-relativity Relativity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants