Theory of Computation
Total Page:16
File Type:pdf, Size:1020Kb
Theory of Computation Lectures delivered by Michael Sipser Notes by Holden Lee Fall 2012, MIT Last updated Tue. 12/11/2012 Contents Lecture 1 Thu. 9/6/12 x1 Overview 5 x2 Finite Automata 6 x3 Formalization 7 Lecture 2 Tue. 9/11/12 x1 Regular expressions 12 x2 Nondeterminism 13 x3 Using nondeterminism to show closure 17 x4 Converting a finite automaton into a regular expression 20 Lecture 3 Thu. 9/13/12 x1 Converting a DFA to a regular expression 22 x2 Non-regular languages 25 Lecture 4 Tue. 9/18/12 x1 Context-Free Grammars 30 x2 Pushdown automata 33 x3 Comparing pushdown and finite automata 33 Lecture 5 Thu. 9/20/12 x1 CFG's and PDA's recognize the same language 37 x2 Converting CFG PDA 38 x3 Non-CFLs 39 x4 Turing machines 42 ! Lecture 6 Tue. 9/25/12 x1 Turing machines 44 x2 Philosophy: Church-Turing Thesis 50 Lecture 7 Thu. 9/27/12 x1 Examples of decidable problems: problems on FA's 52 x2 Problems on grammars 56 1 Lecture 8 Tue. 10/2/12 x1 Languages 58 x2 Diagonalization 59 x3 ATM : Turing-recognizable but not decidable 63 x4 Showing a specific language is not recognizable 65 Lecture 9 Thu. 10/4/12 x1 Reducibility 67 x2 Mapping reducibility 69 Lecture 10 Thu. 10/11/12 x1 Post Correspondence Problem 72 x2 Computation Histories and Linearly Bounded Automata 73 x3 Proof of undecidability of PCP 76 Lecture 11 Tue. 10/16/12 x1 Computation history method 77 x2 Recursion theorem 79 x3 Logic 83 Lecture 12 Thu. 10/18/12 x1 Introduction to complexity theory 84 x2 Time Complexity: formal definition 87 Lecture 13 Tue. 10/23/12 Lecture 14 Tue. 10/30/12 x1 P vs. NP 91 x2 Polynomial reducibility 92 x3 NP completeness 95 Lecture 15 Thu. 11/1/12 x1 Cook-Levin Theorem 101 x2 Subset sum problem 105 Lecture 16 Tue. 11/6/12 x1 Space complexity 108 x2 Savitch's Theorem 112 Lecture 17 Thu. 11/8/12 x1 Savitch's Theorem 114 x2 PSPACE{completeness 116 Lecture 18 Thu. 10/11/12 x1 Games: Generalized Geography 120 x2 Log space 124 x3 L; NL P 126 ⊆ Lecture 19 Thu. 11/15/12 x1 L vs. NL 129 x2 NL-completeness 130 x3 NL=coNL 132 Lecture 20 Tue. 11/20/12 x1 Space hierarchy 134 x2 Time Hierarchy Theorem 137 Lecture 21 Tue. 11/27/12 x1 Intractable problems 138 x2 Oracles 142 Lecture 22 Thu. 11/29/12 x1 Primality testing 144 x2 Probabilistic Turing Machines 145 x3 Branching programs 147 Lecture 23 Thu. 10/11/12 x1 EQROBP 150 Lecture 24 Thu. 12/6/12 x1 Interactive proofs 155 x2 IP=PSPACE 158 Lecture 25 Tue. 12/11/2012 x1 coNP IP 161 x2 A summary of complexity classes 164 ⊆ Introduction Michael Sipser taught a course (18.404J) on Theory of Computation at MIT in Fall 2012. These are my \live-TEXed" notes from the course. The template is borrowed from Akhil Mathew. Please email corrections to [email protected]. Lecture 1 Notes on Theory of Computation Lecture 1 Thu. 9/6/12 Course information: Michael Sipser teaches the course. Alex Arkhipov and Zack Rumscrim teach the recitations. The website is http://math.mit.edu/~sipser/18404. The 3rd edition of the textbook has an extra lesson on parsing and deterministic free languages (which we will not cover), and some additional problems. The 2nd edition is okay. x1 Overview 1.1 Computability theory In the first part of the course we will cover computability theory: what kinds of things can you solve with a computer and what kinds of things can you not solve with a computer? Computers are so powerful that you may think they can do anything. That's false. For example, consider the question Does a given program meet a given specification? Is it possible to build a computer that will answer this question, when you feed it any program and any specification? No; this problem is uncomputable, impossible to solve with a computer. Is it possible to build a computer so that when I feed it math statements (for instance, Fermat's last theorem or the twin primes conjecture), it will output true or false? Again, no. No algorithm can tell whether a math statement is true or fals, not even in principle (given sufficiently long time and large space). We'll have to introduce a formal model of computation|what do we mean by a computer?| to talk about the subject in a mathematical way. There aer several different models for computation. We'll talk about the simplest of these—finite automata|today. Computability theory had its hayday 1930 to 1950's; it is pretty much finished as a field of research. 1.2 Complexity theory By contrast, the second half of the course focuses on complexity theory. This picks up where computability left off, from 1960's to the present. It is still a major area of research, and focuses not on whether we can solve a problem using a computer, but how hard is it to solve? The classical example is factoring. You can easily multiply 2 large numbers (ex. 500- digit numbers) quickly on a laptop. No one knows how or if you can do the opposite|factor a large number (ex. 1000-digit number)|easily. The state of the art is 200 digits right now. 250 digits and up is way beyond what we can do in general. We'll define different ways of measuring hardness: time and space (memory). We'lllook at models that are specific to complexity theory, such as probabilistic models and interactive 5 Lecture 1 Notes on Theory of Computation proof systems. A famous unsolved problem is the P vs. NP problem, which will be a theme throughout our lessons on complexity. In these problems, some kind of \searching" is inevitable. 1.3 Why theory? What is value of studying computer science theory? People question why a computer science department should invest in theoretical computer science. This used to be a big issue. Firstly, theory has proved its value to other parts of computer science. Many technologists and companies grew up out of the work of theorists, for example, RSA cryptography. Akamai came out of looking at distributed systems from a theoretical point of view. Many key personnel in Google were theorists, because search has a theoretical side to it. Theorists have played a role in building the computer science industry. Second, theory as a part of science. It's not just driven by its applications, but by curiosity. For example, \how hard is factoring?" is a natural question that it is intrinsically worthwhile to answer. Our curiosity is makes us human. Computer science theory may also help us understand the brain in the future. We understand heart and most of our other organs pretty well, but we have only the faintest idea how the brain works. Because the brain has a computation aspect to it, it's entirely possible that some theory of computation will help solve this problem. Is there more stuff to do? Certainly. We're still at the very beginnings of computer science and theory. Whole realms out there are worthy of exploration. That's what and why we do this stuff. x2 Finite Automata 2.1 An example We need to set up our models for computability theory. The first one will be finite automata. An example of a finite automata is given by the following picture. 6 Lecture 1 Notes on Theory of Computation The states are q ; q ; q . The transitions are arrows with 0 or 1, such as 0 . The f 1 2 3g −! start state is q1 (it has a regular arrow leading to it) and the accept states is q3 (it has a double circle). Note each state has 2 arrows exiting it, 0 and 1. f g How does this automaton work when we feed it a string such as 010110? We start at the start state q1. Read in the input symbols one at a time, and follow the transition arrow given by the next bit. 0: take the arrow from q back to q . ∙ 1 1 1: take the arrow from q to q . ∙ 1 2 0: take the arrow back to q . ∙ 1 1: get to q ∙ 2 1: get to q ∙ 3 0: stay at q . ∙ 3 Since q3 is an accept state, the output is \accept." By contrast, the input state 101 ends at q2; the machine does not accept, i.e. it rejects the input. Problem 1.1: What strings does the machine accept? The machine accepts exactly the strings with two consecutive 1's. The language of A, denoted L(A), is the set of accepted strings, i.e. the language that the machine recognizes. (This term comes from linguistics.) We say that the language of A is L(A) = w : w has substring 11 : f g x3 Formalization We now give a formal definition of a finite automaton. Definition 1.1: A finite automaton is a tuple M = (Q; Σ; 훿; q0;F ) where Q is a finite set of states, ∙ Σ is a finite alphabet (collection of symbols, for instance 0; 1 ), ∙ f g 훿 is the transition function that takes a state and input symbol and gives another state ∙ 훿 : Q Σ Q × ! (q; a) r: 7! We denote this with a circle q and an arrow a leading to a circle r. −! 7 Lecture 1 Notes on Theory of Computation q Q is a start state.