CS 345H: Programming Languages (Honors) Fall 2022

Homework 1: Denotational Semantics and Rosette

Due date: September 22, 6pm
Grading: 15% (CS 345H) or 9% (CS 386L) of your course grade

In this homework, we'll continue our exploration of denotational semantics, a style of programming language semantics that uses mathematical functions to define the meaning of programs.

The homework is in three parts (but only two files):

Table of contents


First, make sure you have Coq installed and working, following the instructions from Homework 0.

We'll also be working with Rosette in this homework, so we need to get the Racket programming language and Rosette itself set up on your system. Start by installing Racket (at least v8.1). On a Mac, you can get it from Homebrew:

brew install --cask racket

On Linux or Windows (or Mac, if you don't use Homebrew), download and run the appropriate installer from from the Racket website. If you're on Linux, don't get Racket from your package manager—most of them have very outdated versions of Racket that won't work.

We'll need access to the raco command-line tool that comes with Racket. Try running:

raco help

from a terminal. If it works, jump down to installing Rosette below. If not, you need to get the directory you installed Racket into onto your PATH. The Beautiful Racket book has some good instructions on how to do this.

Install Rosette

To install Rosette from the command line:

raco pkg install rosette

You can test that it worked correctly by running something like:

racket -I rosette -e 1

If you just see 1 as output, you're good to go. Otherwise, something went wrong when installing Rosette—try to read back through the output of the installation and debug (or ask for help).

Choosing a Rosette IDE

Racket comes with the DrRacket IDE, which might be a good place to start, especially if you've never written Racket before. It comes with a bunch of useful features like highlighting the source of bindings (try mousing over stuff!). On a Mac, DrRacket will be in the /Applications/Racket v8.4 folder.

The Magic Racket extension for Visual Studio Code is also a pretty good option.

Get the code

We'll be using GitHub Classroom to check out and submit this homework. Follow the GitHub Classroom URL on Ed to create your private copy of the homework repository, and then clone that repository to your machine. For example, the repository it created for me is called hw1-jamesbornholt, so I would do:

git clone git@github.com:utcs345h/hw1-jamesbornholt.git
cd hw1-jamesbornholt

To make sure everything's working with your Rosette install, run:

raco test Homework.rkt

You should see 26 failing tests. You'll know you've finished the Rosette part of the homework when all these tests pass!

Complete the homework

In your repository, there are two files you'll need to edit. Homework.v is the Coq file for Parts 1 and 2 of the homework, and Homework.rkt is the Rosette file for Part 3. Both files use comments to explain what's going on and list the problems you need to solve. A few of the problems in both files ask for English answers rather than code; for those questions, you should just add your answer in the file as a comment.

There is a total of 142 points on this homework, plus 6–12 points of extra credit (and a competition for those points!). As a cross-reference, here's a list of the problems on this homework:

Resources for writing Coq

Coq has a slightly steep learning curve. Here are some resources you could reference if you need help understanding how to write Coq or Coq proofs:

Resources for writing Rosette

Rosette is a language we haven't spent much time talking about, so here are a few references for learning Racket and Rosette:

What to submit

Submit your solutions by committing your changes in Git and pushing them to the private repository GitHub Classroom created for you in the Get the code step.

The only files you should need to modify are Homework.v and Homework.rkt.

GitHub Classroom will automatically select your most recent pushed commit before the deadline as your submission. There's no need to manually submit anything else via Canvas or GitHub.

GitHub Classroom also has a simple autograder for Coq proofs and Rosette code using GitHub Actions. It will pass as long as your Homework.v file compiles and has no remaining admit or Admitted statements, and your Homework.rkt tests pass. This is only a partial grader, so just because the autograder passes doesn't mean you'll get full points—we will still read your code by hand. Also, the autograder does not check the extra credit question.