/-
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 FormalConjecturesUtilTug of war score between prime gap increases and decreases
Score at stage $n$ in "tug of war" between prime gap increases vs. prime gap decreases: start with score $= 0$ at $n = 1$ and at stage $k > 1$, increase (resp. decrease) the score by $1$ if the $k$-th prime gap is greater (resp. less) than the previous prime gap.
References:
namespace OeisA92243The $n$-th prime gap $g(n) = p_n - p_{n-1}$ for $n \ge 1$, where $p_i$ is the $i$-th prime (0-indexed).
noncomputable def primeGap (n : ℕ) : ℕ :=
Nat.nth Nat.Prime n - Nat.nth Nat.Prime (n - 1)Score at stage $n$ in "tug of war" between prime gap increases vs. prime gap decreases.
noncomputable def a (n : ℕ) : ℤ :=
if n ≤ 1 then 0
else
∑ k ∈ Finset.Icc 2 n,
((primeGap k : ℤ) - (primeGap (k - 1) : ℤ)).sign
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.
@[category test, AMS 11]
theorem a_1 : a 1 = 0 := ⊢ a 1 = 0 All goals completed! 🐙
Value of the sequence a at 2.
h2:¬2 ≤ 1h_icc:Finset.Icc 2 2 = {2}h_zero:Nat.nth Nat.Prime 0 = 2h_one:Nat.nth Nat.Prime 1 = 3h_two:Nat.nth Nat.Prime 2 = 5⊢ (↑(5 - 3) - ↑(3 - 2)).sign = 1
decide All goals completed! 🐙
Value of the sequence a at 3.
@[category test, AMS 11]
theorem a_3 : a 3 = 1 := by ⊢ a 3 = 1
unfold a ⊢ (if 3 ≤ 1 then 0 else ∑ k ∈ Finset.Icc 2 3, (↑(primeGap k) - ↑(primeGap (k - 1))).sign) = 1
have h3 : ¬ 3 ≤ 1 := by ⊢ a 3 = 1 h3:¬3 ≤ 1⊢ (if 3 ≤ 1 then 0 else ∑ k ∈ Finset.Icc 2 3, (↑(primeGap k) - ↑(primeGap (k - 1))).sign) = 1 decide h3:¬3 ≤ 1⊢ (if 3 ≤ 1 then 0 else ∑ k ∈ Finset.Icc 2 3, (↑(primeGap k) - ↑(primeGap (k - 1))).sign) = 1 h3:¬3 ≤ 1⊢ (if 3 ≤ 1 then 0 else ∑ k ∈ Finset.Icc 2 3, (↑(primeGap k) - ↑(primeGap (k - 1))).sign) = 1
rw [if_neg h3 h3:¬3 ≤ 1⊢ ∑ k ∈ Finset.Icc 2 3, (↑(primeGap k) - ↑(primeGap (k - 1))).sign = 1 h3:¬3 ≤ 1⊢ ∑ k ∈ Finset.Icc 2 3, (↑(primeGap k) - ↑(primeGap (k - 1))).sign = 1] h3:¬3 ≤ 1⊢ ∑ k ∈ Finset.Icc 2 3, (↑(primeGap k) - ↑(primeGap (k - 1))).sign = 1
have h_icc : Finset.Icc 2 3 = {2, 3} := by ⊢ a 3 = 1 h3:¬3 ≤ 1h_icc:Finset.Icc 2 3 = {2, 3}⊢ ∑ k ∈ Finset.Icc 2 3, (↑(primeGap k) - ↑(primeGap (k - 1))).sign = 1 decide h3:¬3 ≤ 1h_icc:Finset.Icc 2 3 = {2, 3}⊢ ∑ k ∈ Finset.Icc 2 3, (↑(primeGap k) - ↑(primeGap (k - 1))).sign = 1 h3:¬3 ≤ 1h_icc:Finset.Icc 2 3 = {2, 3}⊢ ∑ k ∈ Finset.Icc 2 3, (↑(primeGap k) - ↑(primeGap (k - 1))).sign = 1
rw [h_icc, h3:¬3 ≤ 1h_icc:Finset.Icc 2 3 = {2, 3}⊢ ∑ k ∈ {2, 3}, (↑(primeGap k) - ↑(primeGap (k - 1))).sign = 1 h3:¬3 ≤ 1h_icc:Finset.Icc 2 3 = {2, 3}⊢ (↑(primeGap 2) - ↑(primeGap (2 - 1))).sign + (↑(primeGap 3) - ↑(primeGap (3 - 1))).sign = 1 Finset.sum_pair (by h3:¬3 ≤ 1h_icc:Finset.Icc 2 3 = {2, 3}⊢ 2 ≠ 3 h3:¬3 ≤ 1h_icc:Finset.Icc 2 3 = {2, 3}⊢ (↑(primeGap 2) - ↑(primeGap (2 - 1))).sign + (↑(primeGap 3) - ↑(primeGap (3 - 1))).sign = 1 decide All goals completed! 🐙 h3:¬3 ≤ 1h_icc:Finset.Icc 2 3 = {2, 3}⊢ (↑(primeGap 2) - ↑(primeGap (2 - 1))).sign + (↑(primeGap 3) - ↑(primeGap (3 - 1))).sign = 1)] h3:¬3 ≤ 1h_icc:Finset.Icc 2 3 = {2, 3}⊢ (↑(primeGap 2) - ↑(primeGap (2 - 1))).sign + (↑(primeGap 3) - ↑(primeGap (3 - 1))).sign = 1
unfold primeGap h3:¬3 ≤ 1h_icc:Finset.Icc 2 3 = {2, 3}⊢ (↑(Nat.nth Nat.Prime 2 - Nat.nth Nat.Prime (2 - 1)) -
↑(Nat.nth Nat.Prime (2 - 1) - Nat.nth Nat.Prime (2 - 1 - 1))).sign +
(↑(Nat.nth Nat.Prime 3 - Nat.nth Nat.Prime (3 - 1)) -
↑(Nat.nth Nat.Prime (3 - 1) - Nat.nth Nat.Prime (3 - 1 - 1))).sign =
1
have h_zero : Nat.nth Nat.Prime 0 = 2 := Nat.nth_prime_zero_eq_two h3:¬3 ≤ 1h_icc:Finset.Icc 2 3 = {2, 3}h_zero:Nat.nth Nat.Prime 0 = 2⊢ (↑(Nat.nth Nat.Prime 2 - Nat.nth Nat.Prime (2 - 1)) -
↑(Nat.nth Nat.Prime (2 - 1) - Nat.nth Nat.Prime (2 - 1 - 1))).sign +
(↑(Nat.nth Nat.Prime 3 - Nat.nth Nat.Prime (3 - 1)) -
↑(Nat.nth Nat.Prime (3 - 1) - Nat.nth Nat.Prime (3 - 1 - 1))).sign =
1
have h_one : Nat.nth Nat.Prime 1 = 3 := Nat.nth_prime_one_eq_three h3:¬3 ≤ 1h_icc:Finset.Icc 2 3 = {2, 3}h_zero:Nat.nth Nat.Prime 0 = 2h_one:Nat.nth Nat.Prime 1 = 3⊢ (↑(Nat.nth Nat.Prime 2 - Nat.nth Nat.Prime (2 - 1)) -
↑(Nat.nth Nat.Prime (2 - 1) - Nat.nth Nat.Prime (2 - 1 - 1))).sign +
(↑(Nat.nth Nat.Prime 3 - Nat.nth Nat.Prime (3 - 1)) -
↑(Nat.nth Nat.Prime (3 - 1) - Nat.nth Nat.Prime (3 - 1 - 1))).sign =
1
have h_two : Nat.nth Nat.Prime 2 = 5 := Nat.nth_prime_two_eq_five h3:¬3 ≤ 1h_icc:Finset.Icc 2 3 = {2, 3}h_zero:Nat.nth Nat.Prime 0 = 2h_one:Nat.nth Nat.Prime 1 = 3h_two:Nat.nth Nat.Prime 2 = 5⊢ (↑(Nat.nth Nat.Prime 2 - Nat.nth Nat.Prime (2 - 1)) -
↑(Nat.nth Nat.Prime (2 - 1) - Nat.nth Nat.Prime (2 - 1 - 1))).sign +
(↑(Nat.nth Nat.Prime 3 - Nat.nth Nat.Prime (3 - 1)) -
↑(Nat.nth Nat.Prime (3 - 1) - Nat.nth Nat.Prime (3 - 1 - 1))).sign =
1
have h_three : Nat.nth Nat.Prime 3 = 7 := Nat.nth_prime_three_eq_seven h3:¬3 ≤ 1h_icc:Finset.Icc 2 3 = {2, 3}h_zero:Nat.nth Nat.Prime 0 = 2h_one:Nat.nth Nat.Prime 1 = 3h_two:Nat.nth Nat.Prime 2 = 5h_three:Nat.nth Nat.Prime 3 = 7⊢ (↑(Nat.nth Nat.Prime 2 - Nat.nth Nat.Prime (2 - 1)) -
↑(Nat.nth Nat.Prime (2 - 1) - Nat.nth Nat.Prime (2 - 1 - 1))).sign +
(↑(Nat.nth Nat.Prime 3 - Nat.nth Nat.Prime (3 - 1)) -
↑(Nat.nth Nat.Prime (3 - 1) - Nat.nth Nat.Prime (3 - 1 - 1))).sign =
1
rw [h_zero, h3:¬3 ≤ 1h_icc:Finset.Icc 2 3 = {2, 3}h_zero:Nat.nth Nat.Prime 0 = 2h_one:Nat.nth Nat.Prime 1 = 3h_two:Nat.nth Nat.Prime 2 = 5h_three:Nat.nth Nat.Prime 3 = 7⊢ (↑(Nat.nth Nat.Prime 2 - Nat.nth Nat.Prime (2 - 1)) - ↑(Nat.nth Nat.Prime (2 - 1) - 2)).sign +
(↑(Nat.nth Nat.Prime 3 - Nat.nth Nat.Prime (3 - 1)) -
↑(Nat.nth Nat.Prime (3 - 1) - Nat.nth Nat.Prime (3 - 1 - 1))).sign =
1 h3:¬3 ≤ 1h_icc:Finset.Icc 2 3 = {2, 3}h_zero:Nat.nth Nat.Prime 0 = 2h_one:Nat.nth Nat.Prime 1 = 3h_two:Nat.nth Nat.Prime 2 = 5h_three:Nat.nth Nat.Prime 3 = 7⊢ (↑(5 - 3) - ↑(3 - 2)).sign + (↑(7 - 5) - ↑(5 - 3)).sign = 1 h_one, h3:¬3 ≤ 1h_icc:Finset.Icc 2 3 = {2, 3}h_zero:Nat.nth Nat.Prime 0 = 2h_one:Nat.nth Nat.Prime 1 = 3h_two:Nat.nth Nat.Prime 2 = 5h_three:Nat.nth Nat.Prime 3 = 7⊢ (↑(Nat.nth Nat.Prime 2 - 3) - ↑(3 - 2)).sign +
(↑(Nat.nth Nat.Prime 3 - Nat.nth Nat.Prime (3 - 1)) - ↑(Nat.nth Nat.Prime (3 - 1) - 3)).sign =
1 h3:¬3 ≤ 1h_icc:Finset.Icc 2 3 = {2, 3}h_zero:Nat.nth Nat.Prime 0 = 2h_one:Nat.nth Nat.Prime 1 = 3h_two:Nat.nth Nat.Prime 2 = 5h_three:Nat.nth Nat.Prime 3 = 7⊢ (↑(5 - 3) - ↑(3 - 2)).sign + (↑(7 - 5) - ↑(5 - 3)).sign = 1 h_two, h3:¬3 ≤ 1h_icc:Finset.Icc 2 3 = {2, 3}h_zero:Nat.nth Nat.Prime 0 = 2h_one:Nat.nth Nat.Prime 1 = 3h_two:Nat.nth Nat.Prime 2 = 5h_three:Nat.nth Nat.Prime 3 = 7⊢ (↑(5 - 3) - ↑(3 - 2)).sign + (↑(Nat.nth Nat.Prime 3 - 5) - ↑(5 - 3)).sign = 1 h3:¬3 ≤ 1h_icc:Finset.Icc 2 3 = {2, 3}h_zero:Nat.nth Nat.Prime 0 = 2h_one:Nat.nth Nat.Prime 1 = 3h_two:Nat.nth Nat.Prime 2 = 5h_three:Nat.nth Nat.Prime 3 = 7⊢ (↑(5 - 3) - ↑(3 - 2)).sign + (↑(7 - 5) - ↑(5 - 3)).sign = 1 h_three h3:¬3 ≤ 1h_icc:Finset.Icc 2 3 = {2, 3}h_zero:Nat.nth Nat.Prime 0 = 2h_one:Nat.nth Nat.Prime 1 = 3h_two:Nat.nth Nat.Prime 2 = 5h_three:Nat.nth Nat.Prime 3 = 7⊢ (↑(5 - 3) - ↑(3 - 2)).sign + (↑(7 - 5) - ↑(5 - 3)).sign = 1 h3:¬3 ≤ 1h_icc:Finset.Icc 2 3 = {2, 3}h_zero:Nat.nth Nat.Prime 0 = 2h_one:Nat.nth Nat.Prime 1 = 3h_two:Nat.nth Nat.Prime 2 = 5h_three:Nat.nth Nat.Prime 3 = 7⊢ (↑(5 - 3) - ↑(3 - 2)).sign + (↑(7 - 5) - ↑(5 - 3)).sign = 1] h3:¬3 ≤ 1h_icc:Finset.Icc 2 3 = {2, 3}h_zero:Nat.nth Nat.Prime 0 = 2h_one:Nat.nth Nat.Prime 1 = 3h_two:Nat.nth Nat.Prime 2 = 5h_three:Nat.nth Nat.Prime 3 = 7⊢ (↑(5 - 3) - ↑(3 - 2)).sign + (↑(7 - 5) - ↑(5 - 3)).sign = 1
decide All goals completed! 🐙Is the score $a(n) > 0$ for some $n > 250000$?
@[category research open, AMS 11]
theorem conjecture1 : answer(sorry) ↔ ∃ n > 250000, a n > 0 := by ⊢ True ↔ ∃ n > 250000, a n > 0
sorry All goals completed! 🐙Is the score $a(n)$ bounded from below?
@[category research open, AMS 11]
theorem conjecture2 : answer(sorry) ↔ ∃ B : ℤ, ∀ n : ℕ, B ≤ a n := by ⊢ True ↔ ∃ B, ∀ (n : ℕ), B ≤ a n
sorry All goals completed! 🐙Is the score $a(n)$ bounded from above?
@[category research open, AMS 11]
theorem conjecture3 : answer(sorry) ↔ ∃ B : ℤ, ∀ n : ℕ, a n ≤ B := by ⊢ True ↔ ∃ B, ∀ (n : ℕ), a n ≤ B
sorry All goals completed! 🐙Is the score $a(n) > 0$ for infinitely many values of $n$?
@[category research open, AMS 11]
theorem conjecture4 : answer(sorry) ↔ Set.Infinite {n : ℕ | a n > 0} := by ⊢ True ↔ {n | a n > 0}.Infinite
sorry All goals completed! 🐙Is the score $a(n) < 0$ for infinitely many values of $n$?
@[category research open, AMS 11]
theorem conjecture5 : answer(sorry) ↔ Set.Infinite {n : ℕ | a n < 0} := by ⊢ True ↔ {n | a n < 0}.Infinite
sorry All goals completed! 🐙end OeisA92243