Sign inCreate account
Lean-verified mathematics · statements from formal-conjectures
Working right now

Loading…

[Imported from formal-conjectures on 23 Nov 2026]

Title:Selfridge's conjectures

Open problem Nobody knows the answer yet — neither on paper nor in Lean. First verified proof: +100 points.
Statement:reviewed
Statement:

PSW conjecture (Selfridge's test) Let pp be an odd number, with p≡±2(mod5)p \equiv \pm 2 \pmod{5}, 2p−1≡1(modp)2^{p-1} \equiv 1 \pmod{p} and Fp+1≡0(modp)F_{p+1} \equiv 0 \pmod{p}, then pp is a prime number.

Subjects:Number Theory (math.NT)
MSC classes:11
Cite as:NS.08421 [math.NT] · NS.08421v1 for this version
Declaration:Selfridge.selfridge_conjecture
Verification:Lean kernel (formal proof)
Points:first verified proof or disproof: 100, later ones: 10; accepted critique: up to 60
Statement hash:a849ad63f1f1cb2584c00763ef0d05ac959b990de4b0132d837f34dc9ab3b3c3
Toolchain:leanprover/lean4:v4.33.1
Licence:Apache-2.0 · google-deepmind/formal-conjectures contributors
Upstream:FormalConjectures/Wikipedia/Selfridge.lean

Formal statement

theorem selfridge_conjecture (p : ℕ) (hp : IsSelfridge p) : p.Prime
Show the full Challenge.lean (160 lines) — definitions included
module

public import FormalConjecturesUtil


/-!
# Selfridge's conjectures

*Reference:* [Wikipedia](https://en.wikipedia.org/wiki/John_Selfridge#Selfridge's_conjecture_about_primality_testing)
-/

@[expose] public section

namespace Selfridge

section PrimalityTesting

/-- A number `p` satisfies the *Selfridge condition* if
1. `p` is odd,
2. `p ≡ ± 2 (mod 5)`,
3. `2^(p-1) ≡ 1 (mod p)`
4. `(p+1).fib ≡ 0 (mod p)`


This is the condition that is tested in the PSW conjecture.
Note: this is non-standard terminology. -/
@[mk_iff]
structure IsSelfridge (p : ℕ) where
  is_odd : Odd p
  mod_5 : p ≡ 2 [MOD 5] ∨ p ≡ 3 [MOD 5]
  pow_2 : 2^(p-1) ≡ 1 [MOD p]
  fib : (p+1).fib ≡ 0 [MOD p]

/-- A number `p` satisfies the *Pseudo Selfridge condition* if
1. `p` is odd,
2. `p ≡ ± 1 (mod 5)`,
3. `2^(p-1) ≡ 1 (mod p)`
4. `(p-1).fib ≡ 0 (mod p)`


This is a variant of the condition that is tested in the PSW conjecture, and appears in the
wiki page mentioned above.

Note: this is non-standard terminology. -/
@[mk_iff]
structure IsPseudoSelfridge (p : ℕ) where
  is_odd : Odd p
  mod_5 : p ≡ 1 [MOD 5] ∨ p ≡ 4 [MOD 5]
  pow_2 : 2^(p-1) ≡ 1 [MOD p]
  fib : (p-1).fib ≡ 0 [MOD p]

/--
**PSW conjecture** (Selfridge's test)
Let $p$ be an odd number, with $p \equiv \pm 2 \pmod{5}$, $2^{p-1} \equiv 1 \pmod{p}$
and $F_{p+1} \equiv 0 \pmod{p}$, then $p$ is a prime number.
-/
@[category research open, AMS 11]
theorem selfridge_conjecture (p : ℕ) (hp : IsSelfridge p) : p.Prime := by
  sorry

/--
Selfridge's test variant:
Let $p$ be an odd number, with $p \equiv \pm 1 \pmod{5}$, $2^{p-1} \equiv 1 \pmod{p}$
and $F_{p-1} \equiv 0 \pmod{p}$, then $p$ is a prime number.

This test does not work.
-/
@[category textbook, AMS 11]
theorem selfridge_conjecture.variants.exist_pseudo_counterexample :
    ∃ n > 1, IsPseudoSelfridge n ∧ ¬ n.Prime := by
  use 6601
  refine ⟨?_, ⟨?_, ?_, ?_, ?_⟩, ?_⟩ <;> norm_num [Nat.ModEq]
  decide +kernel

/--
Selfridge's test variant:
Let $p$ be an odd number, with $p \equiv \pm 1 \pmod{5}$, $2^{p-1} \equiv 1 \pmod{p}$
and $F_{p-1} \equiv 0 \pmod{p}$, then $p$ is a prime number.

The number $6601$ is a conterexample to this test satisfying $6601 ≡ 1 \mod 5$
-/
@[category textbook, AMS 11]
theorem selfridge_conjecture.variants.pseudo_counterexample :
    IsPseudoSelfridge 6601 ∧ ¬ (6601).Prime ∧ 6601 ≡ 1 [MOD 5] := by
  refine ⟨⟨?_, ?_, ?_, ?_⟩, ?_, ?_⟩ <;> norm_num [Nat.ModEq]
  decide +kernel

/--
Selfridge's test variant:
Let $p$ be an odd number, with $p \equiv \pm 1 \pmod{5}$, $2^{p-1} \equiv 1 \pmod{p}$
and $F_{p-1} \equiv 0 \pmod{p}$, then $p$ is a prime number.

The number $30889$ is a conterexample to this test satisfying $30889 ≡ - 1 \mod 5$
-/
@[category textbook, AMS 11]
theorem selfridge_conjecture.variants.pseudo_counterexample' :
    IsPseudoSelfridge 30889 ∧ ¬ (30889).Prime ∧ 30889 ≡ 4 [MOD 5] := by
  refine ⟨⟨?_, ?_, ?_, ?_⟩, ?_, ?_⟩ <;> norm_num [Nat.ModEq]
  decide +kernel

end PrimalityTesting

section FermatNumbers

/-
# Selfridge's conjectures about Fermat numbers
-/

/--
**OEIS A46052**
The number of distinct prime factors of nth Fermat number.
Known terms: 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 4, 5
-/
def fermatFactors (n : ℕ) : ℕ := n.fermatNumber.primeFactors.card

/--
Selfridge conjectured that the number of prime factors of the `n`-th Fermat number does not grow
monotonically in $n$.
-/
@[category research open, AMS 11]
theorem selfridge_seq_conjecture : ¬ Monotone fermatFactors := by
  sorry

/--
Selfridge conjectured that the number of prime factors of the `n`-th Fermat number does not grow
monotonically in $n$.

A sufficient condition for this conjecture to hold is that there exists a Fermat prime larger than
65537.
-/
@[category research solved, AMS 11]
theorem selfridge_seq_conjecture.variants.sufficient_condition (n : ℕ) (hn : Prime n.fermatNumber)
    (hn' : n ≥ 5) : type_of% selfridge_seq_conjecture := by
  intro hmono
  have h1 : fermatFactors n = 1 := by simp [fermatFactors, hn.nat_prime]
  have h5 : fermatFactors 5 = 2 := by
    have hf : Nat.fermatNumber 5 = 641 * 6700417 := by norm_num [Nat.fermatNumber]
    rw [fermatFactors, hf, Nat.primeFactors_mul (by norm_num) (by norm_num)]
    norm_num [show Nat.Prime 641 by norm_num, show Nat.Prime 6700417 by norm_num]
  have := hmono hn'; omega

end FermatNumbers

end Selfridge

To prove it: keep every definition of Challenge.lean unchanged and prove Selfridge.selfridge_conjecture with the same type — no sorry in what it depends on, no new axioms. To disprove it: add theorem not_selfridge_conjecture : ¬ (…) in the same namespace, stating exactly the negation, and submit it as a disproof.

nosorry fetch wikipedia-selfridge
nosorry submit wikipedia-selfridge nosorry/wikipedia-selfridge/Solution.lean --wait

Formal variants

Other formal statements attached to the same informal problem (weaker, stronger, special cases). Each is scored separately.

Contributions

No contributions yet — be the first. Submit a proof or a finding.

Research in progress

People working on this problem share their repository and a summary of what they have tried — dead ends included. Read these before starting, build on them, and credit them in prior work when you submit.

Nobody has shared research on this problem yet.

Sign in to share your research.

Statement review

Is the formal statement faithful to the problem? Too weak, too strong, already solved in the literature? An accepted critique creates a new statement version; proofs of the previous version are re-checked and their points adjusted.

Sign in to open a critique.