Skip to content

[Merged by Bors] - feat: algebraic hierarchy on DirectLimit#19893

Closed
alreadydone wants to merge 12 commits intomasterfrom
DirectLimit.v3
Closed

[Merged by Bors] - feat: algebraic hierarchy on DirectLimit#19893
alreadydone wants to merge 12 commits intomasterfrom
DirectLimit.v3

Conversation

@alreadydone
Copy link
Copy Markdown
Contributor

@alreadydone alreadydone commented Dec 11, 2024

Order/DirectedInverseSystem.lean: define the DirectLimit of a DirectedSystem of types as a quotient (by a setoid (equivalence relation)) of the Sigma type (disjoint union). Provide the induction lemmas and map/lift constructions used to define algebraic operations on DirectLimit.

New file Algebra/Colimit/DirectLimit.lean: the first 400 lines are boilerplate code that defines algebraic instances on DirectLImit from magma (Mul) to Field. To make everything "hom-polymorphic", the DirectedSystem consists of FunLikes rather than plain/unbundled functions, and we use algebraic hom typeclasses (e.g. LinearMapClass, RingHomClass) everywhere. The remaining 70 lines essentially shows that DirectLimit is the colimit in the categories of Module and Ring.

Algebra/DirectLimit.lean: renamed to Algebra/Colimit/ModuleRing.lean. This file was originally added @kckennylau 5 years ago in mathlib3#754 and defines Module.DirectLimit and Ring.DirectLimit as quotients of the universal objects (DirectSum and FreeCommRing). This definition is more general and suitable for arbitrary colimits, but makes it very cumbersome to prove of.zero_exact lemmas (130+ lines!); for DirectLimit constructed as quotients of the disjoint union, these are just by definition. We golf these proofs by constructing isomorphisms between Module/Ring.DirectLimit and _root_.DirectLimit. I have more work done that generalizes most lemmas there to work for arbitrary colimits, that's why I put it under a new Colimit directory.

Data/Int/Cast/Lemmas.lean: add map_intCast'
Data/Nat/Cast/Basic.lean: golf a lemma
Order/Directed.lean: add a lemma
ModelTheory/DirectLimit.lean: change two lemmas to aliases of the general FunLike lemmas


Open in Gitpod

@alreadydone alreadydone added the t-algebra Algebra (groups, rings, fields, etc) label Dec 11, 2024
@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 11, 2024

PR summary 19359074a7

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference
Mathlib.Algebra.DirectLimit -1105
85 files Mathlib.Algebra.Homology.ShortComplex.Ab Mathlib.AlgebraicGeometry.Modules.Sheaf Mathlib.RepresentationTheory.GroupCohomology.Hilbert90 Mathlib.Algebra.Category.ModuleCat.Limits Mathlib.Algebra.Category.FGModuleCat.Limits Mathlib.Algebra.Category.Grp.AB Mathlib.Condensed.Limits Mathlib.Algebra.Category.ModuleCat.Abelian Mathlib.CategoryTheory.Abelian.Ext Mathlib.Algebra.Category.ModuleCat.AB Mathlib.Algebra.Category.ModuleCat.Differentials.Basic Mathlib.AlgebraicGeometry.Modules.Presheaf Mathlib.Algebra.Category.ModuleCat.ChangeOfRings Mathlib.CategoryTheory.Sites.SheafCohomology.Basic Mathlib.Algebra.Category.ModuleCat.Presheaf.Limits Mathlib.Topology.Category.Profinite.Nobeling Mathlib.Condensed.Light.Explicit Mathlib.Analysis.Fourier.FiniteAbelian.PontryaginDuality Mathlib.Topology.Sheaves.MayerVietoris Mathlib.Algebra.Category.Grp.Abelian Mathlib.Algebra.Category.AlgebraCat.Limits Mathlib.Condensed.Explicit Mathlib.Algebra.Category.ModuleCat.Sheaf.Colimits Mathlib.Condensed.Module Mathlib.Condensed.Discrete.Characterization Mathlib.RepresentationTheory.GroupCohomology.Resolution Mathlib.Algebra.Category.ModuleCat.Sheaf Mathlib.RepresentationTheory.Rep Mathlib.Algebra.Category.ModuleCat.Sheaf.Free Mathlib.NumberTheory.DirichletCharacter.Orthogonality Mathlib.Algebra.Homology.ShortComplex.ModuleCat Mathlib.Algebra.Category.ModuleCat.Differentials.Presheaf Mathlib.Algebra.Category.ModuleCat.Pseudofunctor Mathlib.Algebra.Category.ModuleCat.Sheaf.ChangeOfRings Mathlib.Algebra.Category.ModuleCat.Biproducts Mathlib.RepresentationTheory.Invariants Mathlib.RingTheory.Flat.CategoryTheory Mathlib.Condensed.Solid Mathlib.Algebra.Category.ModuleCat.EnoughInjectives Mathlib.Condensed.Discrete.Module Mathlib.Algebra.Category.ModuleCat.Sheaf.Limits Mathlib.AlgebraicGeometry.Modules.Tilde Mathlib.NumberTheory.MulChar.Duality Mathlib.Condensed.Light.Epi Mathlib.CategoryTheory.Abelian.Injective Mathlib.RepresentationTheory.Character Mathlib.Algebra.Homology.DerivedCategory.Ext.ExactSequences Mathlib.CategoryTheory.Abelian.Projective Mathlib.Algebra.Category.ModuleCat.Sheaf.Generators Mathlib.Algebra.Category.ModuleCat.Sheaf.Abelian Mathlib.Algebra.Module.PID Mathlib.RingTheory.AdicCompletion.AsTensorProduct Mathlib.Algebra.Category.ModuleCat.Presheaf.Generator Mathlib.Algebra.Category.Grp.Images Mathlib.Condensed.Light.AB Mathlib.Algebra.Category.ModuleCat.Presheaf.Colimits Mathlib.Condensed.Light.Limits Mathlib.RepresentationTheory.GroupCohomology.Basic Mathlib.LinearAlgebra.TensorProduct.DirectLimit Mathlib.RepresentationTheory.FDRep Mathlib.Algebra.Homology.LocalCohomology Mathlib.Algebra.Category.ModuleCat.Presheaf Mathlib.RepresentationTheory.GroupCohomology.LowDegree Mathlib.CategoryTheory.Sites.MayerVietorisSquare Mathlib.Condensed.Light.Module Mathlib.Algebra.Category.ModuleCat.Presheaf.Sheafification Mathlib.GroupTheory.FiniteAbelian.Duality Mathlib.Algebra.Category.ModuleCat.Presheaf.EpiMono Mathlib.Condensed.Epi Mathlib.Algebra.Homology.ShortComplex.ConcreteCategory Mathlib.Algebra.Category.ModuleCat.Free Mathlib.GroupTheory.FiniteAbelian.Basic Mathlib.NumberTheory.LSeries.PrimesInAP Mathlib.Algebra.Category.ModuleCat.Images Mathlib.Algebra.Category.ModuleCat.Presheaf.Monoidal Mathlib.Algebra.Category.ModuleCat.Presheaf.Abelian Mathlib.Algebra.Category.ModuleCat.Presheaf.Pushforward Mathlib.Algebra.Category.ModuleCat.Sheaf.PushforwardContinuous Mathlib.Algebra.Category.ModuleCat.Presheaf.Sheafify Mathlib.Algebra.Category.ModuleCat.Sheaf.Quasicoherent Mathlib.CategoryTheory.Triangulated.Yoneda Mathlib.Algebra.Category.ModuleCat.Presheaf.ChangeOfRings Mathlib.Algebra.Homology.ConcreteCategory Mathlib.CategoryTheory.Preadditive.Yoneda.Limits Mathlib.Algebra.Category.ModuleCat.Presheaf.Free
1
Mathlib.Algebra.Colimit.DirectLimit (new file) 523
Mathlib.Algebra.Colimit.ModuleRing 1106

Declarations diff

+ DirectedSystem.map_map'
+ DirectedSystem.map_self'
+ _root_.DirectLimit
+ directed_of₃
+ div_def
+ div₀_def
+ eq_of_le
+ exists_eq_mk
+ exists_eq_mk₂
+ exists_eq_mk₃
+ exists_eq_one
+ induction
+ induction₂
+ induction₃
+ instance : AddGroupWithOne (DirectLimit G f)
+ instance : AddMonoidWithOne (DirectLimit G f)
+ instance : DivisionRing (DirectLimit G f)
+ instance : DivisionSemiring (DirectLimit G f)
+ instance : Group (DirectLimit G f)
+ instance : GroupWithZero (DirectLimit G f)
+ instance : Monoid (DirectLimit G f)
+ instance : Mul (DirectLimit G f)
+ instance : MulZeroOneClass (DirectLimit G f)
+ instance : One (DirectLimit G f)
+ instance : SMul R (DirectLimit G f)
+ instance [Monoid R] [∀ i, AddMonoid (G i)] [∀ i, DistribMulAction R (G i)]
+ instance [Monoid R] [∀ i, Monoid (G i)] [∀ i, MulDistribMulAction R (G i)]
+ instance [Monoid R] [∀ i, MulAction R (G i)]
+ instance [Semiring R] [∀ i, AddCommMonoid (G i)] [∀ i, Module R (G i)]
+ instance [Zero R] [∀ i, Zero (G i)] [∀ i, SMulWithZero R (G i)]
+ instance [∀ i, AddCommGroupWithOne (G i)] [∀ i j h, AddMonoidHomClass (T h) (G i) (G j)] :
+ instance [∀ i, AddCommMonoidWithOne (G i)] [∀ i j h, AddMonoidHomClass (T h) (G i) (G j)] :
+ instance [∀ i, AddZeroClass (G i)] [∀ i, DistribSMul R (G i)]
+ instance [∀ i, CommGroup (G i)] [∀ i j h, MonoidHomClass (T h) (G i) (G j)] :
+ instance [∀ i, CommGroupWithZero (G i)] [∀ i j h, MonoidWithZeroHomClass (T h) (G i) (G j)] :
+ instance [∀ i, CommMagma (G i)] [∀ i j h, MulHomClass (T h) (G i) (G j)] :
+ instance [∀ i, CommMonoid (G i)] [∀ i j h, MonoidHomClass (T h) (G i) (G j)] :
+ instance [∀ i, CommMonoidWithZero (G i)] [∀ i j h, MonoidWithZeroHomClass (T h) (G i) (G j)] :
+ instance [∀ i, CommRing (G i)] [∀ i j h, RingHomClass (T h) (G i) (G j)] :
+ instance [∀ i, CommSemigroup (G i)] [∀ i j h, MulHomClass (T h) (G i) (G j)] :
+ instance [∀ i, CommSemiring (G i)] [∀ i j h, RingHomClass (T h) (G i) (G j)] :
+ instance [∀ i, Field (G i)] [∀ i j h, RingHomClass (T h) (G i) (G j)] :
+ instance [∀ i, MonoidWithZero (G i)] [∀ i j h, MonoidWithZeroHomClass (T h) (G i) (G j)] :
+ instance [∀ i, MulOneClass (G i)] [∀ i j h, MonoidHomClass (T h) (G i) (G j)] :
+ instance [∀ i, MulZeroClass (G i)] [∀ i j h, MulHomClass (T h) (G i) (G j)]
+ instance [∀ i, NonAssocSemiring (G i)] [∀ i j h, RingHomClass (T h) (G i) (G j)] :
+ instance [∀ i, NonUnitalCommSemiring (G i)] [∀ i j h, NonUnitalRingHomClass (T h) (G i) (G j)] :
+ instance [∀ i, NonUnitalNonAssocCommSemiring (G i)]
+ instance [∀ i, NonUnitalNonAssocSemiring (G i)] [∀ i j h, NonUnitalRingHomClass (T h) (G i) (G j)] :
+ instance [∀ i, NonUnitalSemiring (G i)] [∀ i j h, NonUnitalRingHomClass (T h) (G i) (G j)] :
+ instance [∀ i, Nontrivial (G i)] : Nontrivial (DirectLimit G f)
+ instance [∀ i, Ring (G i)] [∀ i j h, RingHomClass (T h) (G i) (G j)] : Ring (DirectLimit G f)
+ instance [∀ i, Semifield (G i)] [∀ i j h, RingHomClass (T h) (G i) (G j)] :
+ instance [∀ i, Semigroup (G i)] [∀ i j h, MulHomClass (T h) (G i) (G j)] :
+ instance [∀ i, SemigroupWithZero (G i)] [∀ i j h, MulHomClass (T h) (G i) (G j)]
+ instance [∀ i, Semiring (G i)] [∀ i j h, RingHomClass (T h) (G i) (G j)] :
+ instance [∀ i, Zero (G i)] [∀ i, SMulZeroClass R (G i)]
+ intCast_def
+ inv_def
+ inv₀_def
+ lift_def
+ lift_injective
+ lift₂
+ lift₂_def
+ lift₂_def₂
+ linearEquiv
+ linearEquiv_of
+ linearEquiv_symm_mk
+ map
+ map_def
+ map_intCast'
+ map₀
+ map₀_def
+ map₂
+ map₂_def
+ map₂_def₂
+ mk_injective
+ mul_def
+ natCast_def
+ nnratCast_def
+ npow_def
+ one_def
+ r_of_le
+ ratCast_def
+ ringEquiv
+ ringEquiv_of
+ ringEquiv_symm_mk
+ setoid
+ smul_def
+ zpow_def
+ zpow₀_def
++ lift_of
++ of
++ of_f
+++ lift
+--+ of.zero_exact
- of.zero_exact_aux2
- toModule_totalize_of_le
- totalize
- totalize_of_le
- totalize_of_not_le
-- of.zero_exact_aux

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 script/declarations_diff.sh contains some details about this script.


Increase in tech debt: (relative, absolute) = (0.48, 0.00)
Current number Change Type
4897 -6 porting notes
1497 -1 erw
223 1 bare open (scoped) Classical

Current commit 19359074a7
Reference commit 2c66a57507

You can run this locally as

./scripts/technical-debt-metrics.sh pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

@alreadydone alreadydone added the awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. label Dec 11, 2024
@github-actions github-actions bot removed the awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. label Dec 11, 2024
@alreadydone alreadydone changed the title feat: DirectLimit of the whole algebraic hierarchy feat: algebraic hierarchy on DirectLimit Dec 11, 2024
Comment on lines +223 to +224
/-- This version is primed so that the `RingHomClass` versions aren't. -/
theorem map_intCast' [AddGroupWithOne α] [AddGroupWithOne β] [FunLike F α β]
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.

Is this not a strict generalization?

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.

Do you mean map_intCast? That one assumes RingHomClass so there's no need to supply a proof of f 1 = 1. This new lemma is in parallel to map_natCast'.

Comment on lines +235 to +237
/-- The direct limit constructed as a quotient of the direct sum is isomorphic to
the direct limit constructed as a quotient of the disjoint union. -/
def linearEquiv : DirectLimit G f ≃ₗ[R] _root_.DirectLimit G f :=
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.

So now we have two definitions of DirectLimit, whereas we had only one in the past, right?
One is a bit more general, but the other has better defeqs and is easier to work with. Do I understand that correctly?

I think part of your PR commit message contains useful commentary that should also be embedded in a module docstring in one of these files.

Copy link
Copy Markdown
Contributor Author

@alreadydone alreadydone Dec 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were Module.DirectLimit, AddCommGroup.DirectLimit and Ring.DirectLimit, and I'm now adding DirectLimit in the root space. The three existing DirectLimits are in fact constructions of general colimits in the respective categories, while mine is restricted to directed colimits but applies to all kinds of algebraic structures. The point is that when the preorder is directed, the underlying type of all DirectLimits can be taken to be the same, no matter what algebraic structure you consider; in fact I simply take the DirectLimit in Type* and put all kinds of algebraic structures on it. The equivalence relation on that defines the DirectLimit in Type* is easy to understand, and is used to golf the of.zero_exact lemmas.

I'll check what part of the PR message is appropriate to include in the module docstrings.

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.

Thanks, this message is also very useful. So please also add a version of that info to the module docstring.

Copy link
Copy Markdown
Contributor Author

@alreadydone alreadydone Dec 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check these two commits; is there anything I should add?

@jcommelin jcommelin added the awaiting-author A reviewer has asked the author a question or requested changes. label Dec 20, 2024
@alreadydone alreadydone removed the awaiting-author A reviewer has asked the author a question or requested changes. label Dec 20, 2024
Copy link
Copy Markdown
Member

@jcommelin jcommelin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 🎉

bors merge

@ghost ghost added the ready-to-merge This PR has been sent to bors. label Dec 21, 2024
mathlib-bors bot pushed a commit that referenced this pull request Dec 21, 2024
**Order/DirectedInverseSystem.lean**: define the DirectLimit of a DirectedSystem of types as a quotient (by a setoid (equivalence relation)) of the Sigma type (disjoint union). Provide the `induction` lemmas and `map`/`lift` constructions used to define algebraic operations on DirectLimit.

New file **Algebra/Colimit/DirectLimit.lean**: the first 400 lines are boilerplate code that defines algebraic instances on DirectLImit from magma (Mul) to Field. To make everything "hom-polymorphic", the DirectedSystem consists of FunLikes rather than plain/unbundled functions, and we use algebraic hom typeclasses (e.g. LinearMapClass, RingHomClass) everywhere. The remaining 70 lines essentially shows that DirectLimit is the colimit in the categories of Module and Ring.

**Algebra/DirectLimit.lean**: renamed to **Algebra/Colimit/ModuleRing.lean**. This file was originally added @kckennylau 5 years ago in [mathlib3#754](leanprover-community/mathlib3#754) and defines `Module.DirectLimit` and `Ring.DirectLimit` as quotients of the universal objects (DirectSum and FreeCommRing). This definition is more general and suitable for arbitrary colimits, but makes it very cumbersome to prove [`of.zero_exact`](https://leanprover-community.github.io/mathlib4_docs/Mathlib/Algebra/DirectLimit.html#Ring.DirectLimit.of.zero_exact) lemmas (130+ lines!); for DirectLimit constructed as quotients of the disjoint union, these are just by definition. We golf these proofs by constructing isomorphisms between `Module/Ring.DirectLimit` and `_root_.DirectLimit`. I have more work done that generalizes most lemmas there to work for arbitrary colimits, that's why I put it under a new Colimit directory.

**Data/Int/Cast/Lemmas.lean**: add `map_intCast'`
**Data/Nat/Cast/Basic.lean**: golf a lemma
**Order/Directed.lean**: add a lemma
**ModelTheory/DirectLimit.lean**: change two lemmas to aliases of the general FunLike lemmas
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Dec 21, 2024

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title feat: algebraic hierarchy on DirectLimit [Merged by Bors] - feat: algebraic hierarchy on DirectLimit Dec 21, 2024
@mathlib-bors mathlib-bors bot closed this Dec 21, 2024
@mathlib-bors mathlib-bors bot deleted the DirectLimit.v3 branch December 21, 2024 09:32
kim-em pushed a commit that referenced this pull request Dec 21, 2024
**Order/DirectedInverseSystem.lean**: define the DirectLimit of a DirectedSystem of types as a quotient (by a setoid (equivalence relation)) of the Sigma type (disjoint union). Provide the `induction` lemmas and `map`/`lift` constructions used to define algebraic operations on DirectLimit.

New file **Algebra/Colimit/DirectLimit.lean**: the first 400 lines are boilerplate code that defines algebraic instances on DirectLImit from magma (Mul) to Field. To make everything "hom-polymorphic", the DirectedSystem consists of FunLikes rather than plain/unbundled functions, and we use algebraic hom typeclasses (e.g. LinearMapClass, RingHomClass) everywhere. The remaining 70 lines essentially shows that DirectLimit is the colimit in the categories of Module and Ring.

**Algebra/DirectLimit.lean**: renamed to **Algebra/Colimit/ModuleRing.lean**. This file was originally added @kckennylau 5 years ago in [mathlib3#754](leanprover-community/mathlib3#754) and defines `Module.DirectLimit` and `Ring.DirectLimit` as quotients of the universal objects (DirectSum and FreeCommRing). This definition is more general and suitable for arbitrary colimits, but makes it very cumbersome to prove [`of.zero_exact`](https://leanprover-community.github.io/mathlib4_docs/Mathlib/Algebra/DirectLimit.html#Ring.DirectLimit.of.zero_exact) lemmas (130+ lines!); for DirectLimit constructed as quotients of the disjoint union, these are just by definition. We golf these proofs by constructing isomorphisms between `Module/Ring.DirectLimit` and `_root_.DirectLimit`. I have more work done that generalizes most lemmas there to work for arbitrary colimits, that's why I put it under a new Colimit directory.

**Data/Int/Cast/Lemmas.lean**: add `map_intCast'`
**Data/Nat/Cast/Basic.lean**: golf a lemma
**Order/Directed.lean**: add a lemma
**ModelTheory/DirectLimit.lean**: change two lemmas to aliases of the general FunLike lemmas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge This PR has been sent to bors. t-algebra Algebra (groups, rings, fields, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants