class19.pdf • Page 2. RE and Recursive. Linz 6th, §11.1 • Def RE. Linz 6th Definition 11.1 • Def Recursive. Linz 6th Definition 11.2 • Page 28. ∃ lang not RE. Linz 6th, §11.1 • [Thm 11.2 by counting argument] • Thm 11.3 by diagonalization • Page 50. Recursive is 푝푟표푝푒푟 푠푢푏푠푒푡 of RE Linz 6th, §11.1 • [Thm 11.4 If L and L complement both , then both recursive. L recursive, then L complement recursive.] • Thm 11.5 ∃ a non-recursive, but re language 1 Recursively Enumerable and Recursive

Languages

2 Recall Definition (class 18.pdf) Definition 10.4, Linz, 6th, page 279 Let S be a of strings. An procedure for S is a that generates all strings of one by one and each string is generated in finite time.

3 Definition: A language is recursively enumerable if some Turing machine accepts it

4 Let L be a recursively enumerable language and M the Turing Machine that accepts it

For string w : if w L then halts in a final state

if w L then halts in a non-final state or loops forever

5 Definition (11.2, page 287): A language is recursive if some Turing machine accepts it and halts on any input string

In other words: A recursive language has a membership .

6 Let L be a recursive language and M the Turing Machine that accepts it

L is a recursive language if there is a Turing Machine M such that

For any string w : if w L then halts in a final state if w L then halts in a non-final state

7 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

8 Non Recursively Enumerable

Recursively Enumerable

Recursive

9 We will prove:

1. If a language is recursive then there is an enumeration procedure for it. Linz 6th, page 287.

2. A language is recursively enumerable if and only if there is an enumeration procedure for it. Linz 6th, page 287. 10 Theorem: if a language L is recursive then there is an enumeration procedure for it

11 Proof:

Enumeration Machine

~ M M

Enumerates all Accepts L strings of input alphabet 12 If the alphabet is { a , b } then ~ M can enumerate strings as follows: a b aa ab ba bb aaa aab ...... 13 Enumeration procedure

Repeat: ~ M generates a string w M checks if w L YES: print to output NO: ignore w

End of Proof 14 Example: L = {b,ab,bb,aaa,....}

~ Enumeration M L(M ) Output a b aa ab ba bb aaa aab

...... 15 Theorem: if language L is recursively enumerable, then there is an enumeration procedure for it

16 Proof:

Enumeration Machine

~ M M

Enumerates all Accepts L strings of input alphabet 17 If the alphabet is { a , b } then ~ M can enumerate strings as follows: a b aa ab ba bb aaa aab

18 NAIVE APPROACH Enumeration procedure ~ Repeat: M generates a string w M checks if w L YES: print to output NO: ignore

Problem: If w  L machine may loop forever 19 BETTER APPROACH ~ M Generates first string w1 M executes first step on

Generates second string w2

executes first step on

second step on

20 ~ M Generates third string w3

M executes first step on

second step on w2

third step on w1

And so on......

21 w1 w2 w3 w4 

1 1 1 1

Step in 2 2 2 2 string 3 3 3 3

22 If for any string w i the machine M halts in a final state, then it prints on the output

End of Proof 23 Theorem:

If for language L there is an enumeration procedure, then is recursively enumerable

24 Proof: Input Tape w

Machine that accepts

Enumerator Compare for L

25 Turing machine that accepts L

For input string 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 26 We have proven:

A language is recursively enumerable if and only if there is an enumeration procedure for it

27 A Language which is not Recursively Enumerable

28 We want to find a language that is not Recursively Enumerable

This language is not accepted by any Turing Machine

29 Consider alphabet {a}

Strings: a, aa, aaa, aaaa, 

1 2 3 4 a a a a 

30 Consider Turing Machines that accept languages over alphabet {a}

They are countable:

M1, M2, M3, M4, 

31 Example language accepted by Mi

L(Mi ) ={aa,aaaa,aaaaaa} 2 4 6 L(Mi ) = {a ,a ,a }

Alternative representation

a1 a2 a3 a4 a5 a6 a7 

L(Mi ) 0 1

32 a1 a2 a3 a4 

L(M1) 0 1

L(M2) 1

L(M3)

L(M4)

33 Consider the language

i i L = {a : a  L(Mi )}

L consists from the 1’s in the diagonal

34 a1 a2 a3 a4 

L(M1) 0 1

L(M2) 1

L(M3)

L(M4)

L ={a3,a4,} 35 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

36 a1 a2 a3 a4 

L(M1) 0 1

L(M2) 1

L(M3)

L(M4)

L ={a1,a2,} 37 Theorem: Language L is not recursively enumerable

38 Proof:

Assume for contradiction that L is recursively enumerable

There must exist some machine Mk that accepts

L(M ) = L k 39 a1 a2 a3 a4 

L(M1) 0 1

L(M2) 1

L(M3)

L(M4)

Question: Mk = M1? 40 a1 a2 a3 a4 

L(M1) 0 1

L(M2) 1

L(M3)

L(M4) 1 a  L(M k ) M  M Answer: k 1 1 a  L(M1) 41 a1 a2 a3 a4 

L(M1) 0 1

L(M2) 1

L(M3)

L(M4)

Question: Mk = M2 ? 42 a1 a2 a3 a4 

L(M1) 0 1

L(M2) 1

L(M3)

L(M4) 2 a  L(M k ) M  M Answer: k 2 2 a  L(M 2) 43 a1 a2 a3 a4 

L(M1) 0 1

L(M2) 1

L(M3)

L(M4)

Question: Mk =M 3 ? 44 a1 a2 a3 a4 

L(M1) 0 1

L(M2) 1

L(M3)

L(M4) 3 a  L(M k ) M  M Answer: k 3 3 a  L(M3) 45 Similarly: Mk  Mi for any i

Because either:

i i a  L(M k ) a  L(M k ) or i i a  L(Mi ) a  L(Mi )

46 Therefore, the machine M k cannot exist

Therefore, the language L is not recursively enumerable

End of Proof 47 Observation:

There is no algorithm that describes L

(otherwise would be accepted by some Turing Machine)

48 Non Recursively Enumerable L

Recursively Enumerable

Recursive

49 A Language which is Recursively Enumerable and not Recursive

50 We want to find a language which

Is recursively But not enumerable recursive

There is a The machine Turing Machine doesn’t halt that accepts on some input the language 51 We will prove that the language

i i L = {a : a  L(Mi )}

Is recursively enumerable but not recursive

52 a1 a2 a3 a4 

L(M1) 0 1

L(M2) 1

L(M3)

L(M4)

L ={a3,a4,} 53 Theorem:

i i The language L = {a : a  L(Mi )}

is recursively enumerable

54 Proof:

We will give a Turing Machine that accepts L

55 Turing Machine that accepts L For any input string w i • Compute i , for which w = a

• Find Turing machine Mi (using the enumeration procedure for Turing Machines) i • Simulate on input a

• If accepts, then accept

End of Proof 56 Observation:

Recursively enumerable i i L = {a : a  L(Mi )}

Not recursively enumerable i i L = {a : a  L(Mi )}

(Thus, also not recursive)

57 Theorem:

i i The language L = {a : a  L(Mi )} is not recursive

58 Proof: Assume for contradiction that L is recursive

Then L is recursive: Take the Turing Machine M that accepts L M halts on any input: If M accepts then reject If M rejects then accept

59 Therefore:

L is recursive

But we know:

is not recursively enumerable thus, not recursive

CONTRADICTION!!!!

60 Therefore, L is not recursive

End of Proof 61 Non Recursively Enumerable L

Recursively Enumerable L

Recursive

62