/- 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 436

References:

    erdosproblems.com/436

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

    [LeLe62] Lehmer, D. H. and Lehmer, Emma, On runs of residues. Proc. Amer. Math. Soc. (1962), 102-106.

    [LLMS62] Lehmer, D. H. and Lehmer, E. and Mills, W. H. and Selfridge, J. L., Machine proof of a theorem on cubic residues. Math. Comp. (1962), 407-415.

    [BiMi63] Bierstedt, R. G. and Mills, W. H., On the bound for a pair of consecutive quartic residues of a prime. Proc. Amer. Math. Soc. (1963), 628-632.

    [LLM63] Lehmer, D. H. and Lehmer, Emma and Mills, W. H., Pairs of consecutive power residues. Canadian J. Math. (1963), 172-177.

    [BLL64] Brillhart, John and Lehmer, D. H. and Lehmer, Emma, Bounds for pairs of consecutive seventh and higher power residues. Math. Comp. (1964), 397-407.

    [Gr64g] Graham, R. L., On quadruples of consecutive $k$th power residues. Proc. Amer. Math. Soc. (1964), 196-197.

    [Du65] Dunton, M., Bounds for pairs of cubic residues. Proc. Amer. Math. Soc. (1965), 330-332.

    [Hi91] Hildebrand, Adolf, On consecutive $k$th power residues. II. Michigan Math. J. (1991), 241-253.

@[expose] public sectionopen Filternamespace Erdos436

IsPowerResidue k p a means that $a$ is a $k$th power residue modulo $p$, that is, $p \nmid a$ and $a \equiv x^k \pmod{p}$ for some $x$.

def IsPowerResidue (k p a : ℕ) : Prop := (a : ZMod p) ≠ 0 ∧ ∃ x : ZMod p, x ^ k = a

r k m p is the least $r \geq 1$ such that $r, r + 1, \ldots, r + m - 1$ are all $k$th power residues modulo $p$, or ⊤ if there is no such $r$.

noncomputable def r (k m p : ℕ) : ℕ∞ := ⨅ (n : ℕ) (_ : 1 ≤ n ∧ ∀ i < m, IsPowerResidue k p (n + i)), (n : ℕ∞)

$\Lambda(k, m) = \limsup_{p \to \infty} r(k, m, p)$, where $p$ runs over the primes.

noncomputable def runLimsup (k m : ℕ) : ℕ∞ := limsup (r k m) (atTop ⊓ 𝓟 {p | p.Prime})@[inherit_doc] local notation "Λ" => runLimsup

If $p$ is a prime and $k, m \geq 2$, let $r(k, m, p)$ be the minimal $r$ such that $r, r + 1, \ldots, r + m - 1$ are all $k$th power residues modulo $p$, and let $\Lambda(k, m) = \limsup_{p \to \infty} r(k, m, p)$. Is $\Lambda(k, 2)$ finite for all $k$?

A question of Lehmer and Lehmer [LeLe62]. Hildebrand [Hi91] proved that $\Lambda(k, 2)$ is finite for all $k \geq 2$.

@[category research solved, question, AMS 11] theorem erdos_436.parts.i : ∀ k ≥ 2, Λ k 2 < ⊤ := ⊢ ∀ k ≥ 2, Λ k 2 < ⊤ All goals completed! 🐙

Is $\Lambda(k, 3)$ finite for all odd $k$?

Lehmer, Lehmer, Mills and Selfridge [LLMS62] proved $\Lambda(3, 3) = 23532$. The question is open for odd $k \geq 5$.

@[category research open, question, AMS 11] theorem erdos_436.parts.ii : ∀ k ≥ 3, Odd k → Λ k 3 < ⊤ := ⊢ ∀ k ≥ 3, Odd k → Λ k 3 < ⊤ All goals completed! 🐙

Lehmer and Lehmer [LeLe62] proved $\Lambda(2, 2) = 9$.

@[category research solved, AMS 11] theorem erdos_436.variants.two_two : Λ 2 2 = 9 := ⊢ Λ 2 2 = 9 All goals completed! 🐙

Dunton [Du65] proved $\Lambda(3, 2) = 77$.

@[category research solved, AMS 11] theorem erdos_436.variants.three_two : Λ 3 2 = 77 := ⊢ Λ 3 2 = 77 All goals completed! 🐙

Bierstedt and Mills [BiMi63] proved $\Lambda(4, 2) = 1224$.

@[category research solved, AMS 11] theorem erdos_436.variants.four_two : Λ 4 2 = 1224 := ⊢ Λ 4 2 = 1224 All goals completed! 🐙

Lehmer, Lehmer and Mills [LLM63] proved $\Lambda(5, 2) = 7888$.

@[category research solved, AMS 11] theorem erdos_436.variants.five_two : Λ 5 2 = 7888 := ⊢ Λ 5 2 = 7888 All goals completed! 🐙

Lehmer, Lehmer and Mills [LLM63] proved $\Lambda(6, 2) = 202124$.

@[category research solved, AMS 11] theorem erdos_436.variants.six_two : Λ 6 2 = 202124 := ⊢ Λ 6 2 = 202124 All goals completed! 🐙

Brillhart, Lehmer and Lehmer [BLL64] proved $\Lambda(7, 2) = 1649375$.

@[category research solved, AMS 11] theorem erdos_436.variants.seven_two : Λ 7 2 = 1649375 := ⊢ Λ 7 2 = 1649375 All goals completed! 🐙

Lehmer, Lehmer, Mills and Selfridge [LLMS62] proved $\Lambda(3, 3) = 23532$.

@[category research solved, AMS 11] theorem erdos_436.variants.three_three : Λ 3 3 = 23532 := ⊢ Λ 3 3 = 23532 All goals completed! 🐙

Lehmer and Lehmer [LeLe62] proved $\Lambda(k, 3) = \infty$ for all even $k$.

@[category research solved, AMS 11] theorem erdos_436.variants.even_three : ∀ k ≥ 2, Even k → Λ k 3 = ⊤ := ⊢ ∀ k ≥ 2, Even k → Λ k 3 = ⊤ All goals completed! 🐙

Graham [Gr64g] proved $\Lambda(k, l) = \infty$ for all $k \geq 2$ and $l \geq 4$.

@[category research solved, AMS 11] theorem erdos_436.variants.ge_four : ∀ k ≥ 2, ∀ l ≥ 4, Λ k l = ⊤ := ⊢ ∀ k ≥ 2, ∀ l ≥ 4, Λ k l = ⊤ All goals completed! 🐙

Modulo $13$, the quadratic residues are $1, 3, 4, 9, 10, 12$, so the first pair of consecutive quadratic residues starts at $3$.

h2:¬IsPowerResidue 2 13 2n:ℕhn:1 ≤ nh:∀ i < 2, IsPowerResidue 2 13 (n + i)this:3 ≤ n⊢ 3 ≤ ↑n All goals completed! 🐙end Erdos436