You are on page 1of 13

1.

Turing Machines

Introduction
FAs and PDAs are models of computation associated with regular languages and context-free languages, respectively Regular languages form a proper subset of the context-free languages FAs have limited (a small amount of) memory For example, languages, like L = {anbn: n 0}, are not regular languages The use of stack (unlimited LIFO memory) as memory in PDA made it accept the language L = {anbn: n 0} Some simple languages such as {anbncn: n 0} and {ww} are not context-free This makes us look beyond context-free languages How far the concept of automaton can be pushed?
2

Turing Machines
Turing machine (TM) is a powerful model of computation first proposed by Alan Turing in 1936 Similar to an FA but with an unlimited and unrestricted memory A TM is an accurate model of a general purpose computer A TM can do everything a real computer can do A TM cannot solve some problems that are beyond the theoretical limits of computation The TM model uses an infinite tape as its unlimited memory It has a tape head that can read and write symbols and move around on the tape Initially the tape contains only the input string and is blank everywhere else
3

If TM needs to store information, it may write the information on the tape To read information that it has written, the machine can move its head back over it The machine continues computing until it decides to produce an output The whole process terminates by putting the TM in a halt state A TM is said to halt whenever it reaches a configuration for which is not Any final state is a halt state is is not defined on it If it doesn t enter the halt state, it will go on forever, never halting Initially the tape contains only the input string and is blank everywhere else Figure 1.1 shows a schematic representation of a Turing machine
4

tape
... a b a a ...

read-write head

control unit

Figure 1.1: Schematic representation of a Turing machine


5

The Standard Turing Machine


Definition of a Turing Machine A Turing machine is a 7 tuple (Q, , , , q0, , F) where Q, , are all finite sets and: Q is the set of states is the input alphabet { } is the tape alphabet :Q Q {L, R} is the transition function is a special symbol called the blank q0 Q is the initial state F Q is the set of final states The heart of a TM is the transition function When the machine is in a certain state q and the head is over a tape square containing a, and if (q, a) = (r, b, L), the machine writes the symbol b replacing the, and goes to state r
6

The third component is either L or R and indicates whether the head moves to the left or right after writing, respectively Changes occur in the current state, the current tape contents, and the current head location A setting of these three items is called a configuration of TM Instantaneous description is a convenient way to exhibit a sequence of configurations We use the notation x1qx2 or a1 ak-1qakak+1 an where the read-write head is on the cell holding ak, the current state is q, x1 = a1 ak-1 and x2 = ak+1 an Let M = (Q, , , , q0, , F) be a TM. Then any string a1 ak-1q1akak+1 an, with ai and q1 Q, is an instantaneous description of M A move a1 ak-1q1akak+1 an a1 ak-1bq2ak+1 an is possible iff (q1, ak) = (q2, b, R)
7

A move a1 ak-1q1akak+1 an a1 q2ak-1bak+1 an is possible iff (q1, ak) = (q2, b, L) M is said to halt starting from initial configuration x1qix2 if x1qix2 * y1qjay2for any qj and a, for which (qj, a) is undefined The sequence of configurations leading M to a halt state is called a computation If M goes into a loop and never halts we use a special notation x1qix2 * TMs can also be described using transition graphs Turing Machines as Language Accepters A string w is written on the tape, with blanks filling out the unused portions The machine started in the initial state q0 with the read-write head position on the leftmost symbol of w If, after a sequence of moves, the Turing machine enters a 8 final state and halts, then w is considered to be accepted

Let M = (Q, , , , q0, , F) be a TM Then the language accepted by M is: +: q w * x q x for some q L(M) = {w F, x1, x2 *} 0 1 f 2 f Example 1.1: For = {0, 1}, design a TM that accepts the language denoted by the regular expression 00* Example 1.2: For = {a, b}, design a TM that accepts L = {a, b}*{ab} Example 1.3: For = {a, b}, design a TM that accepts L = {anbn: n 1} Example 1.4: Design a TM that accepts L = {anbncn: n 1} Example 1.5: Design a TM that accepts L = {xx: x {a, b}*} Example 1.6: Design a TM that accepts L = {a raised to 2 raised to n: n 0} 9

Turing Machines as Transducers A transducer transforms input to output The input for a computation is the nonblank symbols on the tape at the initial time At the conclusion of the computation, the output will be whatever is then on the tape We can view a TM transducer M as an implementation of a function f defined by w = f(w) provided that q0w *M qfw for some final state qf A function f with domain D is said to be Turing-computable or just computable if there exists some Turing machine M = (Q, , , , q0, , F) such that q0w *M qff(w), qf F, for all w D Example 1.7: Given two positive integers, design a TM that computes x + y
10

Example 1.8: Given a unary representation of a positive integer, design a TM that converts the integer to its binary equivalent Example 1.9: Design a TM that copies a string of 1 s Example 1.10: Let x and y be two positive integers in unary representation. Construct a TM that will halt in a final state qy if x >= y, and will halt in a nonfinal state qn if x < y. Combining Turing Machines as for Complicated Tasks Basic operations can be put together to perform complicated tasks Example 1.11: Design a TM that computes the function f(x, y) = x + y if x y, f(x, y) = 0 if x < y Figure 1.2 shows how TMs can be combined to compute f(x, y)
11

Figure 1.2 Turing s Thesis Reading Assignment

12

Other Models of Turing Machines


Minor Variations on the Turing Machine Theme Equivalence of Classes of Automata Turing Machines with a Stay-Option Turing Machines with Semi-Infinite Tape The Off-Line Turing Machine Turing Machines with More Complex Storage Multitape Turing Machines Multidimensional Turing Machines Nondeterministic Turing Machines A Universal Turing Machine Linear Bounded Automata
13

You might also like