Applied Deliberation

Assorted Adventures of Sampsa Kiiskinen

TIEA1000 Topical Themes in Mathematical Information Technology: Dependently-Typed Programming and Proof Theory, 1–5 ECTS

This is the course plan drafted on 2019-05-01 and finalized on 2019-09-03.

Introduction

Welcome to a new course on using the Coq proof assistant to explore dependently-typed programming and proof theory. This course is mostly based on CIS 500 [1] as organized in the University of Pennsylvania, although we only have half the time and cover only about a quarter of the material. In particular, we cover

This course is not intended to make you an expert Coq user, but rather to give you a concrete feel of formal proofs. Understanding their essence is, in my experience, both practically useful and philosophically satisfying.

Prerequisites

Completing this course requires mathematical maturity and a good grasp of programming. While these requirements are difficult to quantify exactly, familiarity with some (say, three) of the following courses should suffice.

Code Name
ITKA201 Algorithms 1
ITKA2050 Introduction to Software Security
MATA132 How to Prove It?
MATA140 Introduction to Discrete Mathematics
MATA150 Logic
TIEA241 Automatons and Formal Languages
TIEA341 Functional Programming 1

However, the lack of familiarity can be compensated with time and motivation.

Materials

The main material for this course, henceforth known as the book, is Software Foundations: Logical Foundations [2]. It is freely licensed and available online (see the section on completing the course about obtaining it). Supplementary material, or the other books, include Certified Programming with Dependent Types [3] and Homotopy Type Theory: Univalent Foundations of Mathematics [4]. They are also more or less freely licensed and available online.

The book contains all the necessary exposition and exercises we will need on this course. It is elementary in the sense that it can be understood completely by the end of the course. The other books are there just for the amusement of those who enjoy living inside their heads. They are not elementary at all, as they bring the reader to the forefront of research, where nobody understands the topics completely.

Schedule

This course begins with an introductory lecture on 2019-09-03 16:15 (local time, whatever that may be), features two classroom activities per week and ends by 2019-10-29 18:00. The classroom activities align with the book in the following way.

Date Weekday Module Chapter
2019-09-03 Tuesday Preface Preface
2019-09-10 Tuesday Basics Functional Programming in Coq
2019-09-12 Thursday Induction Proof by Induction
2019-09-17 Tuesday Lists Working with Structured Data
2019-09-19 Thursday Poly Polymorphism and Higher-Order Functions
2019-09-24 Tuesday Tactics More Basic Tactics
2019-09-26 Thursday
2019-10-01 Tuesday Logic Logic in Coq
2019-10-03 Thursday
2019-10-08 Tuesday IndProp Inductively Defined Propositions
2019-10-10 Thursday
2019-10-15 Tuesday
2019-10-17 Thursday
2019-10-22 Tuesday ProofObjects The Curry–Howard Correspondence
2019-10-24 Thursday

At the beginning of each week, a set of exercises is assigned from the book. Each set must be done before the next set is assigned, so there is exactly one week of time to do each one. However, nothing prevents doing future exercises ahead of time or going back to improve past exercises later (there are a few exercises that may benefit from doing this).

You may personally negotiate later deadlines, but this is generally not a good idea, because catching up is really difficult. Ideally, we would not have any deadlines at all, but experience suggests that they really improve outcomes.

Classroom Activities

The classroom activities on this course are primarily exercise sessions, where you can do exercises together and get guidance from an instructor. The activities may secondarily become lectures, in case general questions arise or I happen to have some interesting stories to tell, but the remaining time is always reserved for exercises. Participation is voluntary, but strongly encouraged.

The activities should take place in a computer classroom, but it is a good idea to bring your own laptop regardless.

Exercises, Grades and Credits

Exercises in the book are rated from one to five stars. The easiest exercises have the rating of one star and often take less than a minute to do, while the hardest exercises have the rating of five stars and can sometimes take several hours to get right. The scale is obviously nonlinear, but this is balanced out by the fact that there is a limited supply of exercises.

In the chapters covered on this course, there are

While these classifications provide some insight into the structure of the book, they do not affect your assessment in any way. Your grade \(\measuredangle\) or, more precisely, the number of credits you get from passing this course, is simply determined by feeding the number of stars \(\star\) you have gotten from fully completed exercises to the projection function \(\pi\), which is defined according to

\[\begin{eqnarray} {\star} & : & \mathcal U \\ {\star} & = & \{n : \mathbb N \mid n \le 355\} \\ {\measuredangle} & : & \mathcal U \\ {\measuredangle} & = & \{n : \mathbb N \mid n \le 5\} \\ \pi & : & {\star} \to {\measuredangle} \\ \pi (n) & = & \begin{cases} 0, & \phantom{00}0 \le n \le 177 \\ 1, & 178 \le n \le 213 \\ 2, & 214 \le n \le 248 \\ 3, & 249 \le n \le 284 \\ 4, & 285 \le n \le 319 \\ 5, & 320 \le n \le 355. \end{cases} \end{eqnarray}\]

I reserve the right to transparently hand out extra stars for doing harder exercises from the other books, pointing out mistakes in the material or being helpful in other ways.

Visualization of \pi
Visualization of \(\pi\)

Summative and Formative Assessment

I will grade your solutions within one month of you handing them in (see the section on completing the course for details).

Time permitting, I will also look over your solutions and provide feedback. The feedback will not affect your grade, unless your solutions are obviously plagiarized. If you happen to copy someone else’s answer, be honest about it and explain what lead you to do so and what you learned from it. As long as this does not happen too frequently, it will not be considered plagiarism.

Tests or Examinations

There is no written test, but there is a brief oral test at the end of the course. The oral test consists of one question and its sole purpose is to ensure that you did not blindly copy your solutions from the Internet or forcefully smack Coq into submission. It is not graded, but it can be failed (with a dedicated lack of effort).

Completing the Course

The following instructions explain how to complete this course, in as much detail as possible.

Returning Files

If you send me an archive, package the files instead of the directories and name the archive according to your university username.

To create a Gzip archive, you can use the following command.

$ tar -czf sapekiis.tar.gz \
  Preface.v Basics.v Induction.v Lists.v Poly.v \
  Tactics.v Logic.v IndProp.v ProofObjects.v Postscript.v

Make sure to check that you did not accidentally package your animes, because I do not want to see that garbage.

$ tar -tf sapekiis.tar.gz

To create a ZIP archive, you can use either of the following commands.

$ rm -f sapekiis.zip && zip -9q sapekiis.zip \
  Preface.v Basics.v Induction.v Lists.v Poly.v \
  Tactics.v Logic.v IndProp.v ProofObjects.v Postscript.v
$ jar -Mcf sapekiis.zip \
  Preface.v Basics.v Induction.v Lists.v Poly.v \
  Tactics.v Logic.v IndProp.v ProofObjects.v Postscript.v

Checking the packaging works analogously.

$ unzip -l sapekiis.zip
$ jar -tf sapekiis.zip

Making a public Git repository is a bit more involved, but can be done on the university network as follows.

Let us first create a remote repository with a random name.

$ ssh sapekiis@charra.it.jyu.fi
$ cd /autowebhome/home/sapekiis/public_html
$ echo "$(echo "$RANDOM" | sha256sum | head -c 6).git"
abcdef
$ mkdir abcdef
$ cd abcdef
$ git init --bare
Initialized empty Git repository in /autowebhome/home/sapekiis/public_html/abcdef/
$ mv hooks/post-update.sample hooks/post-update
$ git update-server-info
$ exit

Let us then create a local counterpart of the same repository.

$ cd
$ mkdir tiea1000
$ cd tiea1000
$ git init
Initialized empty Git repository in /home/sapekiis/tiea1000/.git/
$ touch Preface.v Basics.v Induction.v Lists.v Poly.v \
  Tactics.v Logic.v IndProp.v ProofObjects.v Postscript.v
$ git add Preface.v Basics.v Induction.v Lists.v Poly.v \
  Tactics.v Logic.v IndProp.v ProofObjects.v Postscript.v
$ git commit -m "Did all the exercises."
[master (root-commit) defaced] Did all the exercises.
  10 files changed, 0 insertions(+), 0 deletions(-)
  create mode 100644 Preface.v
  create mode 100644 Basics.v
  create mode 100644 Induction.v
  create mode 100644 Lists.v
  create mode 100644 Poly.v
  create mode 100644 Tactics.v
  create mode 100644 Logic.v
  create mode 100644 IndProp.v
  create mode 100644 ProofObjects.v
  create mode 100644 Postscript.v
$ git push --set-upstream sapekiis@charra.it.jyu.fi:/autowebhome/home/sapekiis/public_html/abcdef.git master
Counting objects: 3, done.
Writing objects: 100% (20/20), 420 bytes | 0 bytes/s, done.
Total 20 (delta 0), reused 0 (delta 0)
To sapekiis@charra.it.jyu.fi:/autowebhome/home/sapekiis/public_html/abcdef.git
  * [new branch]      master -> master
Branch master set up to track remote branch master from sapekiis@charra.it.jyu.fi:/autowebhome/home/sapekiis/public_html/abcdef.git.

Anyone can now clone the repository as follows.

$ cd /tmp
$ git clone http://users.jyu.fi/~sapekiis/abcdef.git
Cloning into 'abcdef'...
Checking connectivity... done.
$ cd abcdef
$ git ls-files
Preface.v
Basics.v
Induction.v
Lists.v
Poly.v
Tactics.v
Logic.v
IndProp.v
ProofObjects.v
Postscript.v

While Git is the best way to do and return your solutions, I would recommend against using it if you do not know how to do so properly.

References

[1] B. Pierce, CIS 500: Software Foundations. 2018 [Online]. Available: https://www.seas.upenn.edu/~cis500/current/

[2] B. Pierce et al., Software Foundations: Logical Foundations: Version 5.6. 2019 [Online]. Available: https://softwarefoundations.cis.upenn.edu/lf-current/

[3] A. Chlipala, Certified Programming with Dependent Types. 2019 [Online]. Available: http://adam.chlipala.net/cpdt/

[4] The Univalent Foundations Program, Homotopy Type Theory: Univalent Foundations of Mathematics. Institute for Advanced Study, 2013 [Online]. Available: https://homotopytypetheory.org/book/

[5] S. Kiiskinen et al., “The Book,” 09-Jan-2019. [Online]. Available: /data/tiea1000/sf-lf.tar.gz

[6] The Coq Development Team, “The Coq Proof Assistant: Version 8.9.1,” 20-May-2019. [Online]. Available: http://coq.inria.fr/

[7] D. Aspinall, “Proof General,” 18-Sep-2016. [Online]. Available: https://proofgeneral.github.io/

[8] W. Honore and T. Refis, “Coqtail,” 30-Aug-2019. [Online]. Available: https://github.com/whonore/Coqtail

[9] E. J. G. Arias, B. Pin, and P. Jouvelot, “jsCoq: Towards Hybrid Theorem Proving Interfaces,” in Proceedings of the 12th workshop on user interfaces for theorem provers, 2016, vol. 239, pp. 15–27.

[10] E. J. G. Arias, “jsCoq,” 23-Apr-2019. [Online]. Available: https://github.com/ejgallego/jscoq