Cancel one unary symbol from each block at each round. Mark the first, middle and last delimiters by , respectively; use for a cancelled symbol in the left block and for one in the right block. These are extra tape symbols of the Turing machine, all distinct from and blank. No numerical counter is needed in the finite control.
Starting on the first zero, replace it by , scan right through the first block of ones to replace the next zero by , then scan right through the second block and replace its terminal zero by . Move left to . If the initial head is on a blank immediately before the first zero, first move right to that zero. The cancellation loop always starts with the head at :
- Move right past the symbols. If the next symbol is , all right-hand ones have been cancelled; enter the successful cleanup below.
- Otherwise that symbol is . Replace it by , move left past right-block symbols to , and continue left past any symbols.
- If the next symbol is , replace it by . Move right past the symbols back to and repeat the loop.
- If instead the next symbol is , the left block is exhausted while the right block still needed a cancellation. Enter the zero-result cleanup below.
After completed rounds, the invariant isIt holds initially with , and each completed round changes exactly one remaining in each block into the corresponding marker. This proves the cancellation count and preserves the locations of all delimiters.
For successful cleanup, the right block is entirely symbols. From , sweep right, erasing all symbols and finally , then move left across the erased blanks back to the still-present . Erase and continue left, erasing each , until reaching either the last surviving or . Move one cell right and write the new terminal zero there. Move left through the surviving ones to , replace by , and halt. The remaining nonblank tape is exactlyFor example, represents and becomes , representing three.
For zero-result cleanup, the head has reached . Sweep right, erasing everything through while retaining ; after erasing , move left across the blanks to . Replace by , write a second zero in the next cell, and halt. Thus if the machine returns . If , successful cleanup also leaves . With this explicit choice of behaviour,Each sweep seeks a retained delimiter or an end marker a finite distance away. Each completed round removes one right-block ; after at most completed rounds either cleanup or left-block exhaustion occurs. The stated scans, writes and single-cell moves are implementable by finitely many states, so this is an implementation-level Turing machine construction. The output represents zero; a negative integer cannot be represented in the unsigned unary numeral system specified here.
Articles by others on the same topic
There are currently no matching articles.