next up previous
Next: Grammars and context-sensitivity Up: Turing machines and the Previous: Turing machines and the

What is a Turing machine?

A Turing machine $ M=(Q,\Sigma,\Gamma,\delta,q_0,B,F)$ is given by the following data

In the course text the transition function is defined without the stop option as $ \delta\in
Q\times \Gamma \to \{\textrm{stop}\}
Q\times\Gamma\times\{\textrm{L},\textrm{R}\}$. However they allow $ \delta$ to be undefined which correspond to our function returning stop.

This defines deterministic Turing machines, for non-deterministic TMs we change the transition function to

$\displaystyle \delta\in
\ Q\times \Gamma \to {\cal P}(Q\times\Gamma\times\{\textrm{L},\textrm{R}\})$

Here stop corresponds to $ \delta$ returning an empty set. As for finite automata (and unlike for PDAs) there is no difference in the strength of deterministic or non-deterministic TMs.

As for PDAs we define instantaneous descriptions $ \textrm{ID}$ for Turing machines. We have $ \textrm{ID}=\Gamma^*\times Q \times \Gamma^*$ where $ (\gamma_l,q,\gamma_r)\in \textrm{ID}$ means that the TM is in state $ Q$ and left from the head the non-blank part of the tape is $ \gamma_l$ and starting with the head itself and all the non-blank symbols to the right is $ \gamma_r$.

We define the next state relation $ \vdash_M$ similar as for PDAs:

  1. $ (\gamma_l,q,x\gamma_r) \vdash_M (\gamma_l y,q',\gamma_r)$ if $ \delta(q,x)=(q',y,R)$
  2. $ (\gamma_l z,q,x\gamma_r) \vdash_M (\gamma_l ,q',z y \gamma_r)$ if $ \delta(q,x)=(q',y,L)$
  3. $ (\gamma_l,q,\epsilon) \vdash_M (\gamma_l y,q',\gamma_r)$ if $ \delta(q,B)=(q',y,R)$
  4. $ (\epsilon,q,x\gamma_r) \vdash_M (\gamma_l ,q',B y \gamma_r)$ if $ \delta(q,x)=(q',y,L)$
The cases 3. and 4. are only needed to deal with the situation if we have reached the end of the (non-blank part of) the tape.

We say that a TM $ M$ accepts a word if it goes into an accepting state, i.e. the language of a TM is defined as

$\displaystyle L(M) = \{ w\in\Sigma^* \mid (\epsilon,q_0,w) \vdash_M^*
(\gamma_l,q',\gamma_r) \wedge q'\in F \} $

I.e. the TM stops automatically if it goes into an accepting state. However, it may also stop in a non-accepting state if $ \delta$ returns stop - in this case the word is rejected.

A TM $ M$ decides a language if it accepts it and it never loops (in the negative case).

To illustrate this we define a TM $ M$ which accepts the language $ L=\{a^nb^nc^n \mid n\in\mathbb{N}\}$ -- this is a language which cannot be recognized by a PDA or be defined by a CFG.

We define $ M=(Q,\Sigma,\Gamma,\delta,q_0,B,F)$ by

The machine replaces an a by $ X$ ($ q_0$) and then looks for the first b replaces it by $ Y$ ($ q_1$) and looks for the first c and replaces it by a $ Z$ ($ q_2$). If there are more cs left it moves left to the next a ($ q_4$) and repeats the cycle. Otherwise it checks whether there are no as and bs left ($ q_5$) and if so goes in an accepting state ($ q_6$).

E.g. consider the sequence of IDs on aabbcc:

$\displaystyle \ (\epsilon,q_0,\texttt{aabbcc}) \ $ $\displaystyle \vdash (\texttt{X},q_1,\texttt{abbcc})$    
$\displaystyle  $ $\displaystyle \vdash (\texttt{Xa},q_1,\texttt{bbcc})$    
$\displaystyle  $ $\displaystyle \vdash (\texttt{XaY},q_2,\texttt{bcc})$    
$\displaystyle  $ $\displaystyle \vdash (\texttt{XaYb},q_2,\texttt{cc})$    
$\displaystyle  $ $\displaystyle \vdash (\texttt{XaYbZ},q_3,\texttt{c})$    
$\displaystyle  $ $\displaystyle \vdash (\texttt{XaYb},q_4,\texttt{Zc})$    
$\displaystyle  $ $\displaystyle \vdash (\texttt{XaY},q_4,\texttt{bZc})$    
$\displaystyle  $ $\displaystyle \vdash (\texttt{Xa},q_4,\texttt{YbZc})$    
  $\displaystyle \vdash (\texttt{X},q_4,\texttt{aYbZc})$    
  $\displaystyle \vdash (\epsilon,q_4,\texttt{XaYbZc})$    
  $\displaystyle \vdash (\texttt{X},q_0,\texttt{aYbZc})$    
  $\displaystyle \vdash (\texttt{XX},q_1,\texttt{YbZc})$    
  $\displaystyle \vdash (\texttt{XXY},q_1,\texttt{bZc})$    
  $\displaystyle \vdash (\texttt{XXYY},q_2,\texttt{Zc})$    
  $\displaystyle \vdash (\texttt{XXYYZ},q_2,\texttt{c})$    
  $\displaystyle \vdash (\texttt{XXYYZZ},q_2,\epsilon)$    
  $\displaystyle \vdash (\texttt{XXYYZ},q_5,\texttt{Z})$    
  $\displaystyle \vdash (\texttt{XXYY},q_5,\texttt{ZZ})$    
  $\displaystyle \vdash (\texttt{XXY},q_5,\texttt{YZZ})$    
  $\displaystyle \vdash (\texttt{XX},q_5,\texttt{YYZZ})$    
  $\displaystyle \vdash (\texttt{X},q_5,\texttt{XYYZZ})$    
  $\displaystyle \vdash (\epsilon,q_6,\texttt{XXYYZZ})$    

We see that $ M$ accepts aabbcc. Since $ M$ never loops it does actually decide $ L$.


next up previous
Next: Grammars and context-sensitivity Up: Turing machines and the Previous: Turing machines and the
Thorsten Altenkirch 2001-05-08