# February 6, 2015CS21 Lecture 141 CS21 Decidability and Tractability Lecture 14 February 6, 2015.

## Presentation on theme: "February 6, 2015CS21 Lecture 141 CS21 Decidability and Tractability Lecture 14 February 6, 2015."— Presentation transcript:

February 6, 2015CS21 Lecture 141 CS21 Decidability and Tractability Lecture 14 February 6, 2015

CS21 Lecture 142 Outline undecidable problems –computation histories –surprising contrasts between decidable/undecidable Rice’s Theorem Post Correspondence problem

February 6, 2015CS21 Lecture 143 Definition of reduction More refined notion of reduction: –“many-one” reduction (commonly) –“mapping” reduction (book) yes no yes no AB reduction from language A to language B f f

February 6, 2015CS21 Lecture 144 Definition of reduction function f should be computable Definition: f : Σ*→ Σ* is computable if there exists a TM M f such that on every w  Σ* M f halts on w with f(w) written on its tape. yes no yes no AB f f

February 6, 2015CS21 Lecture 145 Dec. and undec. problems two problems regarding Context-Free Grammars: –does a CFG generate all strings: ALL CFG = { : G is a CFG and L(G) = Σ*} –CFG emptiness: E CFG = { : G is a CFG and L(G) = Ø} Both decidable? both undecidable? one decidable?

February 6, 2015CS21 Lecture 146 Dec. and undec. problems Theorem: E CFG is decidable. Proof: –observation: for each nonterminal A, the set S A = {w : A  * w} is non-empty iff there is some rule: A → x and  non-terminals B in string x, S B  Ø

February 6, 2015CS21 Lecture 147 Dec. and undec. problems Proof: –on input –mark all terminals in G –repeat until no new non-terminals get marked: if there is a production A→x 1 x 2 x 3 …x k and each symbol x 1, x 2, …, x k has been marked then mark A –if S marked, reject (G  E CFG ), else accept (G 2 E CFG ). –terminates? correct?

February 6, 2015CS21 Lecture 148 Dec. and undec. problems Theorem: ALL CFG is undecidable. Proof: –reduce from co-A TM ( i.e. show co-A TM ≤ m ALL CFG ) –what should f( ) produce? –Idea: produce CFG G that generates all strings that are not accepting computation histories of M on w

February 6, 2015CS21 Lecture 149 Dec. and undec. problems Proof: –build a NPDA, then convert to CFG –want to accept strings not of this form, #C 1 #C 2 #C 3 #...#C k # plus strings of this form but where C 1 is not the start config. of M on input w, or C k is not an accept. config. of M on input w, or C i does not yield in one step C i+1 for some i

February 6, 2015CS21 Lecture 1410 Dec. and undec. problems Proof: –our NPDA nondeterministically checks one of: C 1 is not the start config. of M on input w, or C k is not an accept. config. of M on input w, or C i does not yield in one step C i+1 for some i input has fewer than two #’s –details of first two? –to check third condition: nondeterministically guess C i starting position how to check that C i doesn’t yield in 1 step C i+1 ?

February 6, 2015CS21 Lecture 1411 Dec. and undec. problems Proof: –checking: C i does not yield in one step C i+1 for some i –push C i onto stack –at #, start popping C i and compare to C i+1 accept if mismatch away from head location, or symbols around head changed in a way inconsistent with M’s transition function. –is everything described possible with NPDA?

February 6, 2015CS21 Lecture 1412 Dec. and undec. problems Proof: –Problem: cannot compare C i to C i+1 –could prove in same way that proved {ww: w  Σ*} not context-free –recall that {ww R : w  Σ*} is context-free –free to tweak construction of G in the reduction –solution: write computation history: #C 1 #C 2 R #C 3 #C 4 R...#C k #

February 6, 2015CS21 Lecture 1413 Dec. and undec. problems Proof: –f( ) = equiv. to NPDA below: on input x, accept if not of form: #C 1 #C 2 R #C 3 #C 4 R...#C k # accept if C 1 is the not the start configuration for M on input w accept if check that C i does not yield in one step C i+1 accept if C k is not an accepting configuration for M is f computable? YES maps to YES?  co-A TM  f(M, w)  ALL CFG NO maps to NO?  co-A TM  f(M, w)  ALL CFG

February 6, 2015CS21 Lecture 1414 Rice’s Theorem We have seen that the following properties of TM’s are undecidable: –TM accepts string w –TM halts on input w –TM accepts the empty language –TM accepts a regular language Can we describe a single generic reduction for all these proofs? Yes. Every property of TMs undecidable!

February 6, 2015CS21 Lecture 1415 Rice’s Theorem A TM property is a language P for which –if L(M 1 ) = L(M 2 ) then  P iff  P TM property P is nontrivial if –there exists a TM M 1 for which  P, and –there exists a TM M 2 for which  P. Rice’s Theorem: Every nontrivial TM property is undecidable.

February 6, 2015CS21 Lecture 1416 Rice’s Theorem The setup: –let T Ø be a TM for which L(T Ø ) = Ø technicality: if  P then work with property co-P instead of P. conclude co-P undecidable; therefore P undec. due to closure under complement –so, WLOG, assume  P –non-triviality ensures existence of TM M 1 such that  P

February 6, 2015CS21 Lecture 1417 Rice’s Theorem Proof: –reduce from A TM (i.e. show A TM ≤ m P) –what should f( ) produce? –f( ) = described below: on input x, accept iff M accepts w and M 1 accepts x (intersection of two RE languages) f computable? YES maps to YES?  A TM  L(f(M, w)) = L(M 1 )  f(M, w)  P

February 6, 2015CS21 Lecture 1418 Rice’s Theorem Proof: –reduce from A TM (i.e. show A TM ≤ m P) –what should f( ) produce? –f( ) = described below: on input x, accept iff M accepts w and M 1 accepts x (intersection of two RE languages) NO maps to NO?  A TM  L(f(M, w)) = L(T Ø )  f(M, w)  P

February 6, 2015CS21 Lecture 1419 Post Correspondence Problem many undecidable problems unrelated to TMs and automata classic example: Post Correspondence Problem PCP = { : x i, y i  Σ* and there exists (a 1, a 2, …, a n ) for which x a 1 x a 2 …x a n = y a 1 y a 2 …y a n }

February 6, 2015CS21 Lecture 1420 Post Correspondence Problem PCP = { : x i, y i  Σ* and there exists (a 1, a 2, …, a n ) for which x a 1 x a 2 …x a n = y a 1 y a 2 …y a n } x1y1x1y1 x2y2x2y2 x3y3x3y3 xkykxkyk “tiles” x2y2x2y2 x1y1x1y1 x5y5x5y5 x2y2x2y2 x1y1x1y1 x3y3x3y3 x4y4x4y4 x 2 x 1 x 5 x 2 x 1 x 3 x 4 x 4 = y 2 y 1 y 5 y 2 y 1 y 3 y 4 y 4 x4y4x4y4 “match”

February 6, 2015CS21 Lecture 1421 Post Correspondence Problem Theorem: PCP is undecidable. Proof: –reduce from A TM (i.e. show A TM ≤ m PCP) –two step reduction makes it easier –first, show A TM ≤ m MPCP (MPCP = “modified PCP”) –next, show MPCP ≤ m PCP

February 6, 2015CS21 Lecture 1422 Post Correspondence Problem MPCP = { : x i, y i  Σ* and there exists (a 1, a 2, …, a n ) for which x 1 x a 1 x a 2 …x a n = y 1 y a 1 y a 2 …y a n } Proof of MPCP ≤ m PCP: –notation: for a string u = u 1 u 2 u 3 …u m  u means the string  u 1  u 2  u 3  u 4 …  u m u  means the string u 1  u 2  u 3  u 4 …  u m   u  means the string  u 1  u 2  u 3  u 4 …  u m 

February 6, 2015CS21 Lecture 1423 Post Correspondence Problem Proof of MPCP ≤ m PCP: –given an instance (x 1, y 1 ), …, (x k, y k ) of MPCP –produce an instance of PCP: (  x 1,  y 1  ), (  x 1, y 1  ), (  x 2, y 2  ), …, (  x k, y k  ), ( ,  ) –YES maps to YES? given a match in original MPCP instance, can produce a match in the new PCP instance –NO maps to NO? given a match in the new PCP instance, can produce a match in the original MPCP instance

February 6, 2015CS21 Lecture 1424 Post Correspondence Problem –YES maps to YES? given a match in original MPCP instance, can produce a match in the new PCP instance x1y1x1y1 x4y4x4y4 x5y5x5y5 x2y2x2y2 x1y1x1y1 x3y3x3y3 x4y4x4y4 x4y4x4y4 x1y1x1y1 x4y4x4y4 x5y5x5y5 x2y2x2y2 x1y1x1y1 x3y3x3y3 x4y4x4y4 x4y4x4y4  

February 6, 2015CS21 Lecture 1425 Post Correspondence Problem –NO maps to NO? given a match in the new PCP instance, can produce a match in the original MPCP instance x1y1x1y1 x4y4x4y4 x5y5x5y5 x2y2x2y2 x1y1x1y1 x3y3x3y3 x4y4x4y4 x4y4x4y4 x1y1x1y1 x4y4x4y4 x5y5x5y5 x2y2x2y2 x1y1x1y1 x3y3x3y3 x4y4x4y4 x4y4x4y4   can’t match unless start with this tile “  ” symbols must align can only appear at the end

February 6, 2015CS21 Lecture 1426 Post Correspondence Problem Theorem: PCP is undecidable. Proof: –show A TM ≤ m MPCP MPCP = { : x i, y i  Σ* and there exists (a 1, a 2, …, a n ) for which x 1 x a 1 x a 2 …x a n = y 1 y a 1 y a 2 …y a n } –show MPCP ≤ m PCP

Download ppt "February 6, 2015CS21 Lecture 141 CS21 Decidability and Tractability Lecture 14 February 6, 2015."

Similar presentations