Skip to content

Commit

Permalink
feat(data/int/basic): add lemma int.abs_le_one_iff (#13513)
Browse files Browse the repository at this point in the history
Also renaming `int.eq_zero_iff_abs_lt_one`.

The proof is due to @Ruben-VandeVelde 

Discussed on Zulip [here](https://leanprover.zulipchat.com/#narrow/stream/217875-Is-there-code-for-X.3F/topic/Integers.20of.20norm.20at.20most.20one)

Co-authored-by: Ruben Van de Velde <65514131+Ruben-VandeVelde@users.noreply.github.com>
  • Loading branch information
ocfnash and Ruben-VandeVelde committed Apr 19, 2022
1 parent 634eab1 commit f06dca7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/data/int/basic.lean
Expand Up @@ -214,10 +214,13 @@ sub_lt_iff_lt_add.trans lt_add_one_iff
theorem le_sub_one_iff {a b : ℤ} : a ≤ b - 1 ↔ a < b :=
le_sub_iff_add_le

@[simp] lemma eq_zero_iff_abs_lt_one {a : ℤ} : |a| < 1 ↔ a = 0 :=
@[simp] lemma abs_lt_one_iff {a : ℤ} : |a| < 1 ↔ a = 0 :=
⟨λ a0, let ⟨hn, hp⟩ := abs_lt.mp a0 in (le_of_lt_add_one (by exact hp)).antisymm hn,
λ a0, (abs_eq_zero.mpr a0).le.trans_lt zero_lt_one⟩

lemma abs_le_one_iff {a : ℤ} : |a| ≤ 1 ↔ a = 0 ∨ a = 1 ∨ a = -1 :=
by rw [le_iff_lt_or_eq, abs_lt_one_iff, abs_eq (@zero_le_one ℤ _)]

@[elab_as_eliminator] protected lemma induction_on {p : ℤ → Prop}
(i : ℤ) (hz : p 0) (hp : ∀ i : ℕ, p i → p (i + 1)) (hn : ∀ i : ℕ, p (-i) → p (-i - 1)) : p i :=
begin
Expand Down Expand Up @@ -1546,7 +1549,7 @@ begin
by_cases hm : m = 0, { subst m, exact zero_dvd_iff.mp h1, },
rcases h1 with ⟨d, rfl⟩,
apply mul_eq_zero_of_right,
rw [←eq_zero_iff_abs_lt_one, ←mul_lt_iff_lt_one_right (abs_pos.mpr hm), ←abs_mul],
rw [←abs_lt_one_iff, ←mul_lt_iff_lt_one_right (abs_pos.mpr hm), ←abs_mul],
exact lt_of_lt_of_le h2 (le_abs_self m),
end

Expand Down

0 comments on commit f06dca7

Please sign in to comment.