CS5371 Theory of Computtion Lecture 20: Complexity V (Polynomil-Time Reducibility)
Objectives Polynomil Time Reducibility Prove Cook-Levin Theorem
Polynomil Time Reducibility Previously, we lernt tht if problem A cn be mpped in finite steps into nother problem B, we conclude tht 1. if B is decidble, A is decidble 2. if B is recognizble, A is recognizble This is clled mpping reducibility Suppose tht we restrict the mpping reducibility to be done in polynomil time. Wht cn we conclude?
Polynomil Time Reducibility (2) We define (this slide + next slide): Definition: A function f: * * is polynomil-time computble function if some polynomil-time TM M exists tht hlts with just f(w) on its tpe, when strted with input w
Polynomil Time Reducibility (3) Definition: Lnguge A is polynomil-time mpping reducible, or simply polynomiltime reducible, to lnguge B, written s A P B, if polynomil-time computble function f exists, where for ech w, w2a f(w)2b The function f is clled polynomil-time reduction of A to B
Definition of NP-Complete Definition: Lnguge B is NP-complete if 1. B is in NP, nd 2. every lnguge A in NP is polynomil-time reducible to B Wht is so specil bout NP-complete? Question: Wht will hppen if n NPcomplete lnguge cn be decided in polynomil time?
Properties of NP-Complete Answer: Every lnguge in NP cn be decided in polynomil time (why??) Nturlly, NP-complete lnguge is the most difficult lnguge in NP In other words, we hve Theorem: Suppose B is NP-complete. Then, B is in P if nd only if P = NP
Cook-Levin Theorem Recll tht Cook-Levin Theorem is the following: Theorem: SAT is P if nd only if P = NP We hve not given its proof yet. To prove this, it is equivlent if we prove: Theorem: SAT is NP-complete
Proof of Cook-Levin To prove SAT is NP-complete, we need to do two things: 1. Show SAT is in NP 2. Show every other lnguge in NP is polynomil time reducible to SAT Proof of 1: Simple Cn you give DTM verifier proof? Cn you give n NTM decider proof? Proof of 2: Hrder
Proof of Prt 2 (Ide) Ide: We construct polynomil-time reduction for ech A in NP to SAT First, let N be n NTM tht decides A The reduction of A tkes string w nd gives Boolen formul F such tht N ccepts w F is stisfible In prticulr, we choose ( long nd strnge) F such tht its stisfying ssignment corresponds to the (ccepting) computtion for N to ccept w
Proof of Prt 2 (Detils) Let N be n NTM tht decides A. Let n k be the running time of N on input of length n, with some constnt k. We define tbleu for N on input w to be n n k by n k tble tht represents brnch of computtion of N on w Ech row stores configurtion in the brnch of computtion For instnce, (see next slide)
A Tbleu for N on w Strt configurtion # q 0 w 1 w 2 w n # # # # # n k # # n k n k th configurtion
More on Tbleu For convenience, we ssume ech configurtion strts nd ends with # The 1st row is the strting configurtion, nd ech row follows from the previous row leglly A tbleu is ccepting if ny row of the tbleu is n ccepting configurtion Thus, every ccepting tbleu corresponds to n ccepting computtion
Proof of Cook-Levin (cont) So, deciding whether N ccepts w is equivlent to deciding whether n ccepting tbleu for N on w exists Our tsk now is to find formul F tht cn check if n ccepting tbleu exists Let us try formul F tht contins vrible x i,j,s for ech cell (i, j) in the tbleu, nd ech s in C = Q {#}, Lter, we hope x i,j,s = 1 cell (i,j) stores symbol s
Defining the Formul F Let us be more mbitious: we hope tht when F is stisfible, the stisfying ssignment of F cn tell us vlid nd ccepting tbleu So, we wnt to ensure tht the stisfying ssignment (when F is stisfible) gurntees: 1. Ech cell is occupied by exct 1 symbol 2. The tbleu hs ccepting configurtion 3. Ech row is correct
Proof of Cook-Levin (cont) In prticulr, we will use sub-formul to represent the bove three cses, so tht these sub-formul is stisfible if the corresponding three cses re correct The finl F is obtined by And -ing ll these formul, so tht if F is stisfible, ll three cses must be correct
Ech Cell hs only 1 symbol The sub-formul f i,j,1 ensures cell (i,j) contins t lest one symbol: f i,j,1 =_ s2c x i,j,s The sub-formul f i,j,2 ensures cell (i,j) contins t most one symbol: f i,j,2 =^s,t2c, s t ( (: x i,j,s )_(: x i,j,t )) Thus, f i,j,1^f i,j,2 will ensure cell (i,j) hs exctly one symbol, if F is stisfible
Accepting Configurtion The following sub-formul ensures the tbleu hs n ccepting configurtion if F is stisfible: f ccept =_ i,j x i,j,qccept
Row is Legl To ensure strting row is correct, we use the following sub-formul: f strt = x 1,1,#^ x 1,2,q0^ x 1,3,w1^ x 1,4,w2^ ^ x 1,n+2,wn^ x 1,n+3, ^ ^ x 1,n k-1, ^ x 1, n k,# To ensure the remining rows re correct, we first define the concept of window nd legl window inside the tbleu: (next slide)
Row is Legl (2) A window t (i,j) refers to the 2x3 cells of (i,j), (i,j+1), (i,j+2), (i+1,j), (i+1,j+1), nd (i+1,j+2) A legl window is window tht does not violte the ctions specified by the N s trnsition function, ssuming the configurtion of ech row follows leglly from the configurtion in the row bove
Row is Legl (3) E.g., q 2 q 1 b c This window is legl if there is trnsition (q 1,b) = (q 2,c,L) q 1 b q 2 This window is legl if there is trnsition (q 1,b) = (q 2,,R) q 1 b This window is legl if there is trnsition (q 1,c) = (q 2,b,R) for some c nd q 2
Row is Legl (4) E.g., # # b b This window is lso legl b b q 2 This window is legl if there is trnsition (q 1,b) = (q 2,c,L) for some q 1, b, nd c b This window is legl if there is trnsition (q 1,) = (q 2,b,L) for some q 1 nd q 2
Row is Legl (5) E.g., b b b q 2 q 1 b q 2 All these windows cnnot be legl, why? q 2 q 1 c b
Row is Legl (6) Note the the window contining the stte symbol in the center top cell gurntees tht the corresponding three lower cells re updted consistently with the trnsition function So, if row stores configurtion c, nd if ll windows in tht row re legl, then the row below it will store configurtion the follows leglly from c
Row is Legl (7) Bsed on the legl window concept, the sub-formul f move ensures tht ech row re following correctly: f move =^1 i,j n k -2 (window t (i,j) is legl) where window t (i,j) is legl is equl to: _ 1,2,,6 is legl window (x i,j,1^ x i,j+1,2^ x i,j+2,3^ x i+1,j,4^ x i+1,j+1,5^ x i+1,j+2,6 )
Thus, if Proof of Cook-Levin (cont) F = (^i,j (f i,j,1^f i,j,2 ))^f ccept^f strt^f move then F is stisfible implies tht its stisfying ssignment represents n ccepting tbleu N hs n ccepting computtion on input w N ccepts w Conversely, if N ccepts w, there must be n ccepting computtion, nd F hs stisfying ssigment F is stisfible
Proof of Cook-Levin (cont) In summry, for ny w, we hve found Boolen formul F such tht N ccepts w F is stisfible Tht is, the construction of F gives reduction from deciding lnguge in NP to deciding whether formul is in SAT To show SAT is NP-complete, it remins to show tht the construction of F is done in polynomil time (in terms of the length of the input w)
Proof of Cook-Levin (cont) Given w of length n, f strt cn be constructed in O(n k ) time sub-formul^i,j (f i,j,1^f i,j,2 ), f ccept, f move cn be constructed in O(n 2k ) time (why??) Time to construct F = polynomil time Thus, ny lnguge in NP is polynomiltime reducible to SAT nd SAT is in NP SAT is NP-complete
Next Time More NP-complete problems