Skip to content

Commit

Permalink
feat(data/nat/basic): add injectivity and divisibility lemmas (#5068)
Browse files Browse the repository at this point in the history
Multiplication by a non-zero natural is injective. Also a simple criterion for non-divisibility which I couldn't find (0<b<a implies a doesn't divide b).
  • Loading branch information
kbuzzard committed Nov 23, 2020
1 parent 2252c3a commit ce0498e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/data/nat/basic.lean
Expand Up @@ -586,6 +586,12 @@ protected theorem mul_left_inj {a b c : ℕ} (ha : 0 < a) : b * a = c * a ↔ b
protected theorem mul_right_inj {a b c : ℕ} (ha : 0 < a) : a * b = a * c ↔ b = c :=
⟨nat.eq_of_mul_eq_mul_left ha, λ e, e ▸ rfl⟩

lemma mul_left_injective {a : ℕ} (ha : 0 < a) : function.injective (λ x, x * a) :=
λ _ _, eq_of_mul_eq_mul_right ha

lemma mul_right_injective {a : ℕ} (ha : 0 < a) : function.injective (λ x, a * x) :=
λ _ _, eq_of_mul_eq_mul_left ha

lemma mul_right_eq_self_iff {a b : ℕ} (ha : 0 < a) : a * b = a ↔ b = 1 :=
suffices a * b = a * 1 ↔ b = 1, by rwa mul_one at this,
nat.mul_right_inj ha
Expand Down Expand Up @@ -882,6 +888,14 @@ nat.dvd_add_right (dvd_refl m)
m ∣ n + m ↔ m ∣ n :=
nat.dvd_add_left (dvd_refl m)

lemma not_dvd_of_pos_of_lt {a b : ℕ} (h1 : 0 < b) (h2 : b < a) : ¬ a ∣ b :=
begin
rintros ⟨c, rfl⟩,
rcases eq_zero_or_pos c with (rfl | hc),
{ exact lt_irrefl 0 h1 },
{ exact not_lt.2 (le_mul_of_pos_right hc) h2 },
end

protected theorem mul_dvd_mul_iff_left {a b c : ℕ} (ha : 0 < a) : a * b ∣ a * c ↔ b ∣ c :=
exists_congr $ λ d, by rw [mul_assoc, nat.mul_right_inj ha]

Expand Down

0 comments on commit ce0498e

Please sign in to comment.