files / problems / brocard / WALKTHROUGH.md

4.0 KB · on GitHub

Walkthrough — Move the prime just beyond the factorial

0. What was actually missing

A fixed prime cannot exclude an infinite set of large factorial indices. Once n≥pn\ge p, one has n!+1≡1(modp)n!+1\equiv1\pmod p, which is already a square residue. The missing degree of freedom was a prime modulus that moves with nn while leaving only a constant-size tail between nn and the Wilson factorial (p−1)!(p-1)!.

1. Named false starts

2. The useful failure

Writing the modulus as a fixed number was the common defect. Writing it as p=n+cp=n+c makes it grow, and Wilson's theorem evaluates the missing tail:

n!≡(−1)c(c−1)!(modp).n!\equiv\frac{(-1)^c}{(c-1)!}\pmod p.

This is useful only when the resulting constant is provably a nonresidue on a whole prime congruence class.

3. The click

The smallest offset is already enough. If p=n+2p=n+2, then Wilson gives n!≡1(modp)n!\equiv1\pmod p, so a Brown equation would force

m2≡2(modp).m^2\equiv2\pmod p.

The supplementary law says that 2 is a quadratic nonresidue when p≡3p\equiv3 or 5(mod8)5\pmod8. Those two prime classes are infinite, and shifting them by 2 produces two infinite families of excluded indices. Offset 3 gives two more families with the same character.

4. The argument

For p=n+2p=n+2, Wilson's congruence is

−1≡(p−1)!=(p−2)!(p−1)≡−n!(modp).-1\equiv(p-1)!=(p-2)!(p-1)\equiv-n!\pmod p.

Thus n!+1≡2(modp)n!+1\equiv2\pmod p. This cannot equal a square when p≡3,5(mod8)p\equiv3,5\pmod8.

For p=n+3>3p=n+3>3, the two omitted factors give

−1≡(p−1)!=n!(p−2)(p−1)≡2n!(modp).-1\equiv(p-1)!=n!(p-2)(p-1)\equiv2n!\pmod p.

Hence n!+1≡1/2(modp)n!+1\equiv1/2\pmod p. If m2≡1/2m^2\equiv1/2, then (2m)2≡2(2m)^2\equiv2, again impossible in the same two prime classes.

Dirichlet's theorem supplies infinitely many primes in each of the reduced classes 3 and 5 modulo 8. The result therefore excludes the four infinite prime-offset families

n=p−2andn=p−3,qquadp≡3,5(mod8).n=p-2\quad\text{and}\quad n=p-3,qquad p\equiv3,5\pmod8.

The condition that the shifted number is prime remains essential.

5. Computer search and formal check

The certificate file compute/q3/offset-certificate.json records the offset, prime class, index class, rational target, and sample count for every row. The Python generator recomputes factorials modulo each prime through 10,000. The independent C verifier uses separate primality, modular exponentiation, and factorial loops. Their complete reports agree: 1,249 row instances pass.

lean/WilsonOffset.lean formalizes the offset-2 proof. It derives the factorial congruence from mathlib's Wilson theorem and closes the nonresidue step with mathlib's characterization of when 2 is a square modulo a prime. The theorem has no bounded enumeration and no sorry.

Replay all three checks with:

problems/brocard/compute/q3/run_all.sh

6. Proved versus still open