{
  "id": "522",
  "ident": "NS.00522",
  "slug": "erdos-1059",
  "title": "Erdős Problem 1059",
  "status": "open",
  "statement_status": "reviewed",
  "statement_md": "Are there infinitely many primes $p$ such that $p - k!$ is composite for each $k$ such that $1 ≤ k! < p$?",
  "subjects": [
    "math.NT",
    "msc:11"
  ],
  "tags": [
    "question"
  ],
  "collection": "erdos",
  "source_url": "https://www.erdosproblems.com/1059",
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "Erdos1059.erdos_1059",
  "statement_lean": "theorem erdos_1059 :\n    Set.Infinite {p | p.Prime ∧ AllFactorialSubtractionsComposite p}",
  "challenge_source": "/-\nCopyright 2025 The Formal Conjectures Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    https://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n-/\nmodule\n\npublic import FormalConjecturesUtil\n\n/-!\n# Erdős Problem 1059\n\n*Reference:* [erdosproblems.com/1059](https://www.erdosproblems.com/1059)\n-/\n\n@[expose] public section\n\nnamespace Erdos1059\n\ndef IsFactorial (d : ℕ) : Prop :=\n  d ∈ Set.range Nat.factorial\n\ndef factorialsLessThanN (n : ℕ) : Set ℕ :=\n  { d | d < n ∧ IsFactorial d }\n\ndef AllFactorialSubtractionsComposite (n : ℕ) : Prop :=\n  ∀d ∈ factorialsLessThanN n, (n - d).Composite\n\n/-- Are there infinitely many primes $p$ such that $p - k!$ is composite for each $k$ such that $1 ≤ k! < p$? -/\n@[category research open, question, AMS 11]\ntheorem erdos_1059 :\n    Set.Infinite {p | p.Prime ∧ AllFactorialSubtractionsComposite p} := by\n  sorry\n\nabbrev DecidableIsFactorial (d : ℕ) : Prop :=\n  ((Finset.Icc 0 d).filter (λ k => Nat.factorial k = d)).Nonempty\n\ndef decidableFactorialsLessThanN (n : ℕ) : Finset ℕ :=\n  (Finset.range n).filter DecidableIsFactorial\n\ndef DecidableAllFactorialSubtractionsComposite (n : ℕ) : Prop :=\n  ∀ d ∈ decidableFactorialsLessThanN n, (n - d).Composite\n\n@[category test, AMS 11]\nlemma isFactorial_equivalent (d : ℕ) :\n  IsFactorial d ↔ DecidableIsFactorial d := by\n  unfold IsFactorial DecidableIsFactorial\n  simp\n  constructor\n  · rintro ⟨k, hk⟩\n    use k\n    rw [Finset.mem_filter]\n    constructor\n    · have hk : k <= d := by\n        rw [← hk]\n        apply Nat.self_le_factorial\n      rw [Finset.mem_Icc]\n      exact ⟨Nat.zero_le k, hk⟩\n    · exact hk\n  · rintro ⟨k, hk⟩\n    use k\n    rw [Finset.mem_filter] at hk\n    exact hk.2\n\n@[category test, AMS 11]\nlemma factorialsLessThanN_equivalent (n : ℕ) :\n  factorialsLessThanN n = ↑(decidableFactorialsLessThanN n) := by\n  ext d\n  unfold factorialsLessThanN decidableFactorialsLessThanN\n  simp\n  exact λ _ => isFactorial_equivalent d\n\n@[category test, AMS 11]\nlemma allFactorialSubtractionsComposite_equivalent (d : ℕ) :\n    DecidableAllFactorialSubtractionsComposite d ↔ AllFactorialSubtractionsComposite d := by\n  unfold AllFactorialSubtractionsComposite DecidableAllFactorialSubtractionsComposite\n  rw [factorialsLessThanN_equivalent d]\n  simp\n\n@[category test, AMS 11]\ntheorem allFactorialSubtractionsComposite_101 : AllFactorialSubtractionsComposite 101 := by\n  have h : DecidableAllFactorialSubtractionsComposite 101 := by\n    norm_num [DecidableAllFactorialSubtractionsComposite, decidableFactorialsLessThanN]\n    decide +kernel\n  exact (allFactorialSubtractionsComposite_equivalent 101).mp h\n\n@[category test, AMS 11]\ntheorem allFactorialSubtractionsComposite_211 : AllFactorialSubtractionsComposite 211 := by\n  have h : DecidableAllFactorialSubtractionsComposite 211 := by\n    norm_num [DecidableAllFactorialSubtractionsComposite, decidableFactorialsLessThanN]\n    decide +kernel\n  exact (allFactorialSubtractionsComposite_equivalent 211).mp h\n\n@[category test, AMS 11]\ntheorem notAllFactorialSubtractionsComposite_89 : ¬(AllFactorialSubtractionsComposite 89) := by\n  have h : ¬(DecidableAllFactorialSubtractionsComposite 89) := by\n    unfold DecidableAllFactorialSubtractionsComposite decidableFactorialsLessThanN\n    intro h\n    specialize h 6\n    have : Nat.Prime (89 - 6) := by norm_num\n    contradiction\n  simp [allFactorialSubtractionsComposite_equivalent] at h\n  exact h\n\n@[category test, AMS 11]\ntheorem testFactorialsLessThanN : factorialsLessThanN 100 = {1, 2, 6, 24} := by\n  have h : decidableFactorialsLessThanN 100 = {1, 2, 6, 24} := by\n    norm_num [decidableFactorialsLessThanN]\n    decide +kernel\n  rw [factorialsLessThanN_equivalent]\n  simp [h]\n\nend Erdos1059\n",
  "statement_hash": "9a2ebf497ea12d89e86c1d18d90f9d33a56ba1758bc4d79386498b1833806770",
  "toolchain": "leanprover/lean4:v4.33.1",
  "upstream_commit": "f9b3868d5ca994a7bf95039bcec05338c0c21e2f",
  "workspace": "formal-conjectures",
  "field": "math",
  "formalization": "formal",
  "verification": "lean-kernel",
  "license": "Apache-2.0",
  "attribution": "google-deepmind/formal-conjectures contributors",
  "metric_name": null,
  "metric_direction": null,
  "critiques": [],
  "public_partial_proofs": [],
  "research_threads": [],
  "instructions": "Read research_threads first: other people's public repositories and what they already tried. Write Solution.lean starting from challenge_source. Keep every definition identical, prove decl_name with exactly the same type, no sorry in its dependency closure, no new axioms, no native_decide, no metaprogramming. Submit with POST /api/v1/submissions."
}