CS 550
Spring 2014
Programming Languages
Thursdays 18:30-21:20
University Crossings 153

Geoffrey Mainland
University Crossings 106
Teaching Assistant:
Mark Boady
Warning! This material is for an old version of the course.
$$ \newcommand{\ox}[1]{\llbracket #1 \rrbracket} $$

Please submit all files for this assignment by checking them in to your cs550 git repository at ~/cs550/git/hw2. Be sure to commit your work to the repository.

Please tell us how long each problem took you by noting the time you required to complete each problem in your submission.

Problem 1: Denotational Semantics of Roman Numerals

For this problem, you will be working with Roman Numerals. You may wish to consult the Wikipedia entry on Roman Numerals.

Submit the solutions to this problem in a file named roman.txt in the hw2 subdirectory of your git repository. Note that you do not have to write any Haskell code, although you may find it helpful to do so.

Problem 1.1: BNF for Roman numerals

Give a BNF definition of the Roman numerals from 1 to 100. One way to do this is to list them all exhaustively, but that is undesirable. Instead, you must give the most compact definition you can. You will likely need to define the syntax of Roman numerals using more than one rule of the form:

\begin{align*} a &::= \ldots \mathrel{|} \ldots \mathrel{|} \ldots \\ b &::= \ldots \mathrel{|} \ldots \mathrel{|} \ldots \mathrel{|} \ldots \end{align*}

Problem 1.2: Denotational semantics for Roman numerals

Define a denotational semantics for your language of Roman numerals. Your denotation function should be inductive and total. You may need to write “helper” denotation functions of the form $\ox{\cdot}_a, \ox{\cdot}_b$, etc.

Problem 2: Inductive Proofs on Lists

Submit the solutions to this problem in a file named list.txt in the hw2 subdirectory of your git repository.

Prove the following theorem, for all lists l, reverse (l ++ [j] ) = j : (reverse (l)). Please be sure to show your work: state the theorem, state the method of proof, break out each case, and state any inductive hypothesis you might use.

Problem 3: Big-Step Operational Semantics

Download the arith interpreter here. Extract the files and commit them to your git repository at ~/cs550/git/hw2/arith.

Your job is to complete the definition of the function bigeval in the file src/Eval.hs. This function must implement the big-step version of the semantics for the arithmetic language from Chapter 3 of Pierce. This problem is the Haskell variant on Problem 4.2.2 from Pierce. Note that you must complete the definition of bigeval—do not modify eval or eval1.