Skip to content

Commit f96ef6f

Browse files
feat: add Mathlib.RingTheory.DedekindDomain.Instances (#26070)
We add a new file `Mathlib.RingTheory.DedekindDomain.Instances` containing various instances that are useful to work with the localization a prime of an extension of Dedekind domains. As a practical example we golf a tedious proof in `Mathlib.RingTheory.Ideal/Norm.RelNorm`.
1 parent b330acf commit f96ef6f

File tree

12 files changed

+227
-76
lines changed

12 files changed

+227
-76
lines changed

Mathlib.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5196,6 +5196,7 @@ import Mathlib.RingTheory.DedekindDomain.Dvr
51965196
import Mathlib.RingTheory.DedekindDomain.Factorization
51975197
import Mathlib.RingTheory.DedekindDomain.FiniteAdeleRing
51985198
import Mathlib.RingTheory.DedekindDomain.Ideal
5199+
import Mathlib.RingTheory.DedekindDomain.Instances
51995200
import Mathlib.RingTheory.DedekindDomain.IntegralClosure
52005201
import Mathlib.RingTheory.DedekindDomain.PID
52015202
import Mathlib.RingTheory.DedekindDomain.SInteger

Mathlib/RingTheory/DedekindDomain/Different.lean

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ theorem differentIdeal_ne_bot [Module.Finite A B]
472472
let L := FractionRing B
473473
have : IsLocalization (Algebra.algebraMapSubmonoid B A⁰) L :=
474474
IsIntegralClosure.isLocalization _ K _ _
475-
have : FiniteDimensional K L := Module.Finite_of_isLocalization A B _ _ A⁰
475+
have : FiniteDimensional K L := .of_isLocalization A B A⁰
476476
rw [ne_eq, ← FractionalIdeal.coeIdeal_inj (K := L), coeIdeal_differentIdeal (K := K)]
477477
simp
478478

@@ -649,8 +649,7 @@ lemma pow_sub_one_dvd_differentIdeal [Algebra.IsSeparable (FractionRing A) (Frac
649649
(hP : P ^ e ∣ p.map (algebraMap A B)) : P ^ (e - 1) ∣ differentIdeal A B := by
650650
have : IsLocalization (algebraMapSubmonoid B A⁰) (FractionRing B) :=
651651
IsIntegralClosure.isLocalization _ (FractionRing A) _ _
652-
have : FiniteDimensional (FractionRing A) (FractionRing B) :=
653-
Module.Finite_of_isLocalization A B _ _ A⁰
652+
have : FiniteDimensional (FractionRing A) (FractionRing B) := .of_isLocalization A B A⁰
654653
by_cases he : e = 0
655654
· rw [he, pow_zero]; exact one_dvd _
656655
exact pow_sub_one_dvd_differentIdeal_aux A (FractionRing A) (FractionRing B) _ he hp hP
@@ -675,7 +674,7 @@ theorem not_dvd_differentIdeal_of_intTrace_not_mem
675674
let L := FractionRing B
676675
have : IsLocalization (Algebra.algebraMapSubmonoid B A⁰) L :=
677676
IsIntegralClosure.isLocalization _ K _ _
678-
have : FiniteDimensional K L := Module.Finite_of_isLocalization A B _ _ A⁰
677+
have : FiniteDimensional K L := .of_isLocalization A B A⁰
679678
rw [Ideal.dvd_iff_le]
680679
intro H
681680
replace H := (mul_le_mul_right' H Q).trans_eq hP
@@ -766,8 +765,7 @@ lemma dvd_differentIdeal_of_not_isSeparable
766765
let L := FractionRing B
767766
have : IsLocalization (Algebra.algebraMapSubmonoid B A⁰) L :=
768767
IsIntegralClosure.isLocalization _ K _ _
769-
have : FiniteDimensional K L :=
770-
Module.Finite_of_isLocalization A B _ _ A⁰
768+
have : FiniteDimensional K L := .of_isLocalization A B A⁰
771769
have hp' := (Ideal.map_eq_bot_iff_of_injective
772770
(FaithfulSMul.algebraMap_injective A B)).not.mpr hp
773771
have habot : a ≠ ⊥ := fun ha' ↦ hp' (by simpa [ha'] using ha)
@@ -826,7 +824,7 @@ theorem not_dvd_differentIdeal_iff
826824
simp only [Submodule.zero_eq_bot, differentIdeal_ne_bot, not_false_eq_true, true_iff]
827825
let K := FractionRing A
828826
let L := FractionRing B
829-
have : FiniteDimensional K L := Module.Finite_of_isLocalization A B _ _ A⁰
827+
have : FiniteDimensional K L := .of_isLocalization A B A⁰
830828
have : IsLocalization B⁰ (Localization.AtPrime (⊥ : Ideal B)) := by
831829
convert (inferInstanceAs
832830
(IsLocalization (⊥ : Ideal B).primeCompl (Localization.AtPrime (⊥ : Ideal B))))
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
/-
2+
Copyright (c) 2025 Riccardo Brasca. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Riccardo Brasca
5+
-/
6+
7+
import Mathlib.Algebra.Lie.OfAssociative
8+
import Mathlib.Order.CompletePartialOrder
9+
import Mathlib.RingTheory.DedekindDomain.PID
10+
import Mathlib.FieldTheory.Separable
11+
12+
/-!
13+
# Instances for Dedekind domains
14+
This file contains various instances to work with localization of a ring extension.
15+
16+
A very common situation in number theory is to have an extension of (say) Dedekind domains `R` and
17+
`S`, and to prove a property of this extension it is useful to consider the localization `Rₚ` of `R`
18+
at `P`, a prime ideal of `R`. One also works with the corresponding localization `Sₚ` of `S` and the
19+
fraction fields `K` and `L` of `R` and `S`. In this situation there are many compatible algebra
20+
structures and various properties of the rings involved. This file contains a collection of such
21+
instances.
22+
23+
## Implementation details
24+
In general one wants all the results below for any algebra satisfying `IsLocalization`, but those
25+
cannot be instances (since Lean has no way of guessing the submonoid). Having the instances in the
26+
special case of *the* localization at a prime ideal is useful in working with Dedekind domains.
27+
28+
-/
29+
30+
open nonZeroDivisors IsLocalization Algebra IsFractionRing IsScalarTower
31+
32+
attribute [local instance] FractionRing.liftAlgebra
33+
34+
variable {R : Type*} (S : Type*) [CommRing R] [CommRing S] [IsDomain R] [IsDomain S] [Algebra R S]
35+
36+
local notation3 "K" => FractionRing R
37+
local notation3 "L" => FractionRing S
38+
section
39+
40+
theorem algebraMapSubmonoid_le_nonZeroDivisors_of_faithfulSMul {A : Type*} (B : Type*)
41+
[CommSemiring A] [CommSemiring B] [Algebra A B] [NoZeroDivisors B] [FaithfulSMul A B]
42+
{S : Submonoid A} (hS : S ≤ A⁰) : algebraMapSubmonoid B S ≤ B⁰ :=
43+
map_le_nonZeroDivisors_of_injective _ (FaithfulSMul.algebraMap_injective A B) hS
44+
45+
variable (Rₘ Sₘ : Type*) [CommRing Rₘ] [CommRing Sₘ] [Algebra R Rₘ] [NoZeroSMulDivisors R S]
46+
[Algebra.IsSeparable (FractionRing R) (FractionRing S)] {M : Submonoid R} [IsLocalization M Rₘ]
47+
[Algebra Rₘ Sₘ] [Algebra S Sₘ] [Algebra R Sₘ] [IsScalarTower R Rₘ Sₘ]
48+
[IsScalarTower R S Sₘ] [IsLocalization (algebraMapSubmonoid S M) Sₘ]
49+
[Algebra (FractionRing Rₘ) (FractionRing Sₘ)]
50+
[IsScalarTower Rₘ (FractionRing Rₘ) (FractionRing Sₘ)]
51+
52+
include R S in
53+
theorem FractionRing.isSeparable_of_isLocalization (hM : M ≤ R⁰) :
54+
Algebra.IsSeparable (FractionRing Rₘ) (FractionRing Sₘ) := by
55+
let M' := algebraMapSubmonoid S M
56+
have hM' : algebraMapSubmonoid S M ≤ S⁰ := algebraMapSubmonoid_le_nonZeroDivisors_of_faithfulSMul
57+
_ hM
58+
let f₁ : Rₘ →+* K := map _ (T := R⁰) (RingHom.id R) hM
59+
let f₂ : Sₘ →+* L := map _ (T := S⁰) (RingHom.id S) hM'
60+
algebraize [f₁, f₂]
61+
have := localization_isScalarTower_of_submonoid_le Rₘ K _ _ hM
62+
have := localization_isScalarTower_of_submonoid_le Sₘ L _ _ hM'
63+
have := isFractionRing_of_isDomain_of_isLocalization M Rₘ K
64+
have := isFractionRing_of_isDomain_of_isLocalization M' Sₘ L
65+
have : IsDomain Rₘ := isDomain_of_le_nonZeroDivisors _ hM
66+
apply Algebra.IsSeparable.of_equiv_equiv (FractionRing.algEquiv Rₘ K).symm.toRingEquiv
67+
(FractionRing.algEquiv Sₘ L).symm.toRingEquiv
68+
apply ringHom_ext R⁰
69+
ext
70+
simp only [AlgEquiv.toRingEquiv_eq_coe, RingHom.coe_comp,
71+
RingHom.coe_coe, Function.comp_apply, ← algebraMap_apply]
72+
rw [algebraMap_apply R Rₘ (FractionRing R), AlgEquiv.coe_ringEquiv, AlgEquiv.commutes,
73+
algebraMap_apply R S L, algebraMap_apply S Sₘ L, AlgEquiv.coe_ringEquiv, AlgEquiv.commutes]
74+
simp only [← algebraMap_apply]
75+
rw [algebraMap_apply R Rₘ (FractionRing Rₘ), ← algebraMap_apply Rₘ, ← algebraMap_apply]
76+
77+
end
78+
79+
variable {P : Ideal R} [P.IsPrime]
80+
81+
local notation3 "P'" => algebraMapSubmonoid S P.primeCompl
82+
local notation3 "Rₚ" => Localization.AtPrime P
83+
local notation3 "Sₚ" => Localization P'
84+
85+
variable [FaithfulSMul R S]
86+
87+
noncomputable instance : Algebra Sₚ L :=
88+
(map _ (T := S⁰) (RingHom.id S)
89+
(algebraMapSubmonoid_le_nonZeroDivisors_of_faithfulSMul _
90+
P.primeCompl_le_nonZeroDivisors)).toAlgebra
91+
92+
instance : IsScalarTower S Sₚ L :=
93+
localization_isScalarTower_of_submonoid_le _ _ _ _
94+
(algebraMapSubmonoid_le_nonZeroDivisors_of_faithfulSMul _
95+
P.primeCompl_le_nonZeroDivisors)
96+
97+
instance : IsFractionRing Rₚ K :=
98+
isFractionRing_of_isDomain_of_isLocalization P.primeCompl _ _
99+
100+
instance : IsFractionRing Sₚ L :=
101+
isFractionRing_of_isDomain_of_isLocalization P' _ _
102+
103+
noncomputable instance : Algebra Rₚ L :=
104+
(lift (M := P.primeCompl) (g := algebraMap R L) <|
105+
fun ⟨x, hx⟩ ↦ by simpa using fun h ↦ hx <| by simp [h]).toAlgebra
106+
107+
-- Make sure there are no diamonds in the case `R = S`.
108+
example : instAlgebraLocalizationAtPrime P = instAlgebraAtPrimeFractionRing (S := R) := by
109+
with_reducible_and_instances rfl
110+
111+
instance : IsScalarTower Rₚ K L :=
112+
of_algebraMap_eq' (ringHom_ext P.primeCompl
113+
(RingHom.ext fun x ↦ by simp [RingHom.algebraMap_toAlgebra]))
114+
115+
instance : IsScalarTower R Rₚ K :=
116+
of_algebraMap_eq' (RingHom.ext fun x ↦ by simp [RingHom.algebraMap_toAlgebra])
117+
118+
instance : IsScalarTower Rₚ Sₚ L := by
119+
refine IsScalarTower.of_algebraMap_eq' <| IsLocalization.ringHom_ext P.primeCompl ?_
120+
rw [RingHom.comp_assoc, ← IsScalarTower.algebraMap_eq R Rₚ Sₚ, IsScalarTower.algebraMap_eq R S Sₚ,
121+
← RingHom.comp_assoc, ← IsScalarTower.algebraMap_eq S Sₚ L, IsScalarTower.algebraMap_eq Rₚ K L,
122+
RingHom.comp_assoc, ← IsScalarTower.algebraMap_eq, ← IsScalarTower.algebraMap_eq,
123+
← IsScalarTower.algebraMap_eq]
124+
125+
instance [IsDedekindDomain S] : IsDedekindDomain Sₚ :=
126+
isDedekindDomain S
127+
(algebraMapSubmonoid_le_nonZeroDivisors_of_faithfulSMul _ P.primeCompl_le_nonZeroDivisors) _
128+
129+
instance [IsDedekindDomain R] [IsDedekindDomain S] [Module.Finite R S] [hP : NeZero P] :
130+
IsPrincipalIdealRing Sₚ :=
131+
IsDedekindDomain.isPrincipalIdealRing_localization_over_prime S P (fun h ↦ hP.1 h)
132+
133+
instance [Algebra.IsSeparable K L] :
134+
-- Without the following line there is a timeout
135+
letI : Algebra Rₚ (FractionRing Sₚ) := OreLocalization.instAlgebra
136+
Algebra.IsSeparable (FractionRing Rₚ) (FractionRing Sₚ) :=
137+
let _ : Algebra Rₚ (FractionRing Sₚ) := OreLocalization.instAlgebra
138+
FractionRing.isSeparable_of_isLocalization S _ _ P.primeCompl_le_nonZeroDivisors

Mathlib/RingTheory/DedekindDomain/IntegralClosure.lean

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Mathlib.LinearAlgebra.BilinearForm.DualLattice
99
import Mathlib.RingTheory.DedekindDomain.Basic
1010
import Mathlib.RingTheory.Localization.Module
1111
import Mathlib.RingTheory.Trace.Basic
12+
import Mathlib.RingTheory.RingHom.Finite
1213

1314
/-!
1415
# Integral closure of Dedekind domains
@@ -247,8 +248,8 @@ instance integralClosure.isDedekindDomain_fractionRing [IsDedekindDomain A] :
247248
integralClosure.isDedekindDomain A (FractionRing A) L
248249

249250
attribute [local instance] FractionRing.liftAlgebra in
250-
instance [NoZeroSMulDivisors A C] [Module.Finite A C] [IsIntegrallyClosed C] :
251-
IsLocalization (Algebra.algebraMapSubmonoid C A⁰) (FractionRing C) :=
252-
IsIntegralClosure.isLocalization _ (FractionRing A) _ _
251+
instance [Module.Finite A C] [NoZeroSMulDivisors A C] :
252+
FiniteDimensional (FractionRing A) (FractionRing C) :=
253+
.of_isLocalization A C A⁰
253254

254255
end IsIntegralClosure

Mathlib/RingTheory/Ideal/Norm/RelNorm.lean

Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Authors: Anne Baanen, Alex J. Best
55
-/
66
import Mathlib.LinearAlgebra.FreeModule.PID
77
import Mathlib.RingTheory.DedekindDomain.PID
8+
import Mathlib.RingTheory.DedekindDomain.Instances
89
import Mathlib.RingTheory.Localization.NormTrace
910
import Mathlib.RingTheory.IntegralClosure.IntegralRestrict
1011

@@ -145,12 +146,11 @@ theorem spanIntNorm_localization (I : Ideal S) (M : Submonoid R) (hM : M ≤ R
145146
Algebra.norm_algebraMap] at has
146147
apply IsFractionRing.injective Rₘ K
147148
simp only [map_mul, map_pow]
148-
have : FiniteDimensional K L := Module.Finite_of_isLocalization R S _ _ R⁰
149+
have : FiniteDimensional K L := .of_isLocalization R S R⁰
149150
rwa [Algebra.algebraMap_intNorm (L := L), ← IsScalarTower.algebraMap_apply,
150151
← IsScalarTower.algebraMap_apply, Algebra.algebraMap_intNorm (L := L)]
151152
· intro a ha
152-
rw [Set.mem_preimage, Function.comp_apply, Algebra.intNorm_eq_of_isLocalization
153-
(A := R) (B := S) M (Aₘ := Rₘ) (Bₘ := Sₘ)]
153+
rw [Set.mem_preimage, Function.comp_apply, Algebra.intNorm_eq_of_isLocalization M (Bₘ := Sₘ)]
154154
exact subset_span (Set.mem_image_of_mem _ (mem_map_of_mem _ ha))
155155

156156
theorem spanNorm_mul_spanNorm_le (I J : Ideal S) :
@@ -191,42 +191,10 @@ theorem spanNorm_mul (I J : Ideal S) : spanNorm R (I * J) = spanNorm R I * spanN
191191
rw [spanNorm_mul_of_bot_or_top]
192192
intro I
193193
exact or_iff_not_imp_right.mpr fun hI ↦ (hP.eq_of_le hI bot_le).symm
194+
have : NeZero P := ⟨hP0⟩
194195
let P' := Algebra.algebraMapSubmonoid S P.primeCompl
195-
let Rₚ := Localization.AtPrime P
196-
let Sₚ := Localization P'
197-
let _ : Algebra Rₚ Sₚ := localizationAlgebra P.primeCompl S
198-
have : IsScalarTower R Rₚ Sₚ :=
199-
IsScalarTower.of_algebraMap_eq (fun x =>
200-
(IsLocalization.map_eq (T := P') (Q := Localization P') P.primeCompl.le_comap_map x).symm)
201-
have h : P' ≤ S⁰ :=
202-
map_le_nonZeroDivisors_of_injective _ (FaithfulSMul.algebraMap_injective _ _)
203-
P.primeCompl_le_nonZeroDivisors
204-
have : IsDomain Sₚ := IsLocalization.isDomain_localization h
205-
have : IsDedekindDomain Sₚ := IsLocalization.isDedekindDomain S h _
206-
have : IsPrincipalIdealRing Sₚ :=
207-
IsDedekindDomain.isPrincipalIdealRing_localization_over_prime S P hP0
208-
have := NoZeroSMulDivisors_of_isLocalization R S Rₚ Sₚ P.primeCompl_le_nonZeroDivisors
209-
have := Module.Finite_of_isLocalization R S Rₚ Sₚ P.primeCompl
210-
let L := FractionRing S
211-
let g : Sₚ →+* L := IsLocalization.map _ (M := P') (T := S⁰) (RingHom.id S) h
212-
algebraize [g]
213-
have : IsScalarTower S Sₚ (FractionRing S) := IsScalarTower.of_algebraMap_eq'
214-
(by rw [RingHom.algebraMap_toAlgebra, IsLocalization.map_comp, RingHom.comp_id])
215-
have := IsFractionRing.isFractionRing_of_isDomain_of_isLocalization P' Sₚ (FractionRing S)
216-
have : Algebra.IsSeparable (FractionRing Rₚ) (FractionRing Sₚ) := by
217-
apply Algebra.IsSeparable.of_equiv_equiv
218-
(FractionRing.algEquiv Rₚ (FractionRing R)).symm.toRingEquiv
219-
(FractionRing.algEquiv Sₚ (FractionRing S)).symm.toRingEquiv
220-
apply IsLocalization.ringHom_ext R⁰
221-
ext
222-
simp only [AlgEquiv.toRingEquiv_eq_coe, RingHom.coe_comp,
223-
RingHom.coe_coe, Function.comp_apply, ← IsScalarTower.algebraMap_apply]
224-
rw [IsScalarTower.algebraMap_apply R Rₚ (FractionRing R), AlgEquiv.coe_ringEquiv,
225-
AlgEquiv.commutes, IsScalarTower.algebraMap_apply R S L,
226-
IsScalarTower.algebraMap_apply S Sₚ L, AlgEquiv.coe_ringEquiv, AlgEquiv.commutes]
227-
simp only [← IsScalarTower.algebraMap_apply]
228-
simp only [Ideal.map_mul, ← spanIntNorm_localization (R := R) (S := S)
229-
(Rₘ := Localization.AtPrime P) (Sₘ := Localization P') _ _ P.primeCompl_le_nonZeroDivisors]
196+
simp only [Ideal.map_mul, ← spanIntNorm_localization (R := R) (Sₘ := Localization P')
197+
_ _ P.primeCompl_le_nonZeroDivisors]
230198
rw [← (I.map _).span_singleton_generator, ← (J.map _).span_singleton_generator,
231199
span_singleton_mul_span_singleton, spanNorm_singleton, spanNorm_singleton,
232200
spanNorm_singleton, span_singleton_mul_span_singleton, map_mul]

0 commit comments

Comments
 (0)