Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Classical reduction: gcd⁡(N,ar/2∓1)\gcd(N, a^{r/2} \mp 1)gcd(N,ar/2∓1) are nontrivial factors when N∤ar/2+1N \nmid a^{r/2}+1N∤ar/2+1

Proved
ShorWiki.gcd_pow_half_nontrivial

by Lucas · Oct 13, 2026 · Mathlib 0df444a (Lean v4.33.1)

quantum-computingshor-algorithm

Let 1<a<N1 < a < N1<a<N with gcd⁡(a,N)=1\gcd(a, N) = 1gcd(a,N)=1 and let r=ord⁡N(a)r = \operatorname{ord}_N(a)r=ordN​(a). Suppose rrr is even and N∤ar/2+1N \nmid a^{r/2} + 1N∤ar/2+1. Then both

d=gcd⁡ ⁣(N, ar/2−1)andd′=gcd⁡ ⁣(N, ar/2+1)d = \gcd\!\left(N,\ a^{r/2} - 1\right) \quad\text{and}\quad d' = \gcd\!\left(N,\ a^{r/2} + 1\right)d=gcd(N, ar/2−1)andd′=gcd(N, ar/2+1)

are nontrivial factors of NNN:

1<d<N,1<d′<N.1 < d < N, \qquad 1 < d' < N .1<d<N,1<d′<N.

This is the success criterion of Shor's algorithm: an even order with ar/2≢−1(modN)a^{r/2} \not\equiv -1 \pmod Nar/2≡−1(modN) splits NNN by a single gcd computation.

Preamble
import Mathlib
import Definitions.Def_ShorWiki_Defs

open Matrix Kronecker
Formal statement
namespace ShorWiki

theorem gcd_pow_half_nontrivial (N a : ℕ) (ha : 1 < a) (haN : a < N)
    (hcop : Nat.Coprime a N) (heven : Even (ord N a))
    (hndvd : ¬ N ∣ a ^ (ord N a / 2) + 1) :
    (1 < Nat.gcd N (a ^ (ord N a / 2) - 1) ∧ Nat.gcd N (a ^ (ord N a / 2) - 1) < N) ∧
      (1 < Nat.gcd N (a ^ (ord N a / 2) + 1) ∧ Nat.gcd N (a ^ (ord N a / 2) + 1) < N) := by sorry

end ShorWiki
Source
Wikipedia, "Shor's algorithm", revision oldid=1378862216, https://en.wikipedia.org/w/index.php?title=Shor%27s_algorithm&oldid=1378862216, section "Classical reduction" (PDF p. 3) and restated algorithm, step 6
Human review
  • Endorsed by Shuze Chen · Oct 13, 2026

    Confirmed by the moderator at approval.

  • Endorsed by Lucas · Oct 13, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me