210 likes | 587 Views
Fall 2008. The Chinese University of Hong Kong. CSC 3130: Automata theory and formal languages. Efficient computation. Andrej Bogdanov http://www.cse.cuhk.edu.hk/~andrejb/csc3130. Why do we care about undecidability?. TM M accepts all inputs. TM M accepts input w.
E N D
Fall 2008 The Chinese University of Hong Kong CSC 3130: Automata theory and formal languages Efficient computation Andrej Bogdanov http://www.cse.cuhk.edu.hk/~andrejb/csc3130
Why do we care about undecidability? TM M accepts all inputs TM M accepts input w CFG G is ambiguous Post Correspondence Problem undecidable decidable Can you get from point A to point B in 100 steps? L = {0n1n: n > 0} Can you schedule final exams so that there are no conflicts? Is P a valid java program? Can you pair up peopleso that every pair is happy? anything you can write a computer program for ... pretty much everything else
Decidable problems L = {0n1n: n > 0} Is P a valid java program? Option 1: On input x: Try all derivations n := |x| if n is odd reject for i := 0 to n/2: if xi ≠ 0 or xn-i ≠ 1 reject otherwise accept Option 2: CYK algorithm Option 3: LR(1) algorithm Can you get from point A to point B in 100 steps? 14 8 For all paths out of point A of length at most 100: Try this path If path reaches B, accept Otherwise, reject 9 10 14 3 A 6 5 9 2 B 5 8 3 4
Scheduling Can you schedule final exams so that there are no conflicts? CSC 2110 CSC 3230 Say we have n exams, k slots (maybe n = 200, k = 10) Exams → vertices Conflicts → edges CSC 3130 CSC 3160 ... Slots → colors Task: Assign one of k colors to the vertices so that no edge has both endpoints of same color
Scheduling algorithm Task: Assign one of k colors to the vertices so that no edge has both endpoints of same color CSC 2110 CSC 3230 For every possible assignment of colors to vertices: Try this assignment If every edge has endpoints of different colors, accept If all colorings failed, reject CSC 3130 CSC 3160 ...
Matching Can you pair up people so that every pair is happy? People → vertices Happy together → edges Pairing → matching For every possible pairing: If each pair is happy, accept If all pairings failed, reject
Shades of decidability Sure, we can write a computer program... Can you get from point A to point B in 100 steps? L = {0n1n: n > 0} Can you schedule final exams so that there are no conflicts? Is P a valid java program? Can you pair up peopleso that every pair is happy? ...but what happens when we run it?
How fast? L = {0n1n: n > 0} Is P a valid java program? Option 1: On input x: Try all derivations n := |x| if n is odd reject for i := 0 to n/2: if xi ≠ 0 or xn-i ≠ 1 reject otherwise accept Option 2: CYK algorithm Option 3: LR(1) algorithm Can you get from point A to point B in 100 steps? 14 8 For all paths out of point A of length at most 100: Try this path If path reaches B, accept Otherwise, reject 9 10 14 3 A 6 5 9 2 B 5 8 3 4
How fast? Is P a valid java program? P = 100 line java program the lifetime of the universe Option 1: Try all derivations efficient? very inefficient 1 week Option 2: CYK algorithm a few milliseconds Option 3: LR(1) algorithm
Finding paths Is there a better wayto do this? Yes! Dijkstra’s algorithm Can you get from point A to point B in 1000 steps? 14 8 For all paths out of point A of length at most 1000: Try this path If path reaches B, accept Otherwise, reject 9 10 14 3 A 6 5 9 2 B 5 8 3 4 Edsger Dijkstra (1930-2002)
Matching For every possible pairing: If each pair is happy, accept If all pairings failed, reject Can we do better? Yes! Edmonds’ algorithm Jack Edmonds
Scheduling algorithm Task: Assign one of k colors to the vertices so that no edge has both endpoints of same color CSC 2110 CSC 3230 For every possible assignment of colors to vertices: Try this assignment If every edge has endpoints of different colors, accept If all colorings failed, reject CSC 3130 CSC 3160 100 vertices, 10 colors Can we do better? 10100 assignments
Some history UNIVAC 1950s first electronic computer integrated circuits
The need for optimization routing problems packing problems how to route calls through the phone network? how many trucks do you need to fit all the boxes?
The need for optimization 30 min 45 min 50 min 40 min 50 min 0 min scheduling problems constraint satisfaction how do you schedule jobs to complete them as soon as possible? can you satisfy a system of local constraints?
Fast algorithms shortest paths matchings and a few more… 1956 1965
Proving theorems Princeton, 20 March 1956 Dear Mr. von Neumann: With the greatest sorrow I have learned of your illness. […] Since you now, as I hear, are feeling stronger, I would like to allow myself to write you about a mathematical problem: […] This would have consequences of the greatest importance. It would obviously mean that in spite of the undecidability of the Entscheidungsproblem, the mental work of a mathematician concerning Yes-or-No questions could be completely replaced by a machine. Kurt Gödel J. von Neumann
Proving theorems • We know some true statements are not provable • But let’s forget about those. • Can you get a computer to find the proof reasonably quickly? • Better than “try all possible proofs?” 52 years later, we still don’t know!
Optimization versus proofs • If we can find proofs quickly, then we can also optimize quickly! • Question: Can we color Gwith so there are noconflicts? • Proof: We can, set v1 v2 v3 v4 v1 v2 v3 v4 (v1,R), (v2,Y), (v3,R), (v4,Y)
The Cook-Levin Theorem • However, Constraint satisfaction is no harder than finding proofs quickly It is no easier, either Cook 1971, Levin 1973 Stephen Cook Leonid Levin
Equivalence of optimization problems constraint satisfaction routing covering scheduling packing theorem-proving are all as hard as one another! Q: So are they all easy or all hard? A: We don’t know, but we suspect all hard Richard Karp (1972)