A linear-feedback shift register of length has binary state and update
Its output obeys over . Since the state space is finite, its trajectory consists of a transient of length followed by a cycle of length , and the output satisfies for .
If the trajectory never reaches zero, all its distinct transient and cyclic states are nonzero; hence . If it reaches zero, let be its first zero-state time. The vectors are linearly independent: in a dependence, apply where is the smallest index with a nonzero coefficient; every later term vanishes and the remaining term is . Therefore . The zero cycle has , and for . This proves the requested bound for all , and for every invertible register.
The unrestricted printed assertion has one exception: at , the zero-feedback register with initial state one outputs . It requires , so . The universally valid finite-state bound is . A register with feedback from its oldest bit is invertible, in which case a nonzero state never reaches zero and the sharper bound holds already with .
To recover an unknown register from a known plaintext/ciphertext keystream, the Berlekamp-Massey algorithm finds a shortest linear recurrence consistent with the observed bits. Use a connection polynomial , so the recurrence discrepancy at index is . Initialize . Process the bits in order. If , increment . If , save and replace
If , also replace by , set ; otherwise retain and increment . Arithmetic is binary, so every nonzero discrepancy equals one. The stored polynomial last failed at an earlier index with discrepancy ; its shifted contribution cancels the new failure without changing previous successful discrepancies.
Here is the minimum recurrence length after a new discrepancy argument behind the update, not just its name. Suppose a span- recurrence succeeds through index but fails at . If another polynomial of span succeeded through and , compute the convolution at in two ways. Applying first gives zero, since all indices used by lie at least at . Applying first gives its nonzero discrepancy at , since its earlier discrepancies used by vanish and . This contradiction proves . The shifted-polynomial update attains the larger of the existing minimum length and this new lower bound; induction therefore gives the shortest recurrence for every prefix. Once at least twice the true linear complexity has been observed, this recurrence determines the whole stream: the difference from a true degree- recurrent stream satisfies a recurrence of degree at most , and a prefix of that many zeros forces every later value to be zero. Without any bound on complexity, a finite observed prefix cannot exclude a longer register that diverges later; the breaking claim uses the finite-register hypothesis and adequate known data.
Finally each of the three input streams is eventually periodic. Let be the maximum of their transient lengths and a common multiple of their periods. Their joint triple, and hence the bit chosen by the specified rule, repeats after once . Therefore
This itself is a linear recurrence of length , so it constructs a linear-feedback shift register producing the selected stream from its first bits. No closure theorem is being assumed: eventual periodicity and this explicit recurrence prove the combined stream is also an LFSR stream, even though the combining rule is nonlinear in its three inputs.