15-150: Principles of Functional Programming

Lecture 5: Datatypes, Recursion and Structural Induction on Trees

We considered the predefined datatype order with constant constructors LESS, EQUAL, GREATER.
We made up some of our own datatypes, including a datatype to model the extended integers, two different tree datatypes, and a datatype for operator-operand trees.

We showed how to prove theorems about trees using structural induction.

Key Concepts

Sample Code

The notes from last lecture

are also again relevant. In particular, please read the proof of extensional equivalence of two implementations of "flattening" a tree.

Proof of totality of the depth function discussed in lecture

Slides from Lecture