15-150: Principles of Functional Programming
Lecture 3: Recursion and Induction
Today we wrote some recursive functions for integers and lists. We
proved correctness of one such function (using strong induction) and
termination of another (using structural induction over lists).
Last time we discussed the 5-step methodology for writing
functions. There is really an implicit "STEP 6" to the 5-step
methodology: It entails proving that a function correctly implements
its specifications, e.g., that it satisfies its ENSURES
clause given its REQUIRES clause.
(There will be additional notes about structural induction next time.)
- Recursive functions
- Proof of correctness
- Mathematical induction ---
Mathematical induction can be useful when an integer
variable is reduced by 1 in the recursive part of a function.
- Strong induction --- Strong induction can be useful when an integer
variable is reduced by more than 1.
- Structural induction --- Structural induction can be useful for recursion over datatypes more general than integers.
- Correspondence between recursive function
clauses and proof by induction.