Computer Science Theory

Homework Assignment #2

October 1, 2012

Due in class 1:10pm, October 15, 2012

- You may consult with others but your answers must be written in your own words.
- Problems (1)-(5) are each worth 20 points.
- This assignment may be handed in October 17, 2012 for 50% credit.

- Consider the grammar
*G*:`S → a S b S | b S a S | ε`

- Describe in English the language generated by
*G*. Prove that*G*generates precisely this language. - Is the language generated by
*G*regular? Prove your answer. - Put the grammar
*G*in question (1) into Chomsky Normal Form. Use the Cocke-Younger-Kasami algorithm to parse the sentence`abab`

according to your CNF grammar. Display the CYK table constructed by the CYK algorithm and show how all parse trees for this sentence can be reconstructed from the CYK table. - From the grammar
*G*in question (1), construct a pushdown automaton that accepts L(*G*) by empty stack. Show all sequences of moves that your PDA can make to accept the input string`abab`

. - From your PDA in question (3),
construct an equivalent context-free grammar.
Show a parse tree for the input string
`abab`

according to your grammar. - Consider the language
*L*consisting of all strings of*a*'s and*b*'s that are even-length palindromes with the same number of*a*'s as*b*'s. If*L*is context free, construct a CFG for*L*and prove that your grammar generates precisely this language. If*L*is not context free, use the pumping lemma for context-free languages to prove that*L*is not context free.

aho@cs.columbia.edu