23 Decidable Undecidable
23 Decidable Undecidable
Recall that:
A language L is Turing-Acceptable
if there is a Turing machine M
that accepts L
qaccept
qreject
x x ,R qaccept
x x ,R x x ,L
x x ,R
Multiple
reject states One reject state
For a decidable language L :
Decision
Decider for L
On Halt:
qaccept
Accept
Input
string
Reject
qreject
Corresponding language:
PRIMES {1, 2, 3, 5, 7, }
Proof:
Build a Turing machine M that
accepts L and halts on every input string
( M is decider for L )
Transform accept state to reject
and vice-versa
M M
qaccept qreject
qa qa
qreject qaccept
qr qr
Turing Machine M
On each input string w do:
END OF PROOF
Undecidable Languages
• L is Turing-acceptable
the complement of a
decidable language is decidable
Therefore, L is undecidable
Non Turing-Acceptable L
Turing-Acceptable L
Decidable
A Language which
is not
Turing Acceptable
Consider alphabet {a}
Strings of {a } :
a , aa , aaa , aaaa ,
1 2 3 4
a a a a
Consider Turing Machines
that accept languages over alphabet {a}
M 1, M 2 , M 3 , M 4 ,
L ( M 1 ), L ( M 2 ), L ( M 3 ), L ( M 4 ),
Binary representation
1 2 3 4 5 6 7
a a a a a a a
L(M i ) 0 1 0 1 0 1 0
Example of binary representations
1 2 3 4
a a a a
L(M1) 0 1 0 1
L(M 2 ) 1 0 0 1
L(M 3 ) 0 1 1 1
L(M 4 ) 0 0 0 1
Consider the language
i i
L {a : a L ( M i )}
L(M1) 0 1 0 1
L(M 2 ) 1 0 0 1
L(M 3 ) 0 1 1 1
L(M 4 ) 0 0 0 1
3 4
L {a , a ,}
Consider the language L
i i
L {a : a L ( M i )}
i i
L {a : a L ( M i )}
L(M1) 0 1 0 1
L(M 2 ) 1 0 0 1
L(M 3 ) 0 1 1 1
L(M 4 ) 0 0 0 1
1 2
L {a , a ,}
Theorem:
Language L is not Turing-Acceptable
Proof:
L(M1) 0 1 0 1
L(M 2 ) 1 0 0 1
L(M 3 ) 0 1 1 1
L(M 4 ) 0 0 0 1
Question: M k M 1 ? L(M k ) L
1 2 3 4
a a a a
L(M1) 0 1 0 1
L(M 2 ) 1 0 0 1
L(M 3 ) 0 1 1 1
L(M 4 ) 0 0 0 1
1
a L(M k )
Answer: M k M1 1
a L(M1)
1 2 3 4
a a a a
L(M1) 0 1 0 1
L(M 2 ) 1 0 0 1
L(M 3 ) 0 1 1 1
L(M 4 ) 0 0 0 1
Question: M k M 2 ? L(M k ) L
1 2 3 4
a a a a
L(M1) 0 1 0 1
L(M 2 ) 1 0 0 1
L(M 3 ) 0 1 1 1
L(M 4 ) 0 0 0 1
2
a L(M k )
Answer: Mk M2
2
a L(M 2 )
1 2 3 4
a a a a
L(M1) 0 1 0 1
L(M 2 ) 1 0 0 1
L(M 3 ) 0 1 1 1
L(M 4 ) 0 0 0 1
Question: M k M 3 ? L(M k ) L
1 2 3 4
a a a a
L(M1) 0 1 0 1
L(M 2 ) 1 0 0 1
L(M 3 ) 0 1 1 1
L(M 4 ) 0 0 0 1
3
a L(M k )
Answer: Mk M3
3
a L(M 3 )
Similarly: Mk Mi for any i
Because either:
i i
a L(M k ) a L(M k )
or
i i
a L(M i ) a L(M i )
L is not Turing-Acceptable
End of Proof
Non Turing-Acceptable
L
Turing-Acceptable
Decidable
A Language which is
Turing-Acceptable
and Undecidable
We will prove that the language
i i
L {a : a L ( M i )}
Is Turing-
Undecidable
Acceptable
L(M1) 0 1 0 1
L(M 2 ) 1 0 0 1
L(M 3 ) 0 1 1 1
L(M 4 ) 0 0 0 1
3 4
L {a , a ,}
Theorem: The language
i i
L {a : a L ( M i )}
Is Turing-Acceptable
i
• Simulate M i on input a
Turing-Acceptable
i i
L {a : a L ( M i )}
Not Turing-acceptable
i i
L {a : a L ( M i )}
(Thus, L is undecidable)
Non Turing-Acceptable
L
Turing-Acceptable
L
Decidable
L?
i i
Theorem: L {a : a L ( M i )}
is undecidable
Proof: If L is decidable
the complement of a
decidable language is decidable
Then L is decidable
Turing-Acceptable
L
Decidable
Turing acceptable languages
and
Enumerators
We will prove:
(weak result)
• If a language is decidable then
there is an enumerator for it
(strong result)
• A language is Turing-acceptable
if and only if
there is an enumerator for it
Theorem:
if a language L is decidable then
there is an enumerator for it
Proof:
Let M be the decider for L
a
b
aa
Example:
ab
alphabet is {a , b}
ba (proper order)
bb
aaa
aab
......
Enumerator for L
Repeat:
~
1. M generates a string w
2. M checks if w L
YES: print w to output
NO: ignore w
bb accept bb
aaa accept aaa
aab reject
END OF PROOF
Theorem:
Proof:
~ M
M
Enumerates all
Accepts L
strings of input alphabet
in proper order
NAIVE APPROACH
Enumerator for L
Repeat:
~ generates a string w
M
M checks if w L
YES: print w to output
NO: ignore w
Problem: If w L
machine M may loop forever
BETTER APPROACH
second step on w1
~ Generates third string
M w3
second step on w2
third step on w1
And so on............
String: w1 w2 w3 w4
1 1 1 1
Step in
2 2 2 2
computation
of string
3 3 3 3
4 4 4 4
If for any string wi
machine M halts in an accepting state
then print wi on the output
End of Proof
Theorem:
If for language L
there is an enumerator
then L is Turing-Acceptable
Proof:
Loop:
• Using the enumerator of L ,
generate the next string of L
End of Proof
By combining the last two theorems,
we have proven:
A language is Turing-Acceptable
if and only if
there is an enumerator for it