{
  "id": "2095",
  "ident": "NS.02095",
  "slug": "erdos-423",
  "title": "Erdős Problem 423",
  "status": "open",
  "statement_status": "reviewed",
  "statement_md": "Erdős Problem 423 [Er77c, p.71; ErGr80, p.83]:\n\nLet $a(1) = 1$, $a(2) = 2$, and for $k \\ge 3$ let $a(k)$ be the least integer greater\nthan $a(k-1)$ that is a sum of at least two consecutive terms of the sequence.\nWhat is the asymptotic behaviour of this sequence? It seems likely that $a_n = n + o(n)$.",
  "subjects": [
    "math.CO",
    "math.NT",
    "msc:05",
    "msc:11"
  ],
  "tags": [
    "question"
  ],
  "collection": "erdos",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "Erdos423.erdos_423",
  "statement_lean": "theorem erdos_423 :\n    ∀ a : ℕ → ℕ, IsHofstadterSeq a →\n    (fun n : ℕ => (a n : ℝ) - n) =o[atTop] (fun n : ℕ => (n : ℝ))",
  "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 423\n\n*References:*\n- [erdosproblems.com/423](https://www.erdosproblems.com/423)\n- [Er77c] Erdős, P., *Problems and results on combinatorial number theory. III*,\n  Number theory day (Proc. Conf., Rockefeller Univ., New York, 1976), 1977, pp. 43–72.\n- [ErGr80] Erdős, P. and Graham, R., *Old and new problems and results in combinatorial\n  number theory*, Monographies de L'Enseignement Mathématique (1980).\n- [Cu25] Cushman, A., *A Note on the Sum-Product Problem and the Convex Sumset Problem*.\n  arXiv:2512.13849 (2025).\n- [Ta26] Tang, Q., *The Hofstadter consecutive-sum sequence omits infinitely many positive\n  integers*. arXiv:2603.09939 (2026).\n- [Bolan] Bolan, M., *Hofstader–Ulam Sequence*,\n  https://github.com/mjtb49/HofstaderUlam/blob/main/HofstaderUlamSequence.pdf\n- [OEIS A005243](https://oeis.org/A005243)\n-/\n\n@[expose] public section\n\nopen Finset BigOperators Filter Asymptotics\n\nnamespace Erdos423\n\n/-- `IsConsecutiveBlockSum a k m` means that $m$ equals the sum of at least two\n    consecutive terms of the sequence $a$, using indices from $\\{1, \\ldots, k - 1\\}$.\n    That is, there exist $i, j$ with $1 \\le i$, $i + 1 \\le j$, $j \\le k - 1$ such that\n    $m = a(i) + a(i+1) + \\cdots + a(j)$. -/\ndef IsConsecutiveBlockSum (a : ℕ → ℕ) (k : ℕ) (m : ℕ) : Prop :=\n  ∃ i j : ℕ, 1 ≤ i ∧ i + 1 ≤ j ∧ j + 1 ≤ k ∧\n    m = ∑ l ∈ Finset.Icc i j, a l\n\n/-- The Hofstadter sequence (OEIS A005243): $a(1) = 1$, $a(2) = 2$, and for $k \\ge 3$,\n$a(k)$ is the least integer $> a(k-1)$ that equals the sum of at least two consecutive terms from\n$\\{a(1), \\ldots, a(k-1)\\}$. The sequence begins $1, 2, 3, 5, 6, 8, 10, 11, \\ldots$. -/\ndef IsHofstadterSeq (a : ℕ → ℕ) : Prop :=\n  a 1 = 1 ∧ a 2 = 2 ∧\n  ∀ k : ℕ, 3 ≤ k →\n    IsConsecutiveBlockSum a k (a k) ∧\n    a (k - 1) < a k ∧\n    ∀ m : ℕ, a (k - 1) < m → m < a k → ¬IsConsecutiveBlockSum a k m\n\n/-- The third term of the Hofstadter sequence is $a(3) = 3 = a(1) + a(2) = 1 + 2$. -/\n@[category test, AMS 5 11]\ntheorem erdos_423.test.a3 : ∀ a : ℕ → ℕ, IsHofstadterSeq a → a 3 = 3 := by\n  intro a ⟨ha1, ha2, hk⟩\n  obtain ⟨⟨i, j, hi, hij, hjk, hsum⟩, _, _⟩ := hk 3 (by omega)\n  have : i = 1 ∧ j = 2 := by omega\n  obtain ⟨rfl, rfl⟩ := this\n  simp only [show Finset.Icc 1 2 = {1, 2} from by decide,\n    Finset.sum_pair (show (1 : ℕ) ≠ 2 from by decide), ha1, ha2] at hsum\n  omega\n\n/-- The fourth term of the Hofstadter sequence is $a(4) = 5 = a(2) + a(3) = 2 + 3$. -/\n@[category test, AMS 5 11]\ntheorem erdos_423.test.a4 : ∀ a : ℕ → ℕ, IsHofstadterSeq a → a 4 = 5 := by\n  intro a ⟨ha1, ha2, hk⟩\n  have ha3 : a 3 = 3 := erdos_423.test.a3 a ⟨ha1, ha2, hk⟩\n  obtain ⟨⟨i, j, hi, hij, hjk, hsum⟩, hlt, hmin⟩ := hk 4 (by omega)\n  -- Since `j ≤ 3`, the possible pairs `(i, j)` are `(1, 2)`, `(2, 3)`, and `(1, 3)`.\n  have h_ij : (i = 1 ∧ j = 2) ∨ (i = 2 ∧ j = 3) ∨ (i = 1 ∧ j = 3) := by omega\n  rcases h_ij with ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩\n  · simp only [show Finset.Icc 1 2 = {1, 2} from by decide,\n      Finset.sum_pair (by decide : (1 : ℕ) ≠ 2), ha1, ha2] at hsum\n    rw [ha3] at hlt\n    omega\n  · simp only [show Finset.Icc 2 3 = {2, 3} from by decide,\n      Finset.sum_pair (by decide : (2 : ℕ) ≠ 3), ha2, ha3] at hsum\n    omega\n  · rw [show Finset.Icc 1 3 = {1, 2, 3} from by decide,\n      Finset.sum_insert (by decide : (1 : ℕ) ∉ ({2, 3} : Finset ℕ)),\n      Finset.sum_pair (by decide : (2 : ℕ) ≠ 3), ha1, ha2, ha3] at hsum\n    rw [ha3] at hlt\n    have ha4_eq : a 4 = 6 := by omega\n    have h3_lt_5 : a 3 < 5 := by omega\n    have h5_lt_a4 : 5 < a 4 := by omega\n    exfalso\n    apply hmin 5 h3_lt_5 h5_lt_a4\n    refine ⟨2, 3, by omega, by omega, by omega, ?_⟩\n    rw [show Finset.Icc 2 3 = {2, 3} from by decide,\n      Finset.sum_pair (by decide : (2 : ℕ) ≠ 3), ha2, ha3]\n\n/--\nErdős Problem 423 [Er77c, p.71; ErGr80, p.83]:\n\nLet $a(1) = 1$, $a(2) = 2$, and for $k \\ge 3$ let $a(k)$ be the least integer greater\nthan $a(k-1)$ that is a sum of at least two consecutive terms of the sequence.\nWhat is the asymptotic behaviour of this sequence? It seems likely that $a_n = n + o(n)$.\n-/\n@[category research open, question, AMS 5 11]\ntheorem erdos_423 :\n    ∀ a : ℕ → ℕ, IsHofstadterSeq a →\n    (fun n : ℕ => (a n : ℝ) - n) =o[atTop] (fun n : ℕ => (n : ℝ)) := by\n  sorry\n\n/--\nBolan and Tang [Ta26] independently proved that $a_n-n$ is nondecreasing.\n-/\n@[category research solved, AMS 5 11]\ntheorem erdos_423.variants.nondecreasing :\n    ∀ a : ℕ → ℕ, IsHofstadterSeq a →\n    ∀ n m : ℕ, 1 ≤ n → n ≤ m → a n - n ≤ a m - m := by\n  intro a ⟨ha1, ha2, hk⟩ n m hn hnm\n  have step : ∀ k, 1 ≤ k → a k + 1 ≤ a (k + 1) := by\n    intro k hk1\n    rcases Nat.lt_or_ge k 2 with h | h\n    · obtain rfl : k = 1 := by omega\n      rw [ha1, ha2]\n    · simpa using (hk (k + 1) (by omega)).2.1\n  have ge : ∀ k, 1 ≤ k → k ≤ a k := by\n    intro k hk1\n    induction k with\n    | zero => omega\n    | succ j ih =>\n      rcases Nat.eq_zero_or_pos j with rfl | hj\n      · simp [ha1]\n      · have := step j hj; have := ih hj; omega\n  induction m, hnm using Nat.le_induction with\n  | base => exact le_rfl\n  | succ m hnm ih =>\n    have h1 := step m (by omega)\n    have h2 := ge m (by omega)\n    omega\n\n/--\nBolan and Tang [Ta26] independently proved that $a_n-n\\to\\infty$.\n-/\n@[category research solved, AMS 5 11]\ntheorem erdos_423.variants.unbounded :\n    ∀ a : ℕ → ℕ, IsHofstadterSeq a →\n    ∀ M : ℕ, ∀ᶠ n in atTop, M + n ≤ a n := by\n  sorry\n\n/--\nBolan and Tang [Ta26] independently proved that infinitely many positive integers do not occur in\nthe Hofstadter sequence.\n-/\n@[category research solved, AMS 5 11]\ntheorem erdos_423.variants.infinite_complement :\n    ∀ a : ℕ → ℕ, IsHofstadterSeq a → Set.Infinite (Set.range a)ᶜ := by\n  sorry\n\n/-- A Hofstadter sequence is strictly increasing from index `1` on. -/\n@[category API, AMS 5 11]\ntheorem IsHofstadterSeq.strictMono {a : ℕ → ℕ} (ha : IsHofstadterSeq a) :\n    StrictMono fun k => a (k + 1) := by\n  obtain ⟨h1, h2, hk⟩ := ha\n  refine strictMono_nat_of_lt_succ fun k => ?_\n  show a (k + 1) < a (k + 1 + 1)\n  rcases Nat.eq_zero_or_pos k with rfl | hpos\n  · show a 1 < a 2\n    omega\n  · have := (hk (k + 2) (by omega)).2.1\n    simpa using this\n\n/-- A Hofstadter sequence satisfies `n ≤ a n` for `n ≥ 1`. -/\n@[category API, AMS 5 11]\ntheorem IsHofstadterSeq.le_apply {a : ℕ → ℕ} (ha : IsHofstadterSeq a) (n : ℕ)\n    (hn : 1 ≤ n) : n ≤ a n := by\n  have h1 := ha.1\n  induction n, hn using Nat.le_induction with\n  | base => omega\n  | succ k hk ih =>\n    have := (IsHofstadterSeq.strictMono ha) (Nat.lt_succ_self (k - 1))\n    simp only [show k - 1 + 1 = k by omega, show k - 1 + 1 + 1 = k + 1 by omega] at this\n    omega\n\n/-- For indices `≥ 1`, a Hofstadter sequence preserves and reflects `<`. -/\n@[category API, AMS 5 11]\ntheorem IsHofstadterSeq.lt_iff_lt {a : ℕ → ℕ} (ha : IsHofstadterSeq a) {i j : ℕ}\n    (hi : 1 ≤ i) (hj : 1 ≤ j) :\n    a i < a j ↔ i < j := by\n  obtain ⟨i, rfl⟩ := Nat.exists_eq_add_of_le' hi\n  obtain ⟨j, rfl⟩ := Nat.exists_eq_add_of_le' hj\n  rw [(IsHofstadterSeq.strictMono ha).lt_iff_lt]\n  omega\n\n/-- If `a n - n` is unbounded, infinitely many integers are missed: when `a n ≥ N + 2 + n`,\nthe `n` values `a 0, …, a (n - 1)` cannot cover the `n + 1` integers in `[N + 1, a n - 1]`, and\nlater terms are too large. -/\n@[category API, AMS 5 11]\ntheorem IsHofstadterSeq.infinite_compl_of_unbounded {a : ℕ → ℕ} (ha : IsHofstadterSeq a)\n    (h : ∀ M : ℕ, ∀ᶠ n in atTop, M + n ≤ a n) : Set.Infinite (Set.range a)ᶜ := by\n  refine Set.infinite_of_forall_exists_gt fun N => ?_\n  obtain ⟨n, hn⟩ := (h (N + 2)).exists_forall_of_atTop\n  obtain ⟨n, hn1, hn⟩ : ∃ n, 1 ≤ n ∧ N + 2 + n ≤ a n :=\n    ⟨max n 1, by omega, hn _ (le_max_left _ _)⟩\n  -- The `n` values `a 0, …, a (n - 1)` cannot cover the `n + 1` integers in `[N + 1, a n - 1]`.\n  have hcard : ((Finset.range n).image a).card < (Finset.Icc (N + 1) (a n - 1)).card := by\n    calc ((Finset.range n).image a).card ≤ n := by\n          simpa using Finset.card_image_le (s := Finset.range n) (f := a)\n      _ < (Finset.Icc (N + 1) (a n - 1)).card := by simp; omega\n  obtain ⟨x, hx, hxi⟩ := Finset.exists_mem_notMem_of_card_lt_card hcard\n  rw [Finset.mem_Icc] at hx\n  refine ⟨x, ?_, by omega⟩\n  rintro ⟨k, rfl⟩\n  rcases Nat.lt_or_ge k n with hk | hk\n  · exact hxi (Finset.mem_image.2 ⟨k, Finset.mem_range.2 hk, rfl⟩)\n  · have : a n ≤ a k := by\n      rcases eq_or_lt_of_le hk with rfl | hk'\n      · exact le_rfl\n      · exact ((IsHofstadterSeq.lt_iff_lt ha hn1 (by omega)).2 hk').le\n    omega\n\n/-- If infinitely many integers are missed, `a n - n` is unbounded: `M + 1` missed integers\nbelow `n` together with `a 1, …, a n` are distinct elements of `[1, a n]`. -/\n@[category API, AMS 5 11]\ntheorem IsHofstadterSeq.unbounded_of_infinite_compl {a : ℕ → ℕ} (ha : IsHofstadterSeq a)\n    (h : Set.Infinite (Set.range a)ᶜ) : ∀ M : ℕ, ∀ᶠ n in atTop, M + n ≤ a n := by\n  intro M\n  obtain ⟨t, hts, htc⟩ := h.exists_subset_card_eq (M + 1)\n  -- All missed values in `t` are at most `X`.\n  set X := t.sup id with hX\n  rw [Filter.eventually_atTop]\n  refine ⟨X + 1, fun n hn => ?_⟩\n  have hn1 : 1 ≤ n := by omega\n  -- `a 1, …, a n` and the positive elements of `t` are distinct integers in `[1, a n]`.\n  set A := (Finset.Icc 1 n).image a with hA\n  set T := t.filter (fun x => 1 ≤ x) with hT\n  have hAcard : A.card = n := by\n    rw [hA, Finset.card_image_of_injOn, Nat.card_Icc]\n    · omega\n    · intro i hi j hj hij\n      rw [Finset.coe_Icc, Set.mem_Icc] at hi hj\n      by_contra hne\n      rcases Nat.lt_or_gt_of_ne hne with hlt | hlt\n      · exact absurd hij ((IsHofstadterSeq.lt_iff_lt ha hi.1 hj.1).2 hlt).ne\n      · exact absurd hij.symm ((IsHofstadterSeq.lt_iff_lt ha hj.1 hi.1).2 hlt).ne\n  have hTcard : M ≤ T.card := by\n    have : (t.filter (fun x => ¬ 1 ≤ x)).card ≤ 1 := by\n      calc (t.filter (fun x => ¬ 1 ≤ x)).card ≤ ({0} : Finset ℕ).card :=\n            Finset.card_le_card fun x hx => by\n              rw [Finset.mem_filter] at hx; simp; omega\n        _ = 1 := rfl\n    have := Finset.card_filter_add_card_filter_not (s := t) (fun x => 1 ≤ x)\n    rw [← hT] at this\n    omega\n  have hdisj : Disjoint A T := by\n    rw [Finset.disjoint_left]\n    intro x hxA hxT\n    obtain ⟨k, -, rfl⟩ := Finset.mem_image.1 hxA\n    exact hts (Finset.mem_filter.1 hxT).1 ⟨k, rfl⟩\n  have hsub : A ∪ T ⊆ Finset.Icc 1 (a n) := by\n    intro x hx\n    rw [Finset.mem_union] at hx\n    rw [Finset.mem_Icc]\n    rcases hx with hx | hx\n    · obtain ⟨k, hk, rfl⟩ := Finset.mem_image.1 hx\n      rw [Finset.mem_Icc] at hk\n      refine ⟨IsHofstadterSeq.le_apply ha k hk.1 |>.trans' (by omega), ?_⟩\n      rcases eq_or_lt_of_le hk.2 with rfl | hlt\n      · exact le_rfl\n      · exact ((IsHofstadterSeq.lt_iff_lt ha hk.1 hn1).2 hlt).le\n    · obtain ⟨hxt, hx1⟩ := Finset.mem_filter.1 hx\n      have : x ≤ X := Finset.le_sup (f := id) hxt\n      exact ⟨hx1, by have := IsHofstadterSeq.le_apply ha n hn1; omega⟩\n  have := Finset.card_le_card hsub\n  rw [Finset.card_union_of_disjoint hdisj, hAcard, Nat.card_Icc] at this\n  omega\n\n/-- The unboundedness of $a_n-n$ is equivalent to the sequence omitting infinitely many positive\nintegers. -/\n@[category test, AMS 5 11]\ntheorem erdos_423.test.unbounded_iff_infinite_complement :\n    type_of% erdos_423.variants.unbounded ↔\n      type_of% erdos_423.variants.infinite_complement :=\n  ⟨fun h a ha => ha.infinite_compl_of_unbounded (h a ha),\n   fun h a ha => ha.unbounded_of_infinite_compl (h a ha)⟩\n\n/--\nTang [Ta26] proved $a_n \\ll n^{1/(c-1)+o(1)}$ whenever every finite convex set $A$ satisfies\n$|A-A|\\geq |A|^{c-o(1)}$. Using the bound of Cushman [Cu25] gives\n$a_n\\ll n^{688/413+o(1)}$.\n-/\n@[category research solved, AMS 5 11]\ntheorem erdos_423.variants.upper_bound :\n    ∀ a : ℕ → ℕ, IsHofstadterSeq a →\n    ∀ ε > (0 : ℝ), (fun n => (a n : ℝ)) =O[atTop]\n      (fun n => (n : ℝ) ^ ((688 : ℝ) / 413 + ε)) := by\n  sorry\n\n/--\nTang [Ta26] proved the lower bound $a_n=n+\\Omega(\\log\\log n)$.\n-/\n@[category research solved, AMS 5 11]\ntheorem erdos_423.variants.lower_bound :\n    ∀ a : ℕ → ℕ, IsHofstadterSeq a →\n    (fun n : ℕ => Real.log (Real.log n)) =O[atTop]\n      (fun n : ℕ => (a n : ℝ) - n) := by\n  sorry\n\nend Erdos423\n",
  "statement_hash": "de759a5ecce6be862d9e22869cad78217f004ebd5d81af177206dfda242e4231",
  "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."
}