图灵完备是什么意思?
你能不能给出一个简单的解释,而不是过多的理论细节?
图灵完备是什么意思?
你能不能给出一个简单的解释,而不是过多的理论细节?
当前回答
We call a language Turing-complete if and only if (1) it is decidable by a Turing machine but (2) not by anything less capable than a Turing machine. For instance, the language of palindromes over the alphabet {a, b} is decidable by Turing machines, but also by pushdown automata; so, this language is not Turing-complete. Truly Turing-complete languages - ones that require the full computing power of Turing machines - are pretty rare. Perhaps the language of strings x.y.z where x is a number, y is a Turing-machine and z is an initial tape configuration, and y halts on z in fewer than x! steps - perhaps that qualifies (though it would need to be shown!)
A common imprecise usage confuses Turing-completeness with Turing-equivalence. Turing-equivalence refers to the property of a computational system which can simulate, and which can be simulated by, Turing machines. We might say Java is a Turing-equivalent programming language, for instance, because you can write a Turing-machine simulator in Java, and because you could define a Turing machine that simulates execution of Java programs. According to the Church-Turing thesis, Turing machines can perform any effective computation, so Turing-equivalence means a system is as capable as possible (if the Church-Turing thesis is true!)
图灵等价比真正的图灵完备性更主流;这一点以及“完全”比“等效”短的事实可能解释了为什么“图灵完全”经常被误用为图灵等效,但我离题了。
其他回答
这是最简单的解释
艾伦·图灵创造了一台机器,它可以接收程序,运行程序,并显示结果。但是他必须为不同的程序创造不同的机器。所以他发明了“通用图灵机”,可以接收并运行任何程序。
编程语言类似于这些机器(尽管是虚拟的)。他们获取程序并运行它们。现在,一种编程语言被称为“图灵完备”,如果它可以运行图灵机在足够的时间和内存下可以运行的任何程序(无论哪种语言)。
例如:假设有一个程序需要10个数字并将它们相加。图灵机可以很容易地运行这个程序。但是现在想象一下,由于某种原因,您的编程语言不能执行相同的加法。这将使它成为“图灵不完整”(可以这么说)。另一方面,如果它能运行通用图灵机能运行的任何程序,那么它就是图灵完备的。
大多数现代编程语言(如Java、JavaScript、Perl等)都是图灵完备语言,因为它们都实现了运行程序所需的所有功能,如加法、乘法、if-else条件、返回语句、存储/检索/擦除数据的方法等等。
更新:你可以在我的博客文章中了解更多:“JavaScript是图灵完备的”-已解释
关系数据库能否输入地点和道路的经度和纬度,并计算它们之间的最短路径?这是一个表明SQL不是图灵完备的问题。
但是c++可以做到,并且可以解决任何问题。事实就是这样。
We call a language Turing-complete if and only if (1) it is decidable by a Turing machine but (2) not by anything less capable than a Turing machine. For instance, the language of palindromes over the alphabet {a, b} is decidable by Turing machines, but also by pushdown automata; so, this language is not Turing-complete. Truly Turing-complete languages - ones that require the full computing power of Turing machines - are pretty rare. Perhaps the language of strings x.y.z where x is a number, y is a Turing-machine and z is an initial tape configuration, and y halts on z in fewer than x! steps - perhaps that qualifies (though it would need to be shown!)
A common imprecise usage confuses Turing-completeness with Turing-equivalence. Turing-equivalence refers to the property of a computational system which can simulate, and which can be simulated by, Turing machines. We might say Java is a Turing-equivalent programming language, for instance, because you can write a Turing-machine simulator in Java, and because you could define a Turing machine that simulates execution of Java programs. According to the Church-Turing thesis, Turing machines can perform any effective computation, so Turing-equivalence means a system is as capable as possible (if the Church-Turing thesis is true!)
图灵等价比真正的图灵完备性更主流;这一点以及“完全”比“等效”短的事实可能解释了为什么“图灵完全”经常被误用为图灵等效,但我离题了。
正如韦伦·弗林所说:
图灵完备意味着它至少和图灵机一样强大。
我认为这是不正确的,如果一个系统和图灵机一样强大,那么它就是图灵完备的,即机器所做的每一个计算都可以由系统完成,而且系统所做的每一个计算都可以由图灵机完成。
在大多数程序员熟悉的实际语言术语中,检测图灵完整性的通常方法是该语言是否允许或允许模拟嵌套的无界while语句(与具有固定上界的pascal风格for语句相反)。