BU CS 332 Theory of Computation Lecture 19: Reading: More on P - - PowerPoint PPT Presentation

bu cs 332 theory of computation
SMART_READER_LITE
LIVE PREVIEW

BU CS 332 Theory of Computation Lecture 19: Reading: More on P - - PowerPoint PPT Presentation

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?


slide-1
SLIDE 1

BU CS 332 – Theory of Computation

Lecture 19:

  • More on P
  • Nondeterministic time, NP

Reading: Sipser Ch 7.2‐7.3

Mark Bun April 8, 2020

slide-2
SLIDE 2

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

slide-3
SLIDE 3

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

slide-4
SLIDE 4

Complexity Class

4/8/2020 CS332 ‐ Theory of Computation 4

slide-5
SLIDE 5

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

slide-6
SLIDE 6

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

slide-7
SLIDE 7

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

slide-8
SLIDE 8

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

slide-9
SLIDE 9

Examples of languages in

  • 4/8/2020

CS332 ‐ Theory of Computation 9

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….

slide-10
SLIDE 10

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

  • f

?

4/8/2020 CS332 ‐ Theory of Computation 10

slide-11
SLIDE 11

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

slide-12
SLIDE 12

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

slide-13
SLIDE 13

4/8/2020 CS332 ‐ Theory of Computation 13

slide-14
SLIDE 14

Examples of languages in

4/8/2020 CS332 ‐ Theory of Computation 14

Problem Description Algorithm Yes No MULTIPLE Is x a multiple of y? Grade school division 51, 17 51, 16 RELPRIME Are x and y relatively prime? Euclid (300 BCE) 34, 39 34, 51 PRIMES Is x prime? AKS (2002) 53 51 all CFLs (e.g. the language of balanced parentheses and brackets) Is a given string in a fixed CFL? (E.g., is the string of parentheses and brackets balanced?) Dynamic programming Depends on the language; e.g. (([])[]) Depends on the language; e.g. ([)], (() LSOLVE Is there a vector x that satisfies Ax = b? Gauss-Edmonds elimination 2 1 4 3 1 2 15 , 2 4 36 1 1 1 1 1 1 , 1 1 1

slide-15
SLIDE 15

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

slide-16
SLIDE 16

Nondeterministic Time and NP

4/8/2020 CS332 ‐ Theory of Computation 16

slide-17
SLIDE 17

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

slide-18
SLIDE 18

Deterministic vs. nondeterministic time

4/8/2020 CS332 ‐ Theory of Computation 18

Deterministic Nondeterministic

accept or reject reject accept

𝒖𝒐

reject accept reject

slide-19
SLIDE 19

Deterministic vs. nondeterministic time

4/8/2020 CS332 ‐ Theory of Computation 19

𝑥 𝑥 𝑥 𝑥 Finite control 𝑥 ⊔ # 𝑥 𝑥 1 3 3 7 Input 𝑥 to 𝑂 (read‐only) Simulation tape (run 𝑂 on 𝑥 using nondeterministic choices from tape 3) Address in computation tree

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

slide-20
SLIDE 20

Deterministic vs. nondeterministic time

4/8/2020 CS332 ‐ Theory of Computation 20

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

  • # leaves:
  • # nodes:

Running time: To simulate one root‐to‐node path: Total time:

input simulation address

slide-21
SLIDE 21

Deterministic vs. nondeterministic time

4/8/2020 CS332 ‐ Theory of Computation 21

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

= · =