Algorithm Search⌘K

Proofs: PSLQ algorithm

These are the human proofs of PSLQ algorithm, at full length.

Exact PSLQ returns an integer relation after at most (n - 1) ln X / ln tau^2 iterations full

This proof shows: correctness, termination, time.worst.

Setting. The input is x∈Qnx \in \mathbb{Q}^n, n≥2n \ge 2, x≠0x \ne 0, and γ2>4/3\gamma^2 > 4/3; let τ2=4γ2/(4+γ2)\tau^2 = 4 \gamma^2 / (4 + \gamma^2), so that 1/τ2=1/γ2+1/41 / \tau^2 = 1 / \gamma^2 + 1/4 and 1<τ2<41 < \tau^2 < 4. We write aia_i for the rows of AA, PxP_x for the orthogonal projection onto x⊥x^\perp, pi=aiPx=ai−(⟨ai,x⟩/⟨x,x⟩)xp_i = a_i P_x = a_i - (\langle a_i, x \rangle / \langle x, x \rangle) x, and μij\mu_{ij}, Bj=∥pj∗∥2B_j = \|p_j^*\|^2 for the Gram-Schmidt data of p1,…,pnp_1, \ldots, p_n, with dk=B1⋯Bkd_k = B_1 \cdots B_k the Gram determinant of p1,…,pkp_1, \ldots, p_k. The line numbers refer to the main block of the page.

Lemma 1 (the integer invariants). At every moment AA is an integer matrix with det⁡A=±1\det A = \pm 1, B=A−1B = A^{-1}, and y=xBy = x B, so x=yA=∑iyiaix = y A = \sum_i y_i a_i.

Proof. Line L1 sets A=B=IA = B = I and y=xy = x. Line L7 exchanges rows r,r+1r, r+1 of AA and columns r,r+1r, r+1 of BB, which keeps B=A−1B = A^{-1} and permutes the entries of y=xBy = x B. Line L11 multiplies AA on the left by I−tEijI - t E_{ij}, and line L12 multiplies BB on the right by its inverse I+tEijI + t E_{ij}, which adds tt times column ii to column jj; then y=xBy = x B changes by yj←yj+tyiy_j \leftarrow y_j + t y_i. Both matrices are integer with determinant ±1\pm 1. □\square

Lemma 2 (the Gram-Schmidt data). At every moment, the stored μij\mu_{ij} (j≤n−1j \le n - 1) and BjB_j are the Gram-Schmidt data of the rows pip_i, and Bn=0B_n = 0. After HERMITE-REDUCE, ∣μij∣≤1/2|\mu_{ij}| \le 1/2 for all j<ij < i.

Proof. Line L2 computes them from the Gram matrix ⟨pi,pj⟩=⟨ai,aj⟩−⟨ai,x⟩⟨aj,x⟩/⟨x,x⟩\langle p_i, p_j \rangle = \langle a_i, a_j \rangle - \langle a_i, x \rangle \langle a_j, x \rangle / \langle x, x \rangle, which for A=IA = I is I−xTx/⟨x,x⟩I - x^{\mathsf T} x / \langle x, x \rangle. Since p1,…,pnp_1, \ldots, p_n lie in x⊥x^\perp, of dimension n−1n - 1, and p1,…,pn−1p_1, \ldots, p_{n-1} are independent while all yj≠0y_j \ne 0 (Lemma 3), these span x⊥x^\perp and pn∗=0p_n^* = 0.

The projection PxP_x is linear, so the row operation ai←ai−taja_i \leftarrow a_i - t a_j is pi←pi−tpjp_i \leftarrow p_i - t p_j, and the swap of ar,ar+1a_r, a_{r+1} is the swap of pr,pr+1p_r, p_{r+1}. Line L11 is the update of a size reduction step, exactly as in Lemma 2 of the LLL proof (the vector pi∗p_i^* does not change, and μik←μik−tμjk\mu_{ik} \leftarrow \mu_{ik} - t \mu_{jk} for k<jk < j, μij←μij−t\mu_{ij} \leftarrow \mu_{ij} - t). Line L8 is the swap update of Lemma 3 there, which needs only Br′=Br+1+μr+1,r2Br≠0B_r' = B_{r+1} + \mu_{r+1,r}^2 B_r \ne 0; this holds by Lemma 3 below, as the new p1,…,pn−1p_1, \ldots, p_{n-1} are independent. For r=n−1r = n - 1, with pn∗=0p_n^* = 0, the derivation gives cn−1∗=μpn−1∗c_{n-1}^* = \mu p_{n-1}^*, so Bn−1′=μ2Bn−1B_{n-1}' = \mu^2 B_{n-1}, and cn∗=pn−1∗−1μcn−1∗=0c_n^* = p_{n-1}^* - \frac{1}{\mu} c_{n-1}^* = 0, matching Bn′=Bn−1Bn/Bn−1′=0B_n' = B_{n-1} B_n / B_{n-1}' = 0.

In HERMITE-REDUCE, for a fixed ii the steps with j=i−1,…,1j = i - 1, \ldots, 1 change μik\mu_{ik} only for k≤jk \le j; so after the step at jj, ∣μij∣≤1/2|\mu_{ij}| \le 1/2, and later steps (smaller jj) do not change it. Rows other than ii are not changed by the steps of row ii. □\square

Lemma 3 (independence while no relation is found). If all yj≠0y_j \ne 0, then for every jj the n−1n - 1 vectors pip_i, i≠ji \ne j, are linearly independent. In particular p1,…,pn−1p_1, \ldots, p_{n-1} are independent and B1,…,Bn−1>0B_1, \ldots, B_{n-1} > 0.

Proof. Suppose ∑i≠jcipi=0\sum_{i \ne j} c_i p_i = 0 with the cic_i not all zero. Then ∑i≠jciai=λx\sum_{i \ne j} c_i a_i = \lambda x for some λ\lambda, and λ≠0\lambda \ne 0 because the aia_i are independent. So xx lies in the span of the aia_i, i≠ji \ne j. But x=∑iyiaix = \sum_i y_i a_i is the unique expansion in the basis AA, and yj≠0y_j \ne 0: a contradiction. □\square

The checks at lines L1 and L5 guarantee that all yj≠0y_j \ne 0 whenever lines L2, L6 to L8 run; the swap at line L7 only permutes yy, so the condition still holds when line L8 runs.

Lemma 4 (the Gram determinants). For k≤n−1k \le n - 1, dk=det⁡Gram⁡(a1,…,ak,x)/⟨x,x⟩d_k = \det \operatorname{Gram}(a_1, \ldots, a_k, x) / \langle x, x \rangle. If xx is an integer vector and all yj≠0y_j \ne 0, then dk≥1/⟨x,x⟩d_k \ge 1 / \langle x, x \rangle.

Proof. Subtracting (⟨ai,x⟩/⟨x,x⟩)x(\langle a_i, x \rangle / \langle x, x \rangle) x from each aia_i is an elementary operation on the list a1,…,ak,xa_1, \ldots, a_k, x that does not change its Gram determinant, and it gives p1,…,pk,xp_1, \ldots, p_k, x, whose Gram matrix is block diagonal because pi⊥xp_i \perp x. So det⁡Gram⁡(a1,…,ak,x)=dk⟨x,x⟩\det \operatorname{Gram}(a_1, \ldots, a_k, x) = d_k \langle x, x \rangle. For integer AA and xx the left side is an integer, and it is positive since dk>0d_k > 0 by Lemma 3; hence it is at least 1. □\square

Lemma 5 (one iteration). Let D=∏k=1n−1dk=∏j=1n−1Bjn−jD = \prod_{k=1}^{n-1} d_k = \prod_{j=1}^{n-1} B_j^{n-j}. Initially D≤1D \le 1 and every Bj≤1B_j \le 1. Each iteration multiplies DD by at most 1/τ21 / \tau^2 and does not increase max⁡j≤n−1Bj\max_{j \le n-1} B_j.

Proof. For A=IA = I, the Schur complement gives det⁡Gram⁡(e1,…,ek,x)=⟨x,x⟩−∑i≤kxi2\det \operatorname{Gram}(e_1, \ldots, e_k, x) = \langle x, x \rangle - \sum_{i \le k} x_i^2, so by Lemma 4, dk=∑i>kxi2/∑ixi2≤1d_k = \sum_{i > k} x_i^2 / \sum_i x_i^2 \le 1, and Bj=dj/dj−1≤1B_j = d_j / d_{j-1} \le 1 since the dkd_k decrease. HERMITE-REDUCE does not change any BjB_j.

Consider the swap at rr, after a HERMITE-REDUCE, so μ=μr+1,r\mu = \mu_{r+1,r} has ∣μ∣≤1/2|\mu| \le 1/2 by Lemma 2. If r≤n−2r \le n - 2, the choice at line L6 gives γ2rBr≥γ2(r+1)Br+1\gamma^{2r} B_r \ge \gamma^{2(r+1)} B_{r+1}, that is Br+1≤Br/γ2B_{r+1} \le B_r / \gamma^2, so

Br′=Br+1+μ2Br≤Br(1γ2+14)=Brτ2.B_r' = B_{r+1} + \mu^2 B_r \le B_r \Big( \frac{1}{\gamma^2} + \frac14 \Big) = \frac{B_r}{\tau^2}.

If r=n−1r = n - 1, then Bn=0B_n = 0 and Bn−1′=μ2Bn−1≤Bn−1/4<Bn−1/τ2B_{n-1}' = \mu^2 B_{n-1} \le B_{n-1} / 4 < B_{n-1} / \tau^2. In both cases the first kk rows are the same set for every k≠rk \ne r, so dkd_k is unchanged for k≠rk \ne r, and dr′=dr−1Br′≤dr/τ2d_r' = d_{r-1} B_r' \le d_r / \tau^2; since r≤n−1r \le n - 1, the factor drd_r occurs in DD, and D′≤D/τ2D' \le D / \tau^2. For the maximum: Br′≤BrB_r' \le B_r, and for r≤n−2r \le n - 2, Br+1′=BrBr+1/Br′≤BrB_{r+1}' = B_r B_{r+1} / B_r' \le B_r because Br′≥Br+1B_r' \ge B_{r+1}; for r=n−1r = n - 1, Bn′=0B_n' = 0. The other BjB_j do not change. □\square

Theorem 1 (correctness). If the algorithm returns a vector mm, then m∈Znm \in \mathbb{Z}^n, m≠0m \ne 0 and ⟨m,x⟩=0\langle m, x \rangle = 0.

Proof. It returns eje_j at line L1 when xj=0x_j = 0, or column jj of BB at line L5 when yj=0y_j = 0. In the second case mm is a column of the invertible integer matrix BB, so m≠0m \ne 0, and ⟨x,m⟩=(xB)j=yj=0\langle x, m \rangle = (x B)_j = y_j = 0 by Lemma 1. □\square

Theorem 2 (the lower bound). At every moment when all yj≠0y_j \ne 0, every integer relation mm of xx satisfies ∥m∥2≥1/max⁡j≤n−1Bj\|m\|^2 \ge 1 / \max_{j \le n-1} B_j. This bound never decreases during the run.

Proof. Since ⟨m,x⟩=0\langle m, x \rangle = 0, m∈x⊥m \in x^\perp, and ⟨pi,m⟩=⟨aiPx,m⟩=⟨ai,m⟩\langle p_i, m \rangle = \langle a_i P_x, m \rangle = \langle a_i, m \rangle, the iith entry of the integer vector z=AmTz = A m^{\mathsf T}; z≠0z \ne 0 since AA is invertible. By Lemma 3 the vectors p1∗,…,pn−1∗p_1^*, \ldots, p_{n-1}^* are a nonzero orthogonal basis of x⊥x^\perp, so some ⟨pk∗,m⟩≠0\langle p_k^*, m \rangle \ne 0; let kk be the least such index. Then zk=⟨pk,m⟩=⟨pk∗,m⟩+∑j<kμkj⟨pj∗,m⟩=⟨pk∗,m⟩≠0z_k = \langle p_k, m \rangle = \langle p_k^*, m \rangle + \sum_{j < k} \mu_{kj} \langle p_j^*, m \rangle = \langle p_k^*, m \rangle \ne 0, so 1≤∣zk∣≤∥pk∗∥∥m∥1 \le |z_k| \le \|p_k^*\| \|m\|, and ∥m∥2≥1/Bk≥1/max⁡jBj\|m\|^2 \ge 1 / B_k \ge 1 / \max_j B_j. The bound never decreases by Lemma 5. □\square

Theorem 3 (termination). Let x^\hat x be the primitive integer vector on the line of xx and X=∥x^∥2X = \|\hat x\|^2. The number II of iterations satisfies τ2I≤Xn−1\tau^{2I} \le X^{n-1}, so I≤(n−1)ln⁡X/ln⁡τ2I \le (n - 1) \ln X / \ln \tau^2, and the algorithm returns a relation.

Proof. Replacing xx by x^=cx\hat x = c x with c≠0c \ne 0 changes neither PxP_x nor which entries of y=xBy = x B are zero, so every step is the same; we may assume x=x^x = \hat x. If X=1X = 1, x=±ejx = \pm e_j has a zero entry and line L1 returns (as n≥2n \ge 2). Otherwise consider the state just after the swap of the ttth iteration. All yjy_j were nonzero at line L5 of that iteration, and the swap only permuted them, so by Lemma 4 every dk≥1/Xd_k \ge 1 / X and D≥X−(n−1)D \ge X^{-(n-1)}. By Lemma 5, D≤τ−2tD \le \tau^{-2t}. Hence τ2t≤Xn−1\tau^{2t} \le X^{n-1} for every iteration tt that is performed. Since τ2>1\tau^2 > 1, only finitely many iterations happen; the loop can only end at line L5, with a relation by Theorem 1. □\square

Theorem 4 (cost). The algorithm takes O(n3(I+1))=O(n4log⁡X)O(n^3 (I + 1)) = O(n^4 \log X) arithmetic operations, using O(n2)O(n^2) space.

Proof. Line L2 computes the Gram matrix of the pip_i in O(n2)O(n^2) operations for A=IA = I and the Gram-Schmidt data in O(n3)O(n^3). Line L6 takes O(n)O(n) operations, line L7 O(n)O(n), and line L8 O(n)O(n). HERMITE-REDUCE makes at most n(n−1)/2n(n-1)/2 steps, each with O(n)O(n) operations on μ\mu, on a row of AA and on a column of BB, so O(n3)O(n^3). There are II iterations, each with one HERMITE-REDUCE, plus the call at line L3 and the checks at line L5 of O(n)O(n) each, giving O(n3(I+1))O(n^3 (I + 1)), and I=O(nlog⁡X)I = O(n \log X) by Theorem 3. The stored data are AA, BB, μ\mu, yy and the BjB_j, which are O(n2)O(n^2) numbers. □\square

Back to PSLQ algorithm