240 likes | 259 Views
Complexity. Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings. Decidability. A language is decidable (aka Turing decidable) if a TM decides it, meaning it halts in an accepting or a non-accepting state. It does not loop. Non-determinism.
E N D
Complexity Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings.
Decidability • A language is decidable (aka Turing decidable) if a TM decides it, meaning it halts in an accepting or a non-accepting state. • It does not loop.
Non-determinism • Concept that can be applied to FSA, PDA, and TM • Start with FSA • NDFSA has choices at each state • So a NDFSA has finite set of states, finite alphabet, start state, set of accepting states and rules of the form State x (Alphabet + empty string) =>subset of states. • Think of it as choices
Non-determinism • extend to PDA and TM • In terms of computation power, for every NDFSA there is a (standard) FSA and the same holds for PDAs and TMs. • increase states to be set of all subsets of the states. • This is an exponential increase in number of states.
Consider • Consider original set of states, the the Power set is the set of all subsets: • For {a,b}, the is the empty set, {a},{b} and {a,b} • for {a,b,c} ? • for {a,b,c,d} ? • Generalize?
Back to complexity • So adding the non-determinism option (may think of it as guessing a solution), doesn't effect the programming power but does effect the complexity.
Fact • If T is a non-deterministic TM that computes in O(f(n)), then there is a deterministic TM that computes in 2 O(f(n)) . • The proof (look it up!) does not mean there isn't a faster deterministic TM.
The class P • consists of all languages that are decidable in polynomial time by a deterministic TM. • P = UNION TIME(nk) • These correspond to all problems that are realistically solvable • though there is a big difference between problems solvable in linear time and problems solvable only in n2 or n3 or higher
Examples of languages in P • Every regular language • Every context free language
Question • If the requirement was to sort a set of 10000 records, then what would be the difference between using a bubble sort and a heap sort?
The class NP • consists of all languages that are decidable in polynomial time by a nondeterministic TM. • NP = UNION NTIME(nk)
Examples of NP • clique = {<G,k< | G is an undirected graph with a k-clique (subgraph with every pair of nodes connected) • …
The class NP • alternate definition: verifier • Informal idea: if we had some information, called a certificate or proof and a way of using this certificate, then we have a verifier. • Formal, a verifier for a language A is an algorithm V, whereA = {w | V accepts <w,c> for some c} • NP is the set of languages that have polynomial time verifiers.
Generic Example • Problem is: does there exist a path • Verifier could be the path which can be checked in polynomial time.
P versus NP • P is the class of languages for which membership can be decided quickly. • NP is the class of languages for which membership can be verified quickly. • where quickly means polynomial time.
Does P = NP? • It is known how to produce a deterministic TM that does the job, but much slower involving a exponential increase in the number of states. • But perhaps there is something better?
NP-completeness • A large and growing number of NP problems that can be converted into each other in polynomial time. • … MEANING that if one can be solved in polynomial time, they all can be.
Example: Satisfiability • A Boolean formula is an expression consisting of Boolean (true/false) variables and AND and OR and NOT operators. • A formula is satisfiable if there is an assignment to its variables that makes the formula true. • x AND NOT x is NOT satisfiable • SAT = {<w> | w is satisfiable } • SAT is in NP. Is it in P?
Travelling salesman • Different versions • Given a directed, weighted graph (edges have direction and values), • what is the shortest path to visit all nodes and return to start • Is there a path of length less than some value L that visits all nodes • This is NP-complete, meaning it can be converted to others in the set, including satisfiability
NP-hard • A problem is NP-hard if solving it in polynomial tiam would mean that NP complete problems can be solved in polynomial time. • It is at least as difficult as the NP-complete problems • but maybe harder…
Note • Repeat: NP complete problems and NP-hard problems are solvable, but take a lot of time. • Note: the Travelling Salesman problem can be solved: try every path and pick the shortest. • Intuitively: adding non-determinism is making a guess. • perhaps over a small set of possibilities
Origami example • Fold and cut to make any polygon shape: http://erikdemaine.org/foldcut/ • Inspiration may have been: http://www.ushistory.org/betsy/flagstar.html • Extra credit opportunity: what is the complexity of either or both of the algorithms that solve this problem?
Origami problem • Creating a crease pattern to match a stick figure is NP-hard: http://www.technologyreview.com/view/420198/origami-crease-pattern-design-proved-np-hard/ • Others: http://erikdemaine.org/folding/
Homework • [Can count as this week's posting, though you are welcome to give another one] • Find a unique problem (unique with respect to what has been posted) of an NP complete problem. • explain problem and • give two sources