Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 052f601

Browse files
committed
refactor(algebraic_geometry/prime_spectrum/basic): refactor prime_spectrum def into structure (#16930)
1 parent 7617158 commit 052f601

File tree

7 files changed

+86
-127
lines changed

7 files changed

+86
-127
lines changed

src/algebraic_geometry/prime_spectrum/basic.lean

Lines changed: 68 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ Authors: Johan Commelin
55
-/
66
import algebra.punit_instances
77
import linear_algebra.finsupp
8-
import ring_theory.nilpotent
9-
import ring_theory.localization.away
10-
import ring_theory.ideal.prod
118
import ring_theory.ideal.over
9+
import ring_theory.ideal.prod
10+
import ring_theory.localization.away
11+
import ring_theory.nilpotent
1212
import topology.sets.closeds
1313
import topology.sober
1414

@@ -37,79 +37,84 @@ whereas we denote subsets of prime spectra with `t`, `t'`, etc...
3737
3838
## Inspiration/contributors
3939
40-
The contents of this file draw inspiration from
41-
<https://github.com/ramonfmir/lean-scheme>
40+
The contents of this file draw inspiration from <https://github.com/ramonfmir/lean-scheme>
4241
which has contributions from Ramon Fernandez Mir, Kevin Buzzard, Kenny Lau,
4342
and Chris Hughes (on an earlier repository).
44-
4543
-/
4644

4745
noncomputable theory
4846
open_locale classical
4947

5048
universes u v
5149

52-
variables (R : Type u) [comm_ring R]
50+
variables (R : Type u) (S : Type v) [comm_ring R] [comm_ring S]
5351

54-
/-- The prime spectrum of a commutative ring `R`
55-
is the type of all prime ideals of `R`.
52+
/-- The prime spectrum of a commutative ring `R` is the type of all prime ideals of `R`.
5653
5754
It is naturally endowed with a topology (the Zariski topology),
5855
and a sheaf of commutative rings (see `algebraic_geometry.structure_sheaf`).
5956
It is a fundamental building block in algebraic geometry. -/
60-
@[nolint has_nonempty_instance]
61-
def prime_spectrum := {I : ideal R // I.is_prime}
57+
@[ext] structure prime_spectrum :=
58+
(as_ideal : ideal R)
59+
(is_prime : as_ideal.is_prime)
6260

63-
variable {R}
61+
attribute [instance] prime_spectrum.is_prime
6462

6563
namespace prime_spectrum
6664

67-
/-- A method to view a point in the prime spectrum of a commutative ring
68-
as an ideal of that ring. -/
69-
abbreviation as_ideal (x : prime_spectrum R) : ideal R := x.val
65+
variables {R S}
7066

71-
instance is_prime (x : prime_spectrum R) :
72-
x.as_ideal.is_prime := x.2
67+
instance [nontrivial R] : nonempty $ prime_spectrum R :=
68+
let ⟨I, hI⟩ := ideal.exists_maximal R in ⟨⟨I, hI.is_prime⟩⟩
7369

74-
/--
75-
The prime spectrum of the zero ring is empty.
76-
-/
70+
/-- The prime spectrum of the zero ring is empty. -/
7771
lemma punit (x : prime_spectrum punit) : false :=
7872
x.1.ne_top_iff_one.1 x.2.1 $ subsingleton.elim (0 : punit) 1 ▸ x.1.zero_mem
7973

80-
section
81-
variables (R) (S : Type v) [comm_ring S]
74+
variables (R S)
75+
76+
/-- The map from the direct sum of prime spectra to the prime spectrum of a direct product. -/
77+
@[simp] def prime_spectrum_prod_of_sum :
78+
prime_spectrum R ⊕ prime_spectrum S → prime_spectrum (R × S)
79+
| (sum.inl ⟨I, hI⟩) := ⟨ideal.prod I ⊤, by exactI ideal.is_prime_ideal_prod_top⟩
80+
| (sum.inr ⟨J, hJ⟩) := ⟨ideal.prod ⊤ J, by exactI ideal.is_prime_ideal_prod_top'⟩
8281

8382
/-- The prime spectrum of `R × S` is in bijection with the disjoint unions of the prime spectrum of
84-
`R` and the prime spectrum of `S`. -/
83+
`R` and the prime spectrum of `S`. -/
8584
noncomputable def prime_spectrum_prod :
8685
prime_spectrum (R × S) ≃ prime_spectrum R ⊕ prime_spectrum S :=
87-
ideal.prime_ideals_equiv R S
86+
equiv.symm $ equiv.of_bijective (prime_spectrum_prod_of_sum R S)
87+
begin
88+
split,
89+
{ rintro (⟨I, hI⟩|⟨J, hJ⟩) (⟨I', hI'⟩|⟨J', hJ'⟩) h;
90+
simp only [ideal.prod.ext_iff, prime_spectrum_prod_of_sum] at h,
91+
{ simp only [h] },
92+
{ exact false.elim (hI.ne_top h.left) },
93+
{ exact false.elim (hJ.ne_top h.right) },
94+
{ simp only [h] } },
95+
{ rintro ⟨I, hI⟩,
96+
rcases (ideal.ideal_prod_prime I).mp hI with (⟨p, ⟨hp, rfl⟩⟩|⟨p, ⟨hp, rfl⟩⟩),
97+
{ exact ⟨sum.inl ⟨p, hp⟩, rfl⟩ },
98+
{ exact ⟨sum.inr ⟨p, hp⟩, rfl⟩ } }
99+
end
88100

89101
variables {R S}
90102

91103
@[simp] lemma prime_spectrum_prod_symm_inl_as_ideal (x : prime_spectrum R) :
92-
((prime_spectrum_prod R S).symm (sum.inl x)).as_ideal = ideal.prod x.as_ideal ⊤ :=
104+
((prime_spectrum_prod R S).symm $ sum.inl x).as_ideal = ideal.prod x.as_ideal ⊤ :=
93105
by { cases x, refl }
106+
94107
@[simp] lemma prime_spectrum_prod_symm_inr_as_ideal (x : prime_spectrum S) :
95-
((prime_spectrum_prod R S).symm (sum.inr x)).as_ideal = ideal.prod ⊤ x.as_ideal :=
108+
((prime_spectrum_prod R S).symm $ sum.inr x).as_ideal = ideal.prod ⊤ x.as_ideal :=
96109
by { cases x, refl }
97110

98-
end
99-
100-
@[ext] lemma ext {x y : prime_spectrum R} :
101-
x = y ↔ x.as_ideal = y.as_ideal :=
102-
subtype.ext_iff_val
103-
104-
/-- The zero locus of a set `s` of elements of a commutative ring `R`
105-
is the set of all prime ideals of the ring that contain the set `s`.
111+
/-- The zero locus of a set `s` of elements of a commutative ring `R` is the set of all prime ideals
112+
of the ring that contain the set `s`.
106113
107-
An element `f` of `R` can be thought of as a dependent function
108-
on the prime spectrum of `R`.
109-
At a point `x` (a prime ideal)
110-
the function (i.e., element) `f` takes values in the quotient ring `R` modulo the prime ideal `x`.
111-
In this manner, `zero_locus s` is exactly the subset of `prime_spectrum R`
112-
where all "functions" in `s` vanish simultaneously.
114+
An element `f` of `R` can be thought of as a dependent function on the prime spectrum of `R`.
115+
At a point `x` (a prime ideal) the function (i.e., element) `f` takes values in the quotient ring
116+
`R` modulo the prime ideal `x`. In this manner, `zero_locus s` is exactly the subset of
117+
`prime_spectrum R` where all "functions" in `s` vanish simultaneously.
113118
-/
114119
def zero_locus (s : set R) : set (prime_spectrum R) :=
115120
{x | s ⊆ x.as_ideal}
@@ -121,15 +126,12 @@ def zero_locus (s : set R) : set (prime_spectrum R) :=
121126
zero_locus (ideal.span s : set R) = zero_locus s :=
122127
by { ext x, exact (submodule.gi R R).gc s x.as_ideal }
123128

124-
/-- The vanishing ideal of a set `t` of points
125-
of the prime spectrum of a commutative ring `R`
126-
is the intersection of all the prime ideals in the set `t`.
129+
/-- The vanishing ideal of a set `t` of points of the prime spectrum of a commutative ring `R` is
130+
the intersection of all the prime ideals in the set `t`.
127131
128-
An element `f` of `R` can be thought of as a dependent function
129-
on the prime spectrum of `R`.
130-
At a point `x` (a prime ideal)
131-
the function (i.e., element) `f` takes values in the quotient ring `R` modulo the prime ideal `x`.
132-
In this manner, `vanishing_ideal t` is exactly the ideal of `R`
132+
An element `f` of `R` can be thought of as a dependent function on the prime spectrum of `R`.
133+
At a point `x` (a prime ideal) the function (i.e., element) `f` takes values in the quotient ring
134+
`R` modulo the prime ideal `x`. In this manner, `vanishing_ideal t` is exactly the ideal of `R`
133135
consisting of all "functions" that vanish on all of `t`.
134136
-/
135137
def vanishing_ideal (t : set (prime_spectrum R)) : ideal R :=
@@ -338,9 +340,8 @@ lemma mem_compl_zero_locus_iff_not_mem {f : R} {I : prime_spectrum R} :
338340
I ∈ (zero_locus {f} : set (prime_spectrum R))ᶜ ↔ f ∉ I.as_ideal :=
339341
by rw [set.mem_compl_iff, mem_zero_locus, set.singleton_subset_iff]; refl
340342

341-
/-- The Zariski topology on the prime spectrum of a commutative ring
342-
is defined via the closed sets of the topology:
343-
they are exactly those sets that are the zero locus of a subset of the ring. -/
343+
/-- The Zariski topology on the prime spectrum of a commutative ring is defined via the closed sets
344+
of the topology: they are exactly those sets that are the zero locus of a subset of the ring. -/
344345
instance zariski_topology : topological_space (prime_spectrum R) :=
345346
topological_space.of_closed (set.range prime_spectrum.zero_locus)
346347
(⟨set.univ, by simp⟩)
@@ -387,7 +388,7 @@ begin
387388
(hs.2 ⟨J, hJ.is_prime⟩ (λ r hr, hIJ (le_of_lt hI $ hs.1 hr)))) },
388389
{ refine ⟨x.as_ideal.1, _⟩,
389390
rw [eq_comm, set.eq_singleton_iff_unique_mem],
390-
refine ⟨λ _ h, h, λ y hy, prime_spectrum.ext.2 (h.eq_of_le y.2.ne_top hy).symm⟩ }
391+
refine ⟨λ _ h, h, λ y hy, prime_spectrum.ext _ _ (h.eq_of_le y.2.ne_top hy).symm⟩ }
391392
end
392393

393394
lemma zero_locus_vanishing_ideal_eq_closure (t : set (prime_spectrum R)) :
@@ -496,7 +497,7 @@ instance : quasi_sober (prime_spectrum R) :=
496497
by rw [is_generic_point, closure_singleton, zero_locus_vanishing_ideal_eq_closure, h₂.closure_eq]⟩⟩
497498

498499
section comap
499-
variables {S : Type v} [comm_ring S] {S' : Type*} [comm_ring S']
500+
variables {S' : Type*} [comm_ring S']
500501

501502
lemma preimage_comap_zero_locus_aux (f : R →+* S) (s : set R) :
502503
(λ y, ⟨ideal.comap f y.as_ideal, infer_instance⟩ :
@@ -540,7 +541,7 @@ preimage_comap_zero_locus_aux f s
540541

541542
lemma comap_injective_of_surjective (f : R →+* S) (hf : function.surjective f) :
542543
function.injective (comap f) :=
543-
λ x y h, prime_spectrum.ext.2 (ideal.comap_injective_of_surjective f hf
544+
λ x y h, prime_spectrum.ext _ _ (ideal.comap_injective_of_surjective f hf
544545
(congr_arg prime_spectrum.as_ideal h : (comap f x).as_ideal = (comap f y).as_ideal))
545546

546547
lemma comap_singleton_is_closed_of_surjective (f : R →+* S) (hf : function.surjective f)
@@ -762,7 +763,7 @@ begin
762763
simp only [set.eq_univ_iff_forall, set.singleton_subset_iff,
763764
topological_space.opens.coe_bot, nilpotent_iff_mem_prime, set.compl_empty_iff, mem_zero_locus,
764765
set_like.mem_coe],
765-
exact subtype.forall,
766+
exact ⟨λ h I hI, h ⟨I, hI⟩, λ h ⟨I, hI⟩, h I hI⟩
766767
end
767768

768769
lemma localization_away_comap_range (S : Type v) [comm_ring S] [algebra R S] (r : R)
@@ -795,20 +796,16 @@ section order
795796
/-!
796797
## The specialization order
797798
798-
We endow `prime_spectrum R` with a partial order,
799-
where `x ≤ y` if and only if `y ∈ closure {x}`.
799+
We endow `prime_spectrum R` with a partial order, where `x ≤ y` if and only if `y ∈ closure {x}`.
800800
-/
801801

802-
instance : partial_order (prime_spectrum R) :=
803-
subtype.partial_order _
802+
instance : partial_order (prime_spectrum R) := partial_order.lift as_ideal ext
804803

805-
@[simp] lemma as_ideal_le_as_ideal (x y : prime_spectrum R) :
806-
x.as_ideal ≤ y.as_ideal ↔ x ≤ y :=
807-
subtype.coe_le_coe
804+
@[simp] lemma as_ideal_le_as_ideal (x y : prime_spectrum R) : x.as_ideal ≤ y.as_ideal ↔ x ≤ y :=
805+
iff.rfl
808806

809-
@[simp] lemma as_ideal_lt_as_ideal (x y : prime_spectrum R) :
810-
x.as_ideal < y.as_ideal ↔ x < y :=
811-
subtype.coe_lt_coe
807+
@[simp] lemma as_ideal_lt_as_ideal (x y : prime_spectrum R) : x.as_ideal < y.as_ideal ↔ x < y :=
808+
iff.rfl
812809

813810
lemma le_iff_mem_closure (x y : prime_spectrum R) :
814811
x ≤ y ↔ y ∈ closure ({x} : set (prime_spectrum R)) :=
@@ -828,8 +825,8 @@ instance : t0_space (prime_spectrum R) := ⟨nhds_order_embedding.injective⟩
828825

829826
end order
830827

831-
/-- If `x` specializes to `y`, then there is a natural map from the localization of `y` to
832-
the localization of `x`. -/
828+
/-- If `x` specializes to `y`, then there is a natural map from the localization of `y` to the
829+
localization of `x`. -/
833830
def localization_map_of_specializes {x y : prime_spectrum R} (h : x ⤳ y) :
834831
localization.at_prime y.as_ideal →+* localization.at_prime x.as_ideal :=
835832
@is_localization.lift _ _ _ _ _ _ _ _
@@ -843,22 +840,18 @@ def localization_map_of_specializes {x y : prime_spectrum R} (h : x ⤳ y) :
843840

844841
end prime_spectrum
845842

846-
847843
namespace local_ring
848844

849-
variables (R) [local_ring R]
845+
variables [local_ring R]
850846

851-
/--
852-
The closed point in the prime spectrum of a local ring.
853-
-/
854-
def closed_point : prime_spectrum R :=
855-
⟨maximal_ideal R, (maximal_ideal.is_maximal R).is_prime⟩
847+
/-- The closed point in the prime spectrum of a local ring. -/
848+
def closed_point : prime_spectrum R := ⟨maximal_ideal R, (maximal_ideal.is_maximal R).is_prime⟩
856849

857850
variable {R}
858851

859852
lemma is_local_ring_hom_iff_comap_closed_point {S : Type v} [comm_ring S] [local_ring S]
860853
(f : R →+* S) : is_local_ring_hom f ↔ prime_spectrum.comap f (closed_point S) = closed_point R :=
861-
by { rw [(local_hom_tfae f).out 0 4, subtype.ext_iff], refl }
854+
by { rw [(local_hom_tfae f).out 0 4, prime_spectrum.ext_iff], refl }
862855

863856
@[simp] lemma comap_closed_point {S : Type v} [comm_ring S] [local_ring S] (f : R →+* S)
864857
[is_local_ring_hom f] : prime_spectrum.comap f (closed_point S) = closed_point R :=

src/algebraic_geometry/prime_spectrum/is_open_comap_C.lean

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def image_of_Df (f) : set (prime_spectrum R) :=
3131

3232
lemma is_open_image_of_Df : is_open (image_of_Df f) :=
3333
begin
34-
rw [image_of_Df, set_of_exists (λ i (x : prime_spectrum R), coeff f i ∉ x.val)],
34+
rw [image_of_Df, set_of_exists (λ i (x : prime_spectrum R), coeff f i ∉ x.as_ideal)],
3535
exact is_open_Union (λ i, is_open_basic_open),
3636
end
3737

@@ -48,11 +48,13 @@ morphism `C⁺ : Spec R[x] → Spec R`. -/
4848
lemma image_of_Df_eq_comap_C_compl_zero_locus :
4949
image_of_Df f = prime_spectrum.comap (C : R →+* R[X]) '' (zero_locus {f})ᶜ :=
5050
begin
51-
refine ext (λ x, ⟨λ hx, ⟨⟨map C x.val, (is_prime_map_C_of_is_prime x.property)⟩, ⟨_, _⟩⟩, _⟩),
51+
ext x,
52+
refine ⟨λ hx, ⟨⟨map C x.as_ideal, (is_prime_map_C_of_is_prime x.is_prime)⟩, ⟨_, _⟩⟩, _⟩,
5253
{ rw [mem_compl_iff, mem_zero_locus, singleton_subset_iff],
5354
cases hx with i hi,
5455
exact λ a, hi (mem_map_C_iff.mp a i) },
55-
{ refine subtype.ext (ext (λ x, ⟨λ h, _, λ h, subset_span (mem_image_of_mem C.1 h)⟩)),
56+
{ ext x,
57+
refine ⟨λ h, _, λ h, subset_span (mem_image_of_mem C.1 h)⟩,
5658
rw ← @coeff_C_zero R x _,
5759
exact mem_map_C_iff.mp h 0 },
5860
{ rintro ⟨xli, complement, rfl⟩,

src/algebraic_geometry/prime_spectrum/maximal.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ variable {R}
4343
namespace maximal_spectrum
4444

4545
instance [nontrivial R] : nonempty $ maximal_spectrum R :=
46-
⟨⟨(ideal.exists_maximal R).some, (ideal.exists_maximal R).some_spec⟩⟩
46+
let ⟨I, hI⟩ := ideal.exists_maximal R in ⟨⟨I, hI⟩⟩
4747

4848
/-- The natural inclusion from the maximal spectrum to the prime spectrum. -/
4949
def to_prime_spectrum (x : maximal_spectrum R) : prime_spectrum R :=
5050
⟨x.as_ideal, x.is_maximal.is_prime⟩
5151

5252
lemma to_prime_spectrum_injective : (@to_prime_spectrum R _).injective :=
53-
λ ⟨_, _⟩ ⟨_, _⟩ h, by simpa only [maximal_spectrum.mk.inj_eq] using subtype.mk.inj h
53+
λ ⟨_, _⟩ ⟨_, _⟩ h, by simpa only [mk.inj_eq] using (prime_spectrum.ext_iff _ _).mp h
5454

5555
open prime_spectrum set
5656

src/algebraic_geometry/prime_spectrum/noetherian.lean

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ variables {A : Type u} [comm_ring A] [is_domain A] [is_noetherian_ring A]
2121
/--In a noetherian ring, every ideal contains a product of prime ideals
2222
([samuel, § 3.3, Lemma 3])-/
2323
lemma exists_prime_spectrum_prod_le (I : ideal R) :
24-
∃ (Z : multiset (prime_spectrum R)), multiset.prod (Z.map (coe : subtype _ → ideal R)) ≤ I :=
24+
∃ (Z : multiset (prime_spectrum R)), multiset.prod (Z.map as_ideal) ≤ I :=
2525
begin
2626
refine is_noetherian.induction (λ (M : ideal R) hgt, _) I,
2727
by_cases h_prM : M.is_prime,
2828
{ use {⟨M, h_prM⟩},
29-
rw [multiset.map_singleton, multiset.prod_singleton, subtype.coe_mk],
29+
rw [multiset.map_singleton, multiset.prod_singleton],
3030
exact le_rfl },
3131
by_cases htop : M = ⊤,
3232
{ rw htop,
@@ -54,8 +54,8 @@ end
5454
product or prime ideals ([samuel, § 3.3, Lemma 3]) -/
5555
lemma exists_prime_spectrum_prod_le_and_ne_bot_of_domain
5656
(h_fA : ¬ is_field A) {I : ideal A} (h_nzI: I ≠ ⊥) :
57-
∃ (Z : multiset (prime_spectrum A)), multiset.prod (Z.map (coe : subtype _ → ideal A)) ≤ I ∧
58-
multiset.prod (Z.map (coe : subtype _ → ideal A)) ≠ ⊥ :=
57+
∃ (Z : multiset (prime_spectrum A)), multiset.prod (Z.map as_ideal) ≤ I ∧
58+
multiset.prod (Z.map as_ideal) ≠ ⊥ :=
5959
begin
6060
revert h_nzI,
6161
refine is_noetherian.induction (λ (M : ideal A) hgt, _) I,
@@ -67,10 +67,10 @@ begin
6767
obtain ⟨p_id, h_nzp, h_pp⟩ : ∃ (p : ideal A), p ≠ ⊥ ∧ p.is_prime,
6868
{ apply ring.not_is_field_iff_exists_prime.mp h_fA },
6969
use [({⟨p_id, h_pp⟩} : multiset (prime_spectrum A)), le_top],
70-
rwa [multiset.map_singleton, multiset.prod_singleton, subtype.coe_mk] },
70+
rwa [multiset.map_singleton, multiset.prod_singleton] },
7171
by_cases h_prM : M.is_prime,
7272
{ use ({⟨M, h_prM⟩} : multiset (prime_spectrum A)),
73-
rw [multiset.map_singleton, multiset.prod_singleton, subtype.coe_mk],
73+
rw [multiset.map_singleton, multiset.prod_singleton],
7474
exact ⟨le_rfl, h_nzM⟩ },
7575
obtain ⟨x, hx, y, hy, h_xy⟩ := (ideal.not_is_prime_iff.mp h_prM).resolve_left h_topM,
7676
have lt_add : ∀ z ∉ M, M < M + span A {z},

src/ring_theory/dedekind_domain/ideal.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,8 @@ begin
342342
obtain ⟨_, hPZ', hPM⟩ := (hM.is_prime.multiset_prod_le (mt multiset.map_eq_zero.mp hZ0)).mp hZM,
343343
-- Then in fact there is a `P ∈ Z` with `P ≤ M`.
344344
obtain ⟨P, hPZ, rfl⟩ := multiset.mem_map.mp hPZ',
345-
letI := classical.dec_eq (ideal A),
346-
have := multiset.map_erase prime_spectrum.as_ideal subtype.coe_injective P Z,
345+
classical,
346+
have := multiset.map_erase prime_spectrum.as_ideal prime_spectrum.ext P Z,
347347
obtain ⟨hP0, hZP0⟩ : P.as_ideal ≠ ⊥ ∧ ((Z.erase P).map prime_spectrum.as_ideal).prod ≠ ⊥,
348348
{ rwa [ne.def, ← multiset.cons_erase hPZ', multiset.prod_cons, ideal.mul_eq_bot,
349349
not_or_distrib, ← this] at hprodZ },

0 commit comments

Comments
 (0)