简体   繁体   中英

Turing machine with one state that converts binary to decimal

I heard that a Turing machine with one state should be able to convert binary numbers into decimal numbers. I am trying to figure out how that would be possible. I'm currently quite unsuccessfully brute-forcing my way to a result. How would one synthesise that in more elegant way?

The binary number is given in reversed order eg. 25 is 10011 not 11001. I would argue this makes it easier. Not sure if it also is a necessity. The number is encapsulated at the ends by two other symbols. Additionally 0 and 1 are in the beginning denoted as T and F -->.......TFFTTXXXXX. The resulting decimal number should look like this: .....25-----XXXXX. Also, the halt state is not counted as real state. To my understanding this is a necessity to formulate a problem like that.

Researching one-state Turing machines I found this paper . I see that there is somewhat a carry and a counter bit, but I can not explain myself how this will help to increase a decimal number up to 10 and then do the carry to the next bit. Given one state I am thinking about at least 10 different terms for each decimal digit and a few more symbols for breaks, carry, counters etc.. Therefore, the definition of my single state gets quite long. Here an example to illustrate what I mean (obvioulsy wrong):

state trigger --> (output, state, shift): 
s, 1 --> (2,s,>) 
s, 2 --> (3,s,>) 
..., s, 
s, 8 --> (9,s,>)
s, 9 --> (c,s,>)

With only one state, you must encode information in counting bits. The trick is that you count down on the binary number and count up on the decimal number.

Say we start as ......[T]FFTTXXXXX , per your example, with [] denoting our current head position after a write. Go to the right and flip the T with an F in order to decrease the binary. Then, overwrite the encountered (and any future) . with a 1 . You should now have the following:

  • .....[.]FFFTTXXXXX
  • .....[1]FFFTTXXXXX

Go back to the right. Now, we run into a problem: We need to go past the F s, flip them to T s, go to the first T and then back. In order to not flip the digits we just passed, we replace them by a placeholder like - , resulting in the following sequence:

  • .....1[F]FFTTXXXXX
  • .....1-[F]FTTXXXXX
  • .....1--[F]TTXXXXX
  • .....1---[T]TXXXXX
  • .....1--[-]FTXXXXX

Now, go back and replace the placeholder:

  • .....1-[-]TFTXXXXX
  • .....1[-]TTFTXXXXX
  • .....[1]TTTFTXXXXX

And now just increment the 1 to a 2 : .....2[T]TTFTXXXXX .

Go to the right again and repeat this process:

  • .....[2]FTTFTXXXXX
  • .....3[F]TTFTXXXXX
  • .....3-[T]TFTXXXXX
  • .....3[-]FTFTXXXXX
  • .....[3]TFTFTXXXXX
  • .....4[T]FTFTXXXXX
  • etc. until the turing machine halts at the first X encountered

The only issue you will encounter is that you'll need to override a decimal 9 with a 10 somehow. Do this by replacing the 9 with a placeholder, going to the left, running the normal state transition from a . to a 1 , going back right and replacing the placeholder with a 0 . Don't forget to add a transition from 0 to 1 as well.


By the way, this seems like a homework assignment of a certain lecture I attend as well;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM