0% found this document useful (0 votes)
47 views2 pages

Exercise 1 (Composition) : (2 Points)

The document is an exercise sheet for a functional programming course that is due on June 6th, 2012. It contains 3 exercises. Exercise 1 asks students to show that the composition of continuous functions is continuous. Exercise 2 asks students to prove that a sum function is monotonic and continuous without using computability. Exercise 3 gives Haskell functions and asks students to define corresponding higher-order functions, give semantics for those functions, and identify least fixed points of the semantic functions.

Uploaded by

tanmaya1991
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views2 pages

Exercise 1 (Composition) : (2 Points)

The document is an exercise sheet for a functional programming course that is due on June 6th, 2012. It contains 3 exercises. Exercise 1 asks students to show that the composition of continuous functions is continuous. Exercise 2 asks students to prove that a sum function is monotonic and continuous without using computability. Exercise 3 gives Haskell functions and asks students to define corresponding higher-order functions, give semantics for those functions, and identify least fixed points of the semantic functions.

Uploaded by

tanmaya1991
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Exercise Sheet 6 (due 06.06.

2012)

Functional Programming SS12 M. Brockschmidt, F. Emmes

Prof.aa Dr. J. Giesl Notes:


Please solve these exercises in groups of two!

The solutions must be handed in directly before (very latest: at the beginning of ) the exercise

course on Wednesday, 06.06.2012, 11:45, in lecture hall AH 2. Alternatively you can drop your solutions into a box which is located right next to Prof. Giesl's oce (until the exercise course starts).

Please write the names and immatriculation numbers of all (two) students on your solution. Also

please staple the individual sheets!

Exercise 1 (Composition):

(2 points)

Let D1 , D2 , and D3 be domains with complete orders 1 , 2 , 3 , respectively. Let f : D1 D2 and g : D2 D3 be continuous functions. Show that the composition g f : D1 D3 is also continuous.

Exercise 2 (Sum semantics):

(2 + 4 = 6 points)

Consider the function sum : Z Z Z Z dened as follows:


(sum (g ))(x) = 1, g (x 1) + x, if x 0 otherwise

Here, we dene x y = and x + y = whenever x = or y = . Show that


a) sum

is monotonic. You should not make use of the fact that sum is computable and hence also monotonic. Instead you should prove monotonicity of sum directly.

b) sum

is continuous. You should not make use of the fact that sum is computable and hence also continous. Instead you should prove continuity of sum directly. Hints: It is probably a good idea to use Lemma 2.1.11 and Theorem 2.1.15 in your proof.

Exercise 3 (Higher Order Functions):

(1 + 1 + 2 + 3 = 7 points)

Consider the following Haskell functions:


fact fact three three inf inf :: Int -> Int = \x -> if x <= 0 then 1 else fact (x-1) * x :: Int -> Int = \x -> 3 :: Int -> Int = \x -> inf (x+3)

times :: (Int,Int) -> Int times = \(x,y) -> if x <= 0 then 0 else y + times (x-1,y)

Exercise Sheet 6 (due 06.06.2012)

Functional Programming SS12

The higher-order Haskell function f_fact corresponding to fact is:


f_fact = \g -> \x -> if x <= 0 then 1 else g (x-1) * x

The semantics f_fact of f_fact is:


(f_fact (g ))(x) = 1, g (x 1) x, if x 0 otherwise

The semantics fact of fact is the least xpoint of f_fact (where for all x 0 we dene x! = 1):
fact (x) = x!, if x Z , otherwise

(a) Give the Haskell denitions for the higher-order functions f_three, f_inf, and f_times corresponding to three, inf, and times. (b) Give the semantics f_three , f_inf , and f_times of the functions f_three, f_inf, and f_times.
n (c) What does the function n f () compute for n N, f {f_three, f_inf, f_times}? Here, f () denotes n applications of f to the undened function .

(d) Give all xpoints of the semantic functions f_three , f_inf , and f_times from (b). Which ones are the least xpoints?

You might also like