/- Copyright 2025 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 422

References:

@[expose] public sectionnamespace Erdos422open Filteropen scoped Topology

IsHofstadterQ f means that $f$ is Hofstadter's $Q$-sequence (OEIS A005185): $f(1) = f(2) = 1$ and for $n > 2$ $$ f(n) = f(n - f(n - 1)) + f(n - f(n - 2)), $$ where the recurrence requires $f(n - 1) < n$ and $f(n - 2) < n$, so that both arguments on the right-hand side are positive integers. The sequence begins $1, 1, 2, 3, 3, 4, \ldots$.

At most one function satisfies this predicate. Some function satisfies it if and only if $f(n)$ is well-defined for all $n$, which is not known.

def IsHofstadterQ (f : ℕ+ ℕ+) : Prop := f 1 = 1 f 2 = 1 n : ℕ+, 2 < n f (n - 1) < n f (n - 2) < n f n = f (n - f (n - 1)) + f (n - f (n - 2))

The third term of Hofstadter's $Q$-sequence is $f(3) = f(2) + f(2) = 2$.

f:ℕ+ ℕ+h1:f 1 = 1h2:f 2 = 1h: (n : ℕ+), 2 < n f (n - 1) < n f (n - 2) < n f n = f (n - f (n - 1)) + f (n - f (n - 2))h3:f 3 = f (3 - f (3 - 1)) + f (3 - f (3 - 2))f 3 = 2 f:ℕ+ ℕ+h1:f 1 = 1h2:f 2 = 1h: (n : ℕ+), 2 < n f (n - 1) < n f (n - 2) < n f n = f (n - f (n - 1)) + f (n - f (n - 2))h3:f 3 = f (3 - f (3 - 1)) + f (3 - f (3 - 2))1 + 1 = 2 All goals completed! 🐙

The fourth term of Hofstadter's $Q$-sequence is $f(4) = f(2) + f(3) = 3$.

f:ℕ+ ℕ+h3:f 3 = 2h1:f 1 = 1h2:f 2 = 1h: (n : ℕ+), 2 < n f (n - 1) < n f (n - 2) < n f n = f (n - f (n - 1)) + f (n - f (n - 2))h4:f 4 = f (4 - f (4 - 1)) + f (4 - f (4 - 2))f 4 = 3 f:ℕ+ ℕ+h3:f 3 = 2h1:f 1 = 1h2:f 2 = 1h: (n : ℕ+), 2 < n f (n - 1) < n f (n - 2) < n f n = f (n - f (n - 1)) + f (n - f (n - 2))h4:f 4 = f (4 - f (4 - 1)) + f (4 - f (4 - 2))1 + 2 = 3 All goals completed! 🐙

Let $f(1) = f(2) = 1$ and for $n > 2$ $$ f(n) = f(n - f(n - 1)) + f(n - f(n - 2)). $$ Does $f(n)$ miss infinitely many integers?

@[category research open, AMS 11] theorem erdos_422 : answer(sorry) f : ℕ+ ℕ+, IsHofstadterQ f Set.Infinite {n | x, f x n} := True (f : ℕ+ ℕ+), IsHofstadterQ f {n | (x : ℕ+), f x n}.Infinite All goals completed! 🐙

Is $f$ surjective?

@[category research open, AMS 11] theorem erdos_422.variants.surjective : answer(sorry) f : ℕ+ ℕ+, IsHofstadterQ f f.Surjective := True (f : ℕ+ ℕ+), IsHofstadterQ f Function.Surjective f All goals completed! 🐙

How does $f$ grow?

@[category research open, AMS 11] theorem erdos_422.variants.growth_rate : f : ℕ+ ℕ+, IsHofstadterQ f (fun n (f n : )) =O[atTop] (answer(sorry) : ℕ+ ) := (f : ℕ+ ℕ+), IsHofstadterQ f (fun n (f n)) =O[atTop] sorry All goals completed! 🐙

Does $f$ become stationary at some point?

@[category research open, AMS 11] theorem erdos_422.variants.eventually_const : answer(sorry) f : ℕ+ ℕ+, IsHofstadterQ f EventuallyConst f atTop := True (f : ℕ+ ℕ+), IsHofstadterQ f EventuallyConst f atTop All goals completed! 🐙end Erdos422