cs252r : Advanced Functional Programming - Fall 2006
These pages are a record of the in-class discussions for the graduate class "Advanced Functional Programming" given at Harvard University in the Fall of 2006.December 6, 2006
- Why dependent types matter. James McKinna.
Warmup
Using the Curry-Howard isomorphism, provide Haskell terms that serve as proofs for the following propositions.
1. forall A B. A => (B => C) 2. A => (B => C) 3. forall A B C. (A => C) /\ (B => C) => ((A \/ B) => C)
1. const 2. const :: A -> B -> A 3. uncurry either
When you try to perform the same exercise on the following terms, what, if anything, goes wrong?
4. forall A. false => A 5. forall A. A 5. forall P. (P(0) /\ forall n. P(n) => P(n+1)) => forall n . P(n)
4. 5. 6.
In GHC with the Glasgow extensions, what representations of falsehood are available at the term level
data False
remark: This works great modulo bottom!
If you've studied logic, what, if anything, do you find suspicious about the proposition of question 4?
The technology
Consider the lists written on page 13.
Write a corresponding definition of Lifted in Haskell.
Lifted a = Lifted a | Infinity
State the invariant satisfied by a value of type CList Infinity.
All elements of the list are bounded below by infinity - empty list.
State the invariant satisfied by a value of type CList (lift b).
List elements are in sorted order, and the GLB is b.
State the invariant satisfied by a value of type OList b.
b is a lower bound on the elements of the list.
BibTeX
@Article{James-McKinna2006
, number = 1
, author = "James McKinna"
, journal = "SIGPLAN Not."
, issn = "0362-1340"
, publisher = "ACM Press"
, title = "Why dependent types matter"
, volume = 41
, address = "New York, NY, USA"
, url = "http://doi.acm.org/10.1145/1111320.1111038"
, pages = "1--1"
, year = 2006
}