/-
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 FormalConjecturesUtilErdős Problem 1141
[APSSV26b] B. Alexeev, M. Putterman, M. Sawhney, M. Sellke, and G. Valiant, Short proofs in combinatorics, probability and number theory II. arXiv:2604.06609 (2026).
[Or26] Y. Oriike, Lean formalisation of Erdős problem 1141 (2026)
[Po17] P. Pollack, Bounds for the first several prime character nonresidues. Proc. Amer. Math. Soc. (2017), 2815--2826.
[Va99] Various, Some of Paul's favorite problems. Booklet produced for the conference "Paul Erdős and his mathematics", Budapest, July 1999 (1999).
open Nat Set
namespace Erdos1141
The property that $n-k^2$ is prime for all $k$ with $(n,k)=1$ and $k^2 < n$.
def Erdos1141Prop (n : ℕ) : Prop :=
∀ k, k ^ 2 < n → Coprime n k → (n - k ^ 2).Prime
instance (n : ℕ) : Decidable (Erdos1141Prop n) :=
decidable_of_iff (∀ k ≤ .sqrt (n - 1), Coprime n k → (n - k ^ 2).Prime) <| n:ℕ⊢ (∀ k ≤ (n - 1).sqrt, n.Coprime k → Nat.Prime (n - k ^ 2)) ↔ Erdos1141Prop n
cases n with
⊢ (∀ k ≤ (0 - 1).sqrt, Coprime 0 k → Nat.Prime (0 - k ^ 2)) ↔ Erdos1141Prop 0 All goals completed! 🐙
n':ℕ⊢ (∀ k ≤ (n' + 1 - 1).sqrt, (n' + 1).Coprime k → Nat.Prime (n' + 1 - k ^ 2)) ↔ Erdos1141Prop (n' + 1)
All goals completed! 🐙
Are there infinitely many $n$ such that $n-k^2$ is prime for all $k$ with $(n,k)=1$ and $k^2 < n$?
In [Va99] it is asked whether $968$ is the largest integer with this property, but this is an error, since for example $968-9=7\cdot 137$.
The list of $n$ satisfying the given property is [A214583] in the OEIS. The largest known such $n$ is $1722$.
The answer is negative: [APSSV26b] proves a stronger finiteness theorem, deducing it from Pollack [Po17]. Oriike [Or26] formalised the deduction in Lean.
@[category research solved, AMS 11, formal_proof using lean4 at
"https://github.com/yuta0x89/ErdosProblems/blob/a1319f732cdee5140faf47d984e2c451c1184803/Erdos1141.lean"]
theorem erdos_1141 :
answer(False) ↔ Infinite { n | Erdos1141Prop n } := ⊢ False ↔ Infinite ↑{n | Erdos1141Prop n}
All goals completed! 🐙
@[category test, AMS 11]
example : ¬ Erdos1141Prop 968 := ⊢ ¬Erdos1141Prop 968
All goals completed! 🐙
@[category test, AMS 11]
example : Erdos1141Prop 1722 := ⊢ Erdos1141Prop 1722
All goals completed! 🐙
end Erdos1141