Solution

advertisement
1. Let R be a regular set contained in (a+b)*. Suppose I delete two b’s from each string
in R. Is the resulting set regular? Give rigorous proof of your answer. If a string does
not have at least two b’s in it, then through away the string.
Yes, the resulting set is regular since it can be expressed as
h1 (a)  a
R1  (a  b) * bˆ(a  b) * bˆ(a  b) *
h1 (b)  b
h (bˆ)  b
1
1
h2 (h1 ( R)  R1 ) where
h2 (a)  a
h2 (b)  b
h2 (bˆ)  
2. Let R be a regular set contained in (a+b+c)*. Rearrange the symbols in each string of
R so that all a’s appear first, then the b’s and then the c’s. Is the resulting set regular? Is
it context free?
Let R=(abc)*. Then rearranging symbols in each string of R yields the set
{a n b n c n | n  0} which is neither regular nor context free.


3. Prove or disprove that L= a i b j c k d l | either i  k or j  l is a cfl.
L is a cfl since it is generated by the following grammar.
G  ({S , S1 , S 2 , A, B, C , D}, {a, b, c, d }, S , {S  S1 D | AS 2
A  aA | 
B  bB | 
C  cC | 
S1  aS1C | B
S 2  bS 2 d | C
D  dD |  })
4. Prove or disprove each of the following:
a) The cfl’s are closed under intersection.
No. {a n b n c* | n  0} and {a * b n c n | n  0} are cfl’s but their intersection {a n b n c n | n  0}
is not a cfl.
b) The class of context-free languages is closed under homomorphism.
Yes. Let G be a cfg generating the language L. Apply the homomorphism to each
terminal symbol where ever it appears on the right hand side of a production.
c) The class of context-free languages is closed under inverse homomorphism.
Yes. Let M be a pda accepting a cfl L and let h be a homomorphism. The h 1 ( L) is
accepted by a pda M̂ that passes each input symbol through h and runs M on the result.
L( Mˆ )  {x | h( x)  L( M )} , that is L( Mˆ )  h 1 ( L)
5. Prove halting problem for Turing machines is undecidable
Let Ld  {xi | xi  L( M i )} . Ld is not recursively enumerable since it diagonalizes over
all r.e. sets. Now if we could solve the halting problem then Ld would be recusive. To
determine if xi is in Ld , first ask if M i halts on input xi . If the answer is no, then accept
xi . If the answer is yes, then simulate M i on xi and do the opposite.
6. For each of the following conditions, give an example of a set or prove that no such
set exists.
a) Both the set and its complement are recursive.
The empty set.
b) The set is recursive but its complement is not.
There is no such set since the class of recursive sets are closed under complement.
c) The set is recursively enumerable and its complement is recursive.
The empty set.
d) The set is recursively enumerable and its complement is also recursively enumerable.
The empty set.
e) The set is recursively enumerable but its complement is not recursively enumerable.
Ld is recursively enumerable but its complement Ld is not. See earlier answer.
f) Neither the set nor its complement are recursively enumerable.
Let Ld be in (0+1)*. Then a Ld +b Ld is not r.e. and its complement is not r.e.
Download