/- 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

Determinant of Legendre symbol matrix with factorial shifts

Determinant of the $(p_n-1)/2$-by-$(p_n-1)/2$ matrix with $(i,j)$-entry being the Legendre symbol $$\left(\frac{i^2 - \left(\frac{p_n-1}{2}\right)! j}{p_n}\right),$$ where $p_n$ is the $n$-th prime ($n \ge 2$).

References:

    A226163

    T. Adamczewski, "OEIS Open: How many conjectures can language models turn into theorems?", arXiv:2608.11941 [cs.AI], 2026.

@[expose] public sectionnamespace OeisA226163open Matrix

The $(p-1)/2$-by-$(p-1)/2$ matrix with $(i,j)$-entry being the Jacobi symbol $\left(\frac{i^2 - \left(\frac{p-1}{2}\right)! j}{p}\right)$ for $1 \le i, j \le (p-1)/2$.

def legendreMatrix (p : ℕ) : Matrix (Fin ((p - 1) / 2)) (Fin ((p - 1) / 2)) ℤ := let m : ℕ := (p - 1) / 2 let C : ℤ := m.factorial fun i j => let i' : ℤ := i.val + 1 let j' : ℤ := j.val + 1 jacobiSym (i' * i' - C * j') p

Determinant of legendreMatrix for the $n$-th prime $p_n$.

noncomputable def a (n : ℕ) : ℤ := (legendreMatrix (Nat.nth Nat.Prime (n - 1))).deth:Nat.nth Nat.Prime (2 - 1) = 3⊢ legendreMatrix 3 0 0 = 0 All goals completed! 🐙h:Nat.nth Nat.Prime (3 - 1) = 5⊢ legendreMatrix 5 0 0 * legendreMatrix 5 1 1 - legendreMatrix 5 0 1 * legendreMatrix 5 1 0 = -1 All goals completed! 🐙h:Nat.nth Nat.Prime (4 - 1) = 7hM:legendreMatrix 7 = !![1, -1, 1; -1, -1, 0; -1, 1, -1]⊢ !![1, -1, 1; -1, -1, 0; -1, 1, -1].det = 0 All goals completed! 🐙h:Nat.nth Nat.Prime (5 - 1) = 11hM:legendreMatrix 11 = !![-1, 1, 1, 1, -1; 1, -1, -1, -1, 1; -1, 0, 1, -1, 1; -1, -1, -1, 1, -1; 1, 1, -1, -1, -1]⊢ !![-1, 1, 1, 1, -1; 1, -1, -1, -1, 1; -1, 0, 1, -1, 1; -1, -1, -1, 1, -1; 1, 1, -1, -1, -1].det = 0 All goals completed! 🐙h:Nat.nth Nat.Prime (6 - 1) = 13hM:legendreMatrix 13 = !![1, 1, 1, -1, -1, 1; 1, -1, -1, 1, -1, 0; 1, 1, -1, -1, 1, -1; -1, -1, 1, 1, 1, 1; -1, -1, 1, -1, 0, -1; -1, 0, -1, 1, -1, -1]⊢ !![1, 1, 1, -1, -1, 1; 1, -1, -1, 1, -1, 0; 1, 1, -1, -1, 1, -1; -1, -1, 1, 1, 1, 1; -1, -1, 1, -1, 0, -1; -1, 0, -1, 1, -1, -1].det = -8 All goals completed! 🐙

Conjecture: $a(n) = 0$ if and only if $p_n \equiv 3 \pmod 4$.

    Zhi-Wei Sun, Aug 13 2013

Proved in the OEIS Open project, see T. Adamczewski, OEIS Open: How many conjectures can language models turn into theorems?, arXiv:2608.11941.

@[category research solved, AMS 11] theorem conjecture (n : ℕ) (hn : 2 ≤ n) : a n = 0 ↔ Nat.nth Nat.Prime (n - 1) % 4 = 3 := n:ℕhn:2 ≤ n⊢ a n = 0 ↔ Nat.nth Nat.Prime (n - 1) % 4 = 3 All goals completed! 🐙end OeisA226163