CS 340 - Assignment 3

Due: Wednesday, October 3rd by 11:59 PM

Context-free languages and Turing Machines

Problem 1.

Define a context-free grammar that generates the language of all parentheses-enclosed, comma-separated lists.  The alphabet of terminal symbols is

( ) , a

A list member can be an a symbol or a nested list.  A list with 0 members (empty list) is allowed.

Examples of strings in the language:







Examples of strings not in the language:






Problem 2.

Use JFLAP to define a Turing machine that, given an input string consisting of a sequence of a, b, and c symbols, generates the reverse of the original string.  Note that the output string does not have to overwrite the input string; it is acceptable to generate the output somewhere else on the tape.

For example, if the input string is


then when the Turing machine halts, somewhere on the tape it should have generated the output


Submitting your work

Save your context-free grammar in a plain text file.  It should look something like this

This is an example context-free grammar (palindromes over the alphabet {a, b}).

The start symbol is "P".

P -> epsilon
P -> a
P -> b
P -> aPa
P -> bPb

Save your Turing machine in a JFLAP (.jff) file.

Create a zip file containing your solutions to both problems and upload them to the marmoset server as Project 3.

The Marmoset server is available using the URL: