-
Notifications
You must be signed in to change notification settings - Fork 298
/
local_ring.lean
342 lines (266 loc) · 11.2 KB
/
local_ring.lean
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
/-
Copyright (c) 2018 Kenny Lau. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau, Chris Hughes, Mario Carneiro
-/
import algebra.algebra.basic
import algebra.category.CommRing.basic
import ring_theory.ideal.operations
/-!
# Local rings
Define local rings as commutative rings having a unique maximal ideal.
## Main definitions
* `local_ring`: A predicate on commutative semirings, stating that the set of nonunits is closed
under the addition. This is shown to be equivalent to the condition that there exists a unique
maximal ideal.
* `local_ring.maximal_ideal`: The unique maximal ideal for a local rings. Its carrier set is the
set of non units.
* `is_local_ring_hom`: A predicate on semiring homomorphisms, requiring that it maps nonunits
to nonunits. For local rings, this means that the image of the unique maximal ideal is again
contained in the unique maximal ideal.
* `local_ring.residue_field`: The quotient of a local ring by its maximal ideal.
-/
universes u v w u'
variables {R : Type u} {S : Type v} {T : Type w} {K : Type u'}
/-- A commutative ring is local if it has a unique maximal ideal. Note that
`local_ring` is a predicate. -/
class local_ring (R : Type u) [semiring R] extends nontrivial R : Prop :=
(nonunits_add : ∀ {a b : R}, a ∈ nonunits R → b ∈ nonunits R → a + b ∈ nonunits R)
section comm_semiring
variables [comm_semiring R]
namespace local_ring
lemma of_nonunits_ideal (hnze : (0:R) ≠ 1) (h : ∀ x y ∈ nonunits R, x + y ∈ nonunits R) :
local_ring R :=
{ exists_pair_ne := ⟨0, 1, hnze⟩,
nonunits_add := λ x y hx hy, h x hx y hy }
lemma of_unique_max_ideal (h : ∃! I : ideal R, I.is_maximal) :
local_ring R :=
of_nonunits_ideal
(let ⟨I, Imax, _⟩ := h in (λ (H : 0 = 1), Imax.1.1 $ I.eq_top_iff_one.2 $ H ▸ I.zero_mem))
$ λ x hx y hy H,
let ⟨I, Imax, Iuniq⟩ := h in
let ⟨Ix, Ixmax, Hx⟩ := exists_max_ideal_of_mem_nonunits hx in
let ⟨Iy, Iymax, Hy⟩ := exists_max_ideal_of_mem_nonunits hy in
have xmemI : x ∈ I, from ((Iuniq Ix Ixmax) ▸ Hx),
have ymemI : y ∈ I, from ((Iuniq Iy Iymax) ▸ Hy),
Imax.1.1 $ I.eq_top_of_is_unit_mem (I.add_mem xmemI ymemI) H
lemma of_unique_nonzero_prime (h : ∃! P : ideal R, P ≠ ⊥ ∧ ideal.is_prime P) :
local_ring R :=
of_unique_max_ideal begin
rcases h with ⟨P, ⟨hPnonzero, hPnot_top, _⟩, hPunique⟩,
refine ⟨P, ⟨⟨hPnot_top, _⟩⟩, λ M hM, hPunique _ ⟨_, ideal.is_maximal.is_prime hM⟩⟩,
{ refine ideal.maximal_of_no_maximal (λ M hPM hM, ne_of_lt hPM _),
exact (hPunique _ ⟨ne_bot_of_gt hPM, ideal.is_maximal.is_prime hM⟩).symm },
{ rintro rfl,
exact hPnot_top (hM.1.2 P (bot_lt_iff_ne_bot.2 hPnonzero)) },
end
variables (R) [local_ring R]
/-- The ideal of elements that are not units. -/
def maximal_ideal : ideal R :=
{ carrier := nonunits R,
zero_mem' := zero_mem_nonunits.2 $ zero_ne_one,
add_mem' := λ x y hx hy, nonunits_add hx hy,
smul_mem' := λ a x, mul_mem_nonunits_right }
instance maximal_ideal.is_maximal : (maximal_ideal R).is_maximal :=
begin
rw ideal.is_maximal_iff,
split,
{ intro h, apply h, exact is_unit_one },
{ intros I x hI hx H,
erw not_not at hx,
rcases hx with ⟨u,rfl⟩,
simpa using I.mul_mem_left ↑u⁻¹ H }
end
lemma maximal_ideal_unique : ∃! I : ideal R, I.is_maximal :=
⟨maximal_ideal R, maximal_ideal.is_maximal R,
λ I hI, hI.eq_of_le (maximal_ideal.is_maximal R).1.1 $
λ x hx, hI.1.1 ∘ I.eq_top_of_is_unit_mem hx⟩
variable {R}
lemma eq_maximal_ideal {I : ideal R} (hI : I.is_maximal) : I = maximal_ideal R :=
unique_of_exists_unique (maximal_ideal_unique R) hI $ maximal_ideal.is_maximal R
lemma le_maximal_ideal {J : ideal R} (hJ : J ≠ ⊤) : J ≤ maximal_ideal R :=
begin
rcases ideal.exists_le_maximal J hJ with ⟨M, hM1, hM2⟩,
rwa ←eq_maximal_ideal hM1
end
@[simp] lemma mem_maximal_ideal (x) : x ∈ maximal_ideal R ↔ x ∈ nonunits R := iff.rfl
end local_ring
end comm_semiring
section comm_ring
variables [comm_ring R]
namespace local_ring
lemma of_is_unit_or_is_unit_one_sub_self [nontrivial R]
(h : ∀ a : R, is_unit a ∨ is_unit (1 - a)) : local_ring R :=
local_ring.mk
begin
intros x y hx hy,
rintros ⟨u, hu⟩,
apply hy,
suffices : is_unit ((↑u⁻¹ : R) * y),
{ rcases this with ⟨s, hs⟩,
use u * s,
convert congr_arg (λ z, (u : R) * z) hs,
rw ← mul_assoc, simp },
rw show (↑u⁻¹ * y) = (1 - ↑u⁻¹ * x),
{ rw eq_sub_iff_add_eq,
replace hu := congr_arg (λ z, (↑u⁻¹ : R) * z) hu.symm,
simpa [mul_add, add_comm] using hu },
apply or_iff_not_imp_left.1 (h _),
exact mul_mem_nonunits_right hx
end
variables [local_ring R]
lemma is_unit_or_is_unit_one_sub_self (a : R) : is_unit a ∨ is_unit (1 - a) :=
or_iff_not_and_not.2 $ λ h, nonunits_add h.1 h.2 $ (add_sub_cancel'_right a 1).symm ▸ is_unit_one
lemma is_unit_of_mem_nonunits_one_sub_self (a : R) (h : 1 - a ∈ nonunits R) :
is_unit a :=
or_iff_not_imp_right.1 (is_unit_or_is_unit_one_sub_self a) h
lemma is_unit_one_sub_self_of_mem_nonunits (a : R) (h : a ∈ nonunits R) :
is_unit (1 - a) :=
or_iff_not_imp_left.1 (is_unit_or_is_unit_one_sub_self a) h
lemma of_surjective [comm_ring S] [nontrivial S] (f : R →+* S) (hf : function.surjective f) :
local_ring S :=
of_is_unit_or_is_unit_one_sub_self
begin
intros b,
obtain ⟨a, rfl⟩ := hf b,
apply (is_unit_or_is_unit_one_sub_self a).imp f.is_unit_map _,
rw [← f.map_one, ← f.map_sub],
apply f.is_unit_map,
end
end local_ring
end comm_ring
/-- A local ring homomorphism is a homomorphism between local rings
such that the image of the maximal ideal of the source is contained within
the maximal ideal of the target. -/
class is_local_ring_hom [semiring R] [semiring S] (f : R →+* S) : Prop :=
(map_nonunit : ∀ a, is_unit (f a) → is_unit a)
section
variables [semiring R] [semiring S] [semiring T]
instance is_local_ring_hom_id (R : Type*) [semiring R] : is_local_ring_hom (ring_hom.id R) :=
{ map_nonunit := λ a, id }
@[simp] lemma is_unit_map_iff (f : R →+* S) [is_local_ring_hom f] (a) :
is_unit (f a) ↔ is_unit a :=
⟨is_local_ring_hom.map_nonunit a, f.is_unit_map⟩
@[simp] lemma map_mem_nonunits_iff (f : R →+* S) [is_local_ring_hom f] (a) :
f a ∈ nonunits S ↔ a ∈ nonunits R :=
⟨λ h ha, h $ (is_unit_map_iff f a).mpr ha, λ h ha, h $ (is_unit_map_iff f a).mp ha⟩
instance is_local_ring_hom_comp
(g : S →+* T) (f : R →+* S) [is_local_ring_hom g] [is_local_ring_hom f] :
is_local_ring_hom (g.comp f) :=
{ map_nonunit := λ a, is_local_ring_hom.map_nonunit a ∘ is_local_ring_hom.map_nonunit (f a) }
instance is_local_ring_hom_equiv (f : R ≃+* S) :
is_local_ring_hom f.to_ring_hom :=
{ map_nonunit := λ a ha,
begin
convert f.symm.to_ring_hom.is_unit_map ha,
rw ring_equiv.symm_to_ring_hom_apply_to_ring_hom_apply,
end }
@[simp] lemma is_unit_of_map_unit (f : R →+* S) [is_local_ring_hom f]
(a) (h : is_unit (f a)) : is_unit a :=
is_local_ring_hom.map_nonunit a h
theorem of_irreducible_map (f : R →+* S) [h : is_local_ring_hom f] {x}
(hfx : irreducible (f x)) : irreducible x :=
⟨λ h, hfx.not_unit $ is_unit.map f h, λ p q hx, let ⟨H⟩ := h in
or.imp (H p) (H q) $ hfx.is_unit_or_is_unit $ f.map_mul p q ▸ congr_arg f hx⟩
lemma is_local_ring_hom_of_comp (f : R →+* S) (g : S →+* T) [is_local_ring_hom (g.comp f)] :
is_local_ring_hom f :=
⟨λ a ha, (is_unit_map_iff (g.comp f) _).mp (g.is_unit_map ha)⟩
instance _root_.CommRing.is_local_ring_hom_comp {R S T : CommRing} (f : R ⟶ S) (g : S ⟶ T)
[is_local_ring_hom g] [is_local_ring_hom f] :
is_local_ring_hom (f ≫ g) := is_local_ring_hom_comp _ _
/-- If `f : R →+* S` is a local ring hom, then `R` is a local ring if `S` is. -/
lemma _root_.ring_hom.domain_local_ring {R S : Type*} [comm_semiring R] [comm_semiring S]
[H : _root_.local_ring S] (f : R →+* S)
[is_local_ring_hom f] : _root_.local_ring R :=
begin
haveI : nontrivial R := pullback_nonzero f f.map_zero f.map_one,
constructor,
intros a b,
simp_rw [←map_mem_nonunits_iff f, f.map_add],
exact local_ring.nonunits_add
end
section
open category_theory
lemma is_local_ring_hom_of_iso {R S : CommRing} (f : R ≅ S) : is_local_ring_hom f.hom :=
{ map_nonunit := λ a ha,
begin
convert f.inv.is_unit_map ha,
rw category_theory.coe_hom_inv_id,
end }
@[priority 100] -- see Note [lower instance priority]
instance is_local_ring_hom_of_is_iso {R S : CommRing} (f : R ⟶ S) [is_iso f] :
is_local_ring_hom f :=
is_local_ring_hom_of_iso (as_iso f)
end
end
section
open local_ring
variables [comm_semiring R] [local_ring R] [comm_semiring S] [local_ring S]
lemma map_nonunit (f : R →+* S) [is_local_ring_hom f] (a : R) (h : a ∈ maximal_ideal R) :
f a ∈ maximal_ideal S :=
λ H, h $ is_unit_of_map_unit f a H
end
namespace local_ring
section
variables [comm_semiring R] [local_ring R] [comm_semiring S] [local_ring S]
/--
A ring homomorphism between local rings is a local ring hom iff it reflects units,
i.e. any preimage of a unit is still a unit. https://stacks.math.columbia.edu/tag/07BJ
-/
theorem local_hom_tfae (f : R →+* S) :
tfae [is_local_ring_hom f,
f '' (maximal_ideal R).1 ⊆ maximal_ideal S,
(maximal_ideal R).map f ≤ maximal_ideal S,
maximal_ideal R ≤ (maximal_ideal S).comap f,
(maximal_ideal S).comap f = maximal_ideal R] :=
begin
tfae_have : 1 → 2, rintros _ _ ⟨a,ha,rfl⟩,
resetI, exact map_nonunit f a ha,
tfae_have : 2 → 4, exact set.image_subset_iff.1,
tfae_have : 3 ↔ 4, exact ideal.map_le_iff_le_comap,
tfae_have : 4 → 1, intro h, fsplit, exact λ x, not_imp_not.1 (@h x),
tfae_have : 1 → 5, intro, resetI, ext,
exact not_iff_not.2 (is_unit_map_iff f x),
tfae_have : 5 → 4, exact λ h, le_of_eq h.symm,
tfae_finish,
end
end
section
variables (R) [comm_ring R] [local_ring R] [comm_ring S] [local_ring S]
/-- The residue field of a local ring is the quotient of the ring by its maximal ideal. -/
def residue_field := R ⧸ maximal_ideal R
noncomputable instance residue_field.field : field (residue_field R) :=
ideal.quotient.field (maximal_ideal R)
noncomputable instance : inhabited (residue_field R) := ⟨37⟩
/-- The quotient map from a local ring to its residue field. -/
def residue : R →+* (residue_field R) :=
ideal.quotient.mk _
noncomputable
instance residue_field.algebra : algebra R (residue_field R) := (residue R).to_algebra
variables {R}
namespace residue_field
/-- The map on residue fields induced by a local homomorphism between local rings -/
noncomputable def map (f : R →+* S) [is_local_ring_hom f] :
residue_field R →+* residue_field S :=
ideal.quotient.lift (maximal_ideal R) ((ideal.quotient.mk _).comp f) $
λ a ha,
begin
erw ideal.quotient.eq_zero_iff_mem,
exact map_nonunit f a ha
end
end residue_field
lemma ker_eq_maximal_ideal [field K] (φ : R →+* K) (hφ : function.surjective φ) :
φ.ker = maximal_ideal R :=
local_ring.eq_maximal_ideal $ φ.ker_is_maximal_of_surjective hφ
end
end local_ring
namespace field
variables (K) [field K]
open_locale classical
@[priority 100] -- see Note [lower instance priority]
instance : local_ring K :=
local_ring.of_is_unit_or_is_unit_one_sub_self $ λ a,
if h : a = 0
then or.inr (by rw [h, sub_zero]; exact is_unit_one)
else or.inl $ is_unit.mk0 a h
end field