{
  "id": "8524",
  "ident": "NS.08524",
  "slug": "wikipedia-sternprime",
  "title": "Stern Primes",
  "status": "open",
  "statement_status": "reviewed",
  "statement_md": "Is the set of Stern primes finite? Euler's representation heuristic suggests that only finitely\nmany primes avoid the form $p + 2 b^2$.",
  "subjects": [
    "math.NT",
    "msc:11"
  ],
  "tags": [
    "question"
  ],
  "collection": "wikipedia",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "SternPrime.stern_primes_finite",
  "statement_lean": "theorem stern_primes_finite : {q : ℕ | IsSternPrime q}.Finite",
  "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\n\n/-!\n# Stern Primes\n\nAs recounted by Laurent Hodges (1993), Christian Goldbach proposed in a 1752 letter to Euler that\nevery odd integer greater than $1$ equals $p + 2 b^2$ with $b \\ge 0$ (counting $1$ as prime); for\nmodern primes, its nontrivial content is the *Goldbach–Stern conjecture* that every odd composite\nequals $p + 2 b^2$ with $p$ prime and $b \\ge 1$. Moritz Abraham Stern (1856) refuted this via the\ncounterexamples $5777$ and $5993$ (`OEIS A060003`).\n\nA prime $q$ admitting no decomposition $q = p + 2 b^2$ with $p$ prime and $b \\ge 1$ is called a\n*Stern prime* (`OEIS A042978`). Only eight examples are known ($2, 3, 17, 137, 227, 977, 1187$, and\n$1493$); Euler noted heuristically that larger primes acquire more decompositions $p + 2 b^2$,\nsuggesting that Stern primes form a finite set and that $1493$ may be the largest.\n\n*References:*\n- [Wikipedia](https://en.wikipedia.org/wiki/Stern_prime)\n- [OEIS A042978](https://oeis.org/A042978)\n- M. A. Stern, *Sur une assertion de Goldbach relative aux nombres impairs*, Nouv. Ann. Math.\n  **15** (1856), 23–24.\n- L. Hodges, *A lesser-known Goldbach conjecture*, Math. Mag. **66** (1993), no. 1, 45–47.\n-/\n\n@[expose] public section\n\nnamespace SternPrime\n\n/-- Predicate asserting that $n = p + 2 b^2$ for some prime $p$ and integer $b \\ge 1$. -/\ndef HasPrimePlusTwiceSquare (n : ℕ) : Prop :=\n  ∃ p b : ℕ, p.Prime ∧ 1 ≤ b ∧ n = p + 2 * b ^ 2\n\n/-- Predicate asserting that $q$ is prime and fails `HasPrimePlusTwiceSquare`. -/\ndef IsSternPrime (q : ℕ) : Prop :=\n  q.Prime ∧ ¬ HasPrimePlusTwiceSquare q\n\ninstance (n : ℕ) : Decidable (HasPrimePlusTwiceSquare n) :=\n  decidable_of_iff (∃ b < n.sqrt + 1, 1 ≤ b ∧ 2 * b ^ 2 < n ∧ (n - 2 * b ^ 2).Prime) <| by\n    unfold HasPrimePlusTwiceSquare\n    constructor\n    · rintro ⟨b, _, hb, hlt, hp⟩\n      exact ⟨n - 2 * b ^ 2, b, hp, hb, by omega⟩\n    · rintro ⟨p, b, hp, hb, rfl⟩\n      have hp_pos : 0 < p := hp.pos\n      have hb_sqrt : b ≤ (p + 2 * b ^ 2).sqrt := Nat.le_sqrt.mpr (by nlinarith)\n      exact ⟨b, by omega, hb, by omega, by simpa using hp⟩\n\ninstance (q : ℕ) : Decidable (IsSternPrime q) :=\n  inferInstanceAs (Decidable (q.Prime ∧ ¬ HasPrimePlusTwiceSquare q))\n\n/-- Verifies that all eight known examples $2, 3, 17, 137, 227, 977, 1187, 1493$ are Stern\nprimes. -/\n@[category test, AMS 11]\ntheorem isSternPrime_known_examples :\n    ∀ q ∈ ([2, 3, 17, 137, 227, 977, 1187, 1493] : List ℕ), IsSternPrime q := by\n  decide +kernel\n\n/-- Checks that $5 = 3 + 2 \\cdot 1^2$ and $11 = 3 + 2 \\cdot 2^2$ satisfy `HasPrimePlusTwiceSquare`\nand hence are not Stern primes. -/\n@[category test, AMS 11]\ntheorem not_isSternPrime_five_and_eleven :\n    HasPrimePlusTwiceSquare 5 ∧ HasPrimePlusTwiceSquare 11 ∧\n      ¬ IsSternPrime 5 ∧ ¬ IsSternPrime 11 := by\n  have h5 : HasPrimePlusTwiceSquare 5 := ⟨3, 1, by norm_num, by omega, by norm_num⟩\n  have h11 : HasPrimePlusTwiceSquare 11 := ⟨3, 2, by norm_num, by omega, by norm_num⟩\n  exact ⟨h5, h11, fun h => h.2 h5, fun h => h.2 h11⟩\n\n/--\nIs the set of Stern primes finite? Euler's representation heuristic suggests that only finitely\nmany primes avoid the form $p + 2 b^2$.\n-/\n@[category research open, question, AMS 11]\ntheorem stern_primes_finite : {q : ℕ | IsSternPrime q}.Finite := by\n  sorry\n\n/--\nDoes $\\{2, 3, 17, 137, 227, 977, 1187, 1493\\}$ exhaust all Stern primes? No ninth example appears\namong the first $100{,}000$ primes (McCranie) or below $2 \\times 10^{13}$ (Chaffin, `OEIS A042978`).\n-/\n@[category research open, question, AMS 11]\ntheorem isSternPrime_iff :\n    ∀ q : ℕ, IsSternPrime q ↔ q ∈ ({2, 3, 17, 137, 227, 977, 1187, 1493} : Set ℕ) := by\n  sorry\n\nend SternPrime\n",
  "statement_hash": "217f4f483e10105ae17a890eb1ef1e85a91e7b2943cb7ffc4136225993470eff",
  "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."
}