from http://www.cs.unm.edu/~luger/cs451/assignments/a7.html
CS 451 Programming Paradigms
Perl Assignment: A Universal Turing Machine

Part 1: (15 pts)

Write a Perl script that simulates the working of a Universal Turing Machine. The script could be called utm and takes in a filename as a command line argument. The file contains a string representing the meaningful/useful part of the 'tape', i.e. the program and the data that the turing machine will work on.

To the left of the 'tape' is the turing machine program and to the right, the data, separated by the 'blank' character,(in the example in Prof.Luger's book, B). The program would be a list of 5 tuples {state,symbol_read,symbol_written, move_head,next_state} which will define the finite state control of the turing machine head. For simplicity lets denaote the start and end of a program to be delimited by the # character.

To the right of the program one would find the data that the turing machine program executes on.

So, in effect your script simulates the finite state control of the UTM until the program is read to completion after which the UTM transforms into the turing machine as described by the program.

The output of any turing machine is the final state of the tape along with the informtion about the position on the tape where the turing machine head comes to a halt. So, rewrite the input file by deleting the program segment, replacing the data segment of the string with the final state of the tape and indicate by some means the position of the head with respect to the string (tape).

Part 2:

a. Test your script with the program for unary subtraction described in the textbook. (0 pts)

b. Test your script with a turing machine program that you will have to come up with for simulating the string search operation given binary data and the string to be searched known to the finite state control of the turing machine as it will be defined (hard-coded) in your program.

(5 pts)

Thus, we would have somewhat proved that the TM is as powerful as Perl and its regular expression search features and confirmed the Church-Turing Hypothesis.


[ Back to CS451: Assigments ]