Computer Science 456/656: Automata and Formal Languages
Using vi and copy and paste to Emulate a Turing Machine

How to use the Emulator

The emulator shows the configuration of the machine at each step. A configuration is written as "x<N>y" where x and y are strings and N is the name of the current state, which can be any string which does not contain ":" or "<" or ">" or any symbol that might confuse vi. x is the string of symbols before the current tape cell, and y is the string of symbols on the tape including the current tape cell. Thus, the head is at the first symbol of y. If the state is h, the machine has halted. If the state designator is of the form "<c:N>" then the machine has crashed and its last state was N.

Here are the steps to run the emulation:

  1. Copy all lines below the dashes in the vicommands file.
  2. Write an initial configuration into any file. Normally, the initial configuration is "<0>w" where w is a string over the input alphabet. Do not forget the space before the string w, representing the fact that the initial cell is blank.
  3. Edit the file using vi. Move the pointer to the line which has the initial configuration, then paste repeatedly.
  4. If all the vicommand text is copied, the sequence of configurations will be written to the file. If all text except for the initial "Yp" is copied, the configuration is edited at each step, so that if your file initially contains just one line, the initial configuration, it will always contain just one line.
  5. The purpose of the "h" in the last line is to create a carriage return. If you paste-cr do not copy the last line.