Choose Your Own Adventure!
Some students will have previous experience with functional programming, some with formal mathematical proofs, and some will be completely new to the area. For that reason, everyone will get their own choice of which exercises to tackle throughout the semester.
The summary is that you will have to complete 10 things by the end of the semester. What is a "thing?" A set of exercises from one of the chapters of Software Foundations. The exercise sets will come in three different groups of increasing difficulty:
- Standard: All of the 1 star and 2 star exercises of a chapter, some of which we will do together in class.
- Advanced: All of the 3 star exercises of a chapter.
- Challenge: A single, select 4 star or 5 star exercise.
When in doubt, stick with the Standard exercises for the chapters we cover in class. If those become too easy, try your hand at some Advanced exercises. If you have success with those, and see a Challenge problem that piques your interest, feel free to have a go.
There are also many more chapters and books to the Software Foundations series covering other, specialized topics. If one of those are of interest to you, talk to the professor to pick some exercises to work on, since explicit permission is needed if you go outside the scope of the in-class lectures. Otherwise, there are some exercise sets listed above that have been pre-approved for you.
Mechanical vs Prosaic
Both traditional "pen-and-paper" proofs written in natural human language and the newer machine-checked proofs written in a formal programming language have their own advantages and disadvantages. On the one hand, traditional proofs are written in a prose style that fits well with the human's understanding of the problem and elides obvious details. However, many students first learning this style have difficulty understanding what is really necessary to say, what is obvious or not, and whether the statements made have any meaning at all. On the other hand, machine-checked proofs are written using a formally rigorous and structured language that removes any ambiguity, and whose correctness can be automatically confirmed. However, the level of detail can make it easy to miss the forest for the trees, and the inflexible structure can overshadow the bigger-picture idea that is more useful to humans than computers.
That's why, in this class, you will be writing both styles of proofs for the same exercises. To fully complete a given set of exercises requires two parts:
- for all the exercises, write the proofs formally in Coq as stated in Software Foundations, and
- for half the exercises rounded up, write an accompanying informal proof in English prose.
That means there will always be at least one informal English proof, even for a one-question Challenge exercise. The informal proof may be done in comments next to the formal proof in the same file, or they may be gathered in a separate file. Either way, be sure to document where these may be found in a way that someone else can find them (see below).
To have the best success in class, the formal and informal proofs should be seen as complementary parts of the same thing as opposed to two separate and unrelated tasks. As the exercises become more challenging, here is a suggested workflow that integrates both formal and informal aspects to harness their complementary strengths:
- Start with some introductory tactics in the formal proof (like intros and induction) to let the computer guide the overall structure of the proof. For example, what cases do you have, and what do your induction hypotheses look like in each case.
- Begin an informal proof with that same structure, and in each case, convince yourself why that case should be true. You can hand-wave over some of the more obvious details, and instead focus on the essential challenge of why the case is correct. Sometimes this is trivial. Sometimes you have to just apply the inductive hypothesis. Sometimes you need to use a previous fact already proved before.
- Having informally convinced yourself, you now need to convince the computer. Try to use the intuitive reason why each case is correct to guide your tactics in Coq. There may be some additional symbolic manipulation that needs to happen inbetween steps in your informal proof to connect the gaps.
- Finally, after finishing the formal proof, look back at your informal proof to check for mistakes. Did you forget an important step that was worth explaining to antoher person? Was one of your assumptions or conclusions actually incorrect?
If you follow this plan for the more challenging exercises, then you will end up with both formal and informal proofs in the same time it takes to just do one on its own. It is easy to write a wrong English proof, but the computer won't be convinced. It is easy to spend all day spamming Coq tactics until you get to
Qed without understanding what is going on.