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

Commit 8f04a92

Browse files
committed
refactor(algebra/*): small API fixes (#3157)
## Changes to `canonically_ordered_comm_semiring` * in the definition of `canonically_ordered_comm_semiring` replace `mul_eq_zero_iff` with `eq_zero_or_eq_zero_of_mul_eq_zero`; the other implication is always true because of `[semiring]`; * add instance `canonically_ordered_comm_semiring.to_no_zero_divisors`; ## Changes to `with_top` * use `to_additive` for `with_top.has_one`, `with_top.coe_one` etc; * move `with_top.coe_ne_zero` to `algebra.ordered_group`; * add `with_top.has_add`, make `coe_add`, `coe_bit*` require only `[has_add α]`; * use proper instances for lemmas about multiplication in `with_top`, not just `canonically_ordered_comm_semiring` for everything; ## Changes to `associates` * merge `associates.mk_zero_eq` and `associates.mk_eq_zero_iff_eq_zero` into `associates.mk_eq_zero`; * drop `associates.mul_zero`, `associates.zero_mul`, `associates.zero_ne_one`, and `associates.mul_eq_zero_iff` in favor of typeclass instances; ## Misc changes * drop `mul_eq_zero_iff_eq_zero_or_eq_zero` in favor of `mul_eq_zero`; * drop `ennreal.mul_eq_zero` in favor of `mul_eq_zero` from instance.
1 parent e1a72b5 commit 8f04a92

File tree

13 files changed

+120
-132
lines changed

13 files changed

+120
-132
lines changed

src/algebra/associated.lean

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -441,18 +441,14 @@ instance [has_zero α] [monoid α] : has_top (associates α) := ⟨0⟩
441441
section comm_semiring
442442
variables [comm_semiring α]
443443

444-
@[simp] theorem mk_zero_eq (a : α) : associates.mk a = 0 ↔ a = 0 :=
444+
@[simp] theorem mk_eq_zero {a : α} : associates.mk a = 0 ↔ a = 0 :=
445445
⟨assume h, (associated_zero_iff_eq_zero a).1 $ quotient.exact h, assume h, h.symm ▸ rfl⟩
446446

447-
@[simp] theorem mul_zero : ∀(a : associates α), a * 0 = 0 :=
448-
by rintros ⟨a⟩; show associates.mk (a * 0) = associates.mk 0; rw [mul_zero]
449-
450-
@[simp] protected theorem zero_mul : ∀(a : associates α), 0 * a = 0 :=
451-
by rintros ⟨a⟩; show associates.mk (0 * a) = associates.mk 0; rw [zero_mul]
452-
453-
theorem mk_eq_zero_iff_eq_zero {a : α} : associates.mk a = 0 ↔ a = 0 :=
454-
calc associates.mk a = 0 ↔ (a ~ᵤ 0) : mk_eq_mk_iff_associated
455-
... ↔ a = 0 : associated_zero_iff_eq_zero a
447+
instance : mul_zero_class (associates α) :=
448+
{ mul := (*),
449+
zero := 0,
450+
zero_mul := by { rintro ⟨a⟩, show associates.mk (0 * a) = associates.mk 0, rw [zero_mul] },
451+
mul_zero := by { rintro ⟨a⟩, show associates.mk (a * 0) = associates.mk 0, rw [mul_zero] } }
456452

457453
theorem dvd_of_mk_le_mk {a b : α} : associates.mk a ≤ associates.mk b → a ∣ b
458454
| ⟨c', hc'⟩ := (quotient.induction_on c' $ assume c hc,
@@ -499,7 +495,7 @@ begin
499495
apply forall_congr, assume a,
500496
exact forall_associated },
501497
apply and_congr,
502-
{ rw [(≠), mk_zero_eq] },
498+
{ rw [(≠), mk_eq_zero] },
503499
apply and_congr,
504500
{ rw [(≠), ← is_unit_iff_eq_one, is_unit_mk], },
505501
apply forall_congr, assume a,
@@ -532,24 +528,23 @@ instance : order_top (associates α) :=
532528
le_top := assume a, ⟨0, mul_zero a⟩,
533529
.. associates.partial_order }
534530

535-
theorem zero_ne_one : (0 : associates α)1 :=
536-
assume h,
537-
have (0 : α) ~ᵤ 1, from quotient.exact h,
538-
have (0 : α) = 1, from ((associated_zero_iff_eq_zero 1).1 this.symm).symm,
539-
zero_ne_one this
531+
instance : nonzero (associates α) :=
532+
assume h,
533+
have (0 : α) ~ᵤ 1, from quotient.exact h,
534+
have (0 : α) = 1, from ((associated_zero_iff_eq_zero 1).1 this.symm).symm,
535+
zero_ne_one this
540536

541-
theorem mul_eq_zero_iff {x y : associates α} : x * y = 0 ↔ x = 0 ∨ y = 0 :=
542-
iff.intro
537+
instance : no_zero_divisors (associates α) :=
538+
⟨λ x y,
543539
(quotient.induction_on₂ x y $ assume a b h,
544540
have a * b = 0, from (associated_zero_iff_eq_zero _).1 (quotient.exact h),
545-
have a = 0 ∨ b = 0, from mul_eq_zero_iff_eq_zero_or_eq_zero.1 this,
546-
this.imp (assume h, h.symm ▸ rfl) (assume h, h.symm ▸ rfl))
547-
(by simp [or_imp_distrib] {contextual := tt})
541+
have a = 0 ∨ b = 0, from mul_eq_zero.1 this,
542+
this.imp (assume h, h.symm ▸ rfl) (assume h, h.symm ▸ rfl))⟩
548543

549544
theorem prod_eq_zero_iff {s : multiset (associates α)} :
550545
s.prod = 0 ↔ (0 : associates α) ∈ s :=
551546
multiset.induction_on s (by simp; exact zero_ne_one.symm) $
552-
assume a s, by simp [mul_eq_zero_iff, @eq_comm _ 0 a] {contextual := tt}
547+
assume a s, by simp [mul_eq_zero, @eq_comm _ 0 a] {contextual := tt}
553548

554549
theorem irreducible_mk_iff (a : α) : irreducible (associates.mk a) ↔ irreducible a :=
555550
begin
@@ -573,7 +568,7 @@ begin
573568
rintros ⟨a⟩ ⟨b⟩ ⟨c⟩ ha h,
574569
rcases quotient.exact' h with ⟨u, hu⟩,
575570
have hu : a * (b * ↑u) = a * c, { rwa [← mul_assoc] },
576-
exact quotient.sound' ⟨u, eq_of_mul_eq_mul_left (mt (mk_zero_eq a).2 ha) hu⟩
571+
exact quotient.sound' ⟨u, eq_of_mul_eq_mul_left (mt mk_eq_zero.2 ha) hu⟩
577572
end
578573

579574
lemma le_of_mul_le_mul_left (a b c : associates α) (ha : a ≠ 0) :

src/algebra/big_operators.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,7 @@ begin
10981098
apply finset.induction_on s,
10991099
exact ⟨not.elim one_ne_zero, λ ⟨_, H, _⟩, H.elim⟩,
11001100
assume a s ha ih,
1101-
rw [prod_insert ha, mul_eq_zero_iff_eq_zero_or_eq_zero, bex_def, exists_mem_insert, ih, ← bex_def]
1101+
rw [prod_insert ha, mul_eq_zero, bex_def, exists_mem_insert, ih, ← bex_def]
11021102
end
11031103

11041104
theorem prod_ne_zero_iff : (∏ x in s, f x) ≠ 0 ↔ (∀ a ∈ s, f a ≠ 0) :=

src/algebra/ordered_group.lean

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -286,35 +286,40 @@ end with_zero
286286

287287
namespace with_top
288288

289-
instance [has_zero α] : has_zero (with_top α) := ⟨(0 : α)⟩
289+
section has_one
290290

291-
@[simp, norm_cast] lemma coe_zero {α : Type*}
292-
[has_zero α] : ((0 : α) : with_top α) = 0 := rfl
291+
variables [has_one α]
293292

294-
@[simp, norm_cast] lemma coe_eq_zero {α : Type*}
295-
[has_zero α] {a : α} : (a : with_top α) = 0 ↔ a = 0 :=
296-
by norm_cast
293+
@[to_additive] instance : has_one (with_top α) := ⟨(1 : α)⟩
297294

298-
instance [has_one α] : has_one (with_top α) := ⟨(1 : α)⟩
295+
@[simp, to_additive] lemma coe_one : ((1 : α) : with_top α) = 1 := rfl
299296

300-
@[simp, norm_cast] lemma coe_one : Type*}
301-
[has_one α] : ((1 : α) : with_top α) = 1 := rfl
297+
@[simp, to_additive] lemma coe_eq_one {a : α} : (a : with_top α) = 1 ↔ a = 1 :=
298+
coe_eq_coe
302299

303-
@[simp, norm_cast] lemma coe_eq_one {α : Type*}
304-
[has_one α] {a : α} : (a : with_top α) = 1 ↔ a = 1 :=
305-
by norm_cast
300+
@[simp, to_additive] theorem one_eq_coe {a : α} : 1 = (a : with_top α) ↔ a = 1 :=
301+
by rw [eq_comm, coe_eq_one]
302+
303+
attribute [norm_cast] coe_one coe_eq_one coe_zero coe_eq_zero one_eq_coe zero_eq_coe
304+
305+
@[simp, to_additive] theorem top_ne_one : ⊤ ≠ (1 : with_top α) .
306+
@[simp, to_additive] theorem one_ne_top : (1 : with_top α) ≠ ⊤ .
307+
308+
end has_one
309+
310+
instance [has_add α] : has_add (with_top α) :=
311+
⟨λ o₁ o₂, o₁.bind (λ a, o₂.map (λ b, a + b))⟩
306312

307313
instance [add_semigroup α] : add_semigroup (with_top α) :=
308-
{ add := λ o₁ o₂, o₁.bind (λ a, o₂.map (λ b, a + b)),
314+
{ add := (+),
309315
..@additive.add_semigroup _ $ @with_zero.semigroup (multiplicative α) _ }
310316

311-
@[norm_cast] lemma coe_add [add_semigroup α] {a b : α} : ((a + b : α) : with_top α) = a + b := rfl
317+
@[norm_cast] lemma coe_add [has_add α] {a b : α} : ((a + b : α) : with_top α) = a + b := rfl
312318

313-
@[norm_cast] lemma coe_bit0 [add_semigroup α] {a : α} : ((bit0 a : α) : with_top α) = bit0 a :=
314-
by unfold bit0; norm_cast
319+
@[norm_cast] lemma coe_bit0 [has_add α] {a : α} : ((bit0 a : α) : with_top α) = bit0 a := rfl
315320

316-
@[norm_cast] lemma coe_bit1 [add_semigroup α] [has_one α] {a : α} : ((bit1 a : α) : with_top α) = bit1 a :=
317-
by unfold bit1; norm_cast
321+
@[norm_cast]
322+
lemma coe_bit1 [has_add α] [has_one α] {a : α} : ((bit1 a : α) : with_top α) = bit1 a := rfl
318323

319324
instance [add_comm_semigroup α] : add_comm_semigroup (with_top α) :=
320325
{ ..@additive.add_comm_semigroup _ $

src/algebra/ordered_ring.lean

Lines changed: 49 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ in which `a ≤ b` iff there exists `c` with `b = a + c`. This is satisfied by t
928928
natural numbers, for example, but not the integers or other ordered groups. -/
929929
class canonically_ordered_comm_semiring (α : Type*) extends
930930
canonically_ordered_add_monoid α, comm_semiring α :=
931-
(mul_eq_zero_iff (a b : α) : a * b = 0 a = 0 ∨ b = 0)
931+
(eq_zero_or_eq_zero_of_mul_eq_zero : ∀ a b : α, a * b = 0 a = 0 ∨ b = 0)
932932
(zero_ne_one : (0 : α) ≠ 1)
933933

934934
namespace canonically_ordered_semiring
@@ -939,6 +939,10 @@ open canonically_ordered_add_monoid (le_iff_exists_add)
939939
instance canonically_ordered_comm_semiring.to_nonzero : nonzero α :=
940940
⟨canonically_ordered_comm_semiring.zero_ne_one⟩
941941

942+
instance canonically_ordered_comm_semiring.to_no_zero_divisors :
943+
no_zero_divisors α :=
944+
⟨canonically_ordered_comm_semiring.eq_zero_or_eq_zero_of_mul_eq_zero⟩
945+
942946
lemma mul_le_mul {a b c d : α} (hab : a ≤ b) (hcd : c ≤ d) :
943947
a * c ≤ b * d :=
944948
begin
@@ -952,22 +956,21 @@ end
952956
lemma zero_lt_one : (0:α) < 1 := lt_of_le_of_ne (zero_le 1) zero_ne_one
953957

954958
lemma mul_pos : 0 < a * b ↔ (0 < a) ∧ (0 < b) :=
955-
by simp only [zero_lt_iff_ne_zero, ne.def, canonically_ordered_comm_semiring.mul_eq_zero_iff,
956-
not_or_distrib]
959+
by simp only [zero_lt_iff_ne_zero, ne.def, mul_eq_zero, not_or_distrib]
957960

958961
end canonically_ordered_semiring
959962

960963
namespace with_top
961-
variables [canonically_ordered_comm_semiring α]
962964

963-
@[simp] theorem top_ne_zero : ⊤ ≠ (0 : with_top α) .
964-
@[simp] theorem zero_ne_top : (0 : with_top α) ≠ ⊤ .
965-
966-
@[simp] theorem zero_eq_coe {a : α} : 0 = (a : with_top α) ↔ a = 0 :=
967-
by rw [eq_comm, coe_eq_zero]
965+
instance [has_zero α] [has_one α] [nonzero α] : nonzero (with_top α) :=
966+
⟨mt coe_eq_coe.1 zero_ne_one⟩
968967

969968
variable [decidable_eq α]
970969

970+
section has_mul
971+
972+
variables [has_zero α] [has_mul α]
973+
971974
instance : mul_zero_class (with_top α) :=
972975
{ zero := 0,
973976
mul := λm n, if m = 0 ∨ n = 0 then 0 else m.bind (λa, n.bind $ λb, ↑(a * b)),
@@ -986,7 +989,13 @@ by cases a; simp [mul_def, h]; refl
986989
@[simp] lemma top_mul_top : (⊤ * ⊤ : with_top α) = ⊤ :=
987990
top_mul top_ne_zero
988991

989-
lemma coe_mul {a b : α} : (↑(a * b) : with_top α) = a * b :=
992+
end has_mul
993+
994+
section mul_zero_class
995+
996+
variables [mul_zero_class α]
997+
998+
@[norm_cast] lemma coe_mul {a b : α} : (↑(a * b) : with_top α) = a * b :=
990999
decidable.by_cases (assume : a = 0, by simp [this]) $ assume ha,
9911000
decidable.by_cases (assume : b = 0, by simp [this]) $ assume hb,
9921001
by simp [*, mul_def]; refl
@@ -996,22 +1005,38 @@ lemma mul_coe {b : α} (hb : b ≠ 0) : ∀{a : with_top α}, a * b = a.bind (λ
9961005
by simp [hb]
9971006
| (some a) := show ↑a * ↑b = ↑(a * b), from coe_mul.symm
9981007

1008+
@[simp] lemma mul_eq_top_iff {a b : with_top α} : a * b = ⊤ ↔ (a ≠ 0 ∧ b = ⊤) ∨ (a = ⊤ ∧ b ≠ 0) :=
1009+
begin
1010+
cases a; cases b; simp only [none_eq_top, some_eq_coe],
1011+
{ simp [← coe_mul] },
1012+
{ suffices : ⊤ * (b : with_top α) = ⊤ ↔ b ≠ 0, by simpa,
1013+
by_cases hb : b = 0; simp [hb] },
1014+
{ suffices : (a : with_top α) * ⊤ = ⊤ ↔ a ≠ 0, by simpa,
1015+
by_cases ha : a = 0; simp [ha] },
1016+
{ simp [← coe_mul] }
1017+
end
1018+
1019+
end mul_zero_class
1020+
1021+
section no_zero_divisors
1022+
1023+
variables [mul_zero_class α] [no_zero_divisors α]
1024+
1025+
instance : no_zero_divisors (with_top α) :=
1026+
⟨λ a b, by cases a; cases b; dsimp [mul_def]; split_ifs;
1027+
simp [*, none_eq_top, some_eq_coe, mul_eq_zero] at *⟩
1028+
1029+
end no_zero_divisors
1030+
1031+
variables [canonically_ordered_comm_semiring α]
1032+
9991033
private lemma comm (a b : with_top α) : a * b = b * a :=
10001034
begin
10011035
by_cases ha : a = 0, { simp [ha] },
10021036
by_cases hb : b = 0, { simp [hb] },
10031037
simp [ha, hb, mul_def, option.bind_comm a b, mul_comm]
10041038
end
10051039

1006-
@[simp] lemma mul_eq_top_iff {a b : with_top α} : a * b = ⊤ ↔ (a ≠ 0 ∧ b = ⊤) ∨ (a = ⊤ ∧ b ≠ 0) :=
1007-
begin
1008-
have H : ∀x:α, (¬x = 0) ↔ (⊤ : with_top α) * ↑x = ⊤ :=
1009-
λx, ⟨λhx, by simp [top_mul, hx], λhx f, by simpa [f] using hx⟩,
1010-
cases a; cases b; simp [none_eq_top, top_mul, coe_ne_top, some_eq_coe, coe_mul.symm],
1011-
{ rw [H b] },
1012-
{ rw [H a, comm] }
1013-
end
1014-
10151040
private lemma distrib' (a b c : with_top α) : (a + b) * c = a * c + b * c :=
10161041
begin
10171042
cases c,
@@ -1023,21 +1048,17 @@ begin
10231048
repeat { refl <|> exact congr_arg some (add_mul _ _ _) } }
10241049
end
10251050

1026-
private lemma mul_eq_zero (a b : with_top α) : a * b = 0 ↔ a = 0 ∨ b = 0 :=
1027-
by cases a; cases b; dsimp [mul_def]; split_ifs;
1028-
simp [*, none_eq_top, some_eq_coe, canonically_ordered_comm_semiring.mul_eq_zero_iff] at *
1029-
10301051
private lemma assoc (a b c : with_top α) : (a * b) * c = a * (b * c) :=
10311052
begin
10321053
cases a,
10331054
{ by_cases hb : b = 0; by_cases hc : c = 0;
1034-
simp [*, none_eq_top, mul_eq_zero b c] },
1055+
simp [*, none_eq_top] },
10351056
cases b,
10361057
{ by_cases ha : a = 0; by_cases hc : c = 0;
1037-
simp [*, none_eq_top, some_eq_coe, mul_eq_zero ↑a c] },
1058+
simp [*, none_eq_top, some_eq_coe] },
10381059
cases c,
10391060
{ by_cases ha : a = 0; by_cases hb : b = 0;
1040-
simp [*, none_eq_top, some_eq_coe, mul_eq_zero ↑a ↑b] },
1061+
simp [*, none_eq_top, some_eq_coe] },
10411062
simp [some_eq_coe, coe_mul.symm, mul_assoc]
10421063
end
10431064

@@ -1051,10 +1072,9 @@ instance : canonically_ordered_comm_semiring (with_top α) :=
10511072
left_distrib := assume a b c, by rw [comm, distrib', comm b, comm c]; refl,
10521073
mul_assoc := assoc,
10531074
mul_comm := comm,
1054-
mul_eq_zero_iff := mul_eq_zero,
10551075
one_mul := one_mul',
10561076
mul_one := assume a, by rw [comm, one_mul'],
1057-
zero_ne_one := assume h : ((0 : α) : with_top α) = 1, zero_ne_one $ option.some.inj h,
1058-
.. with_top.add_comm_monoid, .. with_top.mul_zero_class, .. with_top.canonically_ordered_add_monoid }
1077+
.. with_top.add_comm_monoid, .. with_top.mul_zero_class, .. with_top.canonically_ordered_add_monoid,
1078+
.. with_top.no_zero_divisors, .. with_top.nonzero }
10591079

10601080
end with_top

src/algebra/ring.lean

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -793,13 +793,13 @@ by rw [← sub_eq_zero, ← mul_sub_left_distrib, mul_eq_zero];
793793

794794
/-- An element of a domain fixed by right multiplication by an element other than one must
795795
be zero. -/
796-
theorem eq_zero_of_mul_eq_self_right' {a b : α} (h₁ : b ≠ 1) (h₂ : a * b = a) : a = 0 :=
796+
theorem eq_zero_of_mul_eq_self_right {a b : α} (h₁ : b ≠ 1) (h₂ : a * b = a) : a = 0 :=
797797
by apply (mul_eq_zero.1 _).resolve_right (sub_ne_zero.2 h₁);
798798
rw [mul_sub_left_distrib, mul_one, sub_eq_zero, h₂]
799799

800800
/-- An element of a domain fixed by left multiplication by an element other than one must
801801
be zero. -/
802-
theorem eq_zero_of_mul_eq_self_left' {a b : α} (h₁ : b ≠ 1) (h₂ : b * a = a) : a = 0 :=
802+
theorem eq_zero_of_mul_eq_self_left {a b : α} (h₁ : b ≠ 1) (h₂ : b * a = a) : a = 0 :=
803803
by apply (mul_eq_zero.1 _).resolve_left (sub_ne_zero.2 h₁);
804804
rw [mul_sub_right_distrib, one_mul, sub_eq_zero, h₂]
805805

@@ -813,34 +813,11 @@ class integral_domain (α : Type u) extends comm_ring α, domain α
813813
section integral_domain
814814
variables [integral_domain α] {a b c d e : α}
815815

816-
lemma mul_eq_zero_iff_eq_zero_or_eq_zero : a * b = 0 ↔ a = 0 ∨ b = 0 :=
817-
⟨eq_zero_or_eq_zero_of_mul_eq_zero, λo,
818-
or.elim o (λh, by rw h; apply zero_mul) (λh, by rw h; apply mul_zero)⟩
819-
820816
lemma eq_of_mul_eq_mul_right (ha : a ≠ 0) (h : b * a = c * a) : b = c :=
821-
have b * a - c * a = 0, from sub_eq_zero_of_eq h,
822-
have (b - c) * a = 0, by rw [mul_sub_right_distrib, this],
823-
have b - c = 0, from (eq_zero_or_eq_zero_of_mul_eq_zero this).resolve_right ha,
824-
eq_of_sub_eq_zero this
817+
(domain.mul_left_inj ha).1 h
825818

826819
lemma eq_of_mul_eq_mul_left (ha : a ≠ 0) (h : a * b = a * c) : b = c :=
827-
have a * b - a * c = 0, from sub_eq_zero_of_eq h,
828-
have a * (b - c) = 0, by rw [mul_sub_left_distrib, this],
829-
have b - c = 0, from (eq_zero_or_eq_zero_of_mul_eq_zero this).resolve_left ha,
830-
eq_of_sub_eq_zero this
831-
832-
lemma eq_zero_of_mul_eq_self_right (h₁ : b ≠ 1) (h₂ : a * b = a) : a = 0 :=
833-
have hb : b - 10, from
834-
assume : b - 1 = 0,
835-
have b = 0 + 1, from eq_add_of_sub_eq this,
836-
have b = 1, by rwa zero_add at this,
837-
h₁ this,
838-
have a * b - a = 0, by simp [h₂],
839-
have a * (b - 1) = 0, by rwa [mul_sub_left_distrib, mul_one],
840-
show a = 0, from (eq_zero_or_eq_zero_of_mul_eq_zero this).resolve_right hb
841-
842-
lemma eq_zero_of_mul_eq_self_left (h₁ : b ≠ 1) (h₂ : b * a = a) : a = 0 :=
843-
eq_zero_of_mul_eq_self_right h₁ (by rwa mul_comm at h₂)
820+
(domain.mul_right_inj ha).1 h
844821

845822
lemma mul_self_eq_mul_self_iff (a b : α) : a * a = b * b ↔ a = b ∨ a = -b :=
846823
iff.intro
@@ -861,17 +838,11 @@ by rwa mul_one at this
861838

862839
/-- Right multiplcation by a nonzero element of an integral domain is injective. -/
863840
theorem eq_of_mul_eq_mul_right_of_ne_zero (ha : a ≠ 0) (h : b * a = c * a) : b = c :=
864-
have b * a - c * a = 0, by simp [h],
865-
have (b - c) * a = 0, by rw [mul_sub_right_distrib, this],
866-
have b - c = 0, from (eq_zero_or_eq_zero_of_mul_eq_zero this).resolve_right ha,
867-
eq_of_sub_eq_zero this
841+
eq_of_mul_eq_mul_right ha h
868842

869843
/-- Left multiplication by a nonzero element of an integral domain is injective. -/
870844
theorem eq_of_mul_eq_mul_left_of_ne_zero (ha : a ≠ 0) (h : a * b = a * c) : b = c :=
871-
have a * b - a * c = 0, by simp [h],
872-
have a * (b - c) = 0, by rw [mul_sub_left_distrib, this],
873-
have b - c = 0, from (eq_zero_or_eq_zero_of_mul_eq_zero this).resolve_left ha,
874-
eq_of_sub_eq_zero this
845+
eq_of_mul_eq_mul_left ha h
875846

876847
/-- Given two elements b, c of an integral domain and a nonzero element a, a*b divides a*c iff
877848
b divides c. -/

src/data/nat/basic.lean

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ instance : canonically_ordered_comm_semiring ℕ :=
2727
⟨assume h, let ⟨c, hc⟩ := nat.le.dest h in ⟨c, hc.symm⟩,
2828
assume ⟨c, hc⟩, hc.symm ▸ nat.le_add_right _ _⟩,
2929
zero_ne_one := ne_of_lt zero_lt_one,
30-
mul_eq_zero_iff := assume a b,
31-
iff.intro nat.eq_zero_of_mul_eq_zero (by simp [or_imp_distrib] {contextual := tt}),
30+
eq_zero_or_eq_zero_of_mul_eq_zero := assume a b, nat.eq_zero_of_mul_eq_zero,
3231
bot := 0,
3332
bot_le := nat.zero_le,
3433
.. (infer_instance : ordered_add_comm_monoid ℕ),

0 commit comments

Comments
 (0)