/-
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
namespace OeisA1359The $n$-th lesser twin prime, with $a(0) = 0$.
noncomputable def a (n : ℕ) : ℕ :=
if n > 0 then
Nat.nth (fun p => p.Prime ∧ (p + 2).Prime) (n - 1)
else
0
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 = 3 := ⊢ a 1 = 3
⊢ Nat.nth (fun p ↦ Nat.Prime p ∧ Nat.Prime (p + 2)) 0 = 3
exact(((congr_arg _) (⊢ 0 = Nat.count (fun p ↦ Nat.Prime p ∧ Nat.Prime (p + 2)) 3 All goals completed! 🐙) )).trans.comp (3).nth_count (⊢ Nat.Prime 3 ∧ Nat.Prime (3 + 2) All goals completed! 🐙)
Value of the sequence a at 2.
@[category test, AMS 11]
theorem a_2 : a 2 = 5 := ⊢ a 2 = 5
⊢ (if 2 > 0 then Nat.nth (fun p ↦ Nat.Prime p ∧ Nat.Prime (p + 2)) (2 - 1) else 0) = 5
apply((congr_arg _) (⊢ 2 - 1 = Nat.count (fun p ↦ Nat.Prime p ∧ Nat.Prime (p + 2)) 5 All goals completed! 🐙) ).trans (Nat.nth_count (⊢ Nat.Prime 5 ∧ Nat.Prime (5 + 2) All goals completed! 🐙 ) )
Value of the sequence a at 3.
@[category test, AMS 11]
theorem a_3 : a 3 = 11 := ⊢ a 3 = 11
(inhabited_h:Inhabited ℝ⊢ a 3 = 11)
inhabited_h:Inhabited ℝ⊢ Nat.nth (fun p ↦ Nat.Prime p ∧ Nat.Prime (p + 2)) 2 = 11
exact (congr_arg _ (inhabited_h:Inhabited ℝ⊢ 2 = Nat.count (fun p ↦ Nat.Prime p ∧ Nat.Prime (p + 2)) 11 All goals completed! 🐙)).trans (Nat.nth_count (inhabited_h:Inhabited ℝ⊢ Nat.Prime 11 ∧ Nat.Prime (11 + 2) All goals completed! 🐙))
Value of the sequence a at 4.
@[category test, AMS 11]
theorem a_4 : a 4 = 17 := ⊢ a 4 = 17
⊢ Nat.nth (fun p ↦ Nat.Prime p ∧ Nat.Prime (p + 2)) 3 = 17
exact (congr_arg _ (⊢ 3 = Nat.count (fun p ↦ Nat.Prime p ∧ Nat.Prime (p + 2)) 17 All goals completed! 🐙) ).trans (Nat.nth_count (⊢ Nat.Prime 17 ∧ Nat.Prime (17 + 2) All goals completed! 🐙))Primes $p_k$ such that $p_k! \equiv 1 \pmod{p_{k+1}}$ with the exception of $p_{991} = 7841$ and other unknown primes $p_k$ for which $(p_k+1)(p_k+2)\cdots(p_{k+1}-2) \equiv 1 \pmod{p_{k+1}}$ where $p_{k+1} - p_k > 2$.
@[category research open, AMS 11]
theorem conjecture (k : ℕ) (hk : k > 1) :
let Pk := Nat.nth Nat.Prime (k - 1)
let Pk_succ := Nat.nth Nat.Prime k
let Congruence := Pk.factorial ≡ 1 [MOD Pk_succ]
let IsLesserTwinPrime := (Pk + 2).Prime
let Wk_prod : ℕ := ∏ i ∈ Finset.Icc (Pk + 1) (Pk_succ - 2), i
Congruence ↔ (IsLesserTwinPrime ∨ (k = 991) ∨ (Pk_succ - Pk > 2 ∧ Wk_prod ≡ 1 [MOD Pk_succ])) :=
k:ℕhk:k > 1⊢ let Pk := Nat.nth Nat.Prime (k - 1);
let Pk_succ := Nat.nth Nat.Prime k;
let Congruence := Pk.factorial ≡ 1 [MOD Pk_succ];
let IsLesserTwinPrime := Nat.Prime (Pk + 2);
let Wk_prod := ∏ i ∈ Finset.Icc (Pk + 1) (Pk_succ - 2), i;
Congruence ↔ IsLesserTwinPrime ∨ k = 991 ∨ Pk_succ - Pk > 2 ∧ Wk_prod ≡ 1 [MOD Pk_succ]
All goals completed! 🐙end OeisA1359