Turing Machine Simulator
FilesComputer programs:Example Turing machines: Unary numbers:
Demonstration of Turing machine simulatorI will assume the programs have already been compiled and are located in the current directory.Turing machine to increment unary numbers: Some unary numbers:> more increment.fsm 001 0 --> 001 0 R 001 1 --> 002 1 R 002 0 --> 000 1 R 002 1 --> 002 1 R Demonstrate the Turing machine simulator by incrementing a few numbers:> more 3.num 1110 > more 6.num 1111110 Demonstrate the multiplication Turing machine:> tm increment.fsm 3.num 1111 > tm increment.fsm 5.num 111111 Demonstrate Turing machine that determines primes from non-primes:> cat 3.num 4.num > 3-4.num > more 3-4.num 1110 11110 > tm mul.fsm 3-4.num 111111111111 Convert "increment.fsm" to a binary number...> tm prime.fsm 2.num 11 > tm prime.fsm 3.num 11 > tm prime.fsm 4.num 1 > tm prime.fsm 5.num 11 > tm prime.fsm 6.num 1 > tm prime.fsm 7.num 11 > tm prime.fsm 8.num 1 ...and then back to a finite state machine description:> fsm2num increment.fsm > increment.num > cat increment.num 10011001001011000110001001011000111 Use the universal Turing machine to simulate the increment Turing machine acting on the number 3:> num2fsm increment.num 001 0 --> 001 0 R 001 1 --> 002 1 R 002 0 --> 000 1 R 002 1 --> 002 1 R Use the universal Turing machine to simulate the multiplication Turing machine acting on the numbers 2 and 3:> cat increment.num 3.num > increment-3.num > more increment-3.num 10011001001011000110001001011000111 1110 > tm utm.fsm increment-3.num 1111 Use the universal Turing machine to simulate itself simulating the increment Turing machine acting on the number 3:> fsm2num mul.fsm > mul.num > cat mul.num 2.num 3.num > mul-2-3.num > tm utm.fsm mul-2-3.num 111111 Use the universal Turing machine to simulate itself simulating the multiplication Turing machine acting on the numbers 3 and 4 (this takes about ten hours on my computer):> fsm2num utm.fsm > utm.num > cat utm.num increment-3.num > utm-increment-3.num > tm utm.fsm utm-increment-3.num 1111 > cat utm.num mul.num 3.num 4.num > utm-mul-3-4.num > tm utm.fsm utm-mul-3-4.num 111111111111 |