Algorithm Search⌘K

Proofs: Wiedemann algorithm

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

Correctness of the Wiedemann solver full

This proof shows: correctness, termination.

We prove that WIEDEMANN-SOLVE returns only correct answers, that one try succeeds with probability at least 1−d/∣S∣1 - d/|S| where d=deg⁡μA,bd = \deg \mu_{A,b}, and hence that it terminates with probability 11 after an expected number of tries at most 1/(1−d/∣S∣)1/(1 - d/|S|). Notation is as on the main page: AA is n×nn \times n over a field KK, b≠0b \ne 0, K=span⁡{Aib:i≥0}\mathcal{K} = \operatorname{span}\{A^i b : i \ge 0\} has dimension dd, and si=uTAibs_i = u^T A^i b.

Lemma 1. The vectors b,Ab,…,Ad−1bb, A b, \ldots, A^{d-1} b form a basis of K\mathcal{K}, and deg⁡μA,b=d≤n\deg \mu_{A,b} = d \le n.

Proof. Let kk be the least index with Akb∈span⁡{b,…,Ak−1b}A^k b \in \operatorname{span}\{b, \ldots, A^{k-1} b\}. Then b,…,Ak−1bb, \ldots, A^{k-1} b are independent, and by induction every AibA^i b with i≥ki \ge k lies in their span, because multiplying the relation for AkbA^k b by AA expresses Ak+1bA^{k+1} b through Ab,…,AkbA b, \ldots, A^k b. So k=d≤nk = d \le n. A monic gg of degree ee with g(A)b=0g(A) b = 0 is a dependence among b,…,Aebb, \ldots, A^e b, so e≥de \ge d, and the relation for AdbA^d b gives such a gg of degree dd. □\square

Lemma 2 (annihilators of the sequence). The set of polynomials g=∑jgjxjg = \sum_j g_j x^j with ∑jgjsi+j=0\sum_j g_j s_{i+j} = 0 for all i≥0i \ge 0 is an ideal of K[x]K[x]; its monic generator FF is the minimal polynomial of ss, and FF divides μA,b\mu_{A,b}.

Proof. Writing (x⋅s)i=si+1(x \cdot s)_i = s_{i+1} makes the sequences a K[x]K[x]-module, and the annihilator of ss is an ideal, generated by a monic FF unless it is zero. If g(A)b=0g(A) b = 0, then ∑jgjsi+j=uTAig(A)b=0\sum_j g_j s_{i+j} = u^T A^i g(A) b = 0 for all ii, so μA,b\mu_{A,b} is in the ideal and F∣μA,bF \mid \mu_{A,b}. □\square

Lemma 3 (line L5). Let N≥2deg⁡FN \ge 2 \deg F. The monic polynomial of least degree that annihilates the prefix s0,…,sN−1s_0, \ldots, s_{N-1}, which Berlekamp-Massey returns, is FF. Line L5 uses N=2n≥2d≥2deg⁡FN = 2n \ge 2d \ge 2 \deg F.

Proof. FF annihilates the prefix, so the least degree LL satisfies L≤e=deg⁡FL \le e = \deg F. Let gg be monic of degree LL annihilating the prefix, and let s′s' be the sequence with si′=sis'_i = s_i for i<Li < L that gg generates for all ii. Then si′=sis'_i = s_i for all i<Ni < N, by induction, since both obey the recurrence of gg there. The sequence t=s−s′t = s - s' is annihilated by FgF g, which has degree e+L≤2e≤Ne + L \le 2e \le N, and its first NN terms are zero; since a sequence annihilated by a monic polynomial of degree DD is determined by its first DD terms, t=0t = 0. So gg annihilates ss, F∣gF \mid g, and deg⁡g=L≤e\deg g = L \le e forces g=Fg = F. □\square

Correct outputs. If line L6 reports singularity, then F(0)=0F(0) = 0, so x∣F∣μA,bx \mid F \mid \mu_{A,b} by Lemma 2, and μA,b\mu_{A,b} divides the minimal polynomial of AA, which therefore has the root 00; so 00 is an eigenvalue of AA and AA is singular. If line L9 returns xx, the test on line L8 has verified Ax=bA x = b. Line L1 returns 00, the solution for b=0b = 0. So every output is correct.

Lemma 4 (a good projection gives the solution). If F=μA,bF = \mu_{A,b} and AA is nonsingular, then F(0)≠0F(0) \ne 0 and the vector of line L7 satisfies Ax=bA x = b.

Proof. F(0)=0F(0) = 0 would make AA singular, as above. With F=∑j≤dfjxjF = \sum_{j \le d} f_j x^j and f0≠0f_0 \ne 0, 0=F(A)b=f0b+A∑j=1dfjAj−1b0 = F(A) b = f_0 b + A \sum_{j=1}^d f_j A^{j-1} b, so Ax=bA x = b for x=−f0−1∑j=1dfjAj−1bx = -f_0^{-1} \sum_{j=1}^d f_j A^{j-1} b. Line L7 computes this vector: the Horner loop starts with y=fdb=by = f_d b = b and after the step for index jj holds ∑i=jdfiAi−jb\sum_{i=j}^{d} f_i A^{i-j} b, so it ends with ∑i=1dfiAi−1b\sum_{i=1}^{d} f_i A^{i-1} b. □\square

Lemma 5 (Hankel criterion). Let H(u)H(u) be the d×dd \times d matrix with entries Hij=si+j=uTAi+jbH_{ij} = s_{i+j} = u^T A^{i+j} b for 0≤i,j<d0 \le i, j < d. Then F=μA,bF = \mu_{A,b} if and only if det⁡H(u)≠0\det H(u) \ne 0.

Proof. If F≠μA,bF \ne \mu_{A,b}, then deg⁡F<d\deg F < d by Lemma 2, and the coefficient vector of FF, padded with zeros to length dd, is a nonzero cc with Hc=0H c = 0, since row ii of HcH c is ∑jFjsi+j=0\sum_j F_j s_{i+j} = 0. Conversely, let Hc=0H c = 0 with c≠0c \ne 0, and put g=∑j<dcjxjg = \sum_{j<d} c_j x^j and v=g(A)bv = g(A) b. Then deg⁡g<d\deg g < d, so v≠0v \ne 0 by Lemma 1, and uTAiv=∑jcjsi+j=0u^T A^i v = \sum_j c_j s_{i+j} = 0 for i<di < d. Since v∈Kv \in \mathcal{K} and K\mathcal{K} is AA-invariant, μA,v\mu_{A,v} divides μA,b\mu_{A,b}, so every AivA^i v is a combination of v,…,Ad−1vv, \ldots, A^{d-1} v, and hence uTAiv=0u^T A^i v = 0 for all i≥0i \ge 0. This says that gg annihilates ss, so F∣gF \mid g and deg⁡F<d\deg F < d. □\square

Lemma 6 (probability). If the entries of uu are drawn independently and uniformly from a finite S⊆KS \subseteq K, then Pr⁡[F=μA,b]≥1−d/∣S∣\Pr[F = \mu_{A,b}] \ge 1 - d/|S|.

Proof. Each entry of H(u)H(u) is a linear form in u1,…,unu_1, \ldots, u_n, so det⁡H(u)\det H(u) is a polynomial of total degree at most dd. It is not the zero polynomial: by Lemma 1 the n×dn \times d matrix V=(b,Ab,…,Ad−1b)V = (b, A b, \ldots, A^{d-1} b) has rank dd, so there is u∗u^* with u∗TV=edTu^{*T} V = e_d^T, that is sj=0s_j = 0 for j<d−1j < d - 1 and sd−1=1s_{d-1} = 1. Then H(u∗)H(u^*) has zeros above its anti-diagonal and ones on it, so det⁡H(u∗)=±1\det H(u^*) = \pm 1. By the Schwartz-Zippel lemma, Pr⁡[det⁡H(u)=0]≤d/∣S∣\Pr[\det H(u) = 0] \le d / |S|, and Lemma 5 converts this into the claim. □\square

Termination. Each pass of the loop is a finite computation: 2n−12n - 1 products on line L4, Berlekamp-Massey on 2n2n terms, at most dd products on lines L7 and L8. The tries are independent. By Lemmas 4 and 6, when AA is nonsingular, each try returns with probability at least 1−d/∣S∣1 - d/|S|, and if ∣S∣>d|S| > d this is positive, so the number of tries is geometrically distributed with mean at most 1/(1−d/∣S∣)1/(1 - d/|S|) and is finite with probability 11. Over Fq\mathbb{F}_q with S=FqS = \mathbb{F}_q the success probability is positive even when q≤dq \le d: it is at least the probability that uu restricted to K\mathcal{K} generates the dual of K\mathcal{K} as a K[x]K[x]-module, which is ∏g(1−q−deg⁡g)>0\prod_g (1 - q^{-\deg g}) > 0 over the distinct irreducible factors gg of μA,b\mu_{A,b}. An implementation that bounds the number of tries reports failure after the bound, which happens with probability at most (d/∣S∣)t(d/|S|)^{t} after tt tries.

Conclusion. Every output of WIEDEMANN-SOLVE is correct, and for nonsingular AA it returns the solution after an expected number of tries at most 1/(1−d/∣S∣)≤1/(1−n/∣S∣)1/(1 - d/|S|) \le 1/(1 - n/|S|). ■\blacksquare

Back to Wiedemann algorithm