Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

GNFS: base-mmm polynomial and homogenization

Definition
GNFS_defs

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

integer-factorizationnumber-theory

Two auxiliary objects used throughout the mission.

  1. Base-mmm polynomial. For natural numbers nnn and mmm, let n=admd+⋯+a1m+a0n = a_d m^d + \dots + a_1 m + a_0n=ad​md+⋯+a1​m+a0​ be the base-mmm expansion of nnn, with digits a0,…,ada_0, \dots, a_da0​,…,ad​ (least significant first, as returned by the standard digit expansion; empty when n=0n = 0n=0). The base-mmm polynomial of nnn is
fn,m(x)=∑i=0daixi∈Z[x].f_{n,m}(x) = \sum_{i=0}^{d} a_i x^i \in \mathbb{Z}[x].fn,m​(x)=i=0∑d​ai​xi∈Z[x].
  1. Homogenization. For f=∑i=0dcixi∈Z[x]f = \sum_{i=0}^{d} c_i x^i \in \mathbb{Z}[x]f=∑i=0d​ci​xi∈Z[x] of degree ddd and integers a,ba, ba,b,
F(a,b)=∑i=0dci aibd−i=bdf(a/b).F(a,b) = \sum_{i=0}^{d} c_i\, a^i b^{d-i} = b^d f(a/b).F(a,b)=i=0∑d​ci​aibd−i=bdf(a/b).

The first is the simple polynomial-selection method of GNFS; the second is the integer rrr attached to a relation (a,b)(a,b)(a,b), whose smoothness the sieve tests.

Formalization Note Digits come from Nat.digits m n. For m≤1m \le 1m≤1 that function does not give a base-mmm expansion, so statements about it assume m≥2m \ge 2m≥2. In homogenize, 00=10^0 = 100=1, so F(a,0)=cdadF(a,0) = c_d a^dF(a,0)=cd​ad.

Definition code
import Mathlib

/-!
# General number field sieve — definitions

Shared definitions for the Prove2Me mission proposal drafted from the Wikipedia article
"General number field sieve" (`General_number_field_sieve.pdf`).
-/

open Polynomial

namespace GNFS

/-- The base-`m` polynomial of `n`: if `n = a_d m^d + ⋯ + a_1 m + a_0` is the base-`m`
expansion of `n` (digits `0 ≤ a_i < m`), this is `f(x) = a_d x^d + ⋯ + a_1 x + a_0`. -/
noncomputable def baseMPolynomial (n m : ℕ) : ℤ[X] :=
  ∑ i ∈ Finset.range (Nat.digits m n).length, C (((Nat.digits m n).getD i 0 : ℕ) : ℤ) * X ^ i

/-- The homogenization `F(a, b) = b^d f(a/b) = ∑ c_i a^i b^(d-i)` of an integer polynomial
`f = ∑ c_i x^i` of degree `d`, evaluated at a pair of integers `(a, b)`. -/
def homogenize (f : ℤ[X]) (a b : ℤ) : ℤ :=
  ∑ i ∈ Finset.range (f.natDegree + 1), f.coeff i * a ^ i * b ^ (f.natDegree - i)

end GNFS
Source
Wikipedia, "General number field sieve" (revision oldid=1377718368, https://en.wikipedia.org/w/index.php?title=General_number_field_sieve&oldid=1377718368), sections 'Polynomial choice' and 'Generation of relation pairs (sieving)'
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