Docsity

Assignment #1 in COP 5021: Recursive Programs and Denotational Semantics, Assignments of Computer Science

Toggle sidebar
bg1
Dr. Ferucio Laurent¸iu T¸ IPLEA
Visiting Professor
School of Computer Science
University of Central Florida
CSB #205
Orlando, FL 32816-2362
Tel: (407) 823-1593
COP 5021 (Program Analysis)
Spring 2006
Assignment #1 recursive programs/denotational semantics
Let B= (T0,V,F) be a basis satisfying:
• T0={nat, bool};
• V ={x, y, . . . , p, q , . . . , F, G, . . .}, where
–x, y, . . . are of type nat,
–p, q, . . . are of type bool,
–F, G, . . . are of type (nat, nat →nat);
• F ={0,1,2,...,+,∗,...,<,≤,...}, where
–0,1,... are of type nat,
–+,∗,... are of type (nat, nat →nat),
–<, ≤,... are of type (nat, nat →bool).
Let Ibe the interpretation given by:
•Dnat =N⊥,Dbool =Bool⊥;
• I0(n) is the natural number n,I0(+) is the usual addition operation on N⊥(naturally
extended) and so on.
1. Find I(t)(γ) for the following λ-terms t:
(a) t= 3 < x;
(b) t= [λx.3 + x];
(c) t= [λx.3 + x](5);
(d) t= [λF.F (3, x)];
(e) t= [λF.F (3, x)](∗);
(f) t= [λx, y .x +y];
pf2

Partial preview of the text

Download Assignment #1 in COP 5021: Recursive Programs and Denotational Semantics and more Assignments Computer Science in PDF only on Docsity!

Dr. Ferucio Laurent¸iu T¸ IPLEA Visiting Professor School of Computer Science University of Central Florida CSB # Orlando, FL 32816- Tel: (407) 823- E-mail: [email protected]

COP 5021 (Program Analysis) Spring 2006

Assignment #1 recursive programs/denotational semantics

Let B = (T 0 , V, F) be a basis satisfying:

  • T 0 = {nat, bool};
  • V = {x, y,... , p, q,... , F, G,.. .}, where
    • x, y,... are of type nat,
    • p, q,... are of type bool,
    • F, G,... are of type (nat, nat → nat);
  • F = { 0 , 1 , 2 ,... , +, ∗,... , <, ≤,.. .}, where
    • 0 , 1 ,... are of type nat,
    • +, ∗,... are of type (nat, nat → nat),
    • <, ≤,... are of type (nat, nat → bool).

Let I be the interpretation given by:

  • Dnat = N⊥, Dbool = Bool⊥;
  • I 0 (n) is the natural number n, I 0 (+) is the usual addition operation on N⊥ (naturally extended) and so on.
  1. Find I(t)(γ) for the following λ-terms t:

(a) t = 3 < x; (b) t = [λx.3 + x]; (c) t = λx.3 + x; (d) t = [λF.F (3, x)]; (e) t = λF.F (3, x); (f) t = [λx, y.x + y];

(g) t = [λx.[λy.x + y]]; (h) t = [λx.[λx.x + y]]; (i) t = λx.[λy.x + y]; (j) t = [λx.λy.x + y].

  1. Compute the denotational semantics of the following recursive programs (under the interpretation given above):

(a) (S, 1)

F 1 (x) ⇐ if x = 0 then 0 else F 2 (x − 1) F 2 (x) ⇐ if x = 0 then 1 else F 1 (x − 1)

(b) (S, 1)

F 1 (x) ⇐ if x = 0 then 1 else F 1 (x − 1) + F 2 (x − 1) F 2 (x) ⇐ if x = 0 then 0 else F 2 (x + 1)

(c) (S, 1)

F 1 (x) ⇐ if x > 100 then x − 10 else F 1 (F 2 (x + 11)) F 2 (x) ⇐ if x > 100 then x − 10 else F 2 (F 1 (x + 11))