Basics of using the Code Editor
Creating our Alphabet
To create a Turing Machine, we first need to define the alphabet we are
working with. If we want our input alphabet to have symbols a and b,
we can use the following command.
setAlpha(a,b);
In order for our Turing machine to function, we also need to define a tape alphabet. The tape alphabet is the union of the input alphabet and the empty string.
setAlpha(a,b);
setTapeAlpha(_);
The first symbol of the tape alphabet is used as the blank symbol by default. For ease of use, we only add the symbols that aren't in the input alphabet rather than adding them again.
Creating States
Now that we have the alphabet, we must now define what our states are. These must be different symbols from what is used in the alphabet. We want to have 3 states, q0, q1 and q2.
makeStates(q0,q1,q2);
A Turing machine also requires an initial state, accept and reject states. We assign these from the states we just made.
setInit(q0);
setAccept(q1);
setReject(q2);
Creating Transitions
Each state must have a transition to another state for each symbol in our tape alphabet. Transitions have the following format.
makeTransitions( current_state / current_symbol -> next_state / new_symbol / direction );
Directions can be either L or R. To make transitions for our TM, we do the following:
makeTransitions(q0/_->q1/_/L);
makeTransitions(q0/a->q1/a/R);
makeTransitions(q0/b->q2/b/R);
Note that there are no transitions from q1 or q2. This is because they are halting states.
Complete Turing Machine Code
setAlpha(a,b);
setTapeAlpha(_);
makeStates(q0,q1,q2);
setInit(q0);
setAccept(q1);
setReject(q2);
makeTransitions(q0/_->q1/_/L);
makeTransitions(q0/a->q1/a/R);
makeTransitions(q0/b->q2/b/R);