Wow! That's a lot to take in. The first three items in the quadruple are pretty straightforward, but what is that fourth item? Let's describe this in a more gentle way:
Recall our example of adding two tallies to a number on a tape. We used the following algorithm:
The transition function for this algorithm can be represented using a table:
0
We can write the transition function in an even more compact notation as follows:
The transition function of a Turing machine is extremely powerful. In fact, supplying just the transition function of a Turing machine gives you everything you need to know about the Turing machine except for the initial state of the machine. However, we will make the assumption that the initial state is the first state mentioned (that is, the state at the top left corner of the Turing program), which is called the Top-Left Rule for Varphi. Writing the transition function in compact notation makes it very easy to describe Turing machines without heavy notation or tables.
Believe it or not, you've just written your first Varphi Program! Here it is in a code block.
Pretty simple, right?
A Turing machine is a quadruple , where
is a finite nonempty set of states (e.g., , for some .
is the initial state.
is the set of final states.
is the transition (partial) function.
NOTE: Above, we represent "tally" using , "blank" using , "left" using , and "right" using .
is a partial function (may not be defined for some inputs in the domain) mapping pairs of non-final states and tape cell possibilities to triples containing a state, tape cell possibility, and head direction.
For example, if maps to , then this can be read as "if the machine's state is and the current tape cell is blank, then switch to state , place a tally at the current tape cell, and move the head to the tape cell immediately right of the current tape cell.
Since we previously mentioned that states do not need to define rules for all possible tape cell conditions, is a partial, not total, function.
Start at state . Read the current tape cell.
If we are on state :
If there is a tally at the current tape cell, write a tally to the current tape cell (leaving it as-is) and move to the tape cell immediately to the right of the current one. Stay on state . Repeat.
If the current tape cell is blank, write a tally to the current tape cell and move to the tape cell immediately to the right of the current one. Switch to state . Repeat.
If we are on state :
If the current tape cell is blank, write a tally to the current tape cell and move to the tape cell immediately to the right of the current one. Switch to state . Repeat.
Again, means "tally", means "blank", means "right", and means "left" here.