Berndt–Galway criterion: a quadratic non-residue mod rules out
ProvedBrocard.berndt_galway_criterionnumber-theory
Let be a prime and let be a natural number. Put
If is a quadratic non-residue modulo , that is,
then is not a perfect square: for every natural number .
This is the criterion behind the computer search of Berndt and Galway for Brocard's equation . Wilson's theorem gives , so . The value of modulo takes only multiplications when is a prime just above . One then looks for such a prime for which the Legendre symbol above is .
Formalization Note. is written as (p - 1).descFactorial (p - 1 - n), and the Legendre symbol is Mathlib's legendreSym p, applied to the integer .
Preamble
import Mathlib.NumberTheory.Wilson import Mathlib.NumberTheory.LegendreSymbol.Basic
Formal statement
namespace Brocard
theorem berndt_galway_criterion (n p : ℕ) [Fact p.Prime] (hn : n < p)
(h : legendreSym p (((p - 1).descFactorial (p - 1 - n) : ℤ) *
(((p - 1).descFactorial (p - 1 - n) : ℤ) - 1)) = -1)
(m : ℕ) : Nat.factorial n + 1 ≠ m ^ 2 := by sorry
end BrocardSource
B. C. Berndt and W. F. Galway, On the Brocard–Ramanujan Diophantine equation n! + 1 = m^2, Ramanujan J. 4 (2000), 41–42 (the sieve criterion used in their search).