Repository navigation
[Merged by Bors] - feat(Algebra): inherit cancellation to subobjects - #27992
staroperator wants to merge 10 commits into
Conversation
PR summary a43dd5b131Import changes for modified filesNo significant changes to the import graph Import changes for all files
|
| /-- A submonoid of a left cancellative unital magma inherits left cancellation. -/ | ||
| @[to_additive | ||
| "An `AddSubmonoid` of a left cancellative unital additive magma inherits left cancellation."] | ||
| instance isLeftCancelMul [IsLeftCancelMul M] (S : Submonoid M) : IsLeftCancelMul S := | ||
| Subtype.coe_injective.isLeftCancelMul Subtype.val fun _ _ => rfl | ||
|
|
||
| /-- A submonoid of a right cancellative unital magma inherits right cancellation. -/ | ||
| @[to_additive | ||
| "An `AddSubmonoid` of a right cancellative unital additive magma inherits right | ||
| cancellation."] | ||
| instance isRightCancelMul [IsRightCancelMul M] (S : Submonoid M) : IsRightCancelMul S := | ||
| Subtype.coe_injective.isRightCancelMul Subtype.val fun _ _ => rfl | ||
|
|
||
| /-- A submonoid of a cancellative unital magma inherits cancellation. -/ | ||
| @[to_additive "An `AddSubmonoid` of a cancellative unital additive magma inherits cancellation."] | ||
| instance isCancelMul [IsCancelMul M] (S : Submonoid M) : IsCancelMul S where | ||
|
|
There was a problem hiding this comment.
@Vierkantor or @j-loreaux, do you remember if we discovered it was better to duplicate these instances for MulMemClass and the concrete instantiations? Certainly we still seem to do so for the Monoid instance above.
There was a problem hiding this comment.
I don't recall any reason behind the duplication. Suggestion: deduplicate that instance too and see if anything breaks.
There was a problem hiding this comment.
I think there were performance reasons, and the benchmarking right now is unreliable so I think now is a bad time to test that.
There was a problem hiding this comment.
I guess duplicating these instances are harmless since IsCancelMul/Add are Prop valued.
There was a problem hiding this comment.
Harmless up to performance, anyway.
|
This pull request has conflicts, please merge |
4e50a3e to
4077483
Compare
|
Benchmarks seem to have become a lot more stable compared to last month. So let's see what they think: |
|
!bench |
Vierkantor
left a comment
There was a problem hiding this comment.
I went ahead and added the keyword "subobjects" to the PR title, to make clear where we inherit the cancellation too. Feel free to adjust as you see fit.
I'll run a benchmark as well, to see what happens if we only inherit for the MulMemClasses, and not for the concrete subobjects like Subalgebra etc.
|
Here are the benchmark results for commit 44a669b. Benchmark Metric Change
============================================
+ build linting -16.1%
+ build process pre-definitions -5.9% |
2 files, Instructions +8.0⬝10⁹
2 files, Instructions +7.0⬝10⁹
3 files, Instructions +6.0⬝10⁹
7 files, Instructions +5.0⬝10⁹
36 files, Instructions +4.0⬝10⁹
82 files, Instructions +3.0⬝10⁹
95 files, Instructions +2.0⬝10⁹
461 files, Instructions +1.0⬝10⁹
346 files, Instructions -2.0⬝10⁹
65 files, Instructions -3.0⬝10⁹
41 files, Instructions -4.0⬝10⁹
17 files, Instructions -5.0⬝10⁹
7 files, Instructions -6.0⬝10⁹
2 files, Instructions -7.0⬝10⁹
2 files, Instructions -8.0⬝10⁹
|
|
(The compared-to commit is from during the benchmark instability, so we should ignore it for now, and only compare this benchmark with the commit I am benchmarking in a moment.) |
…nferred automatically This is intended mostly to be benchmarked, for comparison with leanprover-community#27992 which keeps these instances. Our hypothesis is that this commit will see performance regressions.
|
Benchmark results are in. Here the "original" is this PR, the "new" is this PR but with the specific instances removed. I do not see any significant performance changes in total build time or instance synthesis. So: performance does not appear a reason to keep the duplicate instances. I suggest removing them. (Feel free to cherry-pick my commit ebbd142 for this purpose.) |
…nferred automatically This is intended mostly to be benchmarked, for comparison with leanprover-community#27992 which keeps these instances. Our hypothesis is that this commit will see performance regressions.
|
@Vierkantor Thank you so much for your help! I will remove the duplications. |
|
This pull request has conflicts, please merge |
|
Thanks! bors d+ |
|
✌️ staroperator can now approve this pull request. To approve and merge a pull request, simply reply with |
|
bors d+ |
|
✌️ staroperator can now approve this pull request. To approve and merge a pull request, simply reply with |
|
Sorry, bors r+ |
|
bors r+ |
This PR:
1. adds `Is{Left,Right}Cancel{Add,Mul,MulZero}` instances for `{Add,Mul,MulZero}MemClass` etc.
2. removes the duplicated instances for `Submonoid` and `Submodule` which are introduced in #27955 (benchmark results show there isn't large difference with duplicated instances).
Thanks @Vierkantor's help in benchmarks.
Co-authored-by: Anne C.A. Baanen <[email protected]>
|
Pull request successfully merged into master. Build succeeded: |
…ty#27992) This PR: 1. adds `Is{Left,Right}Cancel{Add,Mul,MulZero}` instances for `{Add,Mul,MulZero}MemClass` etc. 2. removes the duplicated instances for `Submonoid` and `Submodule` which are introduced in leanprover-community#27955 (benchmark results show there isn't large difference with duplicated instances). Thanks @Vierkantor's help in benchmarks. Co-authored-by: Anne C.A. Baanen <[email protected]>
…ty#27992) This PR: 1. adds `Is{Left,Right}Cancel{Add,Mul,MulZero}` instances for `{Add,Mul,MulZero}MemClass` etc. 2. removes the duplicated instances for `Submonoid` and `Submodule` which are introduced in leanprover-community#27955 (benchmark results show there isn't large difference with duplicated instances). Thanks @Vierkantor's help in benchmarks. Co-authored-by: Anne C.A. Baanen <[email protected]>
…ty#27992) This PR: 1. adds `Is{Left,Right}Cancel{Add,Mul,MulZero}` instances for `{Add,Mul,MulZero}MemClass` etc. 2. removes the duplicated instances for `Submonoid` and `Submodule` which are introduced in leanprover-community#27955 (benchmark results show there isn't large difference with duplicated instances). Thanks @Vierkantor's help in benchmarks. Co-authored-by: Anne C.A. Baanen <[email protected]>
This PR:
Is{Left,Right}Cancel{Add,Mul,MulZero}instances for{Add,Mul,MulZero}MemClassetc.SubmonoidandSubmodulewhich are introduced in [Merged by Bors] - feat(Algebra): submonoids and submodules inherit cancellations #27955 (benchmark results show there isn't large difference with duplicated instances).Thanks @Vierkantor's help in benchmarks.