Algorithm Search⌘K

Proofs: Multiple-polynomial quadratic sieve

These are the human proofs of Multiple-polynomial quadratic sieve, at full length.

Correctness of the multiple polynomial quadratic sieve full

This proof shows: correctness, termination.

Throughout, N≥3N \ge 3 is odd and not a perfect square, and FF is the factor base of line L1: −1-1, 22, and the odd primes p≤Bp \le B with (N/p)=1(N/p) = 1, each with tp2≡N(modp)t_p^2 \equiv N \pmod p.

Lemma 1 (enough primes qq). There are infinitely many primes qq with (N/q)=1(N/q) = 1. So the search of line L3 always stops.

Proof. First, infinitely many primes divide some value x2−Nx^2 - N with xx an integer. If not, let p1,…,pkp_1, \dots, p_k be all of them and P=p1⋯pkP = p_1 \cdots p_k. Then (NP)2−N=N(NP2−1)(NP)^2 - N = N(NP^2 - 1), and NP2−1≥N−1≥2NP^2 - 1 \ge N - 1 \ge 2 is coprime to PP, so it has a prime factor that is not among the pip_i but divides the value at x=NPx = NP, a contradiction. Now take such a prime qq with q∤2Nq \nmid 2N; all but finitely many qualify. Then x2≡N≢0(modq)x^2 \equiv N \not\equiv 0 \pmod q for some xx, so NN is a nonzero square modulo the odd prime qq, that is, (N/q)=1(N/q) = 1. □\square

Lemma 2 (the polynomial). Let qq be an odd prime with (N/q)=1(N/q) = 1, a=q2a = q^2, and b0b_0 with b02≡N(modq)b_0^2 \equiv N \pmod q, 0<b0<q0 < b_0 < q. Let k=N−b02q⋅(2b0)−1 mod qk = \frac{N - b_0^2}{q} \cdot (2b_0)^{-1} \bmod q and b=b0+kqb = b_0 + kq, replaced by a−ba - b if 2b>a2b > a. Then b2≡N(moda)b^2 \equiv N \pmod a, 0<b≤a/20 < b \le a/2, c=(b2−N)/ac = (b^2 - N)/a is an integer, b2−ac=Nb^2 - ac = N, and for every integer xx

af(x)=(ax+b)2−N≠0,f(x)=ax2+2bx+c.a f(x) = (ax + b)^2 - N \ne 0, \qquad f(x) = ax^2 + 2bx + c.

Proof. Since (N/q)=1(N/q) = 1, q∤Nq \nmid N, so q∤b0q \nmid b_0, and qq is odd, so 2b02b_0 is invertible modulo qq and kk is defined. The quotient (N−b02)/q(N - b_0^2)/q is an integer as q∣N−b02q \mid N - b_0^2. Then

b2=b02+2b0kq+k2q2≡b02+2b0kq(modq2),b^2 = b_0^2 + 2b_0kq + k^2q^2 \equiv b_0^2 + 2b_0kq \pmod{q^2},

and 2b0k≡(N−b02)/q(modq)2b_0k \equiv (N - b_0^2)/q \pmod q gives 2b0kq≡N−b02(modq2)2b_0kq \equiv N - b_0^2 \pmod{q^2}, so b2≡N(modq2)b^2 \equiv N \pmod{q^2}. Also (a−b)2=a2−2ab+b2≡b2(moda)(a - b)^2 = a^2 - 2ab + b^2 \equiv b^2 \pmod a, so the replacement keeps the congruence. Before it, 1≤b0≤b≤(q−1)+(q−1)q<a1 \le b_0 \le b \le (q - 1) + (q - 1)q < a, so 0<b<a0 < b < a, and after it 0<b≤a/20 < b \le a/2. The congruence makes cc an integer, and ac=b2−Nac = b^2 - N is b2−ac=Nb^2 - ac = N. Expanding, (ax+b)2−N=a2x2+2abx+b2−N=a2x2+2abx+ac=af(x)(ax + b)^2 - N = a^2x^2 + 2abx + b^2 - N = a^2x^2 + 2abx + ac = af(x). This is not 00, since NN is not a perfect square. □\square

Lemma 3 (the root classes). Let ff be as in Lemma 2 with q>Bq > B. For an odd p∈Fp \in F, the two classes x≡(±tp−b)a−1(modp)x \equiv (\pm t_p - b)a^{-1} \pmod p are distinct, and p∣f(x)p \mid f(x) if and only if xx is in one of them. Also 2∣f(x)2 \mid f(x) if and only if x≡c(mod2)x \equiv c \pmod 2.

Proof. Let p∈Fp \in F be odd. Then p≤B<qp \le B < q, so p∤a=q2p \nmid a = q^2 and a−1 mod pa^{-1} \bmod p exists. Also (N/p)=1(N/p) = 1 gives p∤Np \nmid N, so tp≢−tp(modp)t_p \not\equiv -t_p \pmod p, since otherwise p∣2tpp \mid 2t_p, so p∣tpp \mid t_p and p∣tp2p \mid t_p^2, and then tp2≡Nt_p^2 \equiv N gives p∣Np \mid N; so the two classes are distinct. As p∤ap \nmid a, p∣f(x)p \mid f(x) if and only if p∣af(x)=(ax+b)2−Np \mid af(x) = (ax + b)^2 - N, which is (ax+b)2≡tp2(ax + b)^2 \equiv t_p^2, that is, (ax+b−tp)(ax+b+tp)≡0(modp)(ax + b - t_p)(ax + b + t_p) \equiv 0 \pmod p. Since pp is prime, this holds if and only if ax+b≡±tpax + b \equiv \pm t_p, that is, x≡(±tp−b)a−1(modp)x \equiv (\pm t_p - b)a^{-1} \pmod p. For p=2p = 2: aa is odd and x2≡x(mod2)x^2 \equiv x \pmod 2, so f(x)=ax2+2bx+c≡x+c(mod2)f(x) = ax^2 + 2bx + c \equiv x + c \pmod 2. □\square

Lemma 4 (the sieve). After line L5, for every x∈[−M,M)x \in [-M, M), S[x]S[x] is the sum of log⁡p\log p over the distinct primes p∈Fp \in F, p>0p > 0, that divide f(x)f(x).

Proof. Line L5 starts with S[x]=0S[x] = 0 and adds log⁡p\log p once for each root class of pp that contains xx. By Lemma 3, an odd pp has two distinct classes and xx lies in one of them exactly when p∣f(x)p \mid f(x), so log⁡p\log p is added once if p∣f(x)p \mid f(x) and never otherwise. For p=2p = 2 the single class x≡cx \equiv c gives the same. □\square

Lemma 5 (relations). Every relation (r,v)(r, v) appended at line L6 satisfies r2≡∏p∈Fpvp(modN)r^2 \equiv \prod_{p \in F} p^{v_p} \pmod N, with p=−1p = -1 included.

Proof. Line L6 appends (r,v)(r, v) only when trial division shows f(x)=∏p∈Fpvpf(x) = \prod_{p \in F} p^{v_p}, with v−1=1v_{-1} = 1 exactly when f(x)<0f(x) < 0. Here r≡(ax+b)q−1(modN)r \equiv (ax + b)q^{-1} \pmod N, where q−1q^{-1} exists because q∤Nq \nmid N. By Lemma 2, (ax+b)2=N+af(x)≡q2f(x)(modN)(ax + b)^2 = N + af(x) \equiv q^2 f(x) \pmod N, so r2≡q2f(x)q−2=f(x)(modN)r^2 \equiv q^2 f(x) q^{-2} = f(x) \pmod N. □\square

Lemma 6 (the elimination). Let v1,…,vmv_1, \dots, v_m be the exponent vectors mod 2, as bit masks over the ∣F∣|F| coordinates of FF. Gaussian elimination that records, for each reduced row, the set hh of original rows added into it, produces for each row that reduces to 00 a nonempty set hh with ⨁l∈hvl=0\bigoplus_{l \in h} v_l = 0. If m>∣F∣m > |F|, at least m−∣F∣m - |F| such sets are found.

Proof. Row jj starts with u=vju = v_j and h={j}h = \{j\}. Each reduction adds a stored pivot pair (u′,h′)(u', h') with u′=⨁l∈h′vlu' = \bigoplus_{l \in h'} v_l to (u,h)(u, h) by ⊕\oplus in both parts, so u=⨁l∈hvlu = \bigoplus_{l \in h} v_l stays true. The stored pairs come from earlier rows, so j∉h′j \notin h' and jj stays in hh, which is therefore nonempty. Each reduction clears the leading bit of uu and changes only lower bits, so the row either reduces to 00 or becomes a pivot with a new leading bit. There are ∣F∣|F| coordinates, so at most ∣F∣|F| pivots, and at least m−∣F∣m - |F| rows reduce to 00. □\square

Theorem. MPQS stops, and it returns 11 or a proper factor gg of NN. Each subset TT tried at line L7 satisfies X2≡Y2(modN)X^2 \equiv Y^2 \pmod N. If the loop ends with ∣R∣≥∣F∣+E|R| \ge |F| + E, at least EE subsets are tried.

Proof. Termination. Each pass of the loop of line L2 uses one more polynomial, and the loop stops after at most PP of them. In each pass, line L3 stops by Lemma 1, lines L4 and L5 do finitely many steps for the finitely many primes of FF on an interval of 2M2M values, and trial division of the nonzero integer f(x)f(x) (Lemma 2) by primes stops. Line L7 runs over finitely many subsets.

Congruence of squares. Let TT be a subset from Lemma 6 and e=∑(r,v)∈Tve = \sum_{(r, v) \in T} v over the integers. Every epe_p is even, including e−1e_{-1}. By Lemma 5,

X2≡∏(r,v)∈Tr2≡∏p∈Fpep=(−1)e−1∏p>0(pep/2)2≡Y2(modN),X^2 \equiv \prod_{(r, v) \in T} r^2 \equiv \prod_{p \in F} p^{e_p} = (-1)^{e_{-1}} \prod_{p > 0} \big(p^{e_p/2}\big)^2 \equiv Y^2 \pmod N,

since (−1)e−1=1(-1)^{e_{-1}} = 1. The relations of TT may come from different polynomials, since each satisfies Lemma 5 over the same FF. The count of subsets is Lemma 6 with m=∣R∣m = |R|.

Correctness. The only return other than line L8 is in line L7, which returns g=gcd⁡(X−Y,N)g = \gcd(X - Y, N) only if 1<g<N1 < g < N. A gcd with NN divides NN, so gg is a proper factor. A prime NN has none, so for a prime NN the output is 11. The threshold τ\tau of line L6 decides only which values are tried by trial division, and keeping only one relation for each value of ±r\pm r only removes relations, so neither affects these statements. ■\blacksquare

Back to Multiple-polynomial quadratic sieve