Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

A nontrivial congruence of squares splits nnn (QS / GNFS)

Proved
PolyTimeFactorization.congruent_squares_split

by LG · Nov 16, 2026 · Mathlib 0df444a (Lean v4.33.1)

factorizationnumber-theorysieve

Let n≥1n\ge 1n≥1 and x,y∈Zx,y\in\mathbb{Z}x,y∈Z. If x2≡y2(modn)x^2\equiv y^2\pmod nx2≡y2(modn) but x≢y(modn)x\not\equiv y\pmod nx≡y(modn) and x≢−y(modn)x\not\equiv -y\pmod nx≡−y(modn), then

1<gcd⁡(x−y, n)<n,1<\gcd(x-y,\,n)<n,1<gcd(x−y,n)<n,

so gcd⁡(x−y,n)\gcd(x-y,n)gcd(x−y,n) is a nontrivial divisor of nnn.

This is the splitting step that concludes both the quadratic sieve and the number field sieve: once a congruence of squares is found that is nontrivial modulo nnn, a single gcd reveals a proper factor. The two exclusions x≢±y(modn)x\not\equiv\pm y\pmod nx≡±y(modn) are exactly what rules out the trivial factors 111 and nnn.

Preamble
import Mathlib
Formal statement
namespace PolyTimeFactorization

theorem congruent_squares_split (n : ℕ) (x y : ℤ) (hn : 0 < n)
    (hsq : (n : ℤ) ∣ x ^ 2 - y ^ 2)
    (hxy : ¬ (n : ℤ) ∣ x - y) (hxy' : ¬ (n : ℤ) ∣ x + y) :
    1 < Int.gcd (x - y) (n : ℤ) ∧ Int.gcd (x - y) (n : ℤ) < n := by sorry

end PolyTimeFactorization
Source
C. Pomerance, The quadratic sieve factoring algorithm, EUROCRYPT '84, LNCS 209 (1985), 169-182, https://doi.org/10.1007/3-540-39757-4_17 ; J. P. Buhler, H. W. Lenstra Jr., C. Pomerance, Factoring integers with the number field sieve, LNM 1554 (1993), 50-94, https://doi.org/10.1007/BFb0091539 (the congruence-of-squares principle)
Human review
  • Endorsed by Shuze Chen · Nov 16, 2026

    Confirmed by the moderator at approval.

  • Endorsed by LG · Nov 16, 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 paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me