Upload
duongkiet
View
213
Download
0
Embed Size (px)
Citation preview
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
Selecting the “Right” Machine • Model Computation Using Turing machine
• But the choice of machine seems to matter a great deal! • Two tapes machines might take fewer steps than one tape machines • Non-Deterministic machines might take fewer steps than Deterministic ones
• Is there a “right” choice to make?
Selecting the “Right” Machine • If a two-tape machine takes steps, a one tape machine can simulate this in
• If a non-deterministic machine takes steps, a deterministic one can simulate this in
So do we need classes for each machine type??
)( knDTIMEP ∪= 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
Some Classic Problems in Computer Science
• Satisfiability Problem
• Hamiltonian Path Problem
• Clique Problem
Are these problems in P ??
Example: The Satisfiability Problem
Boolean expressions in Conjunctive Normal Form:
ktttt ∧∧∧∧ 321
pi xxxxt ∨∨∨∨= 321Variables
Question: is expression satisfiable?
e}satisfiabl is expression :{ wwL =
)2( nDTIMEL∈For variables: n
Algorithm: search exhaustively all the possible binary values of the variables
exponential
Example: the Hamiltonian Problem
Question: is there a simple path that passes through all vertices?
s t
)2()!( nDTIMEnDTIMEL ≈∈
Exponential time
Intractable problem
A solution: search exhaustively all paths
L = {<G,s,t>: there is a Hamiltonian path in G from s to t}
Clique:
A 5-clique
CLIQUE = { : Given a graph does G contains a -clique}
Again, no obvious deterministic polynomial time algorithm…..
>< kG, Gk
Non-Determinism Language class: )(nNTIME
A Non-Deterministic Turing Machine accepts each string of length in time
)(nNTIME
1L2L 3L
)(nOn
Example: The satisfiability problem
Non-Deterministic algorithm:
• Guess an assignment of the variables
e}satisfiabl is expression :{ wwL =
• Check if this is a satisfying assignment
Time for variables: n
)(nO
e}satisfiabl is expression :{ wwL =
Total time:
• Guess an assignment of the variables
• Check if this is a satisfying assignment )(nO
)(nO
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?
Example: Does the Satisfiability problem have a polynomial time deterministic algorithm?
WE DO NOT KNOW THE ANSWER
Open Problem: ?NPP =
Polynomial Time Reductions Polynomial Computable function : f
For any computes in polynomial time
)(wfw
Language A is polynomial time reducible to language B if there is a polynomial computable function such that: f
BwfAw ∈⇔∈ )(
Suppose that is polynomial reducible to . If then .
Theorem:
PB∈A B
PA∈
Proof:
Machine to accept in polynomial time: AOn input : w
1. Compute )(wf
Let be the machine to accept BM
2. Run on input )(wfM
3CNF formula:
)()()()( 654463653321 xxxxxxxxxxxx ∨∨∧∨∨∧∨∨∧∨∨
Each clause has three literals
3SAT ={ : is a satisfiable 3CNF formula}
w wLanguage:
Theorem: 3SAT is polynomial time reducible to CLIQUE
Proof: give a polynomial time reduction of one problem to the other
NP-Completeness A problem is NP-complete if:
• It is in NP
• Every NP problem is reduced to it
(in polynomial time)
Observation:
If we can solve any NP-complete problem in Deterministic Polynomial Time (P time) then we know:
NPP =
Observation:
If we prove that we cannot solve an NP-complete problem in Deterministic Polynomial Time (P time) then we know:
NPP ≠
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
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
– More Complexity • 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 14 Due Today – Homework 15 Due Tuesday – Homework 16 = study for the final!!