{
  "id": "2868",
  "ident": "NS.02868",
  "slug": "erdos-687",
  "title": "Erdős Problem 687",
  "status": "open",
  "statement_status": "reviewed",
  "statement_md": "Let $Y(x)$ be the maximal $y$ such that there exists a choice of congruence classes $a_p$ for\nall primes $p\\leq x$ such that every integer in $[1,y]$ is congruent to at least one of the\n$a_p\\pmod{p}$. Give good estimates for $Y(x)$.\n\nWe formalise this as determining $Y(x)$ up to constant factors.",
  "subjects": [
    "math.NT",
    "msc:11"
  ],
  "tags": [
    "question"
  ],
  "collection": "erdos",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "Erdos687.erdos_687.parts.i",
  "statement_lean": "theorem erdos_687.parts.i :\n    (fun x : ℕ ↦ (Y x : ℝ)) =Θ[atTop] erdos_687.parts.i.answer",
  "challenge_source": "/-\nCopyright 2026 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\npublic import FormalConjectures.GreensOpenProblems.«46»\n\n/-!\n# Erdős Problem 687\n\n*References:*\n- [erdosproblems.com/687](https://www.erdosproblems.com/687)\n- [Ben Green's Open Problem 46](https://people.maths.ox.ac.uk/greenbj/papers/open-problems.pdf#problem.46):\n  the same question; see `Green46` in `FormalConjectures.GreensOpenProblems.«46»`.\n- [OEIS A058989](https://oeis.org/A058989): the values $Y(p_n)$, where $p_n$ is the $n$-th prime.\n- [OEIS A048670](https://oeis.org/A048670): Jacobsthal's function of $\\prod_{p \\leq p_n} p$,\n  which is $Y(p_n) + 1$.\n- [Er79d] Erdős, P., *Some unconventional problems in number theory*. Acta Math. Acad. Sci.\n  Hungar. 33 (1979), 71-80.\n- [Er80] Erdős, Paul, *A survey of problems in combinatorial number theory*. Ann. Discrete Math.\n  6 (1980), 89-115.\n- [Er96b] Erdős, Paul, *Some problems I presented or planned to present in my short talk*.\n  Analytic number theory, Vol. 1 (Allerton Park, IL, 1995), Progr. Math. 138 (1996), 333-335.\n- [Iw78] Iwaniec, Henryk, *On the problem of Jacobsthal*. Demonstratio Math. 11 (1978), 225-232.\n  [doi:10.1515/dema-1978-0121](https://doi.org/10.1515/dema-1978-0121)\n- [MaPo90] Maier, Helmut and Pomerance, Carl, *Unusually large gaps between consecutive primes*.\n  Trans. Amer. Math. Soc. 322 (1990), 201-237.\n- [FGKMT18] Ford, Kevin and Green, Ben and Konyagin, Sergei and Maynard, James and Tao, Terence,\n  *Long gaps between primes*. J. Amer. Math. Soc. 31 (2018), 65-105.\n  [arXiv:1412.5029](https://arxiv.org/abs/1412.5029)\n- [OAI26a] OpenAI, *A quadratic bound for Jacobsthal's function*. OpenAI Math Release preprint\n  (2026).\n  https://github.com/openai/math/blob/adc7f1241b42e322a6451854ab7e4b4c146bf78a/preprints/A-quadratic-bound-for-Jacobsthals-function-September-25-2026/paper.pdf\n-/\n\n@[expose] public section\n\nopen Filter\n\nnamespace Erdos687\n\n/--\n`Y x` is $Y(x)$, the maximal $y$ such that there is a choice of congruence classes $a_p$, one\nfor each prime $p \\leq x$, such that every integer in $[1, y]$ is congruent to at least one of\nthe $a_p \\pmod{p}$. The covering condition is `Green46.IsCoveredByResidues x y`.\n\nWe take $x$ to be a natural number, since $Y(x)$ only depends on $\\lfloor x \\rfloor$. The set of\nsuch $y$ contains $0$ and is bounded by $\\prod_{p \\leq x} p$\n(`Erdos687.lt_primorial_of_isCoveredByResidues`), so `sSup` is its maximum. $Y(x) = 0$ for\n$x < 2$.\n-/\nnoncomputable def Y (x : ℕ) : ℕ :=\n  sSup {y : ℕ | Green46.IsCoveredByResidues x y}\n\n/-- `Green46.maxY` is `Y` cast to `ℝ`. -/\n@[category test, AMS 11]\ntheorem maxY_eq_Y (x : ℕ) : Green46.maxY x = Y x := rfl\n\n/-- If $[1, y]$ is covered by classes $a_p \\pmod{p}$, $p \\leq x$, then $y < \\prod_{p \\leq x} p$:\nby the Chinese remainder theorem some integer in $[1, \\prod_{p \\leq x} p]$ lies in none of the\nclasses. -/\n@[category test, AMS 11]\ntheorem lt_primorial_of_isCoveredByResidues {x y : ℕ} (h : Green46.IsCoveredByResidues x y) :\n    y < primorial x := by\n  obtain ⟨a, ha⟩ := h\n  refine lt_of_not_ge fun hy ↦ ?_\n  let t := (Finset.range (x + 1)).filter Nat.Prime\n  have hs : ∀ p ∈ t, (fun p : ℕ ↦ p) p ≠ 0 := fun p hp ↦ (Finset.mem_filter.1 hp).2.ne_zero\n  have pp : Set.Pairwise (t : Set ℕ) (Function.onFun Nat.Coprime fun p : ℕ ↦ p) :=\n    fun p hp q hq hpq ↦\n      (Nat.coprime_primes (Finset.mem_filter.1 hp).2 (Finset.mem_filter.1 hq).2).2 hpq\n  -- By the Chinese remainder theorem, `k ≡ a p + 1 (mod p)` for every prime `p ≤ x`.\n  let k := Nat.chineseRemainderOfFinset (fun p ↦ a p + 1) (fun p ↦ p) t hs pp\n  have hk : (k : ℕ) < primorial x := Nat.chineseRemainderOfFinset_lt_prod _ _ hs pp\n  -- Shift `k` into `[1, primorial x]` without changing its residues.\n  obtain ⟨m, hm1, hmP, hmk⟩ :\n      ∃ m, 1 ≤ m ∧ m ≤ primorial x ∧ ∀ p ∈ t, m ≡ k [MOD p] := by\n    by_cases h0 : (k : ℕ) = 0\n    · refine ⟨primorial x, primorial_pos x, le_rfl, fun p hp ↦ ?_⟩\n      have hp' := Finset.mem_filter.1 hp\n      rw [h0]\n      exact Nat.modEq_zero_iff_dvd.2\n        (hp'.2.dvd_primorial_iff.2 (Nat.lt_succ_iff.1 (Finset.mem_range.1 hp'.1)))\n    · exact ⟨k, Nat.one_le_iff_ne_zero.2 h0, hk.le, fun p _ ↦ Nat.ModEq.refl _⟩\n  obtain ⟨p, hpx, hp, hpm⟩ := ha m (Finset.mem_Icc.2 ⟨hm1, hmP.trans hy⟩)\n  have hpt : p ∈ t := Finset.mem_filter.2 ⟨Finset.mem_range.2 (Nat.lt_succ_of_le hpx), hp⟩\n  have h1 : a p ≡ a p + 1 [MOD p] := hpm.symm.trans ((hmk p hpt).trans (k.2 p hpt))\n  have hd : p ∣ 1 := by simpa using (Nat.modEq_iff_dvd' (Nat.le_add_right (a p) 1)).1 h1\n  exact hp.not_dvd_one hd\n\n/-- With the single prime $2$, one class covers $1$ but no class covers both $1$ and $2$, so\n$Y(2) = 1$. -/\n@[category test, AMS 11]\ntheorem Y_two : Y 2 = 1 := by\n  have h1 : Green46.IsCoveredByResidues 2 1 := by\n    refine ⟨fun _ ↦ 1, fun m hm ↦ ⟨2, le_rfl, Nat.prime_two, ?_⟩⟩\n    have := Finset.mem_Icc.1 hm\n    show m % 2 = 1 % 2\n    omega\n  have h2 : ∀ y, Green46.IsCoveredByResidues 2 y → y ≤ 1 := by\n    rintro y ⟨a, ha⟩\n    by_contra hy\n    obtain ⟨p, hp2, hp, hp1⟩ := ha 1 (Finset.mem_Icc.2 ⟨le_rfl, by omega⟩)\n    obtain ⟨q, hq2, hq, hq1⟩ := ha 2 (Finset.mem_Icc.2 ⟨by omega, by omega⟩)\n    rw [le_antisymm hp2 hp.two_le] at hp1\n    rw [le_antisymm hq2 hq.two_le] at hq1\n    exact absurd (hp1.trans hq1.symm) (by decide)\n  rw [Y]\n  exact IsGreatest.csSup_eq ⟨h1, h2⟩\n\n/-- The classes $1 \\pmod 2$ and $2 \\pmod 3$ cover $1, 2, 3$, but no choice of classes modulo\n$2$ and $3$ covers $1, 2, 3, 4$, so $Y(3) = 3$. -/\n@[category test, AMS 11]\ntheorem Y_three : Y 3 = 3 := by\n  have h1 : Green46.IsCoveredByResidues 3 3 := by\n    refine ⟨fun p ↦ if p = 2 then 1 else 2, fun m hm ↦ ?_⟩\n    obtain ⟨hm1, hm3⟩ := Finset.mem_Icc.1 hm\n    interval_cases m\n    · exact ⟨2, by norm_num, Nat.prime_two, by decide⟩\n    · exact ⟨3, le_rfl, Nat.prime_three, by decide⟩\n    · exact ⟨2, by norm_num, Nat.prime_two, by decide⟩\n  have h2 : ∀ y, Green46.IsCoveredByResidues 3 y → y ≤ 3 := by\n    rintro y ⟨a, ha⟩\n    by_contra hy\n    have key : ∀ m, 1 ≤ m → m ≤ 4 → m % 2 = a 2 % 2 ∨ m % 3 = a 3 % 3 := by\n      intro m hm1 hm4\n      obtain ⟨p, hp3, hp, hpm⟩ := ha m (Finset.mem_Icc.2 ⟨hm1, by omega⟩)\n      interval_cases p\n      · exact absurd hp (by decide)\n      · exact absurd hp (by decide)\n      · exact Or.inl hpm\n      · exact Or.inr hpm\n    have k1 := key 1 le_rfl (by norm_num)\n    have k2 := key 2 (by norm_num) (by norm_num)\n    have k3 := key 3 (by norm_num) (by norm_num)\n    have k4 := key 4 (by norm_num) le_rfl\n    omega\n  rw [Y]\n  exact IsGreatest.csSup_eq ⟨h1, h2⟩\n\ndef erdos_687.parts.i.answer : ℕ → ℝ := sorry\n\n/--\nLet $Y(x)$ be the maximal $y$ such that there exists a choice of congruence classes $a_p$ for\nall primes $p\\leq x$ such that every integer in $[1,y]$ is congruent to at least one of the\n$a_p\\pmod{p}$. Give good estimates for $Y(x)$.\n\nWe formalise this as determining $Y(x)$ up to constant factors.\n-/\n@[category research open, question value, AMS 11]\ntheorem erdos_687.parts.i :\n    (fun x : ℕ ↦ (Y x : ℝ)) =Θ[atTop] erdos_687.parts.i.answer := by\n  sorry\n\nset_option linter.style.formal_proof_palomar false in\n/--\nIn particular, can one prove that $Y(x)=o(x^2)$?\n\nYes: an internal OpenAI model proved $h(k) \\ll k^2$ for Jacobsthal's function $h$ [OAI26a]\n(see `Erdos970.erdos_970`). Since $Y(x) + 1$ is Jacobsthal's function of $\\prod_{p \\leq x} p$,\nwhich has $\\pi(x) \\ll x/\\log x$ prime factors, this gives $Y(x) \\ll x^2/(\\log x)^2$.\nThe linked Lean proof is by 30k30, from the bound of [OAI26a].\n-/\n@[category research solved, question, AMS 11, formal_proof using lean4 at\n  \"https://github.com/30k30/scholia/blob/b072c89c3edac06521868e32cc15b2bc91bd8533/erdos-687/glue/JacobsthalTo687.lean#L325\"]\ntheorem erdos_687.parts.ii :\n    (fun x : ℕ ↦ (Y x : ℝ)) =o[atTop] (fun x : ℕ ↦ (x : ℝ) ^ 2) := by\n  sorry\n\n/--\nOr, even stronger, can one prove that $Y(x)\\ll x^{1+o(1)}$?\n\nWe read $Y(x)\\ll x^{1+o(1)}$ as $Y(x) = O(x^{1+\\varepsilon})$ for every fixed\n$\\varepsilon > 0$.\n-/\n@[category research open, question, AMS 11]\ntheorem erdos_687.parts.iii :\n    ∀ ε > (0 : ℝ), (fun x : ℕ ↦ (Y x : ℝ)) =O[atTop] (fun x : ℕ ↦ (x : ℝ) ^ (1 + ε)) := by\n  sorry\n\n/--\nIwaniec's upper bound for Jacobsthal's function [Iw78] gives $Y(x) \\ll x^2$.\n-/\n@[category research solved, AMS 11]\ntheorem erdos_687.variants.iwaniec :\n    (fun x : ℕ ↦ (Y x : ℝ)) =O[atTop] (fun x : ℕ ↦ (x : ℝ) ^ 2) := by\n  sorry\n\n/--\nFord, Green, Konyagin, Maynard and Tao [FGKMT18] proved\n$$Y(x) \\gg \\frac{x \\log x \\log\\log\\log x}{\\log\\log x}.$$\n-/\n@[category research solved, AMS 11]\ntheorem erdos_687.variants.fgkmt :\n    (fun x : ℕ ↦ (x : ℝ) * Real.log x * Real.log (Real.log (Real.log x)) /\n      Real.log (Real.log x)) =O[atTop] (fun x : ℕ ↦ (Y x : ℝ)) := by\n  sorry\n\n/--\nMaier and Pomerance [MaPo90] conjectured that $Y(x) \\ll x(\\log x)^{2+o(1)}$ (in this form it is\nstated in [FGKMT18]).\n\nWe read this as $Y(x) = O(x(\\log x)^{2+\\varepsilon})$ for every fixed $\\varepsilon > 0$.\n-/\n@[category research open, AMS 11]\ntheorem erdos_687.variants.maier_pomerance :\n    ∀ ε > (0 : ℝ), (fun x : ℕ ↦ (Y x : ℝ)) =O[atTop]\n      (fun x : ℕ ↦ (x : ℝ) * Real.log x ^ (2 + ε)) := by\n  sorry\n\nend Erdos687\n",
  "statement_hash": "3356b4e7fca2269d2541e18a3a1f7752d39d05b739f7790fb8a23d893a5e3fb7",
  "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."
}