Presentation is loading. Please wait.

Presentation is loading. Please wait.

Data Structures and Algorithm Analysis Lecture 23

Similar presentations


Presentation on theme: "Data Structures and Algorithm Analysis Lecture 23"— Presentation transcript:

1 Data Structures and Algorithm Analysis Lecture 23
CSCI 256 Data Structures and Algorithm Analysis Lecture 23 Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights reserved, and some by Iker Gondra

2 Satisfiability Literal: A Boolean variable or its negation
Clause: A disjunction of literals Conjunctive normal form (CNF): A propositional formula  that is the conjunction of clauses. Any logical formula can be written in CNF

3 Satisfiability SAT: Given CNF formula , does it have a satisfying truth assignment? 3-SAT: SAT where each clause contains exactly 3 literals each corresponds to a different variable Ex: Yes: x1 = true, x2 = true x3 = false

4 Satisfiability Fundamental combinatorial search problem
Contains basic ingredients of a hard computational problem in very “bare-bones” fashion Have to make n independent decisions (i.e., assignments for each xi) so as to satisfy a set of constraints Have to arrange decisions so that all constraints are satisfied simultaneously

5 Find a Satisfying Truth Assignment
(DONE IN CLASS)

6 Reduction again We now relate the computational hardness embodied in satisfaction problems like SAT and 3-SAT to the superficially different sort of hardness represented by the search for independent sets and vertex covers in graphs. Indeed we will show: 3-SAT  P INDEPENDENT-SET

7 Claim: 3-SAT  P INDEPENDENT-SET
Suppose we have a black box for Independent Set and want to solve 3-Sat consisting of variables X ={x1,…,xn} and clauses C1,…,Ck. Can think of this in 2 different ways: make an independent 0/1 decision about each variable and succeed if you find one of 3 ways to satisfy each of the clauses Choose one term(literal) from each clause and find a truth ass that causes all these terms to evaluate to 1, thereby satisfying all the clauses; this can only happen if whenever a term is chosen in one clause, its negation is not chosen in any other clause – say the terms don’t conflict. We focus on (2)

8 Claim: 3-SAT  P INDEPENDENT-SET
Pf: Given an instance  of 3-SAT, we construct an instance (G, k) of INDEPENDENT-SET; this instance has an independent set of size k iff  is satisfiable Construction (in example here,  has 3 clauses) G contains 3 vertices for each clause, one for each literal Connect 3 literals in a clause in a triangle with edges (remark these are now not independent vertices) Use edges to connect each literal to each of its negations (conflicting terms) G k = 3

9 3-SAT Reduces to Independent Set
Claim: G contains an independent set S of size k = || ( = number of clauses) iff  is satisfiable Pf:  Let S be independent set in G of size k There are k triangles so S must contain exactly one vertex in each triangle and there are no conflicts in the vertices chosen (recall S indep) Set these literals to true; This truth assignment is consistent (no conflicts) so all clauses are satisfied Pf:  Given satisfying assignment, use it to select one true literal from each triangle which does not conflict with another literal selected this gives an independent set of size k G k = 3

10 Transitivity of Reductions
Transitivity: If X  P Y and Y  P Z, then X  P Z Pf idea: Compose the two algorithms (composition of poly functions is poly): run the algorithm for X using a black box for Y; each time the black box for Y is called, simulate it in a polynomial number of steps using the algorithm that solves instances of Y using a black box for Z. Ex: 3-SAT  P INDEPENDENT-SET  P VERTEX-COVER  P SET-COVER

11 Decision Problems Theory developed in terms of yes/no problems
Independent set Given a graph G and an integer K, does G have an independent set of size at least K Vertex cover Given a graph G and an integer K, does the graph have a vertex cover of size at most K

12 Decision Problems Decision problem
X is a set of strings Instance: string s Algorithm A solves problem X: A(s) = yes iff s  X Polynomial time: Algorithm A runs in poly-time if for every string s, A(s) terminates in at most p(|s|) "steps", where p() is some polynomial PRIMES: X = { 2, 3, 5, 7, 11, 13, 17, 23, 29, 31, 37, …. } Algorithm: [Agrawal-Kayal-Saxena, 2002] p(|s|) = |s|8 length of s

13 P P: Decision problems for which there is a poly-time algorithm
Description Algorithm Yes No MULTIPLE Is x a multiple of y? Grade school division 51, 17 51, 16 RELPRIME Are x and y relatively prime? Euclid (300 BCE) 34, 39 34, 51 PRIMES Is x prime? AKS (2002) 53 51 EDIT- DISTANCE Is the edit distance between x and y less than 5? Dynamic programming niether neither acgggt ttttta LSOLVE Is there a vector x that satisfies Ax = b? Gauss- Edmonds elimination

14 Backgrounder on Primality Testing en. wikipedia
Backgrounder on Primality Testing en.wikipedia.org/wiki/AKS_primality_tes The AKS primality test (also known as Agrawal–Kayal–Saxena primality test and cyclotomic AKS test) is a deterministic primality-proving algorithm created and published by Manindra Agrawal, Neeraj Kayal, and Nitin Saxena, computer scientists at the Indian Institute of Technology Kanpur, on August 6, 2002, in a paper titled "PRIMES is in P".[1] The authors received many accolades, including the 2006 Gödel Prize and the 2006 Fulkerson Prize, for this work. The algorithm determines whether a number is prime or composite within polynomial time.

15 Backgrounder on Primality Testing en. wikipedia
Backgrounder on Primality Testing en.wikipedia.org/wiki/AKS_primality_tes The key significance of AKS is that it was the first published primality-proving algorithm to be simultaneously general, polynomial, deterministic, and unconditional. Previous algorithms had achieved three of these properties at most, but not all four. The AKS algorithm can be used to verify the primality of any general number given. Many fast primality tests are known that work only for numbers with certain properties. For example, the Lucas–Lehmer test for Mersenne numbers works only for Mersenne numbers, while Pépin's test can be applied to Fermat numbers only. The maximum running time of the algorithm can be expressed as a polynomial over the number of digits in the target number. ECPP and APR conclusively prove or disprove that a given number is prime, but are not known to have polynomial time bounds for all inputs. The algorithm is guaranteed to distinguish deterministically whether the target number is prime or composite. Randomized tests, such as Miller–Rabin and Baillie–PSW, can test any given number for primality in polynomial time, but are known to produce only a probabilistic result. The correctness of AKS is not conditional on any subsidiary unproven hypothesis. In contrast, the Miller test is fully deterministic and runs in polynomial time over all inputs, but its correctness depends on the truth of the yet-unproven generalized Riemann hypothesis.

16 NP Certification algorithm intuition
Certifier views things from "managerial" viewpoint Certifier doesn't determine whether s  X on its own; rather, it checks a proposed proof t that s  X Def: Algorithm C(s, t) is a certifier for problem X if for every string s, s  X iff there exists a string t such that C(s, t) = yes NP: Decision problems for which there exists a poly-time certifier Indeed Remark: NP stands for nondeterministic polynomial-time "certificate" or "witness" C(s, t) is a poly-time algorithm and |t|  p(|s|) for some polynomial p().

17 NP Poly time finding solution versus poly time checking if proposed soln is a soln -- are very different; often one can easily check if a proposed sol is a sol, when finding a sol is much more difficult Easy to check if a particular truth assignment satisfies some formula θ; much harder to determine if there is or there is not a truth assignment to satisfy some formula θ.

18 Certificate Examples Independent set of size K Satifisfiable formula
The Proposed Independent Set Satifisfiable formula Truth assignment to the variables Hamiltonian Circuit Problem A cycle including all of the vertices K-coloring a graph Assignment of colors to the vertices

19 Are There Even Harder Problems?
Simple game: Players alternating selecting nodes in a graph Score points associated with node Remove node’s neighbors When neither can move, player with most points wins

20 Competitive Facility Location
For a particular player Pi, is there a strategy so that, no matter how the other players play, Pi will be able to select a set of nodes with a total value of at least X? Hard to convince someone of the answer to this question (i.e., no short proof, lengthy case-by-case analysis), compare with Independent Set Problem PSPACE-complete

21 Certifiers and Certificates: Composite
COMPOSITES: Given an integer s, is s composite? Certificate: A nontrivial factor t of s. Note that such a certificate exists iff s is composite. Moreover |t|  |s| Certifier Instance: s = 437,669 Certificate: t = 541 or 809 Conclusion: COMPOSITES is in NP boolean C(s, t) { if (t  1 or t  s) return false else if (s is a multiple of t) return true else }

22 Certifiers and Certificates: 3-SAT
SAT: Given a CNF formula , is there a satisfying assignment? Certificate: An assignment of truth values to the n boolean variables Certifier: Evaluate each clause in  to determine if it has at least one true literal Ex: Conclusion: SAT is in NP instance s certificate t

23 Certifiers and Certificates: Hamiltonian Cycle
HAM-CYCLE: Given an undirected graph G = (V, E), does there exist a simple cycle C that visits every node? Certificate: A permutation of the n nodes Certifier: Check that the permutation contains each node in V exactly once, and that there is an edge between each pair of adjacent nodes in the permutation Conclusion: HAM-CYCLE is in NP instance s certificate t

24 P, NP, EXP P: Decision problems for which there is a poly-time algorithm EXP: Decision problems for which there is an exponential-time algorithm NP: Decision problems for which there is a poly-time certifier Claim: P  NP Pf: Consider any problem X in P By definition, there exists a poly-time algorithm A(s) that solves X Certificate: t = , certifier: C(s, t) = A(s) Claim: NP  EXP Pf: Consider any problem X in NP By definition, there exists a poly-time certifier C(s, t) for X To solve input s, run C(s, t) on all strings t with |t|  p(|s|) Return yes, if C(s, t) returns yes for any of these

25 Extra Credit Homework Question
Does P = NP? [Cook 1971, Edmonds, Levin, Yablonski, Gödel] Is the decision problem as easy as the certification problem? $1 million prize (plus the extra credit) If yes: Efficient algorithms for 3-COLOR, TSP, FACTOR, SAT, … If no: No efficient algorithms possible for 3-COLOR,TSP, SAT,… Consensus opinion on P = NP? Probably no EXP NP EXP P P = NP If P  NP If P = NP would break RSA cryptography (and potentially collapse economy)

26 X  p Y Recall X  p Y iff an arbitrary instance of X can be solved using a poly # of standard computational steps ** plus a poly # of calls to a black box that solves problems Y By poly # we mean poly function on the input ** we think of this as kind of preprocessing – the work involved to transform (or “reduce”) an instance of X to an instance of Y

27 NP-Complete NP-complete: A problem Y in NP with the property that for every problem X in NP, X  p Y Theorem: Suppose Y is an NP-complete problem. Then Y is solvable in poly-time iff P = NP Pf:  If P = NP then Y can be solved in poly-time since Y is in NP Pf:  Suppose Y can be solved in poly-time Let X be any problem in NP. Since X  p Y, and Y can be solved in poly-time, we can solve X in poly-time. This implies NP  P We already know P  NP. Thus P = NP Fundamental question: Do there exist "natural" NP-complete problems?


Download ppt "Data Structures and Algorithm Analysis Lecture 23"

Similar presentations


Ads by Google