270 likes | 379 Views
CSCI 4325 / 6339 Theory of Computation. Zhixiang Chen. Chapter 7 NP-Completeness. NP. NP-complete. P. The New World. Poly-Time Computable Functions. Definition. A function is said to be poly-time computable if there is a poly-time bounded TM M that computes it.
E N D
CSCI 4325 / 6339Theory of Computation Zhixiang Chen
NP NP-complete P The New World
Poly-Time Computable Functions • Definition. A function is said to be poly-time computable if there is a poly-time bounded TM M that computes it.
Polynomial Reduction • Definition. Let be two languages. A poly-time computable function is called a polynomial reduction from to if the following is true: • When is ploynomially reducible to , we denote
Understand Polynomial Reduction • When is polynomially reducible to , we have the two results: • If is (deterministically or nondeterministically) poly-time computable, so is . • If is not (deterministically or nondeterministically) ploy-time computable, neither is .
Reduction Examples • Theorem. Hamilton Cycle Problem SAT. • Proof. • Given: A graph • Want: An algorithm (poly-time computable function) f that produces a Boolean CNF such that • G has a Hamilton Cycle if and only if f(G) is satisfiable
… j n -1 1 … 2 A HC Illustration 3 Construction of the Reduction f: • f(G) has Boolean variables • Motivation for is • Node i of G is the j-th node in the Hamilton cycle of G.
Construction of the Reduction f: • Conditions for a Hamilton Cycle (HC): • At least one node at the j-th position of HC • No nodes occur twice in a HC: • Each node occurs exactly once in a HC:
Construction of the Reduction f: • Any two consecutive nodes in the HC must be connected by an edge. In other words, if there is no edge from node i to node k, then node i and node k must not be two consecutive nodes in the HC: • Easy to verify: G has an HC if and only if f(G) is satisfiable.
Reduction Composition • Lemma 7.1.1. If f is a polynomial reduction from to , and g is a reduction from to then is a reduction from to Proof. (Prove in class.)
NP-Completeness • Definition A language is called NP-complete, if • (a) • (b) • An NP-complete language is the “hardest” problem in NP.
Theorem • Theorem 7.1.1. Let L be an NP-complete language. Then P = NP if and only if L is in P. • Proof. (Prove in class.) • By this theorem, to prove P=NP, one only needs to show one NP-complete problem in P.
Cook Theorem • Cook-Levin Theorem. SAT is NP-complete. • Proof. • (1) SAT is in NP • Easy to show • (2) • Hard to show.
Cook Theorem • Prove (2): • Basic Idea: use CNF to describe TM computation • Because L is in NP, there is a polynomial p, an NTM M such that M is p-bounded and L=L(M). • Want: Find a poly-time computable function f such that
Construction of f : • 1. Represent M’s configurations, i.e. tape content, r/w head position, current state. • 2. Ensure that all transitions between configurations are legal. • 3. Encode the initial configuration
… … Step 0 … … … p(|x|) p(|x|) p(|x|) p(|x|) … Step 1 … Step 2 … … Step p(|x|)+1 Construction of f : • Since M is p-bounded, given , the whole working space of M is illustrated below
Construction of f : • Define variables • At step i, we need a variable to describe the state • Assume M has s states: • is true M is at state j at step i
Construction of f : • Of course, M has exactly one state at each step.
Construction of f : • Describe r/w head position at step i: is true iff head position is at j at step i.
Construction of f : • Describe tape content • Assume M has d tape symbols is true iff M has symbol k at cell j at step i.
Construction of f : • For each tape cell, M has at least one symbol • For each tape cell, M has at most one symbol
Construction of f : • Encode the initial input tape • Let the input • Head position • Initial state • The x encoding • Padding blanks between cell |x| and cell p(|x|) where 1 means blank Assume the initial state is indexed as 1.
Construction of f : • Describe the halting configuration of M. • Assume the halting state is indexed as s.
Construction of f : • Describe moves from one configuration to another. • Do this according to the transition relation of M: • For any transition of the form “if M is at state r with head position j and current symbol k at step i, M will be at state r’ with head position j’ and current symbol k’ at cell j at step i+1 with the only tape cell being changed being cell j.” [Note. Either j’=j, or j’=j-1, or j’=j+1.] • The above means that if M is not scanning cell j at step i, then the content of cell j will remain unchanged.
Construction of f : • The following describes the transition:
Putting All Together • We have the desired reduction f(x) such that • f(x) is a CNF • f(x) has variables • f(x) has clauses • f(x) is poly-time computable.