CS252r: Advanced Functional Language Compilation
Fall 2012: Maxwell Dworkin 323, Mon-Wed-Fri 3-4pm
Homework 1: Due Monday Sep 17
This homework is all about the mechanics of getting our environment set up. It will also force you to write a little bit of Coq code.
Feel free, and in fact I highly encourage you, to work with classmates to complete this assignment. Just make sure that you each complete the steps so you can set up and build the code for the course.
Use Piazza to post questions, or come see me if you get stuck. If you can't find me, try the good people in MD 309.
- Sign up for Piazza.
- Download and install OCaml.
- Download and install Coq 8.4.
- Download and install Proof General (for Emacs) or the CoqIDE, or God forbid, some vim hacks.
- If you don't already have a SEAS account, get one here
- Send mail to the instructor with your SEAS account name so that we can add you to the GIT repository
- Clone the GIT repository here: https://code.seas.harvard.edu/252r-coq-compile/252r-coq-compile
- Modify your .emacs file according to the README file in the repository.
- Run setup.sh to clone a copy of G.Malecha's library.
- Run make to build the sources for our compiler so far.
- In a file CpsSemantics.v, write an interpreter for the CPS language, following the basic ideas in the LambdaSemantics module found in the Lambda.v file.
- Mail your CpsSemantics.v to the instructor.
For advanced students:
- The CPS translation that we've defined binds the continuation to a variable before we enter a match, so that the continuation can be shared across the arms of the match. But when the continuation is itself a variable, this eta expansion is unecessary. Modify the CPS translation to avoid this overhead.
- It is often useful for a translation to ensure that the output term uses unique variables for each binder. Modify the CPS translation so that a fresh variable is used for each binder in the translation.
- Define an alternate Cps language that has at most one binding form (i.e., lambda). For instance, "let x = c(v1,...,vn) in e" would be represented as "(\x -> e) (c (v1,...,vn))". The challenge will be representing "letrec" and "match".