fix(Tensors): rank the tensor action above the Tensorial action - #1611
Conversation
`Tensorial.smulAction` has `priority := high` so that the diagonal action on tensor products beats Mathlib's left-only `TensorProduct` action. But `S.Tensor c` is itself `Tensorial` (via `self`), so a bare `g • t` also resolved through it, while the `*_equivariant` lemmas are stated with `Tensor.instSMul`. The two agree only after unfolding `LinearEquiv.refl`, so `rw`/`simp` could never match those lemmas. Give `instSMul`, `actionT` and the `DistribMulAction` on `S.Tensor c` `priority := high + 1`, and register `SMulCommClass` for the tensor action in both argument orders (as well as the missing symmetric order for `Tensorial` types). Fifteen `respectTransparency` options become unnecessary and are removed: twelve in the tensor library and three in Electromagnetism. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
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.
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. |
jstoobysmith
left a comment
There was a problem hiding this comment.
Looks good to me. Approved.
Changes
Tensors/Basic.lean:
instSMul,actionTand theDistribMulActiononS.Tensor cget priority := high + 1.SMulCommClass k G (S.Tensor c)andSMulCommClass G k (S.Tensor c)added (the second viaSMulCommClass.symm, as in Mathlib); the G k order also added for Tensorial types.as a result, multiple
set_option backward.isDefEq.respectTransparency falseremoved and amaxHeartbeats 600000.Why: an instance diamond on
g • tTwo
SMul G (S.Tensor c)instances exist:Tensor.instSMulinTensors/Basic.lean, the direct action. All*_equivariantlemmas arestated with it.
Tensorial.smulActioninTensorial.lean, defined for any[Tensorial S c M]asg • m = toTensor.symm (g • toTensor m). SinceS.Tensor cisTensorialviaself(
toTensor = LinearEquiv.refl), it also applies to bare tensors, and withpriority := highit won.
So in a goal,
g • tcarried instance 2; the lemma's left-hand side carries instance 1. They aredefeq (unfold
refl) but not syntactically equal, hencerw/simpfailed whileexactandthe
respectTransparency falseoption (unfolding fallback, paid for in heartbeats) worked.Fix: rank instance 1 at
high + 1. Bare tensors now use the direct action. Instance 2 keepshighand still governsTensorialtypes andM ⊗ M₂, where it must beat Mathlib's left-onlyTensorProductaction (Tensorial.smul_prod); lowering it instead breaks that lemma.The
SMulCommClassinstances are stated for instance 1 sosmul_commfires on it.fix found by claude and confirmed/edited by myself