Introduction to Functional Programming (1996/7)
This year's (1997/8) course is here. The
present page has more material.
Computer Science Tripos, Part II (General) and Diploma in Computer Science
Twelve lectures, beginning on Fri 16th Jan 1997, ending on Tue 11th Feb 1997
Tuesday, Thursday & Friday at 12:00 in the
Hopkinson Lecture Room
Entire notes (160 pages):
- Title, preface, table of contents:
- Chapter 1 - Introduction:
- Chapter 2 - Lambda calculus:
- Chapter 3 - Lambda calculus as a programming language:
- Chapter 4 - Types:
- Chapter 5 - A taste of ML:
- Chapter 6 - Further ML:
- Chapter 7 - Proving programs correct:
- Chapter 8 - Effective ML:
- Chapter 9 - Examples:
Copies of slides
Additional material is available from those who have taught
the course in previous years: Mike Gordon
Gordon. The theoretical part of the course is also covered by lecture
notes from Larry
- Introduction and Overview:
- Lambda calculus as a formal system:
- Lambda calculus as a programming language:
- Details of ML:
- Proving programs correct:
- Effective ML:
- ML examples I: Symbolic differentiation:
- ML examples II: Recursive descent parsing:
- ML examples III: Exact real arithmetic:
- ML examples IV: Prolog and theorem proving:
This describes roughly how the course was taught over 12 lectures, each of
slightly less than an hour. Only what was actually taught will be examinable.
- Introduction and Overview Functional and imperative
programming: contrast, pros and cons. General structure of the course: how
lambda calculus turns out to be a general programming language. Lambda
notation: how it clarifies variable binding and provides a general analysis of
mathematical notation. Currying. Russell's paradox.
- Lambda calculus as a formal system Free and bound
variables. Substitution. Conversion rules. Lambda equality. Extensionality.
Reduction and reduction strategies. The Church-Rosser theorem: statement and
- Lambda calculus as a programming language Computability
background; Turing completeness (no proof). Representing data and basic
operations: truth values, pairs and tuples, natural numbers. The predecessor
operation. Writing recursive functions: fixed point combinators. Let
expressions. Lambda calculus as a declarative language.
- Types Why types? Answers from programming and logic.
Simply typed lambda calculus. Church and Curry typing. Let polymorphism.
Most general types and Milner's algorithm. Strong normalization (no proof), and
its negative consequences for Turing completeness. Adding a recursion operator.
- ML ML as typed lambda calculus with eager evaluation.
Details of evaluation strategy. The conditional. The ML family. Practicalities
of interacting with ML. Writing functions. Bindings and declarations. Recursive
and polymorphic functions. Comparison of functions.
- Details of ML More about interaction with ML. Loading
from files. Comments. Basic data types: unit, booleans, numbers and strings.
Built-in operations. Concrete syntax and infixes. More examples. Recursive
types and pattern matching. Examples: lists and recursive functions on lists.
- Proving programs correct The correctness problem. Testing
and verification. The limits of verification. Functional programs as
mathematical objects. Examples of program proofs: exponential, GCD, append and
- Effective ML Using standard combinators. List iteration
and other useful combinators; examples. Tail recursion and accumulators; why
tail recursion is more efficient. Forcing evaluation. Minimizing consing. More
efficient reversal. Use of `as'. Imperative features: exceptions, references,
arrays and sequencing. Imperative features and types; the value restriction.
- ML examples I: symbolic differentiation Symbolic
computation. Data representation. Operator precedence. Association lists.
Prettyprinting expressions. Installing the printer. Differentiation.
Simplification. The problem of the `right' simplification.
- ML examples II: recursive descent parsing Grammars and
the parsing problem. Fixing ambiguity. Recursive descent. Parsers in ML. Parser
combinators; examples. Lexical analysis using the same techniques. A parser for
terms. Automating precedence parsing. Avoiding backtracking. Comparison with
- ML examples III: exact real arithmetic Real numbers and
finite representations. Real numbers as programs or functions. Our
representation of reals. Arbitrary precision integers. Injecting integers into
the reals. Negation and absolute value. Addition; the importance of rounding
division. Multiplication and division by integers. General multiplication.
Inverse and division. Ordering and equality. Testing. Avoiding reevaluation
through memo functions.
- ML examples IV: Prolog and theorem proving Prolog terms.
Case-sensitive lexing. Parsing and printing, including list syntax.
Unification. Backtracking search. Prolog examples. Prolog-style theorem
proving. Manipulating formulas; negation normal form. Basic prover; the use of
continuations. Examples: Pelletier problems and whodunit.
Papers and documentation online
Here are some useful books, papers and tutorials online. They might save a trip
to the library.
Online ML resources
This is a collection of other Web links that are relevant to the material we
cover in the second part of the course.