Reducibility The Chinese University of Hong Kong Fall 2010 CSCI 3130: Automata theory and formal languages Reducibility Andrej Bogdanov http://www.cse.cuhk.edu.hk/~andrejb/csc3130
Summary of last lecture program 〈M〉 accept, if M accepts w reject, if M rejects w input w loops, if M loops on w The universal TM U takes as inputs a program M and a string x and simulates M on x The program M itself is specified as a TM!
Summary of last lecture qacc qrej accept reject loop halt recognizable: undecidable: By universal TM U Turing’s Theorem ATM = {〈M, w〉: M is a TM that accepts input w}
Another undecidable language HALTTM = {〈M, w〉: M is a TM that halts on input w} HALTTM is an undecidable language We will argue that … so by Turing’s Theorem it is undecidable. If HALTTM is decidable, so is ATM.
Undecidability of halting If HALTTM can be decided, so can ATM. Suppose H decides HALTTM accept if M halts on w 〈M, w〉 R reject if M loops on w We want to use R to design TM S that decides ATM 〈M, w〉 ? accept if M accepts w reject if M rejects or loops on w
Undecidability of halting accept if M halts on w 〈M, w〉 R reject if M loops on w S U R rej acc simulate M on w rej acc accept if M accepts w 〈M, w〉 reject if M rejects or loops on w
Undecidability of halting HALTTM = {〈M, w〉: M is a TM that halts on input w} ATM = {〈M, w〉: M is 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 AEPSTM = {〈M〉: M is a TM that accepts input e} decidable undecidable 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!
Example 1: Figuring out the reduction reject if not accept if M’ accepts e 〈M’〉 〈M, w〉 reject if not accept if M accepts w S R 〈M’〉 M’ should be a Turing Machine such that: M’ on input e = M on input w If M accepts w, then M’ accepts e If M does not accept w, then M’ does not accept e
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 if M accepts w construct M’ R 〈M’〉 〈M, w〉 reject if not S := On input 〈M, w〉: 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.
Example 1: Writing it up undecidable AEPSTM = {〈M〉: M is a TM that accepts input e} ATM = {〈M, w〉: M is 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 M’ := On input z, Simulate M on input w and output answer Run R on input 〈M’〉 and output its answer. Construct the following TM M’: Then S accepts 〈M, w〉 if and only if M accepts w So S decides ATM, which is impossible.
Example 2 SOMETM = {〈M〉: M is a TM that accepts some input} decidable undecidable 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!
Example 2: Setting up the reduction SOMETM = {〈M〉: M is a TM that accepts some input} Show: If SOMETM can be decided by some TM R, R reject if M’ accepts no inputs accept if M’ accepts some input 〈M’〉 ... then ATM can be decided by some other TM S S 〈M, w〉 reject if not accept if M accepts w
Example 2: Setting up the reduction accept if M accepts w construct M’ R 〈M’〉 〈M, w〉 reject if not 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
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〉: M is a TM that accepts some input} ATM = {〈M, w〉: M is 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 M’ := On input z, Simulate M on input w and output answer Run R on input 〈M’〉 and output its answer. Construct the following TM M’: Then S accepts 〈M, w〉 if and only if M accepts w So S decides ATM, which is impossible.
Example 3 ETM = {〈M〉: M is 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〉: M is a TM that accepts some input}
Example 3 undecidable Suppose ETM can be decided by some TM R. ETM = {〈M〉: M is a TM that accepts no input} SOMETM = {〈M〉: M is a TM that accepts some input} Suppose ETM can be decided by some TM R. Consider the following TM S: S := On input 〈M〉 where M is a TM If R accepts, reject. If R rejects, accept. Run R on input 〈M〉. Then S decides SOMETM, a contradiction.
Example 4 EQTM = {〈M1, M2〉: M1 and M2 accept the same inputs} decidable undecidable Show: If EQTM can be decided by some TM R, ... then ETM can be decided by another TM S
Example 4: Setting up the reduction EQTM = {〈M1, M2〉: M1 and M2 accept the same inputs} ETM = {〈M〉: M is 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 accept same inputs Idea Make M1 = M Make M2 accept nothing
Example 2: Writing it up undecidable EQTM = {〈M1, M2〉: M1 and M2 accept the same inputs} ETM = {〈M〉: M is a TM that accepts no input} Suppose EQTM is decidable and R decides it. Let S := On input 〈M〉 where M is a TM M2 := On input z, reject. Run R on input 〈M, M2〉 and output its answer. Construct the following TM M2: Then S accepts 〈M〉 if and only if M accepts no input So S decides ETM, which is impossible.