Skip to content

Commit 24972cd

Browse files
committed
refactor(Localization/AtPrime/Basic): add predicate for algebra instance on Localization.AtPrime (#38465)
Currently [Localization.AtPrime](https://leanprover-community.github.io/mathlib4_docs/Mathlib/RingTheory/Localization/AtPrime/Basic.html#Localization.AtPrime.instAlgebraOfLiesOver) induces a diamond when the top ring is already an algebra over the localization of the bottom ring (e.g., this happens for `Ideal.Fiber`). This PR resolves the diamond by turning the instance into a def and adding a predicate typeclass. Zulip thread: https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/instance.20diamond.20with.20.60Ideal.2EFiber.60 Co-authored-by: tb65536 <thomas.l.browning@gmail.com>
1 parent 2408d1d commit 24972cd

24 files changed

Lines changed: 162 additions & 42 deletions

File tree

Mathlib/AlgebraicGeometry/Morphisms/QuasiFinite.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ nonrec lemma Scheme.Hom.quasiFiniteAt_iff_isOpen_singleton_asFiber
419419
rw [HasRingHomProperty.Spec_iff (P := @LocallyOfFiniteType)] at ‹LocallyOfFiniteType (Spec.map φ)›
420420
algebraize [φ.hom]
421421
rw [← Algebra.quasiFiniteAt_iff_isOpen_singleton_fiber]
422+
let := Localization.AtPrime.algebraOfLiesOver (x.asIdeal.under R) x.asIdeal
422423
trans Algebra.QuasiFinite (Localization.AtPrime (x.asIdeal.under R))
423424
(Localization.AtPrime x.asIdeal)
424425
· rw [← RingHom.quasiFinite_algebraMap]

Mathlib/AlgebraicGeometry/Morphisms/Smooth.lean

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,12 @@ lemma formallySmooth_stalkMap_iff {f : X ⟶ Y} {x : X} (U : Y.Opens)
247247
(f.stalkMap x).hom.FormallySmooth ↔
248248
hV.primeIdealOf ⟨x, hx⟩ ∈ Algebra.smoothLocus Γ(Y, U) Γ(X, V) := by
249249
letI := (f.appLE U V hVU).hom.toAlgebra
250-
have : (hV.primeIdealOf ⟨x, hx⟩).asIdeal.LiesOver (hU.primeIdealOf ⟨f x, hVU hx⟩).asIdeal :=
250+
let p := (hU.primeIdealOf ⟨f x, hVU hx⟩).asIdeal
251+
let q := (hV.primeIdealOf ⟨x, hx⟩).asIdeal
252+
have : q.LiesOver p :=
251253
⟨congr($(IsAffineOpen.comap_primeIdealOf_appLE U hU V hV hVU hx).1).symm⟩
252-
trans Algebra.FormallySmooth
253-
(Localization.AtPrime (hU.primeIdealOf ⟨f x, hVU hx⟩).asIdeal)
254-
(Localization.AtPrime (hV.primeIdealOf ⟨x, hx⟩).asIdeal)
254+
let := Localization.AtPrime.algebraOfLiesOver p q
255+
trans Algebra.FormallySmooth (Localization.AtPrime p) (Localization.AtPrime q)
255256
· rw [← formallySmooth_algebraMap]
256257
exact RingHom.FormallySmooth.respectsIso.arrow_mk_iso_iff
257258
(IsAffineOpen.arrowStalkMapIso f U hU V hV hVU hx)

Mathlib/NumberTheory/RamificationInertia/Unramified.lean

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ lemma Ideal.ramificationIdx_eq_one_of_isUnramifiedAt
3737
{p : Ideal S} [p.IsPrime] [IsNoetherianRing S] [IsUnramifiedAt R p]
3838
(hp : p ≠ ⊥) [IsDomain S] [EssFiniteType R S] :
3939
e(p|R) = 1 :=
40+
let := Localization.AtPrime.algebraOfLiesOver (p.under R) p
4041
(Ideal.ramificationIdx_eq_one_of_map_localization Ideal.map_comap_le hp
4142
p.primeCompl_le_nonZeroDivisors
4243
((isUnramifiedAt_iff_map_eq R (p.under R) p).mp ‹_›).2)
@@ -49,6 +50,9 @@ lemma IsUnramifiedAt.of_liesOver_of_ne_bot
4950
IsUnramifiedAt R p := by
5051
let p₀ : Ideal R := p.under R
5152
have : P.LiesOver p₀ := .trans P p p₀
53+
let := Localization.AtPrime.algebraOfLiesOver p₀ p
54+
let := Localization.AtPrime.algebraOfLiesOver p P
55+
let := Localization.AtPrime.algebraOfLiesOver p₀ P
5256
have hp₀ : p₀ = P.under R := Ideal.LiesOver.over
5357
have : EssFiniteType S T := .of_comp R S T
5458
have := Algebra.EssFiniteType.isNoetherianRing S T
@@ -91,6 +95,7 @@ lemma Algebra.isUnramifiedAt_iff_of_isDedekindDomain
9195
[Module.Finite ℤ R] [CharZero R] [Algebra.IsIntegral R S]
9296
(hp : p ≠ ⊥) :
9397
Algebra.IsUnramifiedAt R p ↔ e(p|R) = 1 := by
98+
let := Localization.AtPrime.algebraOfLiesOver (p.under R) p
9499
rw [isUnramifiedAt_iff_map_eq R (p.under R) p, and_iff_right,
95100
Ideal.IsDedekindDomain.ramificationIdx_eq_one_iff hp Ideal.map_comap_le]
96101
have : Finite (R ⧸ p.under R) :=

Mathlib/RingTheory/DedekindDomain/Different.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,7 @@ theorem not_dvd_differentIdeal_iff
923923
have hp' := (Ideal.map_eq_bot_iff_of_injective
924924
(FaithfulSMul.algebraMap_injective A B)).not.mpr hp
925925
have := Ideal.IsPrime.isMaximal inferInstance hPbot
926+
let := Localization.AtPrime.algebraOfLiesOver (P.under A) P
926927
constructor
927928
· intro H
928929
· rw [Algebra.isUnramifiedAt_iff_map_eq (p := P.under A)]

Mathlib/RingTheory/Etale/Locus.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ lemma mem_etaleLocus_iff {p : PrimeSpectrum A} : p ∈ etaleLocus R A ↔ IsEtal
4646
lemma IsEtaleAt.comp
4747
(p : Ideal A) (P : Ideal B) [P.LiesOver p] [p.IsPrime] [P.IsPrime]
4848
[IsEtaleAt R p] [IsEtaleAt A P] : IsEtaleAt R P := by
49+
let := Localization.AtPrime.algebraOfLiesOver p P
4950
have : FormallyEtale (Localization.AtPrime p) (Localization.AtPrime P) :=
5051
.localization_base p.primeCompl
5152
exact FormallyEtale.comp R (Localization.AtPrime p) _

Mathlib/RingTheory/Etale/QuasiFinite.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ noncomputable
3939
def Ideal.fiberIsoOfBijectiveResidueField
4040
(H : Function.Bijective (Ideal.ResidueField.mapₐ p q (Algebra.ofId _ _) (q.over_def p))) :
4141
q.primesOver (R' ⊗[R] S) ≃o p.primesOver S :=
42+
let := Localization.AtPrime.algebraOfLiesOver p q
4243
let e : q.Fiber (R' ⊗[R] S) ≃ₐ[p.ResidueField] p.Fiber S :=
4344
((Algebra.TensorProduct.cancelBaseChange _ _ q.ResidueField _ _).restrictScalars _).trans
4445
(Algebra.TensorProduct.congr (.symm <| .ofBijective (Algebra.ofId _ _) H) .refl)
@@ -251,6 +252,7 @@ lemma Algebra.exists_etale_isIdempotentElem_forall_liesOver_eq_aux
251252
simp only [e₀, ← aeval_algHom_apply]; rfl
252253
have he : IsIdempotentElem e := he₀e ▸ he₀.map _
253254
let P' := (Ideal.fiberIsoOfBijectiveResidueField hP).symm ⟨q, ‹_›, ‹_›⟩
255+
let := Localization.AtPrime.algebraOfLiesOver P P'.1
254256
have hP'q : P'.1.comap Algebra.TensorProduct.includeRight.toRingHom = q :=
255257
Ideal.comap_fiberIsoOfBijectiveResidueField_symm ..
256258
have hs'P' : s' ∉ P'.1 := mt (fun h ↦ hP'q.le h) hsq

Mathlib/RingTheory/Flat/Localization.lean

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ end Module
105105

106106
variable {A B : Type*} [CommRing A] [CommRing B] [Algebra A B]
107107

108-
instance [Module.Flat A B] (p : Ideal A) [p.IsPrime] (P : Ideal B) [P.IsPrime] [P.LiesOver p] :
108+
instance [Module.Flat A B] (p : Ideal A) [p.IsPrime] (P : Ideal B) [P.IsPrime] [P.LiesOver p]
109+
[Algebra (Localization.AtPrime p) (Localization.AtPrime P)]
110+
[Localization.AtPrime.IsLiesOverAlgebra p P] :
109111
Module.Flat (Localization.AtPrime p) (Localization.AtPrime P) := by
110112
rw [Module.flat_iff_of_isLocalization (Localization.AtPrime p) p.primeCompl]
111113
exact Module.Flat.trans A B (Localization.AtPrime P)

Mathlib/RingTheory/Flat/Rank.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ lemma PrimeSpectrum.comap_surjective_iff_injective_of_finite :
6060
rw [← faithfulSMul_iff_algebraMap_injective]
6161
obtain ⟨⟨Q, _⟩, hQ⟩ := h ⟨p, inferInstance⟩
6262
have : Q.LiesOver p := ⟨congr($(hQ).asIdeal).symm⟩
63+
let := Localization.AtPrime.algebraOfLiesOver p Q
6364
have : Nontrivial (Localization.AtPrime p ⊗[R] S) := by
6465
let f : Localization.AtPrime p ⊗[R] S →ₐ[R] Localization.AtPrime Q :=
6566
Algebra.TensorProduct.lift (IsScalarTower.toAlgHom R _ _)

Mathlib/RingTheory/Ideal/GoingDown.lean

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ lemma of_comap_localRingHom_surjective
144144
obtain ⟨⟨Pl, _⟩, hl⟩ := H Q ⟨pl, inferInstance⟩
145145
refine ⟨Pl.under S, ?_, Ideal.IsPrime.under S Pl, ⟨?_⟩⟩
146146
· exact (IsLocalization.AtPrime.orderIsoOfPrime _ Q ⟨Pl, inferInstance⟩).2.2
147-
· replace hl : Pl.under _ = pl := by simpa [PrimeSpectrum.ext_iff] using hl
147+
· let := Localization.AtPrime.algebraOfLiesOver (Q.under R) Q
148+
replace hl : Pl.under _ = pl := by simpa [PrimeSpectrum.ext_iff] using hl
148149
rw [Ideal.under_under, ← Ideal.under_under (B := (Localization.AtPrime <| Q.under R)) Pl, hl,
149150
Ideal.under_map_of_isLocalizationAtPrime (Q.under R) hlt.le]
150151

@@ -153,6 +154,7 @@ lemma of_comap_localRingHom_surjective
153154
instance of_flat [Module.Flat R S] : Algebra.HasGoingDown R S := by
154155
apply of_comap_localRingHom_surjective
155156
intro P hP
157+
let := Localization.AtPrime.algebraOfLiesOver (P.under R) P
156158
have : IsLocalHom (algebraMap (Localization.AtPrime <| P.under R) (Localization.AtPrime P)) := by
157159
rw [RingHom.algebraMap_toAlgebra]
158160
exact Localization.isLocalHom_localRingHom (P.under R) P (algebraMap R S) Ideal.LiesOver.over

Mathlib/RingTheory/LocalRing/ResidueField/Ideal.lean

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,20 @@ lemma Ideal.surjectiveOnStalks_residueField (I : Ideal R) [I.IsPrime] :
145145
(RingHom.surjectiveOnStalks_of_surjective Ideal.Quotient.mk_surjective).comp
146146
(RingHom.surjectiveOnStalks_of_isLocalization I.primeCompl _)
147147

148-
instance (p : Ideal R) [p.IsPrime] (q : Ideal A) [q.IsPrime] [q.LiesOver p] :
149-
IsLocalHom (algebraMap (Localization.AtPrime p) (Localization.AtPrime q)) :=
150-
Localization.isLocalHom_localRingHom _ _ _ (Ideal.over_def _ _)
148+
instance (p : Ideal R) [p.IsPrime] (q : Ideal A) [q.IsPrime] [q.LiesOver p]
149+
[Algebra (Localization.AtPrime p) (Localization.AtPrime q)]
150+
[Localization.AtPrime.IsLiesOverAlgebra p q] :
151+
IsLocalHom (algebraMap (Localization.AtPrime p) (Localization.AtPrime q)) := by
152+
rw [Localization.AtPrime.IsLiesOverAlgebra.algebraMap_eq]
153+
exact Localization.isLocalHom_localRingHom _ _ _ (Ideal.over_def _ _)
151154

152155
instance (p : Ideal R) [p.IsPrime] : Algebra.EssFiniteType R p.ResidueField :=
153156
.comp _ (Localization.AtPrime p) _
154157

155158
instance [Algebra.EssFiniteType R A]
156-
(p : Ideal R) [p.IsPrime] (q : Ideal A) [q.IsPrime] [q.LiesOver p] :
159+
(p : Ideal R) [p.IsPrime] (q : Ideal A) [q.IsPrime] [q.LiesOver p]
160+
[Algebra (Localization.AtPrime p) (Localization.AtPrime q)]
161+
[Localization.AtPrime.IsLiesOverAlgebra p q] :
157162
Algebra.EssFiniteType p.ResidueField q.ResidueField := by
158163
have : Algebra.EssFiniteType R q.ResidueField := .comp _ A _
159164
refine .of_comp R _ _

0 commit comments

Comments
 (0)