Computer Science 3675
Fall 2016
Practice Questions for Quiz 5

  1. What is one important motivation for including exception handling in a programming language?

    Answer

  2. How is exception handling implemented in a typical language, such as Java?

    Answer

  3. Are backtracking and exception handling the same thing? For example, can you use the exception handling mechanism of Java to do backtracking? If they are different, what is the difference in their mechanism?

    Answer

  4. What does unification do?

    Answer

  5. Give a collections of substitutions that unifies terms f(g(4,X),Y) and f(g(X,W),Z), where X, Y, Z and W are variables. Choose substitutions that do not many unnecessary restrictions.

    Answer

  6. In Cinnameg, each(ℓ) uses backtracking to create a branch for each member of list ℓ. For example, each([4,6,8]) creates three branches. In the first branch, it yields 4. In the second branch, it yields 6. And in the third branch, it yields 8.

    How many lines does the following Cinnameg program fragment write?

        Try
          !x = each [1, 2, 3].
          !y = each [10, 11, 12, 13].
          !z = each [100, 101].
          Displayln (x, y, z).
          Ensure false.
        %Try
    

    Answer

  7. A fixed point of function F is a value x so that F(x) = x. In mathematics, some functions have fixed points and some don't. For example, 1 is a fixed point of F(x) = x2. But F(x) = x + 1 has no fixed point.

    λ-calculus is different. Every function has a fixed point. In fact, you can write a function that takes F and yields a fixed-point of F.

    Suppose that

     fix = λf. (λx.f (xx)) (λx.f (xx)).

    Show that, for every F, fix FF(fix F). That is, fix F is a fixed-point of F.

    (Hint.

    1. What is fix F? Replace fix by its value and do a single β-reduction to eliminate λf.

    2. Do another β-reduction on the result from part (a).

    3. Replace the value of fix F, as found in step (a), by (literally) fix F, in the result that you got from step (b).

    Answer