Chapter One
What This Subject Is About, and the Four Questions It Answers
Syllabus topic Module 1, "Introduction to Theory of Computation: Basics of Computation, Importance of Theory of Computation in Computer Science"
In one line
The theory of computation is the study of what problems a machine can solve, and how much time and space solving them takes.
In the wording a student can write in an examination: the theory of computation is the branch of computer science that builds precise mathematical models of a computing machine, and uses them to classify problems according to whether they can be solved at all, and if so with what resources.
Why a computer science degree teaches this at all
Every other paper on this degree teaches you to make a computer do something. This one asks a different question, and it is the only paper that asks it: what can a computer do at all?
That sounds like a question with an obvious answer, and it is not. There are problems no computer will ever solve, not because the machine is too slow or the programmer is not clever enough, but because no method exists. There are other problems that can be solved in principle and cannot be solved in practice, because every known method would run past the age of the universe on an input the size of a phone book. Both of those facts were proved, by hand, before the first working computer was built.
The four questions
Everything in this paper is an answer to one of four questions. It is worth having them on one page before starting, because each of the five blocks of the syllabus is an attack on one of them.
One. What can be computed at all? This is the question Module 2 ends on. Some problems have no algorithm, and we can prove which ones.
Two. What can be computed quickly? A problem with an algorithm that takes a thousand years is not solved in any sense a working programmer would accept. The last block of Module 2 is about drawing that line precisely.
Three. How much machine does a job need? Not every task needs a full computer. Checking that a password has a digit in it needs almost nothing. Checking that brackets balance needs a little memory. Deciding whether a program halts needs more than any machine has. Module 1 and Module 2 build a ladder of four machines, each stronger than the last, and place jobs on the rungs.
Four. How can we be sure? Every claim in this paper is proved. That is not academic manners; it is the only way to know that a machine is right for every input rather than for the inputs you happened to try.
The four questions, with a problem you already have
A list of questions is easy to forget. Each of these is a problem you have met on this degree already, and each one is one of the four questions in disguise.
What This Subject Is About, and the Four Questions It Answers
A search box that accepts patterns. You want to find every line in a file that begins with a capital letter and ends in a semicolon. The pattern language that does this is called a regular expression, and the whole of the fourth block of Module 1 is about it. The interesting part is not that it works. It is that there is a precise boundary to what patterns of this kind can express, and "lines with the same number of opening and closing brackets" is on the far side of it. You will prove that in chapter 37.
A compiler. Before your Java compiler can object to a missing bracket, it has to know what a correctly bracketed program looks like. The description it uses is a grammar, which is the third block of Module 1, and the machine that reads it is a pushdown automaton, which opens Module 2. When your compiler reports a syntax error, the thing that found it is one of the machines in this book.
A lock screen. A four digit PIN entry is a machine with a small number of states: how many digits have been typed, and whether they were right. Nothing else needs to be remembered. That is a finite automaton, and it is the second block of Module 1.
A marking scheme. Suppose a lecturer wants a program that reads a student's submitted program and reports whether it will ever loop for ever. Every student wants this to exist. It cannot. That is the halting problem, it is proved in chapter 74, and the proof takes half a page.
What the word computation is standing for
The word is doing a lot of work, so it is worth being careful about it early.
A problem here always means a question about an input, and we shall almost always arrange for the answer to be yes or no. "Is this number prime?" is a problem. "Is this bracket sequence balanced?" is a problem. "Sort this list" looks different, but it can be turned into a yes or no question, and reducing everything to yes or no is what makes a mathematical treatment possible.
An instance of a problem is one particular input. The number 91 is an instance of the primality problem, and the answer for that instance is no, because 91 is 7 times 13.
An algorithm is a finite list of unambiguous instructions that, followed exactly, produces the answer for every instance, and stops. Each of those words matters. Finite, so it can be written down. Unambiguous, so no judgement is needed at any step. Every instance, so it is not a method that works for the cases we tried. And stops, because a procedure that runs for ever has not answered anything.
What This Subject Is About, and the Four Questions It Answers
Computation is what happens when a machine carries out an algorithm on an instance. This subject makes "machine" precise, four times over, each time a little stronger.
Why the models are so simple
The first thing a student notices about this paper is that the machines are absurdly primitive. A Turing machine has one tape, one head, and no arithmetic. That is not a historical accident or a simplification for teaching. It is the point, and there are two reasons for it.
The first is that a simple model can be reasoned about. You cannot prove anything about a machine whose description takes ten thousand pages. You can prove a great deal about a machine whose description takes five lines, and a proof about the simple machine is worth having only if the simple machine is as strong as the complicated one.
The second is that it turns out to be as strong. This is the single most surprising result in the subject, and chapter 72 is about it: every attempt anybody has made to define a more powerful machine, by adding tapes, heads, dimensions, randomness or guessing, has produced a machine that solves exactly the same set of problems. That is the Church Turing thesis, and it is what licenses the whole enterprise. When we prove that no Turing machine can solve a problem, we are entitled to say that no computer can.
Where the subject came from
Three dates are worth remembering, because they explain why the subject looks the way it does.
In 1936 Alan Turing published "On Computable Numbers, with an Application to the Entscheidungsproblem" in the Proceedings of the London Mathematical Society, pages 230 to 265. The paper's own first page records that it was received on 28 May 1936 and read on 12 November 1936. Turing was not designing a computer. He was answering a question David Hilbert had asked about mathematics, and the machine was a tool invented for the proof. The tool turned out to be more important than the answer.
In 1951 Stephen Kleene, working at RAND, wrote up finite automata and the expressions that describe them, in a research memorandum numbered RM-704 and titled "Representation of Events in Nerve Nets and Finite Automata". Its own summary dates the investigations it reports to August 1951. And in 1956 Noam Chomsky, studying human language rather than machines, wrote "Three Models for the Description of Language", which his own archive dates to September 1956. The classification of grammars in chapter 26 is from that paper.
What This Subject Is About, and the Four Questions It Answers
So the four machines in this book were invented by a logician, an electrical engineer and a linguist, none of whom was trying to build a computer. That is worth knowing when the subject feels disconnected from programming. It was not derived from programming; programming arrived later and turned out to fit.
How this book is arranged, and why the order is MU's
The chapters follow the University's printed syllabus in her own order, under her own headings. That order is also a good teaching order, which is not always true of a syllabus, and it is worth seeing why before starting.
Module 1 builds the weakest machine first, the finite automaton, and pushes it until it breaks. Then it introduces grammars, which describe languages from the other direction, and shows that the weakest grammar describes exactly what the weakest machine accepts. Then it takes the next grammar up, the context free one, and Module 2 builds the machine that matches it. Then it does the same thing twice more. By the end there are four machines, four kinds of grammar, and a proof that they pair off.
What it does NOT mean
This is not a paper about programming languages. The word "language" in this subject means something much simpler: a set of strings. The language of a machine is just the collection of inputs it says yes to. It has no syntax, no semantics and no compiler.
A machine here is not a computer. It is a mathematical object, defined by a small number of sets and a function. Nothing is ever built. Asking how fast a Turing machine runs in megahertz is asking the wrong sort of question about the wrong sort of object.
"Cannot be computed" is not a statement about today's computers. It is not "no current machine can do this", nor "we have not found a method yet". It means no method exists, and never will, and that this has been proved.
Quick revision
- The theory of computation studies which problems a machine can solve, and at what cost in time and
space.
- Four questions: what is computable at all; what is computable quickly; how much machine a job
needs; and how we can be sure.
- A problem is a question about an input; an instance is one input; an algorithm is a finite,
unambiguous method that answers every instance and stops.
- A language, in this subject, is a set of strings, and the language of a machine is the set of
inputs it accepts.
- The models are deliberately primitive, because simple models can be proved things about, and
because they turn out to be as strong as complicated ones.
What This Subject Is About, and the Four Questions It Answers
- Turing 1936, pages 230 to 265; Kleene's RAND memorandum RM-704 of 1951; Chomsky's
three models paper of 1956.
- MU examines this paper in one hour for 30 marks, in three questions of two answers each, so every
topic in this book has to be answerable in about ten minutes.
Test yourself
1. Define an algorithm, and say what each part of the definition rules out. A finite list of unambiguous instructions that, followed exactly, produces the correct answer for every instance of the problem and then stops. Finite rules out a method that cannot be written down; unambiguous rules out a step requiring judgement; every instance rules out a method that works only on the cases tried; and stopping rules out a procedure that runs for ever without answering.
2. Give one reason the machines in this subject are defined so simply. Because a proof can be carried out about a five line definition and cannot be carried out about a real processor, and because the simple machines turn out to solve exactly the same problems as any richer model anyone has proposed.
3. What does the word language mean in this paper? A set of strings over a fixed alphabet. Nothing more: no syntax rules beyond membership, and no meaning attached to the strings.
4. State the four questions the subject answers. What can be computed at all; what can be computed quickly; how powerful a machine a given job needs; and how we can be certain of the answers.
5. A student says a problem is uncomputable because no fast enough computer exists yet. Uncomputable means no algorithm exists at all, which is a proved mathematical statement about the problem and not about any machine. A problem that needs a faster computer is computable but expensive, which is a question for the complexity block of Module 2, not the computability block.