1.1 To be a bit more precise, an OBJ3 signature can be considered a variant notation for a context free grammar, with some additions like precedence and subsort polymorphism, and more importantly, with an implementation, which is the very general parsing mechanism in OBJ3; this provides a general and powerful way to handle syntax (we will later see that OBJ also provides powerful ways to handle semantics). The sorts of a signature correspond to the non-terminals of a grammar. OBJ3's subsort polymorphism provides a highly consistent treatment of the most common kinds of coercion, in a way that also supports the common kind of overloaded operations. This is in contrast to the coercion mess found in many programming languages, and it is very convenient for defining denotations.
The prefix notation defined in
NAT is Peano notation, of which
Stansifer's "tally notation" is a postfix variant; some example terms appear
on pages 18 and 19 (though strictly speaking these use a larger signature).
There is a bug in Figure 1.2 on page 14: the sort should be
1.2 A semantics for a signature is given by an algebra A for that signature. Such an algebra gives a denotation for each sort s, which is the set As of elements of A of sort s, called the carrier of A, and similarly, the denotations of the operation symbols in the signature are functions among appropriate carriers of A.
1.3 The operations in the term algebra of a signature are exactly the constructors (in the sense of Stansifer in Section 2.5) for the abstract syntax of the context free language defined by that signature. Moreover, the carrier of sort s of the term algebra consists of exactly the abstract syntax trees (expressed as terms) for the grammar of that sort. Neat!
To be more precise, suppose that G = (N,T,P,S) is a context free grammar. Then the signature for G, denoted SigmaG, has as its sort set N, the non-terminals of G, with operations derived from the productions of G as follows: if
p: N -> w1 N1 w2 N2 ... wn Nn wn+1
is a production in P with each Ni a non-terminal, and each wi a string of terminals, then the corresponding operation is
p: N1 N2 ... Nn -> N
and the SigmaG-term algebra is exactly the algebra of abstract syntax terms (or trees) for G.
We can use the above construction plus the function phi-bar on page 21,
with SigmaG as its source and a suitable semantic algebra
A as its target to get a very nice explanation of synthesized
attribute semantics. For example, if
G is the simple grammar for
expressions discussed in the notes on chapter 2 of
Stansifer (with sort
E but without sort
A be the integers, and define the various operations to
be just the usual operations on integers (i.e., 0 is zero, 1 is one, + is
addition, * is times). Then the unique homomorphism phi-bar computes the
value of the expression. If a given non-terminal has more than one
attributes, then the carrier in
A will have to be a product of
the sets of values for each attributes, but otherwise things work just the
1.4 The notion of assignment in Definition 9 is essentially the same as in Stansifer on page 67, but much more general.
1.6 In Definition 14 on page 30, on the first line, (TSigmaU Xi)s should instead be (TSigma U Xi)s.
The rule [SM] on page 31 should be
(s X)* Y = (X * Y)+ Y .
1.6.1 There is a bug on page 35: in the equation
eq head(N L) = I .the variable
Ishould have been
N. (Thanks for Monica Marcus for noticing this.)
1.6.3 The last line of the definition of
page 39 should be
eq (s X)* Y = (X * Y)+ Y .(Thanks to Bob Boyer, CSE 230 W'01.) Moreover, the same typo occurs in the rule [SM] on page 31.
The "Theorem of Constants" is really a justification for the universal quantifier elimination rule:
There is, however, an important caveat regarding use of the disequality predicate (see Section 2.1.1). For example, suppose we are trying to prove a first order formula (forall X,Y) P(X,Y) over Sig, and use the Theorem of Constants to reduce it to proving P(x,y) over Sig(x,y). Because x=/=y (since they are distinct constants), what we have really proved is
But what should be done if the proof does use x=/=y? We can complete the proof by proving P(x,x), which then gives (forall X) P(X,X). This can be justified by considering the two proofs as parts of a case analysis, where the two cases are X=/=Y and X=Y.