data.int.parity
⟷
Mathlib.Data.Int.Parity
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)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(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)
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -205,7 +205,7 @@ theorem Odd.of_mul_right (h : Odd (m * n)) : Odd n :=
#print Int.even_pow /-
@[parity_simps]
theorem even_pow {n : ℕ} : Even (m ^ n) ↔ Even m ∧ n ≠ 0 := by
- induction' n with n ih <;> simp [*, even_mul, pow_succ]; tauto
+ induction' n with n ih <;> simp [*, even_mul, pow_succ']; tauto
#align int.even_pow Int.even_pow
-/
@@ -299,7 +299,7 @@ theorem four_dvd_add_or_sub_of_odd {a b : ℤ} (ha : Odd a) (hb : Odd b) : 4 ∣
rw [Int.even_add, ← Int.even_sub] at h
obtain ⟨k, hk⟩ := h
convert dvd_mul_right 4 k
- rw [eq_add_of_sub_eq hk, mul_add, add_assoc, add_sub_cancel, ← two_mul, ← mul_assoc]
+ rw [eq_add_of_sub_eq hk, mul_add, add_assoc, add_sub_cancel_right, ← two_mul, ← mul_assoc]
rfl
· left
obtain ⟨k, hk⟩ := h
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -296,7 +296,7 @@ theorem four_dvd_add_or_sub_of_odd {a b : ℤ} (ha : Odd a) (hb : Odd b) : 4 ∣
obtain ⟨n, rfl⟩ := hb
obtain h | h := Int.even_or_odd (m + n)
· right
- rw [Int.even_add, ← Int.even_sub] at h
+ rw [Int.even_add, ← Int.even_sub] at h
obtain ⟨k, hk⟩ := h
convert dvd_mul_right 4 k
rw [eq_add_of_sub_eq hk, mul_add, add_assoc, add_sub_cancel, ← two_mul, ← mul_assoc]
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce64cd319bb6b3e82f31c2d38e79080d377be451
@@ -3,7 +3,7 @@ Copyright (c) 2019 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Benjamin Davidson
-/
-import Mathbin.Data.Nat.Parity
+import Data.Nat.Parity
#align_import data.int.parity from "leanprover-community/mathlib"@"a11f9106a169dd302a285019e5165f8ab32ff433"
mathlib commit https://github.com/leanprover-community/mathlib/commit/32a7e535287f9c73f2e4d2aef306a39190f0b504
@@ -281,10 +281,10 @@ theorem natAbs_odd : Odd n.natAbs ↔ Odd n := by
#align int.nat_abs_odd Int.natAbs_odd
-/
-alias nat_abs_even ↔ _ _root_.even.nat_abs
+alias ⟨_, _root_.even.nat_abs⟩ := nat_abs_even
#align even.nat_abs Even.natAbs
-alias nat_abs_odd ↔ _ _root_.odd.nat_abs
+alias ⟨_, _root_.odd.nat_abs⟩ := nat_abs_odd
#align odd.nat_abs Odd.natAbs
attribute [protected] Even.natAbs Odd.natAbs
mathlib commit https://github.com/leanprover-community/mathlib/commit/8ea5598db6caeddde6cb734aa179cc2408dbd345
@@ -2,14 +2,11 @@
Copyright (c) 2019 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Benjamin Davidson
-
-! This file was ported from Lean 3 source module data.int.parity
-! leanprover-community/mathlib commit a11f9106a169dd302a285019e5165f8ab32ff433
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathbin.Data.Nat.Parity
+#align_import data.int.parity from "leanprover-community/mathlib"@"a11f9106a169dd302a285019e5165f8ab32ff433"
+
/-!
# Parity of integers
mathlib commit https://github.com/leanprover-community/mathlib/commit/9fb8964792b4237dac6200193a0d533f1b3f7423
@@ -50,33 +50,45 @@ theorem even_iff : Even n ↔ n % 2 = 0 :=
#align int.even_iff Int.even_iff
-/
+#print Int.odd_iff /-
theorem odd_iff : Odd n ↔ n % 2 = 1 :=
⟨fun ⟨m, hm⟩ => by rw [hm, add_mod]; norm_num, fun h =>
⟨n / 2, (emod_add_ediv n 2).symm.trans (by rw [h]; abel)⟩⟩
#align int.odd_iff Int.odd_iff
+-/
#print Int.not_even_iff /-
theorem not_even_iff : ¬Even n ↔ n % 2 = 1 := by rw [even_iff, mod_two_ne_zero]
#align int.not_even_iff Int.not_even_iff
-/
+#print Int.not_odd_iff /-
theorem not_odd_iff : ¬Odd n ↔ n % 2 = 0 := by rw [odd_iff, mod_two_ne_one]
#align int.not_odd_iff Int.not_odd_iff
+-/
+#print Int.even_iff_not_odd /-
theorem even_iff_not_odd : Even n ↔ ¬Odd n := by rw [not_odd_iff, even_iff]
#align int.even_iff_not_odd Int.even_iff_not_odd
+-/
+#print Int.odd_iff_not_even /-
@[simp]
theorem odd_iff_not_even : Odd n ↔ ¬Even n := by rw [not_even_iff, odd_iff]
#align int.odd_iff_not_even Int.odd_iff_not_even
+-/
+#print Int.isCompl_even_odd /-
theorem isCompl_even_odd : IsCompl {n : ℤ | Even n} {n | Odd n} := by
simp [← Set.compl_setOf, isCompl_compl]
#align int.is_compl_even_odd Int.isCompl_even_odd
+-/
+#print Int.even_or_odd /-
theorem even_or_odd (n : ℤ) : Even n ∨ Odd n :=
Or.imp_right odd_iff_not_even.2 <| em <| Even n
#align int.even_or_odd Int.even_or_odd
+-/
#print Int.even_or_odd' /-
theorem even_or_odd' (n : ℤ) : ∃ k, n = 2 * k ∨ n = 2 * k + 1 := by
@@ -84,12 +96,14 @@ theorem even_or_odd' (n : ℤ) : ∃ k, n = 2 * k ∨ n = 2 * k + 1 := by
#align int.even_or_odd' Int.even_or_odd'
-/
+#print Int.even_xor'_odd /-
theorem even_xor'_odd (n : ℤ) : Xor' (Even n) (Odd n) :=
by
cases' even_or_odd n with h
· exact Or.inl ⟨h, even_iff_not_odd.mp h⟩
· exact Or.inr ⟨h, odd_iff_not_even.mp h⟩
#align int.even_xor_odd Int.even_xor'_odd
+-/
#print Int.even_xor'_odd' /-
theorem even_xor'_odd' (n : ℤ) : ∃ k, Xor' (n = 2 * k) (n = 2 * k + 1) :=
@@ -104,10 +118,12 @@ theorem even_xor'_odd' (n : ℤ) : ∃ k, Xor' (n = 2 * k) (n = 2 * k + 1) :=
#align int.even_xor_odd' Int.even_xor'_odd'
-/
+#print Int.two_dvd_ne_zero /-
@[simp]
theorem two_dvd_ne_zero : ¬2 ∣ n ↔ n % 2 = 1 :=
even_iff_two_dvd.symm.Not.trans not_even_iff
#align int.two_dvd_ne_zero Int.two_dvd_ne_zero
+-/
instance : DecidablePred (Even : ℤ → Prop) := fun n => decidable_of_iff _ even_iff.symm
@@ -128,9 +144,11 @@ theorem even_add : Even (m + n) ↔ (Even m ↔ Even n) := by
#align int.even_add Int.even_add
-/
+#print Int.even_add' /-
theorem even_add' : Even (m + n) ↔ (Odd m ↔ Odd n) := by
rw [even_add, even_iff_not_odd, even_iff_not_odd, not_iff_not]
#align int.even_add' Int.even_add'
+-/
#print Int.not_even_bit1 /-
@[simp]
@@ -138,8 +156,10 @@ theorem not_even_bit1 (n : ℤ) : ¬Even (bit1 n) := by simp [bit1, parity_simps
#align int.not_even_bit1 Int.not_even_bit1
-/
+#print Int.two_not_dvd_two_mul_add_one /-
theorem two_not_dvd_two_mul_add_one (n : ℤ) : ¬2 ∣ 2 * n + 1 := by simp [add_mod]; rfl
#align int.two_not_dvd_two_mul_add_one Int.two_not_dvd_two_mul_add_one
+-/
#print Int.even_sub /-
@[parity_simps]
@@ -147,9 +167,11 @@ theorem even_sub : Even (m - n) ↔ (Even m ↔ Even n) := by simp [sub_eq_add_n
#align int.even_sub Int.even_sub
-/
+#print Int.even_sub' /-
theorem even_sub' : Even (m - n) ↔ (Odd m ↔ Odd n) := by
rw [even_sub, even_iff_not_odd, even_iff_not_odd, not_iff_not]
#align int.even_sub' Int.even_sub'
+-/
#print Int.even_add_one /-
@[parity_simps]
@@ -166,45 +188,65 @@ theorem even_mul : Even (m * n) ↔ Even m ∨ Even n := by
#align int.even_mul Int.even_mul
-/
+#print Int.odd_mul /-
theorem odd_mul : Odd (m * n) ↔ Odd m ∧ Odd n := by simp [not_or, parity_simps]
#align int.odd_mul Int.odd_mul
+-/
+#print Int.Odd.of_mul_left /-
theorem Odd.of_mul_left (h : Odd (m * n)) : Odd m :=
(odd_mul.mp h).1
#align int.odd.of_mul_left Int.Odd.of_mul_left
+-/
+#print Int.Odd.of_mul_right /-
theorem Odd.of_mul_right (h : Odd (m * n)) : Odd n :=
(odd_mul.mp h).2
#align int.odd.of_mul_right Int.Odd.of_mul_right
+-/
+#print Int.even_pow /-
@[parity_simps]
theorem even_pow {n : ℕ} : Even (m ^ n) ↔ Even m ∧ n ≠ 0 := by
induction' n with n ih <;> simp [*, even_mul, pow_succ]; tauto
#align int.even_pow Int.even_pow
+-/
+#print Int.even_pow' /-
theorem even_pow' {n : ℕ} (h : n ≠ 0) : Even (m ^ n) ↔ Even m :=
even_pow.trans <| and_iff_left h
#align int.even_pow' Int.even_pow'
+-/
+#print Int.odd_add /-
@[parity_simps]
theorem odd_add : Odd (m + n) ↔ (Odd m ↔ Even n) := by
rw [odd_iff_not_even, even_add, not_iff, odd_iff_not_even]
#align int.odd_add Int.odd_add
+-/
+#print Int.odd_add' /-
theorem odd_add' : Odd (m + n) ↔ (Odd n ↔ Even m) := by rw [add_comm, odd_add]
#align int.odd_add' Int.odd_add'
+-/
+#print Int.ne_of_odd_add /-
theorem ne_of_odd_add (h : Odd (m + n)) : m ≠ n := fun hnot => by simpa [hnot, parity_simps] using h
#align int.ne_of_odd_add Int.ne_of_odd_add
+-/
+#print Int.odd_sub /-
@[parity_simps]
theorem odd_sub : Odd (m - n) ↔ (Odd m ↔ Even n) := by
rw [odd_iff_not_even, even_sub, not_iff, odd_iff_not_even]
#align int.odd_sub Int.odd_sub
+-/
+#print Int.odd_sub' /-
theorem odd_sub' : Odd (m - n) ↔ (Odd n ↔ Even m) := by
rw [odd_iff_not_even, even_sub, not_iff, not_iff_comm, odd_iff_not_even]
#align int.odd_sub' Int.odd_sub'
+-/
#print Int.even_mul_succ_self /-
theorem even_mul_succ_self (n : ℤ) : Even (n * (n + 1)) :=
@@ -221,10 +263,12 @@ theorem even_coe_nat (n : ℕ) : Even (n : ℤ) ↔ Even n := by rw_mod_cast [ev
#align int.even_coe_nat Int.even_coe_nat
-/
+#print Int.odd_coe_nat /-
@[simp, norm_cast]
theorem odd_coe_nat (n : ℕ) : Odd (n : ℤ) ↔ Odd n := by
rw [odd_iff_not_even, Nat.odd_iff_not_even, even_coe_nat]
#align int.odd_coe_nat Int.odd_coe_nat
+-/
#print Int.natAbs_even /-
@[simp]
@@ -233,10 +277,12 @@ theorem natAbs_even : Even n.natAbs ↔ Even n := by
#align int.nat_abs_even Int.natAbs_even
-/
+#print Int.natAbs_odd /-
@[simp]
theorem natAbs_odd : Odd n.natAbs ↔ Odd n := by
rw [odd_iff_not_even, Nat.odd_iff_not_even, nat_abs_even]
#align int.nat_abs_odd Int.natAbs_odd
+-/
alias nat_abs_even ↔ _ _root_.even.nat_abs
#align even.nat_abs Even.natAbs
@@ -246,6 +292,7 @@ alias nat_abs_odd ↔ _ _root_.odd.nat_abs
attribute [protected] Even.natAbs Odd.natAbs
+#print Int.four_dvd_add_or_sub_of_odd /-
theorem four_dvd_add_or_sub_of_odd {a b : ℤ} (ha : Odd a) (hb : Odd b) : 4 ∣ a + b ∨ 4 ∣ a - b :=
by
obtain ⟨m, rfl⟩ := ha
@@ -265,6 +312,7 @@ theorem four_dvd_add_or_sub_of_odd {a b : ℤ} (ha : Odd a) (hb : Odd b) : 4 ∣
mul_add]
rfl
#align int.four_dvd_add_or_sub_of_odd Int.four_dvd_add_or_sub_of_odd
+-/
#print Int.two_mul_ediv_two_of_even /-
theorem two_mul_ediv_two_of_even : Even n → 2 * (n / 2) = n := fun h =>
@@ -281,21 +329,29 @@ theorem ediv_two_mul_two_of_even : Even n → n / 2 * 2 = n :=
#align int.div_two_mul_two_of_even Int.ediv_two_mul_two_of_even
-/
+#print Int.two_mul_ediv_two_add_one_of_odd /-
theorem two_mul_ediv_two_add_one_of_odd : Odd n → 2 * (n / 2) + 1 = n := by rintro ⟨c, rfl⟩;
rw [mul_comm]; convert Int.div_add_mod' _ _; simpa [Int.add_emod]
#align int.two_mul_div_two_add_one_of_odd Int.two_mul_ediv_two_add_one_of_odd
+-/
+#print Int.ediv_two_mul_two_add_one_of_odd /-
theorem ediv_two_mul_two_add_one_of_odd : Odd n → n / 2 * 2 + 1 = n := by rintro ⟨c, rfl⟩;
convert Int.div_add_mod' _ _; simpa [Int.add_emod]
#align int.div_two_mul_two_add_one_of_odd Int.ediv_two_mul_two_add_one_of_odd
+-/
+#print Int.add_one_ediv_two_mul_two_of_odd /-
theorem add_one_ediv_two_mul_two_of_odd : Odd n → 1 + n / 2 * 2 = n := by rintro ⟨c, rfl⟩;
rw [add_comm]; convert Int.div_add_mod' _ _; simpa [Int.add_emod]
#align int.add_one_div_two_mul_two_of_odd Int.add_one_ediv_two_mul_two_of_odd
+-/
+#print Int.two_mul_ediv_two_of_odd /-
theorem two_mul_ediv_two_of_odd (h : Odd n) : 2 * (n / 2) = n - 1 :=
eq_sub_of_add_eq (two_mul_ediv_two_add_one_of_odd h)
#align int.two_mul_div_two_of_odd Int.two_mul_ediv_two_of_odd
+-/
-- Here are examples of how `parity_simps` can be used with `int`.
example (m n : ℤ) (h : Even m) : ¬Even (n + 3) ↔ Even (m ^ 2 + m + n) := by
mathlib commit https://github.com/leanprover-community/mathlib/commit/5f25c089cb34db4db112556f23c50d12da81b297
@@ -70,7 +70,7 @@ theorem even_iff_not_odd : Even n ↔ ¬Odd n := by rw [not_odd_iff, even_iff]
theorem odd_iff_not_even : Odd n ↔ ¬Even n := by rw [not_even_iff, odd_iff]
#align int.odd_iff_not_even Int.odd_iff_not_even
-theorem isCompl_even_odd : IsCompl { n : ℤ | Even n } { n | Odd n } := by
+theorem isCompl_even_odd : IsCompl {n : ℤ | Even n} {n | Odd n} := by
simp [← Set.compl_setOf, isCompl_compl]
#align int.is_compl_even_odd Int.isCompl_even_odd
mathlib commit https://github.com/leanprover-community/mathlib/commit/cca40788df1b8755d5baf17ab2f27dacc2e17acb
@@ -252,7 +252,7 @@ theorem four_dvd_add_or_sub_of_odd {a b : ℤ} (ha : Odd a) (hb : Odd b) : 4 ∣
obtain ⟨n, rfl⟩ := hb
obtain h | h := Int.even_or_odd (m + n)
· right
- rw [Int.even_add, ← Int.even_sub] at h
+ rw [Int.even_add, ← Int.even_sub] at h
obtain ⟨k, hk⟩ := h
convert dvd_mul_right 4 k
rw [eq_add_of_sub_eq hk, mul_add, add_assoc, add_sub_cancel, ← two_mul, ← mul_assoc]
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -50,12 +50,6 @@ theorem even_iff : Even n ↔ n % 2 = 0 :=
#align int.even_iff Int.even_iff
-/
-/- warning: int.odd_iff -> Int.odd_iff is a dubious translation:
-lean 3 declaration is
- forall {n : Int}, Iff (Odd.{0} Int Int.semiring n) (Eq.{1} Int (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.hasMod) n (OfNat.ofNat.{0} Int 2 (OfNat.mk.{0} Int 2 (bit0.{0} Int Int.hasAdd (One.one.{0} Int Int.hasOne))))) (OfNat.ofNat.{0} Int 1 (OfNat.mk.{0} Int 1 (One.one.{0} Int Int.hasOne))))
-but is expected to have type
- forall {n : Int}, Iff (Odd.{0} Int Int.instSemiringInt n) (Eq.{1} Int (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.instModInt_1) n (OfNat.ofNat.{0} Int 2 (instOfNatInt 2))) (OfNat.ofNat.{0} Int 1 (instOfNatInt 1)))
-Case conversion may be inaccurate. Consider using '#align int.odd_iff Int.odd_iffₓ'. -/
theorem odd_iff : Odd n ↔ n % 2 = 1 :=
⟨fun ⟨m, hm⟩ => by rw [hm, add_mod]; norm_num, fun h =>
⟨n / 2, (emod_add_ediv n 2).symm.trans (by rw [h]; abel)⟩⟩
@@ -66,50 +60,20 @@ theorem not_even_iff : ¬Even n ↔ n % 2 = 1 := by rw [even_iff, mod_two_ne_zer
#align int.not_even_iff Int.not_even_iff
-/
-/- warning: int.not_odd_iff -> Int.not_odd_iff is a dubious translation:
-lean 3 declaration is
- forall {n : Int}, Iff (Not (Odd.{0} Int Int.semiring n)) (Eq.{1} Int (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.hasMod) n (OfNat.ofNat.{0} Int 2 (OfNat.mk.{0} Int 2 (bit0.{0} Int Int.hasAdd (One.one.{0} Int Int.hasOne))))) (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero))))
-but is expected to have type
- forall {n : Int}, Iff (Not (Odd.{0} Int Int.instSemiringInt n)) (Eq.{1} Int (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.instModInt_1) n (OfNat.ofNat.{0} Int 2 (instOfNatInt 2))) (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)))
-Case conversion may be inaccurate. Consider using '#align int.not_odd_iff Int.not_odd_iffₓ'. -/
theorem not_odd_iff : ¬Odd n ↔ n % 2 = 0 := by rw [odd_iff, mod_two_ne_one]
#align int.not_odd_iff Int.not_odd_iff
-/- warning: int.even_iff_not_odd -> Int.even_iff_not_odd is a dubious translation:
-lean 3 declaration is
- forall {n : Int}, Iff (Even.{0} Int Int.hasAdd n) (Not (Odd.{0} Int Int.semiring n))
-but is expected to have type
- forall {n : Int}, Iff (Even.{0} Int Int.instAddInt n) (Not (Odd.{0} Int Int.instSemiringInt n))
-Case conversion may be inaccurate. Consider using '#align int.even_iff_not_odd Int.even_iff_not_oddₓ'. -/
theorem even_iff_not_odd : Even n ↔ ¬Odd n := by rw [not_odd_iff, even_iff]
#align int.even_iff_not_odd Int.even_iff_not_odd
-/- warning: int.odd_iff_not_even -> Int.odd_iff_not_even is a dubious translation:
-lean 3 declaration is
- forall {n : Int}, Iff (Odd.{0} Int Int.semiring n) (Not (Even.{0} Int Int.hasAdd n))
-but is expected to have type
- forall {n : Int}, Iff (Odd.{0} Int Int.instSemiringInt n) (Not (Even.{0} Int Int.instAddInt n))
-Case conversion may be inaccurate. Consider using '#align int.odd_iff_not_even Int.odd_iff_not_evenₓ'. -/
@[simp]
theorem odd_iff_not_even : Odd n ↔ ¬Even n := by rw [not_even_iff, odd_iff]
#align int.odd_iff_not_even Int.odd_iff_not_even
-/- warning: int.is_compl_even_odd -> Int.isCompl_even_odd is a dubious translation:
-lean 3 declaration is
- IsCompl.{0} (Set.{0} Int) (SemilatticeInf.toPartialOrder.{0} (Set.{0} Int) (Lattice.toSemilatticeInf.{0} (Set.{0} Int) (GeneralizedCoheytingAlgebra.toLattice.{0} (Set.{0} Int) (GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra.{0} (Set.{0} Int) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{0} (Set.{0} Int) (Set.booleanAlgebra.{0} Int)))))) (BooleanAlgebra.toBoundedOrder.{0} (Set.{0} Int) (Set.booleanAlgebra.{0} Int)) (setOf.{0} Int (fun (n : Int) => Even.{0} Int Int.hasAdd n)) (setOf.{0} Int (fun (n : Int) => Odd.{0} Int Int.semiring n))
-but is expected to have type
- IsCompl.{0} (Set.{0} Int) (SemilatticeInf.toPartialOrder.{0} (Set.{0} Int) (Lattice.toSemilatticeInf.{0} (Set.{0} Int) (GeneralizedCoheytingAlgebra.toLattice.{0} (Set.{0} Int) (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{0} (Set.{0} Int) (BiheytingAlgebra.toCoheytingAlgebra.{0} (Set.{0} Int) (BooleanAlgebra.toBiheytingAlgebra.{0} (Set.{0} Int) (Set.instBooleanAlgebraSet.{0} Int))))))) (BooleanAlgebra.toBoundedOrder.{0} (Set.{0} Int) (Set.instBooleanAlgebraSet.{0} Int)) (setOf.{0} Int (fun (n : Int) => Even.{0} Int Int.instAddInt n)) (setOf.{0} Int (fun (n : Int) => Odd.{0} Int Int.instSemiringInt n))
-Case conversion may be inaccurate. Consider using '#align int.is_compl_even_odd Int.isCompl_even_oddₓ'. -/
theorem isCompl_even_odd : IsCompl { n : ℤ | Even n } { n | Odd n } := by
simp [← Set.compl_setOf, isCompl_compl]
#align int.is_compl_even_odd Int.isCompl_even_odd
-/- warning: int.even_or_odd -> Int.even_or_odd is a dubious translation:
-lean 3 declaration is
- forall (n : Int), Or (Even.{0} Int Int.hasAdd n) (Odd.{0} Int Int.semiring n)
-but is expected to have type
- forall (n : Int), Or (Even.{0} Int Int.instAddInt n) (Odd.{0} Int Int.instSemiringInt n)
-Case conversion may be inaccurate. Consider using '#align int.even_or_odd Int.even_or_oddₓ'. -/
theorem even_or_odd (n : ℤ) : Even n ∨ Odd n :=
Or.imp_right odd_iff_not_even.2 <| em <| Even n
#align int.even_or_odd Int.even_or_odd
@@ -120,12 +84,6 @@ theorem even_or_odd' (n : ℤ) : ∃ k, n = 2 * k ∨ n = 2 * k + 1 := by
#align int.even_or_odd' Int.even_or_odd'
-/
-/- warning: int.even_xor_odd -> Int.even_xor'_odd is a dubious translation:
-lean 3 declaration is
- forall (n : Int), Xor' (Even.{0} Int Int.hasAdd n) (Odd.{0} Int Int.semiring n)
-but is expected to have type
- forall (n : Int), Xor' (Even.{0} Int Int.instAddInt n) (Odd.{0} Int Int.instSemiringInt n)
-Case conversion may be inaccurate. Consider using '#align int.even_xor_odd Int.even_xor'_oddₓ'. -/
theorem even_xor'_odd (n : ℤ) : Xor' (Even n) (Odd n) :=
by
cases' even_or_odd n with h
@@ -146,12 +104,6 @@ theorem even_xor'_odd' (n : ℤ) : ∃ k, Xor' (n = 2 * k) (n = 2 * k + 1) :=
#align int.even_xor_odd' Int.even_xor'_odd'
-/
-/- warning: int.two_dvd_ne_zero -> Int.two_dvd_ne_zero is a dubious translation:
-lean 3 declaration is
- forall {n : Int}, Iff (Not (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) (OfNat.ofNat.{0} Int 2 (OfNat.mk.{0} Int 2 (bit0.{0} Int Int.hasAdd (One.one.{0} Int Int.hasOne)))) n)) (Eq.{1} Int (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.hasMod) n (OfNat.ofNat.{0} Int 2 (OfNat.mk.{0} Int 2 (bit0.{0} Int Int.hasAdd (One.one.{0} Int Int.hasOne))))) (OfNat.ofNat.{0} Int 1 (OfNat.mk.{0} Int 1 (One.one.{0} Int Int.hasOne))))
-but is expected to have type
- forall {n : Int}, Iff (Not (Dvd.dvd.{0} Int Int.instDvdInt (OfNat.ofNat.{0} Int 2 (instOfNatInt 2)) n)) (Eq.{1} Int (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.instModInt_1) n (OfNat.ofNat.{0} Int 2 (instOfNatInt 2))) (OfNat.ofNat.{0} Int 1 (instOfNatInt 1)))
-Case conversion may be inaccurate. Consider using '#align int.two_dvd_ne_zero Int.two_dvd_ne_zeroₓ'. -/
@[simp]
theorem two_dvd_ne_zero : ¬2 ∣ n ↔ n % 2 = 1 :=
even_iff_two_dvd.symm.Not.trans not_even_iff
@@ -176,12 +128,6 @@ theorem even_add : Even (m + n) ↔ (Even m ↔ Even n) := by
#align int.even_add Int.even_add
-/
-/- warning: int.even_add' -> Int.even_add' is a dubious translation:
-lean 3 declaration is
- forall {m : Int} {n : Int}, Iff (Even.{0} Int Int.hasAdd (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.hasAdd) m n)) (Iff (Odd.{0} Int Int.semiring m) (Odd.{0} Int Int.semiring n))
-but is expected to have type
- forall {m : Int} {n : Int}, Iff (Even.{0} Int Int.instAddInt (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.instAddInt) m n)) (Iff (Odd.{0} Int Int.instSemiringInt m) (Odd.{0} Int Int.instSemiringInt n))
-Case conversion may be inaccurate. Consider using '#align int.even_add' Int.even_add'ₓ'. -/
theorem even_add' : Even (m + n) ↔ (Odd m ↔ Odd n) := by
rw [even_add, even_iff_not_odd, even_iff_not_odd, not_iff_not]
#align int.even_add' Int.even_add'
@@ -192,12 +138,6 @@ theorem not_even_bit1 (n : ℤ) : ¬Even (bit1 n) := by simp [bit1, parity_simps
#align int.not_even_bit1 Int.not_even_bit1
-/
-/- warning: int.two_not_dvd_two_mul_add_one -> Int.two_not_dvd_two_mul_add_one is a dubious translation:
-lean 3 declaration is
- forall (n : Int), Not (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) (OfNat.ofNat.{0} Int 2 (OfNat.mk.{0} Int 2 (bit0.{0} Int Int.hasAdd (One.one.{0} Int Int.hasOne)))) (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.hasAdd) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) (OfNat.ofNat.{0} Int 2 (OfNat.mk.{0} Int 2 (bit0.{0} Int Int.hasAdd (One.one.{0} Int Int.hasOne)))) n) (OfNat.ofNat.{0} Int 1 (OfNat.mk.{0} Int 1 (One.one.{0} Int Int.hasOne)))))
-but is expected to have type
- forall (n : Int), Not (Dvd.dvd.{0} Int Int.instDvdInt (OfNat.ofNat.{0} Int 2 (instOfNatInt 2)) (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.instAddInt) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) (OfNat.ofNat.{0} Int 2 (instOfNatInt 2)) n) (OfNat.ofNat.{0} Int 1 (instOfNatInt 1))))
-Case conversion may be inaccurate. Consider using '#align int.two_not_dvd_two_mul_add_one Int.two_not_dvd_two_mul_add_oneₓ'. -/
theorem two_not_dvd_two_mul_add_one (n : ℤ) : ¬2 ∣ 2 * n + 1 := by simp [add_mod]; rfl
#align int.two_not_dvd_two_mul_add_one Int.two_not_dvd_two_mul_add_one
@@ -207,12 +147,6 @@ theorem even_sub : Even (m - n) ↔ (Even m ↔ Even n) := by simp [sub_eq_add_n
#align int.even_sub Int.even_sub
-/
-/- warning: int.even_sub' -> Int.even_sub' is a dubious translation:
-lean 3 declaration is
- forall {m : Int} {n : Int}, Iff (Even.{0} Int Int.hasAdd (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.hasSub) m n)) (Iff (Odd.{0} Int Int.semiring m) (Odd.{0} Int Int.semiring n))
-but is expected to have type
- forall {m : Int} {n : Int}, Iff (Even.{0} Int Int.instAddInt (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.instSubInt) m n)) (Iff (Odd.{0} Int Int.instSemiringInt m) (Odd.{0} Int Int.instSemiringInt n))
-Case conversion may be inaccurate. Consider using '#align int.even_sub' Int.even_sub'ₓ'. -/
theorem even_sub' : Even (m - n) ↔ (Odd m ↔ Odd n) := by
rw [even_sub, even_iff_not_odd, even_iff_not_odd, not_iff_not]
#align int.even_sub' Int.even_sub'
@@ -232,102 +166,42 @@ theorem even_mul : Even (m * n) ↔ Even m ∨ Even n := by
#align int.even_mul Int.even_mul
-/
-/- warning: int.odd_mul -> Int.odd_mul is a dubious translation:
-lean 3 declaration is
- forall {m : Int} {n : Int}, Iff (Odd.{0} Int Int.semiring (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) m n)) (And (Odd.{0} Int Int.semiring m) (Odd.{0} Int Int.semiring n))
-but is expected to have type
- forall {m : Int} {n : Int}, Iff (Odd.{0} Int Int.instSemiringInt (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) m n)) (And (Odd.{0} Int Int.instSemiringInt m) (Odd.{0} Int Int.instSemiringInt n))
-Case conversion may be inaccurate. Consider using '#align int.odd_mul Int.odd_mulₓ'. -/
theorem odd_mul : Odd (m * n) ↔ Odd m ∧ Odd n := by simp [not_or, parity_simps]
#align int.odd_mul Int.odd_mul
-/- warning: int.odd.of_mul_left -> Int.Odd.of_mul_left is a dubious translation:
-lean 3 declaration is
- forall {m : Int} {n : Int}, (Odd.{0} Int Int.semiring (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) m n)) -> (Odd.{0} Int Int.semiring m)
-but is expected to have type
- forall {m : Int} {n : Int}, (Odd.{0} Int Int.instSemiringInt (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) m n)) -> (Odd.{0} Int Int.instSemiringInt m)
-Case conversion may be inaccurate. Consider using '#align int.odd.of_mul_left Int.Odd.of_mul_leftₓ'. -/
theorem Odd.of_mul_left (h : Odd (m * n)) : Odd m :=
(odd_mul.mp h).1
#align int.odd.of_mul_left Int.Odd.of_mul_left
-/- warning: int.odd.of_mul_right -> Int.Odd.of_mul_right is a dubious translation:
-lean 3 declaration is
- forall {m : Int} {n : Int}, (Odd.{0} Int Int.semiring (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) m n)) -> (Odd.{0} Int Int.semiring n)
-but is expected to have type
- forall {m : Int} {n : Int}, (Odd.{0} Int Int.instSemiringInt (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) m n)) -> (Odd.{0} Int Int.instSemiringInt n)
-Case conversion may be inaccurate. Consider using '#align int.odd.of_mul_right Int.Odd.of_mul_rightₓ'. -/
theorem Odd.of_mul_right (h : Odd (m * n)) : Odd n :=
(odd_mul.mp h).2
#align int.odd.of_mul_right Int.Odd.of_mul_right
-/- warning: int.even_pow -> Int.even_pow is a dubious translation:
-lean 3 declaration is
- forall {m : Int} {n : Nat}, Iff (Even.{0} Int Int.hasAdd (HPow.hPow.{0, 0, 0} Int Nat Int (instHPow.{0, 0} Int Nat (Monoid.Pow.{0} Int Int.monoid)) m n)) (And (Even.{0} Int Int.hasAdd m) (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))))
-but is expected to have type
- forall {m : Int} {n : Nat}, Iff (Even.{0} Int Int.instAddInt (HPow.hPow.{0, 0, 0} Int Nat Int Int.instHPowIntNat m n)) (And (Even.{0} Int Int.instAddInt m) (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))
-Case conversion may be inaccurate. Consider using '#align int.even_pow Int.even_powₓ'. -/
@[parity_simps]
theorem even_pow {n : ℕ} : Even (m ^ n) ↔ Even m ∧ n ≠ 0 := by
induction' n with n ih <;> simp [*, even_mul, pow_succ]; tauto
#align int.even_pow Int.even_pow
-/- warning: int.even_pow' -> Int.even_pow' is a dubious translation:
-lean 3 declaration is
- forall {m : Int} {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> (Iff (Even.{0} Int Int.hasAdd (HPow.hPow.{0, 0, 0} Int Nat Int (instHPow.{0, 0} Int Nat (Monoid.Pow.{0} Int Int.monoid)) m n)) (Even.{0} Int Int.hasAdd m))
-but is expected to have type
- forall {m : Int} {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (Iff (Even.{0} Int Int.instAddInt (HPow.hPow.{0, 0, 0} Int Nat Int Int.instHPowIntNat m n)) (Even.{0} Int Int.instAddInt m))
-Case conversion may be inaccurate. Consider using '#align int.even_pow' Int.even_pow'ₓ'. -/
theorem even_pow' {n : ℕ} (h : n ≠ 0) : Even (m ^ n) ↔ Even m :=
even_pow.trans <| and_iff_left h
#align int.even_pow' Int.even_pow'
-/- warning: int.odd_add -> Int.odd_add is a dubious translation:
-lean 3 declaration is
- forall {m : Int} {n : Int}, Iff (Odd.{0} Int Int.semiring (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.hasAdd) m n)) (Iff (Odd.{0} Int Int.semiring m) (Even.{0} Int Int.hasAdd n))
-but is expected to have type
- forall {m : Int} {n : Int}, Iff (Odd.{0} Int Int.instSemiringInt (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.instAddInt) m n)) (Iff (Odd.{0} Int Int.instSemiringInt m) (Even.{0} Int Int.instAddInt n))
-Case conversion may be inaccurate. Consider using '#align int.odd_add Int.odd_addₓ'. -/
@[parity_simps]
theorem odd_add : Odd (m + n) ↔ (Odd m ↔ Even n) := by
rw [odd_iff_not_even, even_add, not_iff, odd_iff_not_even]
#align int.odd_add Int.odd_add
-/- warning: int.odd_add' -> Int.odd_add' is a dubious translation:
-lean 3 declaration is
- forall {m : Int} {n : Int}, Iff (Odd.{0} Int Int.semiring (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.hasAdd) m n)) (Iff (Odd.{0} Int Int.semiring n) (Even.{0} Int Int.hasAdd m))
-but is expected to have type
- forall {m : Int} {n : Int}, Iff (Odd.{0} Int Int.instSemiringInt (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.instAddInt) m n)) (Iff (Odd.{0} Int Int.instSemiringInt n) (Even.{0} Int Int.instAddInt m))
-Case conversion may be inaccurate. Consider using '#align int.odd_add' Int.odd_add'ₓ'. -/
theorem odd_add' : Odd (m + n) ↔ (Odd n ↔ Even m) := by rw [add_comm, odd_add]
#align int.odd_add' Int.odd_add'
-/- warning: int.ne_of_odd_add -> Int.ne_of_odd_add is a dubious translation:
-lean 3 declaration is
- forall {m : Int} {n : Int}, (Odd.{0} Int Int.semiring (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.hasAdd) m n)) -> (Ne.{1} Int m n)
-but is expected to have type
- forall {m : Int} {n : Int}, (Odd.{0} Int Int.instSemiringInt (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.instAddInt) m n)) -> (Ne.{1} Int m n)
-Case conversion may be inaccurate. Consider using '#align int.ne_of_odd_add Int.ne_of_odd_addₓ'. -/
theorem ne_of_odd_add (h : Odd (m + n)) : m ≠ n := fun hnot => by simpa [hnot, parity_simps] using h
#align int.ne_of_odd_add Int.ne_of_odd_add
-/- warning: int.odd_sub -> Int.odd_sub is a dubious translation:
-lean 3 declaration is
- forall {m : Int} {n : Int}, Iff (Odd.{0} Int Int.semiring (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.hasSub) m n)) (Iff (Odd.{0} Int Int.semiring m) (Even.{0} Int Int.hasAdd n))
-but is expected to have type
- forall {m : Int} {n : Int}, Iff (Odd.{0} Int Int.instSemiringInt (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.instSubInt) m n)) (Iff (Odd.{0} Int Int.instSemiringInt m) (Even.{0} Int Int.instAddInt n))
-Case conversion may be inaccurate. Consider using '#align int.odd_sub Int.odd_subₓ'. -/
@[parity_simps]
theorem odd_sub : Odd (m - n) ↔ (Odd m ↔ Even n) := by
rw [odd_iff_not_even, even_sub, not_iff, odd_iff_not_even]
#align int.odd_sub Int.odd_sub
-/- warning: int.odd_sub' -> Int.odd_sub' is a dubious translation:
-lean 3 declaration is
- forall {m : Int} {n : Int}, Iff (Odd.{0} Int Int.semiring (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.hasSub) m n)) (Iff (Odd.{0} Int Int.semiring n) (Even.{0} Int Int.hasAdd m))
-but is expected to have type
- forall {m : Int} {n : Int}, Iff (Odd.{0} Int Int.instSemiringInt (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.instSubInt) m n)) (Iff (Odd.{0} Int Int.instSemiringInt n) (Even.{0} Int Int.instAddInt m))
-Case conversion may be inaccurate. Consider using '#align int.odd_sub' Int.odd_sub'ₓ'. -/
theorem odd_sub' : Odd (m - n) ↔ (Odd n ↔ Even m) := by
rw [odd_iff_not_even, even_sub, not_iff, not_iff_comm, odd_iff_not_even]
#align int.odd_sub' Int.odd_sub'
@@ -347,12 +221,6 @@ theorem even_coe_nat (n : ℕ) : Even (n : ℤ) ↔ Even n := by rw_mod_cast [ev
#align int.even_coe_nat Int.even_coe_nat
-/
-/- warning: int.odd_coe_nat -> Int.odd_coe_nat is a dubious translation:
-lean 3 declaration is
- forall (n : Nat), Iff (Odd.{0} Int Int.semiring ((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)) (Odd.{0} Nat Nat.semiring n)
-but is expected to have type
- forall (n : Nat), Iff (Odd.{0} Int Int.instSemiringInt (Nat.cast.{0} Int instNatCastInt n)) (Odd.{0} Nat Nat.semiring n)
-Case conversion may be inaccurate. Consider using '#align int.odd_coe_nat Int.odd_coe_natₓ'. -/
@[simp, norm_cast]
theorem odd_coe_nat (n : ℕ) : Odd (n : ℤ) ↔ Odd n := by
rw [odd_iff_not_even, Nat.odd_iff_not_even, even_coe_nat]
@@ -365,12 +233,6 @@ theorem natAbs_even : Even n.natAbs ↔ Even n := by
#align int.nat_abs_even Int.natAbs_even
-/
-/- warning: int.nat_abs_odd -> Int.natAbs_odd is a dubious translation:
-lean 3 declaration is
- forall {n : Int}, Iff (Odd.{0} Nat Nat.semiring (Int.natAbs n)) (Odd.{0} Int Int.semiring n)
-but is expected to have type
- forall {n : Int}, Iff (Odd.{0} Nat Nat.semiring (Int.natAbs n)) (Odd.{0} Int Int.instSemiringInt n)
-Case conversion may be inaccurate. Consider using '#align int.nat_abs_odd Int.natAbs_oddₓ'. -/
@[simp]
theorem natAbs_odd : Odd n.natAbs ↔ Odd n := by
rw [odd_iff_not_even, Nat.odd_iff_not_even, nat_abs_even]
@@ -379,23 +241,11 @@ theorem natAbs_odd : Odd n.natAbs ↔ Odd n := by
alias nat_abs_even ↔ _ _root_.even.nat_abs
#align even.nat_abs Even.natAbs
-/- warning: odd.nat_abs -> Odd.natAbs is a dubious translation:
-lean 3 declaration is
- forall {n : Int}, (Odd.{0} Int Int.semiring n) -> (Odd.{0} Nat Nat.semiring (Int.natAbs n))
-but is expected to have type
- forall {n : Int}, (Odd.{0} Int Int.instSemiringInt n) -> (Odd.{0} Nat Nat.semiring (Int.natAbs n))
-Case conversion may be inaccurate. Consider using '#align odd.nat_abs Odd.natAbsₓ'. -/
alias nat_abs_odd ↔ _ _root_.odd.nat_abs
#align odd.nat_abs Odd.natAbs
attribute [protected] Even.natAbs Odd.natAbs
-/- warning: int.four_dvd_add_or_sub_of_odd -> Int.four_dvd_add_or_sub_of_odd is a dubious translation:
-lean 3 declaration is
- forall {a : Int} {b : Int}, (Odd.{0} Int Int.semiring a) -> (Odd.{0} Int Int.semiring b) -> (Or (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) (OfNat.ofNat.{0} Int 4 (OfNat.mk.{0} Int 4 (bit0.{0} Int Int.hasAdd (bit0.{0} Int Int.hasAdd (One.one.{0} Int Int.hasOne))))) (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.hasAdd) a b)) (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) (OfNat.ofNat.{0} Int 4 (OfNat.mk.{0} Int 4 (bit0.{0} Int Int.hasAdd (bit0.{0} Int Int.hasAdd (One.one.{0} Int Int.hasOne))))) (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.hasSub) a b)))
-but is expected to have type
- forall {a : Int} {b : Int}, (Odd.{0} Int Int.instSemiringInt a) -> (Odd.{0} Int Int.instSemiringInt b) -> (Or (Dvd.dvd.{0} Int Int.instDvdInt (OfNat.ofNat.{0} Int 4 (instOfNatInt 4)) (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.instAddInt) a b)) (Dvd.dvd.{0} Int Int.instDvdInt (OfNat.ofNat.{0} Int 4 (instOfNatInt 4)) (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.instSubInt) a b)))
-Case conversion may be inaccurate. Consider using '#align int.four_dvd_add_or_sub_of_odd Int.four_dvd_add_or_sub_of_oddₓ'. -/
theorem four_dvd_add_or_sub_of_odd {a b : ℤ} (ha : Odd a) (hb : Odd b) : 4 ∣ a + b ∨ 4 ∣ a - b :=
by
obtain ⟨m, rfl⟩ := ha
@@ -431,42 +281,18 @@ theorem ediv_two_mul_two_of_even : Even n → n / 2 * 2 = n :=
#align int.div_two_mul_two_of_even Int.ediv_two_mul_two_of_even
-/
-/- warning: int.two_mul_div_two_add_one_of_odd -> Int.two_mul_ediv_two_add_one_of_odd is a dubious translation:
-lean 3 declaration is
- forall {n : Int}, (Odd.{0} Int Int.semiring n) -> (Eq.{1} Int (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.hasAdd) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) (OfNat.ofNat.{0} Int 2 (OfNat.mk.{0} Int 2 (bit0.{0} Int Int.hasAdd (One.one.{0} Int Int.hasOne)))) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) n (OfNat.ofNat.{0} Int 2 (OfNat.mk.{0} Int 2 (bit0.{0} Int Int.hasAdd (One.one.{0} Int Int.hasOne)))))) (OfNat.ofNat.{0} Int 1 (OfNat.mk.{0} Int 1 (One.one.{0} Int Int.hasOne)))) n)
-but is expected to have type
- forall {n : Int}, (Odd.{0} Int Int.instSemiringInt n) -> (Eq.{1} Int (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.instAddInt) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) (OfNat.ofNat.{0} Int 2 (instOfNatInt 2)) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) n (OfNat.ofNat.{0} Int 2 (instOfNatInt 2)))) (OfNat.ofNat.{0} Int 1 (instOfNatInt 1))) n)
-Case conversion may be inaccurate. Consider using '#align int.two_mul_div_two_add_one_of_odd Int.two_mul_ediv_two_add_one_of_oddₓ'. -/
theorem two_mul_ediv_two_add_one_of_odd : Odd n → 2 * (n / 2) + 1 = n := by rintro ⟨c, rfl⟩;
rw [mul_comm]; convert Int.div_add_mod' _ _; simpa [Int.add_emod]
#align int.two_mul_div_two_add_one_of_odd Int.two_mul_ediv_two_add_one_of_odd
-/- warning: int.div_two_mul_two_add_one_of_odd -> Int.ediv_two_mul_two_add_one_of_odd is a dubious translation:
-lean 3 declaration is
- forall {n : Int}, (Odd.{0} Int Int.semiring n) -> (Eq.{1} Int (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.hasAdd) (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) n (OfNat.ofNat.{0} Int 2 (OfNat.mk.{0} Int 2 (bit0.{0} Int Int.hasAdd (One.one.{0} Int Int.hasOne))))) (OfNat.ofNat.{0} Int 2 (OfNat.mk.{0} Int 2 (bit0.{0} Int Int.hasAdd (One.one.{0} Int Int.hasOne))))) (OfNat.ofNat.{0} Int 1 (OfNat.mk.{0} Int 1 (One.one.{0} Int Int.hasOne)))) n)
-but is expected to have type
- forall {n : Int}, (Odd.{0} Int Int.instSemiringInt n) -> (Eq.{1} Int (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.instAddInt) (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) n (OfNat.ofNat.{0} Int 2 (instOfNatInt 2))) (OfNat.ofNat.{0} Int 2 (instOfNatInt 2))) (OfNat.ofNat.{0} Int 1 (instOfNatInt 1))) n)
-Case conversion may be inaccurate. Consider using '#align int.div_two_mul_two_add_one_of_odd Int.ediv_two_mul_two_add_one_of_oddₓ'. -/
theorem ediv_two_mul_two_add_one_of_odd : Odd n → n / 2 * 2 + 1 = n := by rintro ⟨c, rfl⟩;
convert Int.div_add_mod' _ _; simpa [Int.add_emod]
#align int.div_two_mul_two_add_one_of_odd Int.ediv_two_mul_two_add_one_of_odd
-/- warning: int.add_one_div_two_mul_two_of_odd -> Int.add_one_ediv_two_mul_two_of_odd is a dubious translation:
-lean 3 declaration is
- forall {n : Int}, (Odd.{0} Int Int.semiring n) -> (Eq.{1} Int (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.hasAdd) (OfNat.ofNat.{0} Int 1 (OfNat.mk.{0} Int 1 (One.one.{0} Int Int.hasOne))) (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) n (OfNat.ofNat.{0} Int 2 (OfNat.mk.{0} Int 2 (bit0.{0} Int Int.hasAdd (One.one.{0} Int Int.hasOne))))) (OfNat.ofNat.{0} Int 2 (OfNat.mk.{0} Int 2 (bit0.{0} Int Int.hasAdd (One.one.{0} Int Int.hasOne)))))) n)
-but is expected to have type
- forall {n : Int}, (Odd.{0} Int Int.instSemiringInt n) -> (Eq.{1} Int (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.instAddInt) (OfNat.ofNat.{0} Int 1 (instOfNatInt 1)) (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) n (OfNat.ofNat.{0} Int 2 (instOfNatInt 2))) (OfNat.ofNat.{0} Int 2 (instOfNatInt 2)))) n)
-Case conversion may be inaccurate. Consider using '#align int.add_one_div_two_mul_two_of_odd Int.add_one_ediv_two_mul_two_of_oddₓ'. -/
theorem add_one_ediv_two_mul_two_of_odd : Odd n → 1 + n / 2 * 2 = n := by rintro ⟨c, rfl⟩;
rw [add_comm]; convert Int.div_add_mod' _ _; simpa [Int.add_emod]
#align int.add_one_div_two_mul_two_of_odd Int.add_one_ediv_two_mul_two_of_odd
-/- warning: int.two_mul_div_two_of_odd -> Int.two_mul_ediv_two_of_odd is a dubious translation:
-lean 3 declaration is
- forall {n : Int}, (Odd.{0} Int Int.semiring n) -> (Eq.{1} Int (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) (OfNat.ofNat.{0} Int 2 (OfNat.mk.{0} Int 2 (bit0.{0} Int Int.hasAdd (One.one.{0} Int Int.hasOne)))) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.hasDiv) n (OfNat.ofNat.{0} Int 2 (OfNat.mk.{0} Int 2 (bit0.{0} Int Int.hasAdd (One.one.{0} Int Int.hasOne)))))) (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.hasSub) n (OfNat.ofNat.{0} Int 1 (OfNat.mk.{0} Int 1 (One.one.{0} Int Int.hasOne)))))
-but is expected to have type
- forall {n : Int}, (Odd.{0} Int Int.instSemiringInt n) -> (Eq.{1} Int (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) (OfNat.ofNat.{0} Int 2 (instOfNatInt 2)) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) n (OfNat.ofNat.{0} Int 2 (instOfNatInt 2)))) (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.instSubInt) n (OfNat.ofNat.{0} Int 1 (instOfNatInt 1))))
-Case conversion may be inaccurate. Consider using '#align int.two_mul_div_two_of_odd Int.two_mul_ediv_two_of_oddₓ'. -/
theorem two_mul_ediv_two_of_odd (h : Odd n) : 2 * (n / 2) = n - 1 :=
eq_sub_of_add_eq (two_mul_ediv_two_add_one_of_odd h)
#align int.two_mul_div_two_of_odd Int.two_mul_ediv_two_of_odd
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -57,14 +57,8 @@ but is expected to have type
forall {n : Int}, Iff (Odd.{0} Int Int.instSemiringInt n) (Eq.{1} Int (HMod.hMod.{0, 0, 0} Int Int Int (instHMod.{0} Int Int.instModInt_1) n (OfNat.ofNat.{0} Int 2 (instOfNatInt 2))) (OfNat.ofNat.{0} Int 1 (instOfNatInt 1)))
Case conversion may be inaccurate. Consider using '#align int.odd_iff Int.odd_iffₓ'. -/
theorem odd_iff : Odd n ↔ n % 2 = 1 :=
- ⟨fun ⟨m, hm⟩ => by
- rw [hm, add_mod]
- norm_num, fun h =>
- ⟨n / 2,
- (emod_add_ediv n 2).symm.trans
- (by
- rw [h]
- abel)⟩⟩
+ ⟨fun ⟨m, hm⟩ => by rw [hm, add_mod]; norm_num, fun h =>
+ ⟨n / 2, (emod_add_ediv n 2).symm.trans (by rw [h]; abel)⟩⟩
#align int.odd_iff Int.odd_iff
#print Int.not_even_iff /-
@@ -204,10 +198,7 @@ lean 3 declaration is
but is expected to have type
forall (n : Int), Not (Dvd.dvd.{0} Int Int.instDvdInt (OfNat.ofNat.{0} Int 2 (instOfNatInt 2)) (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.instAddInt) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) (OfNat.ofNat.{0} Int 2 (instOfNatInt 2)) n) (OfNat.ofNat.{0} Int 1 (instOfNatInt 1))))
Case conversion may be inaccurate. Consider using '#align int.two_not_dvd_two_mul_add_one Int.two_not_dvd_two_mul_add_oneₓ'. -/
-theorem two_not_dvd_two_mul_add_one (n : ℤ) : ¬2 ∣ 2 * n + 1 :=
- by
- simp [add_mod]
- rfl
+theorem two_not_dvd_two_mul_add_one (n : ℤ) : ¬2 ∣ 2 * n + 1 := by simp [add_mod]; rfl
#align int.two_not_dvd_two_mul_add_one Int.two_not_dvd_two_mul_add_one
#print Int.even_sub /-
@@ -277,10 +268,8 @@ but is expected to have type
forall {m : Int} {n : Nat}, Iff (Even.{0} Int Int.instAddInt (HPow.hPow.{0, 0, 0} Int Nat Int Int.instHPowIntNat m n)) (And (Even.{0} Int Int.instAddInt m) (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))
Case conversion may be inaccurate. Consider using '#align int.even_pow Int.even_powₓ'. -/
@[parity_simps]
-theorem even_pow {n : ℕ} : Even (m ^ n) ↔ Even m ∧ n ≠ 0 :=
- by
- induction' n with n ih <;> simp [*, even_mul, pow_succ]
- tauto
+theorem even_pow {n : ℕ} : Even (m ^ n) ↔ Even m ∧ n ≠ 0 := by
+ induction' n with n ih <;> simp [*, even_mul, pow_succ]; tauto
#align int.even_pow Int.even_pow
/- warning: int.even_pow' -> Int.even_pow' is a dubious translation:
@@ -448,12 +437,8 @@ lean 3 declaration is
but is expected to have type
forall {n : Int}, (Odd.{0} Int Int.instSemiringInt n) -> (Eq.{1} Int (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.instAddInt) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) (OfNat.ofNat.{0} Int 2 (instOfNatInt 2)) (HDiv.hDiv.{0, 0, 0} Int Int Int (instHDiv.{0} Int Int.instDivInt_1) n (OfNat.ofNat.{0} Int 2 (instOfNatInt 2)))) (OfNat.ofNat.{0} Int 1 (instOfNatInt 1))) n)
Case conversion may be inaccurate. Consider using '#align int.two_mul_div_two_add_one_of_odd Int.two_mul_ediv_two_add_one_of_oddₓ'. -/
-theorem two_mul_ediv_two_add_one_of_odd : Odd n → 2 * (n / 2) + 1 = n :=
- by
- rintro ⟨c, rfl⟩
- rw [mul_comm]
- convert Int.div_add_mod' _ _
- simpa [Int.add_emod]
+theorem two_mul_ediv_two_add_one_of_odd : Odd n → 2 * (n / 2) + 1 = n := by rintro ⟨c, rfl⟩;
+ rw [mul_comm]; convert Int.div_add_mod' _ _; simpa [Int.add_emod]
#align int.two_mul_div_two_add_one_of_odd Int.two_mul_ediv_two_add_one_of_odd
/- warning: int.div_two_mul_two_add_one_of_odd -> Int.ediv_two_mul_two_add_one_of_odd is a dubious translation:
@@ -462,11 +447,8 @@ lean 3 declaration is
but is expected to have type
forall {n : Int}, (Odd.{0} Int Int.instSemiringInt n) -> (Eq.{1} Int (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.instAddInt) (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) n (OfNat.ofNat.{0} Int 2 (instOfNatInt 2))) (OfNat.ofNat.{0} Int 2 (instOfNatInt 2))) (OfNat.ofNat.{0} Int 1 (instOfNatInt 1))) n)
Case conversion may be inaccurate. Consider using '#align int.div_two_mul_two_add_one_of_odd Int.ediv_two_mul_two_add_one_of_oddₓ'. -/
-theorem ediv_two_mul_two_add_one_of_odd : Odd n → n / 2 * 2 + 1 = n :=
- by
- rintro ⟨c, rfl⟩
- convert Int.div_add_mod' _ _
- simpa [Int.add_emod]
+theorem ediv_two_mul_two_add_one_of_odd : Odd n → n / 2 * 2 + 1 = n := by rintro ⟨c, rfl⟩;
+ convert Int.div_add_mod' _ _; simpa [Int.add_emod]
#align int.div_two_mul_two_add_one_of_odd Int.ediv_two_mul_two_add_one_of_odd
/- warning: int.add_one_div_two_mul_two_of_odd -> Int.add_one_ediv_two_mul_two_of_odd is a dubious translation:
@@ -475,12 +457,8 @@ lean 3 declaration is
but is expected to have type
forall {n : Int}, (Odd.{0} Int Int.instSemiringInt n) -> (Eq.{1} Int (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.instAddInt) (OfNat.ofNat.{0} Int 1 (instOfNatInt 1)) (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) n (OfNat.ofNat.{0} Int 2 (instOfNatInt 2))) (OfNat.ofNat.{0} Int 2 (instOfNatInt 2)))) n)
Case conversion may be inaccurate. Consider using '#align int.add_one_div_two_mul_two_of_odd Int.add_one_ediv_two_mul_two_of_oddₓ'. -/
-theorem add_one_ediv_two_mul_two_of_odd : Odd n → 1 + n / 2 * 2 = n :=
- by
- rintro ⟨c, rfl⟩
- rw [add_comm]
- convert Int.div_add_mod' _ _
- simpa [Int.add_emod]
+theorem add_one_ediv_two_mul_two_of_odd : Odd n → 1 + n / 2 * 2 = n := by rintro ⟨c, rfl⟩;
+ rw [add_comm]; convert Int.div_add_mod' _ _; simpa [Int.add_emod]
#align int.add_one_div_two_mul_two_of_odd Int.add_one_ediv_two_mul_two_of_odd
/- warning: int.two_mul_div_two_of_odd -> Int.two_mul_ediv_two_of_odd is a dubious translation:
mathlib commit https://github.com/leanprover-community/mathlib/commit/da3fc4a33ff6bc75f077f691dc94c217b8d41559
@@ -362,7 +362,7 @@ theorem even_coe_nat (n : ℕ) : Even (n : ℤ) ↔ Even n := by rw_mod_cast [ev
lean 3 declaration is
forall (n : Nat), Iff (Odd.{0} Int Int.semiring ((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)) (Odd.{0} Nat Nat.semiring n)
but is expected to have type
- forall (n : Nat), Iff (Odd.{0} Int Int.instSemiringInt (Nat.cast.{0} Int Int.instNatCastInt n)) (Odd.{0} Nat Nat.semiring n)
+ forall (n : Nat), Iff (Odd.{0} Int Int.instSemiringInt (Nat.cast.{0} Int instNatCastInt n)) (Odd.{0} Nat Nat.semiring n)
Case conversion may be inaccurate. Consider using '#align int.odd_coe_nat Int.odd_coe_natₓ'. -/
@[simp, norm_cast]
theorem odd_coe_nat (n : ℕ) : Odd (n : ℤ) ↔ Odd n := by
mathlib commit https://github.com/leanprover-community/mathlib/commit/bd9851ca476957ea4549eb19b40e7b5ade9428cc
This is a far from a complete success at the PR title, but it makes a fair bit of progress, and then guards this with appropriate assert_not_exists Ring
statements.
It also breaks apart the Mathlib.GroupTheory.Subsemigroup.[Center|Centralizer]
files, to pull the Set.center
and Set.centralizer
declarations into their own files not depending on Subsemigroup
.
Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Yaël Dillies <yael.dillies@gmail.com>
@@ -3,9 +3,9 @@ Copyright (c) 2019 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Benjamin Davidson
-/
-import Mathlib.Algebra.Ring.Int
-import Mathlib.Data.Int.Sqrt
import Mathlib.Data.Nat.Parity
+import Mathlib.Algebra.Group.Int
+import Mathlib.Data.Int.Sqrt
import Mathlib.Tactic.Abel
#align_import data.int.parity from "leanprover-community/mathlib"@"e3d9ab8faa9dea8f78155c6c27d62a621f4c152d"
Nat.sqrt
material (#11866)
Move the content of Data.Nat.ForSqrt
and Data.Nat.Sqrt
to Data.Nat.Defs
by using Nat
-specific Std lemmas rather than the mathlib general ones. This makes it ready to move to Std if wanted.
@@ -3,8 +3,9 @@ Copyright (c) 2019 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Benjamin Davidson
-/
-import Mathlib.Data.Nat.Parity
import Mathlib.Algebra.Ring.Int
+import Mathlib.Data.Int.Sqrt
+import Mathlib.Data.Nat.Parity
import Mathlib.Tactic.Abel
#align_import data.int.parity from "leanprover-community/mathlib"@"e3d9ab8faa9dea8f78155c6c27d62a621f4c152d"
@@ -95,6 +96,11 @@ instance : DecidablePred (Even : ℤ → Prop) := fun _ => decidable_of_iff _ ev
instance : DecidablePred (Odd : ℤ → Prop) := fun _ => decidable_of_iff _ odd_iff_not_even.symm
+/-- `IsSquare` can be decided on `ℤ` by checking against the square root. -/
+instance : DecidablePred (IsSquare : ℤ → Prop) :=
+ fun m ↦ decidable_of_iff' (sqrt m * sqrt m = m) <| by
+ simp_rw [← exists_mul_self m, IsSquare, eq_comm]
+
@[simp]
theorem not_even_one : ¬Even (1 : ℤ) := by
rw [even_iff]
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
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Benjamin Davidson
-/
import Mathlib.Data.Nat.Parity
-import Mathlib.Data.Int.Basic
+import Mathlib.Algebra.Ring.Int
import Mathlib.Tactic.Abel
#align_import data.int.parity from "leanprover-community/mathlib"@"e3d9ab8faa9dea8f78155c6c27d62a621f4c152d"
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
@@ -217,7 +217,7 @@ theorem odd_coe_nat (n : ℕ) : Odd (n : ℤ) ↔ Odd n := by
@[simp]
theorem natAbs_even : Even n.natAbs ↔ Even n := by
- simp [even_iff_two_dvd, dvd_natAbs, coe_nat_dvd_left.symm]
+ simp [even_iff_two_dvd, dvd_natAbs, natCast_dvd.symm]
#align int.nat_abs_even Int.natAbs_even
-- Porting note (#10618): was simp. simp can prove this.
mul
-div
cancellation lemmas (#11530)
Lemma names around cancellation of multiplication and division are a mess.
This PR renames a handful of them according to the following table (each big row contains the multiplicative statement, then the three rows contain the GroupWithZero
lemma name, the Group
lemma, the AddGroup
lemma name).
| Statement | New name | Old name | |
@@ -245,7 +245,7 @@ theorem four_dvd_add_or_sub_of_odd {a b : ℤ} (ha : Odd a) (hb : Odd b) :
rw [Int.even_add, ← Int.even_sub] at h
obtain ⟨k, hk⟩ := h
convert dvd_mul_right 4 k using 1
- rw [eq_add_of_sub_eq hk, mul_add, add_assoc, add_sub_cancel, ← two_mul, ← mul_assoc]
+ rw [eq_add_of_sub_eq hk, mul_add, add_assoc, add_sub_cancel_right, ← two_mul, ← mul_assoc]
rfl
· left
obtain ⟨k, hk⟩ := h
@@ -209,7 +209,7 @@ theorem even_coe_nat (n : ℕ) : Even (n : ℤ) ↔ Even n := by
rw_mod_cast [even_iff, Nat.even_iff]
#align int.even_coe_nat Int.even_coe_nat
--- Porting note: was simp. simp can prove this.
+-- Porting note (#10618): was simp. simp can prove this.
@[norm_cast]
theorem odd_coe_nat (n : ℕ) : Odd (n : ℤ) ↔ Odd n := by
rw [odd_iff_not_even, Nat.odd_iff_not_even, even_coe_nat]
@@ -220,7 +220,7 @@ theorem natAbs_even : Even n.natAbs ↔ Even n := by
simp [even_iff_two_dvd, dvd_natAbs, coe_nat_dvd_left.symm]
#align int.nat_abs_even Int.natAbs_even
--- Porting note: was simp. simp can prove this.
+-- Porting note (#10618): was simp. simp can prove this.
--@[simp]
theorem natAbs_odd : Odd n.natAbs ↔ Odd n := by
rw [odd_iff_not_even, Nat.odd_iff_not_even, natAbs_even]
@@ -4,6 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Benjamin Davidson
-/
import Mathlib.Data.Nat.Parity
+import Mathlib.Data.Int.Basic
import Mathlib.Tactic.Abel
#align_import data.int.parity from "leanprover-community/mathlib"@"e3d9ab8faa9dea8f78155c6c27d62a621f4c152d"
Also rename Nat.even_mul_self_pred
for consistency with Nat.even_mul_succ_self
.
@@ -135,6 +135,10 @@ theorem even_add_one : Even (n + 1) ↔ ¬Even n := by
simp [even_add]
#align int.even_add_one Int.even_add_one
+@[parity_simps]
+theorem even_sub_one : Even (n - 1) ↔ ¬Even n := by
+ simp [even_sub]
+
@[parity_simps]
theorem even_mul : Even (m * n) ↔ Even m ∨ Even n := by
cases' emod_two_eq_zero_or_one m with h₁ h₁ <;>
@@ -196,6 +200,9 @@ theorem even_mul_succ_self (n : ℤ) : Even (n * (n + 1)) := by
simpa [even_mul, parity_simps] using n.even_or_odd
#align int.even_mul_succ_self Int.even_mul_succ_self
+theorem even_mul_pred_self (n : ℤ) : Even (n * (n - 1)) := by
+ simpa [even_mul, parity_simps] using n.even_or_odd
+
@[simp, norm_cast]
theorem even_coe_nat (n : ℕ) : Even (n : ℤ) ↔ Even n := by
rw_mod_cast [even_iff, Nat.even_iff]
@@ -104,8 +104,7 @@ theorem not_even_one : ¬Even (1 : ℤ) := by
theorem even_add : Even (m + n) ↔ (Even m ↔ Even n) := by
cases' emod_two_eq_zero_or_one m with h₁ h₁ <;>
cases' emod_two_eq_zero_or_one n with h₂ h₂ <;>
- simp [even_iff, h₁, h₂, Int.add_emod]
- rfl
+ simp [even_iff, h₁, h₂, Int.add_emod, one_add_one_eq_two, emod_self]
#align int.even_add Int.even_add
theorem even_add' : Even (m + n) ↔ (Odd m ↔ Odd n) := by
This is the supremum of
along with some minor fixes from failures on nightly-testing as Mathlib master
is merged into it.
Note that some PRs for changes that are already compatible with the current toolchain and will be necessary have already been split out: #8380.
I am hopeful that in future we will be able to progressively merge adaptation PRs into a bump/v4.X.0
branch, so we never end up with a "big merge" like this. However one of these adaptation PRs (#8056) predates my new scheme for combined CI, and it wasn't possible to keep that PR viable in the meantime.
In particular this includes adjustments for the Lean PRs
We can get rid of all the
local macro_rules | `($x ^ $y) => `(HPow.hPow $x $y) -- Porting note: See issue [lean4#2220](https://github.com/leanprover/lean4/pull/2220)
macros across Mathlib (and in any projects that want to write natural number powers of reals).
Changes the default behaviour of simp
to (config := {decide := false})
. This makes simp
(and consequentially norm_num
) less powerful, but also more consistent, and less likely to blow up in long failures. This requires a variety of changes: changing some previously by simp
or norm_num
to decide
or rfl
, or adding (config := {decide := true})
.
This changed the behaviour of simp
so that simp [f]
will only unfold "fully applied" occurrences of f
. The old behaviour can be recovered with simp (config := { unfoldPartialApp := true })
. We may in future add a syntax for this, e.g. simp [!f]
; please provide feedback! In the meantime, we have made the following changes:
(config := { unfoldPartialApp := true })
in some places, to recover the old behaviour@[eqns]
to manually adjust the equation lemmas for a particular definition, recovering the old behaviour just for that definition. See #8371, where we do this for Function.comp
and Function.flip
.This change in Lean may require further changes down the line (e.g. adding the !f
syntax, and/or upstreaming the special treatment for Function.comp
and Function.flip
, and/or removing this special treatment). Please keep an open and skeptical mind about these changes!
Co-authored-by: leanprover-community-mathlib4-bot <leanprover-community-mathlib4-bot@users.noreply.github.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Mauricio Collares <mauricio@collares.org>
@@ -27,6 +27,9 @@ theorem emod_two_ne_one : ¬n % 2 = 1 ↔ n % 2 = 0 := by
cases' emod_two_eq_zero_or_one n with h h <;> simp [h]
#align int.mod_two_ne_one Int.emod_two_ne_one
+@[simp]
+theorem one_emod_two : (1 : Int) % 2 = 1 := rfl
+
-- `EuclideanDomain.mod_eq_zero` uses (2 ∣ n) as normal form
@[local simp]
theorem emod_two_ne_zero : ¬n % 2 = 0 ↔ n % 2 = 1 := by
@@ -102,6 +105,7 @@ theorem even_add : Even (m + n) ↔ (Even m ↔ Even n) := by
cases' emod_two_eq_zero_or_one m with h₁ h₁ <;>
cases' emod_two_eq_zero_or_one n with h₂ h₂ <;>
simp [even_iff, h₁, h₂, Int.add_emod]
+ rfl
#align int.even_add Int.even_add
theorem even_add' : Even (m + n) ↔ (Odd m ↔ Odd n) := by
@@ -279,8 +283,8 @@ theorem two_mul_ediv_two_of_odd (h : Odd n) : 2 * (n / 2) = n - 1 :=
-- Here are examples of how `parity_simps` can be used with `Int`.
example (m n : ℤ) (h : Even m) : ¬Even (n + 3) ↔ Even (m ^ 2 + m + n) := by
- simp [*, (by decide : ¬2 = 0), parity_simps]
+ simp (config := {decide := true}) [*, (by decide : ¬2 = 0), parity_simps]
-example : ¬Even (25394535 : ℤ) := by simp
+example : ¬Even (25394535 : ℤ) := by decide
end Int
@@ -215,10 +215,10 @@ theorem natAbs_odd : Odd n.natAbs ↔ Odd n := by
rw [odd_iff_not_even, Nat.odd_iff_not_even, natAbs_even]
#align int.nat_abs_odd Int.natAbs_odd
-alias natAbs_even ↔ _ _root_.Even.natAbs
+alias ⟨_, _root_.Even.natAbs⟩ := natAbs_even
#align even.nat_abs Even.natAbs
-alias natAbs_odd ↔ _ _root_.Odd.natAbs
+alias ⟨_, _root_.Odd.natAbs⟩ := natAbs_odd
#align odd.nat_abs Odd.natAbs
-- Porting note: "protected"-attribute not implemented yet.
@@ -27,8 +27,7 @@ theorem emod_two_ne_one : ¬n % 2 = 1 ↔ n % 2 = 0 := by
cases' emod_two_eq_zero_or_one n with h h <;> simp [h]
#align int.mod_two_ne_one Int.emod_two_ne_one
--- Porting note: This comment from mathlib3 refers to a future file, revisit it once ported:
--- euclidean_domain.mod_eq_zero uses (2 ∣ n) as normal form
+-- `EuclideanDomain.mod_eq_zero` uses (2 ∣ n) as normal form
@[local simp]
theorem emod_two_ne_zero : ¬n % 2 = 0 ↔ n % 2 = 1 := by
cases' emod_two_eq_zero_or_one n with h h <;> simp [h]
@@ -278,7 +277,7 @@ theorem two_mul_ediv_two_of_odd (h : Odd n) : 2 * (n / 2) = n - 1 :=
eq_sub_of_add_eq (two_mul_ediv_two_add_one_of_odd h)
#align int.two_mul_div_two_of_odd Int.two_mul_ediv_two_of_odd
--- Here are examples of how `parity_simps` can be used with `int`.
+-- Here are examples of how `parity_simps` can be used with `Int`.
example (m n : ℤ) (h : Even m) : ¬Even (n + 3) ↔ Even (m ^ 2 + m + n) := by
simp [*, (by decide : ¬2 = 0), parity_simps]
@@ -2,15 +2,12 @@
Copyright (c) 2019 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Benjamin Davidson
-
-! This file was ported from Lean 3 source module data.int.parity
-! leanprover-community/mathlib commit e3d9ab8faa9dea8f78155c6c27d62a621f4c152d
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathlib.Data.Nat.Parity
import Mathlib.Tactic.Abel
+#align_import data.int.parity from "leanprover-community/mathlib"@"e3d9ab8faa9dea8f78155c6c27d62a621f4c152d"
+
/-!
# Parity of integers
@@ -164,6 +164,13 @@ theorem even_pow' {n : ℕ} (h : n ≠ 0) : Even (m ^ n) ↔ Even m :=
even_pow.trans <| and_iff_left h
#align int.even_pow' Int.even_pow'
+@[parity_simps]
+theorem odd_pow {n : ℕ} : Odd (m ^ n) ↔ Odd m ∨ n = 0 := by
+ rw [← not_iff_not, ← Int.even_iff_not_odd, not_or, ← Int.even_iff_not_odd, Int.even_pow]
+
+theorem odd_pow' {n : ℕ} (h : n ≠ 0) : Odd (m ^ n) ↔ Odd m :=
+ odd_pow.trans <| or_iff_left h
+
@[parity_simps]
theorem odd_add : Odd (m + n) ↔ (Odd m ↔ Even n) := by
rw [odd_iff_not_even, even_add, not_iff, odd_iff_not_even]
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.
@@ -68,13 +68,8 @@ theorem even_or_odd (n : ℤ) : Even n ∨ Odd n :=
Or.imp_right odd_iff_not_even.2 <| em <| Even n
#align int.even_or_odd Int.even_or_odd
--- Porting note: TODO. I'm struggling that `Even` uses `k + k` while Odd uses `2 * k`,
--- does this proof need golfing?
--- mathlib3 port: `simpa only [← two_mul, exists_or, ← Odd, ← Even] using even_or_odd n`
theorem even_or_odd' (n : ℤ) : ∃ k, n = 2 * k ∨ n = 2 * k + 1 := by
- rw [exists_or]
- convert even_or_odd n
- rw [two_mul]
+ simpa only [two_mul, exists_or, Odd, Even] using even_or_odd n
#align int.even_or_odd' Int.even_or_odd'
theorem even_xor'_odd (n : ℤ) : Xor' (Even n) (Odd n) := by
@@ -192,9 +187,7 @@ theorem odd_sub' : Odd (m - n) ↔ (Odd n ↔ Even m) := by
#align int.odd_sub' Int.odd_sub'
theorem even_mul_succ_self (n : ℤ) : Even (n * (n + 1)) := by
- rw [even_mul]
- convert n.even_or_odd
- simp [parity_simps]
+ simpa [even_mul, parity_simps] using n.even_or_odd
#align int.even_mul_succ_self Int.even_mul_succ_self
@[simp, norm_cast]
@@ -237,12 +230,12 @@ theorem four_dvd_add_or_sub_of_odd {a b : ℤ} (ha : Odd a) (hb : Odd b) :
· right
rw [Int.even_add, ← Int.even_sub] at h
obtain ⟨k, hk⟩ := h
- convert dvd_mul_right 4 k
+ convert dvd_mul_right 4 k using 1
rw [eq_add_of_sub_eq hk, mul_add, add_assoc, add_sub_cancel, ← two_mul, ← mul_assoc]
rfl
· left
obtain ⟨k, hk⟩ := h
- convert dvd_mul_right 4 (k + 1)
+ convert dvd_mul_right 4 (k + 1) using 1
rw [eq_sub_of_add_eq hk, add_right_comm, ← add_sub, mul_add, mul_sub, add_assoc, add_assoc,
sub_add, add_assoc, ← sub_sub (2 * n), sub_self, zero_sub, sub_neg_eq_add, ← mul_assoc,
mul_add]
congr!
and improvement to convert
(#2566)
This introduces a tactic congr!
that is an analogue to mathlib 3's congr'
. It is a more insistent version of congr
that makes use of more congruence lemmas (including user congruence lemmas), propext
, funext
, and Subsingleton
instances. It also has a feature to lift reflexive relations to equalities. Along with funext
, the tactic does intros
, allowing congr!
to get access to function bodies; the introduced variables can be named using rename_i
if needed.
This also modifies convert
to use congr!
rather than congr
, which makes it work more like the mathlib3 version of the tactic.
@@ -74,7 +74,6 @@ theorem even_or_odd (n : ℤ) : Even n ∨ Odd n :=
theorem even_or_odd' (n : ℤ) : ∃ k, n = 2 * k ∨ n = 2 * k + 1 := by
rw [exists_or]
convert even_or_odd n
- funext i
rw [two_mul]
#align int.even_or_odd' Int.even_or_odd'
The unported dependencies are