Homework 2: IMP and Operational Semantics
Due date: October 13, 6pm
Grading: 15% (CS 345H) or 9% (CS 386L) of your course grade
In this homework, we'll continue studying operational semantics through the lens of the IMP language we saw in lecture.
The homework is in two parts, both in the Homework.v
file.
- In Part 1, we'll explore different notions of termination in IMP, and see how we can (perhaps surprisingly) build an interpreter for IMP even though IMP programs may not terminate.
- In Part 2, we'll develop from first principles some of the ideas of abstract interpretation and build a static analyzer for arithmetic expressions.
Table of contents
Preparation
Make sure you have Coq installed and working, following the instructions from Homework 0. There's no other setup for this homework.
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 hw2-jamesbornholt
, so I would do:
git clone git@github.com:utcs345h/hw2-jamesbornholt.git
cd hw2-jamesbornholt
Complete the homework
In your repository, there is just one file you need to edit:
Homework.v
is the Coq file for Parts 1 and 2 of the homework.
The file uses 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 198 points on this homework, with no extra credit.
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:
- UW's CSE 505 has some great notes on Coq in their first few lectures.
- The first chapter of Software Foundations is a crash course on both Coq programming and proofs.
- If you're trying to find tactics to use in proofs:
- Joe Redmon's Coq Tactics Index is somewhat (in)famous
- Cornell's CS3110 has a Coq tactics cheatsheet
- Coq's standard library documentation is extensive. Use it to find helpful lemmas about data structures you're using from the standard library (which, in this homework, is just
nat
from theArith
module). - You can also try Coq's built-in
Search
command, as this blog post explains
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 file you should need to modify is Homework.v
.
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 using GitHub Actions.
It will pass as long as your Homework.v
file compiles and has no remaining admit
or Admitted
statements.
This is only a partial grader, and we're using it only to give you early feedback on your submissions—we will still be reading and grading your code by hand. Just because the autograder passes doesn't mean you'll get full points; just because the autograder fails doesn't mean you won't get full points.