如何模拟图灵机?
我不太明白图灵机的整个想法。
我目前的任务是制作一台繁忙的海狸图灵机。但我真正不明白的是它模拟输入。那么我要模拟什么样的输入呢?例如,它询问我 3 状态繁忙的海狸机在磁带上写入了多少个 1?我确定我需要编写一个图灵机,但是一旦我有了它,我该怎么用它呢?
我应该用什么字符串来模拟它?
I don't quite understand the whole idea of a turing machine thing.
I am currently tasked with making a busy beaver turing machine. But the thing I don't really get is it simulates input. So what kind of input do I simulate? For example, it's asking me how many 1s the 3 states busy beaver machines writes on tape? I'm sure I need to write a turing machine, but once I have it, what do I do with it?
What string should I simulate it with?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的第一步将是更好地理解“图灵机的整体概念”。您可以尝试阅读它:
Your first step would be get a better understanding of 'the whole idea of turing machine thing'. You could try to read up on it:
对于busy beaver场景,通常假设没有特殊输入,即磁带图灵机的最初是空的。当然,在运行期间,忙碌的海狸可能会向磁带写入数据,然后再读取所写入的内容。
所以你必须模拟磁带。由于它应该在两端都是无限的,我建议通过子类化 ArrayList 并覆盖 get() 和 set() 来实现它> 将正索引映射到偶数元素,将负索引映射到奇数元素的方法(并且当访问超出当前大小的索引时,还可以通过重复调用 add(null) 来自动增加大小列表)。
For the busy beaver scenario, it is usually assumed that there is no special input, i.e. the tape of the Turing Machine is initially empty. Of course, during its runtime, the busy beaver may write to the tape and later read what it has written.
So you do have to simulate the tape. Since it's supposed to be infinite at both ends, I'd suggest to implement it by subclassing
ArrayList
and overwriting theget()
andset()
methods to map positive indices to even elements and negative indices to odd elements (and also to automatically increase the size by repeatedly callingadd(null)
when there is an access to an index outside the current size of the list).