NPC Millennium Prize Problems http://en.wikipedia.org/wiki/Millennium_Prize_Problems 8 NP-complete problem Hard problems: demo NP-hard (Non-deterministic Polynomial-time hard), in computational complexity theory, is a class of problems that are, informally, "at least ashard as the hardest problems in NP". Informal Definition of NP Solutions to the problem can be verified easily (in polynomial time). The idea of “guessing” the right answer or checking all possible solutions in parallel to determine which is correct is called non-determinism. Any problem with an algorithm that runs on a nondeterministic machine in polynomial time is called a problem in NP. Is Towers of Hanoi problem in NP? NPC 2-Coloring 2-coloring (2Col): Given a graph G, can each of its vertices be labeled with one of 2 different “colors”, such that no two adjacent vertices have the same label? Is 2-coloring problem in NP ? Yes Determine the graph is a Is it in P? bipartite graph or not Yes 3-Coloring 3-coloring (3Col): Given a graph G, can each of its vertices be labeled with one of 3 different “colors”, such that no two adjacent vertices have the same label? 3-Coloring 3-Coloring Is 3-coloring problem in NP ? Yes Is it in P? 3-Coloring Is 3-coloring problem in NP ? Yes It is in NPC 4-coloring Four color conjecture – a planar map can be colored properly using 4 colors. 4-coloring Four color theorem – a planar map can be colored properly using 4 colors. The conjecture was first proposed in 1852 1970s, was proved with help from computer programs Hamilton cycle problem Hamilton cycle Hamilton cycle problem: a simple cycle contains all vertices Does a given undirected graph have a Hamilton cycle ? Is Hamilton cycle problem in NP? Yes Traveling salesman problem Given a list of cities and the distances between each pair of cities, what is the shortest possible route that visits each city exactly once and returns to the origin city? Vertex Cover Given a graph G, a vertex cover for G is a subset C of the vertices such that, for every edge (u,v) of G, uC or vC. The optimization goal is to find as small a vertex cover for G as possible. Vertex cover problem: Given a graph G and an integer k, determine whether there is a vertex cover for G containing at most k vertices. B B A D C D Vertex Cover Is vertex cover problem in NP ? Yes 2SAT Often expressed as 2CNF (conjunctive normal form - a conjunction of clauses, where a clause is a disjunction of literals and there are n different literals) Ex: (xy)(yz)(xz)(zy) The 2-satisfiability problem is to find a truth assignment to these variables that makes a formula of this type true. It’s a decision problem. exercise (x y) (xz) (xy)(yz)(xz)(zy) kSAT Maximal number of literals per clause 4 3 2 1 P NP-hard 2SAT is in P Theorem: 2SAT is polynomial-time decidable. Proof: using path searches (DFS/BFS) in graphs… Graph Construction Vertex for each variable and a negation of the variable Edge (,) iff there exists a clause equivalent to () Graph Construction: Example (xy)(yz)(xz)(zy) More edges? Note: xy yx x y x y z z Observation Claim: If the graph contains a path from to , it also contains a path from to . Proof: If there’s an edge (,), then there’s also an edge (,). Corollary A 2-CNF formula is unsatisfiable iff there exists a variable x, such that: there is a path from x to x in the graph AND there is a path from x to x in the graph Graph Construction: Example (xy)(yz)(xz)(zy)(zx) x y x y z z IF Suppose there are paths x..x and x..x for some variable x, AND there’s also a satisfying assignment . If (x)=T (similarly for (x)=F): () =? x T () is false! . . . T x F F Only IF Suppose there are no such paths. Construct an assignment as follows: 1. pick an unassigned literal , with no path from to , and assign it T 2. assign T to all reachable vertices x yy xx y z zz 3. assign F to their negations 4. Repeat until all vertices are assigned Only IF (2) Claim: The algorithm is well defined. Proof: If there were a path from x to both y and y, then there would have been a path from x to y and from y to x which indicate a path from x to x. Corollary Claim: a 2-CNF formula is unsatisfiable iff there exists a variable x, such that: there is a path from x to x in the graph AND there is a path from x to x in the graph 2SAT is in P We get the following efficient algorithm for 2SAT: For each variable x find if there is a path from x to x and vice-versa. Reject if any of these tests succeeded. Accept otherwise 2SATP. 3SAT Is E satisfiable? 3SAT is in NP – a decision problem that can be solved in nondeterministic polynomial time Final review