You are on page 1of 6

CS3133

FINAL EXAM

Name_____________
Date: October 11, 2007 All documentation permitted 1. (25 points) Is the following language context free? Justify your answer.

{a

m n

b c p | ( m = n or n = p ) and ( m, n, p 0 )} .

2. (25 points) Are recursive languages closed under intersection? That is, for any recursive languages L1 and L2, must L1 L2 be recursive? Explain why or why not.

3. (25 points) Construct a CFG in Chomsky Normal Form for the language {a mb2mcn | m, n 1} .

4. (25 points) Is it decidable whether a string does not belong to a context free language? That is, given CFG G and string w * , is it decidable if w L ( G ) ?

CS3133 Solutions to Final Exam

1. {a mb n c p | m = n or n = p} = {a mb n c p | m = n} {a mb n c p | n = p} =L1 L2 A grammar to generate L1 is


S1 Am = n Astringcs Am = n | aAm = nb Astringcs | cAstringcs

and a grammar to generate L2 is

S 2 Astringas An = p Astringas | aAstringas An = p | bAn = p c

And finally S S1 | S2 . 2. Because L1 and L2 are recursive, there are total Turing Machines M1 and M2 such that L ( M 1 ) = L1 and L ( M 2 ) = L2 . So there is a total Turing Machine
if w L ( M 1 ) and w L ( M 2 ) then return accept else return reject to accept L1 L2 .

3. A CFG to generate {a mb 2 m c n | m, n 1} is
S Aa mb2 m Acn Aa mb2 m aAamb2 m bb | abb Acn cAcn | c Putting this into Chomsky Normal Form, S Aa mb2 m Acn
Aa mb2 m Aa X 0 | Aa X 1 X 0 Aa mb2 m X 1 X 1 Bb Bb Aa a Bb b Acn Cc Acn | c Cc c

4. The question is decidable. Given CFG G, we can convert it to an equivalent CFG in Chomsky Normal Form. Testing all derivations in the new grammar of length 2* w 1 , we return w L ( G ) if and only if there does not exist a derivation of w.

You might also like