BU CS 332 – Theory of Computation Lecture 19: Reading: • More on P Sipser Ch 7.2 ‐ 7.3 • Nondeterministic time, NP Mark Bun April 8, 2020
First topic: Time complexity Last time: Answering the basic questions 1. How do we measure complexity? (as in CS 330) 2. Asymptotic notation (as in CS 330) 3. How robust is the TM model when we care about measuring complexity? 4. How do we mathematically capture our intuitive notion of “efficient algorithms”? 4/8/2020 CS332 ‐ Theory of Computation 2
Running time and time complexity classes Let � , A TM runs in time if on every input halts on within at most steps is a class (i.e., set) of languages: A language if there exists a basic single ‐ tape (deterministic) TM that 1) Decides , and 2) Runs in time 4/8/2020 CS332 ‐ Theory of Computation 3
Complexity Class 4/8/2020 CS332 ‐ Theory of Computation 4
Complexity class Definition: is the class of languages decidable in polynomial time on a basic single ‐ tape (deterministic) TM � � ��� • Class doesn’t change if we substitute in another reasonable deterministic model (Extended Church ‐ Turing) • Cobham ‐ Edmonds Thesis: Captures class of problems that are feasible to solve on computers 4/8/2020 CS332 ‐ Theory of Computation 5
A note about encodings We’ll still use the notation for “any reasonable” encoding of the input to a TM…but now we have to be more careful about what we mean by “reasonable” How long is the encoding of a ‐ vertex graph… … as an adjacency matrix? … as an adjacency list? How long is the encoding of a natural number … in binary? … in decimal? … in unary? 4/8/2020 CS332 ‐ Theory of Computation 6
Describing and analyzing polynomial ‐ time algorithms • Due to Extended Church ‐ Turing Thesis, we can still use high ‐ level descriptions on multi ‐ tape machines • Polynomial ‐ time is robust under composition: executions of ‐ time subroutines run on ‐ size inputs gives an algorithm running in time. => Can freely use algorithms we’ve seen before as subroutines if we’ve analyzed their runtime • Need to be careful about size of inputs! (Assume inputs represented in binary unless otherwise stated.) 4/8/2020 CS332 ‐ Theory of Computation 7
Examples of languages in • 𝑄𝐵𝑈𝐼 � 𝐻 , 𝑡 , 𝑢 𝐻 is a directed graph with a directed path from 𝑡 to 𝑢� • 𝐹 ��� � 𝐸 𝐸 is a DFA that recognizes the empty language � 4/8/2020 CS332 ‐ Theory of Computation 8
Examples of languages in • • 2006 Gödel Prize citation The 2006 Gödel Prize for outstanding articles in theoretical computer science is awarded to Manindra Agrawal, Neeraj Kayal, and Nitin Saxena for their paper "PRIMES is in P." In August 2002 one of the most ancient computational problems was finally solved…. 4/8/2020 CS332 ‐ Theory of Computation 9
A polynomial ‐ time algorithm for ? Consider the following algorithm for On input For : Try to divide by If divides , accept If all fail to divide , reject How many divisions does this algorithm require in terms of ? 4/8/2020 CS332 ‐ Theory of Computation 10
CFG Generation Theorem: Every context ‐ free language is in Chomsky Normal Form for CFGs: • Can have a rule 𝑇 → 𝜁 • All remaining rules of the form 𝐵 → 𝐶𝐷 or 𝐵 → 𝑏 • Cannot have 𝑇 on the RHS of any rule Lemma: Any CFG can be converted into an equivalent CFG in Chomsky Normal Form Lemma: If is in Chomsky Normal Form, any nonempty string w that can be derived from has a derivation with at most steps 4/8/2020 CS332 ‐ Theory of Computation 11
CFG Generation Theorem: Every context ‐ free language is in Proof attempt: Let be a CFL with a CFG in Chomsky Normal Form. Define a TM recognizing : On input : (Let ) 1. Enumerate all strings derivable in steps 2. If any of these strings equal , accept. Else, reject. What is the running time of this algorithm? A better idea: Use dynamic programming ‐ Identify subproblems ‐ Record solutions to subproblems in a table ‐ Solve bigger subproblems by combining solutions to smaller subproblems 4/8/2020 CS332 ‐ Theory of Computation 12
4/8/2020 CS332 ‐ Theory of Computation 13
Examples of languages in Problem Description Algorithm Yes No Grade school MULTIPLE Is x a multiple of y? 51, 17 51, 16 division RELPRIME Are x and y relatively prime? Euclid (300 BCE) 34, 39 34, 51 PRIMES Is x prime? AKS (2002) 53 51 all CFLs Depends on Depends on Is a given string in a fixed CFL? (e.g. the the the Dynamic language of (E.g., is the string of language; language; programming balanced parentheses and brackets e.g. e.g. parentheses balanced?) ([)], (() (([])[]) and brackets) 0 1 1 2 1 0 0 1 Is there a vector x that Gauss-Edmonds LSOLVE 2 4 � 2 4 1 , 1 1 , 1 satisfies Ax = b? elimination 0 3 15 36 0 1 1 1 4/8/2020 CS332 ‐ Theory of Computation 14
Beyond polynomial time Definition: is the class of languages decidable in exponential time on a basic single ‐ tape (deterministic) TM � � � ��� 4/8/2020 CS332 ‐ Theory of Computation 15
Nondeterministic Time and NP 4/8/2020 CS332 ‐ Theory of Computation 16
Nondeterministic time Let � , A NTM runs in time if on every input halts on within at most steps on every computational branch 4/8/2020 CS332 ‐ Theory of Computation 17
Deterministic vs. nondeterministic time Deterministic Nondeterministic reject 𝒖�𝒐� accept accept reject reject accept or reject 4/8/2020 CS332 ‐ Theory of Computation 18
Deterministic vs. nondeterministic time Theorem: Let be a function. Every NTM running in time has an equivalent single ‐ tape TM running in time ��� � � Proof: Simulate NTM by 3 ‐ tape TM Input 𝑥 to 𝑂 (read ‐ only) 𝑥 � 𝑥 � 𝑥 � 𝑥 � Simulation tape (run 𝑂 on 𝑥 using Finite 𝑥 � ⊔ 𝑥 � 𝑥 � # control nondeterministic choices from tape 3) 1 3 3 7 Address in computation tree 4/8/2020 CS332 ‐ Theory of Computation 19
Deterministic vs. nondeterministic time Theorem: Let be a function. Every NTM running in time has an equivalent single ‐ tape TM running in time ��� � � input Proof: Simulate NTM by 3 ‐ tape TM simulation • # leaves: address • # nodes: Running time: To simulate one root ‐ to ‐ node path: Total time: 4/8/2020 CS332 ‐ Theory of Computation 20
Deterministic vs. nondeterministic time Theorem: Let be a function. Every NTM running in time has an equivalent single ‐ tape TM running in time ��� � � Proof: Simulate NTM by 3 ‐ tape TM in time ��� � � We know that a 3 ‐ tape TM can be simulated by a single ‐ tape TM with quadratic overhead, hence we get running time ��� � � � = � · ��� � � = ��� � � 4/8/2020 CS332 ‐ Theory of Computation 21
Recommend
More recommend