CSE 230: Principles of Programming Languages
Homework Assignments

Binary for BinProlog 4.00 for Solaris machines (such as the CSE instructional machines beowulf, bintijua, kongo, or the machines in the APE lab) can be found at /net/cs/class/wi99/cse230/prolog/bp, and also as a backup, at /net/cat/disk1/prolog/bp; the latter directory also contains many other files, including some relevant to exercises, so that you don't have to do all the typing yourself. Some basic notes on using BinProlog 4.00 are at binpro.html.

(Standard ML of New Jersey, version 110.0.6) is available on all CSE unix machines at /net/cs/class/development/elkan/cse230/sml-110/bin/sml, which you can either define as an alias for sml, or else you can add the path for its directory to the PATH variable of your environment. You should actually run your ML code for all of the ML programming problems, and turn in your code along with its output.

The OBJ3 semantics of the small programming languages used in some exercises below is on the class website; there is also a version without the html wrapping. In addition, solutions to some OBJ3 problems are on the class website.

  1. Due 15 January:
    1. Say where Java would go in the Figure on p.23 of Stansifer; write a short paragraph of about 30 words justifying your choice. (You can just photocopy the figure and add a line and dot for Java in red ink.)
    2. Briefly compare Java with at least three other languages from among those described in Chapter 1 of Stansifer (FORTRAN, COBOL, BASIC, Algol, C, Lisp, ML, Ada, C++, etc.); the languages that you choose for comparison should be very different from each other; write one paragraph for each comparison; please try to hit the main points and avoid the trivial points.
    Note: If you are unfamiliar with Java, you should be able to learn enough to answer the above questions in about 30 minutes, by going to the campus bookstore (or nearly any other bookstore in the country) and skimming parts of one or more of the many Java books there.
  2. Due 22 January:
    1. Write a grep regular expression that will cause grep to search for, and print the instances of, all the Ada identifiers (as defined on p.45 of Stansifer) that occur as lines in an input file; test it on the file grep.data.html. (You can type "man grep" or "man egrep" etc. at any Sun workstation to learn what you need to know about grep.) Be sure to hand in your output file, plus of course your regular expression.
    2. Do Exercise 2.3 of Stansifer (p.69).
    3. Write the grammar for regular expressions on p.48 of Stansifer as an OBJ3 signature, and run at least 10 test cases, of diverse character, for it using the OBJ3 "parse" command (see p.19 of Algebraic Semantics); be sure to hand in your output, and of course the code. (Note: you will have to fudge the use of parentheses somehow, for example, by replacing them with [ and ].)
    4. Do Exercises 2.8 and 2.9 of Stansifer (p.70).

  3. Due 29 January:
    1. Do Exercise 2.11 of Stansifer (p.71).
    2. Do Exercise 2.20 of Stansifer (p.73).
    3. Let Sigma be the signature of the OBJ module NATEXP given on page 19 of Algebraic Semantics, with the following added:
             ops x y z : -> Exp .
      Let A be the Sigma algebra with carrier the set of natural numbers, with x,y,z interpreted as 1,2,3 (resp.), and with 0,s,+,* interpreted in the usual way. Then every Sigma term gets a unique interpretation in A, according to the map phi-bar defined on page 21. Calculate the value under phi-bar of the following terms:
      1. s(x + y) + z ;
      2. (x * y) + s s 0 ;
      3. (s s 0 * x) + s(y * z) .
      Now explain how to get OBJ3 to do these calculations, and then actually get it to do so; hand in your input and output.
  4. Due 5 February:
    1. Give an OBJ syntax for each of the assignment statements on page 78 of Stansifer, and for each of the "updating assignment statements" on page 80; give some OBJ3 input and output showing that your signatures work.
    2. Do Exercise 1, pp.43-46 of Algebraic Semantics; be sure hand in your input and output.
    3. Do Exercise 3.2 of Stansifer (p.100).
    4. Do Exercise 3.8 of Stansifer (p.102).
    5. If Sigma is the signature of the module NATEXPEQ on page 39 of Algebraic Semantics, give two Sigma-algebras where the first equation (0 + X = X) does not hold.
  5. Due 12 February:
    1. Do Exercise 4.8 of Stansifer (p.138).
    2. Do Exercise 4.11 of Stansifer (p.138).
    3. Do Exercise 4.19 of Stansifer (p.140).
    4. Do Exercise 4, p.64 of Algebraic Semantics.
    5. Do Exercise 6, p.64 of Algebraic Semantics.
    6. Do Exercise 8, pp.64-65 of Algebraic Semantics.
    7. Do Exercises 2.1.4, 2.3.2 and 2.4.3 of Ullman (pp. 20, 33, 43).

  6. Due 19 February (but you can hand it in on 21 Feb):
    1. Do Exercise 9, p.65 of Algebraic Semantics using OBJ.
    2. Do Exercise 12, pp.76-77 of Algebraic Semantics using OBJ.
    3. Do Exercise 15, p.78 of Algebraic Semantics using OBJ.
    4. Do Exercise 5.6 of Stansifer (p.179-180).
    5. Do Exercise 5.8 of Stansifer (p.180-181).
    6. Do Exercises 3.1.2, 3.2.4, 3.3.3, 3.3.10 of Ullman (pp. 53, 65, 75, 76).

  7. Due 26 February:
    1. Do Exercise 17, p.88 of Algebraic Semantics using OBJ.
    2. Do Exercise 20, p.89 of Algebraic Semantics using OBJ.
    3. Do Exercise 22, pp.105-106 of Algebraic Semantics using OBJ.
    4. Do Exercises 3.4.4, 3.4.7, 3.5.2 of Ullman (pp. 83, 83, 88).
    5. Do Exercises 3.6.1 and 3.6.3 of Ullman (p. 98).

  8. Due 5 March:
    1. Do Exercise 6.1 of Stansifer (p.208); use of Prolog is optional, but include your output if you do use it; in each case be sure to say how many answers there are.
    2. Do Exercise 6.4 of Stansifer (p.209) using Prolog.
    3. Do Exercise 6.5 of Stansifer (p.210) using Prolog.
    4. Do Exercise 6.21 of Stansifer (p.213) using Prolog.
    5. Do Exercise 6.17 of Stansifer (p.212), using the OBJ3 spec for unification; explain what this code does, roughly how it does it, and comment on the results of running the cases in Stansifer; use OBJ3 and include your output.
    6. Do Exercises 5.1.4, 5.2.1, 5.3.1b,c,e,g,h, 5.4.2, and 5.4.4 of Ullman (pp. 132, 141, 154, 166, 167).
    Note: If you prefer another Prolog system over BinProlog, you may use it instead.
  9. Due 12 March:
    1. Do Exercise 6.9 of Stansifer (p.211) using Prolog.
    2. Prove partial correctness of the little program on p.312 of Stansifer using OBJ3 and the approach of algebraic denotational semantics; in particular, be sure to treat the variables correctly (as opposed to the treatment in Stansifer).
    3. Do Exercises 7.2 and 7.3 of Stansifer (p.260).
    4. Do Exercise 7.20 of Stansifer (p.263) using OBJ (for some helpful hints see Section C.6, p.72 of Introducing OBJ), or alternatively, see Lambda calculus in OBJ; please have trace turned on for this problem. (You don't need to hand in all of the output, just the first and last few rewrites would be enough. Also there is an inconsistency in the definition of S, but you can check page 228 of Stansifer, or Lambda calculus in OBJ for the right definition.)
    5. Do Exercises 5.5.7b, 5.6.1d,f, 5.6.6 of Ullman (pp. 173, 181, 183).
    6. Do Exercises 6.2.3 and 6.3.1 of Ullman (pp. 206, 222).

To CSE 230 homepage
Maintained by Joseph Goguen
© 2000, 2001 Joseph Goguen
Last modified: Wed Jul 25 22:20:05 PDT 2001