15-212: Principles of Programming

Lecture 8: Representation Invariants (Red/Black Trees)

We demonstrate a complicated representation invariant using Red/Black Trees. The main lesson is to understand the subtle interactions of invariants, data structures, and reliable code production. In order to write code satisfying a strong invariant, it is useful to proceed in stages. Each stage satisfies a simple invariant, and is provably correct. Together the stages satisfy the strong invariant.

Key Concepts

Sample Code

On-line Notes by Robert Harper

Suggested Reading in Programming in Standard ML:

[ CS 15-212 Home page | schedule | language | assignments | handouts ]

Michael Erdmann