110 likes | 260 Views
CS 155, Programming Paradigms Fall 2014, SJSU nondeterminism. Jeff Smith. NP and nondeterminism. The definition of NP depends on the notion of nondeterminism And it’s easiest to define nondeterminism in terms of the state of a computation
E N D
CS 155, Programming ParadigmsFall 2014, SJSUnondeterminism Jeff Smith
NP and nondeterminism • The definition of NP depends on the notion of nondeterminism • And it’s easiest to define nondeterminism in terms of the state of a computation • here, the term state includes information like the values of variables and other memory contents • so the closest CS 154 concept is instantaneous description (ID) rather than state.
Models of nondeterminism • There are several useful models of nondeterministic computation. • In each model, we think of computation as proceeding from state to state. • All of these models are equivalent -- they describe the same class of (nondeterministic) algorithms.
Nondeterministic Turing machines • Nondeterministic Turing machines: a transition function gives the possible successors of a given ID • control may pass to any of the successors. • This model is what we’ll use to show that there’s a hardest problem in NP.
Unbounded parallelism and decision trees • In unbounded parallelism, each successor state is assigned to a newly allocated processor • In decision trees, states are represented as tree nodes, • where state T is a child of state U iff T can be reached from U by a single decision.
Nondeterministic time complexity • In each of the three models above, it's natural to define (nondeterministic) time complexity to be the length of a shortest accepting computation. • This is a natural concept in each model. • To define the length of the input, we use the length of the string that represents the instance.
Guessing and verifying • In the guessing and verifying model, a solution is guessed in a preliminary guessing phase • where each guess takes O(1) time, • and must select from a bounded set of possible choices. • The solution is then verified deterministically • This is the model we'll use most.
Verifying without guessing • Sometimes this model is taken to have only a guessing phase • The sequence of guesses is replaced by a bit string called the certificate • which is the input to the verification process • CLRS takes this approach, on p.1064 • note that they need to stipulate that the certificate has polynomial length • corresponding to a polynomial number of guesses
Time complexity of guessing and verifying • Time complexity in the guess-and-verify model is computed as always … • Except that if verification fails, the time complexity is irrelevant • formally, it’s taken to be O(1) in this case • note that this gives an asymmetry between success and failure
Defining the class NP • The class NP = {P | P has a nondeterministic polynomial-time solution algorithm}. • Its membership does not depend on which model of nondeterminism is used to define it. • a polynomial-time algorithm in one model takes polynomial time in every other model • So this definition of NP now gives us a precise definition of NP-completeness.
NP-completeness • The hardest problems in NP are the problems P such that Q α P for every Q in NP. • Such problems are called NP-complete. • It’s not obvious that such problems exist • but they do! • If an NP-complete problem is in P, then P=NP. • it’s not known whether this is the case • that is, we don’t know whether these apparently hard problems are actually hard