Skip to content

chore: redefine LocalizedModule#25662

Closed
erdOne wants to merge 4 commits intomasterfrom
erd1/ore-module3
Closed

chore: redefine LocalizedModule#25662
erdOne wants to merge 4 commits intomasterfrom
erd1/ore-module3

Conversation

@erdOne
Copy link
Copy Markdown
Member

@erdOne erdOne commented Jun 10, 2025


Open in Gitpod

@erdOne
Copy link
Copy Markdown
Member Author

erdOne commented Jun 10, 2025

!bench

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jun 10, 2025

PR summary 4a11bc26db

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

+ instance (priority := 900) algebra' {A : Type*} [Semiring A] [Algebra R A] :
+ instance (priority := 900) {A : Type*} [CommRing A] [Algebra R A] {S : Submonoid R} :
+ instance (priority := 900) {A : Type*} [CommSemiring A] [Algebra R A] {S : Submonoid R} :
+ instance (priority := 900) {A : Type*} [Ring A] [Algebra R A] {S : Submonoid R} :
+ instance (priority := 900) {A : Type*} [Semiring A] [Algebra R A] :
+ instance [One X] : One X[S⁻¹]
+ mk_mul_mk'
+ mul
+ oreEqv_iff_r
+ oreSetComm_oreDenom
+ oreSetComm_oreNum
++ instance (U : (Opens (PrimeSpectrum.Top R))ᵒᵖ) (x : U.unop) :
++ instance (priority := 900) {A : Type*} [Semiring A] [Algebra R A] {S : Submonoid R} :
++- numeratorRingHom
- algebra'
- hasNatSMul
- instance : Add (LocalizedModule S M)
- instance : AddCommMonoid (LocalizedModule S M)
- instance : One R[S⁻¹]
- instance : Zero (LocalizedModule S M)
- instance {A : Type*} [CommRing A] [Algebra R A] {S : Submonoid R} :
- instance {A : Type*} [CommSemiring A] [Algebra R A] {S : Submonoid R} :
- instance {A : Type*} [Ring A] [Algebra R A] {S : Submonoid R} :
- instance {A : Type*} [Semiring A] [Algebra R A] : Algebra T (LocalizedModule S A)
- instance {M : Type*} [AddCommGroup M] [Module R M] : AddCommGroup (LocalizedModule S M)
- instance {M : Type*} [AddCommGroup M] [Module R M] : Neg (LocalizedModule S M)
- isModule'
-- instance {A : Type*} [Semiring A] [Algebra R A] {S : Submonoid R} :

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.


Decrease in tech debt: (relative, absolute) = (1.00, 0.01)
Current number Change Type
121 -1 adaptation notes

Current commit 2f2c783e49
Reference commit 4a11bc26db

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).

@leanprover-bot
Copy link
Copy Markdown
Collaborator

Here are the benchmark results for commit dfd0bdc.
The entire run failed.
Found no significant differences.

@erdOne
Copy link
Copy Markdown
Member Author

erdOne commented Jun 10, 2025

!bench

@leanprover-bot
Copy link
Copy Markdown
Collaborator

Here are the benchmark results for commit 0f49e19.
There were significant changes against commit 855ce5c:

  Benchmark                                    Metric         Change
  ==================================================================
+ ~Mathlib.Algebra.Module.FinitePresentation   instructions    -6.8%
- ~Mathlib.AlgebraicGeometry.AffineSpace       instructions    69.6%
- ~Mathlib.RingTheory.RingHom.Locally          instructions    12.2%

@github-actions
Copy link
Copy Markdown

File Instructions %
build +281.86⬝10⁹ (+0.20%)
lint +5.414⬝10⁹ (+0.07%)
Mathlib.AlgebraicGeometry.AffineSpace +131.884⬝10⁹ (+69.64%)
Mathlib.RingTheory.RingHom.Locally +12.109⬝10⁹ (+12.15%)
2 files, Instructions +8.0⬝10⁹
File Instructions %
Mathlib.RingTheory.DedekindDomain.Different +8.547⬝10⁹ (+3.17%)
Mathlib.RingTheory.Spectrum.Prime.FreeLocus +8.383⬝10⁹ (+7.99%)
2 files, Instructions +7.0⬝10⁹
File Instructions %
Mathlib.RingTheory.IntegralClosure.IntegralRestrict +7.732⬝10⁹ (+3.50%)
Mathlib.RingTheory.Flat.Domain +7.630⬝10⁹ (+15.51%)
2 files, Instructions +6.0⬝10⁹
File Instructions %
Mathlib.RingTheory.LocalRing.ResidueField.Ideal +6.439⬝10⁹ (+7.09%)
Mathlib.RingTheory.LocalProperties.Exactness +6.371⬝10⁹ (+13.03%)
5 files, Instructions +5.0⬝10⁹
File Instructions %
Mathlib.RingTheory.TensorProduct.Nontrivial +5.892⬝10⁹ (+23.66%)
Mathlib.AlgebraicGeometry.Modules.Tilde +5.748⬝10⁹ (+8.68%)
Mathlib.RingTheory.LocalProperties.Projective +5.447⬝10⁹ (+17.98%)
Mathlib.RingTheory.Ideal.Norm.RelNorm +5.407⬝10⁹ (+4.62%)
Mathlib.NumberTheory.FunctionField +5.345⬝10⁹ (+18.56%)
File Instructions %
Mathlib.Algebra.Module.LocalizedModule.Basic +4.432⬝10⁹ (+3.48%)
5 files, Instructions +3.0⬝10⁹
File Instructions %
Mathlib.RingTheory.Spectrum.Prime.Polynomial +3.878⬝10⁹ (+3.56%)
Mathlib.RingTheory.Smooth.Locus +3.751⬝10⁹ (+11.51%)
Mathlib.LinearAlgebra.Dimension.Localization +3.258⬝10⁹ (+4.43%)
Mathlib.RingTheory.Etale.Kaehler +3.247⬝10⁹ (+1.34%)
Mathlib.NumberTheory.ClassNumber.FunctionField +3.45⬝10⁹ (+27.79%)
5 files, Instructions +2.0⬝10⁹
File Instructions %
Mathlib.Algebra.Module.LocalizedModule.Submodule +2.733⬝10⁹ (+5.09%)
Mathlib.AlgebraicGeometry.Spec +2.502⬝10⁹ (+3.99%)
Mathlib.RingTheory.Regular.Depth +2.415⬝10⁹ (+10.83%)
Mathlib.RingTheory.Localization.Module +2.349⬝10⁹ (+7.56%)
Mathlib.AlgebraicGeometry.StructureSheaf +2.229⬝10⁹ (+2.20%)
19 files, Instructions +1.0⬝10⁹
File Instructions %
Mathlib.RingTheory.Spectrum.Prime.ChevalleyComplexity +1.935⬝10⁹ (+1.10%)
Mathlib.Algebra.Module.LocalizedModule.Exact +1.832⬝10⁹ (+24.07%)
Mathlib.RingTheory.RingHom.Flat +1.777⬝10⁹ (+7.28%)
Mathlib.RingTheory.Support +1.743⬝10⁹ (+7.28%)
Mathlib.AlgebraicGeometry.AffineScheme +1.660⬝10⁹ (+1.17%)
Mathlib.RingTheory.Trace.Quotient +1.619⬝10⁹ (+3.41%)
Mathlib.RingTheory.Localization.Finiteness +1.617⬝10⁹ (+7.59%)
Mathlib.RingTheory.ClassGroup +1.569⬝10⁹ (+1.69%)
Mathlib.Algebra.Lie.TraceForm +1.528⬝10⁹ (+1.06%)
Mathlib.AlgebraicGeometry.ProjectiveSpectrum.Basic +1.503⬝10⁹ (+3.37%)
Mathlib.AlgebraicGeometry.ProjectiveSpectrum.Scheme +1.454⬝10⁹ (+0.96%)
Mathlib.RingTheory.WittVector.Isocrystal +1.453⬝10⁹ (+2.50%)
Mathlib.FieldTheory.SeparableDegree +1.450⬝10⁹ (+1.14%)
Mathlib.RingTheory.LaurentSeries +1.418⬝10⁹ (+0.76%)
Mathlib.RingTheory.Localization.BaseChange +1.338⬝10⁹ (+2.36%)
Mathlib.AlgebraicGeometry.GammaSpecAdjunction +1.311⬝10⁹ (+1.54%)
Mathlib.Algebra.Homology.HomotopyCategory.Triangulated +1.215⬝10⁹ (+1.45%)
Mathlib.RingTheory.Unramified.Locus +1.65⬝10⁹ (+8.03%)
Mathlib.RingTheory.LocalRing.ResidueField.Fiber +1.60⬝10⁹ (+3.01%)
File Instructions %
Mathlib.RingTheory.Localization.Free -5.176⬝10⁹ (-17.57%)
Mathlib.Algebra.Module.FinitePresentation -12.150⬝10⁹ (-6.82%)
CI run

@erdOne
Copy link
Copy Markdown
Member Author

erdOne commented Jun 10, 2025

I think this slowdown is acceptable considering this is the right thing to do.
The worst file Mathlib.AlgebraicGeometry.AffineSpace is a leaf file that is due to be refactored in a later PR.

@erdOne erdOne requested a review from eric-wieser June 19, 2025 11:54
Copy link
Copy Markdown
Collaborator

@kckennylau kckennylau left a comment

Choose a reason for hiding this comment

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

I feel like changing those defs into abbrevs... is there no other way?

/-- The canonical map sending `(m, s) ↦ m/s` -/
def mk (m : M) (s : S) : LocalizedModule S M :=
Quotient.mk' ⟨m, s⟩
abbrev mk (m : M) (s : S) : LocalizedModule S M := m /ₒ s
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is m /ₒ s or mk m s the canonical form now?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is an intermediate step. The long term plan is to remove mk.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you add that as a Todo on the docstring?

@erdOne
Copy link
Copy Markdown
Member Author

erdOne commented Jun 20, 2025

The whole point of this PR is to make LocalizedModule (reducibly) defeq to Localization

@leanprover-community-bot-assistant leanprover-community-bot-assistant added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jul 5, 2025
@leanprover-community-bot-assistant
Copy link
Copy Markdown
Collaborator

This pull request has conflicts, please merge master and resolve them.

@github-actions github-actions bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jul 5, 2025
@leanprover-community-bot-assistant leanprover-community-bot-assistant added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jul 26, 2025
@leanprover-community-bot-assistant
Copy link
Copy Markdown
Collaborator

This pull request has conflicts, please merge master and resolve them.

@vihdzp
Copy link
Copy Markdown
Collaborator

vihdzp commented Sep 3, 2025

Can this PR get a description explaining what it does, and why it's the correct thing to do?

@vihdzp vihdzp added the t-algebra Algebra (groups, rings, fields, etc) label Sep 3, 2025
@@ -49,6 +50,19 @@ for some (u : S), u * (s2 • m1 - s1 • m2) = 0 -/
def r (a b : M × S) : Prop :=
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I get this isn't part of the PR, but I'm really not a fan of single letter defs (let alone unprotected ones!)

-/
def _root_.LocalizedModule : Type max u v :=
Quotient (r.setoid S M)
abbrev _root_.LocalizedModule : Type max u v :=
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I imagine the end-goal here is to deprecate LocalizedModule in favor of OreLocalization, am I right? If so, can you add that to the module docstring as a ## Todo? (And if not, can you explain the design you're going for an ## Implementation notes?)

/-- The canonical map sending `(m, s) ↦ m/s` -/
def mk (m : M) (s : S) : LocalizedModule S M :=
Quotient.mk' ⟨m, s⟩
abbrev mk (m : M) (s : S) : LocalizedModule S M := m /ₒ s
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you add that as a Todo on the docstring?

simp only [smul_add, ← mul_smul, mul_comm,
mul_left_comm] at hu1' hu2' ⊢
rw [hu1', hu2']⟩
theorem zero_mk (s : S) : mk (0 : M) s = 0 := by simp [mk]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why is this no longer simp?

theorem zero_mk (s : S) : mk (0 : M) s = 0 :=
mk_eq.mpr ⟨1, by rw [one_smul, smul_zero, smul_zero, one_smul]⟩

instance : Add (LocalizedModule S M) where
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

(Just to be clear, this instance is now automatically inferred, right?)

mathlib-bors bot pushed a commit that referenced this pull request Oct 9, 2025
This is part of Hahn embedding theorem #27268, where an a ordered group is first embedded in a divisible group / Q-module. I am aware at #25662 there is also an ongoing rewrite of `LocalizedModule` that this PR uses. Hopefully I avoided interfering it by using mostly with public API.
Jlh18 pushed a commit to Jlh18/mathlib4 that referenced this pull request Oct 14, 2025
This is part of Hahn embedding theorem leanprover-community#27268, where an a ordered group is first embedded in a divisible group / Q-module. I am aware at leanprover-community#25662 there is also an ongoing rewrite of `LocalizedModule` that this PR uses. Hopefully I avoided interfering it by using mostly with public API.
BeibeiX0 pushed a commit to BeibeiX0/mathlib4 that referenced this pull request Nov 7, 2025
This is part of Hahn embedding theorem leanprover-community#27268, where an a ordered group is first embedded in a divisible group / Q-module. I am aware at leanprover-community#25662 there is also an ongoing rewrite of `LocalizedModule` that this PR uses. Hopefully I avoided interfering it by using mostly with public API.
@erdOne
Copy link
Copy Markdown
Member Author

erdOne commented Dec 28, 2025

superseded by #31862

@erdOne erdOne closed this Dec 28, 2025
@YaelDillies YaelDillies deleted the erd1/ore-module3 branch January 1, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) t-algebra Algebra (groups, rings, fields, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants