Lecture 22 Recursively Enumerable and Recursive Languages

advertisement
Lecture 22
Recursively Enumerable
and
Recursive Languages
COT 4420
Theory of Computation
Section 11.1
Slides from Prof. Busch
Recursively Enumerable Language
• Definition: A language is recursively
enumerable if some Turing machine accepts it.
• Turing machine M exists such that for every
w ∈ L,
q0w ⊢M x1 qf x2
qf final state
*
Recursively Enumerable Language
• Let L be a recursively enumerable language
and M the Turing machine that accepts it
For any string w:
w∈ L
M
w∉ L
M
halts in a final state
halts in a non-final state
or loops forever
Recursive Language
• Definition: A language is said to be recursive if
there exists a Turing machine M that accepts L
and that halts on every w ∈ Σ+.
• In other words:
A language is recursive if there is a
membership algorithm for it.
Recursive Language
• Let L be a recursive language and M the Turing
machine that accepts it
For any string w:
w∈ L
M
w∉ L
M
halts in a final state
halts in a non-final state
• We proved before:
For any nonempty Σ, there exist languages
that are not recursively enumerable.
(there are more languages than Turing machines)
• We will prove:
1. There is a specific language which is not
recursively enumerable (not accepted by any
Turing machine)
2. There is a specific language which is
recursively enumerable but not recursive
Non Recursively Enumerable languages
Recursively Enumerable
Recursive
A language which is not
recursively enumerable
{a}
Consider alphabet
Strings of {a } :
+
a, aa, aaa, aaaa, 
1
a a
2
a
3
a
4

Consider Turing Machines
that accept languages over alphabet
They are countable:
M1, M 2 , M 3 , M 4 , 
{a}
Example language accepted by
Mi
L( M i ) = {aa, aaaa, aaaaaa}
L( M i ) = {a , a , a }
2
4
6
Alternative representation
1
a
a
L( M i ) 0
1
2
a
3
0
4
a
1
0
a
5
a
6
1
a
7
0


1
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
3
a
4

Consider the language
L = {a : a ∈ L( M i )}
i
i
L consists of the 1’s in the diagonal
1
2
3
4

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

a
L = {a , a ,}
3
4
a
Consider the language
L
L = {a : a ∉ L( M i )}
i
i
L = {a : a ∈ L( M i )}
i
i
L consists of the 0’s in the diagonal
1
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
3
L = {a , a ,}
1
2
a
4

Theorem:
Language
L is not Recursively enumerable
Proof:
Assume for contradiction that
enumerable
L is recursively
There must exist some machine Mk
that accepts L :
L( M k ) = L
Consider the string ak. This string is either in L or
in L .
Assume that ak ∈
Since L( M k ) =
But
L
L
, ak ∈ L(Mk)
L = {a : a ∉ L( M i )}
i
i
ak ∉ L(Mk)
implies that
If we assume that ak ∈ L then ak ∉
L( M k ) = L , ak ∉ L(Mk).
L . And since
But L = {a : a ∉ L( M i )} implies that ak ∈
i
i
The contradiction is inescapable.
The assumption that L is recursively
enumerable is false.
L
A Language which is
Recursively Enumerable
and not Recursive
We will show that
L = {a : a ∈ L( M i )}
i
Is Recursively
Enumerable
There is a
Turing machine
that accepts L
i
But
Not Recursive
The machine does not
halt on some input
Theorem:
The language
i
i
L = {a : a ∈ L( M i )}
Is Recursively Enumerable
Proof:
We will give a Turing Machine that
accepts L
Turing Machine that accepts
L
For any input string w
• Compute i, for which
w=a
i
• Find Turing machine M i
(using the enumerator for Turing Machines)
• Simulate M i on input
a
i
• If M i accepts, then accept w
This is a Turing machine that accepts every ai ∈ L.
Therefore, L is recursively enumerable.
Remember the theorem we proved before:
L is recursive if and only if L and its complement
are both recursively enumerable.
Consider the language L = {a : a ∈ L( M i )}
This language is recursively enumerable but its
complement is not recursively enumerable.
Therefore, L is not recursive.
i
i
Download