简体   繁体   English

图灵机一台 state 将二进制转换为十进制

[英]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.听说有一台state的图灵机应该可以把二进制数转换成十进制数。 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. 25 是 10011 而不是 11001。我认为这更容易。 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.此外,0 和 1 在开头表示为 T 和 F -->.......TFFTTXXXXX。 The resulting decimal number should look like this: .....25-----XXXXX.生成的十进制数应如下所示:.....25-----XXXXX。 Also, the halt state is not counted as real state.此外,停止 state 不算作真正的 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.我看到有一些进位和一个计数器位,但我无法解释自己如何帮助将十进制数增加到 10,然后进行下一位的进位。 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.给定一个 state,我正在考虑每个十进制数字至少 10 个不同的术语,以及更多用于中断、进位、计数器等的符号。因此,我的单个 state 的定义变得很长。 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.只有一个 state,您必须在计数位中编码信息。 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.假设我们以......[T]FFTTXXXXX ,根据您的示例,其中[]表示写入后我们当前的头部 position。 Go to the right and flip the T with an F in order to decrease the binary. Go 向右并用F翻转T以减少二进制。 Then, overwrite the encountered (and any future) .然后,覆盖遇到的(以及任何未来) . with a 1 .1 You should now have the following:您现在应该拥有以下内容:

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

Go back to the right. Go 回到右边。 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.现在,我们遇到了一个问题:我们需要将 go 越过F s,将它们翻转到T s,go 到第一个T然后再返回。 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:现在,go 回来并替换占位符:

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

And now just increment the 1 to a 2 : .....2[T]TTFTXXXXX .现在只需将1增加到2.....2[T]TTFTXXXXX

Go to the right again and repeat this process: Go 再次向右并重复此过程:

  • .....[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以此类推,直到图灵机在遇到的第一个X处停止

The only issue you will encounter is that you'll need to override a decimal 9 with a 10 somehow.您将遇到的唯一问题是您需要以某种方式用10覆盖十进制9 Do this by replacing the 9 with a placeholder, going to the left, running the normal state transition from a .为此,将9替换为占位符,向左移动,从. to a 1 , going back right and replacing the placeholder with a 0 .1 ,向右返回并用0替换占位符。 Don't forget to add a transition from 0 to 1 as well.不要忘记添加从01的转换。


By the way, this seems like a homework assignment of a certain lecture I attend as well;)顺便说一句,这似乎是我参加的某个讲座的家庭作业;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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