/- Copyright 2026 The Formal Conjectures Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -/ module public import FormalConjecturesUtil

Erdős Problem 423

References:

    erdosproblems.com/423

    [Er77c] Erdős, P., Problems and results on combinatorial number theory. III, Number theory day (Proc. Conf., Rockefeller Univ., New York, 1976), 1977, pp. 43–72.

    [ErGr80] Erdős, P. and Graham, R., Old and new problems and results in combinatorial number theory, Monographies de L'Enseignement Mathématique (1980).

    [Cu25] Cushman, A., A Note on the Sum-Product Problem and the Convex Sumset Problem. arXiv:2512.13849 (2025).

    [Ta26] Tang, Q., The Hofstadter consecutive-sum sequence omits infinitely many positive integers. arXiv:2603.09939 (2026).

    [Bolan] Bolan, M., Hofstader–Ulam Sequence, https://github.com/mjtb49/HofstaderUlam/blob/main/HofstaderUlamSequence.pdf

    OEIS A005243

@[expose] public sectionopen Finset BigOperators Filter Asymptoticsnamespace Erdos423

IsConsecutiveBlockSum a k m means that $m$ equals the sum of at least two consecutive terms of the sequence $a$, using indices from ${1, \ldots, k - 1}$. That is, there exist $i, j$ with $1 \le i$, $i + 1 \le j$, $j \le k - 1$ such that $m = a(i) + a(i+1) + \cdots + a(j)$.

def IsConsecutiveBlockSum (a : ) (k : ) (m : ) : Prop := i j : , 1 i i + 1 j j + 1 k m = l Finset.Icc i j, a l

The Hofstadter sequence (OEIS A005243): $a(1) = 1$, $a(2) = 2$, and for $k \ge 3$, $a(k)$ is the least integer $> a(k-1)$ that equals the sum of at least two consecutive terms from ${a(1), \ldots, a(k-1)}$. The sequence begins $1, 2, 3, 5, 6, 8, 10, 11, \ldots$.

def IsHofstadterSeq (a : ) : Prop := a 1 = 1 a 2 = 2 k : , 3 k IsConsecutiveBlockSum a k (a k) a (k - 1) < a k m : , a (k - 1) < m m < a k ¬IsConsecutiveBlockSum a k m

The third term of the Hofstadter sequence is $a(3) = 3 = a(1) + a(2) = 1 + 2$.

a: ha1:a 1 = 1ha2:a 2 = 2hk: (k : ), 3 k IsConsecutiveBlockSum a k (a k) a (k - 1) < a k (m : ), a (k - 1) < m m < a k ¬IsConsecutiveBlockSum a k mi:j:hi:1 ihij:i + 1 jhjk:j + 1 3hsum:a 3 = l Icc i j, a lleft✝:a (3 - 1) < a 3right✝: (m : ), a (3 - 1) < m m < a 3 ¬IsConsecutiveBlockSum a 3 mthis:i = 1 j = 2a 3 = 3 a: ha1:a 1 = 1ha2:a 2 = 2hk: (k : ), 3 k IsConsecutiveBlockSum a k (a k) a (k - 1) < a k (m : ), a (k - 1) < m m < a k ¬IsConsecutiveBlockSum a k mleft✝:a (3 - 1) < a 3right✝: (m : ), a (3 - 1) < m m < a 3 ¬IsConsecutiveBlockSum a 3 mhi:1 1hjk:2 + 1 3hij:1 + 1 2hsum:a 3 = l Icc 1 2, a la 3 = 3 a: ha1:a 1 = 1ha2:a 2 = 2hk: (k : ), 3 k IsConsecutiveBlockSum a k (a k) a (k - 1) < a k (m : ), a (k - 1) < m m < a k ¬IsConsecutiveBlockSum a k mleft✝:a (3 - 1) < a 3right✝: (m : ), a (3 - 1) < m m < a 3 ¬IsConsecutiveBlockSum a 3 mhi:1 1hjk:2 + 1 3hij:1 + 1 2hsum:a 3 = 1 + 2a 3 = 3 All goals completed! 🐙

The fourth term of the Hofstadter sequence is $a(4) = 5 = a(2) + a(3) = 2 + 3$.

All goals completed! 🐙

Erdős Problem 423 [Er77c, p.71; ErGr80, p.83]:

Let $a(1) = 1$, $a(2) = 2$, and for $k \ge 3$ let $a(k)$ be the least integer greater than $a(k-1)$ that is a sum of at least two consecutive terms of the sequence. What is the asymptotic behaviour of this sequence? It seems likely that $a_n = n + o(n)$.

@[category research open, AMS 5 11] theorem erdos_423 : answer(sorry) a : , IsHofstadterSeq a (fun n : => (a n : ) - n) =o[atTop] (fun n : => (n : )) := True (a : ), IsHofstadterSeq a (fun n (a n) - n) =o[atTop] fun n n All goals completed! 🐙

Bolan and Tang [Ta26] independently proved that $a_n-n$ is nondecreasing.

@[category research solved, AMS 5 11] theorem erdos_423.variants.nondecreasing : a : , IsHofstadterSeq a n m : , 1 n n m a n - n a m - m := (a : ), IsHofstadterSeq a (n m : ), 1 n n m a n - n a m - m All goals completed! 🐙

Bolan and Tang [Ta26] independently proved that $a_n-n\to\infty$.

@[category research solved, AMS 5 11] theorem erdos_423.variants.unbounded : a : , IsHofstadterSeq a M : , ∀ᶠ n in atTop, M + n a n := (a : ), IsHofstadterSeq a (M : ), ∀ᶠ (n : ) in atTop, M + n a n All goals completed! 🐙

Bolan and Tang [Ta26] independently proved that infinitely many positive integers do not occur in the Hofstadter sequence.

@[category research solved, AMS 5 11] theorem erdos_423.variants.infinite_complement : a : , IsHofstadterSeq a Set.Infinite (Set.range a) := (a : ), IsHofstadterSeq a (Set.range a).Infinite All goals completed! 🐙

A Hofstadter sequence is strictly increasing from index 1 on.

a: h1:a 1 = 1h2:a 2 = 2hk: (k : ), 3 k IsConsecutiveBlockSum a k (a k) a (k - 1) < a k (m : ), a (k - 1) < m m < a k ¬IsConsecutiveBlockSum a k mk:hpos:k > 0this:a (k + 2 - 1) < a (k + 2)a (k + 1) < a (k + 1 + 1) All goals completed! 🐙

A Hofstadter sequence satisfies n ≤ a n for n ≥ 1.

@[category API, AMS 5 11] theorem IsHofstadterSeq.le_apply {a : } (ha : IsHofstadterSeq a) (n : ) (hn : 1 n) : n a n := a: ha:IsHofstadterSeq an:hn:1 nn a n a: ha:IsHofstadterSeq an:hn:1 nh1:a 1 = 1n a n induction n, hn using Nat.le_induction with a: ha:IsHofstadterSeq an:h1:a 1 = 11 a 1 All goals completed! 🐙 a: ha:IsHofstadterSeq an:h1:a 1 = 1k:hk:1 kih:k a kk + 1 a (k + 1) a: ha:IsHofstadterSeq an:h1:a 1 = 1k:hk:1 kih:k a kthis:(fun k a (k + 1)) (k - 1) < (fun k a (k + 1)) (k - 1).succk + 1 a (k + 1) a: ha:IsHofstadterSeq an:h1:a 1 = 1k:hk:1 kih:k a kthis:a k < a (k + 1)k + 1 a (k + 1) All goals completed! 🐙

For indices ≥ 1, a Hofstadter sequence preserves and reflects <.

a: ha:IsHofstadterSeq ai:hi:1 i + 1j:hj:1 j + 1i < j i + 1 < j + 1 All goals completed! 🐙

If a n - n is unbounded, infinitely many integers are missed: when a n ≥ N + 2 + n, the n values a 0, …, a (n - 1) cannot cover the n + 1 integers in [N + 1, a n - 1], and later terms are too large.

a: ha:IsHofstadterSeq ah: (M : ), ∀ᶠ (n : ) in atTop, M + n a nN:n✝:hn✝: (b : ), n b N + 2 + b a bn:hn1:1 nhn:N + 2 + n a nhcard:#(image a (range n)) < #(Icc (N + 1) (a n - 1))k:hx:N + 1 a k a k a n - 1hxi:a k image a (range n)hk:k nthis:a n a kFalse All goals completed! 🐙

If infinitely many integers are missed, a n - n is unbounded: M + 1 missed integers below n together with a 1, …, a n are distinct elements of [1, a n].

a: ha:IsHofstadterSeq ah:(Set.range a).InfiniteM:t:Finset hts:t (Set.range a)htc:#t = M + 1X: := t.sup idhX:X = t.sup idn:hn:X + 1 nhn1:1 nA:Finset := image a (Icc 1 n)hA:A = image a (Icc 1 n)T:Finset := {x t | 1 x}hT:T = {x t | 1 x}hAcard:#A = nhTcard:M #Thdisj:Disjoint A Thsub:A T Icc 1 (a n)this:n + #T a n + 1 - 1M + n a n All goals completed! 🐙

The unboundedness of $a_n-n$ is equivalent to the sequence omitting infinitely many positive integers.

@[category test, AMS 5 11] theorem erdos_423.test.unbounded_iff_infinite_complement : type_of% erdos_423.variants.unbounded type_of% erdos_423.variants.infinite_complement := fun h a ha => ha.infinite_compl_of_unbounded (h a ha), fun h a ha => ha.unbounded_of_infinite_compl (h a ha)

Tang [Ta26] proved $a_n \ll n^{1/(c-1)+o(1)}$ whenever every finite convex set $A$ satisfies $|A-A|\geq |A|^{c-o(1)}$. Using the bound of Cushman [Cu25] gives $a_n\ll n^{688/413+o(1)}$.

@[category research solved, AMS 5 11] theorem erdos_423.variants.upper_bound : a : , IsHofstadterSeq a ε > (0 : ), (fun n => (a n : )) =O[atTop] (fun n => (n : ) ^ ((688 : ) / 413 + ε)) := (a : ), IsHofstadterSeq a ε > 0, (fun n (a n)) =O[atTop] fun n n ^ (688 / 413 + ε) All goals completed! 🐙

Tang [Ta26] proved the lower bound $a_n=n+\Omega(\log\log n)$.

@[category research solved, AMS 5 11] theorem erdos_423.variants.lower_bound : a : , IsHofstadterSeq a (fun n : => Real.log (Real.log n)) =O[atTop] (fun n : => (a n : ) - n) := (a : ), IsHofstadterSeq a (fun n Real.log (Real.log n)) =O[atTop] fun n (a n) - n All goals completed! 🐙end Erdos423