/-
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 1059
namespace Erdos1059
def IsFactorial (d : ℕ) : Prop :=
d ∈ Set.range Nat.factorial
def factorialsLessThanN (n : ℕ) : Set ℕ :=
{ d | d < n ∧ IsFactorial d }
def AllFactorialSubtractionsComposite (n : ℕ) : Prop :=
∀d ∈ factorialsLessThanN n, (n - d).CompositeAre there infinitely many primes $p$ such that $p - k!$ is composite for each $k$ such that $1 ≤ k! < p$?
@[category research open, AMS 11]
theorem erdos_1059 :
answer(sorry) ↔ Set.Infinite {p | p.Prime ∧ AllFactorialSubtractionsComposite p} := ⊢ True ↔ {p | Nat.Prime p ∧ AllFactorialSubtractionsComposite p}.Infinite
All goals completed! 🐙
abbrev DecidableIsFactorial (d : ℕ) : Prop :=
((Finset.Icc 0 d).filter (λ k => Nat.factorial k = d)).Nonempty
def decidableFactorialsLessThanN (n : ℕ) : Finset ℕ :=
(Finset.range n).filter DecidableIsFactorial
def DecidableAllFactorialSubtractionsComposite (n : ℕ) : Prop :=
∀ d ∈ decidableFactorialsLessThanN n, (n - d).Composite
@[category test, AMS 11]
lemma isFactorial_equivalent (d : ℕ) :
IsFactorial d ↔ DecidableIsFactorial d := d:ℕ⊢ IsFactorial d ↔ DecidableIsFactorial d
d:ℕ⊢ d ∈ Set.range Nat.factorial ↔ {k ∈ Finset.Icc 0 d | k.factorial = d}.Nonempty
d:ℕ⊢ (∃ y, y.factorial = d) ↔ {k ∈ Finset.Icc 0 d | k.factorial = d}.Nonempty
d:ℕ⊢ (∃ y, y.factorial = d) → {k ∈ Finset.Icc 0 d | k.factorial = d}.Nonemptyd:ℕ⊢ {k ∈ Finset.Icc 0 d | k.factorial = d}.Nonempty → ∃ y, y.factorial = d
d:ℕ⊢ (∃ y, y.factorial = d) → {k ∈ Finset.Icc 0 d | k.factorial = d}.Nonempty d:ℕk:ℕhk:k.factorial = d⊢ {k ∈ Finset.Icc 0 d | k.factorial = d}.Nonempty
d:ℕk:ℕhk:k.factorial = d⊢ k ∈ {k ∈ Finset.Icc 0 d | k.factorial = d}
d:ℕk:ℕhk:k.factorial = d⊢ k ∈ Finset.Icc 0 d ∧ k.factorial = d
d:ℕk:ℕhk:k.factorial = d⊢ k ∈ Finset.Icc 0 dd:ℕk:ℕhk:k.factorial = d⊢ k.factorial = d
d:ℕk:ℕhk:k.factorial = d⊢ k ∈ Finset.Icc 0 d have hk : k <= d := d:ℕ⊢ IsFactorial d ↔ DecidableIsFactorial d
d:ℕk:ℕhk:k.factorial = d⊢ k ≤ k.factorial
All goals completed! 🐙
d:ℕk:ℕhk✝:k.factorial = dhk:k ≤ d := Eq.mpr (id (congrArg (fun _a => k ≤ _a) (Eq.symm hk✝))) (Nat.self_le_factorial k)⊢ 0 ≤ k ∧ k ≤ d
All goals completed! 🐙
d:ℕk:ℕhk:k.factorial = d⊢ k.factorial = d All goals completed! 🐙
d:ℕ⊢ {k ∈ Finset.Icc 0 d | k.factorial = d}.Nonempty → ∃ y, y.factorial = d d:ℕk:ℕhk:k ∈ {k ∈ Finset.Icc 0 d | k.factorial = d}⊢ ∃ y, y.factorial = d
d:ℕk:ℕhk:k ∈ {k ∈ Finset.Icc 0 d | k.factorial = d}⊢ k.factorial = d
d:ℕk:ℕhk:k ∈ Finset.Icc 0 d ∧ k.factorial = d⊢ k.factorial = d
All goals completed! 🐙
@[category test, AMS 11]
lemma factorialsLessThanN_equivalent (n : ℕ) :
factorialsLessThanN n = ↑(decidableFactorialsLessThanN n) := n:ℕ⊢ factorialsLessThanN n = ↑(decidableFactorialsLessThanN n)
n:ℕd:ℕ⊢ d ∈ factorialsLessThanN n ↔ d ∈ ↑(decidableFactorialsLessThanN n)
n:ℕd:ℕ⊢ d ∈ {d | d < n ∧ IsFactorial d} ↔ d ∈ ↑(Finset.filter DecidableIsFactorial (Finset.range n))
n:ℕd:ℕ⊢ d < n → (IsFactorial d ↔ DecidableIsFactorial d)
All goals completed! 🐙
@[category test, AMS 11]
lemma allFactorialSubtractionsComposite_equivalent (d : ℕ) :
DecidableAllFactorialSubtractionsComposite d ↔ AllFactorialSubtractionsComposite d := d:ℕ⊢ DecidableAllFactorialSubtractionsComposite d ↔ AllFactorialSubtractionsComposite d
d:ℕ⊢ (∀ d_1 ∈ decidableFactorialsLessThanN d, (d - d_1).Composite) ↔ ∀ d_1 ∈ factorialsLessThanN d, (d - d_1).Composite
d:ℕ⊢ (∀ d_1 ∈ decidableFactorialsLessThanN d, (d - d_1).Composite) ↔
∀ d_1 ∈ ↑(decidableFactorialsLessThanN d), (d - d_1).Composite
All goals completed! 🐙
@[category test, AMS 11]
theorem allFactorialSubtractionsComposite_101 : AllFactorialSubtractionsComposite 101 := ⊢ AllFactorialSubtractionsComposite 101
have h : DecidableAllFactorialSubtractionsComposite 101 := ⊢ AllFactorialSubtractionsComposite 101
⊢ ∀ d < 101, DecidableIsFactorial d → (101 - d).Composite
All goals completed! 🐙
All goals completed! 🐙
@[category test, AMS 11]
theorem allFactorialSubtractionsComposite_211 : AllFactorialSubtractionsComposite 211 := ⊢ AllFactorialSubtractionsComposite 211
have h : DecidableAllFactorialSubtractionsComposite 211 := ⊢ AllFactorialSubtractionsComposite 211
⊢ ∀ d < 211, DecidableIsFactorial d → (211 - d).Composite
All goals completed! 🐙
All goals completed! 🐙
@[category test, AMS 11]
theorem notAllFactorialSubtractionsComposite_89 : ¬(AllFactorialSubtractionsComposite 89) := ⊢ ¬AllFactorialSubtractionsComposite 89
have h : ¬(DecidableAllFactorialSubtractionsComposite 89) := ⊢ ¬AllFactorialSubtractionsComposite 89
⊢ ¬∀ d ∈ Finset.filter DecidableIsFactorial (Finset.range 89), (89 - d).Composite
h:∀ d ∈ Finset.filter DecidableIsFactorial (Finset.range 89), (89 - d).Composite⊢ False
h:6 ∈ Finset.filter DecidableIsFactorial (Finset.range 89) → (89 - 6).Composite⊢ False
have : Nat.Prime (89 - 6) := ⊢ ¬AllFactorialSubtractionsComposite 89 All goals completed! 🐙
All goals completed! 🐙
h:¬AllFactorialSubtractionsComposite 89⊢ ¬AllFactorialSubtractionsComposite 89
All goals completed! 🐙
@[category test, AMS 11]
theorem testFactorialsLessThanN : factorialsLessThanN 100 = {1, 2, 6, 24} := ⊢ factorialsLessThanN 100 = {1, 2, 6, 24}
have h : decidableFactorialsLessThanN 100 = {1, 2, 6, 24} := ⊢ factorialsLessThanN 100 = {1, 2, 6, 24}
⊢ Finset.filter DecidableIsFactorial (Finset.range 100) = {1, 2, 6, 24}
All goals completed! 🐙
h:decidableFactorialsLessThanN 100 = {1, 2, 6, 24} := id testFactorialsLessThanN._proof_1⊢ ↑(decidableFactorialsLessThanN 100) = {1, 2, 6, 24}
All goals completed! 🐙
end Erdos1059