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

Commit c852939

Browse files
kckennylaujohoelzl
authored andcommitted
feat(ring_theory): move localization
1 parent 0b81b24 commit c852939

File tree

8 files changed

+379
-94
lines changed

8 files changed

+379
-94
lines changed

algebra/group.lean

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,18 @@ section monoid
229229

230230
@[simp] theorem divp_right_inj (u : units α) {a b : α} : a /ₚ u = b /ₚ u ↔ a = b :=
231231
units.mul_right_inj _
232-
232+
233233
theorem divp_eq_one (a : α) (u : units α) : a /ₚ u = 1 ↔ a = u :=
234234
(units.mul_right_inj u).symm.trans $ by simp
235235

236236
@[simp] theorem one_divp (u : units α) : 1 /ₚ u = ↑u⁻¹ :=
237237
by simp [divp]
238+
239+
variable α
240+
241+
class is_submonoid (S : set α) : Prop :=
242+
(one_mem : (1:α) ∈ S)
243+
(mul_mem : ∀ {s t}, s ∈ S → t ∈ S → s*t ∈ S)
238244

239245
end monoid
240246

algebra/group_power.lean

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ by rw [←pow_add, ←pow_add, add_comm]
104104
| (n+1) := by simp [smul_succ, list.sum_repeat n]
105105
attribute [to_additive list.sum_repeat] list.prod_repeat
106106

107+
def powers (x : α) : set α := {y | ∃ n, x^n = y}
108+
109+
instance powers.is_submonoid (x : α) : is_submonoid α (powers x) :=
110+
{ one_mem := ⟨0, by simp⟩,
111+
mul_mem := λ x₁ x₂ ⟨n₁, hn₁⟩ ⟨n₂, hn₂⟩, ⟨n₁ + n₂, by simp [pow_add, *]⟩ }
112+
107113
end monoid
108114

109115
theorem nat.pow_eq_pow (p q : ℕ) : nat.pow p q = p ^ q :=

algebra/localization.lean

Lines changed: 0 additions & 91 deletions
This file was deleted.

algebra/module.lean

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,21 @@ end
228228

229229
end is_submodule
230230

231+
section comm_ring
232+
233+
theorem is_submodule.eq_univ_of_contains_unit {α : Type u} [comm_ring α] (S : set α) [is_submodule S]
234+
(x y : α) (hx : x ∈ S) (h : y * x = 1) : S = set.univ :=
235+
set.ext $ λ z, ⟨λ hz, trivial, λ hz, calc
236+
z = z * (y * x) : by simp [h]
237+
... = (z * y) * x : eq.symm $ mul_assoc z y x
238+
... ∈ S : is_submodule.smul (z * y) hx⟩
239+
240+
theorem is_submodule.univ_of_one_mem {α : Type u} [comm_ring α] (S : set α) [is_submodule S] :
241+
(1:α) ∈ S → S = set.univ :=
242+
λ h, set.ext $ λ z, ⟨λ hz, trivial, λ hz, by simpa using (is_submodule.smul z h : z * 1 ∈ S)⟩
243+
244+
end comm_ring
245+
231246
/-- A vector space is the same as a module, except the scalar ring is actually
232247
a field. (This adds commutativity of the multiplication and existence of inverses.)
233248
This is the traditional generalization of spaces like `ℝ^n`, which have a natural

algebra/ring.lean

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ Copyright (c) 2014 Jeremy Avigad. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Jeremy Avigad, Leonardo de Moura, Floris van Doorn
55
-/
6-
import algebra.group tactic
6+
import algebra.group tactic data.set.basic
77

8-
universe u
8+
universes u v
99
variable {α : Type u}
1010

1111
section
@@ -57,6 +57,31 @@ section comm_ring
5757
⟨dvd_of_neg_dvd, neg_dvd_of_dvd⟩
5858
end comm_ring
5959

60+
def nonunits (α : Type u) [comm_ring α] : set α := { x | ¬∃ y, y * x = 1 }
61+
62+
class is_ring_hom {α : Type u} {β : Type v} [comm_ring α] [comm_ring β] (f : α → β) : Prop :=
63+
(map_add : ∀ {x y}, f (x + y) = f x + f y)
64+
(map_mul : ∀ {x y}, f (x * y) = f x * f y)
65+
(map_one : f 1 = 1)
66+
67+
namespace is_ring_hom
68+
69+
variables {β : Type v} [comm_ring α] [comm_ring β]
70+
variables (f : α → β) [is_ring_hom f] {x y : α}
71+
72+
lemma map_zero : f 0 = 0 :=
73+
calc f 0 = f (0 + 0) - f 0 : by rw [map_add f]; simp
74+
... = 0 : by simp
75+
76+
lemma map_neg : f (-x) = -f x :=
77+
calc f (-x) = f (-x + x) - f x : by rw [map_add f]; simp
78+
... = -f x : by simp [map_zero f]
79+
80+
lemma map_sub : f (x - y) = f x - f y :=
81+
by simp [map_add f, map_neg f]
82+
83+
end is_ring_hom
84+
6085
set_option old_structure_cmd true
6186
/-- A domain is a ring with no zero divisors, i.e. satisfying
6287
the condition `a * b = 0 ↔ a = 0 ∨ b = 0`. Alternatively, a domain

data/quot.lean

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ theorem forall_quotient_iff {α : Type*} [r : setoid α] {p : quotient r → Pro
1414
(∀a:quotient r, p a) ↔ (∀a:α, p ⟦a⟧) :=
1515
⟨assume h x, h _, assume h a, a.induction_on h⟩
1616

17+
@[simp] lemma quotient.lift_beta [s : setoid α] (f : α → β) (h : ∀ (a b : α), a ≈ b → f a = f b) (x : α):
18+
quotient.lift f h (quotient.mk x) = f x := rfl
19+
20+
@[simp] lemma quotient.lift_on_beta [s : setoid α] (f : α → β) (h : ∀ (a b : α), a ≈ b → f a = f b) (x : α):
21+
quotient.lift_on (quotient.mk x) f h = f x := rfl
22+
1723
/-- Choose an element of the equivalence class using the axiom of choice.
1824
Sound but noncomputable. -/
1925
noncomputable def quot.out {r : α → α → Prop} (q : quot r) : α :=

ring_theory/ideals.lean

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import algebra.ring algebra.module data.set.basic
2+
3+
universe u
4+
5+
class is_ideal {α : Type u} [comm_ring α] (S : set α) extends is_submodule S : Prop
6+
7+
class is_proper_ideal {α : Type u} [comm_ring α] (S : set α) extends is_ideal S : Prop :=
8+
(ne_univ : S ≠ set.univ)
9+
10+
class is_prime_ideal {α : Type u} [comm_ring α] (S : set α) extends is_proper_ideal S : Prop :=
11+
(mem_or_mem_of_mul_mem : ∀ {x y : α}, x * y ∈ S → x ∈ S ∨ y ∈ S)
12+
13+
theorem mem_or_mem_of_mul_eq_zero {α : Type u} [comm_ring α] (S : set α) [is_prime_ideal S] :
14+
∀ {x y : α}, x * y = 0 → x ∈ S ∨ y ∈ S :=
15+
λ x y hxy, have x * y ∈ S, by rw hxy; from (@is_submodule.zero α α _ _ S _ : (0:α) ∈ S),
16+
is_prime_ideal.mem_or_mem_of_mul_mem this
17+
18+
class is_maximal_ideal {α : Type u} [comm_ring α] (S : set α) extends is_proper_ideal S : Prop :=
19+
mk' ::
20+
(eq_or_univ_of_subset : ∀ (T : set α) [is_submodule T], S ⊆ T → T = S ∨ T = set.univ)
21+
22+
theorem is_maximal_ideal.mk {α : Type u} [comm_ring α] (S : set α) [is_submodule S] :
23+
(1:α) ∉ S → (∀ x (T : set α) [is_submodule T], S ⊆ T → x ∉ S → x ∈ T → (1:α) ∈ T) → is_maximal_ideal S :=
24+
λ h₁ h₂,
25+
{ ne_univ := λ hu, have (1:α) ∈ S, by rw hu; trivial, h₁ this,
26+
eq_or_univ_of_subset := λ T ht hst, or.cases_on (classical.em $ ∃ x, x ∉ S ∧ x ∈ T)
27+
(λ ⟨x, hxns, hxt⟩, or.inr $ @@is_submodule.univ_of_one_mem _ T ht $ @@h₂ x T ht hst hxns hxt)
28+
(λ hnts, or.inl $ set.ext $ λ x,
29+
⟨λ hxt, classical.by_contradiction $ λ hxns, hnts ⟨x, hxns, hxt⟩,
30+
λ hxs, hst hxs⟩) }
31+
32+
theorem not_unit_of_mem_maximal_ideal {α : Type u} [comm_ring α] (S : set α) [is_maximal_ideal S] : S ⊆ nonunits α :=
33+
λ x hx ⟨y, hxy⟩, is_proper_ideal.ne_univ S $ is_submodule.eq_univ_of_contains_unit S x y hx hxy
34+
35+
class local_ring (α : Type u) [comm_ring α] :=
36+
(S : set α)
37+
(max : is_maximal_ideal S)
38+
(unique : ∀ T [is_maximal_ideal T], S = T)
39+
40+
def local_of_nonunits_ideal {α : Type u} [comm_ring α] : (0:α) ≠ 1 → (∀ x y ∈ nonunits α, x + y ∈ nonunits α) → local_ring α :=
41+
λ hnze h, have hi : is_submodule (nonunits α), from
42+
{ zero_ := λ ⟨y, hy⟩, hnze $ by simpa using hy,
43+
add_ := h,
44+
smul := λ x y hy ⟨z, hz⟩, hy ⟨x * z, by rw [← hz]; simp [mul_left_comm, mul_assoc]⟩ },
45+
{ S := nonunits α,
46+
max := @@is_maximal_ideal.mk _ (nonunits α) hi (λ ho, ho ⟨1, mul_one 1⟩) $
47+
λ x T ht hst hxns hxt, have hxu : _, from classical.by_contradiction hxns,
48+
let ⟨y, hxy⟩ := hxu in by rw [← hxy]; exact @@is_submodule.smul _ _ ht y hxt,
49+
unique := λ T hmt, or.cases_on (@@is_maximal_ideal.eq_or_univ_of_subset _ hmt (nonunits α) hi $
50+
λ z hz, @@not_unit_of_mem_maximal_ideal _ T hmt hz) id $
51+
(λ htu, false.elim $ ((set.set_eq_def _ _).1 htu 1).2 trivial ⟨1, mul_one 1⟩) }

0 commit comments

Comments
 (0)