Recursively Enumerable and Recursive Languages
Definition: A language is recursively enumerable if some Turing machine accepts it
For string : Let be a recursively enumerable language and the Turing Machine that accepts it ifthen halts in a final state ifthen halts in a non-final state or loops forever
Definition: A language is recursive if some Turing machine accepts it and halts on any input string In other words: A language is recursive if there is a membership algorithm for it
For string : Let be a recursive language and the Turing Machine that accepts it ifthen halts in a final state ifthen halts in a non-final state
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
Recursive Recursively Enumerable Non Recursively Enumerable
A Language which is not Recursively Enumerable
We want to find a language that is not Recursively Enumerable This language is not accepted by any Turing Machine
Consider alphabet Strings:
Consider Turing Machines that accept languages over alphabet They are countable:
Example language accepted by Alternative representation
Consider the language consists from the 1’s in the diagonal
Consider the language consists of the 0’s in the diagonal
Theorem: Language is not recursively enumerable
Proof: is recursively enumerable Assume for contradiction that There must exist some machine that accepts
Question:
Answer:
Question:
Answer:
Question:
Answer:
Similarly: for any Because either: or
Therefore, the machine cannot exist Therefore, the language is not recursively enumerable End of Proof
Observation: There is no algorithm that describes (otherwise would be accepted by some Turing Machine)
Recursive Recursively Enumerable Non Recursively Enumerable
A Language which is Recursively Enumerable and not Recursive
We want to find a language which There is a Turing Machine that accepts the language The machine doesn’t halt on some input Is recursively enumerable But not recursive
We will prove that the language Is recursively enumerable but not recursive
The language Theorem: is recursively enumerable
Proof: We will give a Turing Machine that accepts
Turing Machine that accepts For any input string Compute, for which Find Turing machine (using an enumeration procedure for Turing Machines) Simulate on input If accepts, then accept End of Proof
Observation: Recursively enumerable Not recursively enumerable (Thus, also not recursive)
Theorem: The language is not recursive
Proof: Assume for contradiction that is recursive Then is recursive: Take the Turing Machine that accepts halts on any input: If accepts then reject If rejects then accept
Therefore: is recursive But we know: is not recursively enumerable thus, not recursive CONTRADICTION!!!!
Therefore, is not recursive End of Proof
Recursive Recursively Enumerable Non Recursively Enumerable
Turing acceptable languages and Enumeration Procedures
We will 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 (weak result) (strong result)
Theorem: if a language is recursive then there is an enumeration procedure for it
Proof: Enumeration Machine Accepts Enumerates all strings of input alphabet
If the alphabet is then can enumerate strings as follows:
Enumeration procedure Repeat: generates a string checks if YES: print to output NO: ignore End of Proof
Example: Enumeration Output
Theorem: if language is recursively enumerable then there is an enumeration procedure for it
Proof: Enumeration Machine Accepts Enumerates all strings of input alphabet
If the alphabet is then can enumerate strings as follows:
Enumeration procedure Repeat:generates a string checks if YES: print to output NO: ignore NAIVE APPROACH Problem: If machine may loop forever
executes first step on BETTER APPROACH Generates second string executes first step on second step on Generates first string
Generates third string executes first step on second step on third step on And so on
1 Step in string
If for any string machine halts in a final state then it prints on the output End of Proof
Theorem: If for language there is an enumeration procedure then is recursively enumerable
Proof: Input Tape Enumerator for Compare Machine that accepts
Turing machine that accepts Repeat: Using the enumerator, generate the next string of For input string Compare generated string with If same, accept and exit loop End of Proof
We have proven: A language is recursively enumerable if and only if there is an enumeration procedure for it
The Chomsky Hierarchy
Non-recursively enumerable Recursively-enumerable Recursive Context-sensitive Context-free Regular The Chomsky Hierarchy
Decidability
Consider problems with answer YES or NO Examples: Does Machine have three states ? Is string a binary number? Does DFA accept any input?
A problem is decidable if some Turing machine decides (solves) the problem Decidable problems: Does Machine have three states ? Is string a binary number? Does DFA accept any input?
Turing Machine Input problem instance YES NO The Turing machine that decides (solves) a problem answers YES or NO for each instance of the problem
The machine that decides (solves) a problem: If the answer is YES then halts in a yes state If the answer is NO then halts in a no state These states may not be final states
YES states NO states Turing Machine that decides a problem YES and NO states are halting states
Difference between Recursive Languages and Decidable problems The YES states may not be final states For decidable problems:
Some problems are undecidable: which means: there is no Turing Machine that solves all instances of the problem A simple undecidable problem: The membership problem
The Membership Problem Input:Turing Machine String Question: Does accept ?
Theorem: The membership problem is undecidable Proof:Assume for contradiction that the membership problem is decidable (there are and for which we cannot decide whether )
Thus, there exists a Turing Machine that solves the membership problem YES accepts NO rejects
Let be a recursively enumerable language Let be the Turing Machine that accepts We will prove that is also recursive: we will describe a Turing machine that accepts and halts on any input
accepts ? NO YES accept Turing Machine that accepts and halts on any input reject
Therefore,is recursive But there are recursively enumerable languages which are not recursive Contradiction!!!! Since is chosen arbitrarily, every recursively enumerable language is also recursive
Therefore, the membership problem is undecidable END OF PROOF
Another famous undecidable problem: The halting problem
The Halting Problem Input:Turing Machine String Question: Does halt on input ?
Theorem: The halting problem is undecidable Proof:Assume for contradiction that the halting problem is decidable (there are and for which we cannot decide whether halts on input )
Thus, there exists Turing Machine that solves the halting problem YEShalts on doesn’t halt on NO
Input: initial tape contents Encoding of String YES NO Construction of
Construct machine : If returns YES then loop forever If returns NO then halt
NO Loop forever YES
Construct machine : Input: If halts on input Then loop forever Else halt (machine )
copy
Run machine with input itself: Input: If halts on input Then loop forever Else halt (machine )
on input If halts then loops forever If doesn’t halt then it halts : NONSENSE !!!!!
Therefore, we have contradiction The halting problem is undecidable END OF PROOF
Another proof of the same theorem: If the halting problem was decidable then every recursively enumerable language would be recursive
Theorem: The halting problem is undecidable Proof:Assume for contradiction that the halting problem is decidable
There exists Turing Machine that solves the halting problem YEShalts on doesn’t halt on NO
Let be a recursively enumerable language Let be the Turing Machine that accepts We will prove that is also recursive: we will describe a Turing machine that accepts and halts on any input
halts on ? YES NO Run with input reject accept reject Turing Machine that accepts and halts on any input Halts on final state Halts on non-final state
Thereforeis recursive But there are recursively enumerable languages which are not recursive Contradiction!!!! Since is chosen arbitrarily, every recursively enumerable language is also recursive
Therefore, the halting problem is undecidable END OF PROOF
Reducibility
Problem is reduced to problem If we can solve problem then we can solve problem
If is undecidable then is undecidable If is decidable then is decidable Problem is reduced to problem
Example: the halting problem is reduced to the state-entry problem
The state-entry problem Inputs: Turing Machine State Question: Does String enter state on input ?
Theorem: The state-entry problem is undecidable Proof: Reduce the halting problem to the state-entry problem
state-entry problem decider YES NO enters doesn’t enter Suppose we have a Decider for the state-entry algorithm:
Halting problem decider YES NO halts on doesn’t halt on We want to build a decider for the halting problem:
State-entry problem decider Halting problem decider YES NO YES NO We want to reduce the halting problem to the state-entry problem:
Halting problem decider YES NO YES NO Convert Inputs ? We need to convert one problem instance to the other problem instance State-entry problem decider
Convert to : Add new state From any halting state of add transitions to halting states Single halt state
halts on input halts on state on input if and only if
Generate Halting problem decider YES NO YES NO State-entry problem decider
Since the halting problem is undecidable, the state-entry problem is undecidable END OF PROOF We reduced the halting problem to the state-entry problem
Another example: the halting problem is reduced to the blank-tape halting problem
The blank-tape halting problem Input:Turing Machine Question:Doeshalt when started with a blank tape?
Theorem: Proof: Reduce the halting problem to the blank-tape halting problem The blank-tape halting problem is undecidable
blank-tape halting problem decider YES NO halts on blank tape doesn’t halt on blank tape Suppose we have a decider for the blank-tape halting problem:
halting problem decider YES NO halts on doesn’t halt on We want to build a decider for the halting problem:
Blank-tape halting problem decider Halting problem decider YES NO YES NO We want to reduce the halting problem to the blank-tape halting problem:
Blank-tape halting problem decider Halting problem decider YES NO YES NO We need to convert one problem instance to the other problem instance Convert Inputs ?
Construct a new machine When started on blank tape, writes Then continues execution like then write step 1step2 if blank tapeexecute with input
halts on input string halts when started with blank tape if and only if
Generate blank-tape halting problem decider Halting problem decider YES NO YES NO
Since the halting problem is undecidable, the blank-tape halting problem is undecidable END OF PROOF We reduced the halting problem to the blank-tape halting problem
Does machine halt on input ? Summary of Undecidable Problems Halting Problem: Membership problem: Does machine accept string ?
Does machine enter state on input ? Does machine halt when starting on blank tape? Blank-tape halting problem: State-entry Problem:
Uncomputable Functions
A function is uncomputable if it cannot be computed for all of its domain Domain Values region
An uncomputable function: maximum number of moves until any Turing machine with states halts when started with the blank tape
Theorem:Function is uncomputable Proof: Then the blank-tape halting problem is decidable Assume for contradiction that is computable
Decider for blank-tape halting problem: Input: machine 1. Count states of : 2. Compute 3. Simulate for steps starting with empty tape If halts then return YES otherwise return NO
Therefore, the blank-tape halting problem is decidable However, the blank-tape halting problem is undecidable Contradiction!!!
Therefore, function in uncomputable END OF PROOF
Undecidable Problems for Recursively Enumerable Languages
is empty? is finite? contains two different strings of the same length? Take a recursively enumerable language Decision problems: All these problems are undecidable
Theorem: For any recursively enumerable language it is undecidable to determine whether is empty Proof: We will reduce the membership problem to this problem
empty language problem decider YES NO Suppose we have a decider for the empty language problem: Let be the TM with empty not empty
membership problem decider YES NO accepts rejects We will build the decider for the membership problem:
YES NO YES Membership problem decider empty language problem decider We want to reduce the membership problem to the empty language problem:
YES NO YES Membership problem decider empty language problem decider We need to convert one problem instance to the other problem instance Convert inputs ?
Construct machine : When enters a final state, compare with Accept only if executes the same as with On arbitrary input string
is not empty if and only if
construct YES NO YES Membership problem decider END OF PROOF empty language problem decider
Undecidable problems for Recursively enumerable languages continued…
is empty? is finite? contains two different strings of the same length? Take a recursively enumerable language Decision problems: All these problems are undecidable
Theorem: For a recursively enumerable language it is undecidable to determine whether is finite Proof: We will reduce the halting problem to this problem
finite language problem decider YES NO Suppose we have a decider for the finite language problem: Let be the TM with finite not finite
Halting problem decider YES NO halts on We will build a decider for the halting problem: doesn’t halt on
YES NO YES Halting problem decider finite language problem decider We want to reduce the halting problem to the finite language problem
YES NO YES Halting problem decider finite language problem decider We need to convert one problem instance to the other problem instance convert input ?
Construct machine : If enters a halt state, accept ( inifinite language) Initially, simulates on input Otherwise, reject ( finite language) On arbitrary input string
halts on is infinite if and only if
construct YES NO YES halting problem decider finite language problem decider
is empty? is finite? contains two different strings of the same length? Take a recursively enumerable language Decision problems: All these problems are undecidable
Theorem: For a recursively enumerable language it is undecidable to determine whether contains two different strings of same length Proof: We will reduce the halting problem to this problem
Two-strings problem decider YES NO Suppose we have the decider for the two-strings problem: Let be the TM with contains Doesn’t contain two equal length strings
Halting problem decider YES NO halts on We will build a decider for the halting problem: doesn’t halt on
YES NO YES NO Halting problem decider Two-strings problem decider We want to reduce the halting problem to the empty language problem
YES NO YES NO Halting problem decider Two-strings problem decider We need to convert one problem instance to the other problem instance convert inputs ?
Construct machine : When enters a halt state, accept if or Initially, simulate on input (two equal length strings ) On arbitrary input string Otherwise, reject ( )
halts on if and only if accepts two equal length strings accepts and
construct YES NO YES NO Halting problem decider Two-strings problem decider
Rice’s Theorem
Non-trivial properties of recursively enumerable languages: any property possessed by some (not all) recursively enumerable languages Definition:
Some non-trivial properties of recursively enumerable languages: is empty is finite contains two different strings of the same length
Rice’s Theorem: Any non-trivial property of a recursively enumerable language is undecidable
The Post Correspondence Problem
Some undecidable problems for context-free languages: Is context-free grammar ambiguous? Is ? are context-free grammars
We need a tool to prove that the previous problems for context-free languages are undecidable: The Post Correspondence Problem
Input: Two sequences of strings
There is a Post Correspondence Solution if there is a sequence such that: PC-solution: Indices may be repeated or omitted
Example: PC-solution:
Example: There is no solution Because total length of strings from is smaller than total length of strings from
1. The MPC problem is undecidable 2. The PC problem is undecidable (by reducing MPC to PC) (by reducing the membership to MPC) We will show:
Theorem: The PC problem is undecidable Proof: We will reduce the MPC problem to the PC problem
Some undecidable problems for context-free languages: Is context-free grammar ambiguous? Is ? are context-free grammars We reduce the PC problem to these problems
Theorem: Proof: Let be context-free grammars. It is undecidable to determine if Rdeduce the PC problem to this problem
Suppose we have a decider for the empty-intersection problem Empty- interection problem decider YES NO Context-free grammars
For a context-free grammar, Theorem: it is undecidable to determine if G is ambiguous Proof: Reduce the PC problem to this problem