/- 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 FormalConjecturesUtil

Erdős Problem 56

Reference: erdosproblems.com/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 divisible 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! 🐙k:hk:k 0this:{x | A, WeaklyDivisible k A (A = A = {1}) #A = x} = {0, 1}MaxWeaklyDivisible 1 k = 1 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)k:n:h:n < khprime:Nat.nth Nat.Prime n = 1this:Nat.Prime 1False 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.

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 + 1hcard_fink:Fintype.card (Fin k) = kx:sy:shne:x yheq:f x = f yh_pair:(↑s).Pairwise Nat.Coprimehne_val:x yh_coprime:(↑x).Coprime yp: := Nat.nth Nat.Prime (f x)hp_prime:Nat.Prime php_div_x:p xhp_div_y:p yhp_div_gcd:p 1h_gcd_eq_one:(↑x).gcd y = 1hp_le_one:p 1False 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 + 1hcard_fink:Fintype.card (Fin k) = kx:sy:shne:x yheq:f x = f yh_pair:(↑s).Pairwise Nat.Coprimehne_val:x yh_coprime:(↑x).Coprime yp: := Nat.nth Nat.Prime (f x)hp_prime:Nat.Prime php_div_x:p xhp_div_y:p yhp_div_gcd:p 1h_gcd_eq_one:(↑x).gcd y = 1hp_le_one:p 1this:p > 1False 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