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

Commit f95e809

Browse files
committed
chore(algebra): displace zero_ne_one_class with nonzero and make no_zero_divisors a Prop (#2847)
- `[nonzero_semiring α]` becomes `[semiring α] [nonzero α]` - `[nonzero_comm_semiring α]` becomes `[comm_semiring α] [nonzero α]` - `[nonzero_comm_ring α]` becomes `[comm_ring α] [nonzero α]` - `no_zero_divisors` is now a `Prop` - `units.ne_zero` (originally for `domain`) merges into `units.coe_ne_zero` (originally for `nonzero_comm_semiring`)
1 parent b2f643e commit f95e809

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+192
-252
lines changed

src/algebra/associated.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ variables {α : Type*} {β : Type*} {γ : Type*} {δ : Type*}
1818
refine ⟨⟨0, 0, _, _⟩, rfl⟩; apply subsingleton.elim
1919
end
2020

21-
@[simp] theorem not_is_unit_zero [nonzero_semiring α] : ¬ is_unit (0 : α) :=
21+
@[simp] theorem not_is_unit_zero [semiring α] [nonzero α] : ¬ is_unit (0 : α) :=
2222
mt is_unit_zero_iff.1 zero_ne_one
2323

2424
lemma is_unit_pow [monoid α] {a : α} (n : ℕ) : is_unit a → is_unit (a ^ n) :=

src/algebra/char_p.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,10 @@ calc r = 1 * r : by rw one_mul
258258

259259
end prio
260260

261-
lemma false_of_nonzero_of_char_one [nonzero_comm_ring R] [char_p R 1] : false :=
261+
lemma false_of_nonzero_of_char_one [semiring R] [nonzero R] [char_p R 1] : false :=
262262
zero_ne_one $ show (0:R) = 1, from subsingleton.elim 0 1
263263

264-
lemma ring_char_ne_one [nonzero_semiring R] : ring_char R ≠ 1 :=
264+
lemma ring_char_ne_one [semiring R] [nonzero R] : ring_char R ≠ 1 :=
265265
by { intros h, apply @zero_ne_one R, symmetry, rw [←nat.cast_one, ring_char.spec, h], }
266266

267267
end char_one

src/algebra/classical_lie_algebras.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace lie_algebra
2828
open_locale matrix
2929

3030
variables (n : Type u₁) (R : Type u₂)
31-
variables [fintype n] [decidable_eq n] [nonzero_comm_ring R]
31+
variables [fintype n] [decidable_eq n] [comm_ring R]
3232

3333
local attribute [instance] matrix.lie_ring
3434
local attribute [instance] matrix.lie_algebra
@@ -77,7 +77,7 @@ def Eb (h : j ≠ i) : sl n R :=
7777

7878
end elementary_basis
7979

80-
lemma sl_non_abelian (h : 1 < fintype.card n) : ¬lie_algebra.is_abelian ↥(sl n R) :=
80+
lemma sl_non_abelian [nonzero R] (h : 1 < fintype.card n) : ¬lie_algebra.is_abelian ↥(sl n R) :=
8181
begin
8282
rcases fintype.exists_pair_of_one_lt_card h with ⟨i, j, hij⟩,
8383
let A := Eb R i j hij,

src/algebra/direct_limit.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -497,15 +497,14 @@ variables [directed_system G f]
497497

498498
namespace direct_limit
499499

500-
instance nonzero_comm_ring : nonzero_comm_ring (ring.direct_limit G f) :=
500+
instance nonzero : nonzero (ring.direct_limit G f) :=
501501
{ zero_ne_one := nonempty.elim (by apply_instance) $ assume i : ι, begin
502502
change (0 : ring.direct_limit G f) ≠ 1,
503503
rw ← ring.direct_limit.of_one,
504504
intros H, rcases ring.direct_limit.of.zero_exact H.symm with ⟨j, hij, hf⟩,
505505
rw is_ring_hom.map_one (f i j hij) at hf,
506506
exact one_ne_zero hf
507-
end,
508-
.. ring.direct_limit.comm_ring G f }
507+
end }
509508

510509
theorem exists_inv {p : ring.direct_limit G f} : p ≠ 0 → ∃ y, p * y = 1 :=
511510
ring.direct_limit.induction_on p $ λ i x H,
@@ -529,7 +528,8 @@ protected noncomputable def field : field (ring.direct_limit G f) :=
529528
{ inv := inv G f,
530529
mul_inv_cancel := λ p, direct_limit.mul_inv_cancel G f,
531530
inv_zero := dif_pos rfl,
532-
.. direct_limit.nonzero_comm_ring G f }
531+
.. ring.direct_limit.comm_ring G f,
532+
.. direct_limit.nonzero G f }
533533

534534
end
535535

src/algebra/euclidean_domain.lean

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ universe u
1212

1313
section prio
1414
set_option default_priority 100 -- see Note [default priority]
15-
15+
set_option old_structure_cmd true
1616
@[protect_proj without mul_left_not_lt r_well_founded]
17-
class euclidean_domain (α : Type u) extends nonzero_comm_ring α :=
17+
class euclidean_domain (α : Type u) extends comm_ring α :=
1818
(quotient : α → α → α)
1919
(quotient_zero : ∀ a, quotient a 0 = 0)
2020
(remainder : α → α → α)
@@ -32,6 +32,7 @@ class euclidean_domain (α : Type u) extends nonzero_comm_ring α :=
3232
function from weak to strong. I've currently divided the lemmas into
3333
strong and weak depending on whether they require `val_le_mul_left` or not. -/
3434
(mul_left_not_lt : ∀ a {b}, b ≠ 0 → ¬r (a * b) a)
35+
(zero_ne_one : (0 : α) ≠ 1)
3536
end prio
3637

3738
namespace euclidean_domain
@@ -40,6 +41,9 @@ variables [euclidean_domain α]
4041

4142
local infix ` ≺ `:50 := euclidean_domain.r
4243

44+
@[priority 70] -- see Note [lower instance priority]
45+
instance : nonzero α := ⟨euclidean_domain.zero_ne_one⟩
46+
4347
@[priority 70] -- see Note [lower instance priority]
4448
instance : has_div α := ⟨euclidean_domain.quotient⟩
4549

@@ -328,8 +332,6 @@ end lcm
328332

329333
end euclidean_domain
330334

331-
open euclidean_domain
332-
333335
instance int.euclidean_domain : euclidean_domain ℤ :=
334336
{ quotient := (/),
335337
quotient_zero := int.div_zero,
@@ -342,7 +344,9 @@ instance int.euclidean_domain : euclidean_domain ℤ :=
342344
exact int.mod_lt _ b0,
343345
mul_left_not_lt := λ a b b0, not_lt_of_ge $
344346
by rw [← mul_one a.nat_abs, int.nat_abs_mul];
345-
exact mul_le_mul_of_nonneg_left (int.nat_abs_pos_of_ne_zero b0) (nat.zero_le _) }
347+
exact mul_le_mul_of_nonneg_left (int.nat_abs_pos_of_ne_zero b0) (nat.zero_le _),
348+
.. int.comm_ring,
349+
.. int.nonzero }
346350

347351
@[priority 100] -- see Note [lower instance priority]
348352
instance field.to_euclidean_domain {K : Type u} [field K] : euclidean_domain K :=
@@ -355,4 +359,5 @@ instance field.to_euclidean_domain {K : Type u} [field K] : euclidean_domain K :
355359
r_well_founded := well_founded.intro $ λ a, acc.intro _ $ λ b ⟨hb, hna⟩,
356360
acc.intro _ $ λ c ⟨hc, hnb⟩, false.elim $ hnb hb,
357361
remainder_lt := λ a b hnb, by simp [hnb],
358-
mul_left_not_lt := λ a b hnb ⟨hab, hna⟩, or.cases_on (mul_eq_zero.1 hab) hna hnb }
362+
mul_left_not_lt := λ a b hnb ⟨hab, hna⟩, or.cases_on (mul_eq_zero.1 hab) hna hnb,
363+
.. ‹field K› }

src/algebra/field.lean

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,19 @@ set_option old_structure_cmd true
1313
universe u
1414
variables {α : Type u}
1515

16-
@[protect_proj, ancestor ring has_inv zero_ne_one_class]
17-
class division_ring (α : Type u) extends ring α, has_inv α, zero_ne_one_class α :=
16+
@[protect_proj, ancestor ring has_inv]
17+
class division_ring (α : Type u) extends ring α, has_inv α :=
1818
(mul_inv_cancel : ∀ {a : α}, a ≠ 0 → a * a⁻¹ = 1)
1919
(inv_mul_cancel : ∀ {a : α}, a ≠ 0 → a⁻¹ * a = 1)
2020
(inv_zero : (0 : α)⁻¹ = 0)
21+
(zero_ne_one : (0 : α) ≠ 1)
2122

2223
section division_ring
2324
variables [division_ring α] {a b : α}
2425

26+
instance division_ring.to_nonzero : nonzero α :=
27+
⟨division_ring.zero_ne_one⟩
28+
2529
protected definition algebra.div (a b : α) : α :=
2630
a * b⁻¹
2731

@@ -284,9 +288,10 @@ instance division_ring.to_domain : domain α :=
284288
end division_ring
285289

286290
@[protect_proj, ancestor division_ring comm_ring]
287-
class field (α : Type u) extends comm_ring α, has_inv α, zero_ne_one_class α :=
291+
class field (α : Type u) extends comm_ring α, has_inv α :=
288292
(mul_inv_cancel : ∀ {a : α}, a ≠ 0 → a * a⁻¹ = 1)
289293
(inv_zero : (0 : α)⁻¹ = 0)
294+
(zero_ne_one : (0 : α) ≠ 1)
290295

291296
section field
292297

src/algebra/gcd_domain.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ lemma normalize_eq_one {x : α} : normalize x = 1 ↔ is_unit x :=
6868

6969
theorem norm_unit_mul_norm_unit (a : α) : norm_unit (a * norm_unit a) = 1 :=
7070
classical.by_cases (assume : a = 0, by simp only [this, norm_unit_zero, zero_mul]) $
71-
assume h, by rw [norm_unit_mul h (units.ne_zero _), norm_unit_coe_units, mul_inv_eq_one]
71+
assume h, by rw [norm_unit_mul h (units.coe_ne_zero _), norm_unit_coe_units, mul_inv_eq_one]
7272

7373
theorem normalize_idem (x : α) : normalize (normalize x) = normalize x :=
7474
by rw [normalize, normalize, norm_unit_mul_norm_unit, units.coe_one, mul_one]
@@ -79,7 +79,7 @@ begin
7979
rcases associated_of_dvd_dvd hab hba with ⟨u, rfl⟩,
8080
refine classical.by_cases (by rintro rfl; simp only [zero_mul]) (assume ha : a ≠ 0, _),
8181
suffices : a * ↑(norm_unit a) = a * ↑u * ↑(norm_unit a) * ↑u⁻¹,
82-
by simpa only [normalize, mul_assoc, norm_unit_mul ha u.ne_zero, norm_unit_coe_units],
82+
by simpa only [normalize, mul_assoc, norm_unit_mul ha u.coe_ne_zero, norm_unit_coe_units],
8383
calc a * ↑(norm_unit a) = a * ↑(norm_unit a) * ↑u * ↑u⁻¹:
8484
(units.mul_inv_cancel_right _ _).symm
8585
... = a * ↑u * ↑(norm_unit a) * ↑u⁻¹ : by rw mul_right_comm a
@@ -282,7 +282,7 @@ iff.intro
282282
(assume h : lcm a b = 0,
283283
have normalize (a * b) = 0,
284284
by rw [← gcd_mul_lcm _ _, h, mul_zero],
285-
by simpa only [normalize_eq_zero, mul_eq_zero, units.ne_zero, or_false])
285+
by simpa only [normalize_eq_zero, mul_eq_zero, units.coe_ne_zero, or_false])
286286
(by rintro (rfl | rfl); [apply lcm_zero_left, apply lcm_zero_right])
287287

288288
@[simp] lemma normalize_lcm (a b : α) : normalize (lcm a b) = lcm a b :=

src/algebra/group/with_one.lean

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,8 @@ namespace with_zero
117117
instance [one : has_one α] : has_one (with_zero α) :=
118118
{ ..one }
119119

120-
instance [has_one α] : zero_ne_one_class (with_zero α) :=
121-
{ zero_ne_one := λ h, option.no_confusion h,
122-
..with_zero.has_zero,
123-
..with_zero.has_one }
120+
instance [has_one α] : nonzero (with_zero α) :=
121+
{ zero_ne_one := λ h, option.no_confusion h }
124122

125123
lemma coe_one [has_one α] : ((1 : α) : with_zero α) = 1 := rfl
126124

@@ -159,7 +157,8 @@ instance [monoid α] : monoid (with_zero α) :=
159157
| none := rfl
160158
| some a := congr_arg some $ mul_one _
161159
end,
162-
..with_zero.zero_ne_one_class,
160+
..with_zero.has_one,
161+
..with_zero.nonzero,
163162
..with_zero.semigroup }
164163

165164
instance [comm_monoid α] : comm_monoid (with_zero α) :=

src/algebra/group_with_zero.lean

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,13 @@ The type is required to come with an “inverse” function, and the inverse of
5050
5151
Examples include division rings and the ordered monoids that are the
5252
target of valuations in general valuation theory.-/
53-
class group_with_zero (G₀ : Type*)
54-
extends monoid_with_zero G₀, has_inv G₀, zero_ne_one_class G₀ :=
53+
class group_with_zero (G₀ : Type*) extends monoid_with_zero G₀, has_inv G₀ :=
5554
(inv_zero : (0 : G₀)⁻¹ = 0)
5655
(mul_inv_cancel : ∀ a:G₀, a ≠ 0 → a * a⁻¹ = 1)
56+
(zero_ne_one : (0 : G₀) ≠ 1)
57+
58+
instance group_with_zero.to_nonzero (G₀ : Type*) [group_with_zero G₀] : nonzero G₀ :=
59+
⟨group_with_zero.zero_ne_one⟩
5760

5861
/-- A type `G₀` is a commutative “group with zero”
5962
if it is a commutative monoid with zero element (distinct from `1`)

src/algebra/opposites.lean

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,20 +109,19 @@ instance [ring α] : ring (opposite α) :=
109109
instance [comm_ring α] : comm_ring (opposite α) :=
110110
{ .. opposite.ring α, .. opposite.comm_semigroup α }
111111

112-
instance [zero_ne_one_class α] : zero_ne_one_class (opposite α) :=
113-
{ zero_ne_one := λ h, zero_ne_one $ op_inj h,
114-
.. opposite.has_zero α, .. opposite.has_one α }
112+
instance [has_zero α] [has_one α] [nonzero α] : nonzero (opposite α) :=
113+
{ zero_ne_one := λ h : op (0 : α) = op 1, zero_ne_one (op_inj h) }
115114

116115
instance [integral_domain α] : integral_domain (opposite α) :=
117116
{ eq_zero_or_eq_zero_of_mul_eq_zero := λ x y (H : op (_ * _) = op (0:α)),
118117
or.cases_on (eq_zero_or_eq_zero_of_mul_eq_zero $ op_inj H)
119118
(λ hy, or.inr $ unop_inj $ hy) (λ hx, or.inl $ unop_inj $ hx),
120-
.. opposite.comm_ring α, .. opposite.zero_ne_one_class α }
119+
.. opposite.comm_ring α, .. opposite.nonzero α }
121120

122121
instance [field α] : field (opposite α) :=
123122
{ mul_inv_cancel := λ x hx, unop_inj $ inv_mul_cancel $ λ hx', hx $ unop_inj hx',
124123
inv_zero := unop_inj inv_zero,
125-
.. opposite.comm_ring α, .. opposite.zero_ne_one_class α, .. opposite.has_inv α }
124+
.. opposite.comm_ring α, .. opposite.nonzero α, .. opposite.has_inv α }
126125

127126
@[simp] lemma op_zero [has_zero α] : op (0 : α) = 0 := rfl
128127
@[simp] lemma unop_zero [has_zero α] : unop (0 : αᵒᵖ) = 0 := rfl

0 commit comments

Comments
 (0)