What are practical guidelines for evaluating a language's “Turing Completeness”?

前端 未结 13 2040
礼貌的吻别
礼貌的吻别 2020-12-22 19:22

I\'ve read \"what-is-turing-complete\" and the wikipedia page, but I\'m less interested in a formal proof than in the practical implications of being Turing Complete.

<
相关标签:
13条回答
  • 2020-12-22 19:51

    I'm not sure if there's a "minimum set of features", but to prove that a language is Turing complete, you only have to prove that it can emulate another Turing complete system (not necessarily a Turing machine), as long as the other system is known to be Turing complete. http://en.wikipedia.org/wiki/Turing_complete#Examples has a whole list of Turing complete systems. Some of them are simpler than Turing machines.

    0 讨论(0)
  • 2020-12-22 19:52

    If you can write a Brainf$&# interpreter in your language, it is Turing-complete. LOLCODE was proved to be Turing-complete in exactly this way.

    0 讨论(0)
  • 2020-12-22 19:54

    You can try emulating an OISC (One Instruction-Set Computer). If you can emulate one of the instructions there, then since those single instruction can be used to compose a Turing Complete machine, then you have proven that your language must be Turing Complete as well.

    0 讨论(0)
  • 2020-12-22 19:57

    You need some form of dynamic allocation construct (malloc ornew or cons will do) and either recursive functions or some other way of writing an infinite loop. If you have those and can do anything at all interesting, you're almost certainly Turing-complete.

    The lambda calculus is equivalent in power to a Turing machine, and if you implement lambda calculus it is actually pretty fun writing lambda calculus programs. Way more fun than writing program for a Turing machine!

    The only practical implication of Turing-completeness I'm aware of is that you can write programs that don't terminate. I've used a couple of special-purpose languages that guarantee termination and therefore are not Turing-complete. Sometimes it is useful to give up the extra expressive power in exchange for guaranteed termination.

    0 讨论(0)
  • 2020-12-22 19:58

    Is there a minimum set of features without which Turing Completeness is impossible? Is there a set of features which virtually guarantees completeness?

    Yes, you need to have flow of control conditional on data: what is often expressed as if. For example a +-*/ pocket calculator is not Turing-complete, since there is no way to express conditionals.

    You also need to be able to express a jump back to an earlier point in the program, on top of which you could implement a loop. For example BPF, which forbids backwards jumps to guarantee the program will terminate, is also not Turing complete.

    You need some storage that is both readable and writable and arbitrarily large. For example, a language that has only two 32-bit variables is limited in what it can compute. You have many options for how the storage is structured: memory addressed by pointers, arrays, stacks, cons cells, pure data structures, etc.

    On top of these you can build every other programming language: it may not be easy or fast, but it is enough.

    0 讨论(0)
  • 2020-12-22 20:05

    I'd like to add one caveat to what Norman Ramsey said: a Turing machine has infinite memory and hence programming languages that are considered to be Turing complete are only so under the assumption that memory is also infinite.

    0 讨论(0)
提交回复
热议问题