CSE 230: Principles of Programming Languages
- Assignments will normally be posted by Friday, due on Wednesday of the
following week. Homework due more than 5 days away is subject to change.
- Please hand in homework in paper hardcopy form; do not email me an
attachment! Computer printed paper is much preferred; if your handwriting is
too hard to read, you will lose credit. You may also lose points if your
solution is too difficult to understand, whether due to English or technical
- Please give the assignment set number and problem number for each
question; also be sure to include your name, and the due date. If there are
multiple pages, you should staple them; since loose pages can easily be lost,
and you will not get credit.
- For problems that require use of a computer, always hand in both your
input and your output as part of your solution.
- Due 13 January:
- Briefly compare Java with at least three other languages, such as
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.
- Say what is your own favorite programming language, and explain why you
like it, without falling into merely subjective considerations; i.e., you
should base your argument on real historical, cultural, and pragmatic
considerations, such as those described in the Essay on Comparative Programming
- Due 20 January:
- Give a BNF definition (do not use extended BNF) of a language of
balanced parentheses, in which the only two tokens are ( and
). For example, ()() and ((()))()((()())) are in
the language, but ((() is not.
- Write the grammar for regular expressions in section
2 of the notes on Sethi 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 ], or by making them optional).
- Write an expression that will cause grep to search for, and print the
instances of, all the Ada identifiers (as defined below), that occur as lines
in an input file; test it on the file grep.data.html. You may use any convenient variant of
grep, such as egrep; you can type "man grep" or "man egrep" etc. at any Sun
workstation to learn what you need to know. Be sure to hand in your output
file, plus of course your regular expression.
L(L + D)* (_(L + D)(L + D)*)*
where L indicates an upper or lower case letter, D indicates
a decimal digit, and _ is the underbar character.
- Due 27 January:
- Give a denotational semantics for the grammar for binary numbers at the
end of section 2 of the notes on Sethi.
- Exercise 2.15 of Sethi (p. 51).
- Exercise 3.3 of Sethi (p. 96).
- Due 3 February:
- Give an OBJ syntax for each of the assignment statements in the list in
the notes on chapter 3 of Sethi; give some OBJ3 input
and output showing that your signatures work.
- 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) .
- 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 10 February:
- Exercise 1, pp.43-46 of Algebraic Semantics; be sure hand in your
input and output.
- Exercise 4, p.64 of Algebraic Semantics.
- Exercise 6, p.64 of Algebraic Semantics.
- Exercises 5.2 and 5.3, pages 198-99 of Sethi.
- Due 17 February:
- Write the Black-Scholes
algorithm in OBJ; you should import the module
which includes the function
- Exercise 9, p.65 of Algebraic Semantics using OBJ.
- Exercise 12, pp.76-77 of Algebraic Semantics using OBJ.
- Exercise 6.5, p.248-9 of Sethi.
- Run two more proofs using Propositional
logic in OBJ.
- Please give me a tentative outline of your final paper (project).
- Due 26 February:
- Exercise 17, p.88 of Algebraic Semantics using OBJ.
- Exercise 18, p.88 of Algebraic Semantics using OBJ.
- Exercise 6.6, p.249 of Sethi.
- Code the following Post system in OBJ, and run some examples:
N x N x x . y = z x|| . y|| = z
--- ------ ----- ----------- -------------
N N x| x . = x . y| = xz z
What does this system do? Hint: It can be described in just three
words (or even one if you cheat a bit).
- Due 5 March:
Note: You may use a different Prolog than BinProlog if you prefer.
- Exercise 22, p.105 of Algebraic Semantics using OBJ.
- Exercise 23, p.106 of Algebraic Semantics using OBJ.
- Exercises 11.6 and 11.7, p.471 of Sethi.
- Find the most general unifier of each pair of terms below, using the
OBJ3 spec for unification; explain what
this code does, roughly how it does it, and comment on the results of
running these pairs of terms; use OBJ3 and include your output.
x, y, z are variables, and the rest are constants.
- Due 12 March:
- Use OBJ to prove the following identities in the combinatory calculus:
S K = K I
S (K I) = B I
S I (K K) = C I K
Kxy = x,
Sxyz = (xz)(yz),
Bxyz = x(yz),
Cxyz = xzy, and equality
means alpha,beta-equivalence (see Combinators
- Exercises 14.3 and 14.6, p.576 of Sethi.
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 email@example.com 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).
The OBJ3 semantics of the small programming
languages used in some exercises is on the class website; there is also
a version without the html wrapping.
Standard ML of New Jersey, version 110.0.6 is available on all CSE unix
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.
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
some 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
To CSE 230 homepage
Maintained by Joseph Goguen
© 2000, 2001, 2002, 2003 Joseph Goguen
Last modified: Thu Mar 6 15:30:01 PST 2003