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

Commit 05449a0

Browse files
jcommelinChrisHughes24
authored andcommitted
refactor(ring_theory/localization): rename of to mk, and define of (#765)
* refactor(ring_theory/localization): rename of to mk, and define of * Make submonoid implicit variable of 'of'
1 parent eb033cf commit 05449a0

File tree

1 file changed

+61
-48
lines changed

1 file changed

+61
-48
lines changed

src/ring_theory/localization.lean

Lines changed: 61 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,23 @@ instance : has_mul (loc α S) :=
6868

6969
variables {α S}
7070

71-
def of (r : α) (s : S) : loc α S := ⟦(r, s)⟧
71+
def mk (r : α) (s : S) : loc α S := ⟦(r, s)⟧
72+
73+
def of (r : α) : loc α S := mk r 1
7274

7375
instance : comm_ring (loc α S) :=
7476
by refine
7577
{ add := has_add.add,
7678
add_assoc := λ m n k, quotient.induction_on₃ m n k _,
77-
zero := of 0 1,
79+
zero := of 0,
7880
zero_add := quotient.ind _,
7981
add_zero := quotient.ind _,
8082
neg := has_neg.neg,
8183
add_left_neg := quotient.ind _,
8284
add_comm := quotient.ind₂ _,
8385
mul := has_mul.mul,
8486
mul_assoc := λ m n k, quotient.induction_on₃ m n k _,
85-
one := of 1 1,
87+
one := of 1,
8688
one_mul := quotient.ind _,
8789
mul_one := quotient.ind _,
8890
left_distrib := λ m n k, quotient.induction_on₃ m n k _,
@@ -95,33 +97,36 @@ by refine
9597
refine (quotient.sound $ r_of_eq _),
9698
simp [mul_left_comm, mul_add, mul_comm] }
9799

98-
instance of.is_ring_hom : is_ring_hom (λ x, of x 1 : α → loc α S) :=
100+
instance of.is_ring_hom : is_ring_hom (of : α → loc α S) :=
99101
{ map_add := λ x y, quotient.sound $ by simp,
100102
map_mul := λ x y, quotient.sound $ by simp,
101103
map_one := rfl }
102104

103-
instance : has_coe α (loc α S) := ⟨λ x, of x 1
105+
variables {S}
106+
107+
instance : has_coe α (loc α S) := ⟨of⟩
104108

105109
instance coe.is_ring_hom : is_ring_hom (coe : α → loc α S) :=
106110
localization.of.is_ring_hom
107111

108112
section
109113
variables (α S) (x y : α) (n : ℕ)
110-
@[simp] lemma of_one : (of 1 1 : loc α S) = 1 := rfl
111-
@[simp] lemma of_add : (of (x + y) 1 : loc α S) = of x 1 + of y 1 :=
112-
by apply of.is_ring_hom.map_add
114+
@[simp] lemma of_zero : (of 0 : loc α S) = 0 := rfl
115+
@[simp] lemma of_one : (of 1 : loc α S) = 1 := rfl
116+
@[simp] lemma of_add : (of (x + y) : loc α S) = of x + of y :=
117+
by apply is_ring_hom.map_add
113118

114-
@[simp] lemma of_sub : (of (x - y) 1 : loc α S) = of x 1 - of y 1 :=
115-
@@is_ring_hom.map_sub _ _ (λ x, of x 1) of.is_ring_hom
119+
@[simp] lemma of_sub : (of (x - y) : loc α S) = of x - of y :=
120+
by apply is_ring_hom.map_sub
116121

117-
@[simp] lemma of_mul : (of (x * y) 1 : loc α S) = of x 1 * of y 1 :=
118-
@@is_ring_hom.map_mul _ _ (λ x, of x 1) of.is_ring_hom
122+
@[simp] lemma of_mul : (of (x * y) : loc α S) = of x * of y :=
123+
by apply is_ring_hom.map_mul
119124

120-
@[simp] lemma of_neg : (of (-x) 1 : loc α S) = -of x 1 :=
121-
@@is_ring_hom.map_neg _ _ (λ x, of x 1) of.is_ring_hom
125+
@[simp] lemma of_neg : (of (-x) : loc α S) = -of x :=
126+
by apply is_ring_hom.map_neg
122127

123-
@[simp] lemma of_pow : (of (x ^ n) 1 : loc α S) = (of x 1) ^ n :=
124-
@@is_semiring_hom.map_pow _ _ (λ x, of x 1) (@@is_ring_hom.is_semiring_hom _ _ _ of.is_ring_hom) x n
128+
@[simp] lemma of_pow : (of (x ^ n) : loc α S) = (of x) ^ n :=
129+
by apply is_semiring_hom.map_pow
125130

126131
@[simp] lemma coe_zero : ((0 : α) : loc α S) = 0 := rfl
127132
@[simp] lemma coe_one : ((1 : α) : loc α S) = 1 := rfl
@@ -132,45 +137,42 @@ by apply of.is_ring_hom.map_add
132137
@[simp] lemma coe_pow : (↑(x ^ n) : loc α S) = x ^ n := of_pow _ _ _ _
133138
end
134139

135-
@[simp] lemma of_zero (s : S) : of 0 s = 0 :=
136-
quotient.sound ⟨s, s.2, by simp only [mul_zero, sub_zero, zero_mul]⟩
137-
138-
@[simp] lemma of_self {x : α} {hx : x ∈ S} :
139-
(of x ⟨x, hx⟩ : loc α S) = 1 :=
140+
@[simp] lemma mk_self {x : α} {hx : x ∈ S} :
141+
(mk x ⟨x, hx⟩ : loc α S) = 1 :=
140142
quotient.sound ⟨1, is_submonoid.one_mem S,
141143
by simp only [subtype.coe_mk, is_submonoid.coe_one, mul_one, one_mul, sub_self]⟩
142144

143-
@[simp] lemma of_self' {s : S} :
144-
(of s s : loc α S) = 1 :=
145-
by cases s; exact of_self
145+
@[simp] lemma mk_self' {s : S} :
146+
(mk s s : loc α S) = 1 :=
147+
by cases s; exact mk_self
146148

147-
@[simp] lemma of_self'' {s : S} :
148-
(of s.1 s : loc α S) = 1 :=
149-
of_self'
149+
@[simp] lemma mk_self'' {s : S} :
150+
(mk s.1 s : loc α S) = 1 :=
151+
mk_self'
150152

151-
@[simp] lemma coe_mul_of (x y : α) (s : S) :
152-
↑x * of y s = of (x * y) s :=
153+
@[simp] lemma coe_mul_mk (x y : α) (s : S) :
154+
↑x * mk y s = mk (x * y) s :=
153155
quotient.sound $ r_of_eq $ by rw one_mul
154156

155-
lemma of_eq_mul_of_one (r : α) (s : S) :
156-
of r s = r * of 1 s :=
157-
by rw [coe_mul_of, mul_one]
157+
lemma mk_eq_mul_mk_one (r : α) (s : S) :
158+
mk r s = r * mk 1 s :=
159+
by rw [coe_mul_mk, mul_one]
158160

159-
@[simp] lemma of_mul_of (x y : α) (s t : S) :
160-
of x s * of y t = of (x * y) (s * t) := rfl
161+
@[simp] lemma mk_mul_mk (x y : α) (s t : S) :
162+
mk x s * mk y t = mk (x * y) (s * t) := rfl
161163

162-
@[simp] lemma of_mul_cancel_left (r : α) (s : S) :
163-
of (↑s * r) s = r :=
164-
by rw [of_eq_mul_of_one, mul_comm ↑s, coe_mul,
165-
mul_assoc, ← of_eq_mul_of_one, of_self', mul_one]
164+
@[simp] lemma mk_mul_cancel_left (r : α) (s : S) :
165+
mk (↑s * r) s = r :=
166+
by rw [mk_eq_mul_mk_one, mul_comm ↑s, coe_mul,
167+
mul_assoc, ← mk_eq_mul_mk_one, mk_self', mul_one]
166168

167-
@[simp] lemma of_mul_cancel_right (r : α) (s : S) :
168-
of (r * s) s = r :=
169-
by rw [mul_comm, of_mul_cancel_left]
169+
@[simp] lemma mk_mul_cancel_right (r : α) (s : S) :
170+
mk (r * s) s = r :=
171+
by rw [mul_comm, mk_mul_cancel_left]
170172

171173
@[elab_as_eliminator]
172174
protected theorem induction_on {C : loc α S → Prop} (x : loc α S)
173-
(ih : ∀ r s, C (of r s : loc α S)) : C x :=
175+
(ih : ∀ r s, C (mk r s : loc α S)) : C x :=
174176
by rcases x with ⟨r, s⟩; exact ih r s
175177

176178
@[elab_with_expected_type]
@@ -212,7 +214,7 @@ instance rec.is_ring_hom {β : Type v} [comm_ring β]
212214
@[reducible] def away (x : α) := loc α (powers x)
213215

214216
@[simp] def away.inv_self (x : α) : away x :=
215-
of 1 ⟨x, 1, pow_one x⟩
217+
mk 1 ⟨x, 1, pow_one x⟩
216218

217219
@[elab_with_expected_type]
218220
protected noncomputable def away.rec {x : α} {β : Type v} [comm_ring β]
@@ -223,7 +225,7 @@ by rw [units.coe_pow, ← classical.some_spec hfx, ← is_semiring_hom.map_pow f
223225
noncomputable def away_to_away_right (x y : α) : away x → away (x * y) :=
224226
localization.away.rec coe $
225227
is_unit_of_mul_one x (y * away.inv_self (x * y)) $
226-
by rw [away.inv_self, coe_mul_of, coe_mul_of, mul_one, of_self]
228+
by rw [away.inv_self, coe_mul_mk, coe_mul_mk, mul_one, mk_self]
227229

228230
instance away.rec.is_ring_hom {x : α} {β : Type v} [comm_ring β]
229231
(f : α → β) [hf : is_ring_hom f] (hfx : is_unit (f x)) :
@@ -348,9 +350,20 @@ by refine
348350
simp only [has_inv.inv, inv_aux, quotient.lift_beta, dif_neg this],
349351
exact (quotient.sound $ r_of_eq $ by simp [mul_comm]) }
350352

351-
@[simp] lemma of_eq_div {r s} : (of r s : fraction_ring β) = (r / s : fraction_ring β) :=
353+
@[simp] lemma mk_eq_div {r s} : (mk r s : fraction_ring β) = (r / s : fraction_ring β) :=
352354
show _ = _ * dite (s.1 = 0) _ _, by rw [dif_neg (ne_zero_of_mem_non_zero_divisors s.2)];
353-
exact localization.of_eq_mul_of_one _ _
355+
exact localization.mk_eq_mul_mk_one _ _
356+
357+
variables {β}
358+
359+
lemma eq_zero_of (x : β) (h : (of x : fraction_ring β) = 0) : x = 0 :=
360+
begin
361+
rcases quotient.exact h with ⟨t, ht, ht'⟩,
362+
simpa [ne_zero_of_mem_non_zero_divisors ht] using ht'
363+
end
364+
365+
lemma of.injective : function.injective (of : β → fraction_ring β) :=
366+
(is_add_group_hom.injective_iff _).mpr eq_zero_of
354367

355368
end fraction_ring
356369

@@ -360,9 +373,9 @@ theorem map_comap (J : ideal (loc α S)) :
360373
ideal.map coe (ideal.comap (coe : α → loc α S) J) = J :=
361374
le_antisymm (ideal.map_le_iff_le_comap.2 (le_refl _)) $ λ x,
362375
localization.induction_on x $ λ r s hJ, (submodule.mem_coe _).2 $
363-
mul_one r ▸ coe_mul_of r 1 s ▸ (ideal.mul_mem_right _ $ ideal.mem_map_of_mem $
376+
mul_one r ▸ coe_mul_mk r 1 s ▸ (ideal.mul_mem_right _ $ ideal.mem_map_of_mem $
364377
have _ := @ideal.mul_mem_left (loc α S) _ _ s _ hJ,
365-
by rwa [coe_coe, coe_mul_of, of_mul_cancel_left] at this)
378+
by rwa [coe_coe, coe_mul_mk, mk_mul_cancel_left] at this)
366379

367380
def le_order_embedding :
368381
((≤) : ideal (loc α S) → ideal (loc α S) → Prop) ≼o

0 commit comments

Comments
 (0)