CSCI 2670, Spring 2012

Introduction to Theory of Computing

Homework Assignment 6

Due Monday November 5, 2012

(Unless otherwise specified, questions are selected from the textbook Michael Sipser, Introduction to the Theory of Computation, Second Edition, Thomson Course Technology.)
  1. Consider the language {an(bc)n | n ≥ 0 }. Draw a PDA diagram to recognize this language. Note that this is not the same language as {anbncn | n ≥ 0 }

  2. Based on the PDA you will have constructed for question 1, construct a context-free grammar for this language by following the construction steps given in the proof of Lemma 2.27 (page 119).

  3. Postfix Expressions (or expressions in the Reverse Polish notation) are expressions transformed from normal arithmetic expressions. For example, expression a+b*(c-d)+e written in postfix form is abcd-*+e+. See Wikipedia for more information.

    Without the use of precedency of operators or parentheses, such postfix expressions can be simply evaluated from left to right using a single stack. For example, for the postfix abcd-*+e+, assume the values of a, b, c, d, e, an evaluation algorithm reads in and put in the stack a, b, c, d in order (from left to right). When encountering the operator '-', it pops the top TWO elements from the stack, which are: d, c and then applies the minors operation c-d and push the result (a single value) back to the stack. Note that the stack now contains, from bottom to the top, a, b and the result of c-d.

    After this, the algorithm continues to read the next symbol in the input, which is *, another operator. As before, it pops the top two elements and apply operation * on them and push the result back to the stack. The process repeats by pushing each non-operator into the stack, applying the operation of each operator on the top two elements of the stack, and then pushing the operation result back to the stack. The final content of the stack is a single value equal to the value of the input postfix expression.

    Note that the evaluation algorithm described above essentially also gives a process to recognize such postfix expressions. This question ask you to draw a PDA to recognize the language of postfix expressions. Note that your PDA does not evaluate but just check the syntax for an input postfix expression. You need to define the alphabets for input and for stack, before you start drawing the PDA.

  4. Using the Pumping Lemma for CFLs to prove that language {0n 1m 0n 1m| n, m ≥ 0 } is not context-free.

  5. Question 2.16 (page 129). Outlines of your ideas suffice.