Programming Language, Turing Completeness and Turing Machine

Posted by Amumu on Programmers See other posts from Programmers or by Amumu
Published on 2012-06-17T17:25:57Z Indexed on 2012/06/17 21:23 UTC
Read the original article Hit count: 283

A programming language is said to be Turing Completeness if it can successfully simulate a universal TM. Let's take functional programming language for example.

In functional programming, function has highest priority over anything. You can pass functions around like any primitives or objects. This is called first class function.

In functional programming, your function does not produce side effect i.e. output strings onto screen, change the state of variables outside of its scope. Each function has a copy of its own objects if the objects are passed from the outside, and the copied objects are returned once the function finishes its job. Each function written purely in functional style is completely independent to anything outside of it. Thus, the complexity of the overall system is reduced. This is referred as referential transparency.

In functional programming, each function can have its local variables kept its values even after the function exits. This is done by the garbage collector. The value can be reused the next time the function is called again. This is called memoization.

A function usually should solve only one thing. It should model only one algorithm to answer a problem. Do you think that a function in a functional language with above properties simulate a Turing Machines?

  • Functions (= algorithms = Turing Machines) are able to be passed around as input and returned as output. TM also accepts and simulate other TMs
  • Memoization models the set of states of a Turing Machine. The memorized variables can be used to determine states of a TM (i.e. which lines to execute, what behavior should it take in a give state ...). Also, you can use memoization to simulate your internal tape storage. In language like C/C++, when a function exits, you lose all of its internal data (unless you store it elsewhere outside of its scope).
  • The set of symbols are the set of all strings in a programming language, which is the higher level and human-readable version of machine code (opcode)
  • Start state is the beginning of the function. However, with memoization, start state can be determined by memoization or if you want, switch/if-else statement in imperative programming language. But then, you can't
  • Final accepting state when the function returns a value, or rejects if an exception happens. Thus, the function (= algorithm = TM) is decidable. Otherwise, it's undecidable. I'm not sure about this. What do you think?

Is my thinking true on all of this?

The reason I bring function in functional programming because I think it's closer to the idea of TM.

What experience with other programming languages do you have which make you feel the idea of TM and the ideas of Computer Science in general? Can you specify how you think?

© Programmers or respective owner

Related posts about programming-languages

Related posts about turing-completeness