[Merged by Bors] - feat(Algebra/Category): ConcreteCategory instances for rings#20815
[Merged by Bors] - feat(Algebra/Category): ConcreteCategory instances for rings#20815Vierkantor wants to merge 5 commits intomasterfrom
ConcreteCategory instances for rings#20815Conversation
PR summary fa7c15f855Import changes for modified filesNo significant changes to the import graph Import changes for all files
|
| Current number | Change | Type |
|---|---|---|
| 1415 | -2 | erw |
Current commit fa7c15f855
Reference commit c33fe046f6
You can run this locally as
./scripts/technical-debt-metrics.sh pr_summary
- The
relativevalue is the weighted sum of the differences with weight given by the inverse of the current value of the statistic. - The
absolutevalue is therelativevalue divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).
|
This PR/issue depends on: |
|
!bench |
|
Here are the benchmark results for commit b0815d4. Benchmark Metric Change
==================================================================================
- ~Mathlib.Algebra.Category.Grp.Biproducts instructions 136.0%
- ~Mathlib.Algebra.Category.ModuleCat.Biproducts instructions 82.5%
- ~Mathlib.Algebra.Category.ModuleCat.Differentials.Presheaf instructions 66.9%
- ~Mathlib.Algebra.Category.ModuleCat.Images instructions 85.2%
- ~Mathlib.Algebra.Category.ModuleCat.Kernels instructions 119.4%
- ~Mathlib.Algebra.Category.ModuleCat.Presheaf instructions 17.7%
- ~Mathlib.Algebra.Category.ModuleCat.Presheaf.Monoidal instructions 25.3%
- ~Mathlib.Algebra.Category.ModuleCat.Products instructions 127.5%
- ~Mathlib.Algebra.Category.Ring.Limits instructions 42.3%
- ~Mathlib.Algebra.Homology.ShortComplex.ModuleCat instructions 137.3%
- ~Mathlib.AlgebraicGeometry.AffineScheme instructions 15.7%
- ~Mathlib.AlgebraicGeometry.AffineSpace instructions 7.6%
- ~Mathlib.AlgebraicGeometry.Modules.Tilde instructions 17.0%
- ~Mathlib.AlgebraicGeometry.Morphisms.QuasiSeparated instructions 12.2%
- ~Mathlib.CategoryTheory.ConcreteCategory.Elementwise instructions 502.3%
- ~Mathlib.CategoryTheory.Sites.LocallySurjective instructions 103.1%
- ~Mathlib.CategoryTheory.Subobject.Limits instructions 48.2%
- ~Mathlib.Geometry.Manifold.Sheaf.Smooth instructions 60.2%
- ~Mathlib.Geometry.RingedSpace.OpenImmersion instructions 13.0%
- ~Mathlib.Geometry.RingedSpace.Stalks instructions 64.3%
+ ~Mathlib.Topology.Sheaves.CommRingCat instructions -16.0%
- ~Mathlib.Topology.Sheaves.SheafCondition.EqualizerProducts instructions 10.8%
- ~Mathlib.Topology.Sheaves.Stalks instructions 30.1% |
2 files, Instructions +40.0⬝10⁹
2 files, Instructions +13.0⬝10⁹
2 files, Instructions +8.0⬝10⁹
2 files, Instructions +7.0⬝10⁹
2 files, Instructions +6.0⬝10⁹
2 files, Instructions +5.0⬝10⁹
3 files, Instructions +4.0⬝10⁹
4 files, Instructions +3.0⬝10⁹
10 files, Instructions +2.0⬝10⁹
7 files, Instructions +1.0⬝10⁹
|
|
Ouch, that's a disappointing outcome... But I suspect quite some changes come from I'll also open a branch adding only the |
b0815d4 to
b6cb4d9
Compare
This changes nothing about the definition of ring categories except upgrading the `HasForget` instance to `ConcreteCategory`. This PR is intended mostly as an experiment to contrast with #20815 and figure out why that one has a disappointing benchmark outcome.
|
!bench |
|
Here are the benchmark results for commit b6cb4d9. Benchmark Metric Change
==================================================================================
- ~Mathlib.Algebra.Category.ModuleCat.Differentials.Presheaf instructions 66.9%
- ~Mathlib.Algebra.Category.ModuleCat.Presheaf instructions 17.6%
- ~Mathlib.Algebra.Category.ModuleCat.Presheaf.Monoidal instructions 25.3%
- ~Mathlib.Algebra.Category.Ring.Limits instructions 42.2%
- ~Mathlib.AlgebraicGeometry.AffineSpace instructions 7.6%
- ~Mathlib.AlgebraicGeometry.Modules.Tilde instructions 6.9%
- ~Mathlib.AlgebraicGeometry.Morphisms.QuasiSeparated instructions 12.2%
+ ~Mathlib.AlgebraicGeometry.OpenImmersion instructions -41.7%
+ ~Mathlib.AlgebraicGeometry.Spec instructions -21.7%
+ ~Mathlib.AlgebraicGeometry.StructureSheaf instructions -31.7%
+ ~Mathlib.Geometry.Manifold.Sheaf.Smooth instructions -43.1%
+ ~Mathlib.Geometry.RingedSpace.OpenImmersion instructions -10.5%
+ ~Mathlib.Topology.Sheaves.CommRingCat instructions -16.0% |
2 files, Instructions +3.0⬝10⁹
7 files, Instructions +2.0⬝10⁹
9 files, Instructions +1.0⬝10⁹
|
|
So it looks like sheaves of modules get slower, but sheaves of rings get faster, and the two cancel out quite neatly. Interesting! |
|
The benchmark results on the other version that does not touch |
This is a step towards a concrete category redesign, as outlined in this Zulip post: https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/Concrete.20category.20class.20redesign/near/493903980 This PR adds a `ConcreteCategory` instance for the categories of rings: `SemiRingCat`, `RingCat`, `CommSemiRingCat` and `CommRingCat`. It also replaces the `Hom.hom` structure projection with an alias for `ConcreteCategory.hom`. The latter requires a few fixes downstream where things get mistakenly unfolded (especially involving `ModuleCat.restrictScalars`) or where `rw` doesn't see through the definitional equality `ConcreteCategory.hom (ConcreteCategory.ofHom f) = f`. Finally, a few places where the proof works around the old `forget` <-> `FunLike` mismatch, and needs updating. I have not tried to look for code that can be cleaned up now, only at what broke. Better do that when the other concrete categories are in.
b6cb4d9 to
10bacfb
Compare
|
!bench |
|
Here are the benchmark results for commit dec48d2. Benchmark Metric Change
==================================================================================
- ~Mathlib.Algebra.Category.ModuleCat.Differentials.Presheaf instructions 66.8%
- ~Mathlib.Algebra.Category.ModuleCat.Presheaf instructions 17.7%
- ~Mathlib.Algebra.Category.ModuleCat.Presheaf.Monoidal instructions 25.4%
- ~Mathlib.Algebra.Category.Ring.Limits instructions 42.3%
+ ~Mathlib.AlgebraicGeometry.AffineScheme instructions -19.4%
- ~Mathlib.AlgebraicGeometry.AffineSpace instructions 6.9%
- ~Mathlib.AlgebraicGeometry.Modules.Tilde instructions 6.9%
- ~Mathlib.AlgebraicGeometry.Morphisms.QuasiSeparated instructions 12.2%
+ ~Mathlib.AlgebraicGeometry.OpenImmersion instructions -41.7%
+ ~Mathlib.AlgebraicGeometry.Spec instructions -21.7%
+ ~Mathlib.AlgebraicGeometry.StructureSheaf instructions -31.7%
+ ~Mathlib.Geometry.Manifold.Sheaf.Smooth instructions -43.1%
+ ~Mathlib.Geometry.RingedSpace.OpenImmersion instructions -10.4%
+ ~Mathlib.Topology.Sheaves.CommRingCat instructions -16.0% |
2 files, Instructions +18.0⬝10⁹
2 files, Instructions +3.0⬝10⁹
5 files, Instructions +2.0⬝10⁹
10 files, Instructions +1.0⬝10⁹
|
|
Huh, apart from that one slowdown, this PR apparently was quite good for timings in |
|
Let's merge master and re-bench. This was a motivation for pushing through #11521. I'm curious to see the effects. |
|
Ok! So should I just merge master, or also add |
|
Merging master should be sufficient. It might be the case that we have some more mismatched instance shapes but I don't know. |
|
!bench |
|
Here are the benchmark results for commit fa7c15f. Benchmark Metric Change
==================================================================================
- ~Mathlib.Algebra.Category.ModuleCat.Differentials.Presheaf instructions 67.0%
- ~Mathlib.Algebra.Category.ModuleCat.Presheaf instructions 17.6%
- ~Mathlib.Algebra.Category.ModuleCat.Presheaf.Monoidal instructions 25.5%
- ~Mathlib.Algebra.Category.Ring.Limits instructions 46.5%
+ ~Mathlib.AlgebraicGeometry.AffineScheme instructions -18.3%
- ~Mathlib.AlgebraicGeometry.AffineSpace instructions 7.0%
- ~Mathlib.AlgebraicGeometry.Modules.Tilde instructions 8.7%
- ~Mathlib.AlgebraicGeometry.Morphisms.QuasiSeparated instructions 11.9%
+ ~Mathlib.AlgebraicGeometry.OpenImmersion instructions -41.0%
+ ~Mathlib.AlgebraicGeometry.Spec instructions -27.1%
+ ~Mathlib.AlgebraicGeometry.StructureSheaf instructions -32.6%
+ ~Mathlib.Geometry.Manifold.Sheaf.Smooth instructions -43.0%
+ ~Mathlib.Geometry.RingedSpace.OpenImmersion instructions -10.1%
+ ~Mathlib.Topology.Sheaves.CommRingCat instructions -16.2% |
3 files, Instructions +3.0⬝10⁹
6 files, Instructions +2.0⬝10⁹
6 files, Instructions +1.0⬝10⁹
2 files, Instructions -29.0⬝10⁹
|
|
Net positive. I want to poke at the regressions but that can be done from master. bors merge |
This is a step towards a concrete category redesign, as outlined in this Zulip post: https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/Concrete.20category.20class.20redesign/near/493903980 This PR adds a `ConcreteCategory` instance for the categories of rings: `SemiRingCat`, `RingCat`, `CommSemiRingCat` and `CommRingCat`. It also replaces the `Hom.hom` structure projection with an alias for `ConcreteCategory.hom`. The latter requires a few fixes downstream where things get mistakenly unfolded (especially involving `ModuleCat.restrictScalars`) or where `rw` doesn't see through the definitional equality `ConcreteCategory.hom (ConcreteCategory.ofHom f) = f`. Finally, a few places where the proof works around the old `forget` <-> `FunLike` mismatch, and needs updating. I have not tried to look for code that can be cleaned up now, only at what broke. I want to get started on cleanup when the other concrete category instances are in. Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>
|
Pull request successfully merged into master. Build succeeded: |
ConcreteCategory instances for ringsConcreteCategory instances for rings
* origin/master: (294 commits) feat: equalizers and coequalizers in the category of ind-objects (#21139) doc: turn more links to Stacks into `@[stacks]` tags (#21135) feat(Asymptotics): prove `IsLittleOTVS.add` (#20578) feat(Algebra/Polynomial): `Polynomial.aeval` for product algebras (#21062) chore: import Std in Mathlib.lean (#21126) feat(Data/Matroid/Circuit): fundamental circuits and extensionality (#21145) feat(CategoryTheory/Endofunctor): prove the dual form of Lambek's Lemma on terminal coalgebra (#21140) feat(SetTheory/Game/PGame): rewrite left moves of `-x` as right moves of `x` under binders (#21109) feat(RingTheory/Localization/Pi): localization of a finite direct product is a product of localizations (#19042) doc: fixed notation error in customizing category composition (#21132) feat(Matrix): more lemmas for `PEquiv.toMatrix` (#21143) chore(SupIndep): speedup the `Decidable` instance (#21114) fix(CI): use `Elab.async=false` for late importers workflow (#21147) feat(Topology/Algebra/Indicator): indicator of a clopen is continuous (#20687) feat(Data/Matroid/Rank/Cardinal): Cardinality-valued rank function (#20921) feat(Algebra): `Pi.single_induction` (#21141) chore(BigOperators/Fin): golf a proof (#21131) feat: generalize tangent cone lemmas to TVS (#20859) feat(CategoryTheory): `Comma.snd L R` is final if `R` is final and domains are filtered (#21136) refactor: unapply matrix lemmas (#21091) chore(Algebra/Category): `erw` -> `rw` (#21130) feat(CategoryTheory): filteredness of Comma catgories given finality of one of the functors (#21128) feat(Algebra/Category): `ConcreteCategory` instance for `ModuleCat` (#21125) feat: PSum of finite sorts is finite (#20285) feat: inequality on the integral of a convex function of a RN derivative (#21093) feat: `(v +ᵥ s) -ᵥ (v +ᵥ t) = s -ᵥ t` (#21058) chore: rename the fact that `(∀ a < a₁, a ≤ a₂) ↔ a₁ ≤ a₂` in a dense order (#20317) feat: a `RelHom` preserves directedness (#20080) feat(Combinatorics/SimpleGraph): add definitions and theorems about the coloring of sum graphs (#18677) chore(Data/Matrix/PEquiv): clean up names (#21108) feat(Algebra/Category): `ConcreteCategory` instances for rings (#20815) feat: define Descriptive.Tree (#18763) chore(Data/Complex/Exponential): split trig functions to new file (#21075) feat(Logic/IsEmpty/Relator): empty on sides (#20319) feat(Algebra/Category): `ConcreteCategory` instance for `AlgebraCat` (#21121) feat(NumberTheory/LSeries): results involving partial sums of coefficients (part 1) (#20661) feat(RingTheory/LaurentSeries): add algebraEquiv (#21004) chore(SetTheory/Game/Impartial): golf two proofs (#21074) feat(CategoryTheory/Subpresheaf): preimage/image/range of subpresheaves (#21047) feat(RingTheory/IntegralClosure): `Algebra.IsIntegral` transfers via surjective homomorphisms (#21023) feat(`InformationTheory/Hamming`): Add AddGroup instances (#20994) feat(RingTheory/IntegralClosure): prove `Module.Finite R (adjoin R S)` for finite set `S` of integral elements (#20970) feat(RingTheory/Artinian): `IsUnit a` iff `a ∈ R⁰` for an artinian ring `R` (#21084) feat: separating set in the category of ind-objects (#21082) feat: derivWithin lemmas (#21092) chore(Fintype): golf a proof (#21113) chore: golf using `funext₂` (#21106) chore(Algebra/Group/Submonoid/Operations): move instances to new file (#21067) doc(Algebra/BigOperators/Fin): change 'product' to 'sum' in doc-string of additivised declarations (#21101) doc(ComputeDegree): typos (#21095) ...
* polynomial-sequences: (308 commits) Use the lemma we already added. Minor reordering. This is true even for the trivial ring. Also add the lt versions and the other inj lemma. Also add the basis ne versions. This seems also like it should be simp. Back to sorry free. And the natDegree version. feat: equalizers and coequalizers in the category of ind-objects (#21139) doc: turn more links to Stacks into `@[stacks]` tags (#21135) feat(Asymptotics): prove `IsLittleOTVS.add` (#20578) feat(Algebra/Polynomial): `Polynomial.aeval` for product algebras (#21062) chore: import Std in Mathlib.lean (#21126) feat(Data/Matroid/Circuit): fundamental circuits and extensionality (#21145) feat(CategoryTheory/Endofunctor): prove the dual form of Lambek's Lemma on terminal coalgebra (#21140) feat(SetTheory/Game/PGame): rewrite left moves of `-x` as right moves of `x` under binders (#21109) feat(RingTheory/Localization/Pi): localization of a finite direct product is a product of localizations (#19042) doc: fixed notation error in customizing category composition (#21132) feat(Matrix): more lemmas for `PEquiv.toMatrix` (#21143) chore(SupIndep): speedup the `Decidable` instance (#21114) fix(CI): use `Elab.async=false` for late importers workflow (#21147) feat(Topology/Algebra/Indicator): indicator of a clopen is continuous (#20687) feat(Data/Matroid/Rank/Cardinal): Cardinality-valued rank function (#20921) feat(Algebra): `Pi.single_induction` (#21141) chore(BigOperators/Fin): golf a proof (#21131) feat: generalize tangent cone lemmas to TVS (#20859) feat(CategoryTheory): `Comma.snd L R` is final if `R` is final and domains are filtered (#21136) refactor: unapply matrix lemmas (#21091) chore(Algebra/Category): `erw` -> `rw` (#21130) feat(CategoryTheory): filteredness of Comma catgories given finality of one of the functors (#21128) feat(Algebra/Category): `ConcreteCategory` instance for `ModuleCat` (#21125) feat: PSum of finite sorts is finite (#20285) feat: inequality on the integral of a convex function of a RN derivative (#21093) feat: `(v +ᵥ s) -ᵥ (v +ᵥ t) = s -ᵥ t` (#21058) chore: rename the fact that `(∀ a < a₁, a ≤ a₂) ↔ a₁ ≤ a₂` in a dense order (#20317) feat: a `RelHom` preserves directedness (#20080) feat(Combinatorics/SimpleGraph): add definitions and theorems about the coloring of sum graphs (#18677) chore(Data/Matrix/PEquiv): clean up names (#21108) feat(Algebra/Category): `ConcreteCategory` instances for rings (#20815) feat: define Descriptive.Tree (#18763) chore(Data/Complex/Exponential): split trig functions to new file (#21075) feat(Logic/IsEmpty/Relator): empty on sides (#20319) feat(Algebra/Category): `ConcreteCategory` instance for `AlgebraCat` (#21121) feat(NumberTheory/LSeries): results involving partial sums of coefficients (part 1) (#20661) feat(RingTheory/LaurentSeries): add algebraEquiv (#21004) chore(SetTheory/Game/Impartial): golf two proofs (#21074) feat(CategoryTheory/Subpresheaf): preimage/image/range of subpresheaves (#21047) feat(RingTheory/IntegralClosure): `Algebra.IsIntegral` transfers via surjective homomorphisms (#21023) feat(`InformationTheory/Hamming`): Add AddGroup instances (#20994) feat(RingTheory/IntegralClosure): prove `Module.Finite R (adjoin R S)` for finite set `S` of integral elements (#20970) ...
This is a step towards a concrete category redesign, as outlined in this Zulip post: https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/Concrete.20category.20class.20redesign/near/493903980
This PR adds a
ConcreteCategoryinstance for the categories of rings:SemiRingCat,RingCat,CommSemiRingCatandCommRingCat. It also replaces theHom.homstructure projection with an alias forConcreteCategory.hom. The latter requires a few fixes downstream where things get mistakenly unfolded (especially involvingModuleCat.restrictScalars) or whererwdoesn't see through the definitional equalityConcreteCategory.hom (ConcreteCategory.ofHom f) = f. Finally, a few places where the proof works around the oldforget<->FunLikemismatch, and needs updating.I have not tried to look for code that can be cleaned up now, only at what broke. I want to get started on cleanup when the other concrete category instances are in.