# CSU390 08S: Homework 05

Created: Thu 14 Oct 2008

Assigned: Thu 14 Feb 2008
Due: Mon 25 Feb 2008

Note: This assignment cannot be turned in late. See "Specific Instruction (1)" below.

## General Instructions

1. Please review the grading policy outlined in the course information page.

2. On the first page of each part of your solution write-up, you must make explicit which problems are to be graded for "regular credit", which problems are to be graded for "extra credit", and which problems you did not attempt. Please use a table something like the following

Problem01020304 0506070809...
CreditRCRCRCECRC RCNARCRC...

where "RC" is "regular credit", "EC" is "extra credit", and "NA" is "not applicable" (not attempted). Failure to do so will result in an arbitrary set of problems being graded for regular credit, no problems being graded for extra credit, and a five percent penalty assessment.

3. You must also write down with whom you worked on the assignment. If this changes from problem to problem, then you should write down this information separately with each problem.

## Specific Instructions

1. Note: This assignment cannot be handed in late. I will be passing out solutions to this assignment the day it is due, in preparation for the midterm exam.

2. This is a somewhat longer assignment than usual, and it is worth somewhat more points than usual. You also have more time to complete this assignment than usual: note that it is due on Mon, Feb 25.

3. In Problems 1, 2, 3, and the first half of Problem 4, you are required to construct a context-free grammar for a given language. You should consider the five CFG patterns discussed in class and how these patterns can be used to construct CFGs for the languages in question. You solutions should be modeled after the solution we gave in class for Sipser Exercise 2.6 (c); a handout describing this solution is available here.

Note: You must describe what each variable in your context-free grammar does, in a manner similar to the solution given in the handout.

4. In Problem 5 and the second half of Problem 4, you are required to construct a PDA for a given language. You should give finite state diagrams for such PDAs, similar to those given in class and in Figures 2.15, 2.17, and 2.19 from the Sipser text.

5. In Problem 6, you are to demonstrate that the given grammar is ambiguous. To do so, you must show multiple left-most (or right-most) derivations for a string in the given language. (See pp. 105-106 of the Sipser text.) To attach a "meaning" to any such derivation, you will likely need to consider the parse trees associated with these derivations.

6. In Problems 7, 8, and 9, you should use the Pumping Lemma for context-free languages to prove that the languages in question are not context-free. See Examples 2.36, 2.37, and 2.38 from the Sipser text for examples of such Pumping Lemma proofs. See also the following handout.

Note: I would strongly suggest that you attempt more than one of these as you will almost certainly see such a problem on your midterm exam.

## Problems

Required: 7 of the following 9 problems
Points: 16 pts per problem

1. Exercise 2.4 (b,c)

2. Exercise 2.6 (d)

• Exercise 2.4 (e)

• Construct a CFG for the following language:

{ai bj | i <= j <= 2i}

3. Exercises 2.9 and 2.10.

4. Give finite state diagrams for PDAs which accept the languages described in Exercises 2.4 (d) and 2.6 (c).

Hint: Make judicious use of non-determinism.

5. Problem 2.27 (a).

Hint: The ambiguity present in the grammar shown in Exercise 2.27 is due to the `if-then` and `if-then-else` statements. The ambiguity you will discover is referred to as the "dangling else" ambiguity.

6. Problem 2.30 (a)

7. Problem 2.30 (d)

8. Problem 2.31

jaa@ccs.neu.edu