6. Lecture 6: Functional Programming
Lecture 3 introduced inductive types by example, reconstructing ℕ and List and defining functions on them by pattern matching. This lecture returns to that material and gives the general mechanism, following chapter 5 of the Hitchhiker's Guide to Logical Verification.A. Baanen, A. Bentkamp, J. Blanchette, J. Hölzl, J. Limperg, The Hitchhiker's Guide to Logical Verification, 2026 edition, chapter 5. It reads an inductive definition as a list of constructors and names what the kernel derives from them, it defines total functions by structural recursion and explains why Lean insists on termination, it packages data in structures, and it explains type classes, the mechanism that Lecture 2 used for Membership and Lecture 4 used for the associativity and commutativity that ac_rfl consults.
The course spends two weeks on this chapter. This lecture is the programs side, defining data and functions. Lecture 7 is the proofs side, deriving the structural induction principle and proving the properties of these programs. So this lecture states the laws of its functions and proves only those that computation or a single case analysis settles, and it defers every proof that needs induction to Lecture 7, exactly as Lecture 5 deferred the general theory of structural induction.
This lecture is also available as presentation slides.