287. Recursively Enumerable Languages¶
287.1. Recursively Enumerable Languages¶
What is the set of languages that TM’s accept? We know that they accept RL’s and CFL’s. And additional languages.
Question: Is there any language that a TM cannot accept?
Definition: A language L is recursively enumerable if there exists a TM M such that L=L(M).
[Hah! All that says is that the languages that a TM can deal with now have a name!]
We say that M accepts the language. For every w in L, M should accept w.
Question: What happens if w is not in L? Saying that M can properly accepting strings in L doesn’t define happens if w is not in L. M may not halt in that case.
Note: We do not get a yes or no answer, just a yes if w is in L!
Definition: A language L is recursive if there exists a TM M such that L=L(M) and M halts on every w∈Σ+. Thus, A language L is recursive if and only if there exists a membership algorithm for it.
[Note the difference beteen a recursive language (one that is recognized by a TM) and a recursive algorithm (which merely means that it calls itself).]
NOTE: We will ignore the empty string. In Chapter 9, the definition of the TM assumes that the input string is always padded on both sides of the input. If the input could be a blank, the tape head would not know where the input string was. It would be easy to adjust the definition to include the empty string, but for now we will just examine languages that do not include λ.
Note
Not a problem if we use a one-sided tape as our base definition, which is a good argument for doing it that way.
287.1.1. Enumeration procedure for recursive languages¶
To enumerate all w∈Σ+ in a recursive language L:
287.1.2. Enumeration procedure for recursively enumerable languages¶
The above procedure does not work, since M might not halt on strings that are not in the language.
To enumerate all w∈Σ+ in a recursively enumerable language L:
Questions:
Are there languages that are RE but not recursive? yes.
Are there languages that are not RE? yes
We will prove that there is a language that is not recursively enumerable.
Note
Ask what is a powerset. 2{a,b},2pos.int.
Theorem 1
Theorem: Let S be an infinite countable set. Its powerset 2S is not countable.
Proof: Use diagonalization
s1s2s3s4s5s6s7...t10_101001...t211_00110...t3000_0100...t41010_110...t511111_11...t6100100_1...t70101000_......ˆt1011011...
Theorem 2
Theorem: For any nonempty Σ, there exist languages that are not recursively enumerable.
Proof:
Theorem 3
Theorem: There exists a recursively enumerable language L such that ˉL is not recursively enumerable.
Proof:
The next two theorems in conjunction with the previous theorem will show that there are some languages that are recursively enumerable, but not recursive.
Theorem 4
Theorem: If languages L and ˉL are both RE, then L is recursive.
Proof:
Theorem 5
Theorem: If L is recursive, then ˉL is recursive.
Proof:
If L is not recursive, then neither L nor ˉL can be RE.
The language L={ai|ai∈L(Mi)} is RE but not recursive (since we proved that its complement was not RE).
Hierarchy of Languages:
Now we will look at the grammar that represents the same language as the turing machine.
Note
Also mention DCFL (which is between reg and CFL), CS (which is between CFL and REC)
Definition: A grammar G=(V,T,S,P) is unrestricted if all productions are of the form
u→v
where u∈(V∪T)+ and v∈(V∪T)∗.
No conditions are imposed on the productions. You can have any number of variables and terminals on the left hand side.
Example 1
Let G=({S,A,X},{a,b},S,P),P=
S→bAaaXbAa→abAAX→λ
A derivation of aab is: (the left hand side that is replaced is underlined)
S⇒bAa_aX⇒abAa_X⇒aabAX_⇒aab
Example 2
Find an unrestricted grammar G such that L(G)={anbncn|n>0}
G=(V,T,S,P)
V={S,A,B,D,E,X}
T={a,b,c}
P=
Change the last rule to DX→c and you can derive the string aaabbcbcc, moves a c in the wrong place to the end of the string…
To derive string aaabbbccc, use productions 1, 2 and 3 to generate a string that has the correct number of a’s b’s and c’s. The a’s will all be together, but the b’s and c’s will be intertwined.
S⇒AX⇒aAbcX⇒aaAbcbcX⇒aaaBbcbcbcX
Use a B to move right through a group of B ‘s until it sees a c. Replace the c by a D, and use the D to move right to the end of the string. Then write the c at the end of the string. Use an E to move back to the left.
aaaBbcbcbcX⇒aaabBcbcbcX⇒aaabDbcbcX⇒aaabbDcbcX⇒aaabbcDbcX⇒aaabbcbDcX⇒aaabbcbcDX⇒aaabbcbcEXc⇒aaabbcbEcXc∗⇒aaaEbbcbcXc⇒aaaBbbcbcXc
Repeat this process until all the c ‘s have been moved to the end of the string. Then remove the X from the string.
aaaBbbcbcXc∗⇒aaaBbbbXccc∗⇒aaabbbBXccc⇒aaabbbccc
Theorem 6
Theorem: If G is an unrestricted grammar, then L(G) is recursively enumerable.
Proof:
List all strings that can be derived in one step.
S⇒w
List all strings that can be derived in two steps.
S⇒x⇒w
List all strings that can be derived in three steps.
Continue in this way for strings deriveable in any finite number of steps.
Therefore, it is possible to enumerate all strings in the language.
Theorem 7
Theorem: If L is recursively enumerable, then there exists an unrestricted grammar G such that L=L(G).
Proof: (Sketch!)
L is recursively enumerable.⇒ there exists a TM M such that L(M)=L.M=(Q,Σ,Γ,δ,q0,B,F)Idea M starts with w and eventually ends up with a final state.q0w∗⊢x1qfx2 for some qf∈F,x1,x2∈Γ∗Construct an unrestricted grammar G such that L(G)=L(M).But in G, grammar starts with S and eventually derives w, S∗⇒wSo the constructed grammar will mimic the Turing machine in reverse.Three steps:1. S∗⇒B…B#xqfyB…Bwith x,y∈Γ∗ for every possible combination2. B…B#xqfyB…B∗⇒B…B#q0wB…Bby following rules that mimic transitions in reverse order.3. B…B#q0wB…B∗⇒wHere just remove the blanks, and #q0.So here is the constructed grammar.G=(V,T,S,P)T=ΣV={Γ−Σ}∪Q{#}∪{S,A}P for each of the three above are:1. For S∗⇒B…B#xqfyB…BS→BS∣SB∣#AReplace S with lots of blanks and then finally a #`A→aA∣Aa∣q(for every a∈Γ and q∈F)then generate the strings of symbols finishing off with a final state.2. For B…B#xqfyB…B∗⇒B…B#q0wB…BCreate the rules that mimic what the TM does in reverse order.Mimic left and right moves.For each δ(qi,a)=(qj,b,R)Add to P, bqj→qiaFor each δ(qi,a)=(qj,b,L)add to P, qjcb→cqia for everyc∈Γ.3. For B…B#q0wB…B∗⇒wTo get rid of #q0 and blanks,#q0→λB→λThen show that S∗⇒w iff q0w∗⊢x1qfx2 for qf∈F
Definition: A grammar G is context-sensitive if all productions are of the form
x→y
where x,y∈(V∪T)+ and |x|≤|y|
Can be shown that another way to define these is that all productions are of the form:
xAy→xvy
This is equivalent to saying A→v can be applied in the context of x on the left and x on the right.
Definition: L is context-sensitive (CSL) if there exists a context-sensitive grammar G such that L=L(G) or L=L(G)∪{λ}.
In the definition of the grammar, we can’t have any lambda rules.
We put λ in there so we can claim that CFL ⊂ CSL
Theorem: For every CSL L not including λ, ∃ an LBA M such that L=L(M).
Theorem: If L is accepted by an LBA M, then ∃ CSG G such that L(M)=L(G).
Theorem: Every context-sensitive language L is recursive.
Theorem: There exists a recursive language that is not CSL.
Note
Section 11.3 covers context-sensitive languages (CSL). These languages lie between the context-free languages and the recursive languages. CSL’s and LBA’s (linear bounded automata) represent the same class of languages.