{
  "id": "1778",
  "ident": "NS.01778",
  "slug": "erdos-342",
  "title": "Erdős Problem 342",
  "status": "open",
  "statement_status": "reviewed",
  "statement_md": "Do infinitely many pairs $(a, a+2)$ occur in Ulam's sequence?",
  "subjects": [
    "math.CO",
    "math.NT",
    "math.CA",
    "msc:05",
    "msc:11",
    "msc:40"
  ],
  "tags": [
    "question"
  ],
  "collection": "erdos",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "Erdos342.erdos_342.parts.i",
  "statement_lean": "theorem erdos_342.parts.i :\n    ∀ a : ℕ → ℕ, IsUlamSequence a →\n      Set.Infinite {n : ℕ | ∃ m, a m = a n + 2}",
  "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# Erdős Problem 342\n\n*References:*\n- [erdosproblems.com/342](https://www.erdosproblems.com/342)\n- [Ben Green's Open Problem 7](https://people.maths.ox.ac.uk/greenbj/papers/open-problems.pdf#problem.7)\n- [OEIS A002858](https://oeis.org/A002858)\n- [Gu04] Guy, Richard K., *Unsolved problems in number theory* (2004), xviii+437.\n-/\n\n@[expose] public section\n\nopen Nat Set Filter\nopen scoped Topology\n\nnamespace Erdos342\n\n/-- `UniqueUlamSum a n m` means that $m$ has a unique representation as $a(i) + a(j)$\nwith $i < j < n$. -/\ndef UniqueUlamSum (a : ℕ → ℕ) (n m : ℕ) : Prop :=\n  ∃! p : ℕ × ℕ, p.1 < p.2 ∧ p.2 < n ∧ m = a p.1 + a p.2\n\n/-- `IsUlamSequence a` means that $a$ is the Ulam sequence (OEIS A002858):\n$a(0) = 1$, $a(1) = 2$, and for each $n \\geq 2$, $a(n)$ is the least integer\ngreater than $a(n-1)$ that has a unique representation as $a(i) + a(j)$\nwith $i < j < n$. -/\ndef IsUlamSequence (a : ℕ → ℕ) : Prop :=\n  a 0 = 1 ∧ a 1 = 2 ∧\n  ∀ n, 2 ≤ n →\n    a (n - 1) < a n ∧\n    UniqueUlamSum a n (a n) ∧\n    ∀ m, a (n - 1) < m → m < a n → ¬ UniqueUlamSum a n m\n\n/-- $a(0) = 1$ by definition. -/\n@[category test, AMS 5 11 40]\ntheorem erdos_342.test.a0 : ∀ a : ℕ → ℕ, IsUlamSequence a → a 0 = 1 := by\n  intro a ⟨ha0, _, _⟩; exact ha0\n\n/-- $a(1) = 2$ by definition. -/\n@[category test, AMS 5 11 40]\ntheorem erdos_342.test.a1 : ∀ a : ℕ → ℕ, IsUlamSequence a → a 1 = 2 := by\n  intro a ⟨_, ha1, _⟩; exact ha1\n\n/-- $a(2) = 3$: the only pair $(i,j)$ with $i < j < 2$ is $(0,1)$, giving $1 + 2 = 3$. -/\n@[category test, AMS 5 11 40]\ntheorem erdos_342.test.a2 : ∀ a : ℕ → ℕ, IsUlamSequence a → a 2 = 3 := by\n  intro a ⟨ha0, ha1, ha⟩\n  obtain ⟨_, ⟨⟨i, j⟩, ⟨hij, hj, hsum⟩, _⟩, _⟩ := ha 2 (by omega)\n  interval_cases j <;> simp_all only [lt_one_iff, not_lt_zero]\n\n/-- $a(3) = 4$: among sums $> 3$ with a unique representation from $\\{1,2,3\\}$,\nthe smallest is $4 = 1 + 3$. The candidate $5 = 2 + 3$ is ruled out by minimality since\n$4$ has a unique representation. -/\n@[category test, AMS 5 11 40]\ntheorem erdos_342.test.a3 : ∀ a : ℕ → ℕ, IsUlamSequence a → a 3 = 4 := by\n  intro a ⟨ha0, ha1, ha⟩\n  have ha2 := erdos_342.test.a2 a ⟨ha0, ha1, ha⟩\n  obtain ⟨hinc, ⟨⟨i, j⟩, ⟨hij, hj, hsum⟩, _⟩, hmin⟩ := ha 3 (by omega)\n  simp only [show (3 : ℕ) - 1 = 2 from rfl] at hinc hmin\n  -- hinc : a 2 < a 3, hmin : ∀ m, a 2 < m → m < a 3 → ¬UniqueUlamSum a 3 m\n  -- hsum : a 3 = a i + a j, hij : i < j, hj : j < 3\n  -- Enumerate j ∈ {0, 1, 2}\n  interval_cases j\n  · -- j = 0: i < 0 impossible\n    omega\n  · -- j = 1: i = 0, so a 3 = a 0 + a 1 = 1 + 2 = 3, but a 3 > a 2 = 3\n    have hi : i = 0 := by omega\n    subst hi; rw [ha0, ha1] at hsum; rw [ha2] at hinc; omega\n  · -- j = 2\n    interval_cases i\n    · -- i = 0: a 3 = a 0 + a 2 = 1 + 3 = 4\n      rw [ha0, ha2] at hsum; exact hsum\n    · -- i = 1: a 3 = a 1 + a 2 = 2 + 3 = 5\n      rw [ha1, ha2] at hsum\n      -- hsum : a 3 = 5. Use minimality: m = 4 has unique sum, contradiction.\n      exfalso\n      have h4 := hmin 4 (by rw [ha2]; omega) (by omega)\n      apply h4\n      -- Goal: UniqueUlamSum a 3 4, i.e. ∃! (p : ℕ × ℕ), p.1 < p.2 ∧ p.2 < 3 ∧ 4 = a p.1 + a p.2\n      -- Witness: (0, 2) since a 0 + a 2 = 1 + 3 = 4\n      refine ⟨⟨0, 2⟩, ⟨by omega, by omega, by rw [ha0, ha2]⟩, ?_⟩\n      -- Uniqueness: check all pairs (i', j') with i' < j' < 3\n      rintro ⟨i', j'⟩ ⟨hij', hj', hsum'⟩\n      simp only [Prod.mk.injEq]\n      interval_cases j'\n      · omega\n      · interval_cases i'\n        · rw [ha0, ha1] at hsum'; omega\n      · interval_cases i'\n        · rw [ha0, ha2] at hsum'; constructor <;> omega\n        · rw [ha1, ha2] at hsum'; omega\n\n/--\nDo infinitely many pairs $(a, a+2)$ occur in Ulam's sequence? -/\n@[category research open, question, AMS 5 11 40]\ntheorem erdos_342.parts.i :\n    ∀ a : ℕ → ℕ, IsUlamSequence a →\n      Set.Infinite {n : ℕ | ∃ m, a m = a n + 2} := by\n  sorry\n\n/--\nDoes Ulam's sequence eventually have periodic differences? That is, is $a(n+1) - a(n)$ eventually periodic?\n-/\n@[category research open, question, AMS 5 11 40]\ntheorem erdos_342.parts.ii :\n    ∀ a : ℕ → ℕ, IsUlamSequence a →\n      let d (n : ℕ) : ℤ := a (n + 1) - a n\n      ∃ p > 0, ∀ᶠ m in atTop, d (m + p) = d m := by\n  sorry\n\n/--\nPart (iii), is the density of the sequence 0?\n-/\n@[category research open, question, AMS 5 11 40]\ntheorem erdos_342.parts.iii :\n    ∀ a : ℕ → ℕ, IsUlamSequence a →\n      Set.upperDensity (Set.range a) = 0 := by\n  sorry\n\nend Erdos342\n",
  "statement_hash": "bdc39077ae8b0301bdb9b31d3fb42862e0f6952130ad2c2b2a85d1ac5b6bc8b4",
  "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."
}