15-150: Principles of Functional Programming
Lecture 3: Recursion and Induction
Today we write some recursive functions and prove their correctness.
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., its ENSURES clause.
Consequently, we show how to prove correctness of some recursive
functions using both mathematical induction and strong induction.
- 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.
- Correspondence between recursive function
clauses and proof by induction.