230 likes | 246 Views
Fall 2010. The Chinese University of Hong Kong. CSCI 3130: Automata theory and formal languages. Reducibility. Andrej Bogdanov http://www.cse.cuhk.edu.hk/~andrejb/csc3130. Summary of last lecture. U. program 〈 M 〉. accept , if M accepts w. reject , if M rejects w. input w.
E N D
Fall 2010 The Chinese University of Hong Kong CSCI 3130: Automata theory and formal languages Reducibility Andrej Bogdanov http://www.cse.cuhk.edu.hk/~andrejb/csc3130
Summary of last lecture U program 〈M〉 accept, if M accepts w reject, if M rejects w input w loops, if M loops on w The universal TMU takes as inputs a program Mand a string x and simulates M on x The program M itself is specified as a TM!
Summary of last lecture recognizable: By universal TM U qacc qrej undecidable: Turing’s Theorem accept reject loop halt ATM = {〈M, w〉: Mis a TM that accepts input w}
Another undecidable language • We will argue that … so by Turing’s Theorem it is undecidable. HALTTM = {〈M, w〉: Mis a TM that halts on input w} HALTTMis an undecidable language If HALTTMis decidable, so is ATM.
Undecidability of halting • Suppose H decides HALTTM If HALTTMcan be decided, so can ATM. accept ifM halts on w R 〈M, w〉 reject ifM loops on w • We want to use R to design TM S that decides ATM accept ifM accepts w ? 〈M, w〉 reject ifM rejects or loops on w
Undecidability of halting accept ifM halts on w R 〈M, w〉 reject ifM loops on w S R acc acc simulate M on w accept ifM accepts w U 〈M, w〉 rej rej reject ifM rejects or loops on w
Undecidability of halting HALTTM = {〈M, w〉: Mis a TM that halts on input w} ATM = {〈M, w〉: Mis a TM that accepts input w} Suppose that HALTTM is decidable. Let H be a TM that decides HALTTM. Then this TM decides ATM: S := On input 〈M, w〉, Run R on input 〈M, w〉. If R rejects, reject. If R accepts, run U on input 〈M, w〉 If U accepts, accept. If U rejects, reject. Impossible, because ATM is undecidable.
Reducibility • Suppose you think L is undecidable. • How do you know for sure? Show: If some TM R decides L then using R, I can build another TM S so that S decides ATM ...but this is impossible, because ATM is undecidable.
Example 1 • Step 1: You gotta believe it • To know if M accepts e, it looks like we have to simulate it • But then we might end up in a loop • Step 2: Prove it! AEPSTM = {〈M〉: Mis a TM that accepts input e} decidable undecidable
Example 1: Figuring out the reduction accept ifM’ accepts e R 〈M’〉 reject if not S accept ifM accepts w 〈M, w〉 reject if not R 〈M’〉 M’ should be a Turing Machine such that: If M accepts w, then M’ accepts e If M does not accept w, then M’ does not accept e M’ on input e=M on input w
Example 1: Implementing the reduction 〈M, w〉 construct M’ 〈M’〉 M’ should be a Turing Machine such that: M’ on input e=M on input w M’ := On input z, Simulate M on input w If M accepts, accept Otherwise, reject
Example 1: Impementing the reduction accept ifM accepts w construct M’ 〈M, w〉 reject if not S := On input 〈M, w〉: Construct the following TM M’: R 〈M’〉 M’ := On input z, Simulate M on input w and output answer Run R on input 〈M’〉 and output its answer.
Example 1: Writing it up undecidable AEPSTM = {〈M〉: Mis a TM that accepts input e} ATM = {〈M, w〉: Mis a TM that accepts input w} Suppose AEPSTM is decidable and R decides it. Let S := On input 〈M, w〉 where M is a TM and w is a string Construct the following TM M’: M’ := On input z, Simulate M on input w and output answer Run R on input 〈M’〉 and output its answer. Then S accepts 〈M, w〉if and only if M accepts w So S decides ATM, which is impossible.
Example 2 • Step 1: You gotta believe it • To know if M is in SOMETM, looks like we have to simulate • But then we might end up in a loop • Step 2: Prove it! SOMETM = {〈M〉: Mis a TM that accepts some input} decidable undecidable
Example 2: Setting up the reduction SOMETM = {〈M〉: Mis a TM that accepts some input} Show: If SOMETM can be decided by some TM R, accept ifM’ accepts some input R 〈M’〉 reject if M’ accepts no inputs ... then ATM can be decided by some other TM S S accept ifM accepts w 〈M, w〉 reject if not
Example 2: Setting up the reduction accept ifM accepts w construct M’ 〈M, w〉 reject if not Task Given 〈M, w〉, constructM’ so that: R 〈M’〉 If M accepts w, then M’ accepts some input If M does not accept w, then M’ accepts no inputs
Example 2: Implementing the reduction Task Given 〈M, w〉, construct M’ so that: If M accepts w, then M’ accepts some input If M does not accept w, then M’ accepts no inputs M’ := On input z, Simulate M on input w If M accepts, accept Otherwise, reject
Example 2: Writing it up undecidable SOMETM = {〈M〉: Mis a TM that accepts some input} ATM = {〈M, w〉: Mis a TM that accepts input w} Suppose SOMETM is decidable and R decides it. Let S := On input 〈M, w〉 where M is a TM and w is a string Construct the following TM M’: M’ := On input z, Simulate M on input w and output answer Run R on input 〈M’〉 and output its answer. Then S accepts 〈M, w〉if and only if M accepts w So S decides ATM, which is impossible.
Example 3 ETM = {〈M〉: Mis a TM that accepts no input} decidable undecidable Show: If ETM can be decided by some TM R, ... then SOMETM can be decided by another TM S SOMETM = {〈M〉: Mis a TM that accepts some input}
Example 3 undecidable ETM = {〈M〉: Mis a TM that accepts no input} SOMETM = {〈M〉: Mis a TM that accepts some input} Suppose ETM can be decided by some TM R. S := On input 〈M〉 where M is a TM Run R on input 〈M〉. Consider the following TM S: If R accepts, reject. If R rejects, accept. Then S decides SOMETM, a contradiction.
Example 4 EQTM = {〈M1, M2〉: M1and M2 accept the same inputs} decidable undecidable Show: If EQTM can be decided by some TM R, ... then ETMcan be decided by another TM S
Example 4: Setting up the reduction EQTM = {〈M1, M2〉: M1and M2 accept the same inputs} ETM = {〈M〉: Mis a TM that accepts no input} Task Given 〈M〉, construct〈M1, M2〉 so that: If M accepts no input, then M1, M2 accept same inputs If M accepts some input, then M1, M2 do not acceptsame inputs Make M1 = M Idea Make M2accept nothing
Example 2: Writing it up undecidable EQTM = {〈M1, M2〉: M1and M2 accept the same inputs} ETM = {〈M〉: Mis a TM that accepts no input} Suppose EQTM is decidable and R decides it. Let S := On input 〈M〉 where M is a TM Construct the following TM M2: M2:= On input z, reject. Run R on input 〈M, M2〉 and output its answer. Then S accepts 〈M〉if and only if M accepts no input So S decides ETM, which is impossible.