简体   繁体   English

图灵机设计

[英]Turing Machine Design

I recently encountered the following problem: 我最近遇到以下问题:

Give a Turing machine diagram for a Turing machine that on input a string x ∈ {0, 1}∗ halts (accepts) with its head on the left end of the tape containing the string x′ ∈ {0, 1}∗ at the left end (and blank otherwise) where x′ is the successor string of x in lexicographic order; 给出一个图灵机的图灵机图,该图灵机在输入字符串x ∈ {0, 1}∗停止(接受),其头在磁带的左端,其中包含字符串x′ ∈ {0, 1}∗ 。左端(否则为空白),其中x'是按字典顺序排列的x的后继字符串; ie the next string in the sequence ε, 0, 1, 00, 01, 10, 11, 000, . . . 即序列ε, 0, 1, 00, 01, 10, 11, 000, . . .的下一个字符串ε, 0, 1, 00, 01, 10, 11, 000, . . . ε, 0, 1, 00, 01, 10, 11, 000, . . . in which the strings are listed in order of increasing length with ties broken by their corresponding integer value. 其中按长度增加的顺序列出字符串,并以相应的整数值打破领带。 (Briefly document your TM.) (简要记录您的TM。)

I am confused as to how to start designing an appropriate solution for it. 对于如何开始为其设计合适的解决方案,我感到困惑。 Could I get a couple of pointers for firstly designing this machine, and then Turing machines in general? 首先设计这台机器,然后再设计图灵机器,我是否可以得到一些建议?

Turing Machines 图灵机

First off, you need to understand what a Turing machine is, and by Turing machine, I'm assuming you're talking about a Universal Turing Machine . 首先,您需要了解什么是图灵机,而我假设您是在谈论通用图灵机 This is a conceptual machine created by the Godfather of Computer Science, Alan Turing. 这是由计算机科学教父Alan Turing创建的概念机。

The machine is built up of some components. 机器由一些组件组成。 First, an infinite tape that contains input. 首先,包含输入的无限磁带。 Something like.. 就像是..

1-0-1-1-1-1-0-1-0-1-0

Then a set of rules.. 然后是一组规则

if 1 then 0
if 0 then 1

So when the machine hits the 1 , the output is 0 , as per the rule. 因此,按照规则,当机器达到1 ,输出为0 We define the machine hitting a value when the read head is set to it. 我们将读取头设置为值时定义机器命中值。 The read head is like the current position in the turing machine. 读取头就像翻唱机中的当前位置。 So it will go.. 所以它会去..

1-0-1-1
^------------Current head.

Then the next iteration: 然后下一次迭代:

1-0-1-1
  ^----------Current Head

This machine is actually simulating bitwise NOT functionality. 这台机器实际上是在模拟按位NOT功能。 You can also set a state in a turing machine, so for example: 您还可以在图灵机中设置状态,例如:

if 1 then enter state 1
if 0 then enter state 0

Big deal right? 没关系吧? Example suddenly, now you can do stuff like: 突然出现示例,现在您可以执行以下操作:

1. if 1 and in state 1 output 1 and enter state 0
2. if 1 and in state 0 output 0 and enter state 1
3. if 0 and in state 0 output 1 and enter state 1
4. if 0 and in state 1 output 0 and enter state 0

And we define a state as our default state. 我们将状态定义为默认状态。 In this example, let's call it state 0 . 在此示例中,我们将其称为state 0 So when the machine starts, it sees a 1. Well I'm in state 0 and I've just got a 1 so I'm going to do rule number 2 . 因此,当机器启动时,它会看到1。好吧,我处于state 0而我刚得到1所以我将执行规则2 Output a 0 and enter state 1 . 输出0并进入state 1 The next number is a 0 . 下一个数字是0 Well I'm in state 1 , so I call rule number 4 . 好吧,我处于state 1 ,所以我将规则编号为4 See where this is going? 看到这是怎么回事? By adding states, you really open up what you can do. 通过添加状态,您可以真正实现自己的目标。

Now, a Universal Turing Machine is what's known as Turing Complete . 现在,通用图灵机就是所谓的Turing Complete This means that it can compute any computable sequence. 这意味着它可以计算任何可计算的序列。 Including, the specification for your assignment! 包括,为您分配的规格!

Your Assignment 您的作业

So let's look at your assignment in the context of a turing machine. 因此,让我们在图灵机的上下文中查看您的任务。

The aim of the machine is to print out.. 机器的目的是打印出来。

0 1 00 01 11 000 001 011 111

So we know that we need to maintain a state. 因此,我们知道我们需要维持一个状态。 We also know that the state needs to get deeper and deeper. 我们也知道,国家需要变得越来越深。 So if you user types in 000 , we need to be able to know that we have three characters to output. 因此,如果用户输入000 ,则需要知道要输出三个字符。

And in terms of homework help, that's I'm afraid all I should be responsibly giving you. 就家庭作业帮助而言,恐怕我应该以负责任的态度给您。 A good understanding of the turing machine, plus an understanding of what you need this to do, should result in a start in your research to a solution. 对图灵机的一个很好的理解,再加上对您需要做的事情的理解,应该会导致您开始研究解决方案。

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

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