[Merged by Bors] - chore: mark Submodule.toAddSubgroup @[reducible]#35761
[Merged by Bors] - chore: mark Submodule.toAddSubgroup @[reducible]#35761
Conversation
PR summary 9b1001cbdbImport changes for modified filesNo significant changes to the import graph Import changes for all files
Declarations diffNo declarations were harmed in the making of this PR! 🐙 You can run this locally as follows## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>
## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>The doc-module for Decrease in tech debt: (relative, absolute) = (25.25, 0.54)
Current commit 416e79d87c You can run this locally as
|
Commit Verification SummaryWarning Some verifications failed. See details below. Commits to Review (2)
\u274c Automated commits (1) - 0/1 verified
Generated by commit verification CI |
46fccb0 to
2d59d24
Compare
|
Can you explain what the repro for this was and why it is a good idea in the PR description? |
I would really prefer not to. It is explained in the Zulip threads. |
|
My reading of that thread is "we should do this because it makes the error go away", I don't see any strong claim that this is actually the direction we want to go in or why. If you intend to make that claim, then the PR description is the place to put it. |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
|
|
Is every I'd assumed that was only true of |
https://github.com/leanprover/lean4/blob/master/src/Lean/Meta/Structure.lean#L114C1-L116C49 Structure parents are reducible: This really needs to be in reference manual rather than digging through the code to understand. :-( |
|
So maybe the right fix here is actually |
|
That seems like the right conclusion to me, thanks for the test-case. |
|
Do we want to encourage |
Submodule.toAddSubgroup @[implicit_reducible]Structure parent projections are [reducible], so this pseudo-parent should be too. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
!bench |
|
Benchmark results for 52f499c against 02dfd80 are in! @eric-wieser
No significant changes detected. |
…oup_inj These are now provable by simp via unfolding the @[reducible] toAddSubgroup. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| | _, _, h => SetLike.ext (SetLike.ext_iff.1 h :) | ||
|
|
||
| @[simp] | ||
| theorem toAddSubgroup_inj : p.toAddSubgroup = p'.toAddSubgroup ↔ p = p' := |
There was a problem hiding this comment.
This seems a little asymmetric with toAddSubmonoid_inj, which is allowed by simp. I suppose if it were a "real" projection though (with overlapping base classes) we'd have the same behavior, so fixing the asymmetry is out of scope.
|
This seems unobjectionable to me. This also fits within the scope of the library note |
|
This pull request has conflicts, please merge |
Does it? That note is for things whose type is a class, am which AddSubgroup is not. I'm not opposed to the PR, but this isn't the first time this confusion has come up in discussion about it |
Oops, my bad. You're right. It still seems fine, though. |
# Conflicts: # Mathlib/RingTheory/Flat/Equalizer.lean # Mathlib/RingTheory/Noetherian/Basic.lean
…ntroduced by merge Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
4afb10d to
92305ea
Compare
…p_toAddSubmonoid Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
!bench |
|
Benchmark results for 416e79d against 9b1001c are in! @kim-em
No significant changes detected. |
|
I'm taking Floris' message about as now a bors d+, since the benchmark was fine. bors merge |
This PR marks `Submodule.toAddSubgroup` as `@[reducible]`, matching the reducibility that a real structure parent projection would have (Lean marks structure parent projections `[reducible]`). This resolves `backward.isDefEq.respectTransparency` failures where Lean needs to see that `s.toAddSubgroup.toAddSubmonoid = s.toAddSubmonoid`.
The motivating example is:
```lean
instance {V : Type} [AddCommGroup V] [Module ℝ V] {l : Submodule ℝ V} :
Module.Free ℝ l := Module.Free.of_divisionRing ℝ l
```
which fails with `backward.isDefEq.respectTransparency` because synthesis of `Module ℝ ↥l` needs `Submodule.module`, whose `AddCommMonoid` comes through `toAddSubgroup` (a virtual parent), while the `Module` prerequisite expects `AddCommMonoid` from `toAddSubmonoid` (a real projection). Lean must unfold `toAddSubgroup` to see these agree, but as a plain `def` it was `[semireducible]` and invisible at instance transparency.
See [#general > backward.isDefEq.respectTransparency](https://leanprover.zulipchat.com/#narrow/channel/113488-general/topic/backward.2EisDefEq.2ErespectTransparency/near/575748939) and the synthetic test case in #35750.
|
Pull request successfully merged into master. Build succeeded:
|
…y#35761) This PR marks `Submodule.toAddSubgroup` as `@[reducible]`, matching the reducibility that a real structure parent projection would have (Lean marks structure parent projections `[reducible]`). This resolves `backward.isDefEq.respectTransparency` failures where Lean needs to see that `s.toAddSubgroup.toAddSubmonoid = s.toAddSubmonoid`. The motivating example is: ```lean instance {V : Type} [AddCommGroup V] [Module ℝ V] {l : Submodule ℝ V} : Module.Free ℝ l := Module.Free.of_divisionRing ℝ l ``` which fails with `backward.isDefEq.respectTransparency` because synthesis of `Module ℝ ↥l` needs `Submodule.module`, whose `AddCommMonoid` comes through `toAddSubgroup` (a virtual parent), while the `Module` prerequisite expects `AddCommMonoid` from `toAddSubmonoid` (a real projection). Lean must unfold `toAddSubgroup` to see these agree, but as a plain `def` it was `[semireducible]` and invisible at instance transparency. See [#general > backward.isDefEq.respectTransparency](https://leanprover.zulipchat.com/#narrow/channel/113488-general/topic/backward.2EisDefEq.2ErespectTransparency/near/575748939) and the synthetic test case in leanprover-community#35750.
This PR marks
Submodule.toAddSubgroupas@[reducible], matching the reducibility that a real structure parent projection would have (Lean marks structure parent projections[reducible]). This resolvesbackward.isDefEq.respectTransparencyfailures where Lean needs to see thats.toAddSubgroup.toAddSubmonoid = s.toAddSubmonoid.The motivating example is:
which fails with
backward.isDefEq.respectTransparencybecause synthesis ofModule ℝ ↥lneedsSubmodule.module, whoseAddCommMonoidcomes throughtoAddSubgroup(a virtual parent), while theModuleprerequisite expectsAddCommMonoidfromtoAddSubmonoid(a real projection). Lean must unfoldtoAddSubgroupto see these agree, but as a plaindefit was[semireducible]and invisible at instance transparency.See #general > backward.isDefEq.respectTransparency and the synthetic test case in #35750.