Undecidability and Reductions CSCI 3130 Formal Languages and Automata Theory Siu On CHAN Fall 2018 Chinese University of Hong Kong 1/32
Undecidability Turing’s Theorem 2/32 A TM = {� M , w � | Turing machine M accepts input w } The language A TM is undecidable Note: a Turing machine M may take as input its own description � M �
Proof of Turing’s Theorem Proof by contradiction: H accept if M accepts w reject if M rejects or loops on w Construct a new TM D (that uses H as a subroutine): On input M (i.e. the description of a Turing machine M ), 1. Run H on input M M 2. Output the opposite of H : If H accepts, D rejects; if H rejects, D accepts 3/32 Suppose A TM is decidable, then some TM H decides A TM : � M , w �
Proof of Turing’s Theorem Proof by contradiction: H accept if M accepts w reject if M rejects or loops on w Construct a new TM D (that uses H as a subroutine): 2. Output the opposite of H : If H accepts, D rejects; if H rejects, D accepts 3/32 Suppose A TM is decidable, then some TM H decides A TM : � M , w � On input � M � (i.e. the description of a Turing machine M ), 1. Run H on input � M , � M ��
Proof of Turing’s theorem D D H never loops indefjnitely, neither does D If D rejects D , then D accepts D If D accepts D , then D rejects D Contradiction! D cannot exist! H cannot exist! 4/32 accept if M rejects or loops on � M � � M � reject if M accepts � M � What happens when M = D ? accept if D rejects or loops on � D � � D � reject if D accepts � D �
Proof of Turing’s theorem D D H never loops indefjnitely, neither does D Contradiction! D cannot exist! H cannot exist! 4/32 accept if M rejects or loops on � M � � M � reject if M accepts � M � What happens when M = D ? accept if D rejects ✘✘✘✘ or loops on � D � � D � reject if D accepts � D � If D rejects � D � , then D accepts � D � If D accepts � D � , then D rejects � D �
Proof of Turing’s theorem: conclusion Proof by contradiction But D cannot exist! Conclusion 5/32 Assume A TM is decidable Then there are TM H , H ′ and D The language A TM is undecidable
Diagonalization acc M 3 rej loop rej rej M 4 rej all possible inputs w acc loop . . . (Entries in this table are all made up for illustration) … rej loop acc 0 1 00 … all possible Turing machines M 1 acc rej rej acc M 2 rej 6/32 ε Write an infjnite table for the pairs ( M , w )
Diagonalization acc M 3 loop acc acc acc M 4 acc rej loop acc . . . Only look at those w that describe Turing machines … acc inputs w acc … all possible Turing machines rej M 1 loop rej rej M 2 rej 7/32 � M 1 � � M 2 � � M 3 � � M 4 �
Diagonalization rej acc . . . . . . D acc inputs w rej rej . . . . . . acc acc loop rej … all possible Turing machines M 1 M 3 loop acc rej M 2 rej rej acc rej … 8/32 � M 1 � � M 2 � � M 3 � � M 4 � If A TM is decidable, then TM D is in the table
Diagonalization acc . . . . . . D rej rej acc rej . . . . . . D does the opposite of the diagonal entries D inputs w acc acc rej … all possible Turing machines loop acc loop M 1 rej … M 2 M 3 9/32 rej acc rej rej � M 1 � � M 2 � � M 3 � � M 4 � D on � M i � = opposite of M i on � M i � accept if D rejects or loops on � D � � D � reject if D accepts � D �
Diagonalization rej acc rej . . . . . . D acc acc rej rej ? . . . . . . acc loop inputs w rej … all possible Turing machines M 1 acc M 3 rej loop loop M 2 rej rej acc rej … acc 10/32 � M 1 � � M 2 � � M 3 � � M 4 � � D � We run into trouble when we look at ( D , � D � )
Unrecognizable languages How about languages that are not recognizable? Claim 11/32 The language A TM is recognizable but not decidable A TM = {� M , w � | M is a TM that does not accept w } = {� M , w � | M rejects or loops on input w } The language A TM is not recognizable
Unrecognizable languages Theorem If L and L are both recognizable, then L is decidable Proof of Claim from Theorem: 12/32 We know A TM is recognizable if A TM were also, then A TM would be decidable But Turing’s Theorem says A TM is not decidable
Problem: If M loops on w , we will never go to step 2 Unrecognizable languages Theorem If L and L are both recognizable, then L is decidable Proof idea: The following Turing machine N decides L : On input w , 1. Simulate M on input w . If M accepts, N accepts. 13/32 Let M = TM recognizing L , M ′ = TM recognizing L 2. Simulate M ′ on input w . If M ′ accepts, N rejects.
Unrecognizable languages Theorem If L and L are both recognizable, then L is decidable Proof idea: The following Turing machine N decides L : On input w , 1. Simulate M on input w . If M accepts, N accepts. 13/32 Let M = TM recognizing L , M ′ = TM recognizing L 2. Simulate M ′ on input w . If M ′ accepts, N rejects. Problem: If M loops on w , we will never go to step 2
Unrecognizable languages Theorem If L and L are both recognizable, then L is decidable Proof idea (2nd attempt): The following Turing machine N decides L : On input w , Simulate fjrst t transitions of M on input w . If M accepts, N accepts. 14/32 Let M = TM recognizing L , M ′ = TM recognizing L For t = 0 , 1 , 2 , 3 , . . . Simulate fjrst t transitions of M ′ on input w . If M ′ accepts, N rejects.
Reductions
Another undecidable language We’ll show: We will argue that 15/32 HALT TM = {� M , w � | M is a TM that halts on input w } HALT TM is an undecidable language If HALT TM is decidable, then so is A TM …but by Turing’s theorem, A TM is not
Undecidability of halting Suppose H decides HALT TM H accept if M halts on w reject if M loops on w We want to construct a TM S that decides A TM ? accept if M accepts w reject if M rejects or loops on w 16/32 If HALT TM can be decided, so can A TM � M , w � � M , w �
Undecidability of halting Let H be a TM that decides HALT TM The following TM S decides A TM If H rejects, reject If U accepts, accept; else reject 17/32 HALT TM = {� M , w � | M is a TM that halts on input w } A TM = {� M , w � | M is a TM that accepts input w } Suppose HALT TM is decidable On input � M , w � : Run H on input � M , w � If H accepts, run universal TM U on input � M , w �
Reductions Steps for showing that a language L is undecidable: 1. If some TM R decides L 2. Using R , build another TM S that decides A TM 18/32 But A TM is undecidable, so R cannot exist
seems to require simulating M Example 1 Undecidable! Intuitive reason: To know whether M accepts But then we need to know whether M halts Let’s justify this intuition 19/32 A ′ TM = {� M � | M is a TM that accepts input ε } Is A ′ TM decidable? Why?
Example 1 Undecidable! Intuitive reason: But then we need to know whether M halts Let’s justify this intuition 19/32 A ′ TM = {� M � | M is a TM that accepts input ε } Is A ′ TM decidable? Why? To know whether M accepts ε seems to require simulating M
Example 1: Figuring out the reduction We want to build a TM S S reject otherwise accept if M accepts w ? R reject otherwise R 20/32 Suppose A ′ TM can be decided by a TM R accept if M ′ accepts ε � M ′ � � M ′ � � M , w � M ′ should be a Turing machine such that M ′ on input ε = M on input w
Example 1: Implementing the reduction ? On input z 1. Simulate M on input w 2. If M accepts w , accept 3. If M rejects w , reject 21/32 � M , w � � M ′ � M ′ should be a Turing machine such that M ′ on input ε = M on input w Description of the machine M ′ :
? R accept if M accepts w reject otherwise S Description of S : Simulate M on input w and accept/reject according to M 22/32 � M ′ � � M , w � On input � M , w � where M is a TM 1. Construct the following TM M ′ : M ′ = a TM such that on input z , 2. Run R on input � M ′ � and accept/reject according to R
Example 1: The formal proof Simulate M on input w and accept/reject according to M So S decides A TM , which is impossible 23/32 A ′ TM = {� M � | M is a TM that accepts input ε } A TM = {� M , w � | M is a TM that accepts input w } Suppose A ′ TM is decidable by a TM R . Consider the TM S : On input � M , w � where M is a TM 1. Construct the following TM M ′ : M ′ = a TM such that on input z , 2. Run R on input � M ′ � and accept/reject according to R Then S accepts � M , w � if and only if M accepts w
Example 2 Undecidable! Intuitive reason: To know whether M accepts some strings seems to require simulating M But then we need to know whether M halts Let’s justify this intuition 24/32 A ′′ TM = {� M � | M is a TM that accepts some input strings } Is A ′′ TM decidable? Why?
Example 2 Undecidable! Intuitive reason: To know whether M accepts some strings seems to require simulating M But then we need to know whether M halts Let’s justify this intuition 24/32 A ′′ TM = {� M � | M is a TM that accepts some input strings } Is A ′′ TM decidable? Why?
Recommend
More recommend