दुर्गा बेरागी Durga Beragi, homeEnter the study →

Library › Foundations of computing

Introduction to the Theory of Computation

Michael Sipser · 1997 · PWS Publishing

Automata, computability and complexity, written to be understood.

About the book

Michael Sipser, a professor at the Massachusetts Institute of Technology, published Introduction to the Theory of Computation with PWS Publishing in 1997. Later editions followed. The book has three parts: automata and languages, computability theory, and complexity theory. It covers finite automata, regular expressions, context-free grammars, pushdown automata, Turing machines, decidability, reducibility, time and space complexity, P and NP, NP-completeness and more advanced topics. Each proof is preceded by a proof idea that explains the intuition in plain words. The book is short for its subject and known for its clarity.

Key ideas

  • Computation can be studied through simple mathematical models. Finite automata, pushdown automata and Turing machines each capture a different level of computing power and memory.
  • Some problems are decidable and some are not. The halting problem is undecidable, and reductions from it show that many other natural problems about programs are undecidable too.
  • Complexity theory asks how much time or space a decidable problem needs. P is the class of problems that a deterministic machine can solve in polynomial time.
  • NP is the class of problems whose proposed solutions can be checked quickly. Whether P equals NP, whether checking is as easy as finding, is the central open question.
  • NP-complete problems are the hardest problems in NP. Sipser shows that a fast algorithm for any one of them would give fast algorithms for every problem in NP.

Why it is on this shelf

It is the clearest introduction to the theory of computation. Its proof ideas make hard results understandable without losing rigour. Reading it gives a firm grasp of the limits of computing that bear on AI, cryptography and the design of algorithms.

How to start reading it

Read Chapter 0 on mathematical notions. Then read Part One on automata and Part Two on computability. Read the proof ideas before the full proofs.

About this book

Introduction to the Theory of Computation by Michael Sipser was first published in 1997 by PWS Publishing in Boston. A second edition followed in the mid-2000s and a third in the early 2010s, the later ones published by Thomson and then Cengage after PWS was absorbed. Through all of them the book has remained what it set out to be: a single-semester introduction to the mathematics of what computers can and cannot do, written for undergraduates and beginning graduate students.

The question the book answers is the oldest question in computer science, older than the computers themselves: what it means to compute something, and whether there are limits to what can be computed. The book divides this into three narrower questions. The first asks what machines with very little memory can compute. The second asks what can be computed at all, by any machine, given unlimited time and memory. The third asks which of the computable things can be computed efficiently, in an amount of time or space that does not explode as problems grow.

These three questions give the book its three parts: automata and languages, computability, and complexity. The first part studies simple machines and the patterns they can recognise. The second studies Turing machines and proves that some problems have no algorithmic solution. The third studies the cost of computation and arrives at the famous open question of whether P equals NP.

Sipser wrote the book because he found the existing texts either too heavy or too dry for students meeting the subject for the first time. The standard text of the previous generation, by Hopcroft and Ullman, which sits in this same bay, was thorough and authoritative but dense. Sipser aimed for something shorter and more readable without giving up rigour. His method was to precede each serious proof with a short informal explanation of why it works, which he called the proof idea, so that the reader understands the plan before following the steps.

The book has become one of the most widely used texts for this subject in the world. Students often describe it as the first mathematics book they enjoyed reading. That reputation rests on a particular kind of clarity: Sipser chooses a small number of central results, explains each one fully, and trusts the reader to follow a careful argument when it is laid out well.

This study edition is a companion to that book. It describes what the book contains, explains its main ideas in our own words with our own examples, places it among the other books in our foundations of computing bay, and suggests a way to read it. It does not reproduce the book's text, its proofs or its exercises, and it is not a substitute for working through them.

The author

Michael Sipser was born in 1954 in Brooklyn, New York. He studied at Cornell University and took his doctorate at the University of California at Berkeley in 1980, under Manuel Blum, one of the founders of complexity theory and a later Turing Award winner. He then joined the mathematics faculty of the Massachusetts Institute of Technology, where he has spent his career.

Sipser's research has been in complexity theory, the part of the subject covered in the third part of the book. In the early 1980s, with Merrick Furst and James Saxe, he proved that a certain class of very shallow circuits cannot compute the parity of a string of bits, that is, whether the number of ones is odd or even. This was one of the first strong lower bounds in circuit complexity, a field that tries to prove that certain problems need large circuits. He also proved, around the same time, a result placing randomised polynomial-time computation inside a structure called the polynomial hierarchy; an improved version by Clemens Lautemann is known as the Sipser-Lautemann theorem. He worked on the relationship between randomness and determinism, and on the P versus NP question itself, about which he wrote an influential survey of its history.

At MIT Sipser became known as an unusually good teacher. His undergraduate course on the theory of computation was the origin of the book, and he has taught it for decades. He served as head of the mathematics department and later as dean of the School of Science. His administrative work and teaching reflect the same values as the book: clarity, fairness to the student, and a preference for understanding over mere technique.

Knowing that the author is a working complexity theorist helps explain the book's balance. The first two parts, on automata and computability, are classical material that Sipser presents with great economy. The third part, on complexity, is closer to his own research, and its advanced sections reach topics such as interactive proofs and circuit lower bounds that many introductory texts omit.

The shape of the argument

The book opens with a preliminary chapter, numbered zero, that reviews the mathematical tools the rest will need: sets, sequences, functions, relations, graphs, strings and languages, Boolean logic, and the main styles of proof, including proof by construction, by contradiction and by induction. Many readers treat this as optional. It is not. The habits it builds, especially the habit of stating exactly what a proof must show, carry the whole book.

The first part studies machines with limited memory. It starts with the simplest model, the finite automaton, which reads its input once from left to right and has a fixed number of states. It shows what such machines can recognise and, just as importantly, what they cannot. It then adds a stack to obtain a more powerful machine and pairs that machine with a way of generating strings called a context-free grammar. The part is a study in how a single resource, memory, determines power.

The second part removes the limit on memory and introduces the Turing machine, which can read and write on an unbounded tape. It argues that this simple model captures everything that any reasonable notion of algorithm could compute. Then it proves the central negative result of the subject: some well-defined problems cannot be solved by any Turing machine. From one such problem it derives many others, using a technique called reduction, and it ends with more advanced topics on self-reference, logic and information.

The third part asks not whether a problem can be solved but how much it costs. It defines time and space complexity, introduces the classes P and NP, proves that certain problems are the hardest in NP, and studies space-bounded computation. Its final chapters introduce the frontier: hierarchy theorems, the limits of certain proof techniques, approximation, randomness, interactive proofs, parallel computation and cryptography.

The argument across the three parts is cumulative. Each part reuses the methods of the one before. Diagonalisation, first met as a set-theoretic trick, proves undecidability in the second part and hierarchy theorems in the third. Reductions, introduced to spread undecidability, become the tool that defines NP-completeness. The machines of the first part reappear as tools for analysing logical theories. By the end the reader sees one subject with one set of methods, not three topics bound together.

A word on the book's form. Each chapter states definitions precisely, illustrates them with examples, and then states and proves theorems. Each major proof is preceded by its proof idea. The exercises at the end of each chapter are divided into exercises, which check understanding, and problems, which demand real thought; some are marked as harder, and selected solutions are given. Working the problems is the main way the subject is learned.

How the book teaches

Before turning to the ideas, it is worth looking at the teaching method, because it is a large part of why the book is read. Mathematical texts often present a theorem and then a proof, and leave the reader to discover the strategy by working backwards through the details. Sipser reverses this. Before each important proof he states, in plain language, the plan of attack: what will be constructed, why it should work, and where the difficulty lies. Only then does the formal proof follow.

The effect is like being shown a map before a walk through unfamiliar country. The walk is no shorter, but the walker knows at each turning why the path goes that way. Students report that they can often reconstruct a proof from its idea alone, which is the surest sign that they have understood it rather than memorised it.

A second feature is restraint in notation. The book introduces formal definitions carefully, as tuples of sets and functions, but once a definition is clear it shifts to descriptions in words and diagrams. State diagrams of automata appear throughout. Turing machines, after the first examples, are described as algorithms in numbered stages. This keeps the page readable without losing precision, because the reader has seen how the words could be turned back into formal objects.

A third feature is the choice of examples. Each new concept is illustrated by a few small, carefully chosen cases, often the smallest case that shows the point. A language with two symbols, a machine with three states, a graph with five vertices. Small examples can be held in the mind entire, and they make the general statement concrete without burying it.

Finally, the book is short for its subject. It covers in a few hundred pages what older texts covered at much greater length, by choosing what to leave out. The result is a book that a student can actually finish in one term, and finishing matters: the three parts illuminate one another only when they are read together.

These choices carry a lesson for any reader who explains difficult things to others. State the plan before the steps. Use the smallest example that shows the point. Keep formal machinery available but do not drown the reader in it. And decide what to leave out. Much of the book's influence comes from these habits as much as from its content.

Idea one: computation as a mathematical object

The first idea, quiet but foundational, is that computation can be studied mathematically at all. A computer is a physical device of enormous complexity. To prove anything about what computers can do, we need a model simple enough to reason about and rich enough to capture what matters. The book uses several such models, each defined in a few lines of mathematics.

The trick that makes this possible is to recast every problem as a question about strings. A string is a finite sequence of symbols from some alphabet. A language is a set of strings. A problem such as deciding whether a number is prime becomes the question of whether a given string, the number written in binary, belongs to the language of all strings that encode primes. A machine solves the problem if it accepts exactly the strings in that language.

This may look like a narrowing. It is actually a widening. Graphs, programs, logical formulas and chess positions can all be written down as strings. So a theory of languages is a theory of every problem with a yes or no answer, and with a little extra work, of problems with other kinds of answers too. Once the reader accepts this translation, the rest of the book becomes possible.

An analogy: a geographer can study real landscapes only through maps. A good map leaves out most of what is there, the colour of each stone and the smell of the air, but keeps what matters for the question being asked. The models in this book are maps of computation. Each keeps one feature, such as the amount of memory, and lets the reader see exactly what that feature controls.

This idea is often confused with the belief that the theory concerns only toy machines with no practical relevance. In fact the models are chosen because they are equivalent in power to real computers for the questions being asked. A Turing machine is slow and awkward, but anything a laptop can compute, a Turing machine can compute too. That equivalence is what lets results about simple models apply to real ones.

Idea two: finite automata and the power of a fixed memory

A finite automaton is a machine with a fixed number of states. It reads its input one symbol at a time, moves from state to state according to a table, and at the end either accepts or rejects. It cannot go back, and it cannot write anything down. All it remembers is which state it is in.

A simple example of our own: a machine to check whether a string of coins contains an even number of heads. It needs only two states, one for even so far and one for odd so far, and it flips between them each time it reads a head. It does not need to count the heads, only to remember the parity. Turnstiles, vending machines, traffic lights and the pattern-matching part of a text editor are all finite automata in this sense.

The languages that finite automata can recognise are called regular. The book shows that they can be described in three equivalent ways: by deterministic finite automata, by nondeterministic finite automata, and by regular expressions, the compact patterns used in programming tools to search text. Proving these equivalences is the main work of the first chapter. Each translation is a construction: given one description, the proof builds the other.

Equally important are the limits. A finite automaton cannot recognise the language of strings with some number of a's followed by the same number of b's, because to do so it would need to count without bound, and it has only finitely many states. The book proves results like this with a tool called the pumping lemma, which says that any sufficiently long string in a regular language contains a section that can be repeated any number of times without leaving the language. If a language lacks this property, it is not regular.

The lesson reaches beyond automata. Any system with a fixed amount of memory, however large, can distinguish only finitely many situations. If a task requires telling apart unboundedly many cases, such a system cannot do it. This is a clean example of the kind of result the whole book aims at: a precise statement of what a resource can and cannot buy.

Readers sometimes confuse finite automata with weak or useless machines. They are neither. Finite automata are fast, cheap and easy to analyse, which is why they appear inside compilers, network equipment and hardware controllers. Their limits are exactly what make them predictable.

Idea three: nondeterminism as a way of thinking

A deterministic machine has exactly one move at each step. A nondeterministic machine may have several, and it accepts if any sequence of choices leads to acceptance. This is not a description of a real device. It is a way of describing a computation by what it must find rather than how it searches for it.

For finite automata, nondeterminism adds convenience but not power. Any nondeterministic finite automaton can be converted into a deterministic one that recognises the same language, by a construction in which each state of the new machine stands for a set of states of the old one. The price is size: the deterministic machine may need exponentially more states. The book presents this subset construction carefully, and it is one of the first places a student sees that two models can be equal in power while very different in cost.

An image helps. Imagine searching a maze. A deterministic searcher must try paths one at a time and backtrack. A nondeterministic searcher is allowed to guess the right turn at every junction. If any path leads out, the guesser finds it in the length of that path. Nondeterminism is a lucky guesser, and the question of how much its luck is worth runs through the whole book.

For Turing machines, nondeterminism again adds no power over what can be computed at all, since a deterministic machine can try every sequence of choices in turn. But it may add enormous power over what can be computed quickly. Whether it does is the P versus NP question. So an idea introduced early as a convenience for building automata becomes, by the third part, the centre of the deepest open problem in the subject.

Nondeterminism is often confused with randomness. They are different. A random machine flips coins and must succeed with high probability over the flips. A nondeterministic machine is required only to have at least one successful path, however rare. The book treats randomness separately, in its advanced complexity chapter, and the relationship between the two is itself a research subject.

Idea four: grammars, stacks and the structure of language

To go beyond regular languages, the book adds memory in a specific form: a stack, on which a machine can push symbols and from which it can pop the most recent one. A finite automaton with a stack is called a pushdown automaton. It can recognise matched brackets, or a's followed by the same number of b's, by pushing a symbol for each a and popping one for each b.

Paired with pushdown automata are context-free grammars. A grammar is a set of rules for producing strings by repeatedly replacing a symbol with a sequence of symbols. Context-free means that each rule replaces a single symbol regardless of what surrounds it. Grammars of this kind were introduced by the linguist Noam Chomsky in the 1950s to describe the structure of sentences, and they were soon adopted to describe the syntax of programming languages. The book proves that context-free grammars and pushdown automata describe exactly the same class of languages.

A concrete case: the rules of arithmetic expressions. An expression can be a number, or two expressions joined by a plus sign, or an expression in brackets. Those three rules generate every well-formed expression, nested to any depth, and the derivation of a string from the rules reveals its structure, which operation applies to which parts. This is what a compiler does when it parses a program: it finds the derivation and builds a tree from it.

Context-free languages have their own limits, proved by their own pumping lemma. A pushdown automaton cannot recognise strings with equal numbers of a's, b's and c's in order, because its single stack can match one pair of counts but not two. The book also discusses ambiguity, when a grammar can derive the same string in two different ways, which matters greatly in programming languages, where a statement must mean exactly one thing. The third edition adds a section on deterministic context-free languages, the subclass that can be parsed efficiently by the methods compilers actually use.

This part of the book is often confused with linguistics or with compiler construction. It touches both but is neither. Its interest is in the general question of how the form of memory available to a machine shapes the patterns it can recognise. A finite memory gives regular languages; a single stack gives context-free languages; an unbounded tape, as the next part shows, gives everything that can be computed.

Idea five: the Turing machine and the Church-Turing thesis

The Turing machine, described by Alan Turing in 1936, is a finite control attached to an unbounded tape divided into cells. At each step the machine reads the symbol under its head, writes a symbol, moves one cell left or right, and changes state. That is all. Yet this machine can carry out any computation that a modern computer can, given enough time and tape.

The book makes this claim plausible in two ways. First, it shows that many variations of the model have the same power: machines with several tapes, machines that can stay in place, nondeterministic machines, and machines that enumerate strings rather than test them. Each variation can be simulated by the basic machine, sometimes at a cost in time but never at a cost in what can be computed. This robustness suggests that the model has captured something natural rather than arbitrary.

Second, the book presents the Church-Turing thesis, the claim that the informal notion of an algorithm, a step-by-step procedure that could in principle be carried out mechanically, coincides exactly with what Turing machines can do. The thesis is named for Alonzo Church, who proposed an equivalent model, the lambda calculus, in the same period, and for Turing. It cannot be proved, because one side of it is informal. But every proposed model of computation since 1936, from register machines to modern programming languages, has turned out to be equivalent, and the thesis is accepted throughout the field.

Sipser uses the thesis to justify an important shift in style. After the first chapter on Turing machines, he describes algorithms at a high level, in ordinary language, rather than by listing states and transitions. The thesis assures the reader that any such description could be turned into a real Turing machine. This makes the rest of the book readable. It also teaches the reader when a high-level description is precise enough and when more detail is needed.

An analogy: the thesis is like the claim that any recipe a cook can follow could be written down in a fixed, small set of kitchen instructions. One cannot prove this about every possible recipe, but after many years of trying, no one has found a recipe that resists. The book also uses the thesis to make a historical point about Hilbert's tenth problem, the question posed in 1900 of whether there is a method to decide if a polynomial equation has whole-number solutions. Only with a precise definition of algorithm could the answer, which turned out to be no, even be stated.

The thesis is often confused with a claim about the physical world or the mind. Some writers extend it to say that any physical process, or any human thought, can be simulated by a Turing machine. That is a stronger and much more contested claim, discussed in this bay by Penrose in The Emperor's New Mind and by Hofstadter in Gödel, Escher, Bach. The book's version is modest: it concerns what can be computed by an effective procedure.

Idea six: undecidability and the method of diagonalisation

The central result of the second part is that some problems cannot be solved by any algorithm. The book distinguishes two kinds of machine behaviour. A machine decides a language if it always halts, accepting strings in the language and rejecting the rest. A machine recognises a language if it accepts every string in the language, but on other strings it may either reject or run forever. A language is decidable if some machine decides it.

The book shows that the problem of determining whether a given Turing machine accepts a given input is undecidable. A closely related problem, whether a given machine halts on a given input, is the famous halting problem. No program, however clever, can examine every program and correctly predict whether it will finish.

The proof rests on diagonalisation, a technique Georg Cantor used in the nineteenth century to show that the real numbers cannot be listed one by one. The book first presents Cantor's argument on its own, then adapts it. In outline, one supposes that a decider for the problem exists, uses it to build a new machine that does the opposite of whatever the decider predicts about that machine when it is given its own description, and derives a contradiction. The self-reference is the engine of the proof. Sipser's proof idea makes the logic clear before the formal steps.

A homely image of the same structure: imagine a librarian who must compile a catalogue listing every catalogue that does not list itself. Whether the new catalogue lists itself or not, either answer contradicts the rule. The halting proof has the same shape, except that the catalogues are programs and the rule is a supposed decider.

The book also shows that the acceptance problem is recognisable, since a machine can simply run the given machine and accept if it accepts, but that its complement is not even recognisable. A language is decidable exactly when both it and its complement are recognisable. This gives a clean map of the territory: decidable problems, recognisable but undecidable problems, and problems that are not even recognisable.

Undecidability is often misunderstood as a statement about current technology, as though a faster computer or a cleverer programmer might eventually succeed. It is not. It is a mathematical fact about all possible algorithms. It is also often misunderstood as saying that no particular program can be analysed. Many programs can be shown to halt. What cannot exist is a single method that works for every program.

Idea seven: reductions

Having found one undecidable problem, the book shows how to find many more. The tool is reduction. To reduce problem A to problem B is to show that a method for solving B could be used to solve A. If A is known to be unsolvable, then B must be unsolvable too, for otherwise A could be solved through it.

With reductions, undecidability spreads quickly. The book shows that it is undecidable whether a Turing machine accepts any string at all, whether two machines accept the same language, and whether a machine's language is regular. A general result often taught alongside, known as Rice's theorem and given in the book as a problem, says that every nontrivial question about the language a program recognises is undecidable. The book also presents the Post correspondence problem, a puzzle about matching dominoes with strings on them, which turns out to be undecidable and serves as a bridge to undecidable problems in other areas, such as questions about grammars.

The book distinguishes several kinds of reduction. A mapping reduction transforms each instance of one problem into an instance of another so that yes answers correspond to yes answers. A Turing reduction allows the solver for one problem to be used as an oracle, consulted many times. The distinctions matter because they control what conclusions can be drawn, and because the efficient version of mapping reduction becomes the central tool of the third part.

An everyday analogy: if you know that a certain lock cannot be picked, and you can show that any tool that opens a second lock could be adapted to open the first, then you know the second lock cannot be picked either. The direction matters. Students often reverse it, reducing the new problem to the known hard one, which proves nothing. The book's exercises drill the correct direction until it is automatic.

Reductions are the single most important technique in the theory of computation. They organise problems into families of equal difficulty and let results about one problem transfer to thousands of others. A reader who masters them has the key to the rest of the book and to much of the research literature.

Idea eight: measuring cost with time complexity and the class P

The third part asks a new question. Among the problems that can be solved, it asks which can be solved efficiently. To answer it, the book measures the running time of a Turing machine as a function of the length of its input, and uses asymptotic notation to ignore constant factors and small inputs. What matters is how the time grows: linearly, quadratically, exponentially.

The class P consists of the problems that a deterministic Turing machine can solve in polynomial time, that is, in time bounded by some fixed power of the input length. The book argues that P is the right mathematical stand-in for the problems that are practically solvable. The argument has two parts. Polynomial time is robust: changing from one reasonable model of computation to another changes running time by at most a polynomial factor, so the class does not depend on details of the model. And the gap between polynomial and exponential growth is enormous: an exponential algorithm becomes useless on modest inputs, however fast the computer.

A concrete comparison of our own: an algorithm whose steps grow as the square of the input size takes a million steps for an input of a thousand, which is nothing for a modern machine. An algorithm whose steps double with each added element takes more steps for an input of a hundred than there are atoms in the observable universe by a wide margin. No improvement in hardware closes a gap of that kind.

The book gives examples of problems in P, such as finding a path between two points in a graph, determining whether two numbers are relatively prime, and recognising every context-free language. The last example connects the third part to the first, showing that the languages of the earlier chapters are not only decidable but efficiently decidable.

P is often confused with the set of problems that are fast in practice. The two are close but not identical. An algorithm whose time grows as the hundredth power of the input is in P but useless, and some exponential algorithms run well on the inputs that arise in practice. The book is honest about this. P is a mathematical idealisation, valuable because it is robust and because its boundary usually matches practical experience.

Idea nine: NP, verification and the great open question

The class NP consists of the problems whose yes answers can be checked quickly when a suitable certificate is supplied. Consider the problem of whether a map can be coloured with three colours so that neighbouring countries differ. Finding such a colouring may take a long search. But if someone hands you a colouring, you can check it quickly by looking at each border. The colouring is the certificate. NP is the class of problems with short, quickly checkable certificates.

The book gives two equivalent definitions. One uses verifiers: a problem is in NP if a polynomial-time machine can check a certificate. The other uses nondeterminism: a problem is in NP if a nondeterministic machine can solve it in polynomial time, by guessing the certificate and then checking it. The equivalence shows that the lucky guesser of the earlier chapters is exactly as strong as a quick checker with a good hint.

Every problem in P is in NP, since a problem that can be solved quickly can certainly be checked quickly. The question is whether the converse holds: whether every problem whose answers can be checked quickly can also be solved quickly. This is the P versus NP question. Most researchers believe the answer is no, that finding is genuinely harder than checking, but no one has proved it. It is one of the Millennium Prize Problems announced by the Clay Mathematics Institute in 2000.

The question matters far beyond theory. Many practical problems, from scheduling and routing to circuit design and protein folding, are in NP. If P equalled NP, all of them would have efficient algorithms. Much of modern cryptography assumes that certain problems are hard to solve even though their solutions are easy to check; if P equalled NP, those assumptions would fail. The question is also philosophical. It asks whether creative discovery is fundamentally harder than recognising a correct discovery, whether finding a proof is harder than checking one.

The book also explains why the question has resisted solution. A natural first attempt is diagonalisation, the method that separated decidable from undecidable problems. But diagonalisation arguments keep working when every machine is given access to the same oracle, a black box that answers some fixed problem instantly. It is known that there are oracles relative to which P equals NP and others relative to which they differ. So any proof that settles the question must use some property of real computation that oracles do not preserve. This barrier, called relativisation and presented in the advanced chapter, explains in a precise way why the problem is hard to attack, and it is one of the most instructive results in the book.

Many attempts to settle the question are announced each year, and nearly all contain simple errors. A reader who has worked through this chapter is well placed to judge such claims. A real resolution would have to overcome known barriers, including relativisation, and would almost certainly bring with it new techniques of wide use. Claims that ignore these barriers can usually be set aside with confidence.

NP is commonly misread as standing for non-polynomial. It stands for nondeterministic polynomial time. Problems in NP are not known to require more than polynomial time; that is precisely what is unknown. Another frequent confusion is to think that NP contains only hard problems. It contains all of P as well.

Idea ten: NP-completeness

Among the problems in NP, some are the hardest, in a precise sense. A problem is NP-complete if it is in NP and every problem in NP can be reduced to it by a polynomial-time reduction. If any NP-complete problem could be solved in polynomial time, every problem in NP could, and P would equal NP.

The foundation is the Cook-Levin theorem, proved independently by Stephen Cook in 1971 and Leonid Levin in the Soviet Union around the same time. It shows that the satisfiability problem for Boolean formulas, the question of whether some assignment of true and false to the variables makes the formula true, is NP-complete. The proof is a construction: given any nondeterministic machine and input, it builds a formula that describes a successful computation, cell by cell and step by step, so that the formula is satisfiable exactly when the machine accepts. The book's proof idea makes this construction feel natural, which is a considerable achievement.

Once one NP-complete problem is known, others follow by reduction, just as undecidable problems followed from the first undecidable one. The book proves NP-completeness for a selection of problems, including a restricted form of satisfiability, finding a large clique in a graph, covering a graph's edges with few vertices, finding a path through every vertex, and choosing numbers that add up to a target. Richard Karp showed in 1972 that many such problems are NP-complete, and thousands more have been found since.

The practical meaning is important. When an engineer finds that a problem is NP-complete, it is strong evidence that no efficient exact algorithm exists, and that effort should go into approximation, heuristics, special cases or problem sizes small enough for exhaustive search. Knowing this saves years of fruitless work. The theory does not say the problem is hopeless, only that it is as hard as thousands of problems that the best minds have failed to solve efficiently.

NP-completeness is often confused with undecidability. They are quite different. An NP-complete problem can always be solved, by trying every possible certificate; the difficulty is only that this may take exponential time. An undecidable problem cannot be solved by any method at all. The parallel between the two parts of the book is deliberate, but the conclusions differ in strength.

Idea eleven: space as a resource

Time is not the only resource. The book also studies space, the amount of tape a machine uses. Space behaves differently from time, because space can be reused while time cannot. A machine that uses only a little memory may still run for a very long time.

The book presents Savitch's theorem, which shows that nondeterminism buys much less in space than it may in time: anything a nondeterministic machine can do in a given amount of space, a deterministic machine can do in roughly the square of that space. So for polynomial space, nondeterminism adds nothing, and the class PSPACE is the same whether defined with or without it. The book identifies PSPACE-complete problems, which include determining the winner in certain games with perfect information played on generalised boards. The connection is natural: deciding a game requires exploring alternating moves of two players, and polynomial space is exactly enough to do that by depth-first search.

The book also studies very small space, logarithmic in the input length, which is enough to hold a few pointers into the input but not to copy it. The classes L and NL capture deterministic and nondeterministic computation in this space. Finding a path in a directed graph is complete for NL. A striking theorem, proved independently by Neil Immerman and Robert Szelepcsenyi in the late 1980s, shows that NL is closed under complement, so that the nondeterministic machine can certify that there is no path as easily as that there is one. The book presents this result, which surprised many experts when it appeared.

The picture that emerges is a chain of classes: L inside NL inside P inside NP inside PSPACE. Each is known to be contained in the next. Very few of the containments are known to be strict. This is a humbling feature of the subject, and the book does not hide it. The theory has organised problems precisely by difficulty while leaving most of the boundaries between levels unproved.

Idea twelve: the frontier

The final chapters of each part, labelled advanced topics, point toward current research. In computability, the book presents the recursion theorem, which shows that a machine can obtain and use its own description, a precise form of self-reference with consequences for computer viruses and for logic. It discusses the decidability of logical theories, showing that some theories of arithmetic are decidable and others, by an argument connected to Gödel's incompleteness theorem, are not. It introduces Kolmogorov complexity, a measure of how much information a string contains, defined as the length of the shortest description that produces it.

In complexity, the advanced topics include the hierarchy theorems, which show by diagonalisation that more time or space allows more problems to be solved; relativisation, which explains why diagonalisation alone cannot settle P versus NP; circuit complexity; approximation algorithms; probabilistic computation and the class BPP; alternation; interactive proof systems, in which a powerful prover convinces a limited verifier; parallel computation; and the complexity foundations of cryptography. Each is treated briefly but carefully, enough to show the reader where the subject goes next.

Interactive proofs deserve a note because they change the idea of what a proof is. A verifier who may ask random questions and accept a small chance of error can be convinced of facts that seem far beyond its ability to check. The theorem that the class of problems with interactive proofs equals PSPACE, proved around 1990, is one of the most surprising results in the field, and the book presents it at the level an introduction can bear.

These sections are not meant to be mastered on a first reading. They are windows. Their value is to show that the clean classes of the earlier chapters are the beginning of a living subject with deep connections to logic, information, cryptography and the nature of proof.

Why the limits matter in practice

A reader may finish the book convinced of its theorems and still wonder what they change in daily work. The answer is that they change which problems one attempts and how. A programmer asked to write a tool that detects every infinite loop in any program now knows that no such tool can exist. What can exist is a tool that detects many loops, accepts some false alarms or misses, and is honest about which. Static analysers, type checkers and verification systems are all designed this way, as careful approximations to undecidable questions.

The same holds for efficiency. An engineer who recognises that a scheduling or packing problem is NP-complete stops searching for a fast exact method and turns to the tools that work: exact search for small instances, solvers that exploit the structure of typical inputs, approximation algorithms with proven guarantees, or heuristics tested on real data. Recognising hardness early is a skill, and it rests on knowing a stock of hard problems and how reductions connect them.

Hardness is also a resource. Modern cryptography depends on problems believed to be easy in one direction and hard in the other, such as multiplying two large primes compared with factoring their product. The theory in the third part of the book provides the language in which such beliefs are stated and their consequences analysed. Without it, the security of online payments and private messages would rest on nothing more than hope.

Finally, the first part of the book is used every day in tools most programmers take for granted. Search patterns in text editors, the tokenisers in compilers, the validators for input formats, and the protocol checkers in network equipment are finite automata or close relatives. Parsers for programming languages, data formats and configuration files are built from context-free grammars. Knowing the theory lets a programmer see why some patterns cannot be matched by regular expressions, and why some grammars are easy to parse while others are not.

In short, the theory gives practical people a sense of where the walls are. Work that runs into a wall cannot succeed by effort alone. Work that knows where the walls are can be directed to the open ground beside them.

The tradition around it

The theory this book presents was built in two waves. The first, in the 1930s, answered Hilbert's question about whether mathematics could be mechanised. Kurt Gödel, Alonzo Church, Alan Turing and Emil Post, among others, defined computation and proved its limits. Their founding papers are collected in The Undecidable, edited by Martin Davis, which sits in this bay. A reader who wants to see the original arguments behind the second part of this book can find them there. Alan Turing: The Enigma by Andrew Hodges tells the life behind the most famous of those papers.

The second wave, from the 1950s to the 1970s, added automata, grammars and complexity. Automata theory grew from work by Warren McCulloch and Walter Pitts on neural nets, by Stephen Kleene on regular events, and by Michael Rabin and Dana Scott on finite automata and nondeterminism. Chomsky's work on grammars connected the subject to linguistics. Complexity theory grew from work by Juris Hartmanis and Richard Stearns on time-bounded computation and was given its central question by Cook, Levin and Karp. Computation: Finite and Infinite Machines by Marvin Minsky, also in this bay, is a classic introduction from the end of the first part of this second wave.

Introduction to Automata Theory, Languages, and Computation by Hopcroft and Ullman was the standard textbook for a generation before Sipser and covers much of the same ground in more detail, especially on automata and grammars. Sipser's book can be read as a leaner, clearer successor; the older book remains valuable as a reference. Computers and Intractability by Garey and Johnson is the classic guide to NP-completeness, with its long catalogue of problems; after Sipser's chapter on the subject, it is the natural next step for anyone who must recognise hard problems in practice.

Other books in the bay take the ideas in different directions. Gödel, Escher, Bach by Hofstadter explores self-reference, the engine of the undecidability proofs, through art, music and logic. The Emperor's New Mind by Penrose argues from Gödel and Turing that human understanding is not algorithmic, a claim this book does not address but helps the reader to evaluate. Introduction to Algorithms by Cormen, Leiserson and Rivest is the practical companion: it designs and analyses the efficient algorithms whose existence the complexity chapters classify. Quantum Computation and Quantum Information by Nielsen and Chuang extends the theory to machines governed by quantum mechanics, which do not compute anything uncomputable but may compute some things faster.

Compilers: Principles, Techniques, and Tools by Aho, Sethi and Ullman shows the first part of this book at work: lexical analysis uses finite automata and regular expressions, and parsing uses context-free grammars. Structure and Interpretation of Computer Programs offers a different route into the idea of a universal machine, through an interpreter that evaluates programs written in the language it is written in.

Questions and criticisms

The most frequent criticism is that the book is too lean. It chooses a limited set of results and omits much that other texts include, such as the minimisation of finite automata, many closure properties, and detailed treatments of parsing. Instructors who want full coverage sometimes supplement it. For a first course, most readers find the selection a virtue: it leaves room to understand each result fully.

A second criticism concerns the proof ideas and high-level descriptions. Some readers feel that describing Turing machines in ordinary language, after the first chapter, lets students skip the hard work of seeing how a machine really carries out a task. Sipser addresses this by giving detailed constructions early and by explaining when high-level descriptions are acceptable. The criticism is worth taking seriously as a reader: it is good practice to turn at least a few high-level descriptions into explicit machines oneself.

A third point concerns the relationship between the theory and practice. The worst-case, asymptotic view of complexity does not always predict which algorithms work well. Some problems that are NP-complete in general are routinely solved for large real instances by modern satisfiability solvers, and the simplex method for linear programming, exponential in the worst case, is fast in practice. Later research on average-case and smoothed analysis, and on parameterised complexity, refines the picture. The book's framework is the starting point for these refinements, not a rival to them.

Some readers find the order of the parts debatable. Starting with automata gives a gentle introduction but delays the most important ideas. Some courses begin with computability or with complexity instead, and the book's structure allows this to an extent. The order Sipser chose follows the growth of memory from finite to unbounded, which gives the first two parts a clear logic.

What has held up is almost everything. The theorems are permanent; mathematics does not age. The main open problems, P versus NP among them, remain open as of the last edition, and the book's presentation of them is still current. The prose and the proof ideas have set a standard for how mathematical computer science is taught, and many later texts and lectures imitate them.

Why it is on this shelf

This shelf brings together Vedanta, Jyotish, science, economics and technology, and asks of each book that it change how a reader sees. This book does. It shows, with complete rigour, that there are questions with definite answers that no mechanical procedure can find, and that among answerable questions, some may be inherently and enormously harder than others. These are facts about the structure of knowledge, not about machines alone.

For the reader of Vedanta, the undecidability results offer a precise, modern instance of an old theme: that a system cannot fully grasp itself from within, and that self-reference produces limits that more effort cannot remove. We do not claim the two are the same, only that each sharpens the other. For the reader of Jyotish, which rests on careful calculation, the book clarifies what calculation is and what makes a calculation feasible. For the economist, the theory of complexity bears on markets and planning, since some optimisation problems that an ideal planner or agent would have to solve are intractable. For the technologist, the book explains why some problems will not yield to more hardware, and why cryptography is possible at all.

There is a further reason in the way the book reasons. Every result in it is either proved or clearly marked as open. Nothing is asserted on authority. A reader who spends a term with it learns to tell the difference between what is known, what is believed, and what is merely hoped, and that habit is useful in every field this shelf covers.

We also keep it because it is the best example we know of hard mathematics made readable without being made easy. It respects its reader. That is a quality we want on every shelf.

How to read it

Start with the preliminary chapter, even if the material looks familiar. Read the section on proofs closely and do several of its exercises. If you have not written proofs before, spend extra time here; the rest of the book is a sequence of proofs.

Then read the first part, on regular and context-free languages, at a steady pace of about a chapter every two weeks. For each construction, such as converting a nondeterministic automaton into a deterministic one, carry it out by hand on a small example. Draw the state diagrams. For each pumping lemma proof, write out the argument in full for at least one new language of your own choosing.

Read the second part with the most care. The chapter on decidability, and the diagonalisation argument in particular, deserves several readings. Read the proof idea, close the book, try to reconstruct the proof, then compare. Do the same with the first few reductions in the following chapter. Once the method of reduction is secure, the rest of the book becomes far easier.

In the third part, read the chapters on time complexity and NP-completeness slowly and work the Cook-Levin construction through on a tiny machine if you can. Then read the space complexity chapter. On a first pass, skip the advanced-topics chapters at the end of the second and third parts, or read only their introductions. Return to them when the core is firm; the recursion theorem and interactive proofs are especially rewarding.

Throughout, work the exercises before the problems, and attempt problems seriously before looking at any solution. Keep a notebook of definitions; many difficulties in this subject come from a slightly wrong memory of a definition. Allow a full semester for the core, which is what the book was designed for.

From this shelf, read Garey and Johnson's Computers and Intractability after the NP-completeness chapter, and the papers in The Undecidable after the second part, for the original sources. Read Introduction to Algorithms alongside the third part to see efficient algorithms in detail. Read Hodges's biography of Turing for the human story, and Hofstadter's Gödel, Escher, Bach for a long, playful meditation on self-reference.

Questions to carry

  • Why is it useful to treat every problem as a question about membership in a language?
  • What exactly does a finite memory prevent a machine from doing, and how would you prove it for a new example?
  • How can two models be equal in power and very unequal in size or speed?
  • What would it take to refute the Church-Turing thesis, and what would count as evidence?
  • Where does self-reference appear in the proof that the halting problem is undecidable?
  • In which direction must a reduction go to prove that a new problem is hard, and why?
  • Why is polynomial time a good mathematical stand-in for practical solvability, and where does it fail?
  • Is finding a solution genuinely harder than checking one, and what would change if it were not?
  • When you meet an NP-complete problem in practice, what are your options?
  • Why does space behave differently from time as a resource?
  • How can a verifier with limited power be convinced of something it cannot check alone?
  • Which boundaries between complexity classes are proved, and which are only believed?
  • How does the theory of computation bear on claims that the mind is or is not a machine?

Words to know

  • Alphabet: A finite set of symbols from which strings are formed.
  • String: A finite sequence of symbols from an alphabet.
  • Language: A set of strings; every yes-or-no problem can be expressed as a language.
  • Finite automaton: A machine with finitely many states that reads its input once and accepts or rejects.
  • Regular language: A language recognised by some finite automaton, or described by a regular expression.
  • Regular expression: A compact pattern built from symbols with union, concatenation and repetition.
  • Nondeterminism: A mode of computation in which a machine may have several possible moves and accepts if any sequence of choices leads to acceptance.
  • Pumping lemma: A property of all sufficiently long strings in a regular or context-free language, used to prove that a language is not in that class.
  • Context-free grammar: A set of rules that generate strings by replacing single symbols with sequences, used for programming language syntax.
  • Pushdown automaton: A finite automaton with a stack, equivalent in power to context-free grammars.
  • Turing machine: A finite control with an unbounded read-write tape; the standard model of general computation.
  • Church-Turing thesis: The principle that the informal notion of algorithm coincides with what Turing machines can compute.
  • Decidable: Describes a language for which some Turing machine always halts with the correct yes or no answer.
  • Recognisable: Describes a language for which some Turing machine accepts exactly its members, possibly running forever on others.
  • Halting problem: The problem of determining whether a given program halts on a given input; undecidable.
  • Diagonalisation: A proof technique, from Cantor, that builds an object differing from every item on a supposed complete list.
  • Reduction: A transformation showing that a solution to one problem would give a solution to another.
  • P: The class of problems solvable by a deterministic machine in polynomial time.
  • NP: The class of problems whose yes answers can be verified in polynomial time given a certificate; equivalently, solvable in polynomial time by a nondeterministic machine.
  • NP-complete: A problem in NP to which every problem in NP reduces in polynomial time.
  • Satisfiability: The problem of whether some assignment of true and false values makes a Boolean formula true; the first problem proved NP-complete.
  • PSPACE: The class of problems solvable using a polynomial amount of memory.
  • Savitch's theorem: The result that nondeterministic space can be simulated deterministically with at most a squaring of space.
  • Kolmogorov complexity: The length of the shortest description that produces a given string.

A note on this edition

This is a study edition written for this shelf in our own words. It describes and explains Introduction to the Theory of Computation by Michael Sipser, but it does not reproduce the book's text, proofs, figures or exercises. The book itself is in copyright and has gone through several editions; it is worth getting from a library or bookshop and reading with a pencil, working the problems as you go. Any errors in this companion are ours, not the author's.

Terms from this book with their own page: Church-Turing thesis, Halting problem, Turing machine

More from “Foundations of computing”

The whole section →