A binary counter from a unary index #
A polynomial-time loop receives its counter in unary, since that is the form a
loop bound takes. This module turns such an index into fixed-width binary: the
width-preserving counter of SavitchBits is incremented that many times,
starting from all zeros.
Nothing here is arithmetic on the index. bumpBits is the width-preserving
increment already proved polynomial-time for Savitch's theorem, and iterating a
polynomial-time step a polynomial number of times is iterate_mem_FP.
Main definitions #
Complexity.coinStr— the counter after that many increments
Main results #
Complexity.coinStr_eq— below the wrap-around, it isbitsOfLenLEComplexity.coinStr_mem_FP— in polynomial time, for any index
The width-t counter after c increments. Total: past 2 ^ t it wraps,
which never happens where it is used but keeps the function unconditional.
Equations
Instances For
The counter value in polynomial time. With the width and the index both supplied in unary, the counter is polynomial-time computable — with no bound on the index, so that the function is total where a loop guard has not yet been applied.