The input-reversal machine #
A two-state machine without work tapes that outputs the reversal of its input word tidily in
2 * input.length + 2 steps and zero work-tape space.
In its initial state false, Turing.MultiTapeTM.reverseInput scans the input from left to right
without emitting anything until it reaches the right boundary blank at position input.length + 1,
where it steps one cell left onto position input.length and enters state true. In state true
it walks left across the input, emitting each symbol as it passes, until it reaches the left
boundary blank at position 0, where it steps one cell right back to the initial head position 1
and halts.
Main definitions #
Turing.MultiTapeTM.reverseInput: the two-state zero-work-tape reversal machine.Turing.MultiTapeTM.ReverseInput.cfg: configurations ofreverseInput.
Main results #
Turing.MultiTapeTM.ReverseInput.runFrom_full: from the initial state at head position1with any prior output prefixout,reverseInputhalts at head position1with outputout ++ input.reverseafter2 * input.length + 2steps.Turing.MultiTapeTM.ReverseInput.computesInTimeAndSpace:reverseInputcomputesinput.reversein2 * input.length + 2steps and zero space.Turing.MultiTapeTM.ReverseInput.computesTidily:reverseInputcomputesinput.reversetidily in2 * input.length + 2steps and zero space.Turing.MultiTapeTM.computableTidilyInTimeAndSpace_reverse: any function whose encoding reverses the encoded input is tidily computable in2 * (encIn a).length + 2steps and zero space.
The input-reversal machine: two states (Bool) and no work tapes. State false scans right to
the blank after the input and steps left into state true; state true walks left emitting each
input symbol until the blank before the input, then steps right to position 1 and halts.
Instances For
Configuration of reverseInput in state q with the input head at pos and output out.
input is explicit because it only occurs in the type.
Instances For
Complete run from the initial state at position 1 with arbitrary prior output prefix out:
after 2 * input.length + 2 steps, reverseInput halts at position 1 with output
out ++ input.reverse.
reverseInput computes input.reverse in 2 * input.length + 2 steps and zero space.
reverseInput computes input.reverse tidily in 2 * input.length + 2 steps and zero
work-tape space, preserving any ambient output prefix.
Any function whose encoding reverses the encoded input is tidily computable in
2 * (encIn a).length + 2 steps and zero work-tape space.