This project implements a Universal Turing Machine in the C programming language. A Turing Machine is a mathematical model of computation that defines an abstract machine, which manipulates symbols on a strip of tape according to a set of rules. The universal version of this machine can simulate any other Turing machine.
>
: Move the tape head to the right.<
: Move the tape head to the left.#
: Initial symbol on the tape._
: Blank space on the tape.
- Compile the Program: Use a C compiler to compile the code. For example, using GCC:
gcc turing_machine.c -o turing_machine
- Run the Program: Execute the compiled program:
./turing_machine
- Input the Transitions: Follow the prompts to input the transitions, initial state, and final states.
- Input the String: Enter the string to be processed by the Turing machine and the initial position of the tape head.
- Simulation: The program will simulate the Turing machine's operation and indicate whether the input string is accepted or not.
-
Example 1:
- Transitions:
1,a,2,b,> 2,b,1,a,<
- Initial State:
1
- Final State(s):
2
- Input String:
abab
- Initial Head Position:
0
- Result:
Accepted
- Transitions:
-
Example 2:
- Transitions:
1,a,1,a,> 1,_,2,_,<
- Initial State:
1
- Final State(s):
2
- Input String:
aaa
- Initial Head Position:
0
- Transitions:
- Ensure the input format for transitions follows the
state1,symbol1,state2,symbol2,direction
pattern. - The program can be modified to handle more complex Turing machines with additional features as needed.