Little-endian binary predecessor — definitions #
This module defines the finite controller for in-place predecessor on a positive canonical binary natural. Borrow turns initial low-order zero bits into ones. The first one becomes zero; when it was the unique high bit, a one-cell lookahead detects the terminating blank and erases that now-redundant zero before rewinding.
The controller is total on zero, where it simply rewinds the unchanged empty
representation. Public correctness theorems intentionally start from
value + 1, so no underflow behavior is claimed.
Ripple one borrow through a little-endian bit string, dropping a vacated unique high bit. The empty case defines underflow as unchanged zero.
Equations
Instances For
Exact transition count used by binaryPredTM on a canonical bit string.
Equations
- Complexity.BinaryPred.steps [] = 2
- Complexity.BinaryPred.steps (false :: rest) = Complexity.BinaryPred.steps rest + 2
- Complexity.BinaryPred.steps (true :: tail) = 4
Instances For
Finite phases of ripple-borrow predecessor.
- borrow : BinaryPredPhase
- check : BinaryPredPhase
- erase : BinaryPredPhase
- rewind : BinaryPredPhase
- done : BinaryPredPhase
Instances For
BinaryPredPhase has exactly five states.
Equations
- One or more equations did not get rendered due to their size.
Exact running time for decrementing canonical value + 1 to value.
Equations
- Complexity.TM.binaryPredTime value = Complexity.BinaryPred.steps (value + 1).bits
Instances For
Decrement a positive canonical little-endian natural on work tape idx.
The borrow phase flips initial zeros to ones and replaces the first one by zero. A lookahead distinguishes an internal bit from the terminating blank; the latter case erases the vacated high zero. The machine finally rewinds to cell one. On canonical zero it takes the blank branch and leaves zero intact.
Equations
- One or more equations did not get rendered due to their size.