Algorithm Search⌘K

Proofs: Petkovšek's Hyper algorithm

These are the human proofs of Petkovšek's Hyper algorithm, at full length.

Hyper returns exactly the hypergeometric solutions full

This proof shows: correctness, termination.

Let KK be a field of characteristic 00 and L=∑i=0rpi(n)SiL = \sum_{i=0}^{r} p_i(n) S^i with pi∈K[n]p_i \in K[n], r≥1r \ge 1, p0≠0p_0 \ne 0 and pr≠0p_r \ne 0. A hypergeometric term tt is eventually nonzero with t(n+1)=R(n) t(n)t(n + 1) = R(n)\, t(n) for a rational R∈K(n)R \in K(n) and all large nn.

Lemma 1 (Gosper-Petkovšek form). Every nonzero R∈K(n)R \in K(n) can be written R=Za(n)b(n)c(n+1)c(n)R = Z \frac{a(n)}{b(n)} \frac{c(n + 1)}{c(n)} with Z∈K∖{0}Z \in K \setminus \{0\}, monic a,b,c∈K[n]a, b, c \in K[n], gcd⁡(a(n),b(n+h))=1\gcd(a(n), b(n + h)) = 1 for all integers h≥0h \ge 0, gcd⁡(a(n),c(n))=1\gcd(a(n), c(n)) = 1 and gcd⁡(b(n),c(n+1))=1\gcd(b(n), c(n + 1)) = 1. This is the lemma of Petkovšek (1992) and of A = B, Chapter 5. Its proof uses only gcds over KK and the integer roots of a resultant, so a,b,ca, b, c and ZZ lie in KK.

Lemma 2 (the key identity). For RR in the form of Lemma 1 and Pi=pi(n)∏j=0i−1a(n+j)∏j=ir−1b(n+j)P_i = p_i(n) \prod_{j=0}^{i-1} a(n + j) \prod_{j=i}^{r-1} b(n + j),

c(n)∏j=0r−1b(n+j)⋅∑i=0rpi(n)∏k=0i−1R(n+k)=∑i=0rZiPi(n) c(n+i).c(n) \prod_{j=0}^{r-1} b(n + j) \cdot \sum_{i=0}^{r} p_i(n) \prod_{k=0}^{i-1} R(n + k) = \sum_{i=0}^{r} Z^i P_i(n)\, c(n + i).

Proof. ∏k<iR(n+k)=Zi∏k<ia(n+k)b(n+k)⋅c(n+i)c(n)\prod_{k<i} R(n + k) = Z^i \prod_{k<i} \frac{a(n + k)}{b(n + k)} \cdot \frac{c(n + i)}{c(n)}, because the factors c(n+k+1)/c(n+k)c(n + k + 1)/c(n + k) telescope. Multiplying by c(n)∏j<rb(n+j)c(n) \prod_{j<r} b(n + j) cancels c(n)c(n) and ∏k<ib(n+k)\prod_{k<i} b(n + k), and leaves ∏j=ir−1b(n+j)\prod_{j=i}^{r-1} b(n + j). □\square

If tt has ratio RR, then (Lt)(n)=t(n)∑ipi(n)∏k<iR(n+k)(L t)(n) = t(n) \sum_i p_i(n) \prod_{k<i} R(n + k). So for eventually nonzero tt, Lt=0L t = 0 holds if and only if the rational function ∑ipi∏k<iR(n+k)\sum_i p_i \prod_{k<i} R(n + k) is zero, if and only if the right side of Lemma 2 is the zero polynomial.

Termination. p0p_0 and pr(n−r+1)p_r(n - r + 1) have finitely many monic factors. For each pair, ∑αiZi\sum \alpha_i Z^i is a nonzero polynomial, because αi≠0\alpha_i \ne 0 for some ii by the choice of mm, so it has at most rr roots. Line L6 solves one finite linear system, by Lemma 4. So the algorithm stops.

Soundness. Let a ratio R=Za(n)c(n+1)/(b(n)c(n))R = Z a(n) c(n + 1)/(b(n) c(n)) be output, with c≠0c \ne 0 from line L6. Then ∑iZiPi(n)c(n+i)=0\sum_i Z^i P_i(n) c(n + i) = 0, and Lemma 2 holds for this RR even if the gcd conditions fail, since its proof used none of them. Since c(n)∏jb(n+j)c(n) \prod_j b(n + j) is a nonzero polynomial, ∑ipi∏k<iR(n+k)=0\sum_i p_i \prod_{k<i} R(n + k) = 0 as a rational function. Define t(n0)=1t(n_0) = 1 and t(n+1)=R(n)t(n)t(n + 1) = R(n) t(n) for n≥n0n \ge n_0, where n0n_0 exceeds every integer root of the numerator and denominator of RR. Then tt is a hypergeometric solution.

Lemma 3 (the necessary conditions). If tt is a hypergeometric solution with ratio RR in the form of Lemma 1, with deg⁡c=δ\deg c = \delta, then a(n)∣p0(n)a(n) \mid p_0(n), b(n)∣pr(n−r+1)b(n) \mid p_r(n - r + 1), ∑iαiZi=0\sum_i \alpha_i Z^i = 0 for the αi\alpha_i of line L4, and cc solves ∑iZiPi(n)c(n+i)=0\sum_i Z^i P_i(n) c(n + i) = 0.

Proof. The last claim is Lemma 2 with Lt=0L t = 0. In ∑iZiPi(n)c(n+i)=0\sum_i Z^i P_i(n) c(n + i) = 0, each term with i≥1i \ge 1 contains the factor a(n)a(n). So a(n)a(n) divides P0(n)c(n)=p0(n)∏j=0r−1b(n+j) c(n)P_0(n) c(n) = p_0(n) \prod_{j=0}^{r-1} b(n + j)\, c(n). By Lemma 1, a(n)a(n) is coprime to each b(n+j)b(n + j) with j≥0j \ge 0 and to c(n)c(n), so a(n)∣p0(n)a(n) \mid p_0(n). Each term with i≤r−1i \le r - 1 contains the factor b(n+r−1)b(n + r - 1), so it divides Pr(n)c(n+r)=pr(n)∏j=0r−1a(n+j) c(n+r)P_r(n) c(n + r) = p_r(n) \prod_{j=0}^{r-1} a(n + j)\, c(n + r). Here gcd⁡(b(n+r−1),a(n+j))=1\gcd(b(n + r - 1), a(n + j)) = 1 for 0≤j≤r−10 \le j \le r - 1: substituting n↦n−jn \mapsto n - j, it is gcd⁡(a(n),b(n+h))\gcd(a(n), b(n + h)) with h=r−1−j≥0h = r - 1 - j \ge 0. And gcd⁡(b(n+r−1),c(n+r))=1\gcd(b(n + r - 1), c(n + r)) = 1 is the shift of gcd⁡(b(n),c(n+1))=1\gcd(b(n), c(n + 1)) = 1. So b(n+r−1)∣pr(n)b(n + r - 1) \mid p_r(n), that is, b(n)∣pr(n−r+1)b(n) \mid p_r(n - r + 1). Finally, cc is monic of degree δ\delta, so c(n+i)c(n + i) has leading term nδn^\delta for every ii, and the coefficient of nm+δn^{m + \delta} in the sum is ∑iZiαi\sum_i Z^i \alpha_i, which must be 00. Z≠0Z \ne 0 because R≠0R \ne 0. □\square

Lemma 4 (degree bound). Let Q0,…,Qr∈K[n]Q_0, \ldots, Q_r \in K[n], not all zero, and Rk=∑i≥k(ik)QiR_k = \sum_{i \ge k} \binom{i}{k} Q_i. Let b∗=max⁡{deg⁡Rk−k:Rk≠0}b^\ast = \max \{ \deg R_k - k : R_k \ne 0 \} and φ(δ)=∑k:deg⁡Rk−k=b∗lc⁡(Rk) δ(δ−1)⋯(δ−k+1)\varphi(\delta) = \sum_{k : \deg R_k - k = b^\ast} \operatorname{lc}(R_k)\, \delta(\delta - 1) \cdots (\delta - k + 1). Every nonzero polynomial solution cc of ∑iQi(n)c(n+i)=0\sum_i Q_i(n) c(n + i) = 0 has a degree δ\delta with φ(δ)=0\varphi(\delta) = 0.

Proof. Some RkR_k is nonzero: the map from (Qi)(Q_i) to (Rk)(R_k) is triangular with 11 on the diagonal, so it is invertible. With Ec(n)=c(n+1)E c(n) = c(n + 1) and Δ=E−1\Delta = E - 1, the binomial theorem Ei=∑k(ik)ΔkE^i = \sum_k \binom{i}{k} \Delta^k gives ∑iQiEi=∑kRkΔk\sum_i Q_i E^i = \sum_k R_k \Delta^k. For cc of degree δ\delta, Δkc\Delta^k c has degree δ−k\delta - k and leading coefficient δ(δ−1)⋯(δ−k+1)lc⁡(c)\delta(\delta - 1) \cdots (\delta - k + 1) \operatorname{lc}(c) when k≤δk \le \delta, and is 00 when k>δk > \delta, where the product also vanishes. So RkΔkcR_k \Delta^k c has degree at most deg⁡Rk+δ−k≤b∗+δ\deg R_k + \delta - k \le b^\ast + \delta, and the coefficient of nb∗+δn^{b^\ast + \delta} in the sum is lc⁡(c) φ(δ)\operatorname{lc}(c)\, \varphi(\delta), which must be 00. The polynomial φ\varphi is nonzero, since the falling factorials of distinct degrees kk are linearly independent and their coefficients lc⁡(Rk)\operatorname{lc}(R_k) are nonzero. □\square

So with DD the largest nonnegative integer root of φ\varphi, the solutions of degree at most DD are all the polynomial solutions, and they are the kernel of a linear map on the coefficient vectors (c0,…,cD)(c_0, \ldots, c_D). Line L6 computes a basis c1,…,csc_1, \ldots, c_s of this kernel.

Completeness. Let tt be a hypergeometric solution with ratio R∈K(n)R \in K(n), and write RR in the form of Lemma 1. By Lemma 3 the pair (a,b)(a, b) is tried at line L2 and ZZ is found at line L5, provided the factorizations of p0p_0 and pr(n−r+1)p_r(n - r + 1) and the roots are taken over KK. Also by Lemma 3, c=∑jλjcjc = \sum_j \lambda_j c_j for the basis of line L6. Choose n0n_0 beyond all integer roots of aa, bb, cc and the cjc_j, and let A(n)=∏k=n0n−1a(k)/b(k)A(n) = \prod_{k=n_0}^{n-1} a(k)/b(k). Then for n≥n0n \ge n_0, t(n)=κ ZnA(n) c(n)t(n) = \kappa\, Z^n A(n)\, c(n) for a constant κ\kappa, and the output solution hjh_j with ratio Za(n)cj(n+1)/(b(n)cj(n))Z a(n) c_j(n + 1)/(b(n) c_j(n)) is hj(n)=κjZnA(n)cj(n)h_j(n) = \kappa_j Z^n A(n) c_j(n) with κj≠0\kappa_j \ne 0. Hence t=∑j(κλj/κj) hjt = \sum_j (\kappa \lambda_j / \kappa_j)\, h_j for n≥n0n \ge n_0. Reducing the ratio to lowest terms at line L7 does not change the sequence hjh_j for n≥n0n \ge n_0. ■\blacksquare

Back to Petkovšek's Hyper algorithm