• Keine Ergebnisse gefunden

Task1:Evaluation Homework3–WS18 ProgrammingLanguages2

N/A
N/A
Protected

Academic year: 2022

Aktie "Task1:Evaluation Homework3–WS18 ProgrammingLanguages2"

Copied!
2
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Fachbereich Informatik

Programmiersprachen und Softwaretechnik

Prof. Dr. Klaus Ostermann

Responsible for the lab Philipp Schuster

philipp.schuster@uni-tuebingen.de

Programming Languages 2

Homework 3 – WS 18

Tübingen, 8. November 2018

In order to be admitted to the exam, you have to successfully submit your homework every week, except for 2 weeks. A successful submission is one where you get at least 1 point.

Handin Please submit this homework until Thursday, November 15, either via email to Philipp Schuster (philipp.schuster@uni-tuebingen.de) before 12:00, or on paper at the beginning of the lab.

Groups You can work in groups of up to 2 people. Please include the names and Matrikelnummern of all group members in your submission.

Points For each of the Tasks you get between 0 and 2 points for a total of 6 points. You get:

1 point, if your submission shows that you tried to solve the task.

2 points, if your submission is mostly correct.

Task 1: Evaluation

Reduce the following terms until they reach a normal form. Use the reduction relation from the lecture.

1. (λa. λb. a) (λx. x)

2. (λa. λb. a b) (λx. λy. x y) (λz. z) 3. (λz. z z) (λf. f (λa. a))

You do not have to draw a derivation tree for the reduction relation, but you do have to write down all reduction steps. So for example for the term(λf. f (λx. x)) (λx. x) you would write down the following:

(λf. f (λx. x)) (λx. x)−→(λx. x) (λx. x)−→(λx. x)

(2)

Task 2: Church encoding

We are going to encode lists in lambda calculus as folds, similarly to how in the lecture we encoded natural numbers as folds. The basic list functions look like this:

nil =λf. λz. z

singleton =λx. λf. λz. f x z cons =λh. λt. λf. λz. f h (t f z) fold =λf. λz. λl. l f z

Using this encoding, the list with elementsc1,c2,c3would for example look like this:

onetwothree =λf. λz. f c1 (f c2 (f c3 z))

Write the following functions, operating on this encoding of lists:

1. sum 2. map 3. length

You can use the macros that were defined in the lecture, especially helpful areplus,c0,c1,c2, ...

Task 3: Monotonicity

Let the reduction relation−→and the functionsizefor terms in untyped lambda calculus be defined as in the lecture. Prove or disprove: ift−→t0, thensize(t)>size(t0).

Seite 2/2

Referenzen

ÄHNLICHE DOKUMENTE

(2) Falls in Folge einer Änderung oder Ergänzung der in der Bundesrepublik Deutschland geltenden Rechtsvorschriften oder auf der Grundlage einer zwischenstaatlichen

In this article we show how to apply the calculus of variations to find evolutionarily singular strategies of function-valued adaptive dynamics: such a strategy has to satisfy

Implement an algorithm that tests if two lambda terms are alpha equivalent in a language of your choice. This might turn out to be

Handin Please submit this homework until Thursday, January 10, either via email to Philipp Schus- ter (philipp.schuster@uni-tuebingen.de) before 12:00, or on paper at the beginning

Consider the type {∃S, {seed : S, step : S → {Nat, S}}} as the type of infinite streams of natural numbers. Define a term that given two streams of natural numbers returns a stream

It is shown that these results qualitatively follow the previously found ones for the inverse squared potential where explicit analytic solutions are known. Key words:

To the left the phonon dispersion relation by plotting the frequency as a function of the group velocity is shown, and to the right the soliton dis- persion relation by plotting

Size-mobility relation in the nanometer