Post on 30-May-2018
8/9/2019 Re Cursive
1/55
Fall 2005 Costas Busch - RPI 1
Recursively Enumerable
andRecursive Languages
8/9/2019 Re Cursive
2/55
Fall 2005 Costas Busch - RPI 2
Definition:
A language is recursively enumerableif there is a Turing machine that accepts it
Also known as: Turing Recognizable languages
orTuring Acceptable languages
8/9/2019 Re Cursive
3/55
Fall 2005 Costas Busch - RPI 3
For any string :
Let be a recursively enumerable languageL
and the Turing Machine that accepts itM
Lw
w
if then halts in an accept stateM
wif then halts in a non-accept stateM
or loops forever
8/9/2019 Re Cursive
4/55
Fall 2005 Costas Busch - RPI 4
Definition:
A language is recursiveif there is a Turing machine accepts it
and the machine halts on every input string
Also known as decidable languages
8/9/2019 Re Cursive
5/55
Fall 2005 Costas Busch - RPI 5
For any string :
Let be a recursive languageL
that accepts such that:M
Lw
w
if then halts in an accept stateM
wif then halts in a non-accept stateM
Then there is a Turing machineL
8/9/2019 Re Cursive
6/55
Fall 2005 Costas Busch - RPI 6
We will prove:
1. There is a specific languagewhich is not recursively enumerable
(not accepted by any Turing Machine)
2. There is a specific language
which is recursively enumerable
but not recursive
L
L
8/9/2019 Re Cursive
7/55
Fall 2005 Costas Busch - RPI 7
Recursive
Recursively Enumerable
Non Recursively Enumerable
L
L
8/9/2019 Re Cursive
8/55
Fall 2005 Costas Busch - RPI 8
A Language which
is notRecursively Enumerable
8/9/2019 Re Cursive
9/55
Fall 2005 Costas Busch - RPI 9
Consider alphabet }{a
Strings: -,,,, aaaaaaaaaa
1a
2a
3a
4a .
8/9/2019 Re Cursive
10/55
Fall 2005 Costas Busch - RPI 10
Consider Turing Machines
that accept languages over alphabet }{a
They are countable:
-,,,, 4321 MMMM
(There is an enumeration procedure that
generates them)
8/9/2019 Re Cursive
11/55
Fall 2005 Costas Busch - RPI 11
-
,,,, 4321MMMM
Each machine accepts some language over }{a
-),(),(),(),( 4321 MLMLMLML
Note that it is possible to have
)()( ji MLML ! ji {
Since, a language could be accepted by more than one
Turing machine
for
8/9/2019 Re Cursive
12/55
Fall 2005 Costas Busch - RPI 12
Example language accepted by
},,{)( aaaaaaaaaaaaML i !
},,{)( 642 aaaML i !
iM
Binary representation
1a 2a 3a 4a 5a 6a 7a
)( iML
.
0 1 1 10 0 0 .
8/9/2019 Re Cursive
13/55
Fall 2005 Costas Busch - RPI 13
1a
2a
3a
4a
)( 1ML
.
0 1 10 .
)( 2ML
)( 3ML
01 0 1 .
0 1 11 .
)( 4ML 0 10 .0
Example of binary representations
8/9/2019 Re Cursive
14/55
Fall 2005 Costas Busch - RPI 14
Consider the language
)}(:{i
iiMLaaL !
L consists of the 1s in the diagonal
8/9/2019 Re Cursive
15/55
Fall 2005 Costas Busch - RPI 15
1a
2a 3a
4a
)( 1ML
.
0 1 10 .
)( 2ML
)( 3ML
01 0 1 .
0 1 11 .
)( 4ML 0 10 .0
},,{ 43 -aaL !
8/9/2019 Re Cursive
16/55
Fall 2005 Costas Busch - RPI 16
Consider the language
)}(:{ iii
MLaaL !
L consists of the 0s in the diagonal
)}(:{ iii
MLaaL !
L
8/9/2019 Re Cursive
17/55
Fall 2005 Costas Busch - RPI 17
1a 2a
3a
4a
)( 1ML
.
0 1 10 .
)( 2ML
)( 3ML
01 0 1 .
0 1 11 .
)( 4ML 0 10 .0
},,{ 21 -aaL !
8/9/2019 Re Cursive
18/55
Fall 2005 Costas Busch - RPI 18
Proof:
is recursively enumerableL
Assume for contradiction that
There must exist some machine
that accepts :kM
L LML k !)(
Theorem:
Language is not recursively enumerableL
8/9/2019 Re Cursive
19/55
Fall 2005 Costas Busch - RPI 19
1a 2a
3a
4a
)( 1ML
.
0 1 10 .
)( 2ML
)( 3ML
01 0 1 .
0 1 11 .
)( 4ML 0 10 .0
Question: ?1MMk ! LML k !)(
8/9/2019 Re Cursive
20/55
Fall 2005 Costas Busch - RPI 20
1a 2a
3a
4a
)( 1ML
.
0 1 10 .
)( 2ML
)( 3ML
01 0 1 .
0 1 11 .
)( 4ML 0 10 .0
Answer: 1MMk {
)(
)(
11
1
MLa
MLa k
8/9/2019 Re Cursive
21/55
Fall 2005 Costas Busch - RPI 21
1a 2a
3a
4a
)( 1ML
.
0 1 10 .
)( 2ML
)( 3ML
01 0 1 .
0 1 11 .
)( 4ML 0 10 .0
Question: ?2MMk ! LML k !)(
8/9/2019 Re Cursive
22/55
Fall 2005 Costas Busch - RPI 22
1a 2a
3a
4a
)( 1ML
.
0 1 10 .
)( 2ML
)( 3ML
01 0 1 .
0 1 11 .
)( 4ML 0 10 .0
Answer: 2MMk {
)(
)(
22
2
MLa
MLa k
8/9/2019 Re Cursive
23/55
Fall 2005 Costas Busch - RPI 23
1a 2a
3a
4a
)( 1ML
.
0 1 10 .
)( 2ML
)( 3ML
01 0 1 .
0 1 11 .
)( 4ML 0 10 .0
Question: ?3MMk ! LML k !)(
8/9/2019 Re Cursive
24/55
Fall 2005 Costas Busch - RPI 24
1a 2a
3a
4a
)( 1ML
.
0 1 10 .
)( 2ML
)( 3ML
01 0 1 .
0 1 11 .
)( 4ML 0 10 .0
Answer: 3MMk {
)(
)(
33
3
MLa
MLa k
8/9/2019 Re Cursive
25/55
Fall 2005 Costas Busch - RPI 25
Similarly: ik MM {
)(
)(
i
i
ki
MLa
MLa
)(
)(
i
i
ki
MLa
MLa
for any i
Because either:
or
the machine cannot existkM
is not recursively enumerableL
End of Proof
8/9/2019 Re Cursive
26/55
Fall 2005 Costas Busch - RPI 26
Recursive
Recursively Enumerable
Non Recursively Enumerable
L
8/9/2019 Re Cursive
27/55
Fall 2005 Costas Busch - RPI 27
A Language which is
Recursively Enumerableand not Recursive
8/9/2019 Re Cursive
28/55
Fall 2005 Costas Busch - RPI 28
There is a
Turing Machine
that accepts
Every machine
that accepts
doesnt halt
on some input string
Is recursively
enumerable
But not
recursive
)}(:{ iii
MLaaL !
We will prove that the language
L
L
8/9/2019 Re Cursive
29/55
Fall 2005 Costas Busch - RPI 29
1a
2a 3a
4a
)( 1ML
.
0 1 10 .
)( 2ML
)( 3ML
01 0 1 .
0 1 11 .
)( 4ML 0 10 .0
},,{ 43 -aaL !
8/9/2019 Re Cursive
30/55
Fall 2005 Costas Busch - RPI 30
The languageTheorem:
)}(:{ iii
MLaaL !is recursively enumerable
Proof: We will give a Turing Machine that
accepts L
8/9/2019 Re Cursive
31/55
Fall 2005 Costas Busch - RPI 31
Turing Machine that accepts L
For any input string w
Compute , for which iaw !
Find Turing machine iM
(using the enumeration procedure
for Turing Machines)
Simulate on inputiMi
a If accepts, then acceptiM w
i
End of Proof
8/9/2019 Re Cursive
32/55
Fall 2005 Costas Busch - RPI 32
Observation:
)}(:{ iii
MLaaL !
)}(:{ iii MLaaL !
Recursively enumerable
Not recursively enumerable
(Thus, is not recursive either)L
8/9/2019 Re Cursive
33/55
Fall 2005 Costas Busch - RPI 33
Theorem:
If a language is recursive,
then its complement is recursive tooX
X
Proof:
Build a Turing machine thataccepts and halts on every inputX
Md
8/9/2019 Re Cursive
34/55
Fall 2005 Costas Busch - RPI 34
(accepts and halts on every input string)
1. Let be the Turing machine that acceptsM X
and halts on every input string
If accepts then reject
If rejects then acceptM
M
X
MdTuring Machine
On any input string do:w
2. Run with input stringM w
8/9/2019 Re Cursive
35/55
Fall 2005 Costas Busch - RPI 35
Md
iq iq
jq jq
Rxx ,p
For all tape symbols
not read in the othertransitions of
x
iq
M
Transform toM Md
ENDOF PROOF
8/9/2019 Re Cursive
36/55
Fall 2005 Costas Busch - RPI 36
Theorem: )}(:{ iii
MLaaL !
is not a recursive language
Proof: If is recursive
Then is recursive
L
L
The complementof a recursive language
is recursive
Contradiction!!!!
However, is not Turing acceptable!L
8/9/2019 Re Cursive
37/55
Fall 2005 Costas Busch - RPI 37
L
Recursive
Recursively Enumerable
Non Recursively Enumerable
L
8/9/2019 Re Cursive
38/55
Fall 2005 Costas Busch - RPI 38
Turing acceptable languagesand
Enumeration Procedures
8/9/2019 Re Cursive
39/55
Fall 2005 Costas Busch - RPI 39
We will prove:
If a language is recursive thenthere is an enumeration procedure for it
A language is recursively enumerable
if and only ifthere is an enumeration procedure for it
(weak result)
(strong result)
8/9/2019 Re Cursive
40/55
Fall 2005 Costas Busch - RPI 40
Theorem:
if a language is recursive then
there is an enumeration procedure for it
L
Proof:
Let be the Turing machine that accepts
and halts on every input
M L
Use to build the enumeration procedure
for
M
L
8/9/2019 Re Cursive
41/55
Fall 2005 Costas Busch - RPI 41
Example:
alphabet is },{ ba
ab
aaabba
bbaaaaab......
(proper order)
Let be an enumerator that prints
all strings from input alphabet in proper order
M~
8/9/2019 Re Cursive
42/55
Fall 2005 Costas Busch - RPI 42
Enumeration procedure for
Repeat:
M~ generates a string
M checks if Lw
YES: print to outputw
NO: ignore w
L
This part terminates,
because is recursiveL
8/9/2019 Re Cursive
43/55
Fall 2005 Costas Busch - RPI 43
MM
~
Enumeration Machine for
string
Give menext stringEnumerates all
strings of
input alphabet
Generates allStrings in alphabet
iw
If accepts
then print to
output
M iw
iw
Tests each stringif it is accepted by
L
M
output
All strings
of L
8/9/2019 Re Cursive
44/55
Fall 2005 Costas Busch - RPI 44
Example:
M~
a
b
aaabba
bbaaaaab
M
,....},,,{ aaabbabbL !Enumeration
Output
b
ab
bbaaa
reject
reject
reject
accept
accept
accept
accept
reject
ENDOF PROOF
1w
2w
3w
8/9/2019 Re Cursive
45/55
Fall 2005 Costas Busch - RPI 45
Theorem:
if language is recursively enumerable thenthere is an enumeration procedure for it
L
Proof:
Let be the Turing machine that acceptsM L
Use to build the enumeration procedure
for
M
L
8/9/2019 Re Cursive
46/55
Fall 2005 Costas Busch - RPI 46
MM~
Enumeration Machine for
Accepts LEnumerates allstrings of input alphabet
in proper order
L
NAIVE APPROACH
8/9/2019 Re Cursive
47/55
Fall 2005 Costas Busch - RPI 47
Enumeration procedure for
Repeat: M~ generates a string
M
w
checks if Lw
YES: print to outputw
NO: ignore w
NAIVE APPROACH
Problem: If
machine may loop forever
Lw
M
L
BE E PP
8/9/2019 Re Cursive
48/55
Fall 2005 Costas Busch - RPI 48
M
~
M
1w
executes first step on
BETTER APPROACH
1w
M~ Generates second string 2w
M executes first step on 2w
second step on 1w
Generates first string
8/9/2019 Re Cursive
49/55
Fall 2005 Costas Busch - RPI 49
M~ Generates third string
3w
M executes first step on 3w
second step on 2w
third step on 1w
And so on............
St i
8/9/2019 Re Cursive
50/55
Fall 2005 Costas Busch - RPI 50
1w 2w 3w 4w ..
1
Step in
computationof string
1 1 1
2 2 2 2
3 3 3 3
String:
4 4 4 4
8/9/2019 Re Cursive
51/55
Fall 2005 Costas Busch - RPI 51
If for any string
machine halts in an accepting state
then it prints on the output
M
iw
iw
End of Proof
8/9/2019 Re Cursive
52/55
Fall 2005 Costas Busch - RPI 52
Theorem:
If for language
there is an enumeration procedure
then is recursively enumerable
L
L
Proof:
Using the enumerator for
we will build a Turing machine
that accepts
L
L
8/9/2019 Re Cursive
53/55
Fall 2005 Costas Busch - RPI 53
w
Input Tape
Enumerator
for L
Compare
Turing Machine that acceptsL
w
iw
If same,Accept and HaltGive me thenext string
in the
enumeration
sequence
8/9/2019 Re Cursive
54/55
Fall 2005 Costas Busch - RPI 54
Turing machine that accepts L
Loop:
U
sing the enumerator of ,generate the next string of L
For any input string w
Compare generated string with w
If same, accept and exit loop
End of Proof
L
8/9/2019 Re Cursive
55/55
By Combining the last two theorems,
we have proven:
A language is recursively enumerable
if and only if
there is an enumeration procedure for it