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

Commit 4ba9098

Browse files
committed
feat(algebra/euclidean_domain,data/int/basic): dvd_div_of_mul_dvd (#12382)
We have a separate `int` and `euclidean_domain` version as `euclidean_domain` isn't pulled in by `int.basic`.
1 parent 269280a commit 4ba9098

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/algebra/euclidean_domain.lean

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,15 @@ begin
195195
euclidean_domain.mul_div_cancel _ hq]
196196
end
197197

198+
lemma dvd_div_of_mul_dvd {a b c : R} (h : a * b ∣ c) : b ∣ c / a :=
199+
begin
200+
rcases eq_or_ne a 0 with rfl | ha,
201+
{ simp only [div_zero, dvd_zero] },
202+
rcases h with ⟨d, rfl⟩,
203+
refine ⟨d, _⟩,
204+
rw [mul_assoc, mul_div_cancel_left _ ha]
205+
end
206+
198207
section
199208
open_locale classical
200209

src/data/int/basic.lean

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,14 +1110,23 @@ not_lt.mp (mt (eq_zero_of_dvd_of_nat_abs_lt_nat_abs hst) ht)
11101110
lemma nat_abs_eq_of_dvd_dvd {s t : ℤ} (hst : s ∣ t) (hts : t ∣ s) : nat_abs s = nat_abs t :=
11111111
nat.dvd_antisymm (nat_abs_dvd_iff_dvd.mpr hst) (nat_abs_dvd_iff_dvd.mpr hts)
11121112

1113-
lemma div_dvd_of_ne_zero_dvd {s t : ℤ} (hst : s ∣ t) : (t / s) ∣ t :=
1113+
lemma div_dvd_of_dvd {s t : ℤ} (hst : s ∣ t) : (t / s) ∣ t :=
11141114
begin
1115-
by_cases hs : s = 0,
1116-
{ simp [*] at *, },
1115+
rcases eq_or_ne s 0 with rfl | hs,
1116+
{ simpa using hst },
11171117
rcases hst with ⟨c, hc⟩,
11181118
simp [hc, int.mul_div_cancel_left _ hs],
11191119
end
11201120

1121+
lemma dvd_div_of_mul_dvd {a b c : ℤ} (h : a * b ∣ c) : b ∣ c / a :=
1122+
begin
1123+
rcases eq_or_ne a 0 with rfl | ha,
1124+
{ simp only [int.div_zero, dvd_zero] },
1125+
rcases h with ⟨d, rfl⟩,
1126+
refine ⟨d, _⟩,
1127+
rw [mul_assoc, int.mul_div_cancel_left _ ha],
1128+
end
1129+
11211130
/-! ### to_nat -/
11221131

11231132
theorem to_nat_eq_max : ∀ (a : ℤ), (to_nat a : ℤ) = max a 0

0 commit comments

Comments
 (0)