This homework has two types of problems:
Self Check: You are strongly encouraged to think about and work through these questions, but you will not submit answers to them.
Problems: You will turn in answers to these questions.
(Required) Read Mitchell, Chapters 3, 4.1--4.2 (just skim the recursion and fixed point section)
(As Needed) "Uniprocessor garbage collection techniques", Paul Wilson.
A thorough overview of collection techniques. (You can most likely skip the details of 3.3--3.6.)
Mitchell, Problem 4.1
Mitchell, Problem 4.3
Mitchell, Problem 3.6
Mitchell, Problem 4.2
Lambda Calculus Checker
I just wrote Lambdasaurus, a Lambda Calculus Reduction Checker, to help you work through the reductions on your homework. You can find it on the CS334 website here.
The Lisp program fragment
(defun f (x) (+ x 4))
(defun g (y) (- 3 y))
(f (g 1))
can be written as the following lambda expression:
Reduce the expression to a normal form in two different ways, as described below.
Reduce the expression by choosing, at each step, the reduction that eliminates a \lambda as far to the left as possible.
Reduce the expression by choosing, at each step, the reduction that eliminates a \lambda as far to the right as possible.
In pure \lambda-calculus, the order of evaluation of subexpressions does not effect the value of an expression. The same is true for Pure Lisp: if a Pure Lisp expression has a value under the ordinary Lisp interpreter, then changing the order of evaluation of subterms cannot produce a different value. However, that is not the case for a language with side effects. To give a concrete example, consider the following "Java"-like code fragment:
int f(int a, int b) {
...
}
{
int x = 0;
System.out.println(f(e1,e2));
}
Write a function f and expressions e1 and e2 for which
evaluating arguments left-to-right and right-to-left produces a
different result. Your expressions may refer to x. Try it out
in your favorite imperative language --- C, C++, Java, etc.
Which evaluation order is used?
Here is a "sugared" lambda-expression using let declarations:
The "de-sugared" lambda-expression, obtained by replacing each {\tt let}\ z = U ~{\tt in}~ V by \\(\lambda z.\,V)\,U is
This is written using the same variable names as the
let-form in order to make it easier to read the expression.
Simplify the desugared lambda expression using reduction. Write one or two sentences explaining why the simplified expression is the answer you expected.
Read the Wilson Garbage Collection paper. This paper discusses many foundational ideas behind modern garbage collection. Please answer the following questions with one or two sentences each. The most credit will be given for clear, concise answers --- you should not need to write much.
a. What are the limitations of mark-and-sweep and reference-counting collectors?
b. What problem does copying-collection solve?
c. What is the main insight behind incremental collection?
d. What about generational collectors? When will they work well? When will they work poorly?
Most modern collectors use a combination of several techniques to best handle current systems with built-in concurrency and much larger heaps. If you're curious, have a look at the additional GC papers on the Readings web page, including papers on the HotSpot Java Virtual Machine implements garbarge collection, the Immix collector, and others.
Submit your answers to the GradeScope assignment named, for example, "HW 0". It should:
You will be asked to resubmit homework not satisfying these requirements. Please select the pages for each question when you submit.