imo.imo2005_q4
⟷
Archive.Imo.Imo2005Q4
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)
(last sync)
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -51,7 +51,7 @@ theorem find_specified_factor {p : ℕ} (hp : Nat.Prime p) (hp' : IsCoprime (6 :
have H : (6 : ℤ) * a (p - 2) ≡ 0 [ZMOD p]
calc
(6 : ℤ) * a (p - 2) = 3 * 2 ^ (p - 1) + 2 * 3 ^ (p - 1) + 6 ^ (p - 1) - 6 := by
- simp only [a, mul_add, mul_sub, hp_sub_one, pow_succ]; ring
+ simp only [a, mul_add, mul_sub, hp_sub_one, pow_succ']; ring
_ ≡ 3 * 1 + 2 * 1 + 1 - 6 [ZMOD p] :=-- At this step we use Fermat's little theorem
by
apply_rules [Int.ModEq.sub_right, Int.ModEq.add, Int.ModEq.mul_left,
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -99,7 +99,7 @@ theorem imo2005_q4 {k : ℕ} (hk : 0 < k) : (∀ n : ℕ, 1 ≤ n → IsCoprime
-- So `3 ≤ p`
have hp₃ : 3 ≤ p :=
by
- have : 2 ≠ p := by rwa [Nat.coprime_primes Nat.prime_two hp] at hp₂
+ have : 2 ≠ p := by rwa [Nat.coprime_primes Nat.prime_two hp] at hp₂
apply Nat.lt_of_le_of_ne hp.two_le this
-- Testing the special property of `k` for the `p - 2`th term of the sequence, we see that `p` is
-- coprime to `a (p - 2)`.
@@ -107,7 +107,7 @@ theorem imo2005_q4 {k : ℕ} (hk : 0 < k) : (∀ n : ℕ, 1 ≤ n → IsCoprime
by
refine' ((h (p - 2) _).of_isCoprime_of_dvd_right (int.coe_nat_dvd.mpr k.min_fac_dvd)).symm
exact le_tsub_of_add_le_right hp₃
- rw [(nat.prime_iff_prime_int.mp hp).coprime_iff_not_dvd] at this
+ rw [(nat.prime_iff_prime_int.mp hp).coprime_iff_not_dvd] at this
-- But also, by our previous lemma, `p` divides `a (p - 2)`.
have : ↑p ∣ a (p - 2) := find_specified_factor hp hp₆
-- Contradiction!
mathlib commit https://github.com/leanprover-community/mathlib/commit/b1abe23ae96fef89ad30d9f4362c307f72a55010
@@ -100,7 +100,7 @@ theorem imo2005_q4 {k : ℕ} (hk : 0 < k) : (∀ n : ℕ, 1 ≤ n → IsCoprime
have hp₃ : 3 ≤ p :=
by
have : 2 ≠ p := by rwa [Nat.coprime_primes Nat.prime_two hp] at hp₂
- apply Nat.lt_of_le_and_ne hp.two_le this
+ apply Nat.lt_of_le_of_ne hp.two_le this
-- Testing the special property of `k` for the `p - 2`th term of the sequence, we see that `p` is
-- coprime to `a (p - 2)`.
have : IsCoprime (↑p) (a (p - 2)) :=
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce64cd319bb6b3e82f31c2d38e79080d377be451
@@ -3,7 +3,7 @@ Copyright (c) 2021 Heather Macbeth. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Heather Macbeth
-/
-import Mathbin.FieldTheory.Finite.Basic
+import FieldTheory.Finite.Basic
#align_import imo.imo2005_q4 from "leanprover-community/mathlib"@"08b081ea92d80e3a41f899eea36ef6d56e0f1db0"
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce64cd319bb6b3e82f31c2d38e79080d377be451
@@ -89,7 +89,7 @@ theorem imo2005_q4 {k : ℕ} (hk : 0 < k) : (∀ n : ℕ, 1 ≤ n → IsCoprime
exact (id (h 2 one_le_two) : IsCoprime (8 * 6 : ℤ) k).of_mul_left_right
-- In particular `p` is coprime to `2` (we record the `nat.coprime` version since that's what's
-- needed later).
- have hp₂ : Nat.coprime 2 p := by
+ have hp₂ : Nat.Coprime 2 p := by
rw [← Nat.isCoprime_iff_coprime]
exact (id hp₆ : IsCoprime (3 * 2 : ℤ) p).of_mul_left_right
-- Suppose for the sake of contradiction that `k ≠ 1`. Then `p` is genuinely a prime factor of
mathlib commit https://github.com/leanprover-community/mathlib/commit/8ea5598db6caeddde6cb734aa179cc2408dbd345
@@ -2,14 +2,11 @@
Copyright (c) 2021 Heather Macbeth. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Heather Macbeth
-
-! This file was ported from Lean 3 source module imo.imo2005_q4
-! leanprover-community/mathlib commit 08b081ea92d80e3a41f899eea36ef6d56e0f1db0
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathbin.FieldTheory.Finite.Basic
+#align_import imo.imo2005_q4 from "leanprover-community/mathlib"@"08b081ea92d80e3a41f899eea36ef6d56e0f1db0"
+
/-!
# IMO 2005 Q4
mathlib commit https://github.com/leanprover-community/mathlib/commit/bf2428c9486c407ca38b5b3fb10b87dad0bc99fa
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Heather Macbeth
! This file was ported from Lean 3 source module imo.imo2005_q4
-! leanprover-community/mathlib commit 308826471968962c6b59c7ff82a22757386603e3
+! leanprover-community/mathlib commit 08b081ea92d80e3a41f899eea36ef6d56e0f1db0
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
@@ -13,6 +13,9 @@ import Mathbin.FieldTheory.Finite.Basic
/-!
# IMO 2005 Q4
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
Problem: Determine all positive integers relatively prime to all the terms of the infinite sequence
`a n = 2 ^ n + 3 ^ n + 6 ^ n - 1`, for `n ≥ 1`.
mathlib commit https://github.com/leanprover-community/mathlib/commit/7e5137f579de09a059a5ce98f364a04e221aabf0
@@ -57,7 +57,6 @@ theorem find_specified_factor {p : ℕ} (hp : Nat.Prime p) (hp' : IsCoprime (6 :
apply_rules [Int.ModEq.sub_right, Int.ModEq.add, Int.ModEq.mul_left,
Int.ModEq.pow_card_sub_one_eq_one hp]
_ = 0 := by norm_num
-
-- Since `6` has an inverse mod `p`, `a (p - 2)` itself is a multiple of `p`
calc
(a (p - 2) : ℤ) = 1 * a (p - 2) := by ring
@@ -65,7 +64,6 @@ theorem find_specified_factor {p : ℕ} (hp : Nat.Prime p) (hp' : IsCoprime (6 :
_ = b * (6 * a (p - 2)) := by ring
_ ≡ b * 0 [ZMOD p] := (Int.ModEq.mul_left _ H)
_ = 0 := by ring
-
#align imo2005_q4.find_specified_factor Imo2005Q4.find_specified_factor
end imo2005_q4
mathlib commit https://github.com/leanprover-community/mathlib/commit/a3209ddf94136d36e5e5c624b10b2a347cc9d090
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
@@ -66,7 +66,7 @@ theorem imo2005_q4 {k : ℕ} (hk : 0 < k) : (∀ n : ℕ, 1 ≤ n → IsCoprime
have hp : Nat.Prime p := Nat.minFac_prime hk'
replace h : ∀ n, 1 ≤ n → ¬(p : ℤ) ∣ a n := fun n hn ↦ by
have : IsCoprime (a n) p :=
- .of_isCoprime_of_dvd_right (h n hn) (Int.coe_nat_dvd.mpr k.minFac_dvd)
+ .of_isCoprime_of_dvd_right (h n hn) (Int.natCast_dvd_natCast.mpr k.minFac_dvd)
rwa [isCoprime_comm,(Nat.prime_iff_prime_int.mp hp).coprime_iff_not_dvd] at this
-- For `p = 2` and `p = 3`, take `n = 1` and `n = 2`, respectively
by_cases hp2 : p = 2
@@ -29,7 +29,7 @@ def a (n : ℕ) : ℤ :=
theorem find_specified_factor {p : ℕ} (hp : Nat.Prime p) (hp2 : p ≠ 2) (hp3 : p ≠ 3) :
↑p ∣ a (p - 2) := by
-- Since `p` is neither `2` nor `3`, it is coprime with `2`, `3`, and `6`
- rw [Ne.def, ← Nat.prime_dvd_prime_iff_eq hp (by decide), ← Nat.Prime.coprime_iff_not_dvd hp]
+ rw [Ne, ← Nat.prime_dvd_prime_iff_eq hp (by decide), ← Nat.Prime.coprime_iff_not_dvd hp]
at hp2 hp3
have : Int.gcd p 6 = 1 := Nat.coprime_mul_iff_right.2 ⟨hp2, hp3⟩
-- Nat arithmetic needed to deal with powers
$
with <|
(#9319)
See Zulip thread for the discussion.
@@ -79,5 +79,5 @@ theorem imo2005_q4 {k : ℕ} (hk : 0 < k) : (∀ n : ℕ, 1 ≤ n → IsCoprime
refine h (p - 2) ?_ (find_specified_factor hp hp2 hp3)
calc
1 = 3 - 2 := by norm_num
- _ ≤ p - 2 := tsub_le_tsub_right (Nat.succ_le_of_lt $ hp.two_le.lt_of_ne' hp2) _
+ _ ≤ p - 2 := tsub_le_tsub_right (Nat.succ_le_of_lt <| hp.two_le.lt_of_ne' hp2) _
#align imo2005_q4 imo2005_q4
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>
@@ -29,7 +29,7 @@ def a (n : ℕ) : ℤ :=
theorem find_specified_factor {p : ℕ} (hp : Nat.Prime p) (hp2 : p ≠ 2) (hp3 : p ≠ 3) :
↑p ∣ a (p - 2) := by
-- Since `p` is neither `2` nor `3`, it is coprime with `2`, `3`, and `6`
- rw [Ne.def, ← Nat.prime_dvd_prime_iff_eq hp (by norm_num), ← Nat.Prime.coprime_iff_not_dvd hp]
+ rw [Ne.def, ← Nat.prime_dvd_prime_iff_eq hp (by decide), ← Nat.Prime.coprime_iff_not_dvd hp]
at hp2 hp3
have : Int.gcd p 6 = 1 := Nat.coprime_mul_iff_right.2 ⟨hp2, hp3⟩
-- Nat arithmetic needed to deal with powers
@@ -71,10 +71,10 @@ theorem imo2005_q4 {k : ℕ} (hk : 0 < k) : (∀ n : ℕ, 1 ≤ n → IsCoprime
-- For `p = 2` and `p = 3`, take `n = 1` and `n = 2`, respectively
by_cases hp2 : p = 2
· rw [hp2] at h
- apply h 1 <;> norm_num
+ apply h 1 <;> decide
by_cases hp3 : p = 3
· rw [hp3] at h
- apply h 2 <;> norm_num
+ apply h 2 <;> decide
-- Otherwise, take `n = p - 2`
refine h (p - 2) ?_ (find_specified_factor hp hp2 hp3)
calc
@@ -57,7 +57,7 @@ theorem imo2005_q4 {k : ℕ} (hk : 0 < k) : (∀ n : ℕ, 1 ≤ n → IsCoprime
rintro rfl n -
exact isCoprime_one_right
intro h
- -- Conversely, suppose `k` is a number with the property, and let `p` be `k.min_fac` (by
+ -- Conversely, suppose `k` is a number with the property, and let `p` be `k.minFac` (by
-- definition this is the minimal prime factor of `k` if `k ≠ 1`, and otherwise `1`.
let p := k.minFac
-- Suppose for the sake of contradiction that `k ≠ 1`. Then `p` is genuinely a prime factor of
@@ -2,14 +2,11 @@
Copyright (c) 2021 Heather Macbeth. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Heather Macbeth
-
-! This file was ported from Lean 3 source module imo.imo2005_q4
-! leanprover-community/mathlib commit 308826471968962c6b59c7ff82a22757386603e3
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathlib.FieldTheory.Finite.Basic
+#align_import imo.imo2005_q4 from "leanprover-community/mathlib"@"308826471968962c6b59c7ff82a22757386603e3"
+
/-!
# IMO 2005 Q4
The unported dependencies are