Review Languages and Grammars Alphabets, strings, languages - - PDF document

review
SMART_READER_LITE
LIVE PREVIEW

Review Languages and Grammars Alphabets, strings, languages - - PDF document

Review Languages and Grammars Alphabets, strings, languages Regular Languages Deterministic Finite and Nondeterministic Automata CS 301 - Lecture 29 Equivalence of NFA and DFA Regular Expressions and Regular Grammars


slide-1
SLIDE 1

1

CS 301 - Lecture 29 P, NP, and NP-Completeness

Fall 2008

Review

  • Languages and Grammars

– Alphabets, strings, languages

  • Regular Languages

– Deterministic Finite and Nondeterministic Automata – Equivalence of NFA and DFA – Regular Expressions and Regular Grammars – Properties of Regular Languages – Languages that are not regular and the pumping lemma

  • Context Free Languages

– Context Free Grammars – Derivations: leftmost, rightmost and derivation trees – Parsing, Ambiguity, Simplifications and Normal Forms – Nondeterministic Pushdown Automata – Pushdown Automata and Context Free Grammars – Deterministic Pushdown Automata – Pumping Lemma for context free grammars – Properties of Context Free Grammars

  • Turing Machines

– Definition, Accepting Languages, and Computing Functions – Combining Turing Machines and Turing’s Thesis – Turing Machine Variations, Universal Turing Machine, and Linear Bounded Automata – Recursive and Recursively Enumerable Languages, Unrestricted Grammars – Context Sensitive Grammars and the Chomsky Hierarchy

  • Computational Limits and Complexity

– Computability and Decidability – Complexity

) ( k n DTIME P ∪ =

for all k The class P

  • All tractable problems
  • Polynomial time
  • Type of deterministic machine no longer

matters

  • Adding more tapes changes k for a

particular problem, but still polynomial ) ( k n NTIME NP ∪ = for all k The class NP Non-Deterministic Polynomial time

slide-2
SLIDE 2

2

Observation:

NP P ⊆

Deterministic Polynomial Non-Deterministic Polynomial Open Problem:

? NP P =

WE DO NOT KNOW THE ANSWER

Why Does P = NP Matter?

From Garey and Johnson “Computers and Intractability”

Function 10 20 30 40 50 60 N 0.0001 s 0.0002 s 0.0003 s 0.0004 s 0.0005 s 0.0006 s N^2 0.0001 s 0.0004 s 0.0009 s 0.0016 s 0.0025 s 0.0036 s N^5 0.1 s 3.2 s 24.3 s 1.7 min 5.2 min 13.0 min 2^N 0.001 s 1 s 17.9 min 12.7 days 35.7 years 366 centuries 3^N 0.059 s 58 min 6.5 years 3855 centuries 2 X 10^8 centuries 10^13 centuries

Common Run Times for Representative Algorithms

Our Three Classic Problems:

  • Satisfiability
  • Hamiltonian Path
  • Clique

All can be solved in polynomial time using non-deterministic Turing machines. Could they be solved in polynomial time using deterministic Turing machines?

slide-3
SLIDE 3

3

Polynomial Time Reductions

Polynomial Computable function : f For any computes in polynomial time ) (w f

w

Language A is polynomial time reducible to language B if there is a polynomial computable function such that:

f B w f A w ∈ ⇔ ∈ ) (

Suppose that is polynomial reducible to . If then . Theorem:

P B∈ A B P A∈

Proof: Machine to accept in polynomial time:

A

On input :

w

  • 1. Compute

) (w f

Let be the machine to accept B

M

  • 2. Run on input

) (w f

M

Theorem: 3SAT is polynomial time reducible to CLIQUE Proof: give a polynomial time reduction

  • f one problem to the other
slide-4
SLIDE 4

4

Clique: A 5-clique CLIQUE = { : Given a graph does G contains a -clique} Again, no obvious deterministic polynomial time algorithm…..

> < k G,

G k

3CNF formula:

) ( ) ( ) ( ) (

6 5 4 4 6 3 6 5 3 3 2 1

x x x x x x x x x x x x ∨ ∨ ∧ ∨ ∨ ∧ ∨ ∨ ∧ ∨ ∨

Each clause has three literals 3SAT ={ : is a satisfiable 3CNF formula}

w w

Language: ) ( ) ( ) (

3 2 1 2 2 1 2 1 1

x x x x x x x x x ∨ ∨ ∧ ∨ ∨ ∧ ∨ ∨

1

x

1

x

2

x

1

x

2

x

2

x

1

x

2

x

3

x ) ( ) ( ) (

3 2 1 2 2 1 2 1 1

x x x x x x x x x ∨ ∨ ∧ ∨ ∨ ∧ ∨ ∨

1

x

1

x

2

x

1

x

2

x

2

x

1

x

2

x

3

x 1 1

3 2 1

= = = x x x

slide-5
SLIDE 5

5

Theorem: Vertex Cover is polynomial time reducible to CLIQUE Proof: give a polynomial time reduction

  • f one problem to the other

Clique: A 5-clique CLIQUE = { : Given a graph does G contains a -clique} Again, no obvious deterministic polynomial time algorithm…..

> < k G,

G k

Reduction: Given a Graph G, define its complement Gc All vertices in G are vertices in Gc. An edge (u,v) is in Gc if and only if (u,v) is not an edge in G. 1) Convert G into Gc… an easy step. 2) Ask whether Gc has a clique of size K? Cliques and Covers: Let V1 = the Clique found in Gc. Claim (V – V1) is a cover in G. Pick an arbitrary edge (u,v) in G. Suppose neither u or v is in (V-V1). ⇒ Both u and v are V1 ⇒ Both u and v are in a clique in Gc ⇒ there must be an edge (u,v) in Gc ⇒ there must not be an edge (u,v) in G But (u,v) was an edge in G!

slide-6
SLIDE 6

6

NP-Completeness

A problem is NP-complete if:

  • It is in NP
  • Every NP problem is reduced to it

(in polynomial time) Theorem: (ANY PROBLEM IN NP) is polynomial time reducible to CLIQUE Clique is an NP-complete problem. Solve Clique in polynomial time and you solve all NP problems in polynomial time. Observation: If we can solve any NP-complete problem in Deterministic Polynomial Time (P time) then we know:

NP P =

Observation: If we prove that we cannot solve an NP-complete problem in Deterministic Polynomial Time (P time) then we know:

NP P ≠

slide-7
SLIDE 7

7

Cook’s Theorem: The satisfiability problem is NP-complete Sketch of Proof: Convert a Non-Deterministic Turing Machine to a Boolean expression in conjunctive normal form Observations: It is unlikely(??) that NP-complete problems are in P The NP-complete problems have exponential time algorithms Approximations of these problems are in P Other NP-Complete Problems:

  • The Traveling Salesperson Problem
  • Vertex cover
  • Hamiltonian Path

All the above are reduced to the satisfiability problem Vertex Cover = { : Given a graph does G contains a size cover? } A cover is a set of vertices in G such that for every edge (u,v) in G, at least one of u and v belongs to G.

> < k G,

G k

slide-8
SLIDE 8

8

Where to Go From Here?

NP P The View We Have From CS 301

Where to Go From Here?

NP Hard: drop requirement problem is in NP, but still “as hard as” an NP-complete problem. RP: Randomized Computations PSPACE: Polynomial Space Incorporating distributed computations. See Papadimitriou, “Computational Complexity” We have established a starting point for a very rich analysis of complexity in both time and space.

Where to Go From Here?

A larger view of complexity theory

What’s Next

  • Read

– Linz Chapter 1,2.1, 2.2, 2.3, (skip 2.4), 3, 4, 5, 6.1, 6.2, (skip 6.3), 7.1, 7.2, 7.3, (skip 7.4), 8, 9, 10, 11, 12.1, 12.2, (skip 12.3, 12.4, 12.5, 13), 14.1, 14.2, and 14.3 – JFLAP Chapter 1, 2.1, (skip 2.2), 3, 4, 5, 6, 7, (skip 8), 9, (skip 10), 11

  • Next Lecture Topics

– Review for Final Exam

  • Final exam Friday 12/19

– Closed book, but you may bring one sheet of 8.5 x 11 inch paper with any notes you like.

  • Homework

– Homework 15 (repeat of previous homework problems) Due Today – Homework 16 = study for the final!!