{
  "id": "2114",
  "ident": "NS.02114",
  "slug": "erdos-427",
  "title": "Erdős Problem 427",
  "status": "solved",
  "statement_status": "reviewed",
  "statement_md": "**Shiu's theorem**: for any $k \\geq 1$ and $(a, q) = 1$ there exist infinitely many $k$-tuples of consecutive primes\n$p_m, \\dots, p_{m + k - 1}$ all of which are congruent to $a$ modulo $q$.\n\nThis is stated ahead of `erdos_427` because the formal proof linked there assumes it, and the\n`assuming` clause must name a declaration that already exists.\n\n[Sh00] Shiu, D. K. L., _Strings of congruent primes_. J. London Math. Soc. (2) (2000), 359-373.",
  "subjects": [
    "math.NT",
    "msc:11"
  ],
  "tags": [],
  "collection": "erdos",
  "source_url": "https://www.erdosproblems.com/427",
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "Erdos427.erdos_427.variants.shiu",
  "statement_lean": "theorem erdos_427.variants.shiu : ShiuTheorem",
  "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 427\n\n*Reference:* [erdosproblems.com/427](https://www.erdosproblems.com/427)\n-/\n\n@[expose] public section\n\nnamespace Erdos427\n\n/--\nThe predicate that for every $n$ and $d$, there exists $k$ such that\n$$\n  d \\mid p_{n + 1} + \\cdots + p_{n + k},\n$$\nwhere $p_r$ denotes the $r$th prime?\n-/\ndef erdos427 : Prop := ∀ (n d : ℕ),\n    -- Need to allow `n = 0` since we're counting primes from `0` rather than `1`\n    -- `d` needs to be `≠ 0` since the sum is never `0`!\n    d ≠ 0 → ∃ k, k ≠ 0 ∧\n    d ∣ ∑ i ∈ Finset.Ico n (n + k), i.nth Nat.Prime\n\n/--\nThe statement of Shiu's theorem:\nfor any $k \\geq 1$ and $(a, q) = 1$ there exist infinitely many $k$-tuples of consecutive primes\n$p_m, \\dots, p_{m + k - 1}$ all of which are congruent to $a$ modulo $q$.\n\n[Sh00] Shiu, D. K. L., _Strings of congruent primes_. J. London Math. Soc. (2) (2000), 359-373.\n-/\ndef ShiuTheorem : Prop := ∀ (k a q : ℕ), 1 ≤ k → 1 ≤ q → a.gcd q = 1 →\n    { m : ℕ | ∀ p ∈ (Finset.Ico m (m + k)).image (Nat.nth Nat.Prime), p ≡ a [MOD q]}.Infinite\n\n\n/--\n**Shiu's theorem**: for any $k \\geq 1$ and $(a, q) = 1$ there exist infinitely many $k$-tuples of consecutive primes\n$p_m, \\dots, p_{m + k - 1}$ all of which are congruent to $a$ modulo $q$.\n\nThis is stated ahead of `erdos_427` because the formal proof linked there assumes it, and the\n`assuming` clause must name a declaration that already exists.\n\n[Sh00] Shiu, D. K. L., _Strings of congruent primes_. J. London Math. Soc. (2) (2000), 359-373.\n-/\n@[category research solved, AMS 11]\ntheorem erdos_427.variants.shiu : ShiuTheorem := by\n  sorry\n\n\nset_option linter.style.formal_proof_palomar false in\n/--\n**Erdős Problem 427**: is it true that, for every $n$ and $d$, there exists $k$ such that\n$$\n  d \\mid p_{n + 1} + \\cdots + p_{n + k},\n$$\nwhere $p_r$ denotes the $r$th prime?\n-/\n@[category research solved, question, AMS 11,\n  formal_proof using lean4 at\n    \"https://github.com/Jayyhk/erdos-lean/blob/main/problems/427/Erdos427.lean\"]\ntheorem erdos_427 : erdos427 := by\n  sorry\n\n\n/--\nCedric Pilatte has observed that a positive solution to Erdős Problem 427 follows from Shiu's theorem.\n-/\n@[category research solved, AMS 11]\ntheorem erdos_427.variants.of_shiu (H : ShiuTheorem) : erdos427 := by\n  intro n d hd\n  obtain ⟨m, hm, hnm⟩ := (H d 1 d (by omega) (by omega) (by simp)).exists_gt n\n  have hp : ∀ i < d, (m + i).nth Nat.Prime ≡ 1 [MOD d] := fun i hi =>\n    hm _ (Finset.mem_image.2 ⟨m + i, Finset.mem_Ico.2 ⟨by omega, by omega⟩, rfl⟩)\n  set S := ∑ i ∈ Finset.Ico n m, i.nth Nat.Prime\n  set j := d - S % d with hj\n  have hS := Nat.mod_lt S (by omega : 0 < d)\n  refine ⟨m - n + j, by omega, ?_⟩\n  have hsplit : ∑ i ∈ Finset.Ico n (n + (m - n + j)), i.nth Nat.Prime =\n      S + ∑ i ∈ Finset.range j, (m + i).nth Nat.Prime := by\n    rw [show n + (m - n + j) = m + j by omega,\n      ← Finset.sum_Ico_consecutive _ hnm.le (by omega : m ≤ m + j)]\n    congr 1\n    rw [Finset.sum_Ico_eq_sum_range, show m + j - m = j by omega]\n  have hmod : ∑ i ∈ Finset.range j, (m + i).nth Nat.Prime ≡ j [MOD d] := by\n    calc ∑ i ∈ Finset.range j, (m + i).nth Nat.Prime\n        ≡ ∑ i ∈ Finset.range j, 1 [MOD d] :=\n          Nat.ModEq.sum fun i hi => hp i (by have := Finset.mem_range.1 hi; omega)\n      _ = j := by simp\n  rw [hsplit, Nat.dvd_iff_mod_eq_zero, Nat.add_mod, hmod]\n  rcases Nat.eq_zero_or_pos (S % d) with h | h\n  · rw [hj, h, Nat.sub_zero, Nat.mod_self]\n    simp\n  · rw [Nat.mod_eq_of_lt (by omega : j < d), hj, show S % d + (d - S % d) = d by omega,\n      Nat.mod_self]\n\nend Erdos427\n",
  "statement_hash": "cb8da4a5f81e837e4bb810feaa429e19203a97161418633b7efceb7e4923f94f",
  "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."
}