A fixed-width binary counter inside the polynomial-time algebra #
⚠️ Unreviewed by Bolton
Savitch's recursion searches for a midpoint by enumerating every bitstring of the width a configuration code occupies. The enumeration is an ordinary little-endian increment that wraps around, and the wrap is what tells the search it has run out of candidates.
Complexity.addBit is that increment as a plain recursion — carry in, carry out,
result — and Complexity.bumpStep is the same thing as a left-to-right scan on a
packed state, the shape Cobham.iterate_mem_FP iterates. The two agree
(Complexity.bumpStep_iterate_run), so the arithmetic can be done on the
recursion and the polynomial-time bound on the scan.
Main definitions #
Complexity.addBit— increment a little-endian bitstring, with carryComplexity.bumpBits,Complexity.bumpOver— its two componentsComplexity.bumpStep— one step of the scan that computes itComplexity.bumpFlag,Complexity.bumpCode— the packed verdicts
Main results #
Complexity.addBit_binValLE— the adder is correctComplexity.bumpBits_length— the width is preservedComplexity.bumpOver_iff— the carry fires exactly on the last candidateComplexity.bumpCodeFn_mem_FP,Complexity.bumpFlagFn_mem_FP— both are inFP
The increment as a recursion #
Add a carry bit into a little-endian bitstring: the carry out and the result.
Equations
Instances For
The increment of a little-endian bitstring, wrapping on overflow.
Equations
- Complexity.bumpBits w = (Complexity.addBit true w).2
Instances For
Did the increment wrap around?
Equations
- Complexity.bumpOver w = (Complexity.addBit true w).1
Instances For
Iterating the increment from zero enumerates the candidates in order.
The increment as a scan #
The same increment, written as a left-to-right pass over the string: carry, the
bits already emitted, and the bits still to read. This is the shape
Cobham.iterate_mem_FP iterates, and every operation in it is one of the
algebra's.
One step of the increment scan.
Equations
Instances For
The packed scan #
The packed scan state.
Equations
- Complexity.bumpPack c acc rest = Complexity.pair c (Complexity.pair acc rest)
Instances For
The verdicts #
The packed scan run to completion.
Equations
Instances For
The increment of w, computed by the scan.
Equations
Instances For
The carry out of the increment, as a flag.