Algorithm Search⌘K

Proofs: Lehman's factorization method

These are the human proofs of Lehman's factorization method, at full length.

Correctness of Lehman's factorization method full

This proof shows: correctness, termination.

Let N≥22N \ge 22, and write t=N1/3t = N^{1/3}, a real number with t>2.8t > 2.8.

Termination. Line L1 is a finite loop. For each kk, the value a2−4kNa^2 - 4kN grows with aa without bound, so the loop of line L4 ends; the loop of line L2 has ⌊t⌋+1\lfloor t \rfloor + 1 passes. So the algorithm stops.

Lemma 1 (a returned gcd is a proper factor). Suppose line L5 returns for some k≤t+1k \le t + 1 and some aa with a2−4kN=b2a^2 - 4kN = b^2, b≥0b \ge 0, and (a2−4kN)3<N2(a^2 - 4kN)^3 < N^2. Then d=gcd⁡(a+b,N)d = \gcd(a + b, N) satisfies 1<d<N1 < d < N.

Proof. From b6<N2b^6 < N^2 we get b<tb < t. From a2=4kN+b2<4(t+1)t3+t2=t2(2t+1)2a^2 = 4kN + b^2 < 4(t + 1)t^3 + t^2 = t^2(2t + 1)^2, we get a<t(2t+1)a < t(2t + 1). So a+b<2t2+2ta + b < 2t^2 + 2t. The inequality 2t2+2t<t32t^2 + 2t < t^3 is t2−2t−2>0t^2 - 2t - 2 > 0, which holds for t>1+3≈2.73t > 1 + \sqrt 3 \approx 2.73, so for N>20.4N > 20.4. Hence a+b<Na + b < N. Also a2−b2=4kN>0a^2 - b^2 = 4kN > 0 with a,b≥0a, b \ge 0, so a>ba > b and a−b≥1a - b \ge 1.

NN divides 4kN=(a+b)(a−b)4kN = (a + b)(a - b). If d=Nd = N, then N∣a+bN \mid a + b with 0<a+b<N0 < a + b < N, which is impossible. If d=1d = 1, then N∣a−bN \mid a - b, and 0<a−b<a+b<N0 < a - b < a + b < N, which is impossible. So 1<d<N1 < d < N. □\square

Lemma 2 (Dirichlet). Let ξ\xi be a real number and B>1B > 1 a real number. There are integers uu and vv with 1≤v≤B1 \le v \le B and ∣vξ−u∣<1/B|v\xi - u| < 1/B.

Proof. Let M=⌊B⌋≥1M = \lfloor B \rfloor \ge 1. The M+2M + 2 numbers 0,10, 1 and {jξ}=jξ−⌊jξ⌋\{j\xi\} = j\xi - \lfloor j\xi \rfloor for j=1,…,Mj = 1, \dots, M lie in [0,1][0, 1]. Split [0,1][0, 1] into the M+1M + 1 closed intervals [i/(M+1),(i+1)/(M+1)][i/(M + 1), (i + 1)/(M + 1)]. Two of the M+2M + 2 numbers lie in the same interval, so they differ by at most 1/(M+1)1/(M + 1). Each of the numbers has the form jξ−ujj\xi - u_j with 0≤j≤M0 \le j \le M (with 0=0ξ−00 = 0\xi - 0 and 1=0ξ+11 = 0\xi + 1), and the two chosen numbers cannot both have j=0j = 0, because 00 and 11 differ by 1>1/(M+1)1 > 1/(M + 1). Their difference is vξ−uv\xi - u with 1≤∣v∣≤M1 \le |v| \le M; replacing (v,u)(v, u) by (−v,−u)(-v, -u) if needed, 1≤v≤M≤B1 \le v \le M \le B, and ∣vξ−u∣≤1/(M+1)<1/B|v\xi - u| \le 1/(M + 1) < 1/B since M+1>BM + 1 > B. □\square

Lemma 3 (a good multiplier exists). Let N=pqN = pq with primes t<p≤qt < p \le q. Then there are integers u,v≥1u, v \ge 1 such that k=uvk = uv satisfies 1≤k<t+11 \le k < t + 1, and a=uq+vpa = uq + vp, b=∣uq−vp∣b = |uq - vp| satisfy a2−b2=4kNa^2 - b^2 = 4kN, a≥4kNa \ge \sqrt{4kN} and b<tb < t.

Proof. Let B=N1/6q/pB = N^{1/6}\sqrt{q/p}. Since q≥pq \ge p and N>1N > 1, B>1B > 1. Apply Lemma 2 with ξ=p/q\xi = p/q: there are u,vu, v with 1≤v≤B1 \le v \le B and ∣vp/q−u∣<1/B|vp/q - u| < 1/B. Multiply by qq: ∣vp−uq∣<q/B=pq/N1/6=N1/2−1/6=t|vp - uq| < q/B = \sqrt{pq}/N^{1/6} = N^{1/2 - 1/6} = t. So b<tb < t.

If u≤0u \le 0, then ∣vp−uq∣≥vp≥p>t|vp - uq| \ge vp \ge p > t, a contradiction; so u≥1u \ge 1. Next, u<vp/q+1/Bu < vp/q + 1/B, so k=uv<v2p/q+v/B≤B2p/q+1=N1/3+1=t+1k = uv < v^2 p/q + v/B \le B^2 p/q + 1 = N^{1/3} + 1 = t + 1, using v≤Bv \le B.

Finally, a2−b2=(uq+vp)2−(uq−vp)2=4uv pq=4kNa^2 - b^2 = (uq + vp)^2 - (uq - vp)^2 = 4uv\,pq = 4kN, and by the inequality of the means a=uq+vp≥2uq⋅vp=2kNa = uq + vp \ge 2\sqrt{uq \cdot vp} = 2\sqrt{kN}. □\square

Theorem. LEHMAN(NN) returns a divisor dd of NN with 1<d<N1 < d < N if NN is composite, and returns NN if NN is prime.

Proof. If line L1 returns dd, then 2≤d≤t<N2 \le d \le t < N and d∣Nd \mid N. If line L5 returns, then Lemma 1 applies, since the loop of line L2 only uses k≤⌊t⌋+1≤t+1k \le \lfloor t \rfloor + 1 \le t + 1 and line L4 checks (a2−4kN)3<N2(a^2 - 4kN)^3 < N^2. So every value returned on lines L1 or L5 is a proper divisor; in particular, for prime NN neither line returns, and line L7 returns NN.

Let NN be composite, and suppose line L1 returns nothing. Then NN has no prime factor at most tt. If NN had three prime factors (with multiplicity), their product would exceed t3=Nt^3 = N. So N=pqN = pq with primes t<p≤qt < p \le q. Take u,v,k,a,bu, v, k, a, b from Lemma 3. Since kk is an integer with 1≤k<t+11 \le k < t + 1, it satisfies k≤⌊t⌋+1k \le \lfloor t \rfloor + 1, so the loop of line L2 reaches kk unless it returned earlier. For this kk, line L3 starts at ⌈4kN⌉≤a\lceil \sqrt{4kN} \rceil \le a, and a2−4kN=b2a^2 - 4kN = b^2 with b6<t6=N2b^6 < t^6 = N^2. The value a′2−4kNa'^2 - 4kN increases with a′a', so every a′a' from ⌈4kN⌉\lceil \sqrt{4kN} \rceil to aa passes the test of line L4, and the loop reaches aa unless line L5 returned earlier. At aa, line L5 finds the square b2b^2 and returns. So for composite NN the algorithm always returns on line L1 or L5, never on line L7. ■\blacksquare

Back to Lehman's factorization method