1 / 16

Lecture 10-11 NP-Completeness

Lecture 10-11 NP-Completeness. Jan Maluszynski , IDA, 200 7 http://www.ida.liu.se/~janma janma @ ida.liu.se. Outline. Lecture 9-10 : NP-completeness (Sipser 7.4 – 7.5) Motivation P vs. NP NP-complete problems definition & intuition 3-SAT Polynomial time reducibility Cook-Levin theorem

troupe
Download Presentation

Lecture 10-11 NP-Completeness

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 10-11NP-Completeness Jan Maluszynski, IDA, 2007 http://www.ida.liu.se/~janma janma @ ida.liu.se Jan Maluszynski - HT 2007

  2. Outline Lecture 9-10 : NP-completeness (Sipser 7.4 – 7.5) • Motivation P vs. NP • NP-complete problems definition & intuition • 3-SAT • Polynomial time reducibility • Cook-Levin theorem • A survey of NP-complete problems Jan Maluszynski - HT 2007

  3. The class NP NTIME(t(n)) = {L | L is a language decided by a O(t(n)) time nondeterministic Turing Machine} A language is in NP iff it is decided by a nondeterministic polynomial time Turing Machine A verifier for L is an algorithm (deterministic TM) V: where L = {w | V accepts <w,c> for some string c} Intuitively c (certificate) gives an evidence that w is in L which can be checked by V. A language is in NP iff it has a polynomial time ( wrt to the size of w) verifier. Jan Maluszynski - HT 2007

  4. Example of an NP problem. A Hamiltonian path in a directed graph G is a path where every node of G appears exactly once. HAMPATH = { <G,s,t> | G is a directed graph with a Hamiltonian path connecting s and t } HAMPATH is in NP: a NTM T constructs pathes of G that at s and have no repeated nodes; T accepts if a constructed path is Hamiltonian. HAMPATH Verifier: on input <G,s,t, c> checks if c is a Hamiltonian path from s to t in G. Can be done in polynomial time on the size of G. Explain how to construct polynomial-time verifier! Jan Maluszynski - HT 2007

  5. HAMPATH verifier is polynomial Input: G, s, t, c • Check if c is a path from s to t in G: PATH is in P • Check if c is Hamiltonian; use 2-tape TM: <c> list of nodes in c on tape 1; <n> list of nodes in G on tape 2 • For each element x of <c> find x in <n>: reject if x not in <n> or if marked ; otherwise mark x in <n>, O(|n|2) • Check if all nodes in <n> are marked O(|n|) runs in O(|n|2) on two-tape TM Jan Maluszynski - HT 2007

  6. More examples of NP problems A clique in an undirected graph is a subgraph where every two nodes are connected by an edge. CLIQUE ={<G,k>|G is a graph with a k nodes clique} A Boolean formula is constructed from variables by using operators:    e.g. (x   y)(  xz) A formula is satisfiable iff some assignment of 0’s and 1’s to variables makes it evaluate to 1. SAT = {<> |  is a satisfiable Boolean formula} Jan Maluszynski - HT 2007

  7. P vs. NP It is not known if P=NP ? Conjecture: it doesn’t. We know NP  EXPTIME Since nondeterministic polynomial time TM decider T can be transformed to a deterministic TM that explores breadth-first all computation branches of T. Jan Maluszynski - HT 2007

  8. Polynomial time reducibility Intuition: composition of efficient algorithms is efficient! Having: a polynomial time decider for a language B a polynomial time reduction f of A to B We can decide wA in polynomial time by • Transforming w to f(w) (in polynomial time) • Deciding f(w) B (in polynomial time) Th: If A p.t.r to B and B P then A P Jan Maluszynski - HT 2007

  9. Polynomial time reducibility A function f: *  * is polynomial time computable if some polynomial time TM M on every input w halts with f(w) on its tape Language A is polynomial time mapping reducible to B written APB if there is a computable function f s.that for every w wA  f(w)B f is called polynomial time reduction of A to B. Jan Maluszynski - HT 2007

  10. Polynomial-time reduction: example 3-cnf formulae: Literal: x or x, where x is a variable Clause: disjunction of literals eg. (x y   z) Cnf- formula: conjunction of clauses eg. (x y   z)  (z   x) 3-cnf formula: each clause has 3 literals 3SAT problem: satisfiability of 3-cnf formulae. Theorem: 3SAT is polynomial-time reducible to CLIQUE Proof: construction of a graph with nodes corresponding to the literals of a 3-cnf formula Jan Maluszynski - HT 2007

  11. Definition of NP-completeness A language B is NP-complete iff: • B is in NP • Every language A in NP is polynomial time reducible to B Intution: most time-consuming problems in NP. If B is NP-complete and B is in P, then P=NP. If B is NP-complete, C is NP, and B is polynomial time reducible to C then C is NP-complete Jan Maluszynski - HT 2007

  12. Proving a language to be NP-complete How to prove that an NP language B is NP-complete: • Directly from definition (difficult: all NP-languages are to be considered) • Knowing one NP-complete language A find a polynomial time reduction from A to B. Find one NP-complete problem!!! Jan Maluszynski - HT 2007

  13. Cook-Levin Theorem Cook-Levin Theorem: SAT is NP-complete. Proof idea (p.281). For any string in NP language there is an accepting polynomial-time computation. Represent it as a tableau. The tableau can be characterized by a satisfiable Boolean formula (also by 3cnf-formula). Corollary: 3SAT is NP-complete Jan Maluszynski - HT 2007

  14. More examples of NP-complete problems • 3SAT proved directly • CLIQUE: existence of a clique of size k in a given graph, proved by reduction from 3SAT • VERTEX-COVER (p.288): existence of a set C of k nodes in a graph s.that every edge has a node in C, proved by reduction from 3SAT • HAMPATH existence of a Hamiltonian path in a directed graph, proved by reduction from 3SAT • UHAMPATH existence of a Hamiltonian path in an undirected graph, reduction from HAMPATH • SUBSET-SUM given a set of integers is there a subset whose sum equals a given number Jan Maluszynski - HT 2007

  15. Importance of time-complexity analysis • Polynomial-time complexity preserved by realistic models of computations. • P is a class of problems that can be realistically solved on a computer. • The notion of NP-completeness based on P; relevant for practical computing. Jan Maluszynski - HT 2007

  16. Importance of time-complexity analysis • The notion of NP-completeness identifies computationally expensive problems. • Many of them appear in practice e.g. scheduling and resource allocation problems. • NP-completeness of a problem shows that no algorithm will behave well in worst case; for some data an algorithm may still be efficient. Jan Maluszynski - HT 2007

More Related