COMS W3261
Computer Science Theory
Lecture 7: September 26, 2012
Context-Free Grammars

Outline

1. Review

2. Definition of a Context-Free Grammar (CFG)

3. Derivations

4. Leftmost and Rightmost Derivations

5. Parse Trees

6. Ambiguity

7. Practice Problems

  1. Construct a CFG that generates the language { anbn | n ≥ 0 }.
  2. Prove that the language generated by the grammar G1 in section 2 consists of all and only all strings of balanced parentheses.
  3. Construct a CFG that generates ELP = { wwR | w is any string of a's and b's }. This is the language of even-length palindromes over the alphabet {a, b}. A palindrome is a string that reads the same in both directions.
  4. Prove that ELP is not a regular language.
  5. Construct a CFG for all regular expressions over the alphabet {a, b}.

8. Reading Assignment



aho@cs.columbia.edu