/-
Copyright 2025 The Formal Conjectures Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-/
import FormalConjecturesUtilErdős Problem 56
open scoped Finsetnamespace Erdos56
Say a set of natural numbers is k-weakly divisible if any k+1 elements
of A are not relatively prime.
def WeaklyDivisible (k : ℕ) (A : Finset ℕ) : Prop :=
∀ s ∈ A.powersetCard (k + 1), ¬ Set.Pairwise s Nat.Coprime
@[category API, AMS 11]
lemma weaklyDivisible_empty (k : ℕ): WeaklyDivisible k {} := k:ℕ⊢ WeaklyDivisible k ∅
All goals completed! 🐙
A singleton is k-weakly divisble if k ≠ 0.
@[category API, AMS 11]
lemma weaklyDivisible_singleton {k : ℕ} (hk : k ≠ 0) (l : ℕ) : WeaklyDivisible k {l} := k:ℕhk:k ≠ 0l:ℕ⊢ WeaklyDivisible k {l}
All goals completed! 🐙
No non-empty set is 1-weakly divisible.
@[category API, AMS 11]
lemma not_weaklyDivisible_zero {A : _} (h : A.Nonempty) : ¬WeaklyDivisible 0 A := A:Finset ℕh:A.Nonempty⊢ ¬WeaklyDivisible 0 A
simpa [WeaklyDivisible] using ⟨{_}, A:Finset ℕh:A.Nonempty⊢ {?m.20} ⊆ A ∧ #{?m.20} = 1 ∧ (↑{?m.20}).Pairwise Nat.Coprime All goals completed! 🐙⟩
@[category API, AMS 11]
lemma empty_iff_weaklyDivisible_zero {A : _} : WeaklyDivisible 0 A ↔ A = ∅ :=
⟨fun h ↦ Finset.not_nonempty_iff_eq_empty.1 <| mt not_weaklyDivisible_zero (not_not.2 h),
fun h ↦ h ▸ weaklyDivisible_empty _⟩
MaxWeaklyDivisible N k is the size of the largest k-weakly divisible subset of {1,..., N}
noncomputable def MaxWeaklyDivisible (N : ℕ) (k : ℕ) : ℕ :=
sSup {#A | (A : Finset ℕ) (_ : A ⊆ Finset.Icc 1 N) (_ : WeaklyDivisible k A)}
@[category test, AMS 11]
theorem maxWeaklyDivisible_zero : ∀ k : ℕ, MaxWeaklyDivisible 0 k = 0 := ⊢ ∀ (k : ℕ), MaxWeaklyDivisible 0 k = 0
k:ℕ⊢ MaxWeaklyDivisible 0 k = 0
All goals completed! 🐙
@[category test, AMS 11]
theorem maxWeaklyDivisible_one {k : ℕ} (hk : k ≠ 0) : MaxWeaklyDivisible 1 k = 1 := k:ℕhk:k ≠ 0⊢ MaxWeaklyDivisible 1 k = 1
have : {x | ∃ A, WeaklyDivisible k A ∧ (A = ∅ ∨ A = {1}) ∧ #A = x} = {0, 1} := k:ℕhk:k ≠ 0⊢ MaxWeaklyDivisible 1 k = 1
refine Set.ext fun _ => ⟨fun _ => k:ℕhk:k ≠ 0x✝¹:ℕx✝:x✝¹ ∈ {x | ∃ A, WeaklyDivisible k A ∧ (A = ∅ ∨ A = {1}) ∧ #A = x}⊢ x✝¹ ∈ {0, 1} All goals completed! 🐙, ?_⟩
k:ℕhk:k ≠ 0⊢ 0 ∈ {x | ∃ A, WeaklyDivisible k A ∧ (A = ∅ ∨ A = {1}) ∧ #A = x}k:ℕhk:k ≠ 0x✝:ℕh✝:x✝ ∈ {1}⊢ x✝¹ ∈ {x | ∃ A, WeaklyDivisible k A ∧ (A = ∅ ∨ A = {1}) ∧ #A = x}
k:ℕhk:k ≠ 0⊢ 0 ∈ {x | ∃ A, WeaklyDivisible k A ∧ (A = ∅ ∨ A = {1}) ∧ #A = x} All goals completed! 🐙
k:ℕhk:k ≠ 0x✝:ℕh✝:x✝ ∈ {1}⊢ x✝¹ ∈ {x | ∃ A, WeaklyDivisible k A ∧ (A = ∅ ∨ A = {1}) ∧ #A = x} exact ⟨{1}, k:ℕhk:k ≠ 0x✝:ℕh✝:x✝ ∈ {1}⊢ WeaklyDivisible k {1} ∧ ({1} = ∅ ∨ {1} = {1}) ∧ #{1} = x✝ All goals completed! 🐙⟩
All goals completed! 🐙
@[category test, AMS 11]
theorem maxWeaklyDivisible_zero_k (N : ℕ) : MaxWeaklyDivisible N 0 = 0 := N:ℕ⊢ MaxWeaklyDivisible N 0 = 0
All goals completed! 🐙
FirstPrimesMultiples N k is the set of numbers in {1,..., N} that are
a multiple of one of the first k primes.
noncomputable def FirstPrimesMultiples (N k : ℕ) : Finset ℕ :=
(Finset.Icc 1 N).filter fun i => ∃ j < k, (j.nth Nat.Prime ∣ i)
@[category test, AMS 11]
theorem firstPrimesMultiples_one_card_zero (k : ℕ) : (FirstPrimesMultiples 1 k).card = 0 := k:ℕ⊢ #(FirstPrimesMultiples 1 k) = 0
k:ℕ⊢ ∀ x < k, ¬Nat.nth Nat.Prime x = 1
intro n k:ℕn:ℕh:n < k⊢ ¬Nat.nth Nat.Prime n = 1
k:ℕn:ℕh:n < khprime:Nat.nth Nat.Prime n = 1⊢ False
have : Nat.Prime 1 := k:ℕ⊢ #(FirstPrimesMultiples 1 k) = 0
k:ℕn:ℕh:n < khprime:Nat.nth Nat.Prime n = 1⊢ 1 = Nat.nth Nat.Prime n
All goals completed! 🐙
All goals completed! 🐙
@[category test, AMS 11]
theorem firstPrimesMultiples_zero_k_card_zero (N : ℕ) : (FirstPrimesMultiples N 0).card = 0 := N:ℕ⊢ #(FirstPrimesMultiples N 0) = 0
All goals completed! 🐙
An example of a k-weakly divisible set is the subset of {1, ..., N}
containing the multiples of the first k primes.
@[category API, AMS 11]
lemma weaklyDivisible_firstPrimesMultiples (N k : ℕ) :
WeaklyDivisible k (FirstPrimesMultiples N k) := N:ℕk:ℕ⊢ WeaklyDivisible k (FirstPrimesMultiples N k)
N:ℕk:ℕ⊢ ∀ s ∈ Finset.powersetCard (k + 1) (FirstPrimesMultiples N k), ¬(↑s).Pairwise Nat.Coprime
intro s N:ℕk:ℕs:Finset ℕhs:s ∈ Finset.powersetCard (k + 1) (FirstPrimesMultiples N k)⊢ ¬(↑s).Pairwise Nat.Coprime
N:ℕk:ℕs:Finset ℕhs:s ⊆ FirstPrimesMultiples N k ∧ #s = k + 1⊢ ¬(↑s).Pairwise Nat.Coprime
-- Define the map from s to Fin k
N:ℕk:ℕs:Finset ℕhs:s ⊆ FirstPrimesMultiples N k ∧ #s = k + 1f:↥s → Fin k :=
fun x =>
match x with
| ⟨x, hx⟩ =>
have h_exists := ⋯;
⟨Classical.choose h_exists, ⋯⟩⊢ ¬(↑s).Pairwise Nat.Coprime
have hcard_s : Fintype.card s = k + 1 := N:ℕk:ℕ⊢ WeaklyDivisible k (FirstPrimesMultiples N k) All goals completed! 🐙
N:ℕk:ℕs:Finset ℕhs:s ⊆ FirstPrimesMultiples N k ∧ #s = k + 1f:↥s → Fin k :=
fun x =>
match x with
| ⟨x, hx⟩ =>
have h_exists := ⋯;
⟨Classical.choose h_exists, ⋯⟩hcard_s:Fintype.card ↥s = k + 1 :=
of_eq_true
(Eq.trans
(Eq.trans (congrArg (fun x => x = k + 1) (Eq.trans (Fintype.card_coe s) hs.right)) Nat.add_left_cancel_iff._simp_1)
(eq_self 1))hcard_fink:Fintype.card (Fin k) = k := Fintype.card_fin k⊢ ¬(↑s).Pairwise Nat.Coprime
obtain ⟨x, y, hne, heq⟩ := Fintype.exists_ne_map_eq_of_card_lt f (N:ℕk:ℕs:Finset ℕhs:s ⊆ FirstPrimesMultiples N k ∧ #s = k + 1f:↥s → Fin k :=
fun x =>
match x with
| ⟨x, hx⟩ =>
have h_exists := ⋯;
⟨Classical.choose h_exists, ⋯⟩hcard_s:Fintype.card ↥s = k + 1 :=
of_eq_true
(Eq.trans
(Eq.trans (congrArg (fun x => x = k + 1) (Eq.trans (Fintype.card_coe s) hs.right)) Nat.add_left_cancel_iff._simp_1)
(eq_self 1))hcard_fink:Fintype.card (Fin k) = k := Fintype.card_fin k⊢ Fintype.card (Fin k) < Fintype.card ↥s All goals completed! 🐙)
N:ℕk:ℕs:Finset ℕhs:s ⊆ FirstPrimesMultiples N k ∧ #s = k + 1f:↥s → Fin k :=
fun x =>
match x with
| ⟨x, hx⟩ =>
have h_exists := ⋯;
⟨Classical.choose h_exists, ⋯⟩hcard_s:Fintype.card ↥s = k + 1 :=
of_eq_true
(Eq.trans
(Eq.trans (congrArg (fun x => x = k + 1) (Eq.trans (Fintype.card_coe s) hs.right)) Nat.add_left_cancel_iff._simp_1)
(eq_self 1))hcard_fink:Fintype.card (Fin k) = k := Fintype.card_fin kx:↥sy:↥shne:x ≠ yheq:f x = f yh_pair:(↑s).Pairwise Nat.Coprime⊢ False
have hne_val : x.1 ≠ y.1 := N:ℕk:ℕ⊢ WeaklyDivisible k (FirstPrimesMultiples N k)
N:ℕk:ℕs:Finset ℕhs:s ⊆ FirstPrimesMultiples N k ∧ #s = k + 1f:↥s → Fin k :=
fun x =>
match x with
| ⟨x, hx⟩ =>
have h_exists := ⋯;
⟨Classical.choose h_exists, ⋯⟩hcard_s:Fintype.card ↥s = k + 1 :=
of_eq_true
(Eq.trans
(Eq.trans (congrArg (fun x => x = k + 1) (Eq.trans (Fintype.card_coe s) hs.right)) Nat.add_left_cancel_iff._simp_1)
(eq_self 1))hcard_fink:Fintype.card (Fin k) = k := Fintype.card_fin kx:↥sy:↥shne:x ≠ yheq:f x = f yh_pair:(↑s).Pairwise Nat.Coprimeh_eq:↑x = ↑y⊢ False
All goals completed! 🐙
N:ℕk:ℕs:Finset ℕhs:s ⊆ FirstPrimesMultiples N k ∧ #s = k + 1f:↥s → Fin k :=
fun x =>
match x with
| ⟨x, hx⟩ =>
have h_exists := ⋯;
⟨Classical.choose h_exists, ⋯⟩hcard_s:Fintype.card ↥s = k + 1 :=
of_eq_true
(Eq.trans
(Eq.trans (congrArg (fun x => x = k + 1) (Eq.trans (Fintype.card_coe s) hs.right)) Nat.add_left_cancel_iff._simp_1)
(eq_self 1))hcard_fink:Fintype.card (Fin k) = k := Fintype.card_fin kx:↥sy:↥shne:x ≠ yheq:f x = f yh_pair:(↑s).Pairwise Nat.Coprimehne_val:↑x ≠ ↑y := fun h_eq => hne (Subtype.ext h_eq)h_coprime:(↑x).Coprime ↑y := h_pair x.property y.property hne_val⊢ False
N:ℕk:ℕs:Finset ℕhs:s ⊆ FirstPrimesMultiples N k ∧ #s = k + 1f:↥s → Fin k :=
fun x =>
match x with
| ⟨x, hx⟩ =>
have h_exists := ⋯;
⟨Classical.choose h_exists, ⋯⟩hcard_s:Fintype.card ↥s = k + 1 :=
of_eq_true
(Eq.trans
(Eq.trans (congrArg (fun x => x = k + 1) (Eq.trans (Fintype.card_coe s) hs.right)) Nat.add_left_cancel_iff._simp_1)
(eq_self 1))hcard_fink:Fintype.card (Fin k) = k := Fintype.card_fin kx:↥sy:↥shne:x ≠ yheq:f x = f yh_pair:(↑s).Pairwise Nat.Coprimehne_val:↑x ≠ ↑y := fun h_eq => hne (Subtype.ext h_eq)h_coprime:(↑x).Coprime ↑y := h_pair x.property y.property hne_valp:ℕ := Nat.nth Nat.Prime ↑(f x)⊢ False
N:ℕk:ℕs:Finset ℕhs:s ⊆ FirstPrimesMultiples N k ∧ #s = k + 1f:↥s → Fin k :=
fun x =>
match x with
| ⟨x, hx⟩ =>
have h_exists := ⋯;
⟨Classical.choose h_exists, ⋯⟩hcard_s:Fintype.card ↥s = k + 1 :=
of_eq_true
(Eq.trans
(Eq.trans (congrArg (fun x => x = k + 1) (Eq.trans (Fintype.card_coe s) hs.right)) Nat.add_left_cancel_iff._simp_1)
(eq_self 1))hcard_fink:Fintype.card (Fin k) = k := Fintype.card_fin kx:↥sy:↥shne:x ≠ yheq:f x = f yh_pair:(↑s).Pairwise Nat.Coprimehne_val:↑x ≠ ↑y := fun h_eq => hne (Subtype.ext h_eq)h_coprime:(↑x).Coprime ↑y := h_pair x.property y.property hne_valp:ℕ := Nat.nth Nat.Prime ↑(f x)hp_prime:Nat.Prime p := Nat.prime_nth_prime ↑(f x)⊢ False
have hp_div_x : p ∣ x.1 := N:ℕk:ℕ⊢ WeaklyDivisible k (FirstPrimesMultiples N k)
N:ℕk:ℕs:Finset ℕhs:s ⊆ FirstPrimesMultiples N k ∧ #s = k + 1f:↥s → Fin k :=
fun x =>
match x with
| ⟨x, hx⟩ =>
have h_exists := ⋯;
⟨Classical.choose h_exists, ⋯⟩hcard_s:Fintype.card ↥s = k + 1 :=
of_eq_true
(Eq.trans
(Eq.trans (congrArg (fun x => x = k + 1) (Eq.trans (Fintype.card_coe s) hs.right)) Nat.add_left_cancel_iff._simp_1)
(eq_self 1))hcard_fink:Fintype.card (Fin k) = k := Fintype.card_fin kx:↥sy:↥shne:x ≠ yheq:f x = f yh_pair:(↑s).Pairwise Nat.Coprimehne_val:↑x ≠ ↑y := fun h_eq => hne (Subtype.ext h_eq)h_coprime:(↑x).Coprime ↑y := h_pair x.property y.property hne_valp:ℕ := Nat.nth Nat.Prime ↑(f x)hp_prime:Nat.Prime p := Nat.prime_nth_prime ↑(f x)h_exists:∃ j < k, Nat.nth Nat.Prime j ∣ ↑x := (Finset.mem_filter.mp (hs.left x.property)).right⊢ p ∣ ↑x
All goals completed! 🐙
have hp_div_y : p ∣ y.1 := N:ℕk:ℕ⊢ WeaklyDivisible k (FirstPrimesMultiples N k)
N:ℕk:ℕs:Finset ℕhs:s ⊆ FirstPrimesMultiples N k ∧ #s = k + 1f:↥s → Fin k :=
fun x =>
match x with
| ⟨x, hx⟩ =>
have h_exists := ⋯;
⟨Classical.choose h_exists, ⋯⟩hcard_s:Fintype.card ↥s = k + 1 :=
of_eq_true
(Eq.trans
(Eq.trans (congrArg (fun x => x = k + 1) (Eq.trans (Fintype.card_coe s) hs.right)) Nat.add_left_cancel_iff._simp_1)
(eq_self 1))hcard_fink:Fintype.card (Fin k) = k := Fintype.card_fin kx:↥sy:↥shne:x ≠ yheq:f x = f yh_pair:(↑s).Pairwise Nat.Coprimehne_val:↑x ≠ ↑y := fun h_eq => hne (Subtype.ext h_eq)h_coprime:(↑x).Coprime ↑y := h_pair x.property y.property hne_valp:ℕ := Nat.nth Nat.Prime ↑(f x)hp_prime:Nat.Prime p := Nat.prime_nth_prime ↑(f x)hp_div_x:p ∣ ↑x :=
have h_exists := (Finset.mem_filter.mp (hs.left x.property)).right;
(Classical.choose_spec h_exists).righth_exists:∃ j < k, Nat.nth Nat.Prime j ∣ ↑y := (Finset.mem_filter.mp (hs.left y.property)).right⊢ p ∣ ↑y
have h_eq_f : (f x).val = (f y).val := N:ℕk:ℕ⊢ WeaklyDivisible k (FirstPrimesMultiples N k) All goals completed! 🐙
-- (f y).val is Classical.choose h_exists by definition
have : p = (Classical.choose h_exists).nth Nat.Prime := N:ℕk:ℕ⊢ WeaklyDivisible k (FirstPrimesMultiples N k)
N:ℕk:ℕs:Finset ℕhs:s ⊆ FirstPrimesMultiples N k ∧ #s = k + 1f:↥s → Fin k :=
fun x =>
match x with
| ⟨x, hx⟩ =>
have h_exists := ⋯;
⟨Classical.choose h_exists, ⋯⟩hcard_s:Fintype.card ↥s = k + 1 :=
of_eq_true
(Eq.trans
(Eq.trans (congrArg (fun x => x = k + 1) (Eq.trans (Fintype.card_coe s) hs.right)) Nat.add_left_cancel_iff._simp_1)
(eq_self 1))hcard_fink:Fintype.card (Fin k) = k := Fintype.card_fin kx:↥sy:↥shne:x ≠ yheq:f x = f yh_pair:(↑s).Pairwise Nat.Coprimehne_val:↑x ≠ ↑y := fun h_eq => hne (Subtype.ext h_eq)h_coprime:(↑x).Coprime ↑y := h_pair x.property y.property hne_valp:ℕ := Nat.nth Nat.Prime ↑(f x)hp_prime:Nat.Prime p := Nat.prime_nth_prime ↑(f x)hp_div_x:p ∣ ↑x :=
have h_exists := (Finset.mem_filter.mp (hs.left x.property)).right;
(Classical.choose_spec h_exists).righth_exists:∃ j < k, Nat.nth Nat.Prime j ∣ ↑y := (Finset.mem_filter.mp (hs.left y.property)).righth_eq_f:↑(f x) = ↑(f y) := Eq.mpr (id (congrArg (fun _a => ↑_a = ↑(f y)) heq)) (Eq.refl ↑(f y))⊢ Nat.nth Nat.Prime ↑(f x) = Nat.nth Nat.Prime (Classical.choose h_exists)
All goals completed! 🐙
N:ℕk:ℕs:Finset ℕhs:s ⊆ FirstPrimesMultiples N k ∧ #s = k + 1f:↥s → Fin k :=
fun x =>
match x with
| ⟨x, hx⟩ =>
have h_exists := ⋯;
⟨Classical.choose h_exists, ⋯⟩hcard_s:Fintype.card ↥s = k + 1 :=
of_eq_true
(Eq.trans
(Eq.trans (congrArg (fun x => x = k + 1) (Eq.trans (Fintype.card_coe s) hs.right)) Nat.add_left_cancel_iff._simp_1)
(eq_self 1))hcard_fink:Fintype.card (Fin k) = k := Fintype.card_fin kx:↥sy:↥shne:x ≠ yheq:f x = f yh_pair:(↑s).Pairwise Nat.Coprimehne_val:↑x ≠ ↑y := fun h_eq => hne (Subtype.ext h_eq)h_coprime:(↑x).Coprime ↑y := h_pair x.property y.property hne_valp:ℕ := Nat.nth Nat.Prime ↑(f x)hp_prime:Nat.Prime p := Nat.prime_nth_prime ↑(f x)hp_div_x:p ∣ ↑x :=
have h_exists := (Finset.mem_filter.mp (hs.left x.property)).right;
(Classical.choose_spec h_exists).righth_exists:∃ j < k, Nat.nth Nat.Prime j ∣ ↑y := (Finset.mem_filter.mp (hs.left y.property)).righth_eq_f:↑(f x) = ↑(f y) := Eq.mpr (id (congrArg (fun _a => ↑_a = ↑(f y)) heq)) (Eq.refl ↑(f y))this:p = Nat.nth Nat.Prime (Classical.choose h_exists) :=
id
(Eq.mpr (id (congrArg (fun _a => Nat.nth Nat.Prime _a = Nat.nth Nat.Prime (Classical.choose h_exists)) h_eq_f))
(Eq.refl (Nat.nth Nat.Prime ↑(f y))))⊢ Nat.nth Nat.Prime (Classical.choose h_exists) ∣ ↑y
All goals completed! 🐙
N:ℕk:ℕs:Finset ℕhs:s ⊆ FirstPrimesMultiples N k ∧ #s = k + 1f:↥s → Fin k :=
fun x =>
match x with
| ⟨x, hx⟩ =>
have h_exists := ⋯;
⟨Classical.choose h_exists, ⋯⟩hcard_s:Fintype.card ↥s = k + 1 :=
of_eq_true
(Eq.trans
(Eq.trans (congrArg (fun x => x = k + 1) (Eq.trans (Fintype.card_coe s) hs.right)) Nat.add_left_cancel_iff._simp_1)
(eq_self 1))hcard_fink:Fintype.card (Fin k) = k := Fintype.card_fin kx:↥sy:↥shne:x ≠ yheq:f x = f yh_pair:(↑s).Pairwise Nat.Coprimehne_val:↑x ≠ ↑y := fun h_eq => hne (Subtype.ext h_eq)h_coprime:(↑x).Coprime ↑y := h_pair x.property y.property hne_valp:ℕ := Nat.nth Nat.Prime ↑(f x)hp_prime:Nat.Prime p := Nat.prime_nth_prime ↑(f x)hp_div_x:p ∣ ↑x :=
have h_exists := (Finset.mem_filter.mp (hs.left x.property)).right;
(Classical.choose_spec h_exists).righthp_div_y:p ∣ ↑y :=
have h_exists := (Finset.mem_filter.mp (hs.left y.property)).right;
have h_eq_f := Eq.mpr (id (congrArg (fun _a => ↑_a = ↑(f y)) heq)) (Eq.refl ↑(f y));
have this :=
id
(Eq.mpr (id (congrArg (fun _a => Nat.nth Nat.Prime _a = Nat.nth Nat.Prime (Classical.choose h_exists)) h_eq_f))
(Eq.refl (Nat.nth Nat.Prime ↑(f y))));
Eq.mpr (id (congrArg (fun _a => _a ∣ ↑y) this)) (Classical.choose_spec h_exists).righthp_div_gcd:p ∣ (↑x).gcd ↑y := Nat.dvd_gcd hp_div_x hp_div_y⊢ False
N:ℕk:ℕs:Finset ℕhs:s ⊆ FirstPrimesMultiples N k ∧ #s = k + 1f:↥s → Fin k :=
fun x =>
match x with
| ⟨x, hx⟩ =>
have h_exists := ⋯;
⟨Classical.choose h_exists, ⋯⟩hcard_s:Fintype.card ↥s = k + 1 :=
of_eq_true
(Eq.trans
(Eq.trans (congrArg (fun x => x = k + 1) (Eq.trans (Fintype.card_coe s) hs.right)) Nat.add_left_cancel_iff._simp_1)
(eq_self 1))hcard_fink:Fintype.card (Fin k) = k := Fintype.card_fin kx:↥sy:↥shne:x ≠ yheq:f x = f yh_pair:(↑s).Pairwise Nat.Coprimehne_val:↑x ≠ ↑y := fun h_eq => hne (Subtype.ext h_eq)h_coprime:(↑x).Coprime ↑y := h_pair x.property y.property hne_valp:ℕ := Nat.nth Nat.Prime ↑(f x)hp_prime:Nat.Prime p := Nat.prime_nth_prime ↑(f x)hp_div_x:p ∣ ↑x :=
have h_exists := (Finset.mem_filter.mp (hs.left x.property)).right;
(Classical.choose_spec h_exists).righthp_div_y:p ∣ ↑y :=
have h_exists := (Finset.mem_filter.mp (hs.left y.property)).right;
have h_eq_f := Eq.mpr (id (congrArg (fun _a => ↑_a = ↑(f y)) heq)) (Eq.refl ↑(f y));
have this :=
id
(Eq.mpr (id (congrArg (fun _a => Nat.nth Nat.Prime _a = Nat.nth Nat.Prime (Classical.choose h_exists)) h_eq_f))
(Eq.refl (Nat.nth Nat.Prime ↑(f y))));
Eq.mpr (id (congrArg (fun _a => _a ∣ ↑y) this)) (Classical.choose_spec h_exists).righthp_div_gcd:p ∣ (↑x).gcd ↑y := Nat.dvd_gcd hp_div_x hp_div_yh_gcd_eq_one:(↑x).gcd ↑y = 1 := h_coprime⊢ False
N:ℕk:ℕs:Finset ℕhs:s ⊆ FirstPrimesMultiples N k ∧ #s = k + 1f:↥s → Fin k :=
fun x =>
match x with
| ⟨x, hx⟩ =>
have h_exists := ⋯;
⟨Classical.choose h_exists, ⋯⟩hcard_s:Fintype.card ↥s = k + 1 :=
of_eq_true
(Eq.trans
(Eq.trans (congrArg (fun x => x = k + 1) (Eq.trans (Fintype.card_coe s) hs.right)) Nat.add_left_cancel_iff._simp_1)
(eq_self 1))hcard_fink:Fintype.card (Fin k) = k := Fintype.card_fin kx:↥sy:↥shne:x ≠ yheq:f x = f yh_pair:(↑s).Pairwise Nat.Coprimehne_val:↑x ≠ ↑y := fun h_eq => hne (Subtype.ext h_eq)h_coprime:(↑x).Coprime ↑y := h_pair x.property y.property hne_valp:ℕ := Nat.nth Nat.Prime ↑(f x)hp_prime:Nat.Prime p := Nat.prime_nth_prime ↑(f x)hp_div_x:p ∣ ↑x :=
have h_exists := (Finset.mem_filter.mp (hs.left x.property)).right;
(Classical.choose_spec h_exists).righthp_div_y:p ∣ ↑y :=
have h_exists := (Finset.mem_filter.mp (hs.left y.property)).right;
have h_eq_f := Eq.mpr (id (congrArg (fun _a => ↑_a = ↑(f y)) heq)) (Eq.refl ↑(f y));
have this :=
id
(Eq.mpr (id (congrArg (fun _a => Nat.nth Nat.Prime _a = Nat.nth Nat.Prime (Classical.choose h_exists)) h_eq_f))
(Eq.refl (Nat.nth Nat.Prime ↑(f y))));
Eq.mpr (id (congrArg (fun _a => _a ∣ ↑y) this)) (Classical.choose_spec h_exists).righthp_div_gcd:p ∣ 1h_gcd_eq_one:(↑x).gcd ↑y = 1⊢ False
have hp_le_one : p ≤ 1 := Nat.le_of_dvd (N:ℕk:ℕs:Finset ℕhs:s ⊆ FirstPrimesMultiples N k ∧ #s = k + 1f:↥s → Fin k :=
fun x =>
match x with
| ⟨x, hx⟩ =>
have h_exists := ⋯;
⟨Classical.choose h_exists, ⋯⟩hcard_s:Fintype.card ↥s = k + 1 :=
of_eq_true
(Eq.trans
(Eq.trans (congrArg (fun x => x = k + 1) (Eq.trans (Fintype.card_coe s) hs.right)) Nat.add_left_cancel_iff._simp_1)
(eq_self 1))hcard_fink:Fintype.card (Fin k) = k := Fintype.card_fin kx:↥sy:↥shne:x ≠ yheq:f x = f yh_pair:(↑s).Pairwise Nat.Coprimehne_val:↑x ≠ ↑y := fun h_eq => hne (Subtype.ext h_eq)h_coprime:(↑x).Coprime ↑y := h_pair x.property y.property hne_valp:ℕ := Nat.nth Nat.Prime ↑(f x)hp_prime:Nat.Prime p := Nat.prime_nth_prime ↑(f x)hp_div_x:p ∣ ↑x :=
have h_exists := (Finset.mem_filter.mp (hs.left x.property)).right;
(Classical.choose_spec h_exists).righthp_div_y:p ∣ ↑y :=
have h_exists := (Finset.mem_filter.mp (hs.left y.property)).right;
have h_eq_f := Eq.mpr (id (congrArg (fun _a => ↑_a = ↑(f y)) heq)) (Eq.refl ↑(f y));
have this :=
id
(Eq.mpr (id (congrArg (fun _a => Nat.nth Nat.Prime _a = Nat.nth Nat.Prime (Classical.choose h_exists)) h_eq_f))
(Eq.refl (Nat.nth Nat.Prime ↑(f y))));
Eq.mpr (id (congrArg (fun _a => _a ∣ ↑y) this)) (Classical.choose_spec h_exists).righthp_div_gcd:p ∣ 1h_gcd_eq_one:(↑x).gcd ↑y = 1⊢ 0 < 1 All goals completed! 🐙) hp_div_gcd
N:ℕk:ℕs:Finset ℕhs:s ⊆ FirstPrimesMultiples N k ∧ #s = k + 1f:↥s → Fin k :=
fun x =>
match x with
| ⟨x, hx⟩ =>
have h_exists := ⋯;
⟨Classical.choose h_exists, ⋯⟩hcard_s:Fintype.card ↥s = k + 1 :=
of_eq_true
(Eq.trans
(Eq.trans (congrArg (fun x => x = k + 1) (Eq.trans (Fintype.card_coe s) hs.right)) Nat.add_left_cancel_iff._simp_1)
(eq_self 1))hcard_fink:Fintype.card (Fin k) = k := Fintype.card_fin kx:↥sy:↥shne:x ≠ yheq:f x = f yh_pair:(↑s).Pairwise Nat.Coprimehne_val:↑x ≠ ↑y := fun h_eq => hne (Subtype.ext h_eq)h_coprime:(↑x).Coprime ↑y := h_pair x.property y.property hne_valp:ℕ := Nat.nth Nat.Prime ↑(f x)hp_prime:Nat.Prime p := Nat.prime_nth_prime ↑(f x)hp_div_x:p ∣ ↑x :=
have h_exists := (Finset.mem_filter.mp (hs.left x.property)).right;
(Classical.choose_spec h_exists).righthp_div_y:p ∣ ↑y :=
have h_exists := (Finset.mem_filter.mp (hs.left y.property)).right;
have h_eq_f := Eq.mpr (id (congrArg (fun _a => ↑_a = ↑(f y)) heq)) (Eq.refl ↑(f y));
have this :=
id
(Eq.mpr (id (congrArg (fun _a => Nat.nth Nat.Prime _a = Nat.nth Nat.Prime (Classical.choose h_exists)) h_eq_f))
(Eq.refl (Nat.nth Nat.Prime ↑(f y))));
Eq.mpr (id (congrArg (fun _a => _a ∣ ↑y) this)) (Classical.choose_spec h_exists).righthp_div_gcd:p ∣ 1h_gcd_eq_one:(↑x).gcd ↑y = 1hp_le_one:p ≤ 1 :=
Nat.le_of_dvd
(Mathlib.Meta.NormNum.isNat_lt_true (Mathlib.Meta.NormNum.isNat_ofNat ℕ (Eq.refl 0))
(Mathlib.Meta.NormNum.isNat_ofNat ℕ (Eq.refl 1)) (Eq.refl false))
hp_div_gcdthis:p > 1 := Nat.Prime.one_lt hp_prime⊢ False
All goals completed! 🐙
Suppose $A \subseteq {1,\dots,N}$ is such that there are no $k+1$ elements of $A$ which are relatively prime. An example is the set of all multiples of the first $k$ primes. Is this the largest such set? To avoid trivial counterexamples, we must insist that $N$ be at least the $k$th prime.
@[category research solved, AMS 11, formal_proof using lean4 at "https://github.com/plby/lean-proofs/blob/main/src/v4.24.0/ErdosProblems/Erdos56.lean"]
theorem erdos_56 : answer(False) ↔ ∀ᵉ (k > 0) (N ≥ (k-1).nth Nat.Prime),
(MaxWeaklyDivisible N k = (FirstPrimesMultiples N k).card) := ⊢ False ↔ ∀ k > 0, ∀ N ≥ Nat.nth Nat.Prime (k - 1), MaxWeaklyDivisible N k = #(FirstPrimesMultiples N k)
All goals completed! 🐙
end Erdos56