Document 7548124

Download Report

Transcript Document 7548124

Recursively Enumerable
and
Recursive
Languages
1
Definition:
A language is recursively enumerable
if some Turing machine accepts it
2
Let
L be a recursively enumerable language
and
M the Turing Machine that accepts it
For string
w:
if
w L
then
M halts in a final state
if
w L
then
M halts in a non-final state
or loops forever
3
Definition:
A language is recursive
if some Turing machine accepts it
and halts on any input string
In other words:
A language is recursive if there is
a membership algorithm for it
4
Let
L be a recursive language
and
M the Turing Machine that accepts it
For string
w:
if
w L
then
M halts in a final state
if
w L
then
M halts in a non-final state
5
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
6
Non Recursively Enumerable
Recursively Enumerable
Recursive
7
We will first prove:
• If a language is recursive then
there is an enumeration procedure for it
• A language is recursively enumerable
if and only if
there is an enumeration procedure for it
8
Theorem:
if a language L is recursive then
there is an enumeration procedure for it
9
Proof:
Enumeration Machine
~
M
Enumerates all
strings of input alphabet
M
Accepts
L
10
If the alphabet is {a, b} then
~
M can enumerate strings as follows:
a
b
aa
ab
ba
bb
aaa
aab
......
11
Enumeration procedure
Repeat:
~
M
generates a string
w
M checks if w L
YES: print
NO:
ignore
End of Proof
w to output
w
12
Example:
~
M
a
b
aa
ab
ba
bb
aaa
aab
......
L  {b, ab, bb, aaa,....}
L(M )
Enumeration
Output
b
b
ab
ab
bb
aaa
bb
aaa
......
......
13
Theorem:
if language L is recursively enumerable then
there is an enumeration procedure for it
14
Proof:
Enumeration Machine
~
M
Enumerates all
strings of input alphabet
M
Accepts L
15
If the alphabet is {a, b} then
~
M can enumerate strings as follows:
a
b
aa
ab
ba
bb
aaa
aab
16
NAIVE APPROACH
Enumeration procedure
Repeat:
~
M
generates a string
w
M checks if w L
YES: print
w to output
NO: ignore w
Problem: If w L
machine M
may loop forever
17
BETTER APPROACH
~
M
Generates first string
w1
M executes first step on w1
~
M
Generates second string
w2
M executes first step on w2
second step on
w1
18
~
M
Generates third string
w3
M executes first step on w3
second step on
w2
third step on
w1
And so on............
19
Step
in
string

w1
w2
w3
w4
1
1
1
1
2
2
2
2
3
3
3
3

20
If for any string wi
machine M halts in a final state
then it prints wi on the output
End of Proof
21
Theorem:
If for language L
there is an enumeration procedure
then L is recursively enumerable
22
Proof:
Input Tape
w
Machine that
accepts L
Enumerator
for L
Compare
23
Turing machine that accepts
For input string
L
w
Repeat:
• Using the enumerator,
generate the next string of
L
• Compare generated string with
w
If same, accept and exit loop
End of Proof
24
We have proven:
A language is recursively enumerable
if and only if
there is an enumeration procedure for it
25
A Language which
is not
Recursively Enumerable
26
We want to find a language that
is not Recursively Enumerable
This language is not accepted by any
Turing Machine
27
Consider alphabet
Strings:
{a}
a, aa, aaa, aaaa, 
1
a a
2
a
3
a
4

28
Consider Turing Machines
that accept languages over alphabet
{a}
They are countable:
M1, M 2 , M 3 , M 4 , 
29
Example language accepted by M i
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
5
4
a
1
0
a
a
6
1
a
7
0


30
3
1
a
a
2
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
4

31
Consider the language
L  {a : a  L( M i )}
i
i
L consists from the 1’s in the diagonal
32
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
a
4
33
Consider the language
L
L  {a : a  L( M i )}
i
i
L  {a : a  L( M i )}
i
L
i
consists from the 0’s in the diagonal
34
1
a
a
2
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
L  {a , a ,}
1
a
4

2
35
Theorem:
Language
L is not recursively enumerable
36
Proof:
Assume for contradiction that
L is recursively enumerable
There must exist some machine
that accepts L
L( M k )  L
Mk
37
1
a
a
2
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
4

Question: M k  M1 ?
38
1
a
a
2
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
4

1
Answer:
M k  M1
a  L( M k )
1
a  L ( M1 )
39
1
a
a
2
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
4

Question: M k  M 2 ?
40
1
a
a
2
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
4

2
Answer:
Mk  M2
a  L( M k )
2
a  L( M 2 )
41
1
a
a
2
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
4

Question: M k  M 3 ?
42
1
a
a
2
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
4

3
Answer:
M k  M3
a  L( M k )
3
a  L( M 3 )
43
Similarly:
Mk  Mi
for any
i
Because either:
a  L( M k )
i
a  L( M i )
i
a  L( M k )
i
or
a  L( M i )
i
44
Therefore, the machine
M k cannot exist
Therefore, the language L
is not recursively enumerable
End of Proof
45
Observation:
There is no algorithm that describes
L
(otherwise L would be accepted by
some Turing Machine)
46
Non Recursively Enumerable
L
Recursively Enumerable
Recursive
47
A Language which is
Recursively Enumerable
and not Recursive
48
We want to find a language which
Is recursively
enumerable
There is a
Turing Machine
that accepts
the language
But not
recursive
The machine
doesn’t halt
on some input
49
We will prove that the language
L  {a : a  L( M i )}
i
i
Is recursively enumerable
but not recursive
50
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
a
4
51
Theorem:
The language
L  {a : a  L( M i )}
i
i
is recursively enumerable
52
Proof:
We will give a Turing Machine that
accepts L
53
Turing Machine that accepts
For any input string
L
w
wa
• Find Turing machine M i
• Compute i , for which
i
(using the enumeration procedure
for Turing Machines)
• Simulate
• If
M i on input a
i
M i accepts, then accept w
End of Proof
54
Observation:
Recursively enumerable
i
i
L  {a : a  L( M i )}
Not recursively enumerable
i
i
L  {a : a  L( M i )}
(Thus, also not recursive)
55
Theorem:
The language
L  {a : a  L( M i )}
i
i
is not recursive
56
Proof:
Assume for contradiction that
Then
L is recursive
L is recursive:
Take the Turing Machine
M that accepts L
M halts on any input:
If
If
M accepts then reject
M rejects then accept
57
Therefore:
L is recursive
But we know:
L is not recursively enumerable
thus, not recursive
CONTRADICTION!!!!
58
Therefore,
L
is not recursive
End of Proof
59
Non Recursively Enumerable
L
Recursively Enumerable
L
Recursive
60