CSE 230: Principles of Programming Languages
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
(Standard ML of New Jersey, version 110.0.6) is available on all CSE unix
/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.
- Please hand in homework in paper hardcopy form; do not email me or the
grader an attachment!
- Please give the assignment set number and problem number for each
question; also be sure to include your name, and the due date.
- For problems that require use of a computer, always hand in both your
input and your output as part of your solution.
- Assignments will normally be posted by Monday, due on Tuesday of the
- Be sure to reload this page frequently, because sometimes it may be
- Binary for OBJ3 is at /net/cs/class/wi99/cse230/obj on the CSE
network, and also at /net/cat/disk1/goguen/obj, but this is a slower,
older machine. To execute OBJ3, you need a Sun workstation running Solaris or
SunOS, such as the CSE instructional machines beowulf, bintijua, kongo, or the
machines in the APE lab. If you are not a CSE student, you may need to email
firstname.lastname@example.org to get a CSE student account. Personally, I like
to run OBJ3 in a shell inside of emacs; this allows easy editing and easy
capture of the output, for use inside of other documents. The OBJ3 Survival Guide may help you along. See also the
code that generates the OBJ3 builtin modules
(this is also in the OBJ3 Manual).
- Due 15 January:
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.
- 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.)
- 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.
- Due 22 January:
- 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.
- Do Exercise 2.3 of Stansifer (p.69).
- 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 ].)
- Do Exercises 2.8 and 2.9 of Stansifer (p.70).
- Due 29 January:
- Do Exercise 2.11 of Stansifer (p.71).
- Do Exercise 2.20 of Stansifer (p.73).
- 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
Now explain how to get OBJ3 to do these calculations, and then actually get
it to do so; hand in your input and output.
- s(x + y) + z ;
- (x * y) + s s 0 ;
- (s s 0 * x) + s(y * z) .
- Due 5 February:
- 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.
- Do Exercise 1, pp.43-46 of Algebraic Semantics; be sure hand in
your input and output.
- Do Exercise 3.2 of Stansifer (p.100).
- Do Exercise 3.8 of Stansifer (p.102).
- 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.
- Due 12 February:
- Do Exercise 4.8 of Stansifer (p.138).
- Do Exercise 4.11 of Stansifer (p.138).
- Do Exercise 4.19 of Stansifer (p.140).
- Do Exercise 4, p.64 of Algebraic Semantics.
- Do Exercise 6, p.64 of Algebraic Semantics.
- Do Exercise 8, pp.64-65 of Algebraic Semantics.
- Do Exercises 2.1.4, 2.3.2 and 2.4.3 of Ullman (pp. 20, 33, 43).
- Due 19 February (but you can hand it in on 21 Feb):
- Do Exercise 9, p.65 of Algebraic Semantics using OBJ.
- Do Exercise 12, pp.76-77 of Algebraic Semantics using OBJ.
- Do Exercise 15, p.78 of Algebraic Semantics using OBJ.
- Do Exercise 5.6 of Stansifer (p.179-180).
- Do Exercise 5.8 of Stansifer (p.180-181).
- Do Exercises 3.1.2, 3.2.4, 3.3.3, 3.3.10 of Ullman (pp. 53, 65, 75, 76).
- Due 26 February:
- Do Exercise 17, p.88 of Algebraic Semantics using OBJ.
- Do Exercise 20, p.89 of Algebraic Semantics using OBJ.
- Do Exercise 22, pp.105-106 of Algebraic Semantics using OBJ.
- Do Exercises 3.4.4, 3.4.7, 3.5.2 of Ullman (pp. 83, 83, 88).
- Do Exercises 3.6.1 and 3.6.3 of Ullman (p. 98).
- Due 5 March:
Note: If you prefer another Prolog system over BinProlog, you may
use it instead.
- 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.
- Do Exercise 6.4 of Stansifer (p.209) using Prolog.
- Do Exercise 6.5 of Stansifer (p.210) using Prolog.
- Do Exercise 6.21 of Stansifer (p.213) using Prolog.
- 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.
- 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).
- Due 12 March:
- Do Exercise 6.9 of Stansifer (p.211) using Prolog.
- 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).
- Do Exercises 7.2 and 7.3 of Stansifer (p.260).
- 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
S, but you can check page 228 of Stansifer, or Lambda calculus in OBJ for the right definition.)
- Do Exercises 5.5.7b, 5.6.1d,f, 5.6.6 of Ullman (pp. 173, 181, 183).
- 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