Review • Languages and Grammars – Alphabets, strings, languages • Regular Languages – Deterministic Finite and Nondeterministic Automata CS 301 - Lecture 23 – Equivalence of NFA and DFA Regular Expressions – Regular Grammars – Properties of Regular Languages Recursive and Recursively – Languages that are not regular and the pumping lemma • Context Free Languages – Context Free Grammars Enumerable Languages – Derivations: leftmost, rightmost and derivation trees – Parsing and ambiguity – Simplifications and Normal Forms – Nondeterministic Pushdown Automata Fall 2008 – Pushdown Automata and Context Free Grammars – Deterministic Pushdown Automata – Pumping Lemma for context free grammars – Properties of Context Free Grammars • Turing Machines – Definition, Accepting Languages, and Computing Functions – Combining Turing Machines and Turing’s Thesis – Turing Machine Variations – Universal Turing Machine and Linear Bounded Automata – Today: Recursive and Recursively Enumerable Languages Definition: A language is recursively enumerable if some Turing machine accepts it Recursively Enumerable and Recursive Languages 1
L Definition: Let be a recursively enumerable language A language is recursive M and the Turing Machine that accepts it if some Turing machine accepts it and halts on any input string w For string : if w ∈ L then halts in a final state M In other words: w ∉ L if then halts in a non-final state M A language is recursive if there is or loops forever a membership algorithm for it L Let be a recursive language M and the Turing Machine that accepts it Turing acceptable languages and w For string : Enumeration Procedures if w ∈ L then halts in a final state M w ∉ L if then halts in a non-final state M 2
We will prove: Theorem: (weak result) • If a language is recursive then if a language is recursive then L there is an enumeration procedure for it there is an enumeration procedure for it (strong result) • A language is recursively enumerable if and only if there is an enumeration procedure for it Proof: { a , b } If the alphabet is then ~ can enumerate strings as follows: M Enumeration Machine a b ~ aa M M ab ba bb aaa aab Enumerates all Accepts L ...... strings of input alphabet 3
Enumeration procedure Example: L = { b , ab , bb , aaa ,....} Enumeration ~ Repeat: L ( M ) M Output ~ a generates a string w M b b b w ∈ L M checks if aa ab ab ab YES: print to output w ba NO: ignore w bb bb bb aaa aaa aaa aab ...... ...... ...... End of Proof Theorem: Proof: L if language is recursively enumerable then Enumeration Machine there is an enumeration procedure for it ~ M M Enumerates all Accepts L strings of input alphabet 4
NAIVE APPROACH { a , b } If the alphabet is then Enumeration procedure ~ can enumerate strings as follows: M ~ Repeat: M generates a string w a w ∈ L b checks if M aa YES: print to output w ab ba NO: ignore w bb aaa aab w ∉ L Problem: If M machine may loop forever BETTER APPROACH ~ ~ Generates third string w M w Generates first string M 3 1 executes first step on w executes first step on w M M 1 3 second step on 2 w ~ w Generates second string 2 M third step on w 1 M executes first step on w 2 And so on............ second step on 1 w 5
w w w w 3 1 2 4 If for any string w i 1 1 1 1 machine halts in a final state M w then it prints on the output Step i 2 2 2 2 in string 3 3 3 3 End of Proof Proof: Theorem: Input Tape w If for language L there is an enumeration procedure Machine that then is recursively enumerable L accepts L Enumerator Compare for L 6
Turing machine that accepts L We have proven: For input string w A language is recursively enumerable Repeat: if and only if • Using the enumerator, there is an enumeration procedure for it generate the next string of L • Compare generated string with w If same, accept and exit loop End of Proof We will prove: Non Recursively Enumerable 1. There is a specific language which is not recursively enumerable Recursively Enumerable (not accepted by any Turing Machine) Recursive 2. There is a specific language which is recursively enumerable but not recursive 7
Some Languages Are Not Definition: A set is uncountable Recursively Enumerable if it is not countable Proof Using Uncountable Sets Theorem: Proof: S Let be an infinite countable set S Since is countable, we can write S = { s , s , s , … } S 1 2 3 S The powerset of is uncountable 2 Elements of S 8
We encode each element of the power set Elements of the powerset have the form: with a binary string of 0’s and 1’s { s 1 s , } Encoding 3 Powerset s s s s element 1 2 3 4 { s , s , s , s } 5 7 9 10 { 1 s } 0 0 0 1 …… { s 2 s , } 0 0 1 1 3 { s , s , s } 1 0 1 1 1 3 4 Let’s assume (for contradiction) Powerset Encoding that the powerset is countable. element t 1 0 0 0 0 1 t 1 1 0 0 0 2 Then: we can enumerate the elements of the powerset t 1 1 0 1 0 3 t 1 1 0 0 1 4 9
t 1 0 0 0 0 1 t 1 1 0 0 0 2 Take the powerset element whose bits are the complements t 0 0 1 1 1 3 in the diagonal t 1 1 0 0 1 4 0011 … New element: (birary complement of diagonal) t The new element must be some Since we have a contradiction: i of the powerset S The powerset of is uncountable 2 S However, that’s impossible: t from definition of i t the i-th bit of must be i the complement of itself Contradiction!!! 10
An Application: Languages { a , b } { a , b } Example Alphabet : Example Alphabet : The set of all Strings: The set of all Strings: * * S { a , b } { , a , b , aa , ab , ba , bb , aaa , aab , … } S { a , b } { , a , b , aa , ab , ba , bb , aaa , aab , … } = = λ = = λ infinite and countable infinite and countable A language is a subset of : S L = { aa , ab , aab } Languages: uncountable { a , b } Example Alphabet : L L L L 1 2 3 k The set of all Strings: * S { a , b } { , a , b , aa , ab , ba , bb , aaa , aab , … } = = λ ? M M M 1 2 3 infinite and countable Turing machines: countable The powerset of contains all languages: S S There are more languages 2 {{ }, { a }, { a , b }{ aa , ab , aab }, … } = λ L L L L than Turing Machines 1 2 3 4 uncountable 11
Languages not accepted by Turing Machines Conclusion: L k There are some languages not accepted by Turing Machines Languages Accepted by Turing Machines (These languages cannot be described by algorithms) We want to find a language that is not Recursively Enumerable A Language which is not Recursively Enumerable This language is not accepted by any Turing Machine 12
{ a } Consider alphabet Consider Turing Machines that accept languages over alphabet { a } a , aa , aaa , aaaa , … Strings: 1 2 3 4 a a a a They are countable: M , M , M , M , … 1 2 3 4 Example language accepted by M i 1 2 3 4 a a a a L ( M ) { aa , aaaa , aaaaaa } i = L ( M ) 0 1 0 1 1 2 4 6 L ( M ) { a , a , a } i = 1 0 0 1 L ( M ) 2 Alternative representation L ( M ) 0 1 1 1 3 1 2 3 4 5 6 7 a a a a a a a L ( M ) 0 0 0 1 4 0 1 0 L ( M ) 0 1 0 1 i 13
1 2 3 4 a a a a Consider the language L ( M ) 0 1 0 1 1 i i 1 0 0 1 L ( M ) L { a : a L ( M )} = ∈ 2 i L ( M ) 0 1 1 1 3 L ( M ) 0 0 0 1 4 L consists from the 1’s in the diagonal 3 4 L = { a , a , … } 1 2 3 4 a a a a Consider the language L L ( M ) 0 1 0 1 1 i i 1 0 0 1 L ( M ) L { a : a L ( M )} = ∈ 2 i L ( M ) 0 1 1 1 3 i i L { a : a L ( M )} = ∉ i L ( M ) 0 0 0 1 4 consists of the 0’s in the diagonal L 1 2 L = { a , a , … } 14
Theorem: Proof: Language is not recursively enumerable L Assume for contradiction that is recursively enumerable L There must exist some machine M k that accepts L L ( M ) L k = 1 2 3 4 1 2 3 4 a a a a a a a a L ( M ) L ( M ) 0 1 0 1 0 1 0 1 1 1 1 0 0 1 1 0 0 1 L ( M ) L ( M ) 2 2 L ( M ) L ( M ) 0 1 1 1 0 1 1 1 3 3 L ( M ) 0 0 0 1 L ( M ) 0 0 0 1 4 4 1 a L ( M ) ∈ k Answer: M k ≠ M Question: M k = M ? 1 1 1 a L ( M ) ∉ 1 15
Recommend
More recommend