/-
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 FormalConjecturesUtilTriangular matchstick numbers in the class of prime numbers
$a(n) = \sum_{k = n}^{2n} p_k$, where $p_k$ is the $k$-th prime.
References:
namespace OeisA105720open Nat Finset
The primary defining sequence a.
$a(n)$ is the sum of primes from the $n$-th prime to the $2n$-th prime, with $p_1=2$.
For $n=0$, we define $a(0) = 0$.
noncomputable def a (n : ℕ) : ℕ :=
if n = 0 then 0
else ∑ i ∈ Ico (n - 1) (2 * n), Nat.nth Nat.Prime ih1:count Nat.Prime 13 = 5h2:Nat.Prime 13⊢ nth Nat.Prime 5 = 13
have h3 := Nat.nth_count h2 h1:count Nat.Prime 13 = 5h2:Nat.Prime 13h3:nth Nat.Prime (count Nat.Prime 13) = 13⊢ nth Nat.Prime 5 = 13
rwa [h1 h1:count Nat.Prime 13 = 5h2:Nat.Prime 13h3:nth Nat.Prime 5 = 13⊢ nth Nat.Prime 5 = 13] h1:count Nat.Prime 13 = 5h2:Nat.Prime 13h3:nth Nat.Prime 5 = 13⊢ nth Nat.Prime 5 = 13 at h3
@[category API, AMS 11]
lemma nth_prime_six : Nat.nth Nat.Prime 6 = 17 := by ⊢ nth Nat.Prime 6 = 17
have h1 : Nat.count Nat.Prime 17 = 6 := by decide h1:count Nat.Prime 17 = 6⊢ nth Nat.Prime 6 = 17 h1:count Nat.Prime 17 = 6⊢ nth Nat.Prime 6 = 17
have h2 : (17).Prime := by decide h1:count Nat.Prime 17 = 6h2:Nat.Prime 17⊢ nth Nat.Prime 6 = 17 h1:count Nat.Prime 17 = 6h2:Nat.Prime 17⊢ nth Nat.Prime 6 = 17
have h3 := Nat.nth_count h2 h1:count Nat.Prime 17 = 6h2:Nat.Prime 17h3:nth Nat.Prime (count Nat.Prime 17) = 17⊢ nth Nat.Prime 6 = 17
rwa [h1 h1:count Nat.Prime 17 = 6h2:Nat.Prime 17h3:nth Nat.Prime 6 = 17⊢ nth Nat.Prime 6 = 17] h1:count Nat.Prime 17 = 6h2:Nat.Prime 17h3:nth Nat.Prime 6 = 17⊢ nth Nat.Prime 6 = 17 at h3
@[category API, AMS 11]
lemma nth_prime_seven : Nat.nth Nat.Prime 7 = 19 := by ⊢ nth Nat.Prime 7 = 19
have h1 : Nat.count Nat.Prime 19 = 7 := by decide h1:count Nat.Prime 19 = 7⊢ nth Nat.Prime 7 = 19 h1:count Nat.Prime 19 = 7⊢ nth Nat.Prime 7 = 19
have h2 : (19).Prime := by decide h1:count Nat.Prime 19 = 7h2:Nat.Prime 19⊢ nth Nat.Prime 7 = 19 h1:count Nat.Prime 19 = 7h2:Nat.Prime 19⊢ nth Nat.Prime 7 = 19
have h3 := Nat.nth_count h2 h1:count Nat.Prime 19 = 7h2:Nat.Prime 19h3:nth Nat.Prime (count Nat.Prime 19) = 19⊢ nth Nat.Prime 7 = 19
rwa [h1 h1:count Nat.Prime 19 = 7h2:Nat.Prime 19h3:nth Nat.Prime 7 = 19⊢ nth Nat.Prime 7 = 19] h1:count Nat.Prime 19 = 7h2:Nat.Prime 19h3:nth Nat.Prime 7 = 19⊢ nth Nat.Prime 7 = 19 at h3macro "eval_a" : tactic => `(tactic| (
repeat rw [Finset.sum_Ico_succ_top (by decide)]
simp only [Finset.Ico_self, Finset.sum_empty, zero_add, add_zero]
simp only [Nat.nth_prime_zero_eq_two, Nat.nth_prime_one_eq_three,
Nat.nth_prime_two_eq_five, Nat.nth_prime_three_eq_seven,
Nat.nth_prime_four_eq_eleven, nth_prime_five, nth_prime_six, nth_prime_seven]
try rfl
))
Value of the sequence a at 0.
@[category test, AMS 11]
theorem a_0 : a 0 = 0 := by ⊢ a 0 = 0
rw [a, ⊢ (if 0 = 0 then 0 else ∑ i ∈ Ico (0 - 1) (2 * 0), nth Nat.Prime i) = 0 All goals completed! 🐙 if_pos rfl ⊢ 0 = 0 All goals completed! 🐙] All goals completed! 🐙
Value of the sequence a at 1.
@[category test, AMS 11]
theorem a_1 : a 1 = 5 := by ⊢ a 1 = 5
rw [a, ⊢ (if 1 = 0 then 0 else ∑ i ∈ Ico (1 - 1) (2 * 1), nth Nat.Prime i) = 5 ⊢ ∑ i ∈ Ico (1 - 1) (2 * 1), nth Nat.Prime i = 5 if_neg (by ⊢ ¬1 = 0 ⊢ ∑ i ∈ Ico (1 - 1) (2 * 1), nth Nat.Prime i = 5 decide All goals completed! 🐙 ⊢ ∑ i ∈ Ico (1 - 1) (2 * 1), nth Nat.Prime i = 5)] ⊢ ∑ i ∈ Ico (1 - 1) (2 * 1), nth Nat.Prime i = 5
eval_a All goals completed! 🐙
Value of the sequence a at 2.
@[category test, AMS 11]
theorem a_2 : a 2 = 15 := by ⊢ a 2 = 15
rw [a, ⊢ (if 2 = 0 then 0 else ∑ i ∈ Ico (2 - 1) (2 * 2), nth Nat.Prime i) = 15 ⊢ ∑ i ∈ Ico (2 - 1) (2 * 2), nth Nat.Prime i = 15 if_neg (by ⊢ ¬2 = 0 ⊢ ∑ i ∈ Ico (2 - 1) (2 * 2), nth Nat.Prime i = 15 decide All goals completed! 🐙 ⊢ ∑ i ∈ Ico (2 - 1) (2 * 2), nth Nat.Prime i = 15)] ⊢ ∑ i ∈ Ico (2 - 1) (2 * 2), nth Nat.Prime i = 15
eval_a All goals completed! 🐙
Value of the sequence a at 3.
@[category test, AMS 11]
theorem a_3 : a 3 = 36 := by ⊢ a 3 = 36
rw [a, ⊢ (if 3 = 0 then 0 else ∑ i ∈ Ico (3 - 1) (2 * 3), nth Nat.Prime i) = 36 ⊢ ∑ i ∈ Ico (3 - 1) (2 * 3), nth Nat.Prime i = 36 if_neg (by ⊢ ¬3 = 0 ⊢ ∑ i ∈ Ico (3 - 1) (2 * 3), nth Nat.Prime i = 36 decide All goals completed! 🐙 ⊢ ∑ i ∈ Ico (3 - 1) (2 * 3), nth Nat.Prime i = 36)] ⊢ ∑ i ∈ Ico (3 - 1) (2 * 3), nth Nat.Prime i = 36
eval_a All goals completed! 🐙
Value of the sequence a at 4.
@[category test, AMS 11]
theorem a_4 : a 4 = 67 := by ⊢ a 4 = 67
rw [a, ⊢ (if 4 = 0 then 0 else ∑ i ∈ Ico (4 - 1) (2 * 4), nth Nat.Prime i) = 67 ⊢ ∑ i ∈ Ico (4 - 1) (2 * 4), nth Nat.Prime i = 67 if_neg (by ⊢ ¬4 = 0 ⊢ ∑ i ∈ Ico (4 - 1) (2 * 4), nth Nat.Prime i = 67 decide All goals completed! 🐙 ⊢ ∑ i ∈ Ico (4 - 1) (2 * 4), nth Nat.Prime i = 67)] ⊢ ∑ i ∈ Ico (4 - 1) (2 * 4), nth Nat.Prime i = 67
eval_a All goals completed! 🐙Terms are squares at only(?) three values of $n = 3, 6, 4072$: corresponding terms are 6^2, 13^2, and 15735^2.
@[category research open, AMS 11]
theorem conjecture :
∀ n : ℕ, 0 < n → (IsSquare (a n) ↔ (n = 3 ∨ n = 6 ∨ n = 4072)) := by ⊢ ∀ (n : ℕ), 0 < n → (IsSquare (OeisA105720.a n) ↔ n = 3 ∨ n = 6 ∨ n = 4072)
sorry All goals completed! 🐙end OeisA105720