/-
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
@[expose] public sectionnamespace OeisA1223Prime gaps: differences between consecutive primes.
noncomputable def a (n : ℕ) : ℕ :=
if n = 0 then 0
else Nat.nth Nat.Prime n - Nat.nth Nat.Prime (n - 1)Helper definition for extracting a finite subsequence (pattern) as a list.
noncomputable def gapSubsequence (startIndex length : ℕ) : List ℕ :=
(List.range length).map (fun i => a (startIndex + i))
Value of the sequence a at 0.
@[category test, AMS 11]
theorem a_0 : a 0 = 0 := ⊢ a 0 = 0 All goals completed! 🐙
Value of the sequence a at 1.
All goals completed! 🐙
Value of the sequence a at 2.
@[category test, AMS 11]
theorem a_2 : a 2 = 2 := by ⊢ a 2 = 2
change Nat.nth Nat.Prime 2 - Nat.nth Nat.Prime 1 = 2 ⊢ Nat.nth Nat.Prime 2 - Nat.nth Nat.Prime 1 = 2
rw [Nat.nth_prime_two_eq_five, ⊢ 5 - Nat.nth Nat.Prime 1 = 2 All goals completed! 🐙 Nat.nth_prime_one_eq_three ⊢ 5 - 3 = 2 All goals completed! 🐙] All goals completed! 🐙
Value of the sequence a at 3.
@[category test, AMS 11]
theorem a_3 : a 3 = 2 := by ⊢ a 3 = 2
change Nat.nth Nat.Prime 3 - Nat.nth Nat.Prime 2 = 2 ⊢ Nat.nth Nat.Prime 3 - Nat.nth Nat.Prime 2 = 2
rw [Nat.nth_prime_three_eq_seven, ⊢ 7 - Nat.nth Nat.Prime 2 = 2 All goals completed! 🐙 Nat.nth_prime_two_eq_five ⊢ 7 - 5 = 2 All goals completed! 🐙] All goals completed! 🐙Any subsequence a(n .. n+m) with n > 2 (as to exclude the untypical primes 2 and 3) should occur infinitely many times at other starting points k.
This is false. The five-term block starting at $n = 3$ is $(2,4,2,4,2)$, and a congruence modulo $5$ shows that it occurs only at $n = 3$.
@[category research solved, AMS 11, formal_proof using lean4 at
"https://github.com/epoch-research/LeanOpenProblems-results/blob/f02efd9a8c5fc6a735d2a90c33e24f7278ce0ffc/runs/oeis-full-50usd-oai-jajpvieznaevpoyg/prime_gap_subsequences_occur_infinitely_often/Submission/Spec.lean#L134"]
theorem conjecture :
¬ ∀ (n m : ℕ), n ≥ 3 →
Set.Infinite {k : ℕ | gapSubsequence k (m + 1) = gapSubsequence n (m + 1)} := by ⊢ ¬∀ (n m : ℕ), n ≥ 3 → {k | gapSubsequence k (m + 1) = gapSubsequence n (m + 1)}.Infinite
sorry All goals completed! 🐙end OeisA1223