如何创建一个图灵机作为 x^y 的函数计算器
我正在学习图灵机测试,我遇到了一个问题,我必须创建一个图灵机作为函数计算器:
f(x,y) = x ^ y
我知道我的磁带输入会像这样分开:
1's of base 0 1's of exponent
用我的磁带输出就像
1's of base 0 1's of exponent 0 1's of the computed result
我如何将 X 和 Y 放在磁带上? (可以是多胶带机) 状态图会是什么样子?
注意:我使用一元,1 用于表示 0,0 不用作值而是用作分隔符。
所以:
0 = delimiter
1 = 0
11 = 1
111 = 2
1111= 3
11111= 4
etc.
I'm studying for a test on Turing machines, and I'm stuck with a problem in which I have to create a Turing Machine that serves as a function calculator for:
f(x,y) = x ^ y
I understand my tape input would come separated like this:
1's of base 0 1's of exponent
With my tape output being like
1's of base 0 1's of exponent 0 1's of the computed result
How would I go about placing X's and Y's on the tape(s)? (It can be a multi-tape machine)
What would the state diagram look like?
Note: I'm using unary with 1 used to represent 0 and 0 used not as value but as a delimiter.
So:
0 = delimiter
1 = 0
11 = 1
111 = 2
1111= 3
11111= 4
etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在这里猜测了一下,自从我玩图灵机模拟器以来已经有一段时间了。 首先,我想将任务分为几个概念步骤:
要重复执行某项任务 N 次,请将 N 放入磁带上,执行该任务一次,然后从数字 N 的末尾减 1。重复,直到数字 N 为从磁带上消失了。
无论如何,希望这足以让您开始。 状态机可以或多或少以这种方式机械地构造。
I'm guessing a bit here, it's been a little while since I played with Turing machine simulators. First of all, I would want to divide the task up into several conceptual steps:
To perform a task repeatedly N times, put N onto the tape, perform the task once, then subtract 1 from the end of the number N. Repeat until the number N is gone from the tape.
Hopefully this is sufficient to get you started anyway. The state machine can be constructed more or less mechanically in this fashion.
在我自己的图灵伪代码中:
这是应该起作用的图灵代码(磁带就像指针,小写字母,输入磁带是
i
):请检查是否有错误:)
In my own Turing pseudocode:
Here's the turing code that should work (tapes are like pointers, lowercase letters, input tape is
i
):Please check for errors :)