Languages and Finite Automata
Total Page:16
File Type:pdf, Size:1020Kb
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 re, 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 set of strings. An enumeration procedure for S is a Turing Machine 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 algorithm. 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:L M Enumeration Machine ~ M Enumerates all Accepts 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 MRepeat: generates a string ~w Mchecksw if w L YES: print to output NO: ignore End of Proof 14 Example: L = {b,ab,bb,aaa,....} ~ M Enumeration L(M ) Output a b aa ab ba bb aaa aab ...... 15 Theorem:L if language is recursively enumerable, then there is an enumeration procedure for it 16 Proof: ~ M EnumerationL Machine M Enumerates all Accepts 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 M Repeat: generates a string checks if ~w M YES: print to output w L NO: ignore w L Problem: If machine may loop forever 19 BETTER APPROACH MGenerates first string w1 executes first step on ~ M Generates second string w2 executes first step on second step on 20 Generates third string w M w1 3 executes first step on ~ second step on M third stepw 2on And so on............ 21 w1 w2 w3 w4 1 1 1 1 Step in 2 2 2 2 string 3 3 3 3 22 M If for any string w i the machine halts in a final state, then it prints on the output End of Proof 23 Theorem:L If for language there is an enumeration procedure, then is recursively enumerable 24 Proof: L Input Tape Machine that accepts w Enumerator Compare for 25 TuringL machine that accepts For input stringL Repeat: w • Using thew enumerator, generate the next string of • Compare generated string with 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 {a} Consider Turing Machines that accept languages over alphabet 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 L(M1) L(M2) 1 L(M3) a1 a2 a3 a4 L(M4) 0 1 33 L Consider the language i i L = {a : a L(Mi )} consists from the 1’s in the diagonal 34 L(M1) L(M2) 1 L(M3) a1 a2 a3 a4 L(M4) 0 1 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 L(M1) L(M2) 1 L(M3) a1 a2 a3 a4 L(M4) 0 1 L ={a1,a2,} 37 Theorem: Language is not recursivelyL enumerable 38 Proof: Assume for contradictionL that is recursively enumerable There must exist some machine Mk that accepts L(M ) = L k 39 L(M1) L(M2) 1 L(M3) a1 a2 a3 a4 L(M4) 0 1 Question: Mk = M1? 40 L(M1) L(M2) 1 L(M3) a1 a2 a3 a4 L(M4) 1 a L(M k ) 0 M 1 M Answer: k 1 1 a L(M1) 41 L(M1) L(M2) 1 L(M3) a1 a2 a3 a4 L(M4) 0 1 Question: Mk = M2 ? 42 L(M1) L(M2) 1 L(M3) a1 a2 a3 a4 L(M4) 2 a L(M k ) 0 M 1 M Answer: k 2 2 a L(M 2) 43 L(M1) L(M2) 1 L(M3) a1 a2 a3 a4 L(M4) 0 1 Question: Mk =M 3 ? 44 L(M1) L(M2) 1 L(M3) a1 a2 a3 a4 L(M4) 3 a L(M k ) 0 M 1 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 cannot exist L Therefore, the language is not recursively enumerable Mk End of Proof 47 Observation: L There is no algorithm that describes (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 Is recursivelyL = enumerable{a : a L(Mi )} but not recursive 52 L(M1) L(M2) 1 L(M3) a1 a2 a3 a4 L(M4) 0 1 L ={a3,a4,} 53 Theorem: The language i i L = {a : a L(Mi )} is recursively enumerable 54 Proof:L We will give a Turing Machine that accepts 55 Turing Machine that accepts L For any input string i • Compute i , for which w = a • Find Turing machine Mi (usingw 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 recursivelyi i enumerable L = {a : a L(Mi )} (Thus, also not recursive) 57 Theorem: The language i i is notL recursive= {a : a L(Mi )} 58 Proof:L Assume for contradiction that 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 L Therefore, is not recursive End of Proof 61 L Non Recursively Enumerable L Recursively Enumerable Recursive 62.