Assignment 6

Nils Anders Danielsson

  1. Four grammar transformations, Bin, Del, Unit and Term, were discussed in a lecture. The results of the Bin and Term transformations are not always uniquely defined: there is a choice of how to name the new nonterminals that may be introduced.

    Consider the context-free grammar G = ({EON}, {+, −, 1}, P, E), where the set of productions P is defined in the following way:

      E → E O E | N
      O → + | − | ε
      N → 1 | 1 N

    1. (1p) Construct one possible (correct) result of applying the Bin transformation to G. Denote this grammar by G.
    2. (1p) Construct the result of applying the Del transformation to G. Denote this grammar by G.
    3. (1p) Construct the result of applying the Unit transformation to G. Denote this grammar by G.
    4. (1p) Construct one possible (correct) result of applying the Term transformation to G. Denote this grammar by G.
    5. (2p) Construct the CYK table for G and the string w = 1 + 1 1 − 1.
  2. (4p) Prove that { int␣X;␣X␣=␣3;  | X ∈ {a, …, z}+}, containing strings like “int␣foo;␣foo␣=␣3;”, is not a context-free language over the alphabet {a, …, z} ∪ {0, …, 9} ∪ {=;}.

    You may use the following lemmas: