data.nat.parity
⟷
Mathlib.Data.Nat.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)
@@ -91,8 +91,6 @@ mod_two_add_add_odd_mod_two m odd_one
@[simp] theorem succ_mod_two_add_mod_two (m : ℕ) : (m + 1) % 2 + m % 2 = 1 :=
by rw [add_comm, mod_two_add_succ_mod_two]
-mk_simp_attribute parity_simps "Simp attribute for lemmas about `even`"
-
@[simp] theorem not_even_one : ¬ even 1 :=
by rw even_iff; norm_num
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(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) 2019 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Benjamin Davidson
-/
-import Data.Nat.Modeq
+import Data.Nat.ModEq
import Algebra.Parity
#align_import data.nat.parity from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4"
@@ -246,7 +246,7 @@ theorem Odd.of_mul_right (h : Odd (m * n)) : Odd n :=
if and only if `m` is even and `n` is positive. -/
@[parity_simps]
theorem even_pow : Even (m ^ n) ↔ Even m ∧ n ≠ 0 := by
- induction' n with n ih <;> simp [*, pow_succ', even_mul]; tauto
+ induction' n with n ih <;> simp [*, pow_succ, even_mul]; tauto
#align nat.even_pow Nat.even_pow
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -392,9 +392,9 @@ theorem bit1_mod_bit0 : bit1 n % bit0 m = bit1 (n % m) :=
by
have h₁ := congr_arg bit1 (Nat.div_add_mod n m)
-- `∀ m n : ℕ, bit0 m * n = bit0 (m * n)` seems to be missing...
- rw [bit1_add, bit0_eq_two_mul, ← mul_assoc, ← bit0_eq_two_mul] at h₁
+ rw [bit1_add, bit0_eq_two_mul, ← mul_assoc, ← bit0_eq_two_mul] at h₁
have h₂ := Nat.div_add_mod (bit1 n) (bit0 m)
- rw [bit1_div_bit0] at h₂
+ rw [bit1_div_bit0] at h₂
exact add_left_cancel (h₂.trans h₁.symm)
#align nat.bit1_mod_bit0 Nat.bit1_mod_bit0
-/
@@ -443,14 +443,14 @@ theorem iterate_odd (hf : Involutive f) (hn : Odd n) : f^[n] = f :=
#print Function.Involutive.iterate_eq_self /-
theorem iterate_eq_self (hf : Involutive f) (hne : f ≠ id) : f^[n] = f ↔ Odd n :=
- ⟨fun H => odd_iff_not_even.2 fun hn => hne <| by rwa [hf.iterate_even hn, eq_comm] at H ,
+ ⟨fun H => odd_iff_not_even.2 fun hn => hne <| by rwa [hf.iterate_even hn, eq_comm] at H,
hf.iterate_odd⟩
#align function.involutive.iterate_eq_self Function.Involutive.iterate_eq_self
-/
#print Function.Involutive.iterate_eq_id /-
theorem iterate_eq_id (hf : Involutive f) (hne : f ≠ id) : f^[n] = id ↔ Even n :=
- ⟨fun H => even_iff_not_odd.2 fun hn => hne <| by rwa [hf.iterate_odd hn] at H , hf.iterate_even⟩
+ ⟨fun H => even_iff_not_odd.2 fun hn => hne <| by rwa [hf.iterate_odd hn] at H, hf.iterate_even⟩
#align function.involutive.iterate_eq_id Function.Involutive.iterate_eq_id
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -313,14 +313,14 @@ theorem even_mul_succ_self (n : ℕ) : Even (n * (n + 1)) :=
#align nat.even_mul_succ_self Nat.even_mul_succ_self
-/
-#print Nat.even_mul_self_pred /-
-theorem even_mul_self_pred (n : ℕ) : Even (n * (n - 1)) :=
+#print Nat.even_mul_pred_self /-
+theorem even_mul_pred_self (n : ℕ) : Even (n * (n - 1)) :=
by
cases n
· exact even_zero
· rw [mul_comm]
apply even_mul_succ_self
-#align nat.even_mul_self_pred Nat.even_mul_self_pred
+#align nat.even_mul_self_pred Nat.even_mul_pred_self
-/
#print Nat.two_mul_div_two_of_even /-
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce64cd319bb6b3e82f31c2d38e79080d377be451
@@ -3,8 +3,8 @@ 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.Modeq
-import Mathbin.Algebra.Parity
+import Data.Nat.Modeq
+import Algebra.Parity
#align_import data.nat.parity from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4"
mathlib commit https://github.com/leanprover-community/mathlib/commit/8ea5598db6caeddde6cb734aa179cc2408dbd345
@@ -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.nat.parity
-! leanprover-community/mathlib commit 48fb5b5280e7c81672afc9524185ae994553ebf4
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathbin.Data.Nat.Modeq
import Mathbin.Algebra.Parity
+#align_import data.nat.parity from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4"
+
/-!
# Parity of natural numbers
mathlib commit https://github.com/leanprover-community/mathlib/commit/728ef9dbb281241906f25cbeb30f90d83e0bb451
@@ -4,7 +4,7 @@ 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.nat.parity
-! leanprover-community/mathlib commit a11f9106a169dd302a285019e5165f8ab32ff433
+! leanprover-community/mathlib commit 48fb5b5280e7c81672afc9524185ae994553ebf4
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
@@ -150,10 +150,6 @@ theorem succ_mod_two_add_mod_two (m : ℕ) : (m + 1) % 2 + m % 2 = 1 := by
#align nat.succ_mod_two_add_mod_two Nat.succ_mod_two_add_mod_two
-/
--- PLEASE REPORT THIS TO MATHPORT DEVS, THIS SHOULD NOT HAPPEN.
--- failed to format: unknown constant 'Lean.Meta._root_.Lean.Parser.Command.registerSimpAttr'
-/-- Simp attribute for lemmas about `even` -/ register_simp_attr parity_simps
-
#print Nat.not_even_one /-
@[simp]
theorem not_even_one : ¬Even 1 := by rw [even_iff] <;> norm_num
mathlib commit https://github.com/leanprover-community/mathlib/commit/9fb8964792b4237dac6200193a0d533f1b3f7423
@@ -78,9 +78,11 @@ theorem odd_iff_not_even : Odd n ↔ ¬Even n := by rw [not_even_iff, odd_iff]
#align nat.odd_iff_not_even Nat.odd_iff_not_even
-/
+#print Nat.isCompl_even_odd /-
theorem isCompl_even_odd : IsCompl {n : ℕ | Even n} {n | Odd n} := by
simp only [← Set.compl_setOf, isCompl_compl, odd_iff_not_even]
#align nat.is_compl_even_odd Nat.isCompl_even_odd
+-/
#print Nat.even_or_odd /-
theorem even_or_odd (n : ℕ) : Even n ∨ Odd n :=
@@ -465,10 +467,12 @@ end Function
variable {R : Type _} [Monoid R] [HasDistribNeg R] {n : ℕ}
+#print neg_one_pow_eq_one_iff_even /-
theorem neg_one_pow_eq_one_iff_even (h : (-1 : R) ≠ 1) : (-1 : R) ^ n = 1 ↔ Even n :=
⟨fun h' => of_not_not fun hn => h <| (Odd.neg_one_pow <| odd_iff_not_even.mpr hn).symm.trans h',
Even.neg_one_pow⟩
#align neg_one_pow_eq_one_iff_even neg_one_pow_eq_one_iff_even
+-/
#print Odd.mod_even_iff /-
/-- If `a` is even, then `n` is odd iff `n % a` is odd. -/
mathlib commit https://github.com/leanprover-community/mathlib/commit/31c24aa72e7b3e5ed97a8412470e904f82b81004
@@ -148,11 +148,8 @@ theorem succ_mod_two_add_mod_two (m : ℕ) : (m + 1) % 2 + m % 2 = 1 := by
#align nat.succ_mod_two_add_mod_two Nat.succ_mod_two_add_mod_two
-/
-/- failed to parenthesize: unknown constant 'Lean.Meta._root_.Lean.Parser.Command.registerSimpAttr'
-[PrettyPrinter.parenthesize.input] (Lean.Meta._root_.Lean.Parser.Command.registerSimpAttr
- [(Command.docComment "/--" "Simp attribute for lemmas about `even` -/")]
- "register_simp_attr"
- `parity_simps)-/-- failed to format: unknown constant 'Lean.Meta._root_.Lean.Parser.Command.registerSimpAttr'
+-- PLEASE REPORT THIS TO MATHPORT DEVS, THIS SHOULD NOT HAPPEN.
+-- failed to format: unknown constant 'Lean.Meta._root_.Lean.Parser.Command.registerSimpAttr'
/-- Simp attribute for lemmas about `even` -/ register_simp_attr parity_simps
#print Nat.not_even_one /-
mathlib commit https://github.com/leanprover-community/mathlib/commit/5f25c089cb34db4db112556f23c50d12da81b297
@@ -78,7 +78,7 @@ theorem odd_iff_not_even : Odd n ↔ ¬Even n := by rw [not_even_iff, odd_iff]
#align nat.odd_iff_not_even Nat.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 only [← Set.compl_setOf, isCompl_compl, odd_iff_not_even]
#align nat.is_compl_even_odd Nat.isCompl_even_odd
mathlib commit https://github.com/leanprover-community/mathlib/commit/cca40788df1b8755d5baf17ab2f27dacc2e17acb
@@ -52,7 +52,7 @@ theorem even_iff : Even n ↔ n % 2 = 0 :=
#print Nat.odd_iff /-
theorem odd_iff : Odd n ↔ n % 2 = 1 :=
- ⟨fun ⟨m, hm⟩ => by norm_num [hm, add_mod] , fun h =>
+ ⟨fun ⟨m, hm⟩ => by norm_num [hm, add_mod], fun h =>
⟨n / 2, (mod_add_div n 2).symm.trans (by rw [h, add_comm])⟩⟩
#align nat.odd_iff Nat.odd_iff
-/
@@ -400,9 +400,9 @@ theorem bit1_mod_bit0 : bit1 n % bit0 m = bit1 (n % m) :=
by
have h₁ := congr_arg bit1 (Nat.div_add_mod n m)
-- `∀ m n : ℕ, bit0 m * n = bit0 (m * n)` seems to be missing...
- rw [bit1_add, bit0_eq_two_mul, ← mul_assoc, ← bit0_eq_two_mul] at h₁
+ rw [bit1_add, bit0_eq_two_mul, ← mul_assoc, ← bit0_eq_two_mul] at h₁
have h₂ := Nat.div_add_mod (bit1 n) (bit0 m)
- rw [bit1_div_bit0] at h₂
+ rw [bit1_div_bit0] at h₂
exact add_left_cancel (h₂.trans h₁.symm)
#align nat.bit1_mod_bit0 Nat.bit1_mod_bit0
-/
@@ -451,14 +451,14 @@ theorem iterate_odd (hf : Involutive f) (hn : Odd n) : f^[n] = f :=
#print Function.Involutive.iterate_eq_self /-
theorem iterate_eq_self (hf : Involutive f) (hne : f ≠ id) : f^[n] = f ↔ Odd n :=
- ⟨fun H => odd_iff_not_even.2 fun hn => hne <| by rwa [hf.iterate_even hn, eq_comm] at H,
+ ⟨fun H => odd_iff_not_even.2 fun hn => hne <| by rwa [hf.iterate_even hn, eq_comm] at H ,
hf.iterate_odd⟩
#align function.involutive.iterate_eq_self Function.Involutive.iterate_eq_self
-/
#print Function.Involutive.iterate_eq_id /-
theorem iterate_eq_id (hf : Involutive f) (hne : f ≠ id) : f^[n] = id ↔ Even n :=
- ⟨fun H => even_iff_not_odd.2 fun hn => hne <| by rwa [hf.iterate_odd hn] at H, hf.iterate_even⟩
+ ⟨fun H => even_iff_not_odd.2 fun hn => hne <| by rwa [hf.iterate_odd hn] at H , hf.iterate_even⟩
#align function.involutive.iterate_eq_id Function.Involutive.iterate_eq_id
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -78,12 +78,6 @@ theorem odd_iff_not_even : Odd n ↔ ¬Even n := by rw [not_even_iff, odd_iff]
#align nat.odd_iff_not_even Nat.odd_iff_not_even
-/
-/- warning: nat.is_compl_even_odd -> Nat.isCompl_even_odd is a dubious translation:
-lean 3 declaration is
- IsCompl.{0} (Set.{0} Nat) (SemilatticeInf.toPartialOrder.{0} (Set.{0} Nat) (Lattice.toSemilatticeInf.{0} (Set.{0} Nat) (GeneralizedCoheytingAlgebra.toLattice.{0} (Set.{0} Nat) (GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra.{0} (Set.{0} Nat) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{0} (Set.{0} Nat) (Set.booleanAlgebra.{0} Nat)))))) (BooleanAlgebra.toBoundedOrder.{0} (Set.{0} Nat) (Set.booleanAlgebra.{0} Nat)) (setOf.{0} Nat (fun (n : Nat) => Even.{0} Nat Nat.hasAdd n)) (setOf.{0} Nat (fun (n : Nat) => Odd.{0} Nat Nat.semiring n))
-but is expected to have type
- IsCompl.{0} (Set.{0} Nat) (SemilatticeInf.toPartialOrder.{0} (Set.{0} Nat) (Lattice.toSemilatticeInf.{0} (Set.{0} Nat) (GeneralizedCoheytingAlgebra.toLattice.{0} (Set.{0} Nat) (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{0} (Set.{0} Nat) (BiheytingAlgebra.toCoheytingAlgebra.{0} (Set.{0} Nat) (BooleanAlgebra.toBiheytingAlgebra.{0} (Set.{0} Nat) (Set.instBooleanAlgebraSet.{0} Nat))))))) (BooleanAlgebra.toBoundedOrder.{0} (Set.{0} Nat) (Set.instBooleanAlgebraSet.{0} Nat)) (setOf.{0} Nat (fun (n : Nat) => Even.{0} Nat instAddNat n)) (setOf.{0} Nat (fun (n : Nat) => Odd.{0} Nat Nat.semiring n))
-Case conversion may be inaccurate. Consider using '#align nat.is_compl_even_odd Nat.isCompl_even_oddₓ'. -/
theorem isCompl_even_odd : IsCompl { n : ℕ | Even n } { n | Odd n } := by
simp only [← Set.compl_setOf, isCompl_compl, odd_iff_not_even]
#align nat.is_compl_even_odd Nat.isCompl_even_odd
@@ -474,12 +468,6 @@ end Function
variable {R : Type _} [Monoid R] [HasDistribNeg R] {n : ℕ}
-/- warning: neg_one_pow_eq_one_iff_even -> neg_one_pow_eq_one_iff_even is a dubious translation:
-lean 3 declaration is
- forall {R : Type.{u1}} [_inst_1 : Monoid.{u1} R] [_inst_2 : HasDistribNeg.{u1} R (MulOneClass.toHasMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1))] {n : Nat}, (Ne.{succ u1} R (Neg.neg.{u1} R (InvolutiveNeg.toHasNeg.{u1} R (HasDistribNeg.toHasInvolutiveNeg.{u1} R (MulOneClass.toHasMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)) _inst_2)) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (MulOneClass.toHasOne.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)))))) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (MulOneClass.toHasOne.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)))))) -> (Iff (Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R _inst_1)) (Neg.neg.{u1} R (InvolutiveNeg.toHasNeg.{u1} R (HasDistribNeg.toHasInvolutiveNeg.{u1} R (MulOneClass.toHasMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)) _inst_2)) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (MulOneClass.toHasOne.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)))))) n) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (MulOneClass.toHasOne.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)))))) (Even.{0} Nat Nat.hasAdd n))
-but is expected to have type
- forall {R : Type.{u1}} [_inst_1 : Monoid.{u1} R] [_inst_2 : HasDistribNeg.{u1} R (MulOneClass.toMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1))] {n : Nat}, (Ne.{succ u1} R (Neg.neg.{u1} R (InvolutiveNeg.toNeg.{u1} R (HasDistribNeg.toInvolutiveNeg.{u1} R (MulOneClass.toMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)) _inst_2)) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Monoid.toOne.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Monoid.toOne.{u1} R _inst_1)))) -> (Iff (Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R _inst_1)) (Neg.neg.{u1} R (InvolutiveNeg.toNeg.{u1} R (HasDistribNeg.toInvolutiveNeg.{u1} R (MulOneClass.toMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)) _inst_2)) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Monoid.toOne.{u1} R _inst_1)))) n) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Monoid.toOne.{u1} R _inst_1)))) (Even.{0} Nat instAddNat n))
-Case conversion may be inaccurate. Consider using '#align neg_one_pow_eq_one_iff_even neg_one_pow_eq_one_iff_evenₓ'. -/
theorem neg_one_pow_eq_one_iff_even (h : (-1 : R) ≠ 1) : (-1 : R) ^ n = 1 ↔ Even n :=
⟨fun h' => of_not_not fun hn => h <| (Odd.neg_one_pow <| odd_iff_not_even.mpr hn).symm.trans h',
Even.neg_one_pow⟩
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -259,10 +259,8 @@ theorem Odd.of_mul_right (h : Odd (m * n)) : Odd n :=
/-- If `m` and `n` are natural numbers, then the natural number `m^n` is even
if and only if `m` is even and `n` is positive. -/
@[parity_simps]
-theorem even_pow : Even (m ^ n) ↔ Even m ∧ n ≠ 0 :=
- by
- induction' n with n ih <;> simp [*, pow_succ', even_mul]
- tauto
+theorem even_pow : Even (m ^ n) ↔ Even m ∧ n ≠ 0 := by
+ induction' n with n ih <;> simp [*, pow_succ', even_mul]; tauto
#align nat.even_pow Nat.even_pow
-/
@@ -352,28 +350,20 @@ theorem div_two_mul_two_of_even : Even n → n / 2 * 2 = n := fun h =>
-/
#print Nat.two_mul_div_two_add_one_of_odd /-
-theorem two_mul_div_two_add_one_of_odd (h : Odd n) : 2 * (n / 2) + 1 = n :=
- by
- rw [mul_comm]
- convert Nat.div_add_mod' n 2
- rw [odd_iff.mp h]
+theorem two_mul_div_two_add_one_of_odd (h : Odd n) : 2 * (n / 2) + 1 = n := by rw [mul_comm];
+ convert Nat.div_add_mod' n 2; rw [odd_iff.mp h]
#align nat.two_mul_div_two_add_one_of_odd Nat.two_mul_div_two_add_one_of_odd
-/
#print Nat.div_two_mul_two_add_one_of_odd /-
-theorem div_two_mul_two_add_one_of_odd (h : Odd n) : n / 2 * 2 + 1 = n :=
- by
- convert Nat.div_add_mod' n 2
- rw [odd_iff.mp h]
+theorem div_two_mul_two_add_one_of_odd (h : Odd n) : n / 2 * 2 + 1 = n := by
+ convert Nat.div_add_mod' n 2; rw [odd_iff.mp h]
#align nat.div_two_mul_two_add_one_of_odd Nat.div_two_mul_two_add_one_of_odd
-/
#print Nat.one_add_div_two_mul_two_of_odd /-
-theorem one_add_div_two_mul_two_of_odd (h : Odd n) : 1 + n / 2 * 2 = n :=
- by
- rw [add_comm]
- convert Nat.div_add_mod' n 2
- rw [odd_iff.mp h]
+theorem one_add_div_two_mul_two_of_odd (h : Odd n) : 1 + n / 2 * 2 = n := by rw [add_comm];
+ convert Nat.div_add_mod' n 2; rw [odd_iff.mp h]
#align nat.one_add_div_two_mul_two_of_odd Nat.one_add_div_two_mul_two_of_odd
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/bd9851ca476957ea4549eb19b40e7b5ade9428cc
Occasionally, remove a "deprecated by" or "deprecated since", to fit the line length.
This is desirable (to me) because
@@ -230,8 +230,7 @@ theorem even_mul_pred_self : ∀ n : ℕ, Even (n * (n - 1))
| (n + 1) => mul_comm (n + 1 - 1) (n + 1) ▸ even_mul_succ_self n
#align nat.even_mul_self_pred Nat.even_mul_pred_self
-@[deprecated] -- 2024-01-20
-alias even_mul_self_pred := even_mul_pred_self
+@[deprecated] alias even_mul_self_pred := even_mul_pred_self -- 2024-01-20
theorem two_mul_div_two_of_even : Even n → 2 * (n / 2) = n := fun h =>
Nat.mul_div_cancel_left' (even_iff_two_dvd.mp h)
Subsingleton,Nontrivial
off of Data.Set.Basic
(#11832)
Moves definition of and lemmas related to Set.Subsingleton
and Set.Nontrivial
to a new file, so that Basic
can be shorter.
@@ -6,7 +6,7 @@ Authors: Jeremy Avigad, Benjamin Davidson
import Mathlib.Algebra.Parity
import Mathlib.Data.Nat.Bits
import Mathlib.Data.Nat.ModEq
-import Mathlib.Data.Set.Basic
+import Mathlib.Data.Set.Subsingleton
#align_import data.nat.parity from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4"
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.
@@ -42,6 +42,11 @@ theorem even_iff : Even n ↔ n % 2 = 0 :=
instance : DecidablePred (Even : ℕ → Prop) := fun _ => decidable_of_iff _ even_iff.symm
+/-- `IsSquare` can be decided on `ℕ` by checking against the square root. -/
+instance : DecidablePred (IsSquare : ℕ → Prop) :=
+ fun m ↦ decidable_of_iff' (Nat.sqrt m * Nat.sqrt m = m) <| by
+ simp_rw [← Nat.exists_mul_self m, IsSquare, eq_comm]
+
theorem odd_iff : Odd n ↔ n % 2 = 1 :=
⟨fun ⟨m, hm⟩ => by norm_num [hm, add_mod],
fun h => ⟨n / 2, (mod_add_div n 2).symm.trans (by rw [h, add_comm])⟩⟩
@@ -156,6 +156,8 @@ theorem Odd.sub_odd (hm : Odd m) (hn : Odd n) : Even (m - n) :=
simp only [tsub_eq_zero_iff_le.mpr h, even_zero]
#align nat.odd.sub_odd Nat.Odd.sub_odd
+alias _root_.Odd.tsub_odd := Nat.Odd.sub_odd
+
@[parity_simps]
theorem even_mul : Even (m * n) ↔ Even m ∨ Even n := by
cases' mod_two_eq_zero_or_one m with h₁ h₁ <;> cases' mod_two_eq_zero_or_one n with h₂ h₂ <;>
Data.Set.Basic
from scripts/noshake.json
.example
s only,
move these example
s to a new test file.Order.Filter.Basic
dependency on Control.Traversable.Instances
,
as the relevant parts were moved to Order.Filter.ListTraverse
.lake exe shake --fix
.@@ -6,6 +6,7 @@ Authors: Jeremy Avigad, Benjamin Davidson
import Mathlib.Algebra.Parity
import Mathlib.Data.Nat.Bits
import Mathlib.Data.Nat.ModEq
+import Mathlib.Data.Set.Basic
#align_import data.nat.parity from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4"
@@ -339,13 +339,44 @@ end Involutive
end Function
-variable {R : Type*} [Monoid R] [HasDistribNeg R] {n : ℕ}
-
-theorem neg_one_pow_eq_one_iff_even (h : (-1 : R) ≠ 1) : (-1 : R) ^ n = 1 ↔ Even n :=
+theorem neg_one_pow_eq_one_iff_even {R : Type*} [Monoid R] [HasDistribNeg R] {n : ℕ}
+ (h : (-1 : R) ≠ 1) : (-1 : R) ^ n = 1 ↔ Even n :=
⟨fun h' => of_not_not fun hn => h <| (Odd.neg_one_pow <| odd_iff_not_even.mpr hn).symm.trans h',
Even.neg_one_pow⟩
#align neg_one_pow_eq_one_iff_even neg_one_pow_eq_one_iff_even
+section LinearOrderedRing
+
+variable {R : Type*} [LinearOrderedRing R] {a b : R} {n : ℕ}
+
+theorem pow_eq_pow_iff_of_ne_zero (hn : n ≠ 0) : a ^ n = b ^ n ↔ a = b ∨ a = -b ∧ Even n :=
+ match n.even_xor_odd with
+ | .inl hne => by simp only [*, and_true, ← abs_eq_abs,
+ ← pow_left_inj (abs_nonneg a) (abs_nonneg b) hn, hne.1.pow_abs]
+ | .inr hn => by simp [hn, (hn.1.strictMono_pow (R := R)).injective.eq_iff]
+
+theorem pow_eq_pow_iff_cases : a ^ n = b ^ n ↔ n = 0 ∨ a = b ∨ a = -b ∧ Even n := by
+ rcases eq_or_ne n 0 with rfl | hn <;> simp [pow_eq_pow_iff_of_ne_zero, *]
+
+theorem pow_eq_one_iff_of_ne_zero (hn : n ≠ 0) : a ^ n = 1 ↔ a = 1 ∨ a = -1 ∧ Even n := by
+ simp [← pow_eq_pow_iff_of_ne_zero hn]
+
+theorem pow_eq_one_iff_cases : a ^ n = 1 ↔ n = 0 ∨ a = 1 ∨ a = -1 ∧ Even n := by
+ simp [← pow_eq_pow_iff_cases]
+
+theorem pow_eq_neg_pow_iff (hb : b ≠ 0) : a ^ n = -b ^ n ↔ a = -b ∧ Odd n :=
+ match n.even_or_odd with
+ | .inl he =>
+ suffices a ^ n > -b ^ n by simpa [he] using this.ne'
+ lt_of_lt_of_le (by simp [he.pow_pos hb]) (he.pow_nonneg _)
+ | .inr ho => by
+ simp only [ho, and_true, ← ho.neg_pow, (ho.strictMono_pow (R := R)).injective.eq_iff]
+
+theorem pow_eq_neg_one_iff : a ^ n = -1 ↔ a = -1 ∧ Odd n := by
+ simpa using pow_eq_neg_pow_iff (R := R) one_ne_zero
+
+end LinearOrderedRing
+
/-- If `a` is even, then `n` is odd iff `n % a` is odd. -/
theorem Odd.mod_even_iff {n a : ℕ} (ha : Even a) : Odd (n % a) ↔ Odd n :=
((even_sub' <| mod_le n a).mp <|
Also rename Nat.even_mul_self_pred
for consistency with Nat.even_mul_succ_self
.
@@ -217,10 +217,13 @@ theorem even_mul_succ_self (n : ℕ) : Even (n * (n + 1)) := by
exact em _
#align nat.even_mul_succ_self Nat.even_mul_succ_self
-theorem even_mul_self_pred : ∀ n : ℕ, Even (n * (n - 1))
+theorem even_mul_pred_self : ∀ n : ℕ, Even (n * (n - 1))
| 0 => even_zero
| (n + 1) => mul_comm (n + 1 - 1) (n + 1) ▸ even_mul_succ_self n
-#align nat.even_mul_self_pred Nat.even_mul_self_pred
+#align nat.even_mul_self_pred Nat.even_mul_pred_self
+
+@[deprecated] -- 2024-01-20
+alias even_mul_self_pred := even_mul_pred_self
theorem two_mul_div_two_of_even : Even n → 2 * (n / 2) = n := fun h =>
Nat.mul_div_cancel_left' (even_iff_two_dvd.mp h)
Function.left_id
and Function.comp.left_id
into Function.id_comp
.Function.right_id
and Function.comp.right_id
into Function.comp_id
.Function.comp_const_right
and Function.comp_const
into Function.comp_const
, use explicit arguments.Function.const_comp
to Mathlib.Init.Function
, use explicit arguments.@@ -305,7 +305,7 @@ theorem iterate_bit0 (hf : Involutive f) (n : ℕ) : f^[bit0 n] = id := by
#align function.involutive.iterate_bit0 Function.Involutive.iterate_bit0
theorem iterate_bit1 (hf : Involutive f) (n : ℕ) : f^[bit1 n] = f := by
- rw [bit1, ← succ_eq_add_one, iterate_succ, hf.iterate_bit0, comp.left_id]
+ rw [bit1, ← succ_eq_add_one, iterate_succ, hf.iterate_bit0, id_comp]
#align function.involutive.iterate_bit1 Function.Involutive.iterate_bit1
end
@@ -320,7 +320,7 @@ theorem iterate_even (hf : Involutive f) (hn : Even n) : f^[n] = id := by
theorem iterate_odd (hf : Involutive f) (hn : Odd n) : f^[n] = f := by
rcases hn with ⟨m, rfl⟩
- rw [iterate_add, hf.iterate_two_mul, comp.left_id, iterate_one]
+ rw [iterate_add, hf.iterate_two_mul, id_comp, iterate_one]
#align function.involutive.iterate_odd Function.Involutive.iterate_odd
theorem iterate_eq_self (hf : Involutive f) (hne : f ≠ id) : f^[n] = f ↔ Odd n :=
Nat
file (#9551)
Data.Nat.Basic
is currently made of two things:
I need the first ones earlier in the algebraic order hierarchy, hence the split.
@@ -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.ModEq
import Mathlib.Algebra.Parity
+import Mathlib.Data.Nat.Bits
+import Mathlib.Data.Nat.ModEq
#align_import data.nat.parity from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4"
@@ -4,7 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Benjamin Davidson
-/
import Mathlib.Data.Nat.ModEq
-import Mathlib.Data.Nat.Prime
import Mathlib.Algebra.Parity
#align_import data.nat.parity from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4"
@@ -305,7 +305,7 @@ theorem iterate_bit0 (hf : Involutive f) (n : ℕ) : f^[bit0 n] = id := by
#align function.involutive.iterate_bit0 Function.Involutive.iterate_bit0
theorem iterate_bit1 (hf : Involutive f) (n : ℕ) : f^[bit1 n] = f := by
- rw [bit1, ←succ_eq_add_one, iterate_succ, hf.iterate_bit0, comp.left_id]
+ rw [bit1, ← succ_eq_add_one, iterate_succ, hf.iterate_bit0, comp.left_id]
#align function.involutive.iterate_bit1 Function.Involutive.iterate_bit1
end
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>
@@ -284,9 +284,8 @@ end
example (m n : ℕ) (h : Even m) : ¬Even (n + 3) ↔ Even (m ^ 2 + m + n) := by
simp [*, two_ne_zero, parity_simps]
-/- Porting note: the `simp` lemmas about `bit*` no longer apply, but `simp` in Lean 4 currently
-simplifies decidable propositions. This may change in the future. -/
-example : ¬Even 25394535 := by simp only
+/- Porting note: the `simp` lemmas about `bit*` no longer apply. -/
+example : ¬Even 25394535 := by decide
end Nat
pathGraph
and prove its chromatic number is 2 (#8166)
Define a bicoloring for pathGraph
and prove that when 2 ≤ n
its chromatic number is 2. Creates a ConcreteColorings module to hold such colorings of concrete graphs.
@@ -122,6 +122,12 @@ theorem even_add' : Even (m + n) ↔ (Odd m ↔ Odd n) := by
theorem even_add_one : Even (n + 1) ↔ ¬Even n := by simp [even_add]
#align nat.even_add_one Nat.even_add_one
+theorem succ_mod_two_eq_zero_iff {m : ℕ} : (m + 1) % 2 = 0 ↔ m % 2 = 1 := by
+ simp [← Nat.even_iff, ← Nat.not_even_iff, parity_simps]
+
+theorem succ_mod_two_eq_one_iff {m : ℕ} : (m + 1) % 2 = 1 ↔ m % 2 = 0 := by
+ simp [← Nat.even_iff, ← Nat.not_even_iff, parity_simps]
+
set_option linter.deprecated false in
@[simp]
theorem not_even_bit1 (n : ℕ) : ¬Even (bit1 n) := by simp [bit1, parity_simps]
norm_num
was passing the wrong syntax node to elabSimpArgs
when elaborating, which essentially had the effect of ignoring all arguments it was passed, i.e. norm_num [add_comm]
would not try to commute addition in the simp step.
The fix itself is very simple (though not obvious to debug!), probably using TSyntax more would help avoid such issues in future.
Due to this bug many norm_num [blah]
became rw [blah]; norm_num
or similar, sometimes with porting notes, sometimes not, we fix these porting notes and other regressions during the port also.
Interestingly cancel_denoms
uses norm_num [<- mul_assoc]
internally, so cancel_denoms
also got stronger with this change.
@@ -42,7 +42,7 @@ theorem even_iff : Even n ↔ n % 2 = 0 :=
instance : DecidablePred (Even : ℕ → Prop) := fun _ => decidable_of_iff _ even_iff.symm
theorem odd_iff : Odd n ↔ n % 2 = 1 :=
- ⟨fun ⟨m, hm⟩ => by rw [hm, add_mod, mul_mod_right]; rfl,
+ ⟨fun ⟨m, hm⟩ => by norm_num [hm, add_mod],
fun h => ⟨n / 2, (mod_add_div n 2).symm.trans (by rw [h, add_comm])⟩⟩
#align nat.odd_iff Nat.odd_iff
Type _
and Sort _
(#6499)
We remove all possible occurences of Type _
and Sort _
in favor of Type*
and Sort*
.
This has nice performance benefits.
@@ -290,7 +290,7 @@ namespace Function
namespace Involutive
-variable {α : Type _} {f : α → α} {n : ℕ}
+variable {α : Type*} {f : α → α} {n : ℕ}
set_option linter.deprecated false in
section
@@ -331,7 +331,7 @@ end Involutive
end Function
-variable {R : Type _} [Monoid R] [HasDistribNeg R] {n : ℕ}
+variable {R : Type*} [Monoid R] [HasDistribNeg R] {n : ℕ}
theorem neg_one_pow_eq_one_iff_even (h : (-1 : R) ≠ 1) : (-1 : R) ^ n = 1 ↔ Even n :=
⟨fun h' => of_not_not fun hn => h <| (Odd.neg_one_pow <| odd_iff_not_even.mpr hn).symm.trans h',
@@ -2,16 +2,13 @@
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.nat.parity
-! leanprover-community/mathlib commit 48fb5b5280e7c81672afc9524185ae994553ebf4
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathlib.Data.Nat.ModEq
import Mathlib.Data.Nat.Prime
import Mathlib.Algebra.Parity
+#align_import data.nat.parity from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4"
+
/-!
# Parity of natural numbers
register_simp_attr
s to 1 file (#5681)
There are slight differences between mathlib3
and mathlib4
(different set of attributes, different lemmas are in core/std), so I redid the same refactor instead of forward-porting changes.
mathlib3 PR: leanprover-community/mathlib#19223
@@ -4,7 +4,7 @@ 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.nat.parity
-! leanprover-community/mathlib commit 8631e2d5ea77f6c13054d9151d82b83069680cb1
+! leanprover-community/mathlib commit 48fb5b5280e7c81672afc9524185ae994553ebf4
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
@@ -64,6 +64,9 @@ 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 nat.odd_iff_not_even Nat.odd_iff_not_even
+theorem _root_.Odd.not_two_dvd_nat (h : Odd n) : ¬(2 ∣ n) := by
+ rwa [← even_iff_two_dvd, ← odd_iff_not_even]
+
theorem isCompl_even_odd : IsCompl { n : ℕ | Even n } { n | Odd n } := by
simp only [← Set.compl_setOf, isCompl_compl, odd_iff_not_even]
#align nat.is_compl_even_odd Nat.isCompl_even_odd
by
s! (#3825)
This PR puts, with one exception, every single remaining by
that lies all by itself on its own line to the previous line, thus matching the current behaviour of start-port.sh
. The exception is when the by
begins the second or later argument to a tuple or anonymous constructor; see https://github.com/leanprover-community/mathlib4/pull/3825#discussion_r1186702599.
Essentially this is s/\n *by$/ by/g
, but with manual editing to satisfy the linter's max-100-char-line requirement. The Python style linter is also modified to catch these "isolated by
s".
@@ -263,8 +263,7 @@ theorem bit0_mod_bit0 : bit0 n % bit0 m = bit0 (n % m) := by
#align nat.bit0_mod_bit0 Nat.bit0_mod_bit0
@[simp]
-theorem bit1_mod_bit0 : bit1 n % bit0 m = bit1 (n % m) :=
- by
+theorem bit1_mod_bit0 : bit1 n % bit0 m = bit1 (n % m) := by
have h₁ := congr_arg bit1 (Nat.div_add_mod n m)
-- `∀ m n : ℕ, bit0 m * n = bit0 (m * n)` seems to be missing...
rw [bit1_add, bit0_eq_two_mul, ← mul_assoc, ← bit0_eq_two_mul] at h₁
This PR fixes two things:
align
statements for definitions and theorems and instances that are separated by two newlines from the relevant declaration (s/\n\n#align/\n#align
). This is often seen in the mathport output after ending calc
blocks.#align
statements. (This was needed for a script I wrote for #3630.)@@ -317,7 +317,6 @@ theorem iterate_even (hf : Involutive f) (hn : Even n) : f^[n] = id := by
theorem iterate_odd (hf : Involutive f) (hn : Odd n) : f^[n] = f := by
rcases hn with ⟨m, rfl⟩
rw [iterate_add, hf.iterate_two_mul, comp.left_id, iterate_one]
-
#align function.involutive.iterate_odd Function.Involutive.iterate_odd
theorem iterate_eq_self (hf : Involutive f) (hne : f ≠ id) : f^[n] = f ↔ Odd n :=
@@ -73,7 +73,7 @@ theorem even_xor_odd (n : ℕ) : Xor' (Even n) (Odd n) := by
#align nat.even_xor_odd Nat.even_xor_odd
theorem even_or_odd (n : ℕ) : Even n ∨ Odd n :=
- xor.or (even_xor_odd n)
+ (even_xor_odd n).or
#align nat.even_or_odd Nat.even_or_odd
theorem even_or_odd' (n : ℕ) : ∃ k, n = 2 * k ∨ n = 2 * k + 1 := by
Backported in leanprover-community/mathlib#18221.
Co-authored-by: Ruben Van de Velde <65514131+Ruben-VandeVelde@users.noreply.github.com>
The unported dependencies are