
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

HW 4 Prof. Caldwell Due: 9 September 2008 COSC 3015
In class we discussed the following code.
plus (x,y) = x + y plusc x y = x + y curry f x y = f(x,y) uncurry f (x,y) = f x y (f. g) x = f (g x) id x = x
Recall the extensionality rule for proving functions f, g : A โ B are equal.
f = g def = โx : A. f x = gx
We gave a proof in class of the following identity.
Lemma 1.1. For every function f where f :: A โ B, the following equality holds
f. id = f
Proof: To show these functions are equal, by extensionality, we must show that
โx : A.(f. id)x = f x
Choose an arbitrary x โ A and show (f. id)x = f x. Starting on the left side:
(f. id) x ใใdef. of (.)ใใ = f (id x) ใใdef. of idใใ = f x
So the identity holds. Following the proofs given in class, prove the following equalities using extensionality.
Problem 1.1. i.) curry plus = plusc ii.) curry (uncurry plusc) = plusc iii.) uncurry (curry plus) = plus
Problem 1.2. Haskell has a built-in function called flip having the following type:
(a -> b -> c) -> b -> a -> c
Write a bit of Haskell code that has this type.