CS 461 Nov 16 Decidable vs undecidable The
CS 461 – Nov. 16 • Decidable vs. undecidable √ – The goal was to create a TM that always halts. – Last undecidable problem: ambiguity of CFG • Tractable vs. intractable – Now, not only should it halt, we want an algorithm that won’t take too long! – Two kinds of problems “P” and “NP”
Ambiguous grammars • If we can’t tell if PCP has a solution, then we can’t tell if a CFG is ambiguous. • The idea is to convert a domino game into a grammar that has to be ambiguous exactly when PCP has a solution. • First, begin with an instance of a PCP problem, like we saw before. • Notice that we have a top & bottom. And we’re wondering if we can get them to match! Create a grammar for the top (A) and bottom (B) and say S A|B
continued • Our grammar will look like S A|B A ___________ B ___________ In our case, we have: A 1 Ai 1 | 10111 Ai 2 | 10 Ai 3 | 1 i 1 | 10111 i 2 | 10 i 3 B 111 Bi 1 | 10 Bi 2 | 0 Bi 3 | 111 i 1 | 10 i 2 | 0 i 3
Derivations • Let’s see how our solution 10111 1 1 10 is derived from our A and B grammars. • We wind up with these strings 10111 1 1 10 i 3 i 1 i 2 and 10 111 0 i 3 i 1 i 2 These strings are equal, so there are 2 derivations ambiguous grammar. Note that within A and B it couldn’t be ambiguous, because each time we lay a domino (and choose a grammar rule) we are writing down a distinct “i” number.
Complexity • Algorithms are often classified according to complexity. • Big-O notation is pretty common. General worstcase behavior. • Example: Sorting – – – Radix sort, O(n) Merge sort, O(n log n) Insertion sort, O(n 2) Stooge sort, O(2. 7 n) Monkey sort, O(n!) Good Bad
Non-determinism • An algorithm should be deterministic! • Non-determinism is “cheating. ” – For sorting, non-determinism means pick the right arrangement of elements, and verify it’s in order! • Ex. Spell checking – Deterministic, O(log n) – Non-deterministic, O(1) • Looks like non-determinism makes things easier, but the trick is there’s no way to know what data to pick. Must try them all, so deterministic algorithm often exponential.
P and NP • P = Problems where deterministic polynomialtime algorithm. – “can quickly decide” (in the TM sense) – The run time is O(n 2) or O(n 3), etc. • NP = Problems where non-deterministic polynomial-time algorithm. – “can quickly verify” – A deterministic algorithm would require exponential time, which isn’t too helpful. – (NP – P) consists of problems where we don’t know of any deterministic polynomial algorithm.
Conjecture • P and NP are distinct. – Meaning that some NP problems are not in P. – There are some problems that seem inherently exponential. • Major unsolved question! – For each NP problem, try to find a deterministic polynomial algorithm, so it can be reclassed as P. – Or, prove that such an algorithm can’t exist. We don’t know how to do this. Therefore, it’s still possible that P = NP. • Ex. Primality was recently shown to be in P.
- Slides: 8