Midterm 2 Solution Fall 2013

The start variable already does not appear on the rhs

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: {0n : n is a prime}. Question 1. [10 marks total] (a) [4 marks] Consider the grammar S → R | T R → aRc | aR | T | ε T → aTb | aT | ε Give a context- free grammar in Chomsky normal form for this language. The start variable already does not appear on the RHS of a rule. Eliminate ε- rules S → R | T | ε R → aRc | aR | ac | a | T T → aTb | aT | ab | a Eliminate unit rules to get S → aRc | aR | ac | a | aTb | aT | ab | ε R → aRc | aR | ac | a | aTb | aT | ab T → aTb | aT | ab | a Replace terminals in long RHSs with variables S → ARC | AR | AC | a | ATB | AT | AB | ε R → ARC | AR | AC | a | ATB | AT | AB T → a...
View Full Document

This note was uploaded on 01/16/2014 for the course CSE 355 taught by Professor Lee during the Fall '08 term at ASU.

Ask a homework question - tutors are online