Recursively Enumerable and Recursive
Languages
1 D efinition: A language is recursively enumerable if some T uring machine accepts it
2 Let L be a recursively enumerable language and M the T uring M achine 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 D efinition: A language is recursive if some T uring machine accepts it and halts on any input string
In other w ords: A language is recursive if there is a membership algorithm for it 4 Let L be a recursive language and M the T uring M achine 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 W e w ill prove:
1.T here is a specific language w hich is not recursively enumerable (not accepted by any T uring M achine)
2.T here is a specific language w hich is recursively enumerable but not recursive
6 N on Recursively Enumerable
Recursively Enumerable
Recursive
7 W e w ill 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 T heorem: if a language L is recursive then there is an enumeration procedure for it
9 Proof:
Enumeration M achine
~ M M
Enumerates all A ccepts L strings of input alphabet 10 If the alphabet is { a , b } then ~ M can enumerate strings as follow s: a b aa ab ba bb aaa aab ...... 11 Enumeration procedure
Repeat: ~ M generates a string w M checks if w∈ L Y ES : print w to output N O : ignore w
End of Proof 12 Example: L = {b,ab,bb,aaa,....}
~ Enumeration M L(M ) O utput a b b b aa ab ab ab ba bb bb bb aaa aaa aaa aab
...... 13 T heorem: if language L is recursively enumerable then there is an enumeration procedure for it
14 Proof:
Enumeration M achine
~ M M
Enumerates all A ccepts L strings of input alphabet 15 If the alphabet is { a , b } then ~ M can enumerate strings as follow s: a b aa ab ba bb aaa aab
16 N A IV E A PPRO A CH Enumeration procedure ~ Repeat: M generates a string w M checks if w∈ L Y ES : print w to output N O : ignore w
Problem: If w ∉ L
machine M may loop forever 17 B ET T ER A PPRO A CH ~ M G enerates first string w1
M executes first step on w1
~ M G enerates second string w2
M executes first step on w2
second step on w1
18 ~ M G enerates third string w3
M executes first step on w3
second step on w2
third step on w1
A nd so on......
19 w1 w2 w3 w4 3
1 1 1 1
S tep in 2 2 2 2 string 3 3 3 3
3 20 If for any string w i machine M halts in a final state then it prints w i on the output
End of Proof 21 T heorem:
If for language L there is an enumeration procedure then L is recursively enumerable
22 Proof: Input T ape w
M achine that accepts L
Enumerator Compare for L
23 T uring machine that accepts L
For input string w
Repeat: • U sing the enumerator, generate the next string of L
• Compare generated string w ith w If same, accept and exit loop
End of Proof 24 W e have proven:
A language is recursively enumerable if and only if there is an enumeration procedure for it
25 A Language w hich is not Recursively Enumerable
26 W e w ant to find a language that is not Recursively Enumerable
T his language is not accepted by any T uring M achine
27 Consider alphabet {a}
S trings: a, aa, aaa, aaaa, 2
a1 a2 a3 a4 3
28 Consider T uring M achines that accept languages over alphabet {a}
T hey are countable: 2 M1, M 2, M3, M 4,
29 Example language accepted by Mi = L(Mi ) {aa,aaaa,aaaaaa} = 2 4 6 L(Mi ) {a ,a ,a }
A lternative representation
a1 a2 a3 a4 a5 a6 a7 3 3 L(Mi ) 0 1 0 1 0 1 0
30 a1 a2 a3 a4 3
L(M1) 0 1 0 1 3 3 L(M 2) 1 0 0 1
L(M3) 0 1 1 1 3
L(M 4) 0 0 0 1 3
31 Consider the language
= i i ∈ L {a : a L(Mi )}
L consists from the 1’s in the diagonal
32 a1 a2 a3 a4 3
L(M1) 0 1 0 1 3 3 L(M 2) 1 0 0 1
L(M3) 0 1 1 1 3
L(M 4) 0 0 0 1 3
L = {a3,a4,2} 33 Consider the language L
= i i ∈ L {a : a L(Mi )}
= i i ∉ L {a : a L(Mi )}
L consists from the 0’s in the diagonal
34 a1 a2 a3 a4 3
L(M1) 0 1 0 1 3 3 L(M 2) 1 0 0 1
L(M3) 0 1 1 1 3
L(M 4) 0 0 0 1 3
L = {a1,a2,2} 35 T heorem: Language L is not recursively enumerable
36 Proof:
A ssume for contradiction that L is recursively enumerable
T here must exist some machine M k that accepts L
L(M ) = L k 37 a1 a2 a3 a4 3
L(M1) 0 1 0 1 3 3 L(M 2) 1 0 0 1
L(M3) 0 1 1 1 3
L(M 4) 0 0 0 1 3
= Q uestion: M k M1? 38 a1 a2 a3 a4 3
L(M1) 0 1 0 1 3 3 L(M 2) 1 0 0 1
L(M3) 0 1 1 1 3
L(M 4) 0 0 0 1 3 a1 ∈ L(M ) ≠ k A nsw er: M k M1 1 ∉ a L(M1) 39 a1 a2 a3 a4 3
L(M1) 0 1 0 1 3 3 L(M 2) 1 0 0 1
L(M3) 0 1 1 1 3
L(M 4) 0 0 0 1 3
= Q uestion: M k M 2 ? 40 a1 a2 a3 a4 3
L(M1) 0 1 0 1 3 3 L(M 2) 1 0 0 1
L(M3) 0 1 1 1 3
L(M 4) 0 0 0 1 3 a2 ∈ L(M ) ≠ k A nsw er: M k M 2 2 ∉ a L(M2) 41 a1 a2 a3 a4 3
L(M1) 0 1 0 1 3 3 L(M 2) 1 0 0 1
L(M3) 0 1 1 1 3
L(M 4) 0 0 0 1 3
= Q uestion: M k M 3 ? 42 a1 a2 a3 a4 3
L(M1) 0 1 0 1 3 3 L(M 2) 1 0 0 1
L(M3) 0 1 1 1 3
L(M 4) 0 0 0 1 3 3 ∉ a L(Mk ) A nsw er: M ≠ M k 3 3 ∈ a L(M3) 43 ≠ S imilarly: M k Mi for any i
B ecause either:
i ∈ i ∉ a L(M k ) a L(M k ) or i ∉ i ∈ a L(Mi ) a L(Mi )
44 T herefore, the machine M k cannot exist
T herefore, the language L is not recursively enumerable
End of Proof 45 O bservation:
T here is no algorithm that describes L
(otherw ise L w ould be accepted by some T uring M achine)
46 N on Recursively Enumerable L
Recursively Enumerable
Recursive
47 A Language w hich is Recursively Enumerable and not Recursive
48 W e w ant to find a language w hich
Is recursively B ut not enumerable recursive
T here is a T he machine T uring M achine doesn’t halt that accepts on some input the language 49 W e w ill prove that the language
= i i ∈ L {a : a L(Mi )}
Is recursively enumerable but not recursive
50 a1 a2 a3 a4 3
L(M1) 0 1 0 1 3 3 L(M 2) 1 0 0 1
L(M3) 0 1 1 1 3
L(M 4) 0 0 0 1 3
L = {a3,a4,2} 51 T heorem:
= i i ∈ T he language L {a : a L(Mi )}
is recursively enumerable
52 Proof:
W e w ill give a T uring M achine that accepts L
53 T uring M achine that accepts L For any input string w i • Compute i , for w hich w = a
• Find T uring machine Mi (using the enumeration procedure for T uring M achines) i • S imulate M i on input a
• If M i accepts, then accept w
End of Proof 54 O bservation:
Recursively enumerable = i i ∈ L {a : a L(Mi )}
N ot recursively enumerable = i i ∉ L {a : a L(Mi )}
(T hus, also not recursive)
55 T heorem:
= i i ∈ T he language L {a : a L(Mi )} is not recursive
56 Proof: A ssume for contradiction that L is recursive
T hen L is recursive: T ake the T uring M achine M that accepts L M halts on any input: If M accepts then reject If M rejects then accept
57 T herefore:
L is recursive
B ut w e know : L is not recursively enumerable thus, not recursive
CO N T RA D ICT IO N !!!!
58 T herefore, L is not recursive
End of Proof 59 N on Recursively Enumerable L
Recursively Enumerable L
Recursive
60