Complexity
The number of non-input sequitur operations applied < 2n where n is the input length.
Amortized Complexity Argument
- Let s = the sum of the right hand sides of all the production rules. Let r = the number of rules.
- We evaluate s - r/2.
- Initially s - r/2 = 1/2 because s = 1 and r = 1.
- s - r/2 > 0 at all times because each rule has at least 1 symbol on the right hand side.
- s - r/2 increases by 1 for every input operation.
- s - r/2 decreases by at least 1/2 for each non-input sequitur rule applied.