Today, we refreshed our understanding of extensional equivalence, which we used to describe the principle of referential transparency, or the refactoring lemma. We saw how we can use equational reasoning to think about code where we swap equals-for-equals, which is very helpful when maintaining existing code.
We went over the 5-step methodology for writing functions, which entails writing a function's type, preconditions, postconditions, body, and tests.
After that, we discussed recursion, our workhorse for writing functions for this course. We saw that using the recursive leap of faith, we can simplify the process of writing a recursive function significantly, by only considering the case immediately prior to the general one we are working on and assuming our function already works. We saw that this was exactly akin to the process of mathematical induction, where our induction hypothesis helps us prove our theorem in generality.
We then used induction on SML code to prove the correctness of the pow function. We then explored more SML features such as case expressions and lists, which differ from lists in other languages in that they must contain elements that all share a type.
Finally, we closed off with a case study into a fast exponentiation function, which we proved was equivalent to the slower implementation using induction.