Docsity

Extensions of Simple Types in CIS 500 — Software Foundations: Homework Assignment 7, Assignments of Computer Science

Toggle sidebar
bg1
CIS 500 — Software Foundations
Homework Assignment 7
Extensions of simple types
Due: Monday, October 30, 2006, by noon
Submit your solutions as hw7, for example using the command:
~cis500/bin/cis500submit hw7 hw7.pdf
1 Exercise For each new extension to the simply-typed lambda calculus (λ→) with error (see Figure
14-1), we must add new rules to propagate the error. For example, in the language λ→+ error +
booleans, we need the rule:
if error then t2else t3−→ error
What new rules do we need for λ→+ error + unit + references, i.e., the language of Figure 13-1
extended with error?
2 Exercise Suppose we extend the language λ→+ unit + references (Figure 13-1) with the following
new syntax, typing rules, and evaluation rules:
t::= . . . terms:
free t deallocation
Γ|Σ`t:Ref T T-Free
Γ|Σ`free t :Unit
l∈dom(µ)E-FreeRef
free l |µ−→ unit |(µ\ {l})
t|µ−→ t0|µ0
E-Free
free t |µ−→ free t0|µ0
where we use the notation µ\ {l}to indicate the store µwithout any binding for the location l.
Some questions about this language:
1. Does progress (Theorem 13.5.7) hold for this language? If so, give the new case(s) in the
proofs. If not, give a counterexample.
2. Does preservation (Theorem 13.5.3) hold for this language? If so, give the new case(s) in the
proofs. If not, give a counterexample.
3. Based on your answers to the previous two questions, can you give a program tin this
language with ∅ | ∅ ` t:Tand t| ∅ −→∗t0|µ06−→ such that t0is not a value? If not, why
not? If so, give such a program.
3 Exercise Exercise 13.3.1 from TAPL. (Again, this exercise has a solution in the back of the book.
To get full value out of the assignment, don’t peek until after you have written out a complete
solution of your own.)
pf2

Partial preview of the text

Download Extensions of Simple Types in CIS 500 — Software Foundations: Homework Assignment 7 and more Assignments Computer Science in PDF only on Docsity!

CIS 500 — Software Foundations

Homework Assignment 7

Extensions of simple types

Due: Monday, October 30, 2006, by noon

Submit your solutions as hw7, for example using the command:

~cis500/bin/cis500submit hw7 hw7.pdf

1 Exercise For each new extension to the simply-typed lambda calculus (λ→) with error (see Figure 14-1), we must add new rules to propagate the error. For example, in the language λ→ + error + booleans, we need the rule:

if error then t 2 else t 3 −→ error

What new rules do we need for λ→ + error + unit + references, i.e., the language of Figure 13- extended with error?

2 Exercise Suppose we extend the language λ→ + unit + references (Figure 13-1) with the following new syntax, typing rules, and evaluation rules: t ::=... terms: free t deallocation Γ | Σ t : Ref T T-Free Γ | Σ free t : Unit l ∈ dom(μ) E-FreeRef free l | μ −→ unit | (μ \ {l})

t | μ −→ t′^ | μ′ E-Free free t | μ −→ free t′^ | μ′ where we use the notation μ \ {l} to indicate the store μ without any binding for the location l. Some questions about this language:

  1. Does progress (Theorem 13.5.7) hold for this language? If so, give the new case(s) in the proofs. If not, give a counterexample.
  2. Does preservation (Theorem 13.5.3) hold for this language? If so, give the new case(s) in the proofs. If not, give a counterexample.
  3. Based on your answers to the previous two questions, can you give a program t in this language with ∅ | ∅ ` t : T and t | ∅ −→∗^ t′^ | μ′^6 −→ such that t′^ is not a value? If not, why not? If so, give such a program.

3 Exercise Exercise 13.3.1 from TAPL. (Again, this exercise has a solution in the back of the book. To get full value out of the assignment, don’t peek until after you have written out a complete solution of your own.)

4 Debriefing

  1. Approximately how many hours (per person, on average) did you spend on this assignment?
  2. Would you rate it as easy, moderate, or difficult?
  3. How deeply do you feel you understand the material it covers (0%–100%)?
  4. Any other comments?