cs1010: theory of computation · theory of computation -fall'20 lorenzo de stefani 1 from...

31
CS1010: Theory of Computation Lorenzo De Stefani Fall 2020 Lecture 16: NP completeness

Upload: others

Post on 05-Mar-2021

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS1010: Theory of Computation · Theory of Computation -Fall'20 Lorenzo De Stefani 1 From SipserChapter 7. Polynomial Time Reducibility •If a problem A reduces to problem B, then

CS1010:TheoryofComputation

LorenzoDeStefaniFall2020

Lecture16:NPcompleteness

Page 2: CS1010: Theory of Computation · Theory of Computation -Fall'20 Lorenzo De Stefani 1 From SipserChapter 7. Polynomial Time Reducibility •If a problem A reduces to problem B, then

Outline

• PolynomialTimeReducibility• NP-HardProblems• NP-CompleteProblems• TheCook-LevinTheorem• SATand3SAT• ThecliqueproblemisNP-Hard

11/5/20 TheoryofComputation- Fall'20LorenzoDeStefani 1

FromSipser Chapter7

Page 3: CS1010: Theory of Computation · Theory of Computation -Fall'20 Lorenzo De Stefani 1 From SipserChapter 7. Polynomial Time Reducibility •If a problem A reduces to problem B, then

PolynomialTimeReducibility• IfaproblemAreducestoproblemB,thenasolutiontoBcanbeusedtosolveA– NotethatthismeansBisatleastashardasA

• Bcouldbeharderbutnoteasier.

• WhenproblemAisefficientlyreducibletoproblemB,anefficientsolutiontoBcanbeusedtosolveAefficiently– “Efficientlyreducible”meansinpolynomialtime– IfAispolytime reducibletoB,wecanconverttheproblemoftestingformembershipinAtoamembershiptestinB

– Ifonelanguageispolynomialtimereducibletoalanguagealreadyknowntohaveapolynomialtimesolution,thentheoriginallanguagewillhaveapolynomialtimesolution

11/5/20 TheoryofComputation- Fall'20LorenzoDeStefani 2

Page 4: CS1010: Theory of Computation · Theory of Computation -Fall'20 Lorenzo De Stefani 1 From SipserChapter 7. Polynomial Time Reducibility •If a problem A reduces to problem B, then

Definitionofpolytime reducibility

• Giventwolanguages𝐴, 𝐵 wesaythat𝐴 ispolynomiallyreducibleto𝐵,𝐴 ≤ 𝑝𝐵,iff thereexistsacomputablefunction𝑓 whichcanbecomputedinpolynomialtimesuchthatwehave

• Wecanchain polynomialtimereductions:– AssumeweshowthatAispolytime reducibletoB– NowweshowthatCispolytime reducibletoA– ClearlyCispolytime reducibletoB– Wecanbuildupalargeclassoflanguagessuchthatifoneofthelanguageshasapolynomialtimesolution,thenalldo

8x 2 ⌃⇤<latexit sha1_base64="aRseYAB8q6yYyy1UKbK8VepLbrg=">AAAB/nicbVDLSgMxFM34rPU1Kq7cBIsgLsrUio9d0Y3LivYBnbFk0kwbmmSGJCOWoeCvuHGhiFu/w51/Y2Y6iFoPBA7n3Ms9OX7EqNKO82nNzM7NLywWlorLK6tr6/bGZlOFscSkgUMWyraPFGFUkIammpF2JAniPiMtf3iR+q07IhUNxY0eRcTjqC9oQDHSRura224QSsQYvHepgO417XN0e9C1S07ZyQCnSSUnJZCj3rU/3F6IY06Exgwp1ak4kfYSJDXFjIyLbqxIhPAQ9UnHUIE4UV6SxR/DPaP0oMlhntAwU39uJIgrNeK+meRID9RfLxX/8zqxDk69hIoo1kTgyaEgZlCHMO0C9qgkWLORIQhLarJCPEASYW0aK2YlnKU4/v7yNGkelivVcvXqqFQ7z+sogB2wC/ZBBZyAGrgEddAAGCTgETyDF+vBerJerbfJ6IyV72yBX7DevwB9TZVQ</latexit>

x 2 A () f(x) 2 B<latexit sha1_base64="liDFg6KQbi0jMeRBN7pSZlzPhZM=">AAACAHicbVDLTgIxFL3jE/GFunDhppGY4IbMiPGxQ9y4xEQeCUxIp3SgodOZtB0DIWz8FTcuNMatn+HOv7EzEKPiSdqcnnNvbu/xIs6Utu1Pa2FxaXllNbOWXd/Y3NrO7ezWVRhLQmsk5KFselhRzgStaaY5bUaS4sDjtOENrhO/cU+lYqG406OIugHuCeYzgrWROrn9IWozga7M7fvILwyP03elk8vbRTsFmifOjORhhmon99HuhiQOqNCEY6Vajh1pd4ylZoTTSbYdKxphMsA92jJU4IAqd5wuMEFHRukiP5TmCI1S9WfHGAdKjQLPVAZY99VfLxH/81qx9i/cMRNRrKkg00F+zJEOUZIG6jJJieYjQzCRzPwVkT6WmGiTWTYN4TLB2ffK86R+UnRKxdLtab5cmcWRgQM4hAI4cA5luIEq1IDABB7hGV6sB+vJerXepqUL1qxnD37Bev8CquOUqQ==</latexit>

11/5/20 TheoryofComputation- Fall'20LorenzoDeStefani 3

Page 5: CS1010: Theory of Computation · Theory of Computation -Fall'20 Lorenzo De Stefani 1 From SipserChapter 7. Polynomial Time Reducibility •If a problem A reduces to problem B, then

NP-hardproblems

• GivenaproblemletAbeitscorrespondinglanguage

• AisNP-hard ifforanyLinNP,wehave L≤pA– ThismeansthatAisatleastashardasL– ThisholdsforanyLinNP,henceAisatleastashardasanyNPproblem

–WecoulduseasolutiontoAtosolveanyprobleminNP

–WearenotstatingAtobeitselfinNP!

11/5/20 TheoryofComputation- Fall'20LorenzoDeStefani 4

Page 6: CS1010: Theory of Computation · Theory of Computation -Fall'20 Lorenzo De Stefani 1 From SipserChapter 7. Polynomial Time Reducibility •If a problem A reduces to problem B, then

NP-CompletenessAnadvanceinPvs.NPcamein1970’s– CertainproblemsinNParerelatedtoalloftheentireclass

– Ifapolynomialtimealgorithmexistsforanyoftheseproblems,thenallproblemsinNPwouldbepolynomialtimesolvable (i.e.,thenP=NP)

– TheseproblemsarecalledNP-complete– AproblemisNPcompleteifisinNPanditisinNP-hard– TheyarethehardestproblemsinNP– IfanyNP-completeproblemhasapolytime solution,thensodoallproblemsinNP

11/5/20 TheoryofComputation- Fall'20LorenzoDeStefani 5

Page 7: CS1010: Theory of Computation · Theory of Computation -Fall'20 Lorenzo De Stefani 1 From SipserChapter 7. Polynomial Time Reducibility •If a problem A reduces to problem B, then

SignificanceofNPComplete

• TheoreticalimportanceofNP-complete– IfanyprobleminNPrequiresmorethanpolytime,thensodoallNP-completeproblems.

– IfanyNP-completeproblemhasapolytimesolution,thensodoallproblemsinNP

• PracticalimportanceofNP-Complete– Sincenopolytime solutionhasbeenfoundforanNP-completeproblem,ifwedetermineaproblemisNP-completeitisreasonabletogiveupfindingageneralpolytime solution

11/5/20 TheoryofComputation- Fall'20LorenzoDeStefani 6

Page 8: CS1010: Theory of Computation · Theory of Computation -Fall'20 Lorenzo De Stefani 1 From SipserChapter 7. Polynomial Time Reducibility •If a problem A reduces to problem B, then

Someobservations• IfBisNP-completeandBÎ P,thenP=NP• IfBisNP-completeandBispolytime reducibletoCforCinNP,

thenCisNP-complete– NotethatthisisusefulforprovingNP-completeness.– AllweneedtodoisshowthatalanguageisinNPandpolytime

reduciblefromanyknownNP-completeproblem• OnceweknowoneproblemtobeNP-complete,wemayobtain

othersbypolytime reductionfromit.– EstablishingthefirstNP-completeproblemisdifficult– TheCook-LevintheoremprovesthatSATisNP-complete

• IfanNP-completeproblemispolytime reducibletoaproblemX,thenXisNP-hard,sinceitisatleastashardastheNP-completeproblem,whichisthehardestclassofproblemsinNP.

11/5/20 TheoryofComputation- Fall'20LorenzoDeStefani 7

Page 9: CS1010: Theory of Computation · Theory of Computation -Fall'20 Lorenzo De Stefani 1 From SipserChapter 7. Polynomial Time Reducibility •If a problem A reduces to problem B, then

BackgroundforSatisfiabilityProblem

• BooleanvariablescantakeonvaluesofTRUEorFALSE(0or1)

• BooleanoperatorsareÙ (and),Ú (or)and¬ (not)• ABooleanformulaisanexpressionwithBoolean

variablesandoperators• ABooleanformulaissatisfiable ifsomeassignmentof

0sand1stothevariablesmakestheformulaevaluateto1(TRUE).• Example:(¬xÙ y)Ú (xÙ ¬z).

– Thisissatisfiable inseveralways,suchasx=0,y=1,z=0

11/5/20 TheoryofComputation- Fall'20LorenzoDeStefani 8

Page 10: CS1010: Theory of Computation · Theory of Computation -Fall'20 Lorenzo De Stefani 1 From SipserChapter 7. Polynomial Time Reducibility •If a problem A reduces to problem B, then

TheSATproblem

• GivenaBooleanformula,wewanttodecidewhetherthereexistsanassignmenttotheBooleanvariableswhichsatisfiestheformula𝑆𝐴𝑇 = {< 𝑥 > |𝑥𝑖𝑠𝑎𝑠𝑎𝑡𝑖𝑠𝑓𝑖𝑎𝑏𝑙𝑒𝐵𝑜𝑜𝑙𝑒𝑎𝑛𝑓𝑜𝑟𝑚𝑢𝑙𝑎}

• GivenaBooleanformula𝑥,solvingthesatisfiability problemcorrespondstodecidewhether𝑥 isinSAT

11/5/20 TheoryofComputation- Fall'20LorenzoDeStefani 9

Page 11: CS1010: Theory of Computation · Theory of Computation -Fall'20 Lorenzo De Stefani 1 From SipserChapter 7. Polynomial Time Reducibility •If a problem A reduces to problem B, then

Cook-LevinTheorem• TheCook-LevinTheoremlinksthecomplexityoftheSATproblemtothecomplexitiesofallproblemsinNP– SATisessentiallythehardestprobleminNPsinceifitissolvedinPthenallproblemsinNParesolvedinP

–WewillneedtoshowthatsolutiontoSATcanbeusedtosolveallproblemsinNP

• Theorem:SATÎ Piff P=NP

11/5/20 TheoryofComputation- Fall'20LorenzoDeStefani 10

Page 12: CS1010: Theory of Computation · Theory of Computation -Fall'20 Lorenzo De Stefani 1 From SipserChapter 7. Polynomial Time Reducibility •If a problem A reduces to problem B, then

Cook-LevinTheorem

• Theorem:SATisNP-Complete• Howtoproveit:

1. Prove2. ProveSATIsNP-hardthatis

…weneedtoprovethatanyprobleminNPcanbereducedtoSATinpolynomialtime!

SAT 2 NP<latexit sha1_base64="EehGa8ERaTg42AAz/sQ3SyzsWw0=">AAAB8XicbVDLSsNAFL2pr1pfVZduBovgqiQqPnZVN66kYl/YBplMJ+3QySTMTIQS+hduXCji1r9x5984SYOo9cDA4ZxzmXuPF3GmtG1/WoW5+YXFpeJyaWV1bX2jvLnVUmEsCW2SkIey42FFORO0qZnmtBNJigOP07Y3ukz99gOVioWioccRdQM8EMxnBGsj3d2eN1CPCXRdvy9X7KqdAc0SJycVyGHyH71+SOKACk04Vqrr2JF2Eyw1I5xOSr1Y0QiTER7QrqECB1S5SbbxBO0ZpY/8UJonNMrUnxMJDpQaB55JBlgP1V8vFf/zurH2T92EiSjWVJDpR37MkQ5Rej7qM0mJ5mNDMJHM7IrIEEtMtCmplJVwluL4++RZ0jqoOofVw5ujSu0ir6MIO7AL++DACdTgCurQBAICHuEZXixlPVmv1ts0WrDymW34Bev9CyRykA4=</latexit>

8L 2 NP, L p SAT<latexit sha1_base64="udZSG4Id6/cRPL+H8jDdYRSZrYI=">AAACBnicbZDLSsNAFIYnXmu9RV2KMFgEF1JSK152VTcuRCr2Bk0Ik+m0HTqZxJmJUEJXbnwVNy4UceszuPNtnKRB1PrDwMd/zmHO+b2QUaks69OYmp6ZnZvPLeQXl5ZXVs219YYMIoFJHQcsEC0PScIoJ3VFFSOtUBDke4w0vcF5Um/eESFpwGtqGBLHRz1OuxQjpS3X3LK7gUCMwUubcnhV3bM1MXLrhvDmtOaaBatopYKTUMqgADJVXfPD7gQ48glXmCEp2yUrVE6MhKKYkVHejiQJER6gHmlr5Mgn0onTM0ZwRzsdqPfRjyuYuj8nYuRLOfQ93ekj1Zd/a4n5X60dqe6xE1MeRopwPP6oGzGoAphkAjtUEKzYUAPCgupdIe4jgbDSyeXTEE4SHX6fPAmN/WKpXCxfHxQqZ1kcObAJtsEuKIEjUAEXoArqAIN78AiewYvxYDwZr8bbuHXKyGY2wC8Z71/1MJem</latexit>

11/5/20 TheoryofComputation- Fall'20LorenzoDeStefani 11

Page 13: CS1010: Theory of Computation · Theory of Computation -Fall'20 Lorenzo De Stefani 1 From SipserChapter 7. Polynomial Time Reducibility •If a problem A reduces to problem B, then

ConsideraNTMN:– Oninputx(a1,a2,…ai),wherex()denotesaboolean expressioninthevariablesa1,a2,…an

– Non-deterministicallyselectatruthassignmentfora1,a2,…an

– Evaluatex forthisassigment:• AcceptifitevaluatestoTrue• Rejectotherwise

SAT 2 NP<latexit sha1_base64="EehGa8ERaTg42AAz/sQ3SyzsWw0=">AAAB8XicbVDLSsNAFL2pr1pfVZduBovgqiQqPnZVN66kYl/YBplMJ+3QySTMTIQS+hduXCji1r9x5984SYOo9cDA4ZxzmXuPF3GmtG1/WoW5+YXFpeJyaWV1bX2jvLnVUmEsCW2SkIey42FFORO0qZnmtBNJigOP07Y3ukz99gOVioWioccRdQM8EMxnBGsj3d2eN1CPCXRdvy9X7KqdAc0SJycVyGHyH71+SOKACk04Vqrr2JF2Eyw1I5xOSr1Y0QiTER7QrqECB1S5SbbxBO0ZpY/8UJonNMrUnxMJDpQaB55JBlgP1V8vFf/zurH2T92EiSjWVJDpR37MkQ5Rej7qM0mJ5mNDMJHM7IrIEEtMtCmplJVwluL4++RZ0jqoOofVw5ujSu0ir6MIO7AL++DACdTgCurQBAICHuEZXixlPVmv1ts0WrDymW34Bev9CyRykA4=</latexit>

11/5/20 TheoryofComputation- Fall'20LorenzoDeStefani 12

Page 14: CS1010: Theory of Computation · Theory of Computation -Fall'20 Lorenzo De Stefani 1 From SipserChapter 7. Polynomial Time Reducibility •If a problem A reduces to problem B, then

AnalysisofN:– Runtime:eachbranchrunsintimen• Hence,polynomial(linear)inthenumberofvariableswhichcorrespondstothesizeoftheinput

– Correctness:ifx isinSATthenatleastonebranchwillaccept• Ifx isnotinSATnoassignmentofthevariableswillbesuchthatx willevaluatetrue

SAT 2 NP<latexit sha1_base64="EehGa8ERaTg42AAz/sQ3SyzsWw0=">AAAB8XicbVDLSsNAFL2pr1pfVZduBovgqiQqPnZVN66kYl/YBplMJ+3QySTMTIQS+hduXCji1r9x5984SYOo9cDA4ZxzmXuPF3GmtG1/WoW5+YXFpeJyaWV1bX2jvLnVUmEsCW2SkIey42FFORO0qZnmtBNJigOP07Y3ukz99gOVioWioccRdQM8EMxnBGsj3d2eN1CPCXRdvy9X7KqdAc0SJycVyGHyH71+SOKACk04Vqrr2JF2Eyw1I5xOSr1Y0QiTER7QrqECB1S5SbbxBO0ZpY/8UJonNMrUnxMJDpQaB55JBlgP1V8vFf/zurH2T92EiSjWVJDpR37MkQ5Rej7qM0mJ5mNDMJHM7IrIEEtMtCmplJVwluL4++RZ0jqoOofVw5ujSu0ir6MIO7AL++DACdTgCurQBAICHuEZXixlPVmv1ts0WrDymW34Bev9CyRykA4=</latexit>

11/5/20 TheoryofComputation- Fall'20LorenzoDeStefani 13

Page 15: CS1010: Theory of Computation · Theory of Computation -Fall'20 Lorenzo De Stefani 1 From SipserChapter 7. Polynomial Time Reducibility •If a problem A reduces to problem B, then

SATisNP-hard

• Weneedtoshowthatany𝐿 ∈ 𝑁𝑃 ispolynomially reducibe toSAT(i.e.,𝐿 ≤@ 𝑆𝐴𝑇)

• GOAL:Weneedtoconstructapolynomialtimereduction suchthatforany𝐿 ∈ 𝑁𝑃andgivenanypossibleword𝑤 ∈ Σ∗constructsinaboolean formula𝜙 suchthat

𝑤 ∈ 𝐿⇔𝜙 ∈ 𝑆𝐴𝑇

i.e.,𝜙 issatisfiable iff 𝑤 ∈ 𝐿.

11/5/20 TheoryofComputation- Fall'20LorenzoDeStefani 14

Page 16: CS1010: Theory of Computation · Theory of Computation -Fall'20 Lorenzo De Stefani 1 From SipserChapter 7. Polynomial Time Reducibility •If a problem A reduces to problem B, then

• Forany𝐿 ∈ 𝑁𝑃, letNbeaNon-deterministicTuringmachinesuchthat𝐿 𝑁 = 𝐿 whichrunsinnon-deterministicpolynomialtime

• Givenanypossibleword𝑤 ∈ Σ∗ wehavethat𝑤 ∈ 𝐿 ifandonlyifthereexistoneacceptingcomputationalhistoryofNforoninputw

11/5/20 TheoryofComputation- Fall'20LorenzoDeStefani 15

SATisNP-hard

• Aconfiguration isgivenby:state,positionoftheheadand,symbolsonthetape:

qstart0 11000#011000- -xq1 1 1000#011000- -

…X11000#qrevX 11000- -qrev2X 11000#X11000- -xxq1 1 000#X11000- -

…XXXXXX#XXXXXX- -

Page 17: CS1010: Theory of Computation · Theory of Computation -Fall'20 Lorenzo De Stefani 1 From SipserChapter 7. Polynomial Time Reducibility •If a problem A reduces to problem B, then

11/5/20 TheoryofComputation- Fall'20LorenzoDeStefani 16

SATisNP-hard• Anacceptingconfigurationhasthefollowingproperties:

qstart0 11000#011000- -xq1 1 1000#011000- -

…X11000#qrevX 11000- -XXXXXX#XXXXXX-qaccept –

– Firstconfigurationmustbethestartingconfiguration– Lastconfigurationmustbeaccepting– Alltransitionsmustbevalid– Since,byassumption,Nrunsintimep(n)polynomialinn

• Atmostp(n)+1configurationsinthehistory• Inanyconfigurationatmostp(n)spacesofthetapearebeingused

Page 18: CS1010: Theory of Computation · Theory of Computation -Fall'20 Lorenzo De Stefani 1 From SipserChapter 7. Polynomial Time Reducibility •If a problem A reduces to problem B, then

11/5/20 TheoryofComputation- Fall'20LorenzoDeStefani 17

SATisNP-hard• Wecanrepresentthecomputationhistoryasatableau:

#qstart0 11000#011000- -##xq1 1 1000#011000- - #

…#X11000#qrevX 11000- - ##XXXXX#XXXXXX–qaccept #

– xi,j,s denotesthefactthatthesymbolsisthecontentofthecellonthei-th rowandj-th column

– p(n)+1rows– p(n)+3columns:thep(n)spacesusedatmost+2#’sandthe

state– Bydefinitionwehave:

w 2 L () 9a valid accepting tableau ofN on w<latexit sha1_base64="LtfGSG5SjmMKrtVOM0c6Rr82hBA=">AAACLXicbVDLShxBFK3WJOrkNerSzSVDIKuhJ0rUnWgWLkQMZFSYHobbNbfHwuqqpuq2OjTzQ27yKyHgQhG3/oY1D0ISc6DgcM591D1poZXnOL6N5uZfvHy1sLhUe/3m7bv39eWVY29LJ6ktrbbuNEVPWhlqs2JNp4UjzFNNJ+n53tg/uSDnlTXfeVhQN8eBUZmSyEHq1b9eJsrAASQqyxK6Cgs9JExXXCFcoFZ9QCmpYGUGwBimYgk2Gx1Oa8AaGF1Cr96Im/EE8Jy0ZqQhZjjq1X8lfSvLnAxLjd53WnHB3QodK6lpVEtKTwXKcxxQJ1CDOfluNbl2BB+D0ofMuvAMw0T9s6PC3PthnobKHPnM/+uNxf95nZKzrW6lTFEyGTldlJUa2MI4OugrR5L1MBCUToW/gjxDh5JDwLVJCNtjfPl98nNy/LnZWm+uf9to7OzO4lgUa+KD+CRaYlPsiH1xJNpCimvxU9yKu+hHdBPdRw/T0rlo1rMq/kL0+ARZOqjz</latexit>

Page 19: CS1010: Theory of Computation · Theory of Computation -Fall'20 Lorenzo De Stefani 1 From SipserChapter 7. Polynomial Time Reducibility •If a problem A reduces to problem B, then

11/5/20 TheoryofComputation- Fall'20LorenzoDeStefani 18

SATisNP-hard

Weconstructthefollowingboolean expression:

• takesvaluetrueifallthecellsofthetableauassumeasinglesymbolfromeitherthetapealphabet,#,andthestates

• takesvaluetrueifthesymbolsonthefirstlineofthetableaucorrespondtotheinitialconfigurationoftheNTM

• takesvaluetrueifqaccept appearsinthetableau• takesvaluetrueifallthetransitionsinthe

computationhistorycorrespondingtothetableauarevalid

↵ = ↵cell ^ ↵start ^ ↵accept ^ ↵move<latexit sha1_base64="pNSmNmaSjKJrxDDkxhRuAcgVl1E=">AAACTXicbVFJSwMxGM3UpbVuVY9egkXwVKZWXA5C0YvHCnaBTimZzNc2NDMZkkylDP2DXgRv/gsvHhQR0+ng1j4IPN77luTFDTlT2rafrczS8spqNreWX9/Y3Nou7Ow2lIgkhToVXMiWSxRwFkBdM82hFUogvsuh6Q6vp35zBFIxEdzpcQgdn/QD1mOUaCN1C54jFCdqgC9xyroxBc4n2LkHrw/4R1aaSD3B8wahFMKFji9GYPRuoWiX7AR4npRTUkQpat3Ck+MJGvkQaGomqXbZDnUnNvsZ5TDJO5GCkNAh6UPb0ID4oDpxksYEHxrFwz0hzQk0TtTfHTHxlRr7rqn0iR6o/95UXOS1I90778QsCCMNAZ0t6kUca4Gn0WKPSaCajw0hVDJzV0wHRBKqzQfkkxAupjj9fvI8aRyXypVS5fakWL1K48ihfXSAjlAZnaEqukE1VEcUPaAX9IberUfr1fqwPmelGSvt2UN/kMl+AbxTtO8=</latexit>

↵cell<latexit sha1_base64="g9M0EZkTIgaF8/CPaGV6Lhg1n+A=">AAAB9XicbVDLSgMxFL1TX7W+qi7dBIvgqsyo+NgV3bisYB/QjiWTZtrQTDIkGaUM/Q83LhRx67+482/MtIOo9cCFwzn3JveeIOZMG9f9dAoLi0vLK8XV0tr6xuZWeXunqWWiCG0QyaVqB1hTzgRtGGY4bceK4ijgtBWMrjK/dU+VZlLcmnFM/QgPBAsZwcZKd12pOdbDXkoo55NeueJW3SnQPPFyUoEc9V75o9uXJImoMMS+ozueGxs/xcowwumk1E00jTEZ4QHtWCpwRLWfTreeoAOr9FEolS1h0FT9OZHiSOtxFNjOCJuh/utl4n9eJzHhuZ8yESeGCjL7KEw4MhJlEaA+U5QYPrYEE8XsrogMscLE2KBK0xAuMpx+nzxPmkdV77h6fHNSqV3mcRRhD/bhEDw4gxpcQx0aQEDBIzzDi/PgPDmvztusteDkM7vwC877FzJskxo=</latexit>

↵start<latexit sha1_base64="SpRyeMs15d0y8XoWAaYwXFFOLc0=">AAAB+HicbVDLSsNAFL2pr1ofjbp0M1gEVyVR8bErunFZwT6gDWEynbZDJ5MwMxFq6Je4caGIWz/FnX/jJA2i1gMDh3Pua04Qc6a043xapaXlldW18nplY3Nru2rv7LZVlEhCWyTikewGWFHOBG1ppjntxpLiMOC0E0yuM79zT6VikbjT05h6IR4JNmQEayP5drUfKY7V2E+VxlLPfLvm1J0caJG4BalBgaZvf/QHEUlCKjQxg1TPdWLtpWYWI5zOKv1E0RiTCR7RnqECh1R5aX74DB0aZYCGkTRPaJSrPztSHCo1DQNTGWI9Vn+9TPzP6yV6eOGlTMSJpoLMFw0TjnSEshTQgElKNJ8agolk5lZExlhiok1WlTyEywxn319eJO3juntSP7k9rTWuijjKsA8HcAQunEMDbqAJLSCQwCM8w4v1YD1Zr9bbvLRkFT178AvW+xessZPj</latexit>

↵accept<latexit sha1_base64="7wrD4tEDbtvmdBBxKCjXZ7w0+G0=">AAAB+XicbVDLSsNAFL2pr1pfUZdugkVwVVIrPnZFNy4r2Ae0IUymk3boZCbMTAol9E/cuFDErX/izr9xkgZR64ELh3Punbn3BDGjSrvup1VaWV1b3yhvVra2d3b37P2DjhKJxKSNBROyFyBFGOWkralmpBdLgqKAkW4wuc387pRIRQV/0LOYeBEacRpSjLSRfNseCMWQGvspwpjEeu7bVbfm5nCWSb0gVSjQ8u2PwVDgJCJcY/OS6tfdWHspkppiRuaVQaJIjPAEjUjfUI4iorw033zunBhl6IRCmuLaydWfEymKlJpFgemMkB6rv14m/uf1Ex1eeSnlcaIJx4uPwoQ5WjhZDM6QSoI1mxmCsKRmVwePkURYm7AqeQjXGS6+T14mnbNavVFr3J9XmzdFHGU4gmM4hTpcQhPuoAVtwDCFR3iGFyu1nqxX623RWrKKmUP4Bev9CzthlC8=</latexit>

↵move<latexit sha1_base64="l3AAhQRAypKqhuiOtsb6smsDCSE=">AAAB9XicbVDLSgMxFM3UV62vqks3wSK4KjNWfOyKblxWsA9ox5JJM21oHkOSqZSh/+HGhSJu/Rd3/o2Z6SBqPXDhcM69yb0niBjVxnU/ncLS8srqWnG9tLG5tb1T3t1raRkrTJpYMqk6AdKEUUGahhpGOpEiiAeMtIPxdeq3J0RpKsWdmUbE52goaEgxMla670nNkB71Ey4nZNYvV9yqmwEuEi8nFZCj0S9/9AYSx5wIg+07uuu5kfETpAzFjMxKvViTCOExGpKupQJxov0k23oGj6wygKFUtoSBmfpzIkFc6ykPbCdHZqT/eqn4n9eNTXjhJ1REsSECzz8KYwaNhGkEcEAVwYZNLUFYUbsrxCOkEDY2qFIWwmWKs++TF0nrpOrVqrXb00r9Ko+jCA7AITgGHjgHdXADGqAJMFDgETyDF+fBeXJenbd5a8HJZ/bBLzjvX1WbkzE=</latexit>

Page 20: CS1010: Theory of Computation · Theory of Computation -Fall'20 Lorenzo De Stefani 1 From SipserChapter 7. Polynomial Time Reducibility •If a problem A reduces to problem B, then

11/5/20 TheoryofComputation- Fall'20LorenzoDeStefani 19

SATisNP-hard

• TheconstructionofsuchBooleanexpressioncanbeaccomplishedinpolynomialtime

• WeconstructedapolynomialtimereductionfromthemembershipproblemforanylanguageLtotheSATproblem

• Hence,wecanconcludethat SATisatleastashardasanyproblemLfromNP

• Thus,asolutiontoSATcanbeusedtosolveanyproblemLfromNP

• WecanconcludethatSATisNP-Hard

Page 21: CS1010: Theory of Computation · Theory of Computation -Fall'20 Lorenzo De Stefani 1 From SipserChapter 7. Polynomial Time Reducibility •If a problem A reduces to problem B, then

3SAT3SATisaspecialcaseofthesatisfiability problem– Aclause isagroupBooleanvariablesconnectedonlywithor’s(Ú’s)

– ABooleanformulaisinconjunctivenormalform(cnf)ifithasonlyclauses connectedbyand’s(Ù’s)

– A3cnfformulahas3Booleanvariablesinallclauses– Example:

• (x1Ú ¬x2Ú ¬ x3)Ù (x3Ú ¬ x5Ú x6)Ù (x3Ú ¬ x6Ú x4)Ù (x4Ú x5Ú x6)– Let3SATbethelanguageof3cnfformulasthataresatisfiable

• Thismeansthateachclausemusthaveatleastoneliteralwithavalueof1

–Wewanttoprovethat3SATisNP-Complete

11/5/20 TheoryofComputation- Fall'20LorenzoDeStefani 20

Page 22: CS1010: Theory of Computation · Theory of Computation -Fall'20 Lorenzo De Stefani 1 From SipserChapter 7. Polynomial Time Reducibility •If a problem A reduces to problem B, then

3SATisNP-Complete• ThesamesolutionforSATusingNTMwillalsoworkfor3SATà 3SATisinNP

• Weneedtoshowthat3SATisNP-hard–Wesetupapolynomialreduction– Considerthepreviousexpresion:

– Canwetransformitina3cnfinpolynomialtime?– Fromthedetailsoftheproofwehavethatallthecomponentsarealreadyincnf

– Howcanwetransformitintoa3cnf

↵ = ↵cell ^ ↵start ^ ↵accept ^ ↵move<latexit sha1_base64="pNSmNmaSjKJrxDDkxhRuAcgVl1E=">AAACTXicbVFJSwMxGM3UpbVuVY9egkXwVKZWXA5C0YvHCnaBTimZzNc2NDMZkkylDP2DXgRv/gsvHhQR0+ng1j4IPN77luTFDTlT2rafrczS8spqNreWX9/Y3Nou7Ow2lIgkhToVXMiWSxRwFkBdM82hFUogvsuh6Q6vp35zBFIxEdzpcQgdn/QD1mOUaCN1C54jFCdqgC9xyroxBc4n2LkHrw/4R1aaSD3B8wahFMKFji9GYPRuoWiX7AR4npRTUkQpat3Ck+MJGvkQaGomqXbZDnUnNvsZ5TDJO5GCkNAh6UPb0ID4oDpxksYEHxrFwz0hzQk0TtTfHTHxlRr7rqn0iR6o/95UXOS1I90778QsCCMNAZ0t6kUca4Gn0WKPSaCajw0hVDJzV0wHRBKqzQfkkxAupjj9fvI8aRyXypVS5fakWL1K48ihfXSAjlAZnaEqukE1VEcUPaAX9IberUfr1fqwPmelGSvt2UN/kMl+AbxTtO8=</latexit>

11/5/20 TheoryofComputation- Fall'20LorenzoDeStefani 21

Page 23: CS1010: Theory of Computation · Theory of Computation -Fall'20 Lorenzo De Stefani 1 From SipserChapter 7. Polynomial Time Reducibility •If a problem A reduces to problem B, then

3SATisNP-Complete• Aboolean expressionincnf willbeaconjunction(and)ofmultipledisjunctiveclauses(or’s)– Ifonesuchclausehaslessthan3variables,justaddonenewvariableneverusedbefore• Atmost2nvariableswillbeaddedthisway

– Ifonesuchclausehasmorethan3variableswebreakitdownbyaddingnewBooleanvariables• Forexample x1 _ x2 _ x3 _ x4

<latexit sha1_base64="EKCbqoeX7TgmD8VbrdA3aWQqs1s=">AAACBHicbVDLSsNAFJ34rPUVddnNYBFclaQtPnZFNy4r2Ae0IUymN+3QyYOZSWkJXbjxV9y4UMStH+HOvzFJg6j1wHAP59zLnXuckDOpDONTW1ldW9/YLGwVt3d29/b1g8O2DCJBoUUDHoiuQyRw5kNLMcWhGwognsOh44yvU78zASFZ4N+pWQiWR4Y+cxklKpFsvTS1zf4EAE/tal5rea3betmoGBnwMjFzUkY5mrb+0R8ENPLAV5QTKXumESorJkIxymFe7EcSQkLHZAi9hPrEA2nF2RFzfJIoA+wGInm+wpn6cyImnpQzz0k6PaJG8q+Xiv95vUi5F1bM/DBS4NPFIjfiWAU4TQQPmACq+CwhhAqW/BXTERGEqiS3YhbCZYqz75OXSbtaMWuV2m293LjK4yigEjpGp8hE56iBblATtRBF9+gRPaMX7UF70l61t0XripbPHKFf0N6/AC2cl0o=</latexit>

(x1 _ x2 _ z) ^ (z̄ _ x3 _ x4)<latexit sha1_base64="9wbXXbNc7q0jWJFYSkj7Yf5S/4w=">AAACG3icbVDLTsJAFJ3iC/GFunQzkZjAhrRAfOyIblxiIo+EkmY6XGDC9JGZKQIN/+HGX3HjQmNcmbjwbyylMSqeZHJPzrk3d+6xfc6k0vVPLbWyura+kd7MbG3v7O5l9w8a0gsEhTr1uCdaNpHAmQt1xRSHli+AODaHpj28mvvNEQjJPPdWTXzoOKTvsh6jREWSlS3lx5ZhjgDw2CrFdVow76Dbh7xpExFOZ4lZTmqlYGVzelGPgZeJkZAcSlCzsu9m16OBA66inEjZNnRfdUIiFKMcZhkzkOATOiR9aEfUJQ7IThjfNsMnkdLFPU9Ez1U4Vn9OhMSRcuLYUadD1ED+9ebif147UL3zTshcP1Dg0sWiXsCx8vA8KNxlAqjik4gQKlj0V0wHRBCqojgzcQgXc5x+n7xMGqWiUS6Wbyq56mUSRxodoWOURwY6Q1V0jWqojii6R4/oGb1oD9qT9qq9LVpTWjJziH5B+/gCQdagcw==</latexit>

11/5/20 TheoryofComputation- Fall'20LorenzoDeStefani 22

Page 24: CS1010: Theory of Computation · Theory of Computation -Fall'20 Lorenzo De Stefani 1 From SipserChapter 7. Polynomial Time Reducibility •If a problem A reduces to problem B, then

3SATisNP-Complete• Suchtransformationscanbeexecutedinpolynomial(linear)timewithrespecttothenumberofBooleanvariablesintheoriginalexpression

• Wehaveavalid,polynomialtimereductionfromSATto3-SAT

• Wecanconcludethat3SATisNP-Hardand,hence,NP-Complete

• Somedetailsaremissinghere.Inthefutureyoucanassumethat3SATisNP-CompleteinyourProofs

11/5/20 TheoryofComputation- Fall'20LorenzoDeStefani 23

Page 25: CS1010: Theory of Computation · Theory of Computation -Fall'20 Lorenzo De Stefani 1 From SipserChapter 7. Polynomial Time Reducibility •If a problem A reduces to problem B, then

TheCliqueProblem

Thecliqueproblemistodeterminewhetheragraphcontainsacliqueofaspecifiedsize– CLIQUE:{<G,k>|Gisanundirectedgraphwithak-clique}

– Notethatkisaparameter.Thustheproblemofdecidingwhetherthereisa3-cliqueora10-cliqueisnottheCLIQUEproblem

– ThisisimportantbecausewewillseethatCLIQUEisNP-complete

11/5/20 24TheoryofComputation- Fall'20LorenzoDeStefani

Page 26: CS1010: Theory of Computation · Theory of Computation -Fall'20 Lorenzo De Stefani 1 From SipserChapter 7. Polynomial Time Reducibility •If a problem A reduces to problem B, then

ProvingCLIQUENP-complete• LetusapplyarecipeforprovingNP-Completeness• ToproveCLIQUEisNP-completeweneedtoshow:

– Step1:CLIQUEisinNP– Step2:AnNP-Completeproblemispolytime reducibletoit

• ThebookprovedSATisNP-completeandalsothat3SATisNP-complete,sowecanjustuse3SAT

• Weneedtoprovethat3-SATispolytime reducibletoCLIQUE– Wealreadydidthis!

• Step1:CLIQUEisinNPbecauseitscertificatecaneasilybecheckedinpolytime– Givenacertificate,weneedtocheckthatthereisanedgebetweenallk

nodesintheclique– Simplylookateachnodeinturnanmakesureithasanedgetoeachof

thek-1othernodes.ClearlythisisO(n2)atworst(assumingk=n).• WhentryingtoproveaproblemNP-complete,youcan“use”

anyproblemyouknowisalreadyNP-complete

11/5/20 TheoryofComputation- Fall'20LorenzoDeStefani 25

Page 27: CS1010: Theory of Computation · Theory of Computation -Fall'20 Lorenzo De Stefani 1 From SipserChapter 7. Polynomial Time Reducibility •If a problem A reduces to problem B, then

Polytime Reductionfrom3SATtoCLIQUE

• ProofIdea:convertany3SATformulatoagraph,suchthatacliqueofthespecifiedsizecorrespondstosatisfyingassignmentsoftheformula– Constructapolynomialtimereductionfrom3SATtoCLIQUEwhichmapsany< 𝐺, 𝑘 > toabooleanformula𝜙 suchthat

< 𝐺, 𝑘 >∈ 𝐶𝐿𝐼𝑄𝑈𝐸⇔𝜙 ∈ 3 − 𝑆𝐴𝑇

– Thestructureofthegraphmustmimicthebehaviorofthevariablesintheclauses

11/5/20 TheoryofComputation- Fall'20LorenzoDeStefani 26

Page 28: CS1010: Theory of Computation · Theory of Computation -Fall'20 Lorenzo De Stefani 1 From SipserChapter 7. Polynomial Time Reducibility •If a problem A reduces to problem B, then

PolytimeReductionProcedureGivena3SATformulacreateagraphG– ThenodesinGareorganizedintokgroupsofthreenodes(triples)calledt1,…,tk

– EachtriplecorrespondstooneoftheclausesintheformulaandeachnodeinthetripleislabeledwithaBooleanvariableintheclause

– TheedgesinGconnectallbuttwotypesofpairsofnodesinG• Noedgeisbetweennodesinthesametriple• Noedgeispresentbetweennodeswithcontradictorylabels(e.g.,x1and¬x1)

11/5/20 TheoryofComputation- Fall'20LorenzoDeStefani 27

Page 29: CS1010: Theory of Computation · Theory of Computation -Fall'20 Lorenzo De Stefani 1 From SipserChapter 7. Polynomial Time Reducibility •If a problem A reduces to problem B, then

TheReductionof3SATtoCLIQUE

Formulaissatisfiableifgraphhasak-clique(k=3forthe3clauses)

IfCLIQUEsolvableinpolytime sois3SAT

11/5/20 TheoryofComputation- Fall'20LorenzoDeStefani 28

Page 30: CS1010: Theory of Computation · Theory of Computation -Fall'20 Lorenzo De Stefani 1 From SipserChapter 7. Polynomial Time Reducibility •If a problem A reduces to problem B, then

Whydoesthisreductionwork?Thesatisfiability problemrequiresthateachclausehasatleastonevaluethatevaluatestotrue– IneachtripleinGweselectonenodecorrespondingtoatrueliteralinthesatisfyingassignment• Ifmorethanoneistrueinaclause,arbitrarilychooseone• Thenodesjustselectedwillformak-clique

– Thenumberofnodesselectedisk,sincekclauses– Everypairofnodeswillbeconnectedbyanedgebecausetheydonotviolateoneofthe2conditionsfornothavinganedge

– Thisshowsthatifthe3cnfformulaissatisfiable,thentherewillbeak-clique

– Theargumenttheotherwayisessentiallythesame• Ifk-cliquethenallindifferentclausesandhencewillbesatisfiable,sinceanylogicallyinconsistentassignmentsarenotrepresentedinG

11/5/20 TheoryofComputation- Fall'20LorenzoDeStefani 29

Page 31: CS1010: Theory of Computation · Theory of Computation -Fall'20 Lorenzo De Stefani 1 From SipserChapter 7. Polynomial Time Reducibility •If a problem A reduces to problem B, then

ChallengesinprovingNP-Completeness

Thehardpartisalwayscomingupwiththepolynomialtimereduction– Experienceandseeinglotsofproblemscanhelp– Followtherecipeandpatternsoftheexamples– Chapter7.5hasseveralexamples.Allareharderthanthereductionof3SATtoCLIQUE

– YouneedtobeabletoarguethatCLIQUEisNP-Completebyreductionto3SAT

– Asafirstsimpleexercise,arguethatCLIQUEisNP-CompletebyreductiontoSAT,withoutrelyingon3𝑆𝐴𝑇 ≤@ 𝑆𝐴𝑇

11/5/20 TheoryofComputation- Fall'20LorenzoDeStefani 30