Skip to content

Turing Machines (TMs)

Welcome to Week 6!

After our introductory adventure with NFAs and PDAs, we will finally meet the ultimate model for computation: Turing Machines (TMs).

Learning Objectives for this week

  • Classify grammars according to the Chomsky Hierarchy.
  • Define Turing Machines (TMs).
  • Formally specify TMs.
  • Simulate TM computation.
  • Use configurations to describe the state of a TM at a given time.
  • Describe TMs using the 3 levels of specification (Formal, Implementation, High-level/pseudocode).
  • Define decidable and recognisable languages.
  • Use a Venn diagram to show the relation between the various language classes.
  • Describe the differences between DFAs/NFAs, PDAs and TMs.
  • Describe and discuss some generalisations of TMs.
  • Interpret the Church-Turing Thesis.

Pre-class Activity

CFLs are powerful, but patterns like \(\texttt{a}^n \texttt{b}^n \texttt{c}^n\) still cannot be recognised! Maybe what we need is two stacks? How can 2 stacks be used in this particular case?

Hint

Make two copies of \(n\) in both stacks.

Solution
  • Use the first stack to check there are \(n\) copies of \(\texttt{b}\)'s.
  • Use the first stack to check there are \(n\) copies of \(\texttt{c}\)'s.

Now, does this mean we will need 3,4,... stacks for more demanding languages?

Answer

No, but why?

Hint

How can you simulate a tape with 2 stacks?

Answer

Push whatever you pop from one stack into the other one.

To help you visualise this think of the stacks sideways like this:

 --------------       --------------
| aaabb                    baabbaaa |
 --------------       --------------

Lecture videos

The PDF slides are available for download below.

Download Slides

Chomsky Hierarchy

Grammars are very powerful and can represent languages from regular to the most complex ones.

Noam Chomsky studied Grammars and classified them according to their rules into 4 types. The most general type (Type-0) corresponds to full computation, and the associated machine is called a Turing Machine (TM).

Let us see how these TMs build on NFAs and PDAs.

N.B.

"Recursively Enumerable" (in Chomsky Hierarchy) is what we call "Recognisable" (following the terminology used in Sipser's textbook).

Decidable languages and Recognisable languages

The two major changes that TMs introduce is the ability to use an infinite tape to store the input and perform calculations without any restrictions on space. This gives us huge possibilities but introduces a subtle complication: when do we stop processing the input? (When do we stop the computation)

The answer is that we introduce dedicated accept and reject states which take immediate effect when they reached. This however gives rise to situations where the TM may loop forever and never reach either of the halting states... welcome to decidable and recognisable languages (and the halting problem!)

Specification of TMs

TMs are the most powerful model of computation, and will be with us for the rest of this module. We will describe many of them, but if we always insist on the low-level description using states and transitions then it can become rather challenging. Instead, we use higher level descriptions, similar to code that we usually write using popular programming languages.

Generalisations of TMs

Let us now look at non-determinism with TMs, and the possibility of increasing their power using many tapes. Do these make a difference like non-determinism made a difference for PDAs?

Also, could quantum computing or DNA computing be more powerful than what TMs model?

So what is "computation"?

TMs are the most powerful model of computation that we know of. The Church-Turing Thesis tries to formalise the surprising fact that all the models of computation that we have developed end up being equivalent to TMs. This is used to give a precise definition to computation and algorithms.

Ready for the lab exercises?

Attempt Lab 6 exercises

Ask & Answer Questions

Don't forget: you can use Teams or the Aula's feed to raise questions for me and the rest of the class.

Add your questions to the Community Feed and take a look at others' questions. If you see a question which you'd like to answer then just go ahead and participate in the discussion!