/- 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. -/ import FormalConjecturesUtil

Büchi's problem

References:

namespace Buchi

IsBuchi M asserts that whenever M consecutive values (x + n)² + a (for n = 0, …, M - 1) are all perfect squares, then a must be 0.

def IsBuchi (M : ) : Prop := x a : , ( n Finset.range M, IsSquare ((x + (n : )) ^ 2 + a)) a = 0

Büchi's problem There exists a positive integer $M$ such that, for all integers $x$ and $a$, if $(x+n)^2 + a$ is a square for $M$ consecutive values of $n$, then $a = 0$.

@[category research open, AMS 11] theorem declaration uses 'sorry'buchi_problem : answer(sorry) M : , 1 M IsBuchi M := True M, 1 M IsBuchi M All goals completed! 🐙

Büchi's problem (first open case, $M = 5$): For all integers $x$ and $a$, if $(x+n)^2 + a$ is a perfect square for $n = 0, 1, 2, 3, 4$, then $a = 0$.

Non-trivial sequences of length 3 and 4 are known to exist, so $M = 5$ is the first open case.

@[category research open, AMS 11] theorem declaration uses 'sorry'buchi_problem_M5 : IsBuchi 5 := IsBuchi 5 All goals completed! 🐙

The case $M = 0$ fails: the hypothesis is vacuous, so $a = 0$ cannot be concluded.

@[category test, AMS 11] theorem buchi_false_M0 : ¬ IsBuchi 0 := ¬IsBuchi 0 x x_1, (∀ n , IsSquare ((x + n) ^ 2 + x_1)) ¬x_1 = 0 exact 0, 1, (∀ n , IsSquare ((0 + n) ^ 2 + 1)) ¬1 = 0 All goals completed! 🐙

The case $M = 1$ fails: $0^2 + 4 = 4 = 2^2$ is a square but $a = 4 \neq 0$.

@[category test, AMS 11] theorem buchi_false_M1 : ¬ IsBuchi 1 := ¬IsBuchi 1 x x_1, (_ : n Finset.range 1, IsSquare ((x + n) ^ 2 + x_1)), ¬x_1 = 0 refine 0, 4, ?_, ¬4 = 0 All goals completed! 🐙 intro n n:hn:n Finset.range 1IsSquare ((0 + n) ^ 2 + 4) n:hn:n = 0IsSquare ((0 + n) ^ 2 + 4); IsSquare ((0 + 0) ^ 2 + 4) exact 2, (0 + 0) ^ 2 + 4 = 2 * 2 All goals completed! 🐙

The case $M = 2$ fails: $(7+n)^2 - 48$ is a perfect square for $n = 0, 1$ ($1^2$ and $4^2$), but $a = -48 \neq 0$.

@[category test, AMS 11] theorem buchi_false_M2 : ¬ IsBuchi 2 := ¬IsBuchi 2 x x_1, (_ : n Finset.range 2, IsSquare ((x + n) ^ 2 + x_1)), ¬x_1 = 0 refine 7, -48, ?_, ¬-48 = 0 All goals completed! 🐙 intro n n:hn:n Finset.range 2IsSquare ((7 + n) ^ 2 + -48) n:hn:n < 2IsSquare ((7 + n) ^ 2 + -48) n:hn:0 < 2IsSquare ((7 + 0) ^ 2 + -48)n:hn:1 < 2IsSquare ((7 + 1) ^ 2 + -48) n:hn:0 < 2IsSquare ((7 + 0) ^ 2 + -48) exact 1, n:hn:0 < 2(7 + 0) ^ 2 + -48 = 1 * 1 All goals completed! 🐙 n:hn:1 < 2IsSquare ((7 + 1) ^ 2 + -48) exact 4, n:hn:1 < 2(7 + 1) ^ 2 + -48 = 4 * 4 All goals completed! 🐙

The case $M = 3$ fails: $(24+n)^2 - 576$ is a perfect square for $n = 0, 1, 2$ ($0^2$, $7^2$, and $10^2$), but $a = -576 \neq 0$.

@[category test, AMS 11] theorem buchi_false_M3 : ¬ IsBuchi 3 := ¬IsBuchi 3 x x_1, (_ : n Finset.range 3, IsSquare ((x + n) ^ 2 + x_1)), ¬x_1 = 0 refine 24, -576, ?_, ¬-576 = 0 All goals completed! 🐙 intro n n:hn:n Finset.range 3IsSquare ((24 + n) ^ 2 + -576) n:hn:n < 3IsSquare ((24 + n) ^ 2 + -576) n:hn:0 < 3IsSquare ((24 + 0) ^ 2 + -576)n:hn:1 < 3IsSquare ((24 + 1) ^ 2 + -576)n:hn:2 < 3IsSquare ((24 + 2) ^ 2 + -576) n:hn:0 < 3IsSquare ((24 + 0) ^ 2 + -576) exact 0, n:hn:0 < 3(24 + 0) ^ 2 + -576 = 0 * 0 All goals completed! 🐙 n:hn:1 < 3IsSquare ((24 + 1) ^ 2 + -576) exact 7, n:hn:1 < 3(24 + 1) ^ 2 + -576 = 7 * 7 All goals completed! 🐙 n:hn:2 < 3IsSquare ((24 + 2) ^ 2 + -576) exact 10, n:hn:2 < 3(24 + 2) ^ 2 + -576 = 10 * 10 All goals completed! 🐙

The case $M = 4$ fails: $(246+n)^2 - 60480$ is a perfect square for $n = 0, 1, 2, 3$ ($6^2$, $23^2$, $32^2$, and $39^2$), but $a = -60480 \neq 0$. The sequence $(6, 23, 32, 39)$ is a nontrivial Büchi sequence of length 4 (Hensley 1983).

@[category test, AMS 11] theorem buchi_false_M4 : ¬ IsBuchi 4 := ¬IsBuchi 4 x x_1, (_ : n Finset.range 4, IsSquare ((x + n) ^ 2 + x_1)), ¬x_1 = 0 refine 246, -60480, ?_, ¬-60480 = 0 All goals completed! 🐙 intro n n:hn:n Finset.range 4IsSquare ((246 + n) ^ 2 + -60480) n:hn:n < 4IsSquare ((246 + n) ^ 2 + -60480) n:hn:0 < 4IsSquare ((246 + 0) ^ 2 + -60480)n:hn:1 < 4IsSquare ((246 + 1) ^ 2 + -60480)n:hn:2 < 4IsSquare ((246 + 2) ^ 2 + -60480)n:hn:3 < 4IsSquare ((246 + 3) ^ 2 + -60480) n:hn:0 < 4IsSquare ((246 + 0) ^ 2 + -60480) exact 6, n:hn:0 < 4(246 + 0) ^ 2 + -60480 = 6 * 6 All goals completed! 🐙 n:hn:1 < 4IsSquare ((246 + 1) ^ 2 + -60480) exact 23, n:hn:1 < 4(246 + 1) ^ 2 + -60480 = 23 * 23 All goals completed! 🐙 n:hn:2 < 4IsSquare ((246 + 2) ^ 2 + -60480) exact 32, n:hn:2 < 4(246 + 2) ^ 2 + -60480 = 32 * 32 All goals completed! 🐙 n:hn:3 < 4IsSquare ((246 + 3) ^ 2 + -60480) exact 39, n:hn:3 < 4(246 + 3) ^ 2 + -60480 = 39 * 39 All goals completed! 🐙 end Buchi