data.int.order.basic
⟷
Mathlib.Data.Int.Order.Basic
The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(last sync)
A few convenience shortcuts for dvd
along with some simple nat
lemmas. Also
neg_dvd_of_dvd
/dvd_of_neg_dvd
/dvd_neg_of_dvd
/dvd_of_dvd_neg
in favor of the aforementioned shortcuts.dvd_neg
/neg_dvd
.int.of_nat_dvd_of_dvd_nat_abs
/int.dvd_nat_abs_of_of_nat_dvd
because they are the two directions of int.coe_nat_dvd_left
.group_with_zero.to_cancel_monoid_with_zero
from algebra.group_with_zero.units.basic
back to algebra.group_with_zero.basic
. It was erroneously moved during the Great Splits.@@ -525,7 +525,7 @@ theorem neg_div_of_dvd : ∀ {a b : ℤ} (H : b ∣ a), -a / b = -(a / b)
lemma sub_div_of_dvd (a : ℤ) {b c : ℤ} (hcb : c ∣ b) : (a - b) / c = a / c - b / c :=
begin
- rw [sub_eq_add_neg, sub_eq_add_neg, int.add_div_of_dvd_right ((dvd_neg c b).mpr hcb)],
+ rw [sub_eq_add_neg, sub_eq_add_neg, int.add_div_of_dvd_right hcb.neg_right],
congr,
exact neg_div_of_dvd hcb,
end
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
@@ -76,6 +76,16 @@ lemma coe_nat_ne_zero_iff_pos {n : ℕ} : (n : ℤ) ≠ 0 ↔ 0 < n :=
@[norm_cast] lemma abs_coe_nat (n : ℕ) : |(n : ℤ)| = n := abs_of_nonneg (coe_nat_nonneg n)
+theorem sign_add_eq_of_sign_eq : ∀ {m n : ℤ}, m.sign = n.sign → (m + n).sign = n.sign :=
+begin
+ have : (1 : ℤ) ≠ -1 := dec_trivial,
+ rintro ((_ | m) | m) ((_ | n) | n);
+ simp [this, this.symm],
+ rw int.sign_eq_one_iff_pos,
+ apply int.add_pos;
+ { exact zero_lt_one.trans_le (le_add_of_nonneg_left $ coe_zero_le _) }
+end
+
/-! ### succ and pred -/
theorem lt_succ_self (a : ℤ) : a < succ a :=
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
div
/mod
as an equivalence on nat
/int
(#18359)
The motivation here is to be able to use this to change a sum/product/supr/infi/tsum/etc to be indexed by a product, such that every n
th term can be collected into an inner / outer sum. We already have the API in most places for equiv
s and prod
s to do this, all that's missing is the equivalences in this PR.
Note that we use [ne_zero n]
instead of hn : n ≠ 0
as this is required by fin.of_nat'
for the coercion.
Co-authored-by: Junyan Xu <junyanxumath@gmail.com>
@@ -346,6 +346,7 @@ begin
rw [sub_add_cancel, ← add_mod_mod, sub_add_cancel, mod_mod]
end
+/-- See also `int.div_mod_equiv` for a similar statement as an `equiv`. -/
protected theorem div_mod_unique {a b r q : ℤ} (h : 0 < b) :
a / b = q ∧ a % b = r ↔ r + b * q = a ∧ 0 ≤ r ∧ r < b :=
begin
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
@@ -4,6 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad
-/
import data.int.basic
+import data.int.cast.basic
import algebra.ring.divisibility
import algebra.order.group.abs
import algebra.order.ring.char_zero
@@ -54,6 +55,11 @@ theorem abs_eq_nat_abs : ∀ a : ℤ, |a| = nat_abs a
| (n : ℕ) := abs_of_nonneg $ coe_zero_le _
| -[1+ n] := abs_of_nonpos $ le_of_lt $ neg_succ_lt_zero _
+@[simp, norm_cast] lemma coe_nat_abs (n : ℤ) : (n.nat_abs : ℤ) = |n| := n.abs_eq_nat_abs.symm
+
+lemma _root_.nat.cast_nat_abs {α : Type*} [add_group_with_one α] (n : ℤ) : (n.nat_abs : α) = ↑|n| :=
+by rw [←int.coe_nat_abs, int.cast_coe_nat]
+
theorem nat_abs_abs (a : ℤ) : nat_abs (|a|) = nat_abs a :=
by rw [abs_eq_nat_abs]; refl
@@ -68,8 +74,7 @@ lemma coe_nat_ne_zero_iff_pos {n : ℕ} : (n : ℤ) ≠ 0 ↔ 0 < n :=
⟨λ h, nat.pos_of_ne_zero (coe_nat_ne_zero.1 h),
λ h, (ne_of_lt (coe_nat_lt.2 h)).symm⟩
-theorem coe_nat_abs (n : ℕ) : |(n : ℤ)| = n :=
-abs_of_nonneg (coe_nat_nonneg n)
+@[norm_cast] lemma abs_coe_nat (n : ℕ) : |(n : ℤ)| = n := abs_of_nonneg (coe_nat_nonneg n)
/-! ### succ and pred -/
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(first ported)
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -3,7 +3,7 @@ Copyright (c) 2016 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad
-/
-import Data.Int.Basic
+import Algebra.Group.Int
import Data.Int.Cast.Basic
import Algebra.Ring.Divisibility.Basic
import Algebra.Order.Group.Abs
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -76,7 +76,7 @@ theorem natCast_natAbs (n : ℤ) : (n.natAbs : ℤ) = |n| :=
#print Nat.cast_natAbs /-
theorem Nat.cast_natAbs {α : Type _} [AddGroupWithOne α] (n : ℤ) : (n.natAbs : α) = ↑|n| := by
- rw [← Int.natCast_natAbs, Int.cast_ofNat]
+ rw [← Int.natCast_natAbs, Int.cast_natCast]
#align nat.cast_nat_abs Nat.cast_natAbs
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -5,7 +5,7 @@ Authors: Jeremy Avigad
-/
import Data.Int.Basic
import Data.Int.Cast.Basic
-import Algebra.Ring.Divisibility
+import Algebra.Ring.Divisibility.Basic
import Algebra.Order.Group.Abs
import Algebra.Order.Ring.CharZero
import Tactic.AssertExists
@@ -67,16 +67,16 @@ theorem abs_eq_natAbs : ∀ a : ℤ, |a| = natAbs a
#align int.abs_eq_nat_abs Int.abs_eq_natAbs
-/
-#print Int.coe_natAbs /-
+#print Int.natCast_natAbs /-
@[simp, norm_cast]
-theorem coe_natAbs (n : ℤ) : (n.natAbs : ℤ) = |n| :=
+theorem natCast_natAbs (n : ℤ) : (n.natAbs : ℤ) = |n| :=
n.abs_eq_natAbs.symm
-#align int.coe_nat_abs Int.coe_natAbs
+#align int.coe_nat_abs Int.natCast_natAbs
-/
#print Nat.cast_natAbs /-
theorem Nat.cast_natAbs {α : Type _} [AddGroupWithOne α] (n : ℤ) : (n.natAbs : α) = ↑|n| := by
- rw [← Int.coe_natAbs, Int.cast_ofNat]
+ rw [← Int.natCast_natAbs, Int.cast_ofNat]
#align nat.cast_nat_abs Nat.cast_natAbs
-/
@@ -90,28 +90,28 @@ theorem sign_mul_abs (a : ℤ) : sign a * |a| = a := by rw [abs_eq_nat_abs, sign
#align int.sign_mul_abs Int.sign_mul_abs
-/
-#print Int.coe_nat_eq_zero /-
-theorem coe_nat_eq_zero {n : ℕ} : (n : ℤ) = 0 ↔ n = 0 :=
+#print Int.natCast_eq_zero /-
+theorem natCast_eq_zero {n : ℕ} : (n : ℤ) = 0 ↔ n = 0 :=
Nat.cast_eq_zero
-#align int.coe_nat_eq_zero Int.coe_nat_eq_zero
+#align int.coe_nat_eq_zero Int.natCast_eq_zero
-/
-#print Int.coe_nat_ne_zero /-
-theorem coe_nat_ne_zero {n : ℕ} : (n : ℤ) ≠ 0 ↔ n ≠ 0 := by simp
-#align int.coe_nat_ne_zero Int.coe_nat_ne_zero
+#print Int.natCast_ne_zero /-
+theorem natCast_ne_zero {n : ℕ} : (n : ℤ) ≠ 0 ↔ n ≠ 0 := by simp
+#align int.coe_nat_ne_zero Int.natCast_ne_zero
-/
-#print Int.coe_nat_ne_zero_iff_pos /-
-theorem coe_nat_ne_zero_iff_pos {n : ℕ} : (n : ℤ) ≠ 0 ↔ 0 < n :=
- ⟨fun h => Nat.pos_of_ne_zero (coe_nat_ne_zero.1 h), fun h => (ne_of_lt (ofNat_lt.2 h)).symm⟩
-#align int.coe_nat_ne_zero_iff_pos Int.coe_nat_ne_zero_iff_pos
+#print Int.natCast_ne_zero_iff_pos /-
+theorem natCast_ne_zero_iff_pos {n : ℕ} : (n : ℤ) ≠ 0 ↔ 0 < n :=
+ ⟨fun h => Nat.pos_of_ne_zero (natCast_ne_zero.1 h), fun h => (ne_of_lt (ofNat_lt.2 h)).symm⟩
+#align int.coe_nat_ne_zero_iff_pos Int.natCast_ne_zero_iff_pos
-/
-#print Int.abs_coe_nat /-
+#print Int.abs_natCast /-
@[norm_cast]
-theorem abs_coe_nat (n : ℕ) : |(n : ℤ)| = n :=
- abs_of_nonneg (coe_nat_nonneg n)
-#align int.abs_coe_nat Int.abs_coe_nat
+theorem abs_natCast (n : ℕ) : |(n : ℤ)| = n :=
+ abs_of_nonneg (natCast_nonneg n)
+#align int.abs_coe_nat Int.abs_natCast
-/
#print Int.sign_add_eq_of_sign_eq /-
@@ -368,8 +368,7 @@ theorem emod_abs (a b : ℤ) : a % |b| = a % b :=
#print Int.emod_nonneg /-
theorem emod_nonneg : ∀ (a : ℤ) {b : ℤ}, b ≠ 0 → 0 ≤ a % b
| (m : ℕ), n, H => ofNat_zero_le _
- | -[m+1], n, H =>
- sub_nonneg_of_le <| ofNat_le_ofNat_of_le <| Nat.mod_lt _ (natAbs_pos_of_ne_zero H)
+ | -[m+1], n, H => sub_nonneg_of_le <| ofNat_le_ofNat_of_le <| Nat.mod_lt _ (natAbs_pos H)
#align int.mod_nonneg Int.emod_nonneg
-/
@@ -936,12 +935,12 @@ theorem lt_toNat {n : ℕ} {a : ℤ} : n < toNat a ↔ (n : ℤ) < a :=
#align int.lt_to_nat Int.lt_toNat
-/
-#print Int.coe_nat_nonpos_iff /-
+#print Int.natCast_nonpos_iff /-
@[simp]
-theorem coe_nat_nonpos_iff {n : ℕ} : (n : ℤ) ≤ 0 ↔ n = 0 :=
+theorem natCast_nonpos_iff {n : ℕ} : (n : ℤ) ≤ 0 ↔ n = 0 :=
⟨fun h => le_antisymm (Int.ofNat_le.mp (h.trans Int.ofNat_zero.le)) n.zero_le, fun h =>
- (coe_nat_eq_zero.mpr h).le⟩
-#align int.coe_nat_nonpos_iff Int.coe_nat_nonpos_iff
+ (natCast_eq_zero.mpr h).le⟩
+#align int.coe_nat_nonpos_iff Int.natCast_nonpos_iff
-/
#print Int.toNat_le_toNat /-
@@ -975,8 +974,8 @@ theorem toNat_pred_coe_of_pos {i : ℤ} (h : 0 < i) : ((i.toNat - 1 : ℕ) : ℤ
theorem toNat_eq_zero : ∀ {n : ℤ}, n.toNat = 0 ↔ n ≤ 0
| (n : ℕ) =>
calc
- _ ↔ n = 0 := ⟨(toNat_coe_nat n).symm.trans, (toNat_coe_nat n).trans⟩
- _ ↔ _ := coe_nat_nonpos_iff.symm
+ _ ↔ n = 0 := ⟨(toNat_natCast n).symm.trans, (toNat_natCast n).trans⟩
+ _ ↔ _ := natCast_nonpos_iff.symm
| -[n+1] =>
show (-((n : ℤ) + 1)).toNat = 0 ↔ (-(n + 1) : ℤ) ≤ 0 from
calc
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -251,7 +251,7 @@ theorem natAbs_dvd_natAbs {a b : ℤ} : a.natAbs ∣ b.natAbs ↔ a ∣ b :=
by
refine' ⟨_, fun ⟨k, hk⟩ => ⟨k.natAbs, hk.symm ▸ nat_abs_mul a k⟩⟩
rintro ⟨k, hk⟩
- rw [← nat_abs_of_nat k, ← nat_abs_mul, nat_abs_eq_nat_abs_iff, neg_mul_eq_mul_neg] at hk
+ rw [← nat_abs_of_nat k, ← nat_abs_mul, nat_abs_eq_nat_abs_iff, neg_mul_eq_mul_neg] at hk
cases hk <;> exact ⟨_, hk⟩
#align int.nat_abs_dvd_iff_dvd Int.natAbs_dvd_natAbs
-/
@@ -316,7 +316,7 @@ protected theorem add_mul_ediv_left (a : ℤ) {b : ℤ} (c : ℤ) (H : b ≠ 0)
#print Int.mul_ediv_cancel /-
@[simp]
protected theorem mul_ediv_cancel (a : ℤ) {b : ℤ} (H : b ≠ 0) : a * b / b = a := by
- have := Int.add_mul_ediv_right 0 a H <;> rwa [zero_add, Int.zero_div, zero_add] at this
+ have := Int.add_mul_ediv_right 0 a H <;> rwa [zero_add, Int.zero_div, zero_add] at this
#align int.mul_div_cancel Int.mul_ediv_cancel
-/
@@ -330,7 +330,7 @@ protected theorem mul_ediv_cancel_left {a : ℤ} (b : ℤ) (H : a ≠ 0) : a * b
#print Int.ediv_self /-
@[simp]
protected theorem ediv_self {a : ℤ} (H : a ≠ 0) : a / a = 1 := by
- have := Int.mul_ediv_cancel 1 H <;> rwa [one_mul] at this
+ have := Int.mul_ediv_cancel 1 H <;> rwa [one_mul] at this
#align int.div_self Int.ediv_self
-/
@@ -343,7 +343,7 @@ protected theorem add_ediv_of_dvd_right {a b c : ℤ} (H : c ∣ b) : (a + b) /
· simp [h1]
cases' H with k hk
rw [hk]
- change c ≠ 0 at h1
+ change c ≠ 0 at h1
rw [mul_comm c k, Int.add_mul_ediv_right _ _ h1, ← zero_add (k * c),
Int.add_mul_ediv_right _ _ h1, Int.zero_div, zero_add]
#align int.add_div_of_dvd_right Int.add_ediv_of_dvd_right
@@ -407,7 +407,7 @@ theorem add_mul_emod_self_left (a b c : ℤ) : (a + b * c) % b = a % b := by
#print Int.add_emod_self /-
@[simp]
theorem add_emod_self {a b : ℤ} : (a + b) % b = a % b := by
- have := add_mul_mod_self_left a b 1 <;> rwa [mul_one] at this
+ have := add_mul_mod_self_left a b 1 <;> rwa [mul_one] at this
#align int.add_mod_self Int.add_emod_self
-/
@@ -421,7 +421,7 @@ theorem add_emod_self_left {a b : ℤ} : (a + b) % a = b % a := by rw [add_comm,
@[simp]
theorem emod_add_emod (m n k : ℤ) : (m % n + k) % n = (m + k) % n := by
have := (add_mul_mod_self_left (m % n + k) n (m / n)).symm <;>
- rwa [add_right_comm, mod_add_div] at this
+ rwa [add_right_comm, mod_add_div] at this
#align int.mod_add_mod Int.emod_add_emod
-/
@@ -453,7 +453,7 @@ theorem add_emod_eq_add_emod_left {m n k : ℤ} (i : ℤ) (H : m % n = k % n) :
theorem emod_add_cancel_right {m n k : ℤ} (i) : (m + i) % n = (k + i) % n ↔ m % n = k % n :=
⟨fun H => by
have := add_mod_eq_add_mod_right (-i) H <;>
- rwa [add_neg_cancel_right, add_neg_cancel_right] at this ,
+ rwa [add_neg_cancel_right, add_neg_cancel_right] at this,
add_emod_eq_add_emod_right _⟩
#align int.mod_add_cancel_right Int.emod_add_cancel_right
-/
@@ -494,7 +494,7 @@ theorem mul_emod (a b n : ℤ) : a * b % n = a % n * (b % n) % n := by
#print Int.emod_self /-
-- Will be generalized to Euclidean domains.
@[local simp]
-theorem emod_self {a : ℤ} : a % a = 0 := by have := mul_mod_left 1 a <;> rwa [one_mul] at this
+theorem emod_self {a : ℤ} : a % a = 0 := by have := mul_mod_left 1 a <;> rwa [one_mul] at this
#align int.mod_self Int.emod_self
-/
@@ -590,7 +590,7 @@ theorem abs_ediv_le_abs : ∀ a b : ℤ, |a / b| ≤ |a| :=
#print Int.ediv_le_self /-
theorem ediv_le_self {a : ℤ} (b : ℤ) (Ha : 0 ≤ a) : a / b ≤ a := by
- have := le_trans (le_abs_self _) (abs_div_le_abs a b) <;> rwa [abs_of_nonneg Ha] at this
+ have := le_trans (le_abs_self _) (abs_div_le_abs a b) <;> rwa [abs_of_nonneg Ha] at this
#align int.div_le_self Int.ediv_le_self
-/
@@ -632,7 +632,7 @@ theorem dvd_iff_emod_eq_zero (a b : ℤ) : a ∣ b ↔ b % a = 0 :=
theorem dvd_sub_of_emod_eq {a b c : ℤ} (h : a % b = c) : b ∣ a - c :=
by
have hx : a % b % b = c % b := by rw [h]
- rw [mod_mod, ← mod_sub_cancel_right c, sub_self, zero_mod] at hx
+ rw [mod_mod, ← mod_sub_cancel_right c, sub_self, zero_mod] at hx
exact dvd_of_mod_eq_zero hx
#align int.dvd_sub_of_mod_eq Int.dvd_sub_of_emod_eq
-/
@@ -748,9 +748,9 @@ theorem exists_lt_and_lt_iff_not_dvd (m : ℤ) {n : ℤ} (hn : 0 < n) :
(∃ k, n * k < m ∧ m < n * (k + 1)) ↔ ¬n ∣ m :=
by
constructor
- · rintro ⟨k, h1k, h2k⟩ ⟨l, rfl⟩; rw [mul_lt_mul_left hn] at h1k h2k
- rw [lt_add_one_iff, ← not_lt] at h2k ; exact h2k h1k
- · intro h; rw [dvd_iff_mod_eq_zero, ← Ne.def] at h
+ · rintro ⟨k, h1k, h2k⟩ ⟨l, rfl⟩; rw [mul_lt_mul_left hn] at h1k h2k
+ rw [lt_add_one_iff, ← not_lt] at h2k; exact h2k h1k
+ · intro h; rw [dvd_iff_mod_eq_zero, ← Ne.def] at h
have := (mod_nonneg m hn.ne.symm).lt_of_ne h.symm
simp (config := { singlePass := true }) only [← mod_add_div m n]
refine' ⟨m / n, lt_add_of_pos_left _ this, _⟩
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce64cd319bb6b3e82f31c2d38e79080d377be451
@@ -3,12 +3,12 @@ Copyright (c) 2016 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad
-/
-import Mathbin.Data.Int.Basic
-import Mathbin.Data.Int.Cast.Basic
-import Mathbin.Algebra.Ring.Divisibility
-import Mathbin.Algebra.Order.Group.Abs
-import Mathbin.Algebra.Order.Ring.CharZero
-import Mathbin.Tactic.AssertExists
+import Data.Int.Basic
+import Data.Int.Cast.Basic
+import Algebra.Ring.Divisibility
+import Algebra.Order.Group.Abs
+import Algebra.Order.Ring.CharZero
+import Tactic.AssertExists
#align_import data.int.order.basic from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3"
mathlib commit https://github.com/leanprover-community/mathlib/commit/32a7e535287f9c73f2e4d2aef306a39190f0b504
@@ -41,7 +41,7 @@ instance : LinearOrderedCommRing ℤ :=
{ Int.commRing, Int.linearOrder,
Int.nontrivial with
add_le_add_left := @Int.add_le_add_left
- mul_pos := @Int.mul_pos
+ mul_pos := @Int.hMul_pos
zero_le_one := le_of_lt Int.zero_lt_one }
/-! ### Extra instances to short-circuit type class resolution
mathlib commit https://github.com/leanprover-community/mathlib/commit/8ea5598db6caeddde6cb734aa179cc2408dbd345
@@ -2,11 +2,6 @@
Copyright (c) 2016 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad
-
-! This file was ported from Lean 3 source module data.int.order.basic
-! leanprover-community/mathlib commit e8638a0fcaf73e4500469f368ef9494e495099b3
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathbin.Data.Int.Basic
import Mathbin.Data.Int.Cast.Basic
@@ -15,6 +10,8 @@ import Mathbin.Algebra.Order.Group.Abs
import Mathbin.Algebra.Order.Ring.CharZero
import Mathbin.Tactic.AssertExists
+#align_import data.int.order.basic from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3"
+
/-!
# Order instances on the integers
mathlib commit https://github.com/leanprover-community/mathlib/commit/9240e8be927a0955b9a82c6c85ef499ee3a626b8
@@ -78,13 +78,13 @@ theorem coe_natAbs (n : ℤ) : (n.natAbs : ℤ) = |n| :=
-/
#print Nat.cast_natAbs /-
-theorem Nat.cast_natAbs {α : Type _} [AddGroupWithOne α] (n : ℤ) : (n.natAbs : α) = ↑(|n|) := by
+theorem Nat.cast_natAbs {α : Type _} [AddGroupWithOne α] (n : ℤ) : (n.natAbs : α) = ↑|n| := by
rw [← Int.coe_natAbs, Int.cast_ofNat]
#align nat.cast_nat_abs Nat.cast_natAbs
-/
#print Int.natAbs_abs /-
-theorem natAbs_abs (a : ℤ) : natAbs (|a|) = natAbs a := by rw [abs_eq_nat_abs] <;> rfl
+theorem natAbs_abs (a : ℤ) : natAbs |a| = natAbs a := by rw [abs_eq_nat_abs] <;> rfl
#align int.nat_abs_abs Int.natAbs_abs
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/9fb8964792b4237dac6200193a0d533f1b3f7423
@@ -63,25 +63,35 @@ end Int
namespace Int
+#print Int.abs_eq_natAbs /-
theorem abs_eq_natAbs : ∀ a : ℤ, |a| = natAbs a
| (n : ℕ) => abs_of_nonneg <| ofNat_zero_le _
| -[n+1] => abs_of_nonpos <| le_of_lt <| negSucc_lt_zero _
#align int.abs_eq_nat_abs Int.abs_eq_natAbs
+-/
+#print Int.coe_natAbs /-
@[simp, norm_cast]
theorem coe_natAbs (n : ℤ) : (n.natAbs : ℤ) = |n| :=
n.abs_eq_natAbs.symm
#align int.coe_nat_abs Int.coe_natAbs
+-/
+#print Nat.cast_natAbs /-
theorem Nat.cast_natAbs {α : Type _} [AddGroupWithOne α] (n : ℤ) : (n.natAbs : α) = ↑(|n|) := by
rw [← Int.coe_natAbs, Int.cast_ofNat]
#align nat.cast_nat_abs Nat.cast_natAbs
+-/
+#print Int.natAbs_abs /-
theorem natAbs_abs (a : ℤ) : natAbs (|a|) = natAbs a := by rw [abs_eq_nat_abs] <;> rfl
#align int.nat_abs_abs Int.natAbs_abs
+-/
+#print Int.sign_mul_abs /-
theorem sign_mul_abs (a : ℤ) : sign a * |a| = a := by rw [abs_eq_nat_abs, sign_mul_nat_abs]
#align int.sign_mul_abs Int.sign_mul_abs
+-/
#print Int.coe_nat_eq_zero /-
theorem coe_nat_eq_zero {n : ℕ} : (n : ℤ) = 0 ↔ n = 0 :=
@@ -100,10 +110,12 @@ theorem coe_nat_ne_zero_iff_pos {n : ℕ} : (n : ℤ) ≠ 0 ↔ 0 < n :=
#align int.coe_nat_ne_zero_iff_pos Int.coe_nat_ne_zero_iff_pos
-/
+#print Int.abs_coe_nat /-
@[norm_cast]
theorem abs_coe_nat (n : ℕ) : |(n : ℤ)| = n :=
abs_of_nonneg (coe_nat_nonneg n)
#align int.abs_coe_nat Int.abs_coe_nat
+-/
#print Int.sign_add_eq_of_sign_eq /-
theorem sign_add_eq_of_sign_eq : ∀ {m n : ℤ}, m.sign = n.sign → (m + n).sign = n.sign :=
@@ -154,6 +166,7 @@ theorem le_sub_one_iff {a b : ℤ} : a ≤ b - 1 ↔ a < b :=
#align int.le_sub_one_iff Int.le_sub_one_iff
-/
+#print Int.abs_lt_one_iff /-
@[simp]
theorem abs_lt_one_iff {a : ℤ} : |a| < 1 ↔ a = 0 :=
⟨fun a0 =>
@@ -161,14 +174,19 @@ theorem abs_lt_one_iff {a : ℤ} : |a| < 1 ↔ a = 0 :=
(le_of_lt_add_one hp).antisymm hn,
fun a0 => (abs_eq_zero.mpr a0).le.trans_lt zero_lt_one⟩
#align int.abs_lt_one_iff Int.abs_lt_one_iff
+-/
+#print Int.abs_le_one_iff /-
theorem 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' ℤ)]
#align int.abs_le_one_iff Int.abs_le_one_iff
+-/
+#print Int.one_le_abs /-
theorem one_le_abs {z : ℤ} (h₀ : z ≠ 0) : 1 ≤ |z| :=
add_one_le_iff.mpr (abs_pos.mpr h₀)
#align int.one_le_abs Int.one_le_abs
+-/
#print Int.inductionOn' /-
/-- Inductively define a function on `ℤ` by defining it at `b`, for the `succ` of a number greater
@@ -230,6 +248,7 @@ variable {a b : ℤ} {n : ℕ}
attribute [simp] nat_abs nat_abs_of_nat nat_abs_zero nat_abs_one
+#print Int.natAbs_dvd_natAbs /-
@[simp]
theorem natAbs_dvd_natAbs {a b : ℤ} : a.natAbs ∣ b.natAbs ↔ a ∣ b :=
by
@@ -238,6 +257,7 @@ theorem natAbs_dvd_natAbs {a b : ℤ} : a.natAbs ∣ b.natAbs ↔ a ∣ b :=
rw [← nat_abs_of_nat k, ← nat_abs_mul, nat_abs_eq_nat_abs_iff, neg_mul_eq_mul_neg] at hk
cases hk <;> exact ⟨_, hk⟩
#align int.nat_abs_dvd_iff_dvd Int.natAbs_dvd_natAbs
+-/
/-! ### `/` -/
@@ -249,11 +269,13 @@ protected theorem ediv_nonpos {a b : ℤ} (Ha : 0 ≤ a) (Hb : b ≤ 0) : a / b
#align int.div_nonpos Int.ediv_nonpos
-/
+#print Int.ediv_eq_zero_of_lt_abs /-
theorem ediv_eq_zero_of_lt_abs {a b : ℤ} (H1 : 0 ≤ a) (H2 : a < |b|) : a / b = 0 :=
match b, |b|, abs_eq_natAbs b, H2 with
| (n : ℕ), _, rfl, H2 => div_eq_zero_of_lt H1 H2
| -[n+1], _, rfl, H2 => neg_injective <| by rw [← Int.div_neg] <;> exact div_eq_zero_of_lt H1 H2
#align int.div_eq_zero_of_lt_abs Int.ediv_eq_zero_of_lt_abs
+-/
#print Int.add_mul_ediv_right /-
protected theorem add_mul_ediv_right (a b : ℤ) {c : ℤ} (H : c ≠ 0) : (a + b * c) / c = a / c + b :=
@@ -317,6 +339,7 @@ protected theorem ediv_self {a : ℤ} (H : a ≠ 0) : a / a = 1 := by
attribute [local simp] Int.zero_div Int.div_zero
+#print Int.add_ediv_of_dvd_right /-
protected theorem add_ediv_of_dvd_right {a b c : ℤ} (H : c ∣ b) : (a + b) / c = a / c + b / c :=
by
by_cases h1 : c = 0
@@ -327,18 +350,23 @@ protected theorem add_ediv_of_dvd_right {a b c : ℤ} (H : c ∣ b) : (a + b) /
rw [mul_comm c k, Int.add_mul_ediv_right _ _ h1, ← zero_add (k * c),
Int.add_mul_ediv_right _ _ h1, Int.zero_div, zero_add]
#align int.add_div_of_dvd_right Int.add_ediv_of_dvd_right
+-/
+#print Int.add_ediv_of_dvd_left /-
protected theorem add_ediv_of_dvd_left {a b c : ℤ} (H : c ∣ a) : (a + b) / c = a / c + b / c := by
rw [add_comm, Int.add_ediv_of_dvd_right H, add_comm]
#align int.add_div_of_dvd_left Int.add_ediv_of_dvd_left
+-/
/-! ### mod -/
+#print Int.emod_abs /-
@[simp]
theorem emod_abs (a b : ℤ) : a % |b| = a % b :=
abs_by_cases (fun i => a % i = a % b) rfl (mod_neg _ _)
#align int.mod_abs Int.emod_abs
+-/
#print Int.emod_nonneg /-
theorem emod_nonneg : ∀ (a : ℤ) {b : ℤ}, b ≠ 0 → 0 ≤ a % b
@@ -356,9 +384,11 @@ theorem emod_lt_of_pos (a : ℤ) {b : ℤ} (H : 0 < b) : a % b < b :=
#align int.mod_lt_of_pos Int.emod_lt_of_pos
-/
+#print Int.emod_lt /-
theorem emod_lt (a : ℤ) {b : ℤ} (H : b ≠ 0) : a % b < |b| := by
rw [← mod_abs] <;> exact mod_lt_of_pos _ (abs_pos.2 H)
#align int.mod_lt Int.emod_lt
+-/
#print Int.add_mul_emod_self /-
@[simp]
@@ -471,6 +501,7 @@ theorem emod_self {a : ℤ} : a % a = 0 := by have := mul_mod_left 1 a <;> rwa [
#align int.mod_self Int.emod_self
-/
+#print Int.emod_emod_of_dvd /-
@[simp]
theorem emod_emod_of_dvd (n : ℤ) {m k : ℤ} (h : m ∣ k) : n % k % m = n % m :=
by
@@ -479,6 +510,7 @@ theorem emod_emod_of_dvd (n : ℤ) {m k : ℤ} (h : m ∣ k) : n % k % m = n % m
rw [← mod_add_div n k]
rcases h with ⟨t, rfl⟩; rw [mul_assoc, add_mul_mod_self_left]
#align int.mod_mod_of_dvd Int.emod_emod_of_dvd
+-/
#print Int.emod_emod /-
@[simp]
@@ -542,6 +574,7 @@ theorem lt_ediv_add_one_mul_self (a : ℤ) {b : ℤ} (H : 0 < b) : a < (a / b +
#align int.lt_div_add_one_mul_self Int.lt_ediv_add_one_mul_self
-/
+#print Int.abs_ediv_le_abs /-
theorem abs_ediv_le_abs : ∀ a b : ℤ, |a / b| ≤ |a| :=
suffices ∀ (a : ℤ) (n : ℕ), |a / n| ≤ |a| from fun a b =>
match b, eq_nat_or_neg b with
@@ -556,6 +589,7 @@ theorem abs_ediv_le_abs : ∀ a b : ℤ, |a / b| ≤ |a| :=
| -[m+1], 0 => Nat.zero_le _
| -[m+1], n + 1 => Nat.succ_le_succ (Nat.div_le_self _ _))
#align int.abs_div_le_abs Int.abs_ediv_le_abs
+-/
#print Int.ediv_le_self /-
theorem ediv_le_self {a : ℤ} (b : ℤ) (Ha : 0 ≤ a) : a / b ≤ a := by
@@ -578,18 +612,25 @@ theorem emod_two_eq_zero_or_one (n : ℤ) : n % 2 = 0 ∨ n % 2 = 1 :=
/-! ### dvd -/
+#print Int.dvd_of_emod_eq_zero /-
theorem dvd_of_emod_eq_zero {a b : ℤ} (H : b % a = 0) : a ∣ b :=
⟨b / a, (mul_div_cancel_of_mod_eq_zero H).symm⟩
#align int.dvd_of_mod_eq_zero Int.dvd_of_emod_eq_zero
+-/
+#print Int.emod_eq_zero_of_dvd /-
theorem emod_eq_zero_of_dvd : ∀ {a b : ℤ}, a ∣ b → b % a = 0
| a, _, ⟨c, rfl⟩ => mul_emod_right _ _
#align int.mod_eq_zero_of_dvd Int.emod_eq_zero_of_dvd
+-/
+#print Int.dvd_iff_emod_eq_zero /-
theorem dvd_iff_emod_eq_zero (a b : ℤ) : a ∣ b ↔ b % a = 0 :=
⟨emod_eq_zero_of_dvd, dvd_of_emod_eq_zero⟩
#align int.dvd_iff_mod_eq_zero Int.dvd_iff_emod_eq_zero
+-/
+#print Int.dvd_sub_of_emod_eq /-
/-- If `a % b = c` then `b` divides `a - c`. -/
theorem dvd_sub_of_emod_eq {a b c : ℤ} (h : a % b = c) : b ∣ a - c :=
by
@@ -597,27 +638,39 @@ theorem dvd_sub_of_emod_eq {a b c : ℤ} (h : a % b = c) : b ∣ a - c :=
rw [mod_mod, ← mod_sub_cancel_right c, sub_self, zero_mod] at hx
exact dvd_of_mod_eq_zero hx
#align int.dvd_sub_of_mod_eq Int.dvd_sub_of_emod_eq
+-/
+#print Int.natAbs_dvd /-
theorem natAbs_dvd {a b : ℤ} : (a.natAbs : ℤ) ∣ b ↔ a ∣ b :=
(natAbs_eq a).elim (fun e => by rw [← e]) fun e => by rw [← neg_dvd, ← e]
#align int.nat_abs_dvd Int.natAbs_dvd
+-/
+#print Int.dvd_natAbs /-
theorem dvd_natAbs {a b : ℤ} : a ∣ b.natAbs ↔ a ∣ b :=
(natAbs_eq b).elim (fun e => by rw [← e]) fun e => by rw [← dvd_neg, ← e]
#align int.dvd_nat_abs Int.dvd_natAbs
+-/
+#print Int.decidableDvd /-
instance decidableDvd : @DecidableRel ℤ (· ∣ ·) := fun a n =>
decidable_of_decidable_of_iff (by infer_instance) (dvd_iff_emod_eq_zero _ _).symm
#align int.decidable_dvd Int.decidableDvd
+-/
+#print Int.ediv_mul_cancel /-
protected theorem ediv_mul_cancel {a b : ℤ} (H : b ∣ a) : a / b * b = a :=
div_mul_cancel_of_mod_eq_zero (emod_eq_zero_of_dvd H)
#align int.div_mul_cancel Int.ediv_mul_cancel
+-/
+#print Int.mul_ediv_cancel' /-
protected theorem mul_ediv_cancel' {a b : ℤ} (H : a ∣ b) : a * (b / a) = b := by
rw [mul_comm, Int.ediv_mul_cancel H]
#align int.mul_div_cancel' Int.mul_ediv_cancel'
+-/
+#print Int.ediv_dvd_ediv /-
theorem ediv_dvd_ediv : ∀ {a b c : ℤ} (H1 : a ∣ b) (H2 : b ∣ c), b / a ∣ c / a
| a, _, _, ⟨b, rfl⟩, ⟨c, rfl⟩ =>
if az : a = 0 then by simp [az]
@@ -625,10 +678,13 @@ theorem ediv_dvd_ediv : ∀ {a b c : ℤ} (H1 : a ∣ b) (H2 : b ∣ c), b / a
rw [Int.mul_ediv_cancel_left _ az, mul_assoc, Int.mul_ediv_cancel_left _ az] <;>
apply dvd_mul_right
#align int.div_dvd_div Int.ediv_dvd_ediv
+-/
+#print Int.eq_mul_of_ediv_eq_right /-
protected theorem eq_mul_of_ediv_eq_right {a b c : ℤ} (H1 : b ∣ a) (H2 : a / b = c) : a = b * c :=
by rw [← H2, Int.mul_ediv_cancel' H1]
#align int.eq_mul_of_div_eq_right Int.eq_mul_of_ediv_eq_right
+-/
#print Int.ediv_eq_of_eq_mul_right /-
protected theorem ediv_eq_of_eq_mul_right {a b c : ℤ} (H1 : b ≠ 0) (H2 : a = b * c) : a / b = c :=
@@ -642,18 +698,24 @@ protected theorem eq_ediv_of_mul_eq_right {a b c : ℤ} (H1 : a ≠ 0) (H2 : a *
#align int.eq_div_of_mul_eq_right Int.eq_ediv_of_mul_eq_right
-/
+#print Int.ediv_eq_iff_eq_mul_right /-
protected theorem ediv_eq_iff_eq_mul_right {a b c : ℤ} (H : b ≠ 0) (H' : b ∣ a) :
a / b = c ↔ a = b * c :=
⟨Int.eq_mul_of_ediv_eq_right H', Int.ediv_eq_of_eq_mul_right H⟩
#align int.div_eq_iff_eq_mul_right Int.ediv_eq_iff_eq_mul_right
+-/
+#print Int.ediv_eq_iff_eq_mul_left /-
protected theorem ediv_eq_iff_eq_mul_left {a b c : ℤ} (H : b ≠ 0) (H' : b ∣ a) :
a / b = c ↔ a = c * b := by rw [mul_comm] <;> exact Int.ediv_eq_iff_eq_mul_right H H'
#align int.div_eq_iff_eq_mul_left Int.ediv_eq_iff_eq_mul_left
+-/
+#print Int.eq_mul_of_ediv_eq_left /-
protected theorem eq_mul_of_ediv_eq_left {a b c : ℤ} (H1 : b ∣ a) (H2 : a / b = c) : a = c * b := by
rw [mul_comm, Int.eq_mul_of_ediv_eq_right H1 H2]
#align int.eq_mul_of_div_eq_left Int.eq_mul_of_ediv_eq_left
+-/
#print Int.ediv_eq_of_eq_mul_left /-
protected theorem ediv_eq_of_eq_mul_left {a b c : ℤ} (H1 : b ≠ 0) (H2 : a = c * b) : a / b = c :=
@@ -661,21 +723,28 @@ protected theorem ediv_eq_of_eq_mul_left {a b c : ℤ} (H1 : b ≠ 0) (H2 : a =
#align int.div_eq_of_eq_mul_left Int.ediv_eq_of_eq_mul_left
-/
+#print Int.eq_zero_of_ediv_eq_zero /-
protected theorem eq_zero_of_ediv_eq_zero {d n : ℤ} (h : d ∣ n) (H : n / d = 0) : n = 0 := by
rw [← Int.mul_ediv_cancel' h, H, MulZeroClass.mul_zero]
#align int.eq_zero_of_div_eq_zero Int.eq_zero_of_ediv_eq_zero
+-/
+#print Int.ediv_left_inj /-
@[simp]
protected theorem ediv_left_inj {a b d : ℤ} (hda : d ∣ a) (hdb : d ∣ b) : a / d = b / d ↔ a = b :=
by
refine' ⟨fun h => _, congr_arg _⟩
rw [← Int.mul_ediv_cancel' hda, ← Int.mul_ediv_cancel' hdb, h]
#align int.div_left_inj Int.ediv_left_inj
+-/
+#print Int.abs_sign_of_nonzero /-
theorem abs_sign_of_nonzero {z : ℤ} (hz : z ≠ 0) : |z.sign| = 1 := by
rw [abs_eq_nat_abs, nat_abs_sign_of_nonzero hz, Int.ofNat_one]
#align int.abs_sign_of_nonzero Int.abs_sign_of_nonzero
+-/
+#print Int.exists_lt_and_lt_iff_not_dvd /-
/-- If `n > 0` then `m` is not divisible by `n` iff it is between `n * k` and `n * (k + 1)`
for some `k`. -/
theorem exists_lt_and_lt_iff_not_dvd (m : ℤ) {n : ℤ} (hn : 0 < n) :
@@ -690,40 +759,53 @@ theorem exists_lt_and_lt_iff_not_dvd (m : ℤ) {n : ℤ} (hn : 0 < n) :
refine' ⟨m / n, lt_add_of_pos_left _ this, _⟩
rw [add_comm _ (1 : ℤ), left_distrib, mul_one]; exact add_lt_add_right (mod_lt_of_pos _ hn) _
#align int.exists_lt_and_lt_iff_not_dvd Int.exists_lt_and_lt_iff_not_dvd
+-/
attribute [local simp] Int.div_zero
+#print Int.mul_ediv_assoc /-
protected theorem mul_ediv_assoc (a : ℤ) : ∀ {b c : ℤ}, c ∣ b → a * b / c = a * (b / c)
| _, c, ⟨d, rfl⟩ =>
if cz : c = 0 then by simp [cz]
else by rw [mul_left_comm, Int.mul_ediv_cancel_left _ cz, Int.mul_ediv_cancel_left _ cz]
#align int.mul_div_assoc Int.mul_ediv_assoc
+-/
+#print Int.mul_ediv_assoc' /-
protected theorem mul_ediv_assoc' (b : ℤ) {a c : ℤ} (h : c ∣ a) : a * b / c = a / c * b := by
rw [mul_comm, Int.mul_ediv_assoc _ h, mul_comm]
#align int.mul_div_assoc' Int.mul_ediv_assoc'
+-/
+#print Int.neg_ediv_of_dvd /-
theorem neg_ediv_of_dvd : ∀ {a b : ℤ} (H : b ∣ a), -a / b = -(a / b)
| _, b, ⟨c, rfl⟩ =>
if bz : b = 0 then by simp [bz]
else by rw [neg_mul_eq_mul_neg, Int.mul_ediv_cancel_left _ bz, Int.mul_ediv_cancel_left _ bz]
#align int.neg_div_of_dvd Int.neg_ediv_of_dvd
+-/
+#print Int.sub_ediv_of_dvd /-
theorem sub_ediv_of_dvd (a : ℤ) {b c : ℤ} (hcb : c ∣ b) : (a - b) / c = a / c - b / c :=
by
rw [sub_eq_add_neg, sub_eq_add_neg, Int.add_ediv_of_dvd_right hcb.neg_right]
congr
exact neg_div_of_dvd hcb
#align int.sub_div_of_dvd Int.sub_ediv_of_dvd
+-/
+#print Int.sub_ediv_of_dvd_sub /-
theorem sub_ediv_of_dvd_sub {a b c : ℤ} (hcab : c ∣ a - b) : (a - b) / c = a / c - b / c := by
rw [eq_sub_iff_add_eq, ← Int.add_ediv_of_dvd_left hcab, sub_add_cancel]
#align int.sub_div_of_dvd_sub Int.sub_ediv_of_dvd_sub
+-/
+#print Int.sign_eq_ediv_abs /-
protected theorem sign_eq_ediv_abs (a : ℤ) : sign a = a / |a| :=
if az : a = 0 then by simp [az]
else (Int.ediv_eq_of_eq_mul_left (mt abs_eq_zero.1 az) (sign_mul_abs _).symm).symm
#align int.sign_eq_div_abs Int.sign_eq_ediv_abs
+-/
/-! ### `/` and ordering -/
@@ -789,34 +871,47 @@ protected theorem ediv_lt_iff_lt_mul {a b c : ℤ} (H : 0 < c) : a / c < b ↔ a
#align int.div_lt_iff_lt_mul Int.ediv_lt_iff_lt_mul
-/
+#print Int.le_mul_of_ediv_le /-
protected theorem le_mul_of_ediv_le {a b c : ℤ} (H1 : 0 ≤ b) (H2 : b ∣ a) (H3 : a / b ≤ c) :
a ≤ c * b := by rw [← Int.ediv_mul_cancel H2] <;> exact mul_le_mul_of_nonneg_right H3 H1
#align int.le_mul_of_div_le Int.le_mul_of_ediv_le
+-/
+#print Int.lt_ediv_of_mul_lt /-
protected theorem lt_ediv_of_mul_lt {a b c : ℤ} (H1 : 0 ≤ b) (H2 : b ∣ c) (H3 : a * b < c) :
a < c / b :=
lt_of_not_ge <| mt (Int.le_mul_of_ediv_le H1 H2) (not_le_of_gt H3)
#align int.lt_div_of_mul_lt Int.lt_ediv_of_mul_lt
+-/
+#print Int.lt_ediv_iff_mul_lt /-
protected theorem lt_ediv_iff_mul_lt {a b : ℤ} (c : ℤ) (H : 0 < c) (H' : c ∣ b) :
a < b / c ↔ a * c < b :=
⟨Int.mul_lt_of_lt_ediv H, Int.lt_ediv_of_mul_lt (le_of_lt H) H'⟩
#align int.lt_div_iff_mul_lt Int.lt_ediv_iff_mul_lt
+-/
+#print Int.ediv_pos_of_pos_of_dvd /-
theorem ediv_pos_of_pos_of_dvd {a b : ℤ} (H1 : 0 < a) (H2 : 0 ≤ b) (H3 : b ∣ a) : 0 < a / b :=
Int.lt_ediv_of_mul_lt H2 H3 (by rwa [MulZeroClass.zero_mul])
#align int.div_pos_of_pos_of_dvd Int.ediv_pos_of_pos_of_dvd
+-/
+#print Int.natAbs_eq_of_dvd_dvd /-
theorem natAbs_eq_of_dvd_dvd {s t : ℤ} (hst : s ∣ t) (hts : t ∣ s) : natAbs s = natAbs t :=
Nat.dvd_antisymm (natAbs_dvd_natAbs.mpr hst) (natAbs_dvd_natAbs.mpr hts)
#align int.nat_abs_eq_of_dvd_dvd Int.natAbs_eq_of_dvd_dvd
+-/
+#print Int.ediv_eq_ediv_of_mul_eq_mul /-
theorem ediv_eq_ediv_of_mul_eq_mul {a b c d : ℤ} (H2 : d ∣ c) (H3 : b ≠ 0) (H4 : d ≠ 0)
(H5 : a * d = b * c) : a / b = c / d :=
Int.ediv_eq_of_eq_mul_right H3 <| by
rw [← Int.mul_ediv_assoc _ H2] <;> exact (Int.ediv_eq_of_eq_mul_left H4 H5.symm).symm
#align int.div_eq_div_of_mul_eq_mul Int.ediv_eq_ediv_of_mul_eq_mul
+-/
+#print Int.ediv_dvd_of_dvd /-
theorem ediv_dvd_of_dvd {s t : ℤ} (hst : s ∣ t) : t / s ∣ t :=
by
rcases eq_or_ne s 0 with (rfl | hs)
@@ -824,6 +919,7 @@ theorem ediv_dvd_of_dvd {s t : ℤ} (hst : s ∣ t) : t / s ∣ t :=
rcases hst with ⟨c, hc⟩
simp [hc, Int.mul_ediv_cancel_left _ hs]
#align int.div_dvd_of_dvd Int.ediv_dvd_of_dvd
+-/
/-! ### to_nat -/
mathlib commit https://github.com/leanprover-community/mathlib/commit/7e5137f579de09a059a5ce98f364a04e221aabf0
@@ -884,13 +884,11 @@ theorem toNat_eq_zero : ∀ {n : ℤ}, n.toNat = 0 ↔ n ≤ 0
calc
_ ↔ n = 0 := ⟨(toNat_coe_nat n).symm.trans, (toNat_coe_nat n).trans⟩
_ ↔ _ := coe_nat_nonpos_iff.symm
-
| -[n+1] =>
show (-((n : ℤ) + 1)).toNat = 0 ↔ (-(n + 1) : ℤ) ≤ 0 from
calc
_ ↔ True := ⟨fun _ => trivial, fun h => toNat_neg_nat _⟩
_ ↔ _ := ⟨fun h => neg_nonpos_of_nonneg (ofNat_zero_le _), fun _ => trivial⟩
-
#align int.to_nat_eq_zero Int.toNat_eq_zero
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/cca40788df1b8755d5baf17ab2f27dacc2e17acb
@@ -200,7 +200,7 @@ protected theorem le_induction {P : ℤ → Prop} {m : ℤ} (h0 : P m)
(h1 : ∀ n : ℤ, m ≤ n → P n → P (n + 1)) (n : ℤ) : m ≤ n → P n :=
by
apply Int.inductionOn' n m
- · intro ; exact h0
+ · intro; exact h0
· intro k hle hi _; exact h1 k hle (hi hle)
· intro _ hle _ hle'
exfalso
@@ -214,7 +214,7 @@ protected theorem le_induction_down {P : ℤ → Prop} {m : ℤ} (h0 : P m)
(h1 : ∀ n : ℤ, n ≤ m → P n → P (n - 1)) (n : ℤ) : n ≤ m → P n :=
by
apply Int.inductionOn' n m
- · intro ; exact h0
+ · intro; exact h0
· intro _ hle _ hle'
exfalso
exact lt_irrefl k (add_one_le_iff.mp (hle'.trans hle))
@@ -235,7 +235,7 @@ theorem natAbs_dvd_natAbs {a b : ℤ} : a.natAbs ∣ b.natAbs ↔ a ∣ b :=
by
refine' ⟨_, fun ⟨k, hk⟩ => ⟨k.natAbs, hk.symm ▸ nat_abs_mul a k⟩⟩
rintro ⟨k, hk⟩
- rw [← nat_abs_of_nat k, ← nat_abs_mul, nat_abs_eq_nat_abs_iff, neg_mul_eq_mul_neg] at hk
+ rw [← nat_abs_of_nat k, ← nat_abs_mul, nat_abs_eq_nat_abs_iff, neg_mul_eq_mul_neg] at hk
cases hk <;> exact ⟨_, hk⟩
#align int.nat_abs_dvd_iff_dvd Int.natAbs_dvd_natAbs
@@ -297,7 +297,7 @@ protected theorem add_mul_ediv_left (a : ℤ) {b : ℤ} (c : ℤ) (H : b ≠ 0)
#print Int.mul_ediv_cancel /-
@[simp]
protected theorem mul_ediv_cancel (a : ℤ) {b : ℤ} (H : b ≠ 0) : a * b / b = a := by
- have := Int.add_mul_ediv_right 0 a H <;> rwa [zero_add, Int.zero_div, zero_add] at this
+ have := Int.add_mul_ediv_right 0 a H <;> rwa [zero_add, Int.zero_div, zero_add] at this
#align int.mul_div_cancel Int.mul_ediv_cancel
-/
@@ -311,7 +311,7 @@ protected theorem mul_ediv_cancel_left {a : ℤ} (b : ℤ) (H : a ≠ 0) : a * b
#print Int.ediv_self /-
@[simp]
protected theorem ediv_self {a : ℤ} (H : a ≠ 0) : a / a = 1 := by
- have := Int.mul_ediv_cancel 1 H <;> rwa [one_mul] at this
+ have := Int.mul_ediv_cancel 1 H <;> rwa [one_mul] at this
#align int.div_self Int.ediv_self
-/
@@ -323,7 +323,7 @@ protected theorem add_ediv_of_dvd_right {a b c : ℤ} (H : c ∣ b) : (a + b) /
· simp [h1]
cases' H with k hk
rw [hk]
- change c ≠ 0 at h1
+ change c ≠ 0 at h1
rw [mul_comm c k, Int.add_mul_ediv_right _ _ h1, ← zero_add (k * c),
Int.add_mul_ediv_right _ _ h1, Int.zero_div, zero_add]
#align int.add_div_of_dvd_right Int.add_ediv_of_dvd_right
@@ -380,7 +380,7 @@ theorem add_mul_emod_self_left (a b c : ℤ) : (a + b * c) % b = a % b := by
#print Int.add_emod_self /-
@[simp]
theorem add_emod_self {a b : ℤ} : (a + b) % b = a % b := by
- have := add_mul_mod_self_left a b 1 <;> rwa [mul_one] at this
+ have := add_mul_mod_self_left a b 1 <;> rwa [mul_one] at this
#align int.add_mod_self Int.add_emod_self
-/
@@ -394,7 +394,7 @@ theorem add_emod_self_left {a b : ℤ} : (a + b) % a = b % a := by rw [add_comm,
@[simp]
theorem emod_add_emod (m n k : ℤ) : (m % n + k) % n = (m + k) % n := by
have := (add_mul_mod_self_left (m % n + k) n (m / n)).symm <;>
- rwa [add_right_comm, mod_add_div] at this
+ rwa [add_right_comm, mod_add_div] at this
#align int.mod_add_mod Int.emod_add_emod
-/
@@ -426,7 +426,7 @@ theorem add_emod_eq_add_emod_left {m n k : ℤ} (i : ℤ) (H : m % n = k % n) :
theorem emod_add_cancel_right {m n k : ℤ} (i) : (m + i) % n = (k + i) % n ↔ m % n = k % n :=
⟨fun H => by
have := add_mod_eq_add_mod_right (-i) H <;>
- rwa [add_neg_cancel_right, add_neg_cancel_right] at this,
+ rwa [add_neg_cancel_right, add_neg_cancel_right] at this ,
add_emod_eq_add_emod_right _⟩
#align int.mod_add_cancel_right Int.emod_add_cancel_right
-/
@@ -467,7 +467,7 @@ theorem mul_emod (a b n : ℤ) : a * b % n = a % n * (b % n) % n := by
#print Int.emod_self /-
-- Will be generalized to Euclidean domains.
@[local simp]
-theorem emod_self {a : ℤ} : a % a = 0 := by have := mul_mod_left 1 a <;> rwa [one_mul] at this
+theorem emod_self {a : ℤ} : a % a = 0 := by have := mul_mod_left 1 a <;> rwa [one_mul] at this
#align int.mod_self Int.emod_self
-/
@@ -559,7 +559,7 @@ theorem abs_ediv_le_abs : ∀ a b : ℤ, |a / b| ≤ |a| :=
#print Int.ediv_le_self /-
theorem ediv_le_self {a : ℤ} (b : ℤ) (Ha : 0 ≤ a) : a / b ≤ a := by
- have := le_trans (le_abs_self _) (abs_div_le_abs a b) <;> rwa [abs_of_nonneg Ha] at this
+ have := le_trans (le_abs_self _) (abs_div_le_abs a b) <;> rwa [abs_of_nonneg Ha] at this
#align int.div_le_self Int.ediv_le_self
-/
@@ -594,7 +594,7 @@ theorem dvd_iff_emod_eq_zero (a b : ℤ) : a ∣ b ↔ b % a = 0 :=
theorem dvd_sub_of_emod_eq {a b c : ℤ} (h : a % b = c) : b ∣ a - c :=
by
have hx : a % b % b = c % b := by rw [h]
- rw [mod_mod, ← mod_sub_cancel_right c, sub_self, zero_mod] at hx
+ rw [mod_mod, ← mod_sub_cancel_right c, sub_self, zero_mod] at hx
exact dvd_of_mod_eq_zero hx
#align int.dvd_sub_of_mod_eq Int.dvd_sub_of_emod_eq
@@ -682,9 +682,9 @@ theorem exists_lt_and_lt_iff_not_dvd (m : ℤ) {n : ℤ} (hn : 0 < n) :
(∃ k, n * k < m ∧ m < n * (k + 1)) ↔ ¬n ∣ m :=
by
constructor
- · rintro ⟨k, h1k, h2k⟩ ⟨l, rfl⟩; rw [mul_lt_mul_left hn] at h1k h2k
- rw [lt_add_one_iff, ← not_lt] at h2k; exact h2k h1k
- · intro h; rw [dvd_iff_mod_eq_zero, ← Ne.def] at h
+ · rintro ⟨k, h1k, h2k⟩ ⟨l, rfl⟩; rw [mul_lt_mul_left hn] at h1k h2k
+ rw [lt_add_one_iff, ← not_lt] at h2k ; exact h2k h1k
+ · intro h; rw [dvd_iff_mod_eq_zero, ← Ne.def] at h
have := (mod_nonneg m hn.ne.symm).lt_of_ne h.symm
simp (config := { singlePass := true }) only [← mod_add_div m n]
refine' ⟨m / n, lt_add_of_pos_left _ this, _⟩
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -63,53 +63,23 @@ end Int
namespace Int
-/- warning: int.abs_eq_nat_abs -> Int.abs_eq_natAbs is a dubious translation:
-lean 3 declaration is
- forall (a : Int), Eq.{1} Int (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) a) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (Int.natAbs a))
-but is expected to have type
- forall (a : Int), Eq.{1} Int (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) a) (Nat.cast.{0} Int instNatCastInt (Int.natAbs a))
-Case conversion may be inaccurate. Consider using '#align int.abs_eq_nat_abs Int.abs_eq_natAbsₓ'. -/
theorem abs_eq_natAbs : ∀ a : ℤ, |a| = natAbs a
| (n : ℕ) => abs_of_nonneg <| ofNat_zero_le _
| -[n+1] => abs_of_nonpos <| le_of_lt <| negSucc_lt_zero _
#align int.abs_eq_nat_abs Int.abs_eq_natAbs
-/- warning: int.coe_nat_abs -> Int.coe_natAbs is a dubious translation:
-lean 3 declaration is
- forall (n : Int), Eq.{1} Int ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (Int.natAbs n)) (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) n)
-but is expected to have type
- forall (n : Int), Eq.{1} Int (Nat.cast.{0} Int instNatCastInt (Int.natAbs n)) (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) n)
-Case conversion may be inaccurate. Consider using '#align int.coe_nat_abs Int.coe_natAbsₓ'. -/
@[simp, norm_cast]
theorem coe_natAbs (n : ℤ) : (n.natAbs : ℤ) = |n| :=
n.abs_eq_natAbs.symm
#align int.coe_nat_abs Int.coe_natAbs
-/- warning: nat.cast_nat_abs -> Nat.cast_natAbs is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} [_inst_1 : AddGroupWithOne.{u1} α] (n : Int), Eq.{succ u1} α ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α _inst_1))))) (Int.natAbs n)) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Int α (HasLiftT.mk.{1, succ u1} Int α (CoeTCₓ.coe.{1, succ u1} Int α (Int.castCoe.{u1} α (AddGroupWithOne.toHasIntCast.{u1} α _inst_1)))) (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) n))
-but is expected to have type
- forall {α : Type.{u1}} [_inst_1 : AddGroupWithOne.{u1} α] (n : Int), Eq.{succ u1} α (Nat.cast.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α _inst_1)) (Int.natAbs n)) (Int.cast.{u1} α (AddGroupWithOne.toIntCast.{u1} α _inst_1) (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) n))
-Case conversion may be inaccurate. Consider using '#align nat.cast_nat_abs Nat.cast_natAbsₓ'. -/
theorem Nat.cast_natAbs {α : Type _} [AddGroupWithOne α] (n : ℤ) : (n.natAbs : α) = ↑(|n|) := by
rw [← Int.coe_natAbs, Int.cast_ofNat]
#align nat.cast_nat_abs Nat.cast_natAbs
-/- warning: int.nat_abs_abs -> Int.natAbs_abs is a dubious translation:
-lean 3 declaration is
- forall (a : Int), Eq.{1} Nat (Int.natAbs (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) a)) (Int.natAbs a)
-but is expected to have type
- forall (a : Int), Eq.{1} Nat (Int.natAbs (Abs.abs.{0} ([mdata borrowed:1 Int]) (Neg.toHasAbs.{0} ([mdata borrowed:1 Int]) Int.instNegInt (SemilatticeSup.toSup.{0} ([mdata borrowed:1 Int]) (Lattice.toSemilatticeSup.{0} ([mdata borrowed:1 Int]) (DistribLattice.toLattice.{0} ([mdata borrowed:1 Int]) (instDistribLattice.{0} ([mdata borrowed:1 Int]) Int.instLinearOrderInt))))) a)) (Int.natAbs a)
-Case conversion may be inaccurate. Consider using '#align int.nat_abs_abs Int.natAbs_absₓ'. -/
theorem natAbs_abs (a : ℤ) : natAbs (|a|) = natAbs a := by rw [abs_eq_nat_abs] <;> rfl
#align int.nat_abs_abs Int.natAbs_abs
-/- warning: int.sign_mul_abs -> Int.sign_mul_abs is a dubious translation:
-lean 3 declaration is
- forall (a : Int), Eq.{1} Int (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) (Int.sign a) (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) a)) a
-but is expected to have type
- forall (a : Int), Eq.{1} Int (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) (Int.sign a) (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) a)) a
-Case conversion may be inaccurate. Consider using '#align int.sign_mul_abs Int.sign_mul_absₓ'. -/
theorem sign_mul_abs (a : ℤ) : sign a * |a| = a := by rw [abs_eq_nat_abs, sign_mul_nat_abs]
#align int.sign_mul_abs Int.sign_mul_abs
@@ -130,12 +100,6 @@ theorem coe_nat_ne_zero_iff_pos {n : ℕ} : (n : ℤ) ≠ 0 ↔ 0 < n :=
#align int.coe_nat_ne_zero_iff_pos Int.coe_nat_ne_zero_iff_pos
-/
-/- warning: int.abs_coe_nat -> Int.abs_coe_nat is a dubious translation:
-lean 3 declaration is
- forall (n : Nat), Eq.{1} Int (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) n)) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) n)
-but is expected to have type
- forall (n : Nat), Eq.{1} Int (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) (Nat.cast.{0} Int instNatCastInt n)) (Nat.cast.{0} Int instNatCastInt n)
-Case conversion may be inaccurate. Consider using '#align int.abs_coe_nat Int.abs_coe_natₓ'. -/
@[norm_cast]
theorem abs_coe_nat (n : ℕ) : |(n : ℤ)| = n :=
abs_of_nonneg (coe_nat_nonneg n)
@@ -190,12 +154,6 @@ theorem le_sub_one_iff {a b : ℤ} : a ≤ b - 1 ↔ a < b :=
#align int.le_sub_one_iff Int.le_sub_one_iff
-/
-/- warning: int.abs_lt_one_iff -> Int.abs_lt_one_iff is a dubious translation:
-lean 3 declaration is
- forall {a : Int}, Iff (LT.lt.{0} Int Int.hasLt (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) a) (OfNat.ofNat.{0} Int 1 (OfNat.mk.{0} Int 1 (One.one.{0} Int Int.hasOne)))) (Eq.{1} Int a (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero))))
-but is expected to have type
- forall {a : Int}, Iff (LT.lt.{0} Int Int.instLTInt (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) a) (OfNat.ofNat.{0} Int 1 (instOfNatInt 1))) (Eq.{1} Int a (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)))
-Case conversion may be inaccurate. Consider using '#align int.abs_lt_one_iff Int.abs_lt_one_iffₓ'. -/
@[simp]
theorem abs_lt_one_iff {a : ℤ} : |a| < 1 ↔ a = 0 :=
⟨fun a0 =>
@@ -204,22 +162,10 @@ theorem abs_lt_one_iff {a : ℤ} : |a| < 1 ↔ a = 0 :=
fun a0 => (abs_eq_zero.mpr a0).le.trans_lt zero_lt_one⟩
#align int.abs_lt_one_iff Int.abs_lt_one_iff
-/- warning: int.abs_le_one_iff -> Int.abs_le_one_iff is a dubious translation:
-lean 3 declaration is
- forall {a : Int}, Iff (LE.le.{0} Int Int.hasLe (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) a) (OfNat.ofNat.{0} Int 1 (OfNat.mk.{0} Int 1 (One.one.{0} Int Int.hasOne)))) (Or (Eq.{1} Int a (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero)))) (Or (Eq.{1} Int a (OfNat.ofNat.{0} Int 1 (OfNat.mk.{0} Int 1 (One.one.{0} Int Int.hasOne)))) (Eq.{1} Int a (Neg.neg.{0} Int Int.hasNeg (OfNat.ofNat.{0} Int 1 (OfNat.mk.{0} Int 1 (One.one.{0} Int Int.hasOne)))))))
-but is expected to have type
- forall {a : Int}, Iff (LE.le.{0} Int Int.instLEInt (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) a) (OfNat.ofNat.{0} Int 1 (instOfNatInt 1))) (Or (Eq.{1} Int a (OfNat.ofNat.{0} Int 0 (instOfNatInt 0))) (Or (Eq.{1} Int a (OfNat.ofNat.{0} Int 1 (instOfNatInt 1))) (Eq.{1} Int a (Neg.neg.{0} Int Int.instNegInt (OfNat.ofNat.{0} Int 1 (instOfNatInt 1))))))
-Case conversion may be inaccurate. Consider using '#align int.abs_le_one_iff Int.abs_le_one_iffₓ'. -/
theorem 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' ℤ)]
#align int.abs_le_one_iff Int.abs_le_one_iff
-/- warning: int.one_le_abs -> Int.one_le_abs is a dubious translation:
-lean 3 declaration is
- forall {z : Int}, (Ne.{1} Int z (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero)))) -> (LE.le.{0} Int Int.hasLe (OfNat.ofNat.{0} Int 1 (OfNat.mk.{0} Int 1 (One.one.{0} Int Int.hasOne))) (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) z))
-but is expected to have type
- forall {z : Int}, (Ne.{1} Int z (OfNat.ofNat.{0} Int 0 (instOfNatInt 0))) -> (LE.le.{0} Int Int.instLEInt (OfNat.ofNat.{0} Int 1 (instOfNatInt 1)) (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) z))
-Case conversion may be inaccurate. Consider using '#align int.one_le_abs Int.one_le_absₓ'. -/
theorem one_le_abs {z : ℤ} (h₀ : z ≠ 0) : 1 ≤ |z| :=
add_one_le_iff.mpr (abs_pos.mpr h₀)
#align int.one_le_abs Int.one_le_abs
@@ -284,12 +230,6 @@ variable {a b : ℤ} {n : ℕ}
attribute [simp] nat_abs nat_abs_of_nat nat_abs_zero nat_abs_one
-/- warning: int.nat_abs_dvd_iff_dvd -> Int.natAbs_dvd_natAbs is a dubious translation:
-lean 3 declaration is
- forall {a : Int} {b : Int}, Iff (Dvd.Dvd.{0} Nat Nat.hasDvd (Int.natAbs a) (Int.natAbs b)) (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) a b)
-but is expected to have type
- forall {a : Int} {b : Int}, Iff (Dvd.dvd.{0} Nat Nat.instDvdNat (Int.natAbs a) (Int.natAbs b)) (Dvd.dvd.{0} Int Int.instDvdInt a b)
-Case conversion may be inaccurate. Consider using '#align int.nat_abs_dvd_iff_dvd Int.natAbs_dvd_natAbsₓ'. -/
@[simp]
theorem natAbs_dvd_natAbs {a b : ℤ} : a.natAbs ∣ b.natAbs ↔ a ∣ b :=
by
@@ -309,12 +249,6 @@ protected theorem ediv_nonpos {a b : ℤ} (Ha : 0 ≤ a) (Hb : b ≤ 0) : a / b
#align int.div_nonpos Int.ediv_nonpos
-/
-/- warning: int.div_eq_zero_of_lt_abs -> Int.ediv_eq_zero_of_lt_abs is a dubious translation:
-lean 3 declaration is
- forall {a : Int} {b : Int}, (LE.le.{0} Int Int.hasLe (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero))) a) -> (LT.lt.{0} Int Int.hasLt a (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) b)) -> (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) a b) (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero))))
-but is expected to have type
- forall {a : Int} {b : Int}, (LE.le.{0} Int Int.instLEInt (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)) a) -> (LT.lt.{0} Int Int.instLTInt a (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) b)) -> (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) a b) (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)))
-Case conversion may be inaccurate. Consider using '#align int.div_eq_zero_of_lt_abs Int.ediv_eq_zero_of_lt_absₓ'. -/
theorem ediv_eq_zero_of_lt_abs {a b : ℤ} (H1 : 0 ≤ a) (H2 : a < |b|) : a / b = 0 :=
match b, |b|, abs_eq_natAbs b, H2 with
| (n : ℕ), _, rfl, H2 => div_eq_zero_of_lt H1 H2
@@ -383,12 +317,6 @@ protected theorem ediv_self {a : ℤ} (H : a ≠ 0) : a / a = 1 := by
attribute [local simp] Int.zero_div Int.div_zero
-/- warning: int.add_div_of_dvd_right -> Int.add_ediv_of_dvd_right is a dubious translation:
-lean 3 declaration is
- forall {a : Int} {b : Int} {c : Int}, (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) c b) -> (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.hasAdd) a b) c) (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.hasAdd) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) a c) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) b c)))
-but is expected to have type
- forall {a : Int} {b : Int} {c : Int}, (Dvd.dvd.{0} Int Int.instDvdInt c b) -> (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.instAddInt) a b) c) (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.instAddInt) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) a c) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) b c)))
-Case conversion may be inaccurate. Consider using '#align int.add_div_of_dvd_right Int.add_ediv_of_dvd_rightₓ'. -/
protected theorem add_ediv_of_dvd_right {a b c : ℤ} (H : c ∣ b) : (a + b) / c = a / c + b / c :=
by
by_cases h1 : c = 0
@@ -400,12 +328,6 @@ protected theorem add_ediv_of_dvd_right {a b c : ℤ} (H : c ∣ b) : (a + b) /
Int.add_mul_ediv_right _ _ h1, Int.zero_div, zero_add]
#align int.add_div_of_dvd_right Int.add_ediv_of_dvd_right
-/- warning: int.add_div_of_dvd_left -> Int.add_ediv_of_dvd_left is a dubious translation:
-lean 3 declaration is
- forall {a : Int} {b : Int} {c : Int}, (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) c a) -> (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.hasAdd) a b) c) (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.hasAdd) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) a c) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) b c)))
-but is expected to have type
- forall {a : Int} {b : Int} {c : Int}, (Dvd.dvd.{0} Int Int.instDvdInt c a) -> (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.instAddInt) a b) c) (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.instAddInt) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) a c) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) b c)))
-Case conversion may be inaccurate. Consider using '#align int.add_div_of_dvd_left Int.add_ediv_of_dvd_leftₓ'. -/
protected theorem add_ediv_of_dvd_left {a b c : ℤ} (H : c ∣ a) : (a + b) / c = a / c + b / c := by
rw [add_comm, Int.add_ediv_of_dvd_right H, add_comm]
#align int.add_div_of_dvd_left Int.add_ediv_of_dvd_left
@@ -413,12 +335,6 @@ protected theorem add_ediv_of_dvd_left {a b c : ℤ} (H : c ∣ a) : (a + b) / c
/-! ### mod -/
-/- warning: int.mod_abs -> Int.emod_abs is a dubious translation:
-lean 3 declaration is
- forall (a : Int) (b : Int), Eq.{1} Int (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.hasMod) a (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) b)) (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.hasMod) a b)
-but is expected to have type
- forall (a : Int) (b : Int), Eq.{1} Int (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.instModInt_1) a (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) b)) (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.instModInt_1) a b)
-Case conversion may be inaccurate. Consider using '#align int.mod_abs Int.emod_absₓ'. -/
@[simp]
theorem emod_abs (a b : ℤ) : a % |b| = a % b :=
abs_by_cases (fun i => a % i = a % b) rfl (mod_neg _ _)
@@ -440,12 +356,6 @@ theorem emod_lt_of_pos (a : ℤ) {b : ℤ} (H : 0 < b) : a % b < b :=
#align int.mod_lt_of_pos Int.emod_lt_of_pos
-/
-/- warning: int.mod_lt -> Int.emod_lt is a dubious translation:
-lean 3 declaration is
- forall (a : Int) {b : Int}, (Ne.{1} Int b (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero)))) -> (LT.lt.{0} Int Int.hasLt (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.hasMod) a b) (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) b))
-but is expected to have type
- forall (a : Int) {b : Int}, (Ne.{1} Int b (OfNat.ofNat.{0} Int 0 (instOfNatInt 0))) -> (LT.lt.{0} Int Int.instLTInt (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.instModInt_1) a b) (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) b))
-Case conversion may be inaccurate. Consider using '#align int.mod_lt Int.emod_ltₓ'. -/
theorem emod_lt (a : ℤ) {b : ℤ} (H : b ≠ 0) : a % b < |b| := by
rw [← mod_abs] <;> exact mod_lt_of_pos _ (abs_pos.2 H)
#align int.mod_lt Int.emod_lt
@@ -561,12 +471,6 @@ theorem emod_self {a : ℤ} : a % a = 0 := by have := mul_mod_left 1 a <;> rwa [
#align int.mod_self Int.emod_self
-/
-/- warning: int.mod_mod_of_dvd -> Int.emod_emod_of_dvd is a dubious translation:
-lean 3 declaration is
- forall (n : Int) {m : Int} {k : Int}, (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) m k) -> (Eq.{1} Int (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.hasMod) (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.hasMod) n k) m) (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.hasMod) n m))
-but is expected to have type
- forall (n : Int) {m : Int} {k : Int}, (Dvd.dvd.{0} Int Int.instDvdInt m k) -> (Eq.{1} Int (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.instModInt_1) (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.instModInt_1) n k) m) (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.instModInt_1) n m))
-Case conversion may be inaccurate. Consider using '#align int.mod_mod_of_dvd Int.emod_emod_of_dvdₓ'. -/
@[simp]
theorem emod_emod_of_dvd (n : ℤ) {m k : ℤ} (h : m ∣ k) : n % k % m = n % m :=
by
@@ -638,12 +542,6 @@ theorem lt_ediv_add_one_mul_self (a : ℤ) {b : ℤ} (H : 0 < b) : a < (a / b +
#align int.lt_div_add_one_mul_self Int.lt_ediv_add_one_mul_self
-/
-/- warning: int.abs_div_le_abs -> Int.abs_ediv_le_abs is a dubious translation:
-lean 3 declaration is
- forall (a : Int) (b : Int), LE.le.{0} Int Int.hasLe (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) a b)) (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) a)
-but is expected to have type
- forall (a : Int) (b : Int), LE.le.{0} Int Int.instLEInt (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) a b)) (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) a)
-Case conversion may be inaccurate. Consider using '#align int.abs_div_le_abs Int.abs_ediv_le_absₓ'. -/
theorem abs_ediv_le_abs : ∀ a b : ℤ, |a / b| ≤ |a| :=
suffices ∀ (a : ℤ) (n : ℕ), |a / n| ≤ |a| from fun a b =>
match b, eq_nat_or_neg b with
@@ -680,42 +578,18 @@ theorem emod_two_eq_zero_or_one (n : ℤ) : n % 2 = 0 ∨ n % 2 = 1 :=
/-! ### dvd -/
-/- warning: int.dvd_of_mod_eq_zero -> Int.dvd_of_emod_eq_zero is a dubious translation:
-lean 3 declaration is
- forall {a : Int} {b : Int}, (Eq.{1} Int (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.hasMod) b a) (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero)))) -> (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) a b)
-but is expected to have type
- forall {a : Int} {b : Int}, (Eq.{1} Int (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.instModInt_1) b a) (OfNat.ofNat.{0} Int 0 (instOfNatInt 0))) -> (Dvd.dvd.{0} Int Int.instDvdInt a b)
-Case conversion may be inaccurate. Consider using '#align int.dvd_of_mod_eq_zero Int.dvd_of_emod_eq_zeroₓ'. -/
theorem dvd_of_emod_eq_zero {a b : ℤ} (H : b % a = 0) : a ∣ b :=
⟨b / a, (mul_div_cancel_of_mod_eq_zero H).symm⟩
#align int.dvd_of_mod_eq_zero Int.dvd_of_emod_eq_zero
-/- warning: int.mod_eq_zero_of_dvd -> Int.emod_eq_zero_of_dvd is a dubious translation:
-lean 3 declaration is
- forall {a : Int} {b : Int}, (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) a b) -> (Eq.{1} Int (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.hasMod) b a) (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero))))
-but is expected to have type
- forall {a : Int} {b : Int}, (Dvd.dvd.{0} Int Int.instDvdInt a b) -> (Eq.{1} Int (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.instModInt_1) b a) (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)))
-Case conversion may be inaccurate. Consider using '#align int.mod_eq_zero_of_dvd Int.emod_eq_zero_of_dvdₓ'. -/
theorem emod_eq_zero_of_dvd : ∀ {a b : ℤ}, a ∣ b → b % a = 0
| a, _, ⟨c, rfl⟩ => mul_emod_right _ _
#align int.mod_eq_zero_of_dvd Int.emod_eq_zero_of_dvd
-/- warning: int.dvd_iff_mod_eq_zero -> Int.dvd_iff_emod_eq_zero is a dubious translation:
-lean 3 declaration is
- forall (a : Int) (b : Int), Iff (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) a b) (Eq.{1} Int (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.hasMod) b a) (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero))))
-but is expected to have type
- forall (a : Int) (b : Int), Iff (Dvd.dvd.{0} Int Int.instDvdInt a b) (Eq.{1} Int (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.instModInt_1) b a) (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)))
-Case conversion may be inaccurate. Consider using '#align int.dvd_iff_mod_eq_zero Int.dvd_iff_emod_eq_zeroₓ'. -/
theorem dvd_iff_emod_eq_zero (a b : ℤ) : a ∣ b ↔ b % a = 0 :=
⟨emod_eq_zero_of_dvd, dvd_of_emod_eq_zero⟩
#align int.dvd_iff_mod_eq_zero Int.dvd_iff_emod_eq_zero
-/- warning: int.dvd_sub_of_mod_eq -> Int.dvd_sub_of_emod_eq is a dubious translation:
-lean 3 declaration is
- forall {a : Int} {b : Int} {c : Int}, (Eq.{1} Int (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.hasMod) a b) c) -> (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) b (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.hasSub) a c))
-but is expected to have type
- forall {a : Int} {b : Int} {c : Int}, (Eq.{1} Int (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.instModInt_1) a b) c) -> (Dvd.dvd.{0} Int Int.instDvdInt b (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.instSubInt) a c))
-Case conversion may be inaccurate. Consider using '#align int.dvd_sub_of_mod_eq Int.dvd_sub_of_emod_eqₓ'. -/
/-- If `a % b = c` then `b` divides `a - c`. -/
theorem dvd_sub_of_emod_eq {a b c : ℤ} (h : a % b = c) : b ∣ a - c :=
by
@@ -724,62 +598,26 @@ theorem dvd_sub_of_emod_eq {a b c : ℤ} (h : a % b = c) : b ∣ a - c :=
exact dvd_of_mod_eq_zero hx
#align int.dvd_sub_of_mod_eq Int.dvd_sub_of_emod_eq
-/- warning: int.nat_abs_dvd -> Int.natAbs_dvd is a dubious translation:
-lean 3 declaration is
- forall {a : Int} {b : Int}, Iff (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (Int.natAbs a)) b) (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) a b)
-but is expected to have type
- forall {a : Int} {b : Int}, Iff (Dvd.dvd.{0} Int Int.instDvdInt (Nat.cast.{0} Int instNatCastInt (Int.natAbs a)) b) (Dvd.dvd.{0} Int Int.instDvdInt a b)
-Case conversion may be inaccurate. Consider using '#align int.nat_abs_dvd Int.natAbs_dvdₓ'. -/
theorem natAbs_dvd {a b : ℤ} : (a.natAbs : ℤ) ∣ b ↔ a ∣ b :=
(natAbs_eq a).elim (fun e => by rw [← e]) fun e => by rw [← neg_dvd, ← e]
#align int.nat_abs_dvd Int.natAbs_dvd
-/- warning: int.dvd_nat_abs -> Int.dvd_natAbs is a dubious translation:
-lean 3 declaration is
- forall {a : Int} {b : Int}, Iff (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) a ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (Int.natAbs b))) (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) a b)
-but is expected to have type
- forall {a : Int} {b : Int}, Iff (Dvd.dvd.{0} Int Int.instDvdInt a (Nat.cast.{0} Int instNatCastInt (Int.natAbs b))) (Dvd.dvd.{0} Int Int.instDvdInt a b)
-Case conversion may be inaccurate. Consider using '#align int.dvd_nat_abs Int.dvd_natAbsₓ'. -/
theorem dvd_natAbs {a b : ℤ} : a ∣ b.natAbs ↔ a ∣ b :=
(natAbs_eq b).elim (fun e => by rw [← e]) fun e => by rw [← dvd_neg, ← e]
#align int.dvd_nat_abs Int.dvd_natAbs
-/- warning: int.decidable_dvd -> Int.decidableDvd is a dubious translation:
-lean 3 declaration is
- DecidableRel.{1} Int (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup))
-but is expected to have type
- DecidableRel.{1} Int (fun (x._@.Std.Data.Int.DivMod._hyg.13542 : Int) (x._@.Std.Data.Int.DivMod._hyg.13544 : Int) => Dvd.dvd.{0} Int Int.instDvdInt x._@.Std.Data.Int.DivMod._hyg.13542 x._@.Std.Data.Int.DivMod._hyg.13544)
-Case conversion may be inaccurate. Consider using '#align int.decidable_dvd Int.decidableDvdₓ'. -/
instance decidableDvd : @DecidableRel ℤ (· ∣ ·) := fun a n =>
decidable_of_decidable_of_iff (by infer_instance) (dvd_iff_emod_eq_zero _ _).symm
#align int.decidable_dvd Int.decidableDvd
-/- warning: int.div_mul_cancel -> Int.ediv_mul_cancel is a dubious translation:
-lean 3 declaration is
- forall {a : Int} {b : Int}, (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) b a) -> (Eq.{1} Int (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) a b) b) a)
-but is expected to have type
- forall {a : Int} {b : Int}, (Dvd.dvd.{0} Int Int.instDvdInt b a) -> (Eq.{1} Int (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) a b) b) a)
-Case conversion may be inaccurate. Consider using '#align int.div_mul_cancel Int.ediv_mul_cancelₓ'. -/
protected theorem ediv_mul_cancel {a b : ℤ} (H : b ∣ a) : a / b * b = a :=
div_mul_cancel_of_mod_eq_zero (emod_eq_zero_of_dvd H)
#align int.div_mul_cancel Int.ediv_mul_cancel
-/- warning: int.mul_div_cancel' -> Int.mul_ediv_cancel' is a dubious translation:
-lean 3 declaration is
- forall {a : Int} {b : Int}, (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) a b) -> (Eq.{1} Int (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) a (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) b a)) b)
-but is expected to have type
- forall {a : Int} {b : Int}, (Dvd.dvd.{0} Int Int.instDvdInt a b) -> (Eq.{1} Int (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) a (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) b a)) b)
-Case conversion may be inaccurate. Consider using '#align int.mul_div_cancel' Int.mul_ediv_cancel'ₓ'. -/
protected theorem mul_ediv_cancel' {a b : ℤ} (H : a ∣ b) : a * (b / a) = b := by
rw [mul_comm, Int.ediv_mul_cancel H]
#align int.mul_div_cancel' Int.mul_ediv_cancel'
-/- warning: int.div_dvd_div -> Int.ediv_dvd_ediv is a dubious translation:
-lean 3 declaration is
- forall {a : Int} {b : Int} {c : Int}, (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) a b) -> (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) b c) -> (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) b a) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) c a))
-but is expected to have type
- forall {a : Int} {b : Int} {c : Int}, (Dvd.dvd.{0} Int Int.instDvdInt a b) -> (Dvd.dvd.{0} Int Int.instDvdInt b c) -> (Dvd.dvd.{0} Int Int.instDvdInt (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) b a) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) c a))
-Case conversion may be inaccurate. Consider using '#align int.div_dvd_div Int.ediv_dvd_edivₓ'. -/
theorem ediv_dvd_ediv : ∀ {a b c : ℤ} (H1 : a ∣ b) (H2 : b ∣ c), b / a ∣ c / a
| a, _, _, ⟨b, rfl⟩, ⟨c, rfl⟩ =>
if az : a = 0 then by simp [az]
@@ -788,12 +626,6 @@ theorem ediv_dvd_ediv : ∀ {a b c : ℤ} (H1 : a ∣ b) (H2 : b ∣ c), b / a
apply dvd_mul_right
#align int.div_dvd_div Int.ediv_dvd_ediv
-/- warning: int.eq_mul_of_div_eq_right -> Int.eq_mul_of_ediv_eq_right is a dubious translation:
-lean 3 declaration is
- forall {a : Int} {b : Int} {c : Int}, (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) b a) -> (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) a b) c) -> (Eq.{1} Int a (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) b c))
-but is expected to have type
- forall {a : Int} {b : Int} {c : Int}, (Dvd.dvd.{0} Int Int.instDvdInt b a) -> (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) a b) c) -> (Eq.{1} Int a (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) b c))
-Case conversion may be inaccurate. Consider using '#align int.eq_mul_of_div_eq_right Int.eq_mul_of_ediv_eq_rightₓ'. -/
protected theorem eq_mul_of_ediv_eq_right {a b c : ℤ} (H1 : b ∣ a) (H2 : a / b = c) : a = b * c :=
by rw [← H2, Int.mul_ediv_cancel' H1]
#align int.eq_mul_of_div_eq_right Int.eq_mul_of_ediv_eq_right
@@ -810,33 +642,15 @@ protected theorem eq_ediv_of_mul_eq_right {a b c : ℤ} (H1 : a ≠ 0) (H2 : a *
#align int.eq_div_of_mul_eq_right Int.eq_ediv_of_mul_eq_right
-/
-/- warning: int.div_eq_iff_eq_mul_right -> Int.ediv_eq_iff_eq_mul_right is a dubious translation:
-lean 3 declaration is
- forall {a : Int} {b : Int} {c : Int}, (Ne.{1} Int b (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero)))) -> (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) b a) -> (Iff (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) a b) c) (Eq.{1} Int a (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) b c)))
-but is expected to have type
- forall {a : Int} {b : Int} {c : Int}, (Ne.{1} Int b (OfNat.ofNat.{0} Int 0 (instOfNatInt 0))) -> (Dvd.dvd.{0} Int Int.instDvdInt b a) -> (Iff (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) a b) c) (Eq.{1} Int a (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) b c)))
-Case conversion may be inaccurate. Consider using '#align int.div_eq_iff_eq_mul_right Int.ediv_eq_iff_eq_mul_rightₓ'. -/
protected theorem ediv_eq_iff_eq_mul_right {a b c : ℤ} (H : b ≠ 0) (H' : b ∣ a) :
a / b = c ↔ a = b * c :=
⟨Int.eq_mul_of_ediv_eq_right H', Int.ediv_eq_of_eq_mul_right H⟩
#align int.div_eq_iff_eq_mul_right Int.ediv_eq_iff_eq_mul_right
-/- warning: int.div_eq_iff_eq_mul_left -> Int.ediv_eq_iff_eq_mul_left is a dubious translation:
-lean 3 declaration is
- forall {a : Int} {b : Int} {c : Int}, (Ne.{1} Int b (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero)))) -> (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) b a) -> (Iff (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) a b) c) (Eq.{1} Int a (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) c b)))
-but is expected to have type
- forall {a : Int} {b : Int} {c : Int}, (Ne.{1} Int b (OfNat.ofNat.{0} Int 0 (instOfNatInt 0))) -> (Dvd.dvd.{0} Int Int.instDvdInt b a) -> (Iff (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) a b) c) (Eq.{1} Int a (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) c b)))
-Case conversion may be inaccurate. Consider using '#align int.div_eq_iff_eq_mul_left Int.ediv_eq_iff_eq_mul_leftₓ'. -/
protected theorem ediv_eq_iff_eq_mul_left {a b c : ℤ} (H : b ≠ 0) (H' : b ∣ a) :
a / b = c ↔ a = c * b := by rw [mul_comm] <;> exact Int.ediv_eq_iff_eq_mul_right H H'
#align int.div_eq_iff_eq_mul_left Int.ediv_eq_iff_eq_mul_left
-/- warning: int.eq_mul_of_div_eq_left -> Int.eq_mul_of_ediv_eq_left is a dubious translation:
-lean 3 declaration is
- forall {a : Int} {b : Int} {c : Int}, (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) b a) -> (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) a b) c) -> (Eq.{1} Int a (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) c b))
-but is expected to have type
- forall {a : Int} {b : Int} {c : Int}, (Dvd.dvd.{0} Int Int.instDvdInt b a) -> (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) a b) c) -> (Eq.{1} Int a (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) c b))
-Case conversion may be inaccurate. Consider using '#align int.eq_mul_of_div_eq_left Int.eq_mul_of_ediv_eq_leftₓ'. -/
protected theorem eq_mul_of_ediv_eq_left {a b c : ℤ} (H1 : b ∣ a) (H2 : a / b = c) : a = c * b := by
rw [mul_comm, Int.eq_mul_of_ediv_eq_right H1 H2]
#align int.eq_mul_of_div_eq_left Int.eq_mul_of_ediv_eq_left
@@ -847,22 +661,10 @@ protected theorem ediv_eq_of_eq_mul_left {a b c : ℤ} (H1 : b ≠ 0) (H2 : a =
#align int.div_eq_of_eq_mul_left Int.ediv_eq_of_eq_mul_left
-/
-/- warning: int.eq_zero_of_div_eq_zero -> Int.eq_zero_of_ediv_eq_zero is a dubious translation:
-lean 3 declaration is
- forall {d : Int} {n : Int}, (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) d n) -> (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) n d) (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero)))) -> (Eq.{1} Int n (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero))))
-but is expected to have type
- forall {d : Int} {n : Int}, (Dvd.dvd.{0} Int Int.instDvdInt d n) -> (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) n d) (OfNat.ofNat.{0} Int 0 (instOfNatInt 0))) -> (Eq.{1} Int n (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)))
-Case conversion may be inaccurate. Consider using '#align int.eq_zero_of_div_eq_zero Int.eq_zero_of_ediv_eq_zeroₓ'. -/
protected theorem eq_zero_of_ediv_eq_zero {d n : ℤ} (h : d ∣ n) (H : n / d = 0) : n = 0 := by
rw [← Int.mul_ediv_cancel' h, H, MulZeroClass.mul_zero]
#align int.eq_zero_of_div_eq_zero Int.eq_zero_of_ediv_eq_zero
-/- warning: int.div_left_inj -> Int.ediv_left_inj is a dubious translation:
-lean 3 declaration is
- forall {a : Int} {b : Int} {d : Int}, (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) d a) -> (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) d b) -> (Iff (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) a d) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) b d)) (Eq.{1} Int a b))
-but is expected to have type
- forall {a : Int} {b : Int} {d : Int}, (Dvd.dvd.{0} Int Int.instDvdInt d a) -> (Dvd.dvd.{0} Int Int.instDvdInt d b) -> (Iff (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) a d) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) b d)) (Eq.{1} Int a b))
-Case conversion may be inaccurate. Consider using '#align int.div_left_inj Int.ediv_left_injₓ'. -/
@[simp]
protected theorem ediv_left_inj {a b d : ℤ} (hda : d ∣ a) (hdb : d ∣ b) : a / d = b / d ↔ a = b :=
by
@@ -870,22 +672,10 @@ protected theorem ediv_left_inj {a b d : ℤ} (hda : d ∣ a) (hdb : d ∣ b) :
rw [← Int.mul_ediv_cancel' hda, ← Int.mul_ediv_cancel' hdb, h]
#align int.div_left_inj Int.ediv_left_inj
-/- warning: int.abs_sign_of_nonzero -> Int.abs_sign_of_nonzero is a dubious translation:
-lean 3 declaration is
- forall {z : Int}, (Ne.{1} Int z (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero)))) -> (Eq.{1} Int (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) (Int.sign z)) (OfNat.ofNat.{0} Int 1 (OfNat.mk.{0} Int 1 (One.one.{0} Int Int.hasOne))))
-but is expected to have type
- forall {z : Int}, (Ne.{1} Int z (OfNat.ofNat.{0} Int 0 (instOfNatInt 0))) -> (Eq.{1} Int (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) (Int.sign z)) (OfNat.ofNat.{0} Int 1 (instOfNatInt 1)))
-Case conversion may be inaccurate. Consider using '#align int.abs_sign_of_nonzero Int.abs_sign_of_nonzeroₓ'. -/
theorem abs_sign_of_nonzero {z : ℤ} (hz : z ≠ 0) : |z.sign| = 1 := by
rw [abs_eq_nat_abs, nat_abs_sign_of_nonzero hz, Int.ofNat_one]
#align int.abs_sign_of_nonzero Int.abs_sign_of_nonzero
-/- warning: int.exists_lt_and_lt_iff_not_dvd -> Int.exists_lt_and_lt_iff_not_dvd is a dubious translation:
-lean 3 declaration is
- forall (m : Int) {n : Int}, (LT.lt.{0} Int Int.hasLt (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero))) n) -> (Iff (Exists.{1} Int (fun (k : Int) => And (LT.lt.{0} Int Int.hasLt (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) n k) m) (LT.lt.{0} Int Int.hasLt m (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) n (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.hasAdd) k (OfNat.ofNat.{0} Int 1 (OfNat.mk.{0} Int 1 (One.one.{0} Int Int.hasOne)))))))) (Not (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) n m)))
-but is expected to have type
- forall (m : Int) {n : Int}, (LT.lt.{0} Int Int.instLTInt (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)) n) -> (Iff (Exists.{1} Int (fun (k : Int) => And (LT.lt.{0} Int Int.instLTInt (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) n k) m) (LT.lt.{0} Int Int.instLTInt m (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) n (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.instAddInt) k (OfNat.ofNat.{0} Int 1 (instOfNatInt 1))))))) (Not (Dvd.dvd.{0} Int Int.instDvdInt n m)))
-Case conversion may be inaccurate. Consider using '#align int.exists_lt_and_lt_iff_not_dvd Int.exists_lt_and_lt_iff_not_dvdₓ'. -/
/-- If `n > 0` then `m` is not divisible by `n` iff it is between `n * k` and `n * (k + 1)`
for some `k`. -/
theorem exists_lt_and_lt_iff_not_dvd (m : ℤ) {n : ℤ} (hn : 0 < n) :
@@ -903,46 +693,22 @@ theorem exists_lt_and_lt_iff_not_dvd (m : ℤ) {n : ℤ} (hn : 0 < n) :
attribute [local simp] Int.div_zero
-/- warning: int.mul_div_assoc -> Int.mul_ediv_assoc is a dubious translation:
-lean 3 declaration is
- forall (a : Int) {b : Int} {c : Int}, (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) c b) -> (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) a b) c) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) a (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) b c)))
-but is expected to have type
- forall (a : Int) {b : Int} {c : Int}, (Dvd.dvd.{0} Int Int.instDvdInt c b) -> (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) a b) c) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) a (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) b c)))
-Case conversion may be inaccurate. Consider using '#align int.mul_div_assoc Int.mul_ediv_assocₓ'. -/
protected theorem mul_ediv_assoc (a : ℤ) : ∀ {b c : ℤ}, c ∣ b → a * b / c = a * (b / c)
| _, c, ⟨d, rfl⟩ =>
if cz : c = 0 then by simp [cz]
else by rw [mul_left_comm, Int.mul_ediv_cancel_left _ cz, Int.mul_ediv_cancel_left _ cz]
#align int.mul_div_assoc Int.mul_ediv_assoc
-/- warning: int.mul_div_assoc' -> Int.mul_ediv_assoc' is a dubious translation:
-lean 3 declaration is
- forall (b : Int) {a : Int} {c : Int}, (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) c a) -> (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) a b) c) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) a c) b))
-but is expected to have type
- forall (b : Int) {a : Int} {c : Int}, (Dvd.dvd.{0} Int Int.instDvdInt c a) -> (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) a b) c) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) a c) b))
-Case conversion may be inaccurate. Consider using '#align int.mul_div_assoc' Int.mul_ediv_assoc'ₓ'. -/
protected theorem mul_ediv_assoc' (b : ℤ) {a c : ℤ} (h : c ∣ a) : a * b / c = a / c * b := by
rw [mul_comm, Int.mul_ediv_assoc _ h, mul_comm]
#align int.mul_div_assoc' Int.mul_ediv_assoc'
-/- warning: int.neg_div_of_dvd -> Int.neg_ediv_of_dvd is a dubious translation:
-lean 3 declaration is
- forall {a : Int} {b : Int}, (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) b a) -> (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) (Neg.neg.{0} Int Int.hasNeg a) b) (Neg.neg.{0} Int Int.hasNeg (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) a b)))
-but is expected to have type
- forall {a : Int} {b : Int}, (Dvd.dvd.{0} Int Int.instDvdInt b a) -> (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) (Neg.neg.{0} Int Int.instNegInt a) b) (Neg.neg.{0} Int Int.instNegInt (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) a b)))
-Case conversion may be inaccurate. Consider using '#align int.neg_div_of_dvd Int.neg_ediv_of_dvdₓ'. -/
theorem neg_ediv_of_dvd : ∀ {a b : ℤ} (H : b ∣ a), -a / b = -(a / b)
| _, b, ⟨c, rfl⟩ =>
if bz : b = 0 then by simp [bz]
else by rw [neg_mul_eq_mul_neg, Int.mul_ediv_cancel_left _ bz, Int.mul_ediv_cancel_left _ bz]
#align int.neg_div_of_dvd Int.neg_ediv_of_dvd
-/- warning: int.sub_div_of_dvd -> Int.sub_ediv_of_dvd is a dubious translation:
-lean 3 declaration is
- forall (a : Int) {b : Int} {c : Int}, (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) c b) -> (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.hasSub) a b) c) (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.hasSub) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) a c) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) b c)))
-but is expected to have type
- forall (a : Int) {b : Int} {c : Int}, (Dvd.dvd.{0} Int Int.instDvdInt c b) -> (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.instSubInt) a b) c) (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.instSubInt) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) a c) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) b c)))
-Case conversion may be inaccurate. Consider using '#align int.sub_div_of_dvd Int.sub_ediv_of_dvdₓ'. -/
theorem sub_ediv_of_dvd (a : ℤ) {b c : ℤ} (hcb : c ∣ b) : (a - b) / c = a / c - b / c :=
by
rw [sub_eq_add_neg, sub_eq_add_neg, Int.add_ediv_of_dvd_right hcb.neg_right]
@@ -950,22 +716,10 @@ theorem sub_ediv_of_dvd (a : ℤ) {b c : ℤ} (hcb : c ∣ b) : (a - b) / c = a
exact neg_div_of_dvd hcb
#align int.sub_div_of_dvd Int.sub_ediv_of_dvd
-/- warning: int.sub_div_of_dvd_sub -> Int.sub_ediv_of_dvd_sub is a dubious translation:
-lean 3 declaration is
- forall {a : Int} {b : Int} {c : Int}, (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) c (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.hasSub) a b)) -> (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.hasSub) a b) c) (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.hasSub) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) a c) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) b c)))
-but is expected to have type
- forall {a : Int} {b : Int} {c : Int}, (Dvd.dvd.{0} Int Int.instDvdInt c (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.instSubInt) a b)) -> (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.instSubInt) a b) c) (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.instSubInt) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) a c) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) b c)))
-Case conversion may be inaccurate. Consider using '#align int.sub_div_of_dvd_sub Int.sub_ediv_of_dvd_subₓ'. -/
theorem sub_ediv_of_dvd_sub {a b c : ℤ} (hcab : c ∣ a - b) : (a - b) / c = a / c - b / c := by
rw [eq_sub_iff_add_eq, ← Int.add_ediv_of_dvd_left hcab, sub_add_cancel]
#align int.sub_div_of_dvd_sub Int.sub_ediv_of_dvd_sub
-/- warning: int.sign_eq_div_abs -> Int.sign_eq_ediv_abs is a dubious translation:
-lean 3 declaration is
- forall (a : Int), Eq.{1} Int (Int.sign a) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) a (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) a))
-but is expected to have type
- forall (a : Int), Eq.{1} Int (Int.sign a) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) a (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) a))
-Case conversion may be inaccurate. Consider using '#align int.sign_eq_div_abs Int.sign_eq_ediv_absₓ'. -/
protected theorem sign_eq_ediv_abs (a : ℤ) : sign a = a / |a| :=
if az : a = 0 then by simp [az]
else (Int.ediv_eq_of_eq_mul_left (mt abs_eq_zero.1 az) (sign_mul_abs _).symm).symm
@@ -1035,76 +789,34 @@ protected theorem ediv_lt_iff_lt_mul {a b c : ℤ} (H : 0 < c) : a / c < b ↔ a
#align int.div_lt_iff_lt_mul Int.ediv_lt_iff_lt_mul
-/
-/- warning: int.le_mul_of_div_le -> Int.le_mul_of_ediv_le is a dubious translation:
-lean 3 declaration is
- forall {a : Int} {b : Int} {c : Int}, (LE.le.{0} Int Int.hasLe (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero))) b) -> (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) b a) -> (LE.le.{0} Int Int.hasLe (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) a b) c) -> (LE.le.{0} Int Int.hasLe a (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) c b))
-but is expected to have type
- forall {a : Int} {b : Int} {c : Int}, (LE.le.{0} Int Int.instLEInt (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)) b) -> (Dvd.dvd.{0} Int Int.instDvdInt b a) -> (LE.le.{0} Int Int.instLEInt (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) a b) c) -> (LE.le.{0} Int Int.instLEInt a (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) c b))
-Case conversion may be inaccurate. Consider using '#align int.le_mul_of_div_le Int.le_mul_of_ediv_leₓ'. -/
protected theorem le_mul_of_ediv_le {a b c : ℤ} (H1 : 0 ≤ b) (H2 : b ∣ a) (H3 : a / b ≤ c) :
a ≤ c * b := by rw [← Int.ediv_mul_cancel H2] <;> exact mul_le_mul_of_nonneg_right H3 H1
#align int.le_mul_of_div_le Int.le_mul_of_ediv_le
-/- warning: int.lt_div_of_mul_lt -> Int.lt_ediv_of_mul_lt is a dubious translation:
-lean 3 declaration is
- forall {a : Int} {b : Int} {c : Int}, (LE.le.{0} Int Int.hasLe (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero))) b) -> (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) b c) -> (LT.lt.{0} Int Int.hasLt (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) a b) c) -> (LT.lt.{0} Int Int.hasLt a (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) c b))
-but is expected to have type
- forall {a : Int} {b : Int} {c : Int}, (LE.le.{0} Int Int.instLEInt (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)) b) -> (Dvd.dvd.{0} Int Int.instDvdInt b c) -> (LT.lt.{0} Int Int.instLTInt (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) a b) c) -> (LT.lt.{0} Int Int.instLTInt a (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) c b))
-Case conversion may be inaccurate. Consider using '#align int.lt_div_of_mul_lt Int.lt_ediv_of_mul_ltₓ'. -/
protected theorem lt_ediv_of_mul_lt {a b c : ℤ} (H1 : 0 ≤ b) (H2 : b ∣ c) (H3 : a * b < c) :
a < c / b :=
lt_of_not_ge <| mt (Int.le_mul_of_ediv_le H1 H2) (not_le_of_gt H3)
#align int.lt_div_of_mul_lt Int.lt_ediv_of_mul_lt
-/- warning: int.lt_div_iff_mul_lt -> Int.lt_ediv_iff_mul_lt is a dubious translation:
-lean 3 declaration is
- forall {a : Int} {b : Int} (c : Int), (LT.lt.{0} Int Int.hasLt (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero))) c) -> (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) c b) -> (Iff (LT.lt.{0} Int Int.hasLt a (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) b c)) (LT.lt.{0} Int Int.hasLt (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) a c) b))
-but is expected to have type
- forall {a : Int} {b : Int} (c : Int), (LT.lt.{0} Int Int.instLTInt (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)) c) -> (Dvd.dvd.{0} Int Int.instDvdInt c b) -> (Iff (LT.lt.{0} Int Int.instLTInt a (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) b c)) (LT.lt.{0} Int Int.instLTInt (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) a c) b))
-Case conversion may be inaccurate. Consider using '#align int.lt_div_iff_mul_lt Int.lt_ediv_iff_mul_ltₓ'. -/
protected theorem lt_ediv_iff_mul_lt {a b : ℤ} (c : ℤ) (H : 0 < c) (H' : c ∣ b) :
a < b / c ↔ a * c < b :=
⟨Int.mul_lt_of_lt_ediv H, Int.lt_ediv_of_mul_lt (le_of_lt H) H'⟩
#align int.lt_div_iff_mul_lt Int.lt_ediv_iff_mul_lt
-/- warning: int.div_pos_of_pos_of_dvd -> Int.ediv_pos_of_pos_of_dvd is a dubious translation:
-lean 3 declaration is
- forall {a : Int} {b : Int}, (LT.lt.{0} Int Int.hasLt (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero))) a) -> (LE.le.{0} Int Int.hasLe (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero))) b) -> (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) b a) -> (LT.lt.{0} Int Int.hasLt (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero))) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) a b))
-but is expected to have type
- forall {a : Int} {b : Int}, (LT.lt.{0} Int Int.instLTInt (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)) a) -> (LE.le.{0} Int Int.instLEInt (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)) b) -> (Dvd.dvd.{0} Int Int.instDvdInt b a) -> (LT.lt.{0} Int Int.instLTInt (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) a b))
-Case conversion may be inaccurate. Consider using '#align int.div_pos_of_pos_of_dvd Int.ediv_pos_of_pos_of_dvdₓ'. -/
theorem ediv_pos_of_pos_of_dvd {a b : ℤ} (H1 : 0 < a) (H2 : 0 ≤ b) (H3 : b ∣ a) : 0 < a / b :=
Int.lt_ediv_of_mul_lt H2 H3 (by rwa [MulZeroClass.zero_mul])
#align int.div_pos_of_pos_of_dvd Int.ediv_pos_of_pos_of_dvd
-/- warning: int.nat_abs_eq_of_dvd_dvd -> Int.natAbs_eq_of_dvd_dvd is a dubious translation:
-lean 3 declaration is
- forall {s : Int} {t : Int}, (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) s t) -> (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) t s) -> (Eq.{1} Nat (Int.natAbs s) (Int.natAbs t))
-but is expected to have type
- forall {s : Int} {t : Int}, (Dvd.dvd.{0} Int Int.instDvdInt s t) -> (Dvd.dvd.{0} Int Int.instDvdInt t s) -> (Eq.{1} Nat (Int.natAbs s) (Int.natAbs t))
-Case conversion may be inaccurate. Consider using '#align int.nat_abs_eq_of_dvd_dvd Int.natAbs_eq_of_dvd_dvdₓ'. -/
theorem natAbs_eq_of_dvd_dvd {s t : ℤ} (hst : s ∣ t) (hts : t ∣ s) : natAbs s = natAbs t :=
Nat.dvd_antisymm (natAbs_dvd_natAbs.mpr hst) (natAbs_dvd_natAbs.mpr hts)
#align int.nat_abs_eq_of_dvd_dvd Int.natAbs_eq_of_dvd_dvd
-/- warning: int.div_eq_div_of_mul_eq_mul -> Int.ediv_eq_ediv_of_mul_eq_mul is a dubious translation:
-lean 3 declaration is
- forall {a : Int} {b : Int} {c : Int} {d : Int}, (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) d c) -> (Ne.{1} Int b (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero)))) -> (Ne.{1} Int d (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero)))) -> (Eq.{1} Int (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) a d) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) b c)) -> (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) a b) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) c d))
-but is expected to have type
- forall {a : Int} {b : Int} {c : Int} {d : Int}, (Dvd.dvd.{0} Int Int.instDvdInt d c) -> (Ne.{1} Int b (OfNat.ofNat.{0} Int 0 (instOfNatInt 0))) -> (Ne.{1} Int d (OfNat.ofNat.{0} Int 0 (instOfNatInt 0))) -> (Eq.{1} Int (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) a d) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) b c)) -> (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) a b) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) c d))
-Case conversion may be inaccurate. Consider using '#align int.div_eq_div_of_mul_eq_mul Int.ediv_eq_ediv_of_mul_eq_mulₓ'. -/
theorem ediv_eq_ediv_of_mul_eq_mul {a b c d : ℤ} (H2 : d ∣ c) (H3 : b ≠ 0) (H4 : d ≠ 0)
(H5 : a * d = b * c) : a / b = c / d :=
Int.ediv_eq_of_eq_mul_right H3 <| by
rw [← Int.mul_ediv_assoc _ H2] <;> exact (Int.ediv_eq_of_eq_mul_left H4 H5.symm).symm
#align int.div_eq_div_of_mul_eq_mul Int.ediv_eq_ediv_of_mul_eq_mul
-/- warning: int.div_dvd_of_dvd -> Int.ediv_dvd_of_dvd is a dubious translation:
-lean 3 declaration is
- forall {s : Int} {t : Int}, (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) s t) -> (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) t s) t)
-but is expected to have type
- forall {s : Int} {t : Int}, (Dvd.dvd.{0} Int Int.instDvdInt s t) -> (Dvd.dvd.{0} Int Int.instDvdInt (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) t s) t)
-Case conversion may be inaccurate. Consider using '#align int.div_dvd_of_dvd Int.ediv_dvd_of_dvdₓ'. -/
theorem ediv_dvd_of_dvd {s t : ℤ} (hst : s ∣ t) : t / s ∣ t :=
by
rcases eq_or_ne s 0 with (rfl | hs)
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -254,10 +254,8 @@ protected theorem le_induction {P : ℤ → Prop} {m : ℤ} (h0 : P m)
(h1 : ∀ n : ℤ, m ≤ n → P n → P (n + 1)) (n : ℤ) : m ≤ n → P n :=
by
apply Int.inductionOn' n m
- · intro
- exact h0
- · intro k hle hi _
- exact h1 k hle (hi hle)
+ · intro ; exact h0
+ · intro k hle hi _; exact h1 k hle (hi hle)
· intro _ hle _ hle'
exfalso
exact lt_irrefl k (le_sub_one_iff.mp (hle.trans hle'))
@@ -270,8 +268,7 @@ protected theorem le_induction_down {P : ℤ → Prop} {m : ℤ} (h0 : P m)
(h1 : ∀ n : ℤ, n ≤ m → P n → P (n - 1)) (n : ℤ) : n ≤ m → P n :=
by
apply Int.inductionOn' n m
- · intro
- exact h0
+ · intro ; exact h0
· intro _ hle _ hle'
exfalso
exact lt_irrefl k (add_one_le_iff.mp (hle'.trans hle))
@@ -335,15 +332,13 @@ protected theorem add_mul_ediv_right (a b : ℤ) {c : ℤ} (H : c ≠ 0) : (a +
cases' lt_or_ge m (n * k.succ) with h h
· rw [← Int.ofNat_sub h, ← Int.ofNat_sub ((Nat.div_lt_iff_lt_mul k.succ_pos).2 h)]
apply congr_arg of_nat
- rw [mul_comm, Nat.mul_sub_div]
- rwa [mul_comm]
+ rw [mul_comm, Nat.mul_sub_div]; rwa [mul_comm]
· change (↑(n * Nat.succ k) - (m + 1) : ℤ) / ↑(Nat.succ k) = ↑n - ((m / Nat.succ k : ℕ) + 1)
rw [← sub_sub, ← sub_sub, ← neg_sub (m : ℤ), ← neg_sub _ (n : ℤ), ← Int.ofNat_sub h, ←
Int.ofNat_sub ((Nat.le_div_iff_mul_le k.succ_pos).2 h), ← neg_succ_of_nat_coe', ←
neg_succ_of_nat_coe']
· apply congr_arg neg_succ_of_nat
- rw [mul_comm, Nat.sub_mul_div]
- rwa [mul_comm]
+ rw [mul_comm, Nat.sub_mul_div]; rwa [mul_comm]
have : ∀ {a b c : ℤ}, 0 < c → (a + b * c) / c = a / c + b := fun a b c H =>
match c, eq_succ_of_zero_lt H, b with
| _, ⟨k, rfl⟩, (n : ℕ) => this
@@ -897,17 +892,13 @@ theorem exists_lt_and_lt_iff_not_dvd (m : ℤ) {n : ℤ} (hn : 0 < n) :
(∃ k, n * k < m ∧ m < n * (k + 1)) ↔ ¬n ∣ m :=
by
constructor
- · rintro ⟨k, h1k, h2k⟩ ⟨l, rfl⟩
- rw [mul_lt_mul_left hn] at h1k h2k
- rw [lt_add_one_iff, ← not_lt] at h2k
- exact h2k h1k
- · intro h
- rw [dvd_iff_mod_eq_zero, ← Ne.def] at h
+ · rintro ⟨k, h1k, h2k⟩ ⟨l, rfl⟩; rw [mul_lt_mul_left hn] at h1k h2k
+ rw [lt_add_one_iff, ← not_lt] at h2k; exact h2k h1k
+ · intro h; rw [dvd_iff_mod_eq_zero, ← Ne.def] at h
have := (mod_nonneg m hn.ne.symm).lt_of_ne h.symm
simp (config := { singlePass := true }) only [← mod_add_div m n]
refine' ⟨m / n, lt_add_of_pos_left _ this, _⟩
- rw [add_comm _ (1 : ℤ), left_distrib, mul_one]
- exact add_lt_add_right (mod_lt_of_pos _ hn) _
+ rw [add_comm _ (1 : ℤ), left_distrib, mul_one]; exact add_lt_add_right (mod_lt_of_pos _ hn) _
#align int.exists_lt_and_lt_iff_not_dvd Int.exists_lt_and_lt_iff_not_dvd
attribute [local simp] Int.div_zero
mathlib commit https://github.com/leanprover-community/mathlib/commit/06a655b5fcfbda03502f9158bbf6c0f1400886f9
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad
! This file was ported from Lean 3 source module data.int.order.basic
-! leanprover-community/mathlib commit 728baa2f54e6062c5879a3e397ac6bac323e506f
+! leanprover-community/mathlib commit e8638a0fcaf73e4500469f368ef9494e495099b3
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
@@ -954,7 +954,7 @@ but is expected to have type
Case conversion may be inaccurate. Consider using '#align int.sub_div_of_dvd Int.sub_ediv_of_dvdₓ'. -/
theorem sub_ediv_of_dvd (a : ℤ) {b c : ℤ} (hcb : c ∣ b) : (a - b) / c = a / c - b / c :=
by
- rw [sub_eq_add_neg, sub_eq_add_neg, Int.add_ediv_of_dvd_right ((dvd_neg c b).mpr hcb)]
+ rw [sub_eq_add_neg, sub_eq_add_neg, Int.add_ediv_of_dvd_right hcb.neg_right]
congr
exact neg_div_of_dvd hcb
#align int.sub_div_of_dvd Int.sub_ediv_of_dvd
mathlib commit https://github.com/leanprover-community/mathlib/commit/0148d455199ed64bf8eb2f493a1e7eb9211ce170
@@ -141,6 +141,7 @@ theorem abs_coe_nat (n : ℕ) : |(n : ℤ)| = n :=
abs_of_nonneg (coe_nat_nonneg n)
#align int.abs_coe_nat Int.abs_coe_nat
+#print Int.sign_add_eq_of_sign_eq /-
theorem sign_add_eq_of_sign_eq : ∀ {m n : ℤ}, m.sign = n.sign → (m + n).sign = n.sign :=
by
have : (1 : ℤ) ≠ -1 := by decide
@@ -148,6 +149,7 @@ theorem sign_add_eq_of_sign_eq : ∀ {m n : ℤ}, m.sign = n.sign → (m + n).si
rw [Int.sign_eq_one_iff_pos]
apply Int.add_pos <;> · exact zero_lt_one.trans_le (le_add_of_nonneg_left <| coe_zero_le _)
#align int.sign_add_eq_of_sign_eq Int.sign_add_eq_of_sign_eq
+-/
/-! ### succ and pred -/
mathlib commit https://github.com/leanprover-community/mathlib/commit/728baa2f54e6062c5879a3e397ac6bac323e506f
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad
! This file was ported from Lean 3 source module data.int.order.basic
-! leanprover-community/mathlib commit bd835ef554f37ef9b804f0903089211f89cb370b
+! leanprover-community/mathlib commit 728baa2f54e6062c5879a3e397ac6bac323e506f
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
@@ -141,6 +141,14 @@ theorem abs_coe_nat (n : ℕ) : |(n : ℤ)| = n :=
abs_of_nonneg (coe_nat_nonneg n)
#align int.abs_coe_nat Int.abs_coe_nat
+theorem sign_add_eq_of_sign_eq : ∀ {m n : ℤ}, m.sign = n.sign → (m + n).sign = n.sign :=
+ by
+ have : (1 : ℤ) ≠ -1 := by decide
+ rintro ((_ | m) | m) ((_ | n) | n) <;> simp [this, this.symm]
+ rw [Int.sign_eq_one_iff_pos]
+ apply Int.add_pos <;> · exact zero_lt_one.trans_le (le_add_of_nonneg_left <| coe_zero_le _)
+#align int.sign_add_eq_of_sign_eq Int.sign_add_eq_of_sign_eq
+
/-! ### succ and pred -/
mathlib commit https://github.com/leanprover-community/mathlib/commit/da3fc4a33ff6bc75f077f691dc94c217b8d41559
@@ -67,7 +67,7 @@ namespace Int
lean 3 declaration is
forall (a : Int), Eq.{1} Int (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) a) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (Int.natAbs a))
but is expected to have type
- forall (a : Int), Eq.{1} Int (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) a) (Nat.cast.{0} Int Int.instNatCastInt (Int.natAbs a))
+ forall (a : Int), Eq.{1} Int (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) a) (Nat.cast.{0} Int instNatCastInt (Int.natAbs a))
Case conversion may be inaccurate. Consider using '#align int.abs_eq_nat_abs Int.abs_eq_natAbsₓ'. -/
theorem abs_eq_natAbs : ∀ a : ℤ, |a| = natAbs a
| (n : ℕ) => abs_of_nonneg <| ofNat_zero_le _
@@ -78,7 +78,7 @@ theorem abs_eq_natAbs : ∀ a : ℤ, |a| = natAbs a
lean 3 declaration is
forall (n : Int), Eq.{1} Int ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (Int.natAbs n)) (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) n)
but is expected to have type
- forall (n : Int), Eq.{1} Int (Nat.cast.{0} Int Int.instNatCastInt (Int.natAbs n)) (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) n)
+ forall (n : Int), Eq.{1} Int (Nat.cast.{0} Int instNatCastInt (Int.natAbs n)) (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) n)
Case conversion may be inaccurate. Consider using '#align int.coe_nat_abs Int.coe_natAbsₓ'. -/
@[simp, norm_cast]
theorem coe_natAbs (n : ℤ) : (n.natAbs : ℤ) = |n| :=
@@ -134,7 +134,7 @@ theorem coe_nat_ne_zero_iff_pos {n : ℕ} : (n : ℤ) ≠ 0 ↔ 0 < n :=
lean 3 declaration is
forall (n : Nat), Eq.{1} Int (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) n)) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) n)
but is expected to have type
- forall (n : Nat), Eq.{1} Int (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) (Nat.cast.{0} Int Int.instNatCastInt n)) (Nat.cast.{0} Int Int.instNatCastInt n)
+ forall (n : Nat), Eq.{1} Int (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) (Nat.cast.{0} Int instNatCastInt n)) (Nat.cast.{0} Int instNatCastInt n)
Case conversion may be inaccurate. Consider using '#align int.abs_coe_nat Int.abs_coe_natₓ'. -/
@[norm_cast]
theorem abs_coe_nat (n : ℕ) : |(n : ℤ)| = n :=
@@ -723,7 +723,7 @@ theorem dvd_sub_of_emod_eq {a b c : ℤ} (h : a % b = c) : b ∣ a - c :=
lean 3 declaration is
forall {a : Int} {b : Int}, Iff (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (Int.natAbs a)) b) (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) a b)
but is expected to have type
- forall {a : Int} {b : Int}, Iff (Dvd.dvd.{0} Int Int.instDvdInt (Nat.cast.{0} Int Int.instNatCastInt (Int.natAbs a)) b) (Dvd.dvd.{0} Int Int.instDvdInt a b)
+ forall {a : Int} {b : Int}, Iff (Dvd.dvd.{0} Int Int.instDvdInt (Nat.cast.{0} Int instNatCastInt (Int.natAbs a)) b) (Dvd.dvd.{0} Int Int.instDvdInt a b)
Case conversion may be inaccurate. Consider using '#align int.nat_abs_dvd Int.natAbs_dvdₓ'. -/
theorem natAbs_dvd {a b : ℤ} : (a.natAbs : ℤ) ∣ b ↔ a ∣ b :=
(natAbs_eq a).elim (fun e => by rw [← e]) fun e => by rw [← neg_dvd, ← e]
@@ -733,7 +733,7 @@ theorem natAbs_dvd {a b : ℤ} : (a.natAbs : ℤ) ∣ b ↔ a ∣ b :=
lean 3 declaration is
forall {a : Int} {b : Int}, Iff (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) a ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (Int.natAbs b))) (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) a b)
but is expected to have type
- forall {a : Int} {b : Int}, Iff (Dvd.dvd.{0} Int Int.instDvdInt a (Nat.cast.{0} Int Int.instNatCastInt (Int.natAbs b))) (Dvd.dvd.{0} Int Int.instDvdInt a b)
+ forall {a : Int} {b : Int}, Iff (Dvd.dvd.{0} Int Int.instDvdInt a (Nat.cast.{0} Int instNatCastInt (Int.natAbs b))) (Dvd.dvd.{0} Int Int.instDvdInt a b)
Case conversion may be inaccurate. Consider using '#align int.dvd_nat_abs Int.dvd_natAbsₓ'. -/
theorem dvd_natAbs {a b : ℤ} : a ∣ b.natAbs ↔ a ∣ b :=
(natAbs_eq b).elim (fun e => by rw [← e]) fun e => by rw [← dvd_neg, ← e]
mathlib commit https://github.com/leanprover-community/mathlib/commit/3180fab693e2cee3bff62675571264cb8778b212
@@ -448,7 +448,7 @@ theorem emod_lt (a : ℤ) {b : ℤ} (H : b ≠ 0) : a % b < |b| := by
#print Int.add_mul_emod_self /-
@[simp]
theorem add_mul_emod_self {a b c : ℤ} : (a + b * c) % c = a % c :=
- if cz : c = 0 then by rw [cz, mul_zero, add_zero]
+ if cz : c = 0 then by rw [cz, MulZeroClass.mul_zero, add_zero]
else by
rw [mod_def, mod_def, Int.add_mul_ediv_right _ _ cz, mul_add, mul_comm,
add_sub_add_right_eq_sub]
@@ -849,7 +849,7 @@ but is expected to have type
forall {d : Int} {n : Int}, (Dvd.dvd.{0} Int Int.instDvdInt d n) -> (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) n d) (OfNat.ofNat.{0} Int 0 (instOfNatInt 0))) -> (Eq.{1} Int n (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)))
Case conversion may be inaccurate. Consider using '#align int.eq_zero_of_div_eq_zero Int.eq_zero_of_ediv_eq_zeroₓ'. -/
protected theorem eq_zero_of_ediv_eq_zero {d n : ℤ} (h : d ∣ n) (H : n / d = 0) : n = 0 := by
- rw [← Int.mul_ediv_cancel' h, H, mul_zero]
+ rw [← Int.mul_ediv_cancel' h, H, MulZeroClass.mul_zero]
#align int.eq_zero_of_div_eq_zero Int.eq_zero_of_ediv_eq_zero
/- warning: int.div_left_inj -> Int.ediv_left_inj is a dubious translation:
@@ -1073,7 +1073,7 @@ but is expected to have type
forall {a : Int} {b : Int}, (LT.lt.{0} Int Int.instLTInt (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)) a) -> (LE.le.{0} Int Int.instLEInt (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)) b) -> (Dvd.dvd.{0} Int Int.instDvdInt b a) -> (LT.lt.{0} Int Int.instLTInt (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) a b))
Case conversion may be inaccurate. Consider using '#align int.div_pos_of_pos_of_dvd Int.ediv_pos_of_pos_of_dvdₓ'. -/
theorem ediv_pos_of_pos_of_dvd {a b : ℤ} (H1 : 0 < a) (H2 : 0 ≤ b) (H3 : b ∣ a) : 0 < a / b :=
- Int.lt_ediv_of_mul_lt H2 H3 (by rwa [zero_mul])
+ Int.lt_ediv_of_mul_lt H2 H3 (by rwa [MulZeroClass.zero_mul])
#align int.div_pos_of_pos_of_dvd Int.ediv_pos_of_pos_of_dvd
/- warning: int.nat_abs_eq_of_dvd_dvd -> Int.natAbs_eq_of_dvd_dvd is a dubious translation:
mathlib commit https://github.com/leanprover-community/mathlib/commit/9da1b3534b65d9661eb8f42443598a92bbb49211
@@ -67,7 +67,7 @@ namespace Int
lean 3 declaration is
forall (a : Int), Eq.{1} Int (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) a) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (Int.natAbs a))
but is expected to have type
- forall (a : Int), Eq.{1} Int (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) a) (Nat.cast.{0} Int Int.instNatCastInt (Int.natAbs a))
+ forall (a : Int), Eq.{1} Int (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) a) (Nat.cast.{0} Int Int.instNatCastInt (Int.natAbs a))
Case conversion may be inaccurate. Consider using '#align int.abs_eq_nat_abs Int.abs_eq_natAbsₓ'. -/
theorem abs_eq_natAbs : ∀ a : ℤ, |a| = natAbs a
| (n : ℕ) => abs_of_nonneg <| ofNat_zero_le _
@@ -78,7 +78,7 @@ theorem abs_eq_natAbs : ∀ a : ℤ, |a| = natAbs a
lean 3 declaration is
forall (n : Int), Eq.{1} Int ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (Int.natAbs n)) (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) n)
but is expected to have type
- forall (n : Int), Eq.{1} Int (Nat.cast.{0} Int Int.instNatCastInt (Int.natAbs n)) (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) n)
+ forall (n : Int), Eq.{1} Int (Nat.cast.{0} Int Int.instNatCastInt (Int.natAbs n)) (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) n)
Case conversion may be inaccurate. Consider using '#align int.coe_nat_abs Int.coe_natAbsₓ'. -/
@[simp, norm_cast]
theorem coe_natAbs (n : ℤ) : (n.natAbs : ℤ) = |n| :=
@@ -89,7 +89,7 @@ theorem coe_natAbs (n : ℤ) : (n.natAbs : ℤ) = |n| :=
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : AddGroupWithOne.{u1} α] (n : Int), Eq.{succ u1} α ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α _inst_1))))) (Int.natAbs n)) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Int α (HasLiftT.mk.{1, succ u1} Int α (CoeTCₓ.coe.{1, succ u1} Int α (Int.castCoe.{u1} α (AddGroupWithOne.toHasIntCast.{u1} α _inst_1)))) (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) n))
but is expected to have type
- forall {α : Type.{u1}} [_inst_1 : AddGroupWithOne.{u1} α] (n : Int), Eq.{succ u1} α (Nat.cast.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α _inst_1)) (Int.natAbs n)) (Int.cast.{u1} α (AddGroupWithOne.toIntCast.{u1} α _inst_1) (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) n))
+ forall {α : Type.{u1}} [_inst_1 : AddGroupWithOne.{u1} α] (n : Int), Eq.{succ u1} α (Nat.cast.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α _inst_1)) (Int.natAbs n)) (Int.cast.{u1} α (AddGroupWithOne.toIntCast.{u1} α _inst_1) (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) n))
Case conversion may be inaccurate. Consider using '#align nat.cast_nat_abs Nat.cast_natAbsₓ'. -/
theorem Nat.cast_natAbs {α : Type _} [AddGroupWithOne α] (n : ℤ) : (n.natAbs : α) = ↑(|n|) := by
rw [← Int.coe_natAbs, Int.cast_ofNat]
@@ -99,7 +99,7 @@ theorem Nat.cast_natAbs {α : Type _} [AddGroupWithOne α] (n : ℤ) : (n.natAbs
lean 3 declaration is
forall (a : Int), Eq.{1} Nat (Int.natAbs (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) a)) (Int.natAbs a)
but is expected to have type
- forall (a : Int), Eq.{1} Nat (Int.natAbs (Abs.abs.{0} ([mdata borrowed:1 Int]) (Neg.toHasAbs.{0} ([mdata borrowed:1 Int]) Int.instNegInt (SemilatticeSup.toHasSup.{0} ([mdata borrowed:1 Int]) (Lattice.toSemilatticeSup.{0} ([mdata borrowed:1 Int]) (DistribLattice.toLattice.{0} ([mdata borrowed:1 Int]) (instDistribLattice.{0} ([mdata borrowed:1 Int]) Int.instLinearOrderInt))))) a)) (Int.natAbs a)
+ forall (a : Int), Eq.{1} Nat (Int.natAbs (Abs.abs.{0} ([mdata borrowed:1 Int]) (Neg.toHasAbs.{0} ([mdata borrowed:1 Int]) Int.instNegInt (SemilatticeSup.toSup.{0} ([mdata borrowed:1 Int]) (Lattice.toSemilatticeSup.{0} ([mdata borrowed:1 Int]) (DistribLattice.toLattice.{0} ([mdata borrowed:1 Int]) (instDistribLattice.{0} ([mdata borrowed:1 Int]) Int.instLinearOrderInt))))) a)) (Int.natAbs a)
Case conversion may be inaccurate. Consider using '#align int.nat_abs_abs Int.natAbs_absₓ'. -/
theorem natAbs_abs (a : ℤ) : natAbs (|a|) = natAbs a := by rw [abs_eq_nat_abs] <;> rfl
#align int.nat_abs_abs Int.natAbs_abs
@@ -108,7 +108,7 @@ theorem natAbs_abs (a : ℤ) : natAbs (|a|) = natAbs a := by rw [abs_eq_nat_abs]
lean 3 declaration is
forall (a : Int), Eq.{1} Int (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) (Int.sign a) (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) a)) a
but is expected to have type
- forall (a : Int), Eq.{1} Int (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) (Int.sign a) (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) a)) a
+ forall (a : Int), Eq.{1} Int (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) (Int.sign a) (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) a)) a
Case conversion may be inaccurate. Consider using '#align int.sign_mul_abs Int.sign_mul_absₓ'. -/
theorem sign_mul_abs (a : ℤ) : sign a * |a| = a := by rw [abs_eq_nat_abs, sign_mul_nat_abs]
#align int.sign_mul_abs Int.sign_mul_abs
@@ -134,7 +134,7 @@ theorem coe_nat_ne_zero_iff_pos {n : ℕ} : (n : ℤ) ≠ 0 ↔ 0 < n :=
lean 3 declaration is
forall (n : Nat), Eq.{1} Int (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) n)) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) n)
but is expected to have type
- forall (n : Nat), Eq.{1} Int (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) (Nat.cast.{0} Int Int.instNatCastInt n)) (Nat.cast.{0} Int Int.instNatCastInt n)
+ forall (n : Nat), Eq.{1} Int (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) (Nat.cast.{0} Int Int.instNatCastInt n)) (Nat.cast.{0} Int Int.instNatCastInt n)
Case conversion may be inaccurate. Consider using '#align int.abs_coe_nat Int.abs_coe_natₓ'. -/
@[norm_cast]
theorem abs_coe_nat (n : ℕ) : |(n : ℤ)| = n :=
@@ -184,7 +184,7 @@ theorem le_sub_one_iff {a b : ℤ} : a ≤ b - 1 ↔ a < b :=
lean 3 declaration is
forall {a : Int}, Iff (LT.lt.{0} Int Int.hasLt (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) a) (OfNat.ofNat.{0} Int 1 (OfNat.mk.{0} Int 1 (One.one.{0} Int Int.hasOne)))) (Eq.{1} Int a (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero))))
but is expected to have type
- forall {a : Int}, Iff (LT.lt.{0} Int Int.instLTInt (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) a) (OfNat.ofNat.{0} Int 1 (instOfNatInt 1))) (Eq.{1} Int a (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)))
+ forall {a : Int}, Iff (LT.lt.{0} Int Int.instLTInt (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) a) (OfNat.ofNat.{0} Int 1 (instOfNatInt 1))) (Eq.{1} Int a (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)))
Case conversion may be inaccurate. Consider using '#align int.abs_lt_one_iff Int.abs_lt_one_iffₓ'. -/
@[simp]
theorem abs_lt_one_iff {a : ℤ} : |a| < 1 ↔ a = 0 :=
@@ -198,7 +198,7 @@ theorem abs_lt_one_iff {a : ℤ} : |a| < 1 ↔ a = 0 :=
lean 3 declaration is
forall {a : Int}, Iff (LE.le.{0} Int Int.hasLe (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) a) (OfNat.ofNat.{0} Int 1 (OfNat.mk.{0} Int 1 (One.one.{0} Int Int.hasOne)))) (Or (Eq.{1} Int a (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero)))) (Or (Eq.{1} Int a (OfNat.ofNat.{0} Int 1 (OfNat.mk.{0} Int 1 (One.one.{0} Int Int.hasOne)))) (Eq.{1} Int a (Neg.neg.{0} Int Int.hasNeg (OfNat.ofNat.{0} Int 1 (OfNat.mk.{0} Int 1 (One.one.{0} Int Int.hasOne)))))))
but is expected to have type
- forall {a : Int}, Iff (LE.le.{0} Int Int.instLEInt (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) a) (OfNat.ofNat.{0} Int 1 (instOfNatInt 1))) (Or (Eq.{1} Int a (OfNat.ofNat.{0} Int 0 (instOfNatInt 0))) (Or (Eq.{1} Int a (OfNat.ofNat.{0} Int 1 (instOfNatInt 1))) (Eq.{1} Int a (Neg.neg.{0} Int Int.instNegInt (OfNat.ofNat.{0} Int 1 (instOfNatInt 1))))))
+ forall {a : Int}, Iff (LE.le.{0} Int Int.instLEInt (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) a) (OfNat.ofNat.{0} Int 1 (instOfNatInt 1))) (Or (Eq.{1} Int a (OfNat.ofNat.{0} Int 0 (instOfNatInt 0))) (Or (Eq.{1} Int a (OfNat.ofNat.{0} Int 1 (instOfNatInt 1))) (Eq.{1} Int a (Neg.neg.{0} Int Int.instNegInt (OfNat.ofNat.{0} Int 1 (instOfNatInt 1))))))
Case conversion may be inaccurate. Consider using '#align int.abs_le_one_iff Int.abs_le_one_iffₓ'. -/
theorem 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' ℤ)]
@@ -208,7 +208,7 @@ theorem abs_le_one_iff {a : ℤ} : |a| ≤ 1 ↔ a = 0 ∨ a = 1 ∨ a = -1 := b
lean 3 declaration is
forall {z : Int}, (Ne.{1} Int z (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero)))) -> (LE.le.{0} Int Int.hasLe (OfNat.ofNat.{0} Int 1 (OfNat.mk.{0} Int 1 (One.one.{0} Int Int.hasOne))) (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) z))
but is expected to have type
- forall {z : Int}, (Ne.{1} Int z (OfNat.ofNat.{0} Int 0 (instOfNatInt 0))) -> (LE.le.{0} Int Int.instLEInt (OfNat.ofNat.{0} Int 1 (instOfNatInt 1)) (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) z))
+ forall {z : Int}, (Ne.{1} Int z (OfNat.ofNat.{0} Int 0 (instOfNatInt 0))) -> (LE.le.{0} Int Int.instLEInt (OfNat.ofNat.{0} Int 1 (instOfNatInt 1)) (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) z))
Case conversion may be inaccurate. Consider using '#align int.one_le_abs Int.one_le_absₓ'. -/
theorem one_le_abs {z : ℤ} (h₀ : z ≠ 0) : 1 ≤ |z| :=
add_one_le_iff.mpr (abs_pos.mpr h₀)
@@ -306,7 +306,7 @@ protected theorem ediv_nonpos {a b : ℤ} (Ha : 0 ≤ a) (Hb : b ≤ 0) : a / b
lean 3 declaration is
forall {a : Int} {b : Int}, (LE.le.{0} Int Int.hasLe (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero))) a) -> (LT.lt.{0} Int Int.hasLt a (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) b)) -> (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) a b) (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero))))
but is expected to have type
- forall {a : Int} {b : Int}, (LE.le.{0} Int Int.instLEInt (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)) a) -> (LT.lt.{0} Int Int.instLTInt a (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) b)) -> (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) a b) (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)))
+ forall {a : Int} {b : Int}, (LE.le.{0} Int Int.instLEInt (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)) a) -> (LT.lt.{0} Int Int.instLTInt a (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) b)) -> (Eq.{1} Int (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) a b) (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)))
Case conversion may be inaccurate. Consider using '#align int.div_eq_zero_of_lt_abs Int.ediv_eq_zero_of_lt_absₓ'. -/
theorem ediv_eq_zero_of_lt_abs {a b : ℤ} (H1 : 0 ≤ a) (H2 : a < |b|) : a / b = 0 :=
match b, |b|, abs_eq_natAbs b, H2 with
@@ -412,7 +412,7 @@ protected theorem add_ediv_of_dvd_left {a b c : ℤ} (H : c ∣ a) : (a + b) / c
lean 3 declaration is
forall (a : Int) (b : Int), Eq.{1} Int (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.hasMod) a (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) b)) (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.hasMod) a b)
but is expected to have type
- forall (a : Int) (b : Int), Eq.{1} Int (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.instModInt_1) a (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) b)) (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.instModInt_1) a b)
+ forall (a : Int) (b : Int), Eq.{1} Int (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.instModInt_1) a (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) b)) (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.instModInt_1) a b)
Case conversion may be inaccurate. Consider using '#align int.mod_abs Int.emod_absₓ'. -/
@[simp]
theorem emod_abs (a b : ℤ) : a % |b| = a % b :=
@@ -439,7 +439,7 @@ theorem emod_lt_of_pos (a : ℤ) {b : ℤ} (H : 0 < b) : a % b < b :=
lean 3 declaration is
forall (a : Int) {b : Int}, (Ne.{1} Int b (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero)))) -> (LT.lt.{0} Int Int.hasLt (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.hasMod) a b) (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) b))
but is expected to have type
- forall (a : Int) {b : Int}, (Ne.{1} Int b (OfNat.ofNat.{0} Int 0 (instOfNatInt 0))) -> (LT.lt.{0} Int Int.instLTInt (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.instModInt_1) a b) (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) b))
+ forall (a : Int) {b : Int}, (Ne.{1} Int b (OfNat.ofNat.{0} Int 0 (instOfNatInt 0))) -> (LT.lt.{0} Int Int.instLTInt (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.instModInt_1) a b) (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) b))
Case conversion may be inaccurate. Consider using '#align int.mod_lt Int.emod_ltₓ'. -/
theorem emod_lt (a : ℤ) {b : ℤ} (H : b ≠ 0) : a % b < |b| := by
rw [← mod_abs] <;> exact mod_lt_of_pos _ (abs_pos.2 H)
@@ -637,7 +637,7 @@ theorem lt_ediv_add_one_mul_self (a : ℤ) {b : ℤ} (H : 0 < b) : a < (a / b +
lean 3 declaration is
forall (a : Int) (b : Int), LE.le.{0} Int Int.hasLe (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) a b)) (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) a)
but is expected to have type
- forall (a : Int) (b : Int), LE.le.{0} Int Int.instLEInt (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) a b)) (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) a)
+ forall (a : Int) (b : Int), LE.le.{0} Int Int.instLEInt (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) a b)) (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) a)
Case conversion may be inaccurate. Consider using '#align int.abs_div_le_abs Int.abs_ediv_le_absₓ'. -/
theorem abs_ediv_le_abs : ∀ a b : ℤ, |a / b| ≤ |a| :=
suffices ∀ (a : ℤ) (n : ℕ), |a / n| ≤ |a| from fun a b =>
@@ -869,7 +869,7 @@ protected theorem ediv_left_inj {a b d : ℤ} (hda : d ∣ a) (hdb : d ∣ b) :
lean 3 declaration is
forall {z : Int}, (Ne.{1} Int z (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero)))) -> (Eq.{1} Int (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) (Int.sign z)) (OfNat.ofNat.{0} Int 1 (OfNat.mk.{0} Int 1 (One.one.{0} Int Int.hasOne))))
but is expected to have type
- forall {z : Int}, (Ne.{1} Int z (OfNat.ofNat.{0} Int 0 (instOfNatInt 0))) -> (Eq.{1} Int (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) (Int.sign z)) (OfNat.ofNat.{0} Int 1 (instOfNatInt 1)))
+ forall {z : Int}, (Ne.{1} Int z (OfNat.ofNat.{0} Int 0 (instOfNatInt 0))) -> (Eq.{1} Int (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) (Int.sign z)) (OfNat.ofNat.{0} Int 1 (instOfNatInt 1)))
Case conversion may be inaccurate. Consider using '#align int.abs_sign_of_nonzero Int.abs_sign_of_nonzeroₓ'. -/
theorem abs_sign_of_nonzero {z : ℤ} (hz : z ≠ 0) : |z.sign| = 1 := by
rw [abs_eq_nat_abs, nat_abs_sign_of_nonzero hz, Int.ofNat_one]
@@ -963,7 +963,7 @@ theorem sub_ediv_of_dvd_sub {a b c : ℤ} (hcab : c ∣ a - b) : (a - b) / c = a
lean 3 declaration is
forall (a : Int), Eq.{1} Int (Int.sign a) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) a (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.hasNeg (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (LinearOrder.toLattice.{0} Int Int.linearOrder)))) a))
but is expected to have type
- forall (a : Int), Eq.{1} Int (Int.sign a) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) a (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toHasSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) a))
+ forall (a : Int), Eq.{1} Int (Int.sign a) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) a (Abs.abs.{0} Int (Neg.toHasAbs.{0} Int Int.instNegInt (SemilatticeSup.toSup.{0} Int (Lattice.toSemilatticeSup.{0} Int (DistribLattice.toLattice.{0} Int (instDistribLattice.{0} Int Int.instLinearOrderInt))))) a))
Case conversion may be inaccurate. Consider using '#align int.sign_eq_div_abs Int.sign_eq_ediv_absₓ'. -/
protected theorem sign_eq_ediv_abs (a : ℤ) : sign a = a / |a| :=
if az : a = 0 then by simp [az]
mathlib commit https://github.com/leanprover-community/mathlib/commit/bd9851ca476957ea4549eb19b40e7b5ade9428cc
@@ -411,8 +411,8 @@ theorem toNat_le_toNat {a b : ℤ} (h : a ≤ b) : toNat a ≤ toNat b := by
#align int.to_nat_le_to_nat Int.toNat_le_toNat
theorem toNat_lt_toNat {a b : ℤ} (hb : 0 < b) : toNat a < toNat b ↔ a < b :=
- ⟨fun h => by cases a; exact lt_toNat.1 h; exact lt_trans (neg_of_sign_eq_neg_one rfl) hb,
- fun h => by rw [lt_toNat]; cases a; exact h; exact hb⟩
+ ⟨fun h => by cases a; exacts [lt_toNat.1 h, lt_trans (neg_of_sign_eq_neg_one rfl) hb],
+ fun h => by rw [lt_toNat]; cases a; exacts [h, hb]⟩
#align int.to_nat_lt_to_nat Int.toNat_lt_toNat
theorem lt_of_toNat_lt {a b : ℤ} (h : toNat a < toNat b) : a < b :=
Int
and Rat
instances (#12235)
Fix a few names and deduplicate the AddCommGroup ℤ
instance
@@ -14,7 +14,7 @@ import Mathlib.Algebra.Order.Ring.Defs
# The integers form a linear ordered ring
This file contains:
-* instances on `ℤ`. The stronger one is `Int.linearOrderedCommRing`.
+* instances on `ℤ`. The stronger one is `Int.instLinearOrderedCommRing`.
* basic lemmas about integers that involve order properties.
## Recursors
@@ -31,10 +31,12 @@ open Function Nat
namespace Int
-instance linearOrderedCommRing : LinearOrderedCommRing ℤ :=
- { instCommRingInt, instLinearOrderInt, instNontrivialInt with
- add_le_add_left := @Int.add_le_add_left,
- mul_pos := @Int.mul_pos, zero_le_one := le_of_lt Int.zero_lt_one }
+instance instLinearOrderedCommRing : LinearOrderedCommRing ℤ where
+ __ := instCommRing
+ __ := instLinearOrder
+ add_le_add_left := @Int.add_le_add_left
+ mul_pos := @Int.mul_pos
+ zero_le_one := le_of_lt Int.zero_lt_one
/-!
### Extra instances to short-circuit type class resolution
@@ -42,11 +44,8 @@ instance linearOrderedCommRing : LinearOrderedCommRing ℤ :=
These also prevent non-computable instances being used to construct these instances non-computably.
-/
-instance orderedCommRing : OrderedCommRing ℤ :=
- StrictOrderedCommRing.toOrderedCommRing'
-
-instance orderedRing : OrderedRing ℤ :=
- StrictOrderedRing.toOrderedRing'
+instance instOrderedCommRing : OrderedCommRing ℤ := StrictOrderedCommRing.toOrderedCommRing'
+instance instOrderedRing : OrderedRing ℤ := StrictOrderedRing.toOrderedRing'
/-! ### Miscellaneous lemmas -/
Int
and Rat
instances (#12235)
Fix a few names and deduplicate the AddCommGroup ℤ
instance
@@ -33,7 +33,7 @@ open Function Nat
namespace Int
instance linearOrderedAddCommGroup : LinearOrderedAddCommGroup ℤ where
- __ := instLinearOrderInt
+ __ := instLinearOrder
__ := instAddCommGroup
add_le_add_left _ _ := Int.add_le_add_left
Data.{Nat,Int}{.Order}.Basic
in group vs ring instances (#11924)
Scatter the content of Data.Nat.Basic
across:
Data.Nat.Defs
for the lemmas having no dependenciesAlgebra.Group.Nat
for the monoid instances and the few miscellaneous lemmas needing them.Algebra.Ring.Nat
for the semiring instance and the few miscellaneous lemmas following it.Similarly, scatter
Data.Int.Basic
across Data.Int.Defs
, Algebra.Group.Int
, Algebra.Ring.Int
Data.Nat.Order.Basic
across Data.Nat.Defs
, Algebra.Order.Group.Nat
, Algebra.Order.Ring.Nat
Data.Int.Order.Basic
across Data.Int.Defs
, Algebra.Order.Group.Int
, Algebra.Order.Ring.Int
Also move a few lemmas from Data.Nat.Order.Lemmas
to Data.Nat.Defs
.
Before
After
Data.{Nat,Int}{.Order}.Basic
in group vs ring instances (#11924)
Scatter the content of Data.Nat.Basic
across:
Data.Nat.Defs
for the lemmas having no dependenciesAlgebra.Group.Nat
for the monoid instances and the few miscellaneous lemmas needing them.Algebra.Ring.Nat
for the semiring instance and the few miscellaneous lemmas following it.Similarly, scatter
Data.Int.Basic
across Data.Int.Defs
, Algebra.Group.Int
, Algebra.Ring.Int
Data.Nat.Order.Basic
across Data.Nat.Defs
, Algebra.Order.Group.Nat
, Algebra.Order.Ring.Nat
Data.Int.Order.Basic
across Data.Int.Defs
, Algebra.Order.Group.Int
, Algebra.Order.Ring.Int
Also move a few lemmas from Data.Nat.Order.Lemmas
to Data.Nat.Defs
.
Before
After
@@ -3,20 +3,18 @@ Copyright (c) 2016 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad
-/
-import Mathlib.Data.Nat.Order.Basic
-import Mathlib.Data.Int.Basic
+import Mathlib.Algebra.Group.Int
import Mathlib.Algebra.Order.Group.Abs
-import Mathlib.Algebra.Order.Ring.CharZero
import Mathlib.Algebra.Divisibility.Basic
#align_import data.int.order.basic from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3"
/-!
-# Order instances on the integers
+# The integers form a linear ordered group
-This file contains:
-* instances on `ℤ`. The stronger one is `Int.linearOrderedCommRing`.
-* basic lemmas about integers that involve order properties.
+This file contains the linear ordered group instance on the integers.
+
+See note [foundational algebra order theory].
## Recursors
@@ -28,30 +26,18 @@ This file contains:
induction on numbers less than `b`.
-/
+assert_not_exists Ring
+
open Function Nat
namespace Int
-instance linearOrderedCommRing : LinearOrderedCommRing ℤ :=
- { instCommRingInt, instLinearOrderInt, instNontrivialInt with
- add_le_add_left := @Int.add_le_add_left,
- mul_pos := @Int.mul_pos, zero_le_one := le_of_lt Int.zero_lt_one }
-
-/-! ### Extra instances to short-circuit type class resolution
--/
-
+instance linearOrderedAddCommGroup : LinearOrderedAddCommGroup ℤ where
+ __ := instLinearOrderInt
+ __ := instAddCommGroup
+ add_le_add_left _ _ := Int.add_le_add_left
-instance orderedCommRing : OrderedCommRing ℤ :=
- StrictOrderedCommRing.toOrderedCommRing'
-
-instance orderedRing : OrderedRing ℤ :=
- StrictOrderedRing.toOrderedRing'
-
-instance linearOrderedAddCommGroup : LinearOrderedAddCommGroup ℤ := by infer_instance
-
-end Int
-
-namespace Int
+/-! ### Miscellaneous lemmas -/
theorem abs_eq_natAbs : ∀ a : ℤ, |a| = natAbs a
| (n : ℕ) => abs_of_nonneg <| ofNat_zero_le _
@@ -61,10 +47,6 @@ theorem abs_eq_natAbs : ∀ a : ℤ, |a| = natAbs a
@[simp, norm_cast] lemma natCast_natAbs (n : ℤ) : (n.natAbs : ℤ) = |n| := n.abs_eq_natAbs.symm
#align int.coe_nat_abs Int.natCast_natAbs
-lemma _root_.Nat.cast_natAbs {α : Type*} [AddGroupWithOne α] (n : ℤ) : (n.natAbs : α) = |n| := by
- rw [← natCast_natAbs, Int.cast_natCast]
-#align nat.cast_nat_abs Nat.cast_natAbs
-
theorem natAbs_abs (a : ℤ) : natAbs |a| = natAbs a := by rw [abs_eq_natAbs]; rfl
#align int.nat_abs_abs Int.natAbs_abs
@@ -72,12 +54,6 @@ theorem sign_mul_abs (a : ℤ) : sign a * |a| = a := by
rw [abs_eq_natAbs, sign_mul_natAbs a]
#align int.sign_mul_abs Int.sign_mul_abs
-lemma natAbs_sq (x : ℤ) : (x.natAbs : ℤ) ^ 2 = x ^ 2 := by rw [sq, Int.natAbs_mul_self', sq]
-#align int.nat_abs_sq Int.natAbs_sq
-
-alias natAbs_pow_two := natAbs_sq
-#align int.nat_abs_pow_two Int.natAbs_pow_two
-
lemma natAbs_le_self_sq (a : ℤ) : (Int.natAbs a : ℤ) ≤ a ^ 2 := by
rw [← Int.natAbs_sq a, sq]
norm_cast
@@ -92,50 +68,23 @@ lemma le_self_sq (b : ℤ) : b ≤ b ^ 2 := le_trans le_natAbs (natAbs_le_self_s
alias le_self_pow_two := le_self_sq
#align int.le_self_pow_two Int.le_self_pow_two
-theorem natCast_eq_zero {n : ℕ} : (n : ℤ) = 0 ↔ n = 0 :=
- Nat.cast_eq_zero
-#align int.coe_nat_eq_zero Int.natCast_eq_zero
-
-theorem natCast_ne_zero {n : ℕ} : (n : ℤ) ≠ 0 ↔ n ≠ 0 := by simp
-#align int.coe_nat_ne_zero Int.natCast_ne_zero
-
-theorem natCast_ne_zero_iff_pos {n : ℕ} : (n : ℤ) ≠ 0 ↔ 0 < n :=
- ⟨fun h => Nat.pos_of_ne_zero (natCast_ne_zero.1 h),
- fun h => (_root_.ne_of_lt (ofNat_lt.2 h)).symm⟩
-#align int.coe_nat_ne_zero_iff_pos Int.natCast_ne_zero_iff_pos
-
@[norm_cast] lemma abs_natCast (n : ℕ) : |(n : ℤ)| = n := abs_of_nonneg (natCast_nonneg n)
#align int.abs_coe_nat Int.abs_natCast
-theorem sign_add_eq_of_sign_eq : ∀ {m n : ℤ}, m.sign = n.sign → (m + n).sign = n.sign := by
- have : (1 : ℤ) ≠ -1 := by decide
- rintro ((_ | m) | m) ((_ | n) | n) <;> simp [this, this.symm, Int.negSucc_add_negSucc]
- rw [Int.sign_eq_one_iff_pos]
- apply Int.add_pos <;> · exact zero_lt_one.trans_le (le_add_of_nonneg_left <| natCast_nonneg _)
-#align int.sign_add_eq_of_sign_eq Int.sign_add_eq_of_sign_eq
-
-/-- Note this holds in marginally more generality than `Int.cast_mul` -/
-lemma cast_mul_eq_zsmul_cast {α : Type*} [AddCommGroupWithOne α] :
- ∀ m n : ℤ, ↑(m * n) = m • (n : α) :=
- fun m ↦ Int.induction_on m (by simp) (fun _ ih ↦ by simp [add_mul, add_zsmul, ih]) fun _ ih ↦ by
- simp only [sub_mul, one_mul, cast_sub, ih, sub_zsmul, one_zsmul, ← sub_eq_add_neg, forall_const]
-#align int.cast_mul_eq_zsmul_cast Int.cast_mul_eq_zsmul_cast
-
theorem natAbs_sub_pos_iff {i j : ℤ} : 0 < natAbs (i - j) ↔ i ≠ j := by
rw [natAbs_pos, ne_eq, sub_eq_zero]
theorem natAbs_sub_ne_zero_iff {i j : ℤ} : natAbs (i - j) ≠ 0 ↔ i ≠ j :=
Nat.ne_zero_iff_zero_lt.trans natAbs_sub_pos_iff
-/-! ### succ and pred -/
-
+/-! #### succ and pred -/
theorem lt_succ_self (a : ℤ) : a < succ a :=
- lt_add_of_pos_right _ zero_lt_one
+ lt_add_of_pos_right _ Int.zero_lt_one
#align int.lt_succ_self Int.lt_succ_self
theorem pred_self_lt (a : ℤ) : pred a < a :=
- sub_lt_self _ zero_lt_one
+ sub_lt_self _ Int.zero_lt_one
#align int.pred_self_lt Int.pred_self_lt
#align int.lt_add_one_iff Int.lt_add_one_iff
@@ -158,7 +107,7 @@ theorem abs_lt_one_iff {a : ℤ} : |a| < 1 ↔ a = 0 := by
#align int.abs_lt_one_iff Int.abs_lt_one_iff
theorem 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' ℤ)]
+ rw [le_iff_lt_or_eq, abs_lt_one_iff, abs_eq Int.one_nonneg]
#align int.abs_le_one_iff Int.abs_le_one_iff
theorem one_le_abs {z : ℤ} (h₀ : z ≠ 0) : 1 ≤ |z| :=
@@ -216,8 +165,7 @@ protected theorem le_induction_down {P : ℤ → Prop} {m : ℤ} (h0 : P m)
exact h1 k hle (hi hle)
#align int.le_induction_down Int.le_induction_down
-/-! ### nat abs -/
-
+/-! #### nat abs -/
variable {a b : ℤ} {n : ℕ}
@@ -225,7 +173,7 @@ attribute [simp] natAbs_ofNat natAbs_zero natAbs_one
#align int.nat_abs_dvd_iff_dvd Int.natAbs_dvd_natAbs
-/-! ### `/` -/
+/-! #### `/` -/
#align int.div_nonpos Int.ediv_nonpos
@@ -251,8 +199,7 @@ attribute [local simp] Int.zero_ediv Int.ediv_zero
#align int.add_div_of_dvd_left Int.add_ediv_of_dvd_left
-/-! ### mod -/
-
+/-! #### mod -/
@[simp]
theorem emod_abs (a b : ℤ) : a % |b| = a % b :=
@@ -319,7 +266,7 @@ attribute [local simp] Int.zero_emod
theorem neg_emod_two (i : ℤ) : -i % 2 = i % 2 := by
apply Int.emod_eq_emod_iff_emod_sub_eq_zero.mpr
convert Int.mul_emod_right 2 (-i) using 2
- rw [two_mul, sub_eq_add_neg]
+ rw [Int.two_mul, sub_eq_add_neg]
#align int.neg_mod_two Int.neg_emod_two
/-! ### properties of `/` and `%` -/
@@ -343,22 +290,7 @@ theorem abs_ediv_le_abs : ∀ a b : ℤ, |a / b| ≤ |a| :=
#align int.div_le_self Int.ediv_le_self
-theorem emod_two_eq_zero_or_one (n : ℤ) : n % 2 = 0 ∨ n % 2 = 1 :=
- have h : n % 2 < 2 := abs_of_nonneg (show 0 ≤ (2 : ℤ) by decide) ▸ Int.emod_lt _ (by decide)
- have h₁ : 0 ≤ n % 2 := Int.emod_nonneg _ (by decide)
- match n % 2, h, h₁ with
- | (0 : ℕ), _ ,_ => Or.inl rfl
- | (1 : ℕ), _ ,_ => Or.inr rfl
- -- Porting note: this used to be `=> absurd h (by decide)`
- -- see https://github.com/leanprover-community/mathlib4/issues/994
- | (k + 2 : ℕ), h₁, _ => False.elim (h₁.not_le (by
- rw [Nat.cast_add]
- exact (le_add_iff_nonneg_left 2).2 (NonNeg.mk k)))
- -- Porting note: this used to be `=> absurd h₁ (by decide)`
- | -[a+1], _, h₁ => by cases h₁
-#align int.mod_two_eq_zero_or_one Int.emod_two_eq_zero_or_one
-
-/-! ### dvd -/
+/-! #### dvd -/
#align int.dvd_of_mod_eq_zero Int.dvd_of_emod_eq_zero
@@ -408,24 +340,6 @@ theorem abs_sign_of_nonzero {z : ℤ} (hz : z ≠ 0) : |z.sign| = 1 := by
rw [abs_eq_natAbs, natAbs_sign_of_nonzero hz, Int.ofNat_one]
#align int.abs_sign_of_nonzero Int.abs_sign_of_nonzero
-/-- If `n > 0` then `m` is not divisible by `n` iff it is between `n * k` and `n * (k + 1)`
- for some `k`. -/
-theorem exists_lt_and_lt_iff_not_dvd (m : ℤ) {n : ℤ} (hn : 0 < n) :
- (∃ k, n * k < m ∧ m < n * (k + 1)) ↔ ¬n ∣ m := by
- constructor
- · rintro ⟨k, h1k, h2k⟩ ⟨l, rfl⟩
- rw [mul_lt_mul_left hn] at h1k h2k
- rw [lt_add_one_iff, ← not_lt] at h2k
- exact h2k h1k
- · intro h
- rw [dvd_iff_emod_eq_zero, ← Ne] at h
- have := (emod_nonneg m hn.ne.symm).lt_of_ne h.symm
- rw [← emod_add_ediv m n]
- refine' ⟨m / n, lt_add_of_pos_left _ this, _⟩
- rw [add_comm _ (1 : ℤ), left_distrib, mul_one]
- exact add_lt_add_right (emod_lt_of_pos _ hn) _
-#align int.exists_lt_and_lt_iff_not_dvd Int.exists_lt_and_lt_iff_not_dvd
-
attribute [local simp] Int.ediv_zero
#align int.mul_div_assoc Int.mul_ediv_assoc
@@ -443,7 +357,7 @@ protected theorem sign_eq_ediv_abs (a : ℤ) : sign a = a / |a| :=
else (Int.ediv_eq_of_eq_mul_left (mt abs_eq_zero.1 az) (sign_mul_abs _).symm).symm
#align int.sign_eq_div_abs Int.sign_eq_ediv_abs
-/-! ### `/` and ordering -/
+/-! #### `/` and ordering -/
#align int.div_mul_le Int.ediv_mul_le
#align int.div_le_of_le_mul Int.ediv_le_of_le_mul
@@ -473,7 +387,7 @@ theorem ediv_dvd_of_dvd {s t : ℤ} (hst : s ∣ t) : t / s ∣ t := by
simp [hc, Int.mul_ediv_cancel_left _ hs]
#align int.div_dvd_of_dvd Int.ediv_dvd_of_dvd
-/-! ### toNat -/
+/-! #### `toNat` -/
@[simp]
@@ -541,37 +455,5 @@ lemma zpow_abs_eq_one (a : G) (n : ℤ) : a ^ |n| = 1 ↔ a ^ n = 1 := by
end Group
-section bit0_bit1
-variable {R}
-set_option linter.deprecated false
-
--- The next four lemmas allow us to replace multiplication by a numeral with a `zsmul` expression.
-
-section NonUnitalNonAssocRing
-variable [NonUnitalNonAssocRing R] (n r : R)
-
-lemma bit0_mul : bit0 n * r = (2 : ℤ) • (n * r) := by
- rw [bit0, add_mul, ← one_add_one_eq_two, add_zsmul, one_zsmul]
-#align bit0_mul bit0_mul
-
-lemma mul_bit0 : r * bit0 n = (2 : ℤ) • (r * n) := by
- rw [bit0, mul_add, ← one_add_one_eq_two, add_zsmul, one_zsmul]
-#align mul_bit0 mul_bit0
-
-end NonUnitalNonAssocRing
-
-section NonAssocRing
-variable [NonAssocRing R] (n r : R)
-
-lemma bit1_mul : bit1 n * r = (2 : ℤ) • (n * r) + r := by rw [bit1, add_mul, bit0_mul, one_mul]
-#align bit1_mul bit1_mul
-
-lemma mul_bit1 {n r : R} : r * bit1 n = (2 : ℤ) • (r * n) + r := by
- rw [bit1, mul_add, mul_bit0, mul_one]
-#align mul_bit1 mul_bit1
-
-end NonAssocRing
-end bit0_bit1
-
-- We should need only a minimal development of sets in order to get here.
assert_not_exists Set.range
OfNat
and Nat.cast
lemmas (#11861)
This renames
Int.cast_ofNat
to Int.cast_natCast
Int.int_cast_ofNat
to Int.cast_ofNat
I think the history here is that this lemma was previously about Int.ofNat
, before we globally fixed the simp-normal form to be Nat.cast
.
Since the Int.cast_ofNat
name is repurposed, it can't be deprecated. Int.int_cast_ofNat
is such a wonky name that it was probably never used.
@@ -62,7 +62,7 @@ theorem abs_eq_natAbs : ∀ a : ℤ, |a| = natAbs a
#align int.coe_nat_abs Int.natCast_natAbs
lemma _root_.Nat.cast_natAbs {α : Type*} [AddGroupWithOne α] (n : ℤ) : (n.natAbs : α) = |n| := by
- rw [← natCast_natAbs, Int.cast_ofNat]
+ rw [← natCast_natAbs, Int.cast_natCast]
#align nat.cast_nat_abs Nat.cast_natAbs
theorem natAbs_abs (a : ℤ) : natAbs |a| = natAbs a := by rw [abs_eq_natAbs]; rfl
coe_nat
to natCast
(#11637)
Reduce the diff of #11499
All in the Int
namespace:
ofNat_eq_cast
→ ofNat_eq_natCast
cast_eq_cast_iff_Nat
→ natCast_inj
natCast_eq_ofNat
→ ofNat_eq_natCast
coe_nat_sub
→ natCast_sub
coe_nat_nonneg
→ natCast_nonneg
sign_coe_add_one
→ sign_natCast_add_one
nat_succ_eq_int_succ
→ natCast_succ
succ_neg_nat_succ
→ succ_neg_natCast_succ
coe_pred_of_pos
→ natCast_pred_of_pos
coe_nat_div
→ natCast_div
coe_nat_ediv
→ natCast_ediv
sign_coe_nat_of_nonzero
→ sign_natCast_of_ne_zero
toNat_coe_nat
→ toNat_natCast
toNat_coe_nat_add_one
→ toNat_natCast_add_one
coe_nat_dvd
→ natCast_dvd_natCast
coe_nat_dvd_left
→ natCast_dvd
coe_nat_dvd_right
→ dvd_natCast
le_coe_nat_sub
→ le_natCast_sub
succ_coe_nat_pos
→ succ_natCast_pos
coe_nat_modEq_iff
→ natCast_modEq_iff
coe_natAbs
→ natCast_natAbs
coe_nat_eq_zero
→ natCast_eq_zero
coe_nat_ne_zero
→ natCast_ne_zero
coe_nat_ne_zero_iff_pos
→ natCast_ne_zero_iff_pos
abs_coe_nat
→ abs_natCast
coe_nat_nonpos_iff
→ natCast_nonpos_iff
Also rename Nat.coe_nat_dvd
to Nat.cast_dvd_cast
@@ -58,11 +58,11 @@ theorem abs_eq_natAbs : ∀ a : ℤ, |a| = natAbs a
| -[_+1] => abs_of_nonpos <| le_of_lt <| negSucc_lt_zero _
#align int.abs_eq_nat_abs Int.abs_eq_natAbs
-@[simp, norm_cast] lemma coe_natAbs (n : ℤ) : (n.natAbs : ℤ) = |n| := n.abs_eq_natAbs.symm
-#align int.coe_nat_abs Int.coe_natAbs
+@[simp, norm_cast] lemma natCast_natAbs (n : ℤ) : (n.natAbs : ℤ) = |n| := n.abs_eq_natAbs.symm
+#align int.coe_nat_abs Int.natCast_natAbs
lemma _root_.Nat.cast_natAbs {α : Type*} [AddGroupWithOne α] (n : ℤ) : (n.natAbs : α) = |n| := by
- rw [← coe_natAbs, Int.cast_ofNat]
+ rw [← natCast_natAbs, Int.cast_ofNat]
#align nat.cast_nat_abs Nat.cast_natAbs
theorem natAbs_abs (a : ℤ) : natAbs |a| = natAbs a := by rw [abs_eq_natAbs]; rfl
@@ -92,26 +92,26 @@ lemma le_self_sq (b : ℤ) : b ≤ b ^ 2 := le_trans le_natAbs (natAbs_le_self_s
alias le_self_pow_two := le_self_sq
#align int.le_self_pow_two Int.le_self_pow_two
-theorem coe_nat_eq_zero {n : ℕ} : (n : ℤ) = 0 ↔ n = 0 :=
+theorem natCast_eq_zero {n : ℕ} : (n : ℤ) = 0 ↔ n = 0 :=
Nat.cast_eq_zero
-#align int.coe_nat_eq_zero Int.coe_nat_eq_zero
+#align int.coe_nat_eq_zero Int.natCast_eq_zero
-theorem coe_nat_ne_zero {n : ℕ} : (n : ℤ) ≠ 0 ↔ n ≠ 0 := by simp
-#align int.coe_nat_ne_zero Int.coe_nat_ne_zero
+theorem natCast_ne_zero {n : ℕ} : (n : ℤ) ≠ 0 ↔ n ≠ 0 := by simp
+#align int.coe_nat_ne_zero Int.natCast_ne_zero
-theorem coe_nat_ne_zero_iff_pos {n : ℕ} : (n : ℤ) ≠ 0 ↔ 0 < n :=
- ⟨fun h => Nat.pos_of_ne_zero (coe_nat_ne_zero.1 h),
+theorem natCast_ne_zero_iff_pos {n : ℕ} : (n : ℤ) ≠ 0 ↔ 0 < n :=
+ ⟨fun h => Nat.pos_of_ne_zero (natCast_ne_zero.1 h),
fun h => (_root_.ne_of_lt (ofNat_lt.2 h)).symm⟩
-#align int.coe_nat_ne_zero_iff_pos Int.coe_nat_ne_zero_iff_pos
+#align int.coe_nat_ne_zero_iff_pos Int.natCast_ne_zero_iff_pos
-@[norm_cast] lemma abs_coe_nat (n : ℕ) : |(n : ℤ)| = n := abs_of_nonneg (coe_nat_nonneg n)
-#align int.abs_coe_nat Int.abs_coe_nat
+@[norm_cast] lemma abs_natCast (n : ℕ) : |(n : ℤ)| = n := abs_of_nonneg (natCast_nonneg n)
+#align int.abs_coe_nat Int.abs_natCast
theorem sign_add_eq_of_sign_eq : ∀ {m n : ℤ}, m.sign = n.sign → (m + n).sign = n.sign := by
have : (1 : ℤ) ≠ -1 := by decide
rintro ((_ | m) | m) ((_ | n) | n) <;> simp [this, this.symm, Int.negSucc_add_negSucc]
rw [Int.sign_eq_one_iff_pos]
- apply Int.add_pos <;> · exact zero_lt_one.trans_le (le_add_of_nonneg_left <| coe_nat_nonneg _)
+ apply Int.add_pos <;> · exact zero_lt_one.trans_le (le_add_of_nonneg_left <| natCast_nonneg _)
#align int.sign_add_eq_of_sign_eq Int.sign_add_eq_of_sign_eq
/-- Note this holds in marginally more generality than `Int.cast_mul` -/
@@ -487,10 +487,10 @@ theorem lt_toNat {n : ℕ} {a : ℤ} : n < toNat a ↔ (n : ℤ) < a :=
#align int.lt_to_nat Int.lt_toNat
@[simp]
-theorem coe_nat_nonpos_iff {n : ℕ} : (n : ℤ) ≤ 0 ↔ n = 0 :=
+theorem natCast_nonpos_iff {n : ℕ} : (n : ℤ) ≤ 0 ↔ n = 0 :=
⟨fun h => le_antisymm (Int.ofNat_le.mp (h.trans Int.ofNat_zero.le)) n.zero_le,
- fun h => (coe_nat_eq_zero.mpr h).le⟩
-#align int.coe_nat_nonpos_iff Int.coe_nat_nonpos_iff
+ fun h => (natCast_eq_zero.mpr h).le⟩
+#align int.coe_nat_nonpos_iff Int.natCast_nonpos_iff
theorem toNat_le_toNat {a b : ℤ} (h : a ≤ b) : toNat a ≤ toNat b := by
rw [toNat_le]; exact le_trans h (self_le_toNat b)
@@ -514,8 +514,8 @@ theorem toNat_pred_coe_of_pos {i : ℤ} (h : 0 < i) : ((i.toNat - 1 : ℕ) : ℤ
theorem toNat_eq_zero : ∀ {n : ℤ}, n.toNat = 0 ↔ n ≤ 0
| (n : ℕ) =>
calc
- _ ↔ n = 0 := ⟨(toNat_coe_nat n).symm.trans, (toNat_coe_nat n).trans⟩
- _ ↔ _ := coe_nat_nonpos_iff.symm
+ _ ↔ n = 0 := ⟨(toNat_natCast n).symm.trans, (toNat_natCast n).trans⟩
+ _ ↔ _ := natCast_nonpos_iff.symm
| -[n+1] =>
show (-((n : ℤ) + 1)).toNat = 0 ↔ (-(n + 1) : ℤ) ≤ 0 from
@@ -537,7 +537,7 @@ variable {G : Type*} [Group G]
@[to_additive (attr := simp) abs_zsmul_eq_zero]
lemma zpow_abs_eq_one (a : G) (n : ℤ) : a ^ |n| = 1 ↔ a ^ n = 1 := by
- rw [← Int.coe_natAbs, zpow_natCast, pow_natAbs_eq_one]
+ rw [← Int.natCast_natAbs, zpow_natCast, pow_natAbs_eq_one]
end Group
@@ -418,7 +418,7 @@ theorem exists_lt_and_lt_iff_not_dvd (m : ℤ) {n : ℤ} (hn : 0 < n) :
rw [lt_add_one_iff, ← not_lt] at h2k
exact h2k h1k
· intro h
- rw [dvd_iff_emod_eq_zero, ← Ne.def] at h
+ rw [dvd_iff_emod_eq_zero, ← Ne] at h
have := (emod_nonneg m hn.ne.symm).lt_of_ne h.symm
rw [← emod_add_ediv m n]
refine' ⟨m / n, lt_add_of_pos_left _ this, _⟩
I removed some redundant instance arguments throughout Mathlib. To do this, I used VS Code's regex search. See https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/repeating.20instances.20from.20variable.20command I closed the previous PR for this and reopened it.
@@ -566,7 +566,7 @@ variable [NonAssocRing R] (n r : R)
lemma bit1_mul : bit1 n * r = (2 : ℤ) • (n * r) + r := by rw [bit1, add_mul, bit0_mul, one_mul]
#align bit1_mul bit1_mul
-lemma mul_bit1 [NonAssocRing R] {n r : R} : r * bit1 n = (2 : ℤ) • (r * n) + r := by
+lemma mul_bit1 {n r : R} : r * bit1 n = (2 : ℤ) • (r * n) + r := by
rw [bit1, mul_add, mul_bit0, mul_one]
#align mul_bit1 mul_bit1
zpow_coe_nat
to zpow_natCast
(#11528)
... and add a deprecated alias for the old name. This is mostly just me discovering the power of F2
@@ -537,7 +537,7 @@ variable {G : Type*} [Group G]
@[to_additive (attr := simp) abs_zsmul_eq_zero]
lemma zpow_abs_eq_one (a : G) (n : ℤ) : a ^ |n| = 1 ↔ a ^ n = 1 := by
- rw [← Int.coe_natAbs, zpow_coe_nat, pow_natAbs_eq_one]
+ rw [← Int.coe_natAbs, zpow_natCast, pow_natAbs_eq_one]
end Group
@@ -61,8 +61,8 @@ theorem abs_eq_natAbs : ∀ a : ℤ, |a| = natAbs a
@[simp, norm_cast] lemma coe_natAbs (n : ℤ) : (n.natAbs : ℤ) = |n| := n.abs_eq_natAbs.symm
#align int.coe_nat_abs Int.coe_natAbs
-lemma _root_.Nat.cast_natAbs {α : Type*} [AddGroupWithOne α] (n : ℤ) : (n.natAbs : α) = |n| :=
- by rw [← coe_natAbs, Int.cast_ofNat]
+lemma _root_.Nat.cast_natAbs {α : Type*} [AddGroupWithOne α] (n : ℤ) : (n.natAbs : α) = |n| := by
+ rw [← coe_natAbs, Int.cast_ofNat]
#align nat.cast_nat_abs Nat.cast_natAbs
theorem natAbs_abs (a : ℤ) : natAbs |a| = natAbs a := by rw [abs_eq_natAbs]; rfl
Homogenises porting notes via capitalisation and addition of whitespace.
It makes the following changes:
@@ -307,7 +307,7 @@ theorem add_emod_eq_add_mod_right {m n k : ℤ} (i : ℤ) (H : m % n = k % n) :
#align int.sub_mod Int.sub_emod
--- porting note: this should be a doc comment, but the lemma isn't here any more!
+-- Porting note: this should be a doc comment, but the lemma isn't here any more!
/- See also `Int.divModEquiv` for a similar statement as an `Equiv`. -/
#align int.div_mod_unique Int.ediv_emod_unique
zpow_ofNat
and ofNat_zsmul
(#10969)
Previously these were syntactically identical to the corresponding zpow_coe_nat
and coe_nat_zsmul
lemmas, now they are about OfNat.ofNat
.
Unfortunately, almost every call site uses the ofNat
name to refer to Nat.cast
, so the downstream proofs had to be adjusted too.
@@ -537,7 +537,7 @@ variable {G : Type*} [Group G]
@[to_additive (attr := simp) abs_zsmul_eq_zero]
lemma zpow_abs_eq_one (a : G) (n : ℤ) : a ^ |n| = 1 ↔ a ^ n = 1 := by
- rw [← Int.coe_natAbs, zpow_ofNat, pow_natAbs_eq_one]
+ rw [← Int.coe_natAbs, zpow_coe_nat, pow_natAbs_eq_one]
end Group
@@ -445,74 +445,25 @@ protected theorem sign_eq_ediv_abs (a : ℤ) : sign a = a / |a| :=
/-! ### `/` and ordering -/
-
-protected theorem ediv_mul_le (a : ℤ) {b : ℤ} (H : b ≠ 0) : a / b * b ≤ a :=
- le_of_sub_nonneg <| by rw [mul_comm, ← emod_def]; apply emod_nonneg _ H
#align int.div_mul_le Int.ediv_mul_le
-
-protected theorem ediv_le_of_le_mul {a b c : ℤ} (H : 0 < c) (H' : a ≤ b * c) : a / c ≤ b :=
- le_of_mul_le_mul_right (le_trans (Int.ediv_mul_le _ (ne_of_gt H)) H') H
#align int.div_le_of_le_mul Int.ediv_le_of_le_mul
-
-protected theorem mul_lt_of_lt_ediv {a b c : ℤ} (H : 0 < c) (H3 : a < b / c) : a * c < b :=
- lt_of_not_ge <| mt (Int.ediv_le_of_le_mul H) (not_le_of_gt H3)
#align int.mul_lt_of_lt_div Int.mul_lt_of_lt_ediv
-
-protected theorem mul_le_of_le_ediv {a b c : ℤ} (H1 : 0 < c) (H2 : a ≤ b / c) : a * c ≤ b :=
- le_trans (mul_le_mul_of_nonneg_right H2 (le_of_lt H1)) (Int.ediv_mul_le _ (ne_of_gt H1))
#align int.mul_le_of_le_div Int.mul_le_of_le_ediv
-
-protected theorem le_ediv_of_mul_le {a b c : ℤ} (H1 : 0 < c) (H2 : a * c ≤ b) : a ≤ b / c :=
- le_of_lt_add_one <|
- lt_of_mul_lt_mul_right (lt_of_le_of_lt H2 (lt_ediv_add_one_mul_self _ H1)) (le_of_lt H1)
#align int.le_div_of_mul_le Int.le_ediv_of_mul_le
-
-protected theorem le_ediv_iff_mul_le {a b c : ℤ} (H : 0 < c) : a ≤ b / c ↔ a * c ≤ b :=
- ⟨Int.mul_le_of_le_ediv H, Int.le_ediv_of_mul_le H⟩
#align int.le_div_iff_mul_le Int.le_ediv_iff_mul_le
-
-protected theorem ediv_le_ediv {a b c : ℤ} (H : 0 < c) (H' : a ≤ b) : a / c ≤ b / c :=
- Int.le_ediv_of_mul_le H (le_trans (Int.ediv_mul_le _ (ne_of_gt H)) H')
#align int.div_le_div Int.ediv_le_ediv
-
-protected theorem ediv_lt_of_lt_mul {a b c : ℤ} (H : 0 < c) (H' : a < b * c) : a / c < b :=
- lt_of_not_ge <| mt (Int.mul_le_of_le_ediv H) (not_le_of_gt H')
#align int.div_lt_of_lt_mul Int.ediv_lt_of_lt_mul
-
-protected theorem lt_mul_of_ediv_lt {a b c : ℤ} (H1 : 0 < c) (H2 : a / c < b) : a < b * c :=
- lt_of_not_ge <| mt (Int.le_ediv_of_mul_le H1) (not_le_of_gt H2)
#align int.lt_mul_of_div_lt Int.lt_mul_of_ediv_lt
-
-protected theorem ediv_lt_iff_lt_mul {a b c : ℤ} (H : 0 < c) : a / c < b ↔ a < b * c :=
- ⟨Int.lt_mul_of_ediv_lt H, Int.ediv_lt_of_lt_mul H⟩
#align int.div_lt_iff_lt_mul Int.ediv_lt_iff_lt_mul
-
-protected theorem le_mul_of_ediv_le {a b c : ℤ} (H1 : 0 ≤ b) (H2 : b ∣ a) (H3 : a / b ≤ c) :
- a ≤ c * b := by rw [← Int.ediv_mul_cancel H2]; exact mul_le_mul_of_nonneg_right H3 H1
#align int.le_mul_of_div_le Int.le_mul_of_ediv_le
-
-protected theorem lt_ediv_of_mul_lt {a b c : ℤ} (H1 : 0 ≤ b) (H2 : b ∣ c) (H3 : a * b < c) :
- a < c / b :=
- lt_of_not_ge <| mt (Int.le_mul_of_ediv_le H1 H2) (not_le_of_gt H3)
#align int.lt_div_of_mul_lt Int.lt_ediv_of_mul_lt
-
-protected theorem lt_ediv_iff_mul_lt {a b : ℤ} (c : ℤ) (H : 0 < c) (H' : c ∣ b) :
- a < b / c ↔ a * c < b :=
- ⟨Int.mul_lt_of_lt_ediv H, Int.lt_ediv_of_mul_lt (le_of_lt H) H'⟩
#align int.lt_div_iff_mul_lt Int.lt_ediv_iff_mul_lt
-
-theorem ediv_pos_of_pos_of_dvd {a b : ℤ} (H1 : 0 < a) (H2 : 0 ≤ b) (H3 : b ∣ a) : 0 < a / b :=
- Int.lt_ediv_of_mul_lt H2 H3 (by rwa [zero_mul])
#align int.div_pos_of_pos_of_dvd Int.ediv_pos_of_pos_of_dvd
theorem natAbs_eq_of_dvd_dvd {s t : ℤ} (hst : s ∣ t) (hts : t ∣ s) : natAbs s = natAbs t :=
Nat.dvd_antisymm (natAbs_dvd_natAbs.mpr hst) (natAbs_dvd_natAbs.mpr hts)
#align int.nat_abs_eq_of_dvd_dvd Int.natAbs_eq_of_dvd_dvd
-theorem ediv_eq_ediv_of_mul_eq_mul {a b c d : ℤ} (H2 : d ∣ c) (H3 : b ≠ 0) (H4 : d ≠ 0)
- (H5 : a * d = b * c) : a / b = c / d :=
- Int.ediv_eq_of_eq_mul_right H3 <| by
- rw [← Int.mul_ediv_assoc _ H2]; exact (Int.ediv_eq_of_eq_mul_left H4 H5.symm).symm
#align int.div_eq_div_of_mul_eq_mul Int.ediv_eq_ediv_of_mul_eq_mul
theorem ediv_dvd_of_dvd {s t : ℤ} (hst : s ∣ t) : t / s ∣ t := by
@@ -121,6 +121,11 @@ lemma cast_mul_eq_zsmul_cast {α : Type*} [AddCommGroupWithOne α] :
simp only [sub_mul, one_mul, cast_sub, ih, sub_zsmul, one_zsmul, ← sub_eq_add_neg, forall_const]
#align int.cast_mul_eq_zsmul_cast Int.cast_mul_eq_zsmul_cast
+theorem natAbs_sub_pos_iff {i j : ℤ} : 0 < natAbs (i - j) ↔ i ≠ j := by
+ rw [natAbs_pos, ne_eq, sub_eq_zero]
+
+theorem natAbs_sub_ne_zero_iff {i j : ℤ} : natAbs (i - j) ≠ 0 ↔ i ≠ j :=
+ Nat.ne_zero_iff_zero_lt.trans natAbs_sub_pos_iff
/-! ### succ and pred -/
exists_pow_eq_one_of_zpow_eq_one
(#10559)
and replace it by two more explicit lemmas
@@ -576,6 +576,15 @@ theorem toNat_sub_of_le {a b : ℤ} (h : b ≤ a) : (toNat (a - b) : ℤ) = a -
end Int
+section Group
+variable {G : Type*} [Group G]
+
+@[to_additive (attr := simp) abs_zsmul_eq_zero]
+lemma zpow_abs_eq_one (a : G) (n : ℤ) : a ^ |n| = 1 ↔ a ^ n = 1 := by
+ rw [← Int.coe_natAbs, zpow_ofNat, pow_natAbs_eq_one]
+
+end Group
+
section bit0_bit1
variable {R}
set_option linter.deprecated false
Of the 18 uses of singlePass
, in 3 cases we can just use rw
, in 4 cases it isn't needed at all.
In the other 11 cases we are always use it as simp (config := {singlePass := true}) only [X]
(i.e. with just a single simp lemma), and that simp
call would loop forever (usually failing with a maxRecDepth error, sometimes with heartbeats). I've left these as is.
There's also one case where there was a missing only
.
Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
@@ -415,7 +415,7 @@ theorem exists_lt_and_lt_iff_not_dvd (m : ℤ) {n : ℤ} (hn : 0 < n) :
· intro h
rw [dvd_iff_emod_eq_zero, ← Ne.def] at h
have := (emod_nonneg m hn.ne.symm).lt_of_ne h.symm
- simp (config := { singlePass := true }) only [← emod_add_ediv m n]
+ rw [← emod_add_ediv m n]
refine' ⟨m / n, lt_add_of_pos_left _ this, _⟩
rw [add_comm _ (1 : ℤ), left_distrib, mul_one]
exact add_lt_add_right (emod_lt_of_pos _ hn) _
@@ -136,6 +136,9 @@ theorem pred_self_lt (a : ℤ) : pred a < a :=
#align int.lt_add_one_iff Int.lt_add_one_iff
#align int.le_add_one Int.le_add_one
+theorem le_add_one_iff {m n : ℤ} : m ≤ n + 1 ↔ m ≤ n ∨ m = n + 1 := by
+ rw [le_iff_lt_or_eq, lt_add_one_iff]
+
theorem sub_one_lt_iff {a b : ℤ} : a - 1 < b ↔ a ≤ b :=
sub_lt_iff_lt_add.trans lt_add_one_iff
#align int.sub_one_lt_iff Int.sub_one_lt_iff
@@ -145,13 +148,8 @@ theorem le_sub_one_iff {a b : ℤ} : a ≤ b - 1 ↔ a < b :=
#align int.le_sub_one_iff Int.le_sub_one_iff
@[simp]
-theorem abs_lt_one_iff {a : ℤ} : |a| < 1 ↔ a = 0 :=
- ⟨fun a0 => by
- let ⟨hn, hp⟩ := abs_lt.mp a0
- rw [← zero_add 1, lt_add_one_iff] at hp
- -- Defeq abuse: `hn : -1 < a` but should be `hn : 0 λ a`.
- exact hp.antisymm hn,
- fun a0 => (abs_eq_zero.mpr a0).le.trans_lt zero_lt_one⟩
+theorem abs_lt_one_iff {a : ℤ} : |a| < 1 ↔ a = 0 := by
+ rw [← zero_add 1, lt_add_one_iff, abs_nonpos_iff]
#align int.abs_lt_one_iff Int.abs_lt_one_iff
theorem abs_le_one_iff {a : ℤ} : |a| ≤ 1 ↔ a = 0 ∨ a = 1 ∨ a = -1 := by
shake
bug, improve noshake.json generation (#9772)
This is the noshake.json
file corresponding to the edits in leanprover/std4#533. There was a small bug in shake
making it much more conservative than it needed to be, so there is a big mathlib PR #9830, on which this PR depends because CI will not pass without it.
Co-authored-by: Mario Carneiro <di.gama@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
@@ -3,11 +3,11 @@ Copyright (c) 2016 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad
-/
-import Mathlib.Algebra.Divisibility.Basic
+import Mathlib.Data.Nat.Order.Basic
+import Mathlib.Data.Int.Basic
import Mathlib.Algebra.Order.Group.Abs
import Mathlib.Algebra.Order.Ring.CharZero
-import Mathlib.Data.Int.Basic
-import Mathlib.Data.Nat.Order.Basic
+import Mathlib.Algebra.Divisibility.Basic
#align_import data.int.order.basic from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3"
@@ -3,12 +3,11 @@ Copyright (c) 2016 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad
-/
-
-import Mathlib.Data.Int.Basic
+import Mathlib.Algebra.Divisibility.Basic
import Mathlib.Algebra.Order.Group.Abs
import Mathlib.Algebra.Order.Ring.CharZero
-import Mathlib.Algebra.Divisibility.Basic
-import Mathlib.Data.Int.Defs
+import Mathlib.Data.Int.Basic
+import Mathlib.Data.Nat.Order.Basic
#align_import data.int.order.basic from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3"
@@ -29,7 +28,7 @@ This file contains:
induction on numbers less than `b`.
-/
-open Nat
+open Function Nat
namespace Int
@@ -73,6 +72,26 @@ theorem sign_mul_abs (a : ℤ) : sign a * |a| = a := by
rw [abs_eq_natAbs, sign_mul_natAbs a]
#align int.sign_mul_abs Int.sign_mul_abs
+lemma natAbs_sq (x : ℤ) : (x.natAbs : ℤ) ^ 2 = x ^ 2 := by rw [sq, Int.natAbs_mul_self', sq]
+#align int.nat_abs_sq Int.natAbs_sq
+
+alias natAbs_pow_two := natAbs_sq
+#align int.nat_abs_pow_two Int.natAbs_pow_two
+
+lemma natAbs_le_self_sq (a : ℤ) : (Int.natAbs a : ℤ) ≤ a ^ 2 := by
+ rw [← Int.natAbs_sq a, sq]
+ norm_cast
+ apply Nat.le_mul_self
+#align int.abs_le_self_sq Int.natAbs_le_self_sq
+
+alias natAbs_le_self_pow_two := natAbs_le_self_sq
+
+lemma le_self_sq (b : ℤ) : b ≤ b ^ 2 := le_trans le_natAbs (natAbs_le_self_sq _)
+#align int.le_self_sq Int.le_self_sq
+
+alias le_self_pow_two := le_self_sq
+#align int.le_self_pow_two Int.le_self_pow_two
+
theorem coe_nat_eq_zero {n : ℕ} : (n : ℤ) = 0 ↔ n = 0 :=
Nat.cast_eq_zero
#align int.coe_nat_eq_zero Int.coe_nat_eq_zero
@@ -95,6 +114,14 @@ theorem sign_add_eq_of_sign_eq : ∀ {m n : ℤ}, m.sign = n.sign → (m + n).si
apply Int.add_pos <;> · exact zero_lt_one.trans_le (le_add_of_nonneg_left <| coe_nat_nonneg _)
#align int.sign_add_eq_of_sign_eq Int.sign_add_eq_of_sign_eq
+/-- Note this holds in marginally more generality than `Int.cast_mul` -/
+lemma cast_mul_eq_zsmul_cast {α : Type*} [AddCommGroupWithOne α] :
+ ∀ m n : ℤ, ↑(m * n) = m • (n : α) :=
+ fun m ↦ Int.induction_on m (by simp) (fun _ ih ↦ by simp [add_mul, add_zsmul, ih]) fun _ ih ↦ by
+ simp only [sub_mul, one_mul, cast_sub, ih, sub_zsmul, one_zsmul, ← sub_eq_add_neg, forall_const]
+#align int.cast_mul_eq_zsmul_cast Int.cast_mul_eq_zsmul_cast
+
+
/-! ### succ and pred -/
@@ -551,5 +578,37 @@ theorem toNat_sub_of_le {a b : ℤ} (h : b ≤ a) : (toNat (a - b) : ℤ) = a -
end Int
+section bit0_bit1
+variable {R}
+set_option linter.deprecated false
+
+-- The next four lemmas allow us to replace multiplication by a numeral with a `zsmul` expression.
+
+section NonUnitalNonAssocRing
+variable [NonUnitalNonAssocRing R] (n r : R)
+
+lemma bit0_mul : bit0 n * r = (2 : ℤ) • (n * r) := by
+ rw [bit0, add_mul, ← one_add_one_eq_two, add_zsmul, one_zsmul]
+#align bit0_mul bit0_mul
+
+lemma mul_bit0 : r * bit0 n = (2 : ℤ) • (r * n) := by
+ rw [bit0, mul_add, ← one_add_one_eq_two, add_zsmul, one_zsmul]
+#align mul_bit0 mul_bit0
+
+end NonUnitalNonAssocRing
+
+section NonAssocRing
+variable [NonAssocRing R] (n r : R)
+
+lemma bit1_mul : bit1 n * r = (2 : ℤ) • (n * r) + r := by rw [bit1, add_mul, bit0_mul, one_mul]
+#align bit1_mul bit1_mul
+
+lemma mul_bit1 [NonAssocRing R] {n r : R} : r * bit1 n = (2 : ℤ) • (r * n) + r := by
+ rw [bit1, mul_add, mul_bit0, mul_one]
+#align mul_bit1 mul_bit1
+
+end NonAssocRing
+end bit0_bit1
+
-- We should need only a minimal development of sets in order to get here.
assert_not_exists Set.range
@@ -5,9 +5,10 @@ Authors: Jeremy Avigad
-/
import Mathlib.Data.Int.Basic
-import Mathlib.Algebra.Ring.Divisibility.Basic
import Mathlib.Algebra.Order.Group.Abs
import Mathlib.Algebra.Order.Ring.CharZero
+import Mathlib.Algebra.Divisibility.Basic
+import Mathlib.Data.Int.Defs
#align_import data.int.order.basic from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3"
@@ -347,7 +347,7 @@ theorem emod_two_eq_zero_or_one (n : ℤ) : n % 2 = 0 ∨ n % 2 = 1 :=
#align int.mul_div_cancel' Int.mul_ediv_cancel'
-theorem ediv_dvd_ediv : ∀ {a b c : ℤ} (_ : a ∣ b) (_ : b ∣ c), b / a ∣ c / a
+theorem ediv_dvd_ediv : ∀ {a b c : ℤ}, a ∣ b → b ∣ c → b / a ∣ c / a
| a, _, _, ⟨b, rfl⟩, ⟨c, rfl⟩ =>
if az : a = 0 then by simp [az]
else by
@@ -62,7 +62,7 @@ theorem abs_eq_natAbs : ∀ a : ℤ, |a| = natAbs a
#align int.coe_nat_abs Int.coe_natAbs
lemma _root_.Nat.cast_natAbs {α : Type*} [AddGroupWithOne α] (n : ℤ) : (n.natAbs : α) = |n| :=
- by rw [←coe_natAbs, Int.cast_ofNat]
+ by rw [← coe_natAbs, Int.cast_ofNat]
#align nat.cast_nat_abs Nat.cast_natAbs
theorem natAbs_abs (a : ℤ) : natAbs |a| = natAbs a := by rw [abs_eq_natAbs]; rfl
@@ -120,7 +120,7 @@ theorem le_sub_one_iff {a b : ℤ} : a ≤ b - 1 ↔ a < b :=
theorem abs_lt_one_iff {a : ℤ} : |a| < 1 ↔ a = 0 :=
⟨fun a0 => by
let ⟨hn, hp⟩ := abs_lt.mp a0
- rw [←zero_add 1, lt_add_one_iff] at hp
+ rw [← zero_add 1, lt_add_one_iff] at hp
-- Defeq abuse: `hn : -1 < a` but should be `hn : 0 λ a`.
exact hp.antisymm hn,
fun a0 => (abs_eq_zero.mpr a0).le.trans_lt zero_lt_one⟩
@@ -5,7 +5,7 @@ Authors: Jeremy Avigad
-/
import Mathlib.Data.Int.Basic
-import Mathlib.Algebra.Ring.Divisibility
+import Mathlib.Algebra.Ring.Divisibility.Basic
import Mathlib.Algebra.Order.Group.Abs
import Mathlib.Algebra.Order.Ring.CharZero
@@ -89,7 +89,7 @@ theorem coe_nat_ne_zero_iff_pos {n : ℕ} : (n : ℤ) ≠ 0 ↔ 0 < n :=
theorem sign_add_eq_of_sign_eq : ∀ {m n : ℤ}, m.sign = n.sign → (m + n).sign = n.sign := by
have : (1 : ℤ) ≠ -1 := by decide
- rintro ((_ | m) | m) ((_ | n) | n) <;> simp [this, this.symm]
+ rintro ((_ | m) | m) ((_ | n) | n) <;> simp [this, this.symm, Int.negSucc_add_negSucc]
rw [Int.sign_eq_one_iff_pos]
apply Int.add_pos <;> · exact zero_lt_one.trans_le (le_add_of_nonneg_left <| coe_nat_nonneg _)
#align int.sign_add_eq_of_sign_eq Int.sign_add_eq_of_sign_eq
Type _
and Sort _
(#6499)
We remove all possible occurences of Type _
and Sort _
in favor of Type*
and Sort*
.
This has nice performance benefits.
@@ -61,7 +61,7 @@ theorem abs_eq_natAbs : ∀ a : ℤ, |a| = natAbs a
@[simp, norm_cast] lemma coe_natAbs (n : ℤ) : (n.natAbs : ℤ) = |n| := n.abs_eq_natAbs.symm
#align int.coe_nat_abs Int.coe_natAbs
-lemma _root_.Nat.cast_natAbs {α : Type _} [AddGroupWithOne α] (n : ℤ) : (n.natAbs : α) = |n| :=
+lemma _root_.Nat.cast_natAbs {α : Type*} [AddGroupWithOne α] (n : ℤ) : (n.natAbs : α) = |n| :=
by rw [←coe_natAbs, Int.cast_ofNat]
#align nat.cast_nat_abs Nat.cast_natAbs
@@ -136,7 +136,7 @@ theorem one_le_abs {z : ℤ} (h₀ : z ≠ 0) : 1 ≤ |z| :=
/-- Inductively define a function on `ℤ` by defining it at `b`, for the `succ` of a number greater
than `b`, and the `pred` of a number less than `b`. -/
-@[elab_as_elim] protected def inductionOn' {C : ℤ → Sort _}
+@[elab_as_elim] protected def inductionOn' {C : ℤ → Sort*}
(z : ℤ) (b : ℤ) (H0 : C b) (Hs : ∀ k, b ≤ k → C k → C (k + 1))
(Hp : ∀ k ≤ b, C k → C (k - 1)) : C z := by
rw [← sub_add_cancel (G := ℤ) z b, add_comm]
@@ -2,11 +2,6 @@
Copyright (c) 2016 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad
-
-! This file was ported from Lean 3 source module data.int.order.basic
-! leanprover-community/mathlib commit e8638a0fcaf73e4500469f368ef9494e495099b3
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathlib.Data.Int.Basic
@@ -14,6 +9,8 @@ import Mathlib.Algebra.Ring.Divisibility
import Mathlib.Algebra.Order.Group.Abs
import Mathlib.Algebra.Order.Ring.CharZero
+#align_import data.int.order.basic from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3"
+
/-!
# Order instances on the integers
This is the second half of the changes originally in #5699, removing all occurrences of ;
after a space and implementing a linter rule to enforce it.
In most cases this 2-character substring has a space after it, so the following command was run first:
find . -type f -name "*.lean" -exec sed -i -E 's/ ; /; /g' {} \;
The remaining cases were few enough in number that they were done manually.
@@ -68,7 +68,7 @@ lemma _root_.Nat.cast_natAbs {α : Type _} [AddGroupWithOne α] (n : ℤ) : (n.n
by rw [←coe_natAbs, Int.cast_ofNat]
#align nat.cast_nat_abs Nat.cast_natAbs
-theorem natAbs_abs (a : ℤ) : natAbs |a| = natAbs a := by rw [abs_eq_natAbs] ; rfl
+theorem natAbs_abs (a : ℤ) : natAbs |a| = natAbs a := by rw [abs_eq_natAbs]; rfl
#align int.nat_abs_abs Int.natAbs_abs
theorem sign_mul_abs (a : ℤ) : sign a * |a| = a := by
@@ -68,7 +68,7 @@ lemma _root_.Nat.cast_natAbs {α : Type _} [AddGroupWithOne α] (n : ℤ) : (n.n
by rw [←coe_natAbs, Int.cast_ofNat]
#align nat.cast_nat_abs Nat.cast_natAbs
-theorem natAbs_abs (a : ℤ) : natAbs (|a|) = natAbs a := by rw [abs_eq_natAbs] ; rfl
+theorem natAbs_abs (a : ℤ) : natAbs |a| = natAbs a := by rw [abs_eq_natAbs] ; rfl
#align int.nat_abs_abs Int.natAbs_abs
theorem sign_mul_abs (a : ℤ) : sign a * |a| = a := by
@@ -65,7 +65,7 @@ theorem abs_eq_natAbs : ∀ a : ℤ, |a| = natAbs a
#align int.coe_nat_abs Int.coe_natAbs
lemma _root_.Nat.cast_natAbs {α : Type _} [AddGroupWithOne α] (n : ℤ) : (n.natAbs : α) = |n| :=
-by rw [←coe_natAbs, Int.cast_ofNat]
+ by rw [←coe_natAbs, Int.cast_ofNat]
#align nat.cast_nat_abs Nat.cast_natAbs
theorem natAbs_abs (a : ℤ) : natAbs (|a|) = natAbs a := by rw [abs_eq_natAbs] ; rfl
@@ -553,6 +553,5 @@ theorem toNat_sub_of_le {a b : ℤ} (h : b ≤ a) : (toNat (a - b) : ℤ) = a -
end Int
--- Porting note assert_not_exists not ported yet.
-- We should need only a minimal development of sets in order to get here.
--- assert_not_exists set.range
+assert_not_exists Set.range
Match https://github.com/leanprover-community/mathlib/pull/18698 and a bit of https://github.com/leanprover-community/mathlib/pull/18785.
algebra.divisibility.basic
@70d50ecfd4900dd6d328da39ab7ebd516abe4025
..e8638a0fcaf73e4500469f368ef9494e495099b3
algebra.euclidean_domain.basic
@655994e298904d7e5bbd1e18c95defd7b543eb94
..e8638a0fcaf73e4500469f368ef9494e495099b3
algebra.group.units
@369525b73f229ccd76a6ec0e0e0bf2be57599768
..e8638a0fcaf73e4500469f368ef9494e495099b3
algebra.group_with_zero.basic
@2196ab363eb097c008d4497125e0dde23fb36db2
..e8638a0fcaf73e4500469f368ef9494e495099b3
algebra.group_with_zero.divisibility
@f1a2caaf51ef593799107fe9a8d5e411599f3996
..e8638a0fcaf73e4500469f368ef9494e495099b3
algebra.group_with_zero.units.basic
@70d50ecfd4900dd6d328da39ab7ebd516abe4025
..df5e9937a06fdd349fc60106f54b84d47b1434f0
algebra.order.monoid.canonical.defs
@de87d5053a9fe5cbde723172c0fb7e27e7436473
..e8638a0fcaf73e4500469f368ef9494e495099b3
algebra.ring.divisibility
@f1a2caaf51ef593799107fe9a8d5e411599f3996
..e8638a0fcaf73e4500469f368ef9494e495099b3
data.int.dvd.basic
@e1bccd6e40ae78370f01659715d3c948716e3b7e
..e8638a0fcaf73e4500469f368ef9494e495099b3
data.int.dvd.pow
@b3f25363ae62cb169e72cd6b8b1ac97bacf21ca7
..e8638a0fcaf73e4500469f368ef9494e495099b3
data.int.order.basic
@728baa2f54e6062c5879a3e397ac6bac323e506f
..e8638a0fcaf73e4500469f368ef9494e495099b3
data.nat.gcd.basic
@a47cda9662ff3925c6df271090b5808adbca5b46
..e8638a0fcaf73e4500469f368ef9494e495099b3
data.nat.order.basic
@26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2
..e8638a0fcaf73e4500469f368ef9494e495099b3
data.nat.order.lemmas
@2258b40dacd2942571c8ce136215350c702dc78f
..e8638a0fcaf73e4500469f368ef9494e495099b3
group_theory.perm.cycle.basic
@92ca63f0fb391a9ca5f22d2409a6080e786d99f7
..e8638a0fcaf73e4500469f368ef9494e495099b3
number_theory.divisors
@f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c
..e8638a0fcaf73e4500469f368ef9494e495099b3
number_theory.pythagorean_triples
@70fd9563a21e7b963887c9360bd29b2393e6225a
..e8638a0fcaf73e4500469f368ef9494e495099b3
number_theory.zsqrtd.basic
@7ec294687917cbc5c73620b4414ae9b5dd9ae1b4
..e8638a0fcaf73e4500469f368ef9494e495099b3
ring_theory.multiplicity
@ceb887ddf3344dab425292e497fa2af91498437c
..e8638a0fcaf73e4500469f368ef9494e495099b3
Co-authored-by: Jeremy Tan Jie Rui <reddeloostw@gmail.com>
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad
! This file was ported from Lean 3 source module data.int.order.basic
-! leanprover-community/mathlib commit 728baa2f54e6062c5879a3e397ac6bac323e506f
+! leanprover-community/mathlib commit e8638a0fcaf73e4500469f368ef9494e495099b3
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
We don't port the IMO proof itself since it seems there's no archive in Mathlib4.
Mathlib 3: https://github.com/leanprover-community/mathlib/pull/15613
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad
! This file was ported from Lean 3 source module data.int.order.basic
-! leanprover-community/mathlib commit bd835ef554f37ef9b804f0903089211f89cb370b
+! leanprover-community/mathlib commit 728baa2f54e6062c5879a3e397ac6bac323e506f
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
@@ -90,6 +90,13 @@ theorem coe_nat_ne_zero_iff_pos {n : ℕ} : (n : ℤ) ≠ 0 ↔ 0 < n :=
@[norm_cast] lemma abs_coe_nat (n : ℕ) : |(n : ℤ)| = n := abs_of_nonneg (coe_nat_nonneg n)
#align int.abs_coe_nat Int.abs_coe_nat
+theorem sign_add_eq_of_sign_eq : ∀ {m n : ℤ}, m.sign = n.sign → (m + n).sign = n.sign := by
+ have : (1 : ℤ) ≠ -1 := by decide
+ rintro ((_ | m) | m) ((_ | n) | n) <;> simp [this, this.symm]
+ rw [Int.sign_eq_one_iff_pos]
+ apply Int.add_pos <;> · exact zero_lt_one.trans_le (le_add_of_nonneg_left <| coe_nat_nonneg _)
+#align int.sign_add_eq_of_sign_eq Int.sign_add_eq_of_sign_eq
+
/-! ### succ and pred -/
Also fixes a lemma statement to use %
notation like it did in Lean3
Co-authored-by: Jon Eugster <eugster.jon@gmail.com>
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad
! This file was ported from Lean 3 source module data.int.order.basic
-! leanprover-community/mathlib commit b86832321b586c6ac23ef8cdef6a7a27e42b13bd
+! leanprover-community/mathlib commit bd835ef554f37ef9b804f0903089211f89cb370b
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
@@ -272,6 +272,8 @@ theorem add_emod_eq_add_mod_right {m n k : ℤ} (i : ℤ) (H : m % n = k % n) :
#align int.sub_mod Int.sub_emod
+-- porting note: this should be a doc comment, but the lemma isn't here any more!
+/- See also `Int.divModEquiv` for a similar statement as an `Equiv`. -/
#align int.div_mod_unique Int.ediv_emod_unique
attribute [local simp] Int.zero_emod
congr!
and convert
(#2606)
congr!
, convert
, and convert_to
to control parts of the congruence algorithm, in particular transparency settings when applying congruence lemmas.congr!
now applies congruence lemmas with reducible transparency by default. This prevents it from unfolding definitions when applying congruence lemmas. It also now tries both the LHS-biased and RHS-biased simp congruence lemmas, with a configuration option to set which it should try first.HEq
congruence lemma generator that gives each hypothesis access to the proofs of previous hypotheses. This means that if you have an equality ⊢ ⟨a, x⟩ = ⟨b, y⟩
of sigma types, congr!
turns this into goals ⊢ a = b
and ⊢ a = b → HEq x y
(note that congr!
will also auto-introduce a = b
for you in the second goal). This congruence lemma generator applies to more cases than the simp congruence lemma generator does.congr!
(and hence convert
) are more careful about applying lemmas that don't force definitions to unfold. There were a number of cases in mathlib where the implementation of congr
was being abused to unfold definitions.set_option trace.congr! true
you can see what congr!
sees when it is deciding on congruence lemmas.convert_to
to do using 1
when there is no using
clause, to match its documentation.Note that congr!
is more capable than congr
at finding a way to equate left-hand sides and right-hand sides, so you will frequently need to limit its depth with a using
clause. However, there is also a new heuristic to prevent considering unlikely-to-be-provable type equalities (controlled by the typeEqs
option), which can help limit the depth automatically.
There is also a predefined configuration that you can invoke with, for example, convert (config := .unfoldSameFun) h
, that causes it to behave more like congr
, including using default transparency when unfolding.
@@ -281,8 +281,8 @@ attribute [local simp] Int.zero_emod
@[simp]
theorem neg_emod_two (i : ℤ) : -i % 2 = i % 2 := by
apply Int.emod_eq_emod_iff_emod_sub_eq_zero.mpr
- convert Int.mul_emod_right 2 (-i)
- simp only [two_mul, sub_eq_add_neg]
+ convert Int.mul_emod_right 2 (-i) using 2
+ rw [two_mul, sub_eq_add_neg]
#align int.neg_mod_two Int.neg_emod_two
/-! ### properties of `/` and `%` -/
This PR is the result of a slight variant on the following "algorithm"
_
and make all uppercase letters into lowercase_
and make all uppercase letters into lowercase(original_lean3_name, OriginalLean4Name)
#align
statement just before the next empty line#align
statement to have been inserted too early)@@ -153,6 +153,7 @@ where
refine _root_.cast (by rw [add_sub_assoc]; rfl) (Hp _ (Int.le_of_lt ?_) (neg n))
conv => rhs; apply (add_zero b).symm
rw [Int.add_lt_add_iff_left]; apply negSucc_lt_zero
+#align int.induction_on' Int.inductionOn'
/-- See `Int.inductionOn'` for an induction in both directions. -/
protected theorem le_induction {P : ℤ → Prop} {m : ℤ} (h0 : P m)
Match https://github.com/leanprover-community/mathlib/pull/17967
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad
! This file was ported from Lean 3 source module data.int.order.basic
-! leanprover-community/mathlib commit 10b4e499f43088dd3bb7b5796184ad5216648ab1
+! leanprover-community/mathlib commit b86832321b586c6ac23ef8cdef6a7a27e42b13bd
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
@@ -61,6 +61,13 @@ theorem abs_eq_natAbs : ∀ a : ℤ, |a| = natAbs a
| -[_+1] => abs_of_nonpos <| le_of_lt <| negSucc_lt_zero _
#align int.abs_eq_nat_abs Int.abs_eq_natAbs
+@[simp, norm_cast] lemma coe_natAbs (n : ℤ) : (n.natAbs : ℤ) = |n| := n.abs_eq_natAbs.symm
+#align int.coe_nat_abs Int.coe_natAbs
+
+lemma _root_.Nat.cast_natAbs {α : Type _} [AddGroupWithOne α] (n : ℤ) : (n.natAbs : α) = |n| :=
+by rw [←coe_natAbs, Int.cast_ofNat]
+#align nat.cast_nat_abs Nat.cast_natAbs
+
theorem natAbs_abs (a : ℤ) : natAbs (|a|) = natAbs a := by rw [abs_eq_natAbs] ; rfl
#align int.nat_abs_abs Int.natAbs_abs
@@ -80,9 +87,8 @@ theorem coe_nat_ne_zero_iff_pos {n : ℕ} : (n : ℤ) ≠ 0 ↔ 0 < n :=
fun h => (_root_.ne_of_lt (ofNat_lt.2 h)).symm⟩
#align int.coe_nat_ne_zero_iff_pos Int.coe_nat_ne_zero_iff_pos
-theorem coe_natAbs (n : ℕ) : |(n : ℤ)| = n :=
- abs_of_nonneg (coe_nat_nonneg n)
-#align int.coe_nat_abs Int.coe_natAbs
+@[norm_cast] lemma abs_coe_nat (n : ℕ) : |(n : ℤ)| = n := abs_of_nonneg (coe_nat_nonneg n)
+#align int.abs_coe_nat Int.abs_coe_nat
/-! ### succ and pred -/
@@ -148,7 +148,7 @@ where
conv => rhs; apply (add_zero b).symm
rw [Int.add_lt_add_iff_left]; apply negSucc_lt_zero
-/-- See `int.induction_on'` for an induction in both directions. -/
+/-- See `Int.inductionOn'` for an induction in both directions. -/
protected theorem le_induction {P : ℤ → Prop} {m : ℤ} (h0 : P m)
(h1 : ∀ n : ℤ, m ≤ n → P n → P (n + 1)) (n : ℤ) : m ≤ n → P n := by
refine Int.inductionOn' n m ?_ ?_ ?_
@@ -161,7 +161,7 @@ protected theorem le_induction {P : ℤ → Prop} {m : ℤ} (h0 : P m)
exact lt_irrefl k (le_sub_one_iff.mp (hle.trans hle'))
#align int.le_induction Int.le_induction
-/-- See `int.induction_on'` for an induction in both directions. -/
+/-- See `Int.inductionOn'` for an induction in both directions. -/
protected theorem le_induction_down {P : ℤ → Prop} {m : ℤ} (h0 : P m)
(h1 : ∀ n : ℤ, n ≤ m → P n → P (n - 1)) (n : ℤ) : n ≤ m → P n := by
refine Int.inductionOn' n m ?_ ?_ ?_
The script used to do this is included. The yaml file was obtained from https://raw.githubusercontent.com/wiki/leanprover-community/mathlib/mathlib4-port-status.md
@@ -2,6 +2,11 @@
Copyright (c) 2016 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad
+
+! This file was ported from Lean 3 source module data.int.order.basic
+! leanprover-community/mathlib commit 10b4e499f43088dd3bb7b5796184ad5216648ab1
+! Please do not edit these lines, except to modify the commit id
+! if you have ported upstream changes.
-/
import Mathlib.Data.Int.Basic
The unported dependencies are