Class 32: Introduction to Turing Machines


Reading
Sections 4.1 of Theory of Computing, A Gentle Introduction, introduces Turing Machines. But we're really only worrying about the first 3 pages of that section right now.
Homework
Then printout the homework and answer the questions on that paper.

Introduction
We've considered two computational models so far: FAs and PDAs. We've proved a wide variety of things about what these models are capable of computing and what they're not capable of computing. From a practical standpoint, these models are extremely important. From them we get algorithms for pattern matching (as in egrep and perl) and parsing (as in bison), and the formalisms of regular expressions and grammars are used in specifications of programming languages, data formats and protocols. From a theoretical standpoint, however, they're both just warm-ups for the main event: a computational model with the full power of what we call "a computer".

This model is called a Turing Machine, and it was invented and investigated by Alan Turing in the 1930's ... before we really had computers! Essentially, it is a finite automaton + an array. In particular:

For this class we played with examples of such machines using JFLAP. Once we're familiar with them informally, we'll go back and give formal definitions.

Example 1
Below is a simple Turing Machine that erases it's input. Note: the "  " in the transitions stands for a blank.

This machine writes a blank no matter what it reads, and keeps moving right. When reads the first blank (i.e. the end of the input) it halts. We specifically ran it in class on the input tape

 a   b   b              ...

Lab Excercises
The following problems were given as excercises in the lab. You'll use JFLAP and choose the Turing Machine option. [Note: JFLAP's Turing machine model is slightly different than ours. The JFLAP Turing machine has a two-way infinite tape, rather than one-way.] Construct Turing Machines (input alphabet is {a,b} for all problems) with JFLAP that:

  1. swaps all the as and bs in the input. E.g. abbbaa.

  2. swaps all the as and bs in the input and leaves the read/write head pointing to the first character in the string.

  3. Copies the first letter of the string to the square following the first blank after the string. E.g. abbabb a.

  4. Copies the input with a blank in between the input and the copy. E.g. abbabb abb.

  5. Halts if the input is a palindrome, goes into an infinite loop otherwise.

Note: Please save each machine as a separate JFLAP file. You might need them later!


Christopher W Brown
Last modified: Wed Nov 18 13:30:09 EST 2009