MODULAR LOGIC GRAMMARS
Michael C. McCord
IBM Thomas J. Watson Research C e n t e r P. O. Box 218
Y o r k t o w n H e i g h t s , N Y 10598
A B S T R A C T
This report d e s c r i b e s a logic g r a m m a r formalism,
Modular Logic Grammars,
e x h i b i t i n g a high d e g r e e of m o d u l a r i t y b e t w e e n syntax and semantics. T h e r e is a s y n t a x rule c o m p i l e r ( c o m p i l i n g into Prolog) w h i c h takes care of the b u i l d i n g of analysis s t r u c t u r e s and the interface to a c l e a r l y s e p a r a t e d s e m a n t i c i n t e r p r e t a t i o n c o m p o n e n t d e a l i n g w i t h s c o p i n g and the c o n s t r u c t i o n of logical forms. The w h o l e system can w o r k in either a o n e - p a s s mode or a two-pass mode. [n the o n e - p a s s mode, logical forms are built d i r e c t l y d u r i n g p a r s i n g through i n t e r l e a v e d calls to semantics, added a u t o m a t i c a l l yby the rule compiler. [n the two-pass mode, syn-
tactic analysis trees are built a u t o m a t i c a l l y in
the first pass, and then given to the (one-pass)
semantic component. The grammar f o r m a l i s m includes two devices w h i c h cause the a u t o m a t i c a l l y built s y n t a c t i c s t r u c t u r e s to differ from d e r i v a t i o n trees in two ways: [I) T h e r e is a shift operator, for d e a l i n g w i t h l e f t - e m b e d d i n g c o n s t r u c t i o n s such as E n g l i s h p o s s e s s i v e noun phrases w h i l e u s i n g right- r e z u r s i v e rules (which are a p p r o p r i a t e for Prolog parsing). (2) T h e r e is a d i s t i n c t i o n in the syn- tactic f o r m a l i s m between s t r o n g n o n - t e r m i n a l s and w e a k n o n - t e r m i n a l s , w h i c h is important for distin- g u i s h i n g m a j o r levels of grammar.
I.
INTRODUCTION
l'he term
logic grammar
will be used here, inthe context of natural
language
processing, to m e a n a logic p r o g r a m m i n g system ( i m p l e m e n t e d n o r m a l l y in P£olog), w h i c h associates s e m a n t i c represent- ations Cnormally in some v e r s i o n of p r e a i c a t e logic)with natural language text. Logic grammars may have
v a r y i n g degrees on m o d u l a r i t y in their t r e a t m e n t s of syntax and semantics. Th, ere may or may not be an isolatable s y n t a c t i c component.
In w r i t i n g metamorpilosis g r a m m a r s (Colmerauer, 1978), or d e f i n i t e clause grammars, DCG's, (a spe- cial case of m e t a m o r p h o s i s g r a m m a r s , P e r e i r a and Warren. 1980), it is possible to build logical forms d i r e c t l y in the syntax rules by letting non- terminals have arguments that r e p r e s e n t partial
logical forms being manipulated. Some of the ear-
ties= logic grammars (e.g., Dahl, 1977) u s e d this approach. T h e r e is c e r t a i n l y an appeal in b e i n g dicect, but there are some d i s a d v a n t a g e s in this lack of modularity. One d i s a d v a n t a g e is that it seems d i f f i c u l Z to get an adequate t r e a t m e n t of the
s c o p i n g of q u a n t i f i e r s (and m o r e g e n e r a l l y
focalizers,
McCord, 1981) w h e n the b u i l d i n g of log- ical forms is too c l o s e l y b o n d e d to syntax. A n o t h e r d i s a d v a n t a g e is just a general result of lack of m o d u l a r i t y : it can be harder to d e v e l o p and un- d e r s t a n d s y n t a x rules w h e n too m u c h is g o i n g on in them.The logic g r a m m a r s d e s c r i b e d in M c C o r d (1982, 1981) w e r e t h r e e - p a s s systems, w h e r e one of the m a i n points of the m o d u l a r i t y was a good t r e a t m e n t of scoping. T h e first pass was the s y n t a c t i c compo- nent, w r i t t e n as a d e f i n i t e clause grammar, w h e r e s y n t a c t i c s t r u c t u r e s were e x p l i c i t l y built up in the a r g u m e n t s of the n o n - t e r m i n a l s . W o r d s e n s e s e l e c t i o n and s l o t - f i l l i n g were done in this first pass, so that the o u t p u t analysis trees w e r e actu- ally p a r t i a l l y semantic. The s e c o n d pass was a p r e l i m i n a r y stage of s e m a n t i c i n t e r p r e t a t i o n in w h i c h the s y n t a c t i c analysis tree was r e s h a p e d to reflect p r o p e r s c o p i n g of modifiers. The third pass took the r e s h a p e d tree and p r o d u c e d logical forms in a s t r a i g h t f o r w a r d w a y by c a r r y i n g out modification of nodes by their d a u g h t e r s u s i n g a m o d u l a r s y s t e m of rules that m a n i p u l a t e semantic items -- c o n s i s t - ing of logical forms together w i t h terms that de- termine how they can combine.
The C H A T - 8 0 system (Pereira and Warren, 1982,
Pereira, 1983) is a three-pass system. T h e first
pass is a p u r e l y s y n t a c t i c c o m p o n e n t u s i n g an extrapositJon g r a m m a r (Pereira, 1981) and p r o d u c i n g s y n t a c t i c analyses in r i g h ~ o s t n o r m a l form. The s e c o n d pass handles w o r d sense s e l e c t i o n and slot- filling, and =he third pass handles some s c o p i n g p h e n o m e n a and the final s e m a n t i c interpretation. One gets a great deal of m o d u l a r i t y b e t w e e n s y n t a x and s e m a n t i c s in that the first c o m p o n e n t has no elements of s e m a n t i c i n t e r p r e t a t i o n at all.
In DCG's and extraposition grammars, the
building of analysis structures .(either logical
forms or syntactic trees) must be specified ex-
plicitly in the syntax rules. A certain amoun~ of
modularity is then lost, because the grammar writer must be aware of manipulating these structures, and the possibility of using the grammar in different
ways is reduced. [n Dahl and McCord (1983), a logic
grammar formalism was described, modifier structure g r a m m a r s (HSG's), in which structure-building (of
annotated derivation trees) is implicit in the
formalism. MSG's look formally like extraposition
grammars, with the additional ingredient that se- mantic items (of the type used in McCord (1981)) can be indicated on the left-hand sides of rules, and contribute automatically to the construction
of a syntactico-semantic tree much like that in
HcCord (1981). These MSG's were used interpretively in parsing, and then (essentially) the two-pass
semantic interpretation system o f McCord (1981) was
used to get logical forms. So, totally there were
three passes in this system.
[n this report, [ wish t o describe a logic
grammar system, m o d u l a r logic g r a m m a r s (MLG's), with the following features:
There is a syntax rule compiler which takes care of the building of analysis structures and the interface to semantic interpretation.
There is a clearly separated semantic inter-
pretation component dealing with scoping and
the construction of logical forms.
The whole system (syntax and semantics) can work optionally in either a one-pass mode or a two- pass mode.
In the one-pass mode, no syntactic structures are built, but logical forms are built directly during parsing through interleaved calls to the semantic interpretation component, added auto- matically by the rule compiler.
in the two-pass mode, the calls to the semantic interpretation component are not interleaved, but are made in a second pass, operating on
syntactic analysis trees produced (automat-
ically) in the first pass.
The syntactic formalism includes a t device,
called the shift operator, for dealing with
left-embedding constructions such as English possessive noun phrases ("my wife's brother's friend's car") and Japanese relative clauses. ~ne shift operator instructs the rule compiler to build the structures appropriate for left-
embedding. These structures are n o t derivation
trees, because the syntax rules are right-re- cursive, because of the top-down parsing asso- ciated with Prolo E.
There is a distinction in the syntactic
formalism between strong non-terminals and w e a k non-terminals, which is important for distin- guishing major levels of grammar and which simplifies the. working of semantic interpreta-
tion. This distinction also makes the (auto-
matically produced) syntactic analysis trees much more readable and natural linguistically. In the absence of shift constructions, these trees are like derivation trees, but only with nodes corresponding to strong non-terminals.
[n an experimental MLG, the semantic component handles all the scoping phenomena handled by that in McCord (1981) and more than the semantic
component in McCord (1984). The logical form
language is improved over that in the previous systems.
The MLG formalism allows for a great deal of modu- larity in natural language grammars, because the
syntax rules can be written with very little
awareness of semantics or the building of analysis structures, and the very same syntactic component can be used in either the one-pass or the two-pass mode described above.
Three other logic grammar systems designed with modularity in mind are Hirschman and Puder (1982), Abramson (1984) and Porto and Filgueiras (198&). These will be compared with MLG's in Section 6.
2. THE MLG S Y N T A C T I C F O R M A L I S M
The syntactic component for an MLG consists of a declaration of the s t r o n g
non-terminals,
fol-lowed by a sequence of MLG syntax rules. The dec-
[aration of strong non-terminals is of the form
strongnonterminals(NTI.NT2 . . . NTn.nil).
where the NTi are the desired strong non-terminals
(only their principal functors are indicated).
Non-terminals that are not declared strong are
called w e a k . The significance of the strong/weak distinction will be explained below.
MLG s y n t a x rules are of the form
A ~---> B
where A is a n o n - t e r m i n a l and B i s a r u l e b o d y . A r u l e b o d y i s any c o m b i n a t i o n o f surlCace t e r m i n a l s ,
logical
terminals,
goals,
s h i f t e d n o n - t e r m i n a l s , non-tprminals, the symbol 'nil', and the cut symbol '/', using the sequencing operator ':' and the 'or'symbol 'l' (We represent left-to-right sequencing
with a colon instead of a comma, as is often done
in logic grammars.) These rule body elements are
Prolog terms (normally with arguments), and they are distinguished formally as follows.
A s u ~ e terminal is of the form +A, where A
is any Prolog term. Surface terminals corre-
spond to ordinary terminals in DCG's (they match elements of the surface word string), and the notation is often [A] in DCG's.
A l o g i c a l t e r m i n a l i s o f t h e form 0 p - L ~ ,
where
Op i s a m o d i f i c a t i o n o p e r a t o r and LF i s a l o g i c a lform. Logical terminals a r e special cases of
s e m a n t i c i t e m s , the significance of which will
r e c o g n i z e s them as b e i n g terms of the form A-B. T h e r e can be any n u m b e r of them in a rule body.
A
goal
is of the form $A, w h e r e A is a term re- p r e s e n t i n g a Prolog goal. (This is the usual p r o v i s i o n for Prolog p r o c e d u r e calls, w h i c h are often i n d i c a t e d by e n c l o s u r e in braces in DCG's.)A s h i f t e d n o n - t e r m i n a l is either of the f o r m % A , or of the form F%A, w h e r e A i s a w e a k non-
terminal and F is any ~erm. (In practice, F
will be a list of features.) As indicated in
the introduction, the shift o p e r a t o r '~' is used to handle l e f t - e m b e d d i n g c o n s t r u c t i o n s in a r i g h t - r e c u r s i v e ~ule system.
A n y rule body element not of the above four
forms and not 'nil' or the cut symbol is taken to be a non-terminal.
A terminal is either a surface terminal or a logical ~erminal. Surface ~erminals are b u i l d i n g blocks for the w o r d s t r i n g being analyzed, and logical terminals are b u i l d i n g blocks for the amalysis structures.
A syntax rule is c a l l e d s t r o n g or w e a k , .,u-
cording as the non-terminal on its left-hand side
is s t r o n g or weak.
It can be seen that on a purely formal level, the only d i f f e r e n c e s b e t w e e n HLG syntax rules and DCG's are (1) the a p p e a r a n c e of logical terminals
in rule bodies of MLG's, (2) the use of ~he shift operator, and (3) the d i s t i n c t i o n b e t w e e n s t r o n g and w e a k non-terminals. However, for a given lin- guistic coverage, the s y n t a c t i c c o m p o n e n t of an MLG will n o r m a l l y be more compact than the c o r r e s p o n d i n g DCG because s t r u c t u r e - b u i l d i n g must be ,~xplicit in DCG's. In this report, the arrow '-->' (as o p p o s e d to ' : > ' ) will be used for for DCG rules, and the same n o t a t i o n for sequencing, terminals, etc.. will be used for DCG's as for MLG's.
What is the s i g n i f i c a n c e of the s t r o n g / w e a k d i s t i n c t i o n for n o n - t e r m i n a l s and rules? Roughly, a strong rule should be thought of as i n t r o d u c i n g a new l®vel of grammar, w h e [ e a s a w e a k rule d e f i n e s analysis w i t h i n a level. M a j o r c a t e g o r i e s like s e n t e n c e and n o u n p h r a s e are e x p a n d e d by s t r o n g rules, but a u x i l i a r y rules like the reoursive rules that find the p o s t m o d i f i e r s of a verb are w e a k rules. An analogy w i t h ATN's (Woods, 1970) is t~at strong n o n - t e c m i n a l s are like the start c a t e g o r i e s of s u b n e t w o r k s (with s t r u c t u r e - b u i l d i n g POP arcs for termination), w h e r e a s w e a k n o n - t e r m i n a l s are llke internal nodes.
In the one-pass mode, the HLG rule c o m p i l e r makes the f o l l o w i n g d i s t i n c t i o n for s t r o n g and w e a k rules. In the Horn clause ~ r a n s l a t i D n of a s t r o n g ~11e, a call to the s e m a n t i c i n t e r p r e t a t i o n compo- nent is c o m p i l e d in at the end of the clause. The n o n - t e r m i n a l s a p p e a r i n g in rules (both s t r o n g and weak) are given extra a r g u m e n t s w h i c h m a n i p u ! a K e semantic s t r u c t u r e s used in the call to s e m a n t i c interpretation. No such call to s e m a n t i c s is com- p i l e d in for weak rules. W e a k rules o n l y g a t h e r
i n f o r m a t i o n to be used in the call to s e m a n t i c s m a d e by the next h i g h e r s t r o n g rule. (Also, a shift g e n e r a t e s a call to s e m a n t i c s . )
In the two-pass mode, w h e r e s y n t a c t i c a n a l y s i s trees are built d u r i n g the first pass, the rule c o m p i l e r builds in the c o n s t r u c t i o n of a tree node c o r r e s p o n d i n g t o e v e r y s t r o n g rule. T h e node is labeled e s s e n t i a l l y by the n o n - t e r m i n a l a p p e a r i n g on the left-hand side of the s t r o n g rule. (A shift also g e n e r a t e s the c o n s t r u c t i o n of a tree node.) Details of rule c o m p i l a t i o n will be g i v e n in the next section.
As indicated above, logical terminals, and m o r e g e n e r a l l y s e m a n t i c items, are of the form
O p e r a t o r - L o g i c a l F o r m .
The O p e r a t o r is a term w h i c h d e t e r m i n e s how the semantic item can combine with o t h e r s e m a n t i c items d u r i n g semantic interpretation. (In this c o m b i n a - tion, new s e m a n t i c items are formed w h i c h ;ire no
longer logical terminals.) Logical terminals are
most typically a s s o c i a t e d w i t h lexical items, al- though they ar~ also used to produc~, c e r t a i n non- l e x i c a l i n g r e d i e n t s in l o g i c a l form a n a l y s i s . An example for the lexical item "each" might be
Q/P - e a c h ( P , Q ) .
Here the o p e r a t o r Q/P is such that w h e n the "each" item modifies, say, an item h a v i n g logical form man(X), P gets u n i f i e d w i t h man(X), and the re- s u l t i n g semantic item is
@ Q - each(~.an(X),Q)
w h e r e @q is an o p e r a t o r w h i c h causes Q t o get uni- fied w i ~ h the logical form of a further m o d i f i c a n d . Details ,Jr the dse of s e m a n t i c items will be g i v e n in Section A.
Now let us look at the s y n t a c t i c c o m p o n e n t of a sample HLG w h i c h covers the same g r o u n d a s a w e l t - k n o w n DCG. The following DCG is taken essen- tially from Pereira and W a r r e n (1980). It is the sort of DCG that builds logical forms d i r e c t l y Dy m a n i p u l a t i n g partial logical forms in a r g u m e n t s of the grammar symbols.
s e n t f P ) --> np(X,PI,P): vp(X,Pl). np(X,P~,P) --~ d e t f P 2 , P I , P ) : noun(X,P3):
r e l c l a u s e ( X , P 3 , P 2 ) . n p ( X , P , P ) - - > n a m e ( X ) .
v p ( X , P ) - - > t r a n s v e r b f X , Y , P l ) : n p ( Y , P l , P ) . v p f X , P ~ - - > i n t r a n s v e r b ( X , P ) .
r e l c b t u s e ( X , P l , P l & P 2 ) - - > + t h a t : v p ( X , P 2 ) . r e l c ~ a u s e ( * , P , P ) - - > n i l .
d e t ( P I , P 2 , P ) - - > +D: $ d t ~ D , P I , P 2 , P ) . nounfX,P) --> +N: SnfN,X,P). name(X) - - > +X: $ n m ( X ) .
t r a n s v e r b ( X , Y , P ) - - > +V: $ t v ( V , X , Y , P ) . i n t r a n s v e r b ( X , P ) - - > +V: $ i v ( V , X , P ) .
/ ~ L e x i c o n * /
d t ( e v e r y , P 1 , P 2 , a l l ( P 1 , P 2 ) ) . d t ( a , P I , P 2 , e x ( P l , P 2 ) ) . t v ( l o v e s , X , Y , l o v e ( X , Y ) ) . i v ( l i v e s , X , l i v e ( X ) ) .
T h e s y n t a c t i c c o m p o n e n t of an analogous H L G is as follows. T h e lexicon is e x a c t l y the same as that of the p r e c e d i n g DCG. For reference below, this g r a m m a r will be c a l l e d MLGRAH.
s t r o n g n o n t e r m i n a l s ( s e n t . n p . r e l c l a u s e . d e t . n i l ) .
sent ~ > np(X): vp(X).
np(X) = > dec: noun(X): relclause(X). np(X) ~ > name(X).
vp(X) ~ > transverb(X,Y): np(Y). vp(X) ~ > intransverb(X).
relclause(X) ~ > +that: vp(X). relclause(*) ~ > nil.
d e t ~ > +O: S d t ( D , P 1 , P 2 , P ) : P Z / P I - P . n o u n ( X ) ----> +N: S n ( N , X , P ) : I - P . name(X) ~ > +X: Snm(X).
transverb(X,Y) : > +V: $tv(V,X,Y,P): I-P. i n t r a n s v e r b ( X ) = > +V: $iv(V,X,P): l-P
This small grammar illustrates all the ingredients
of HLG syntax rules except the shift operator. The
shift will be illustrated below. Note that 'sent'
and 'np' are s t r o n g c a t e g o r i e s but 'vp' is weak. A result is that there will be no call to s e m a n t i c s at the end of the 'vp' rule. Instead, the s e m a n t i c s t r u c t u r e s a s s o c i a t e d w i t h the verb and object are p a s s e d up to the 'sent' level, s o that the subject and object are "thrown into the same pot" for se- m a n t i c combination. (However, their surface o r d e r
is not forgotten.)
T h e r e are o n l y two types of m o d i f i c a t i o n op- erators a p p e a r i n g in the semantic items of this MLG: 'I' and P2/PI. The o p e r a t o r 'i' means 'left- c o n l o t n . Its effect is to left-conjoin its asso- c i a t e d logical form to the logical form of the m o d i f i c a n d (although its use in this small grammar is almost trivial). The o p e r a t o r P2/PI is associ-
ated with determiners, and its effect has been il-
lustrated above.
The semantic c o m p o n e n t will be given below in Section &. A sa~_ple s e m a n t i c analysis for the sentence "Every m a n that lives loves a w o m a n " is
a l l ( m a n ( X l ) & l i v e ( X l ) , e x ( w o m a n ( X 2 ) , l o v e ( X l , X 2 ) ) ) .
This is the same as for the above DCG. We will also show a sample parse in the next section.
A fragment of an M L G illustrating the use of the shift in the treatment of p o s s e s s i v e noun phrases is as follows:
np ~---> deC: n p l .
n p l = > p r e m o d s : n o u n : np2. vp2 ~ > p o s t m o d s .
np2
~ > p o s s : % n p l ._The idea of this fragment can be d e s c r i b e d in a
rough
p r o c e d u r a l way, as follows. In p a r s i n g an np, one reads an o r d i n a r y d e t e r m i n e r (deC), theng o e s t o n p l . I n n p l , one r e a d s s e v e r a l p r e m o d i f i e r s (premods), say adjectives, then a h e a d noun, then goes to np2. [n np2, one m a y e i t h e r finish by reading p o s t m o d i f i e r s (postmods), O R one m a y read an a p o s t r o p h e - s (poss) and then S H I F T back to npl. I l l u s t r a t i o n for the n o u n phrase, "the old man's d u s t y hat":
the old man
's
np det npl premods noun np2 poss %npl
d u s t y hat (nil)
premods noun np2 postmods
W h e n the shift is encountered, the s y n t a c t i c s t r u c t u r e s (in the two-pass mode) are m a n i p u l a t e d (in the c o m p i l e d rules) so that the initial np ("the old man") becomes a left-embedded s u b - s t r u c t u r e of the larger np (whose head is "hat"). But if no a p o s t r o p h e - s is encountered, then the s t r u c t u r e for "the old man" remains on the top level.
3 . C O M P I L A T I O N O F M L G S Y N T A X R U L E S
In d e s c r i b i n g rule compilation, we will first look at the two-pass mode, where s y n t a c t i c struc- tures are built in the first pass, because the re- lationship of the analysis s t r u c t u r e s to the syntax rules is more direct in this case.
The syntactic structures m a n i p u l a t e d by the c o m p i l e d rules are represented as s y n t a c t i c i t e m s , w h i c h a r e t e r m s o f t h e f o r m
syn(Features,Oaughters)
where Features is a feature list (to be defined), and D a u g h t e r s is a list c o n s i s t i n g of s y n t a c t i c items
and terminals. Both types of terminal (surface and
logical) are included in Daughters, but the dis-
p l a y i n g procedures for s y n t a c t i c structures can o p t i o n a l l y filter out one or the other of the two types. A f e a t u r e l i s t is of the form nt:Argl, w h e r e nt is the principal fun=tot of a s t r o n g n o n - t e r m i n a l and Argl is its first argument. (If nt has no ar-
guments, we take Argl=nil.) It is convenient, in
large grammars, to use this first argument Argl to hold a list (based on the o p e r a t o r ':') of gram- matical features of the phrase a n a l y z e d by the n o n - t e r m i n a l (like n u m b e r and p e r s o n for noun phrases).
[n c o m p i l i n g DCG rules into Prolog clauses, each non-terminal gets two extra arguments treated as a d i f f e r e n c e list r e p r e s e n t i n g the w o r d string a n a l y z e d by the non-terminal. In c o m p i l i n g MLG rules, exactly the same thing is done to handle w o r d strings. For h a n d l i n g s y n t a c t i c structures, the MLG rule compiler adds a d d i t i o n a l arguments w h i c h m a n i p u l a t e 'syn' structures. The number of addi- tional arguments and the w a y they are used d e p e n d on w h e t h e r :he non-terminal is s t r o n g or weak. If the original n o n - t e r m i n a l is s t r o n g and has the form
nt(Xl . . . . , Xn)
nt(Xl . . . Xn, Syn, Strl,Str2).
Here there is a single s y n t a c t i c s t r u c t u r e argument, Syn, r e p r e s e n t i n g the s y n t a c t i c s t r u c t u r e of the p h r a s e a s s o c i a t e d by nt w i t h the w o r d s t r i n g g i v e n by the d i f f e r e n c e list (Strl, Sir2).
On the o t h e r hand, w h e n the n o n - t e r m i n a l nt is weak, four s y n t a c t i c s t r u c t u r e a r g u m e n t s are added, p r o d u c i n g a c o m p i l e d p r e d i c a t i o n of the form
nt(Xl, .... Xn, SynO,Syn, H o d s l , H o d s 2 , Strl,Str2).
Here t h e pair (Hodsl, Hods2) holds a d i f f e r e n c e list for the sequence of s t r u c t u r e s a n a l y z e d by the w e a k n o n - t e r m i n a l nt. T h e s e s t r u c t u r e s could be 'syn' s t r u c t u r e s or terminals, and they will be d a u g h t e r s (modifiers) for a 'syn' s t r u c t u r e a s s o c i a t e d w i t h the closest higher call to a s t r o n g n o n - t e r m i n a l
-- l e t us call this h i g h e r 'syn s t r u c t u r e the ma-
t r i x ' s y n ' s t r u c t u r e . The o t h e r p a i r (SynO, Syn) r e p r e s e n t s the changing view o f what the m a t r i x ' s y n ' s t r u c t u r e a c t u a l l y should be, a view t h a t may change because a s h i f t is encountered w h i l e s a t i s - f y i n g n t . SynO r e p r e s e n t s the v e r s i o n b e f o r e s a t - i s f y i n g n t , and Syn r e p r e s e n t s the v e r s i o n a f t e r s a t i s f y i n g nt. If no shift is e n c o u n t e r e d w h i l e s a t i s f y i n g nt, then Syn w i l l just equal SynO. But if a shift is encountered, the old v e r s i o n SynO will become a d a u g h t e r node in the new v e r s i o n Syn.
In c o m p i l i n g a rule with several n o n - t e r m i n a l s in the rule body, linked by the s e q u e n c i n g o p e r a t o r
':', the argument pairs (SynO, Syn) and (Hodsl,
Hods2) for w e a k n o n - t e r m i n a l s are linked, respec- tively, across adjacent n o n - t e r m i n a l s in a m a n n e r similar to the linking of the d i f f e r e n c e lists for w o r d - s t r i n g arguments. Calls to s t r o n g non- terminals a s s o c i a t e 'syn' s t r u c t u r e elements w i t h the m o d i f i e r lists, just as surface terminals are a s s o c i a t e d w i t h elements of the w o r d - s t r i n g lists.
Let us look now at the c o m p i l a t i o n of a set
of rules. We will take the noun phrase grammar
fragment i l l u s t r a t i n g the shift and shown above in S e c t i o n 2, and repeated for c o n v e n i e n c e here, to- g e t h e r w i t h d e c l a r a t i o n s of s t r o n g non-terminals.
s t r o n g n o n ~ e r m i n a l s ( n p . d e t . n o u n . p o s s . n i l ) .
np = > det: npl.
npl = > premods: noun: np2. np2 ----~-> postmods.
rip2 = > poss: %npl.
The c o m p i l e d rules are as follows:
np[Syn, Strl,Str3) <- det(Hod, Strl,Str2) & n p l ( s y n ( n p : n i l , H o d : H o d s ) , S y n ,
Hods,nil, Str2,Str3).
npl(Synl,Syn3, H o d s l , H o d s 3 , Strl,Str4) <- p r e m o d s ( S y n l , S y n 2 , H o d s l , H o d : H o d s 2 ,
Strl,Str2) & noun(Hod, Str2,Str3) &
np2(Syn2,Syn3, H o d s 2 , H o d s 3 , Str3,Str4).
np2(Synl,Syn2, H o d s l , H o d s 2 , Strl,Str2) < -
p o s t m o d s ( S y n l , S y n 2 , H o d s l , H o d s 2 , Strl,Str2).
n p 2 ( s y n ( F e a s , H o d s O ) , S y n , H o d : H o d s l , H o d s l , Strl,Str3) <-
p o s s ( M o d , Strl,Str2) &
n p l ( s y n ( F e a s , s y n ( F e a s , H o d s O ) : H o d s 2 ) , S y n , Hods2,nil, Str2,Str3).
In the first c o m p i l e d rule, the s t r u c t u r e Syn to be a s s o c i a t e d w i t h the call to 'np' appears a g a i n in the s e c o n d m a t r i x s t r u c t u r e argument of 'npl' T h e first m a t r i x s t r u c t u r e a r g u m e n t of 'npl' is
s y n ( n p : n i l , M o d : H o d s ) .
and this will turn out to be the v a l u e of Syn if
no shifts are encountered. Here Hod is the 'syn'
s t r u c t u r e a s s o c i a t e d w i t h the d e t e r m i n e r 'det', and Hods is the list of m o d i f i e r s d e t e r m i n e d further by 'npi'. The feature list np:nil is c o n s t r u c t e d from the leading n o n - t e r m i n a l 'np' of this s t r o n g
rule. (It w o u l d have been np:Argl if np had a
(first) a r g u m e n t Argl.)
[n the second and third c o m p i l e d rules, the m a t r i x s t r u c t u r e pairs (first two arguments) and the m o d i f i e r d i f f e r e n c e list pairs are linked in a s t r a i g h t f o r w a r d w a y to reflect sequencing.
]'be fourth rule shows the effect of the shift. Here s y n ( F e a s , H o d s O ) , the previous " c o n j e c t u r e " for the m a t r i x structure, is now m a d e simply the first m o d i f i e r in the larger s t r u c t u r e
s y n ( F e a s , s y n ( F e a s , H o d s O ) : H o d s 2 )
w h i c h becomes the new " c o n j e c t u r e " by b e i n g p l a c e d in the first argument of the further call to 'npl'. If the shift o p e r a t o r had been used in its b i n a r y form FO%npl, then the new c o n j e c t u r e w o u l d be
syn(NT:F,syn(NT:FO,Mods0):Hods2)
w h e r e the o l d c o n j e c t u r e was s y n ( N T : F , H o d s O ) . [n
larger grammars, this allows one t o have a com-
p l e t e l y c o r r e c t feature list N T : F O for the left- e m b e d d e d modifier.
To illustrate the c o m p i l a t i o n of terminal symbols, let us look at the rule
det = > +O: Sdt(D,PI,P2,P): P2/Pt-P.
from the grammar H L G R A M in S e c t i o n 2. The c o m p i l e d rule is
d e t ( s y n ( d e t : n i l , + D : P 2 / P I - P : n i l ) , D.Str,Str) <- d t ( D , P I , P 2 , P ) .
Note that both the s u r f a c e terminal +D and the logical terminal P2/PI-P are e n t e r e d as m o d i f i e r s of the 'det' node. T h e s e m a n t i c i n t e r p r e t a t i o n c o m p o n e n t looks only at the logical terminals, but in c e r t a i n a p p l i c a t i o n s it is useful to be able to
s e e t h e s u r f a c e t e r m i n a l s in the s y n t a c t i c struc- tures. As m e n t i o n e d above, the d i s p l a y p r o c e d u r e s for s y n t a c = i ¢ s t r u c t u r e s can o p t i o n a l l y show o n l y
The d i s p l a y of the s y n t a c t i c s t r u c t u r e of the s e n t e n c e "Every m a n loves a w o m a n " p r o d u c e d by M L G R A M is as follows.
s e n t e n c e : n i l np:Xl
det:nil
X 2 / X 3 - a l I ( X 3 , X 2 ) l-man(Xl)
l-love(Xl,XA) n p : X A
det:nil
X S / X 6 - e x ( X 6 , X S )
l-woman(X&)
Note that no 'vp' node is shown in the parse tree;
'vp' is a w e a k non-terminal. The logical form
p r o d u c e d for this tree by the semantic c o m p o n e n t given in the next section is
all(man(Xl), e x ( w o m a n ( X 2 ) , l o v e ( X I , X 2 ) ) ) .
Now let us look at the c o m p i l a t i o n of syntax
rules for the one-pass mode. In this mode, syn-
tactic structures are not built, but semantic
structures are built up directly. The rule compiler
adds extra arguments to n o n - t e r m i n a l s for manipu-
lation of semantic structures, and adds calls to
the top-level semantic i n t e r p r e t a t i o n procedure, 'semant'.
The p r o c e d u r e 'semant' builds c o m p l e x semantic structures out of simpler ones, w h e r e the original b u i l d i n g blocks are the logical terminals a p p e a r i n g
in the MLG syntax rules. In this process of con-
struction, it w o u l d be p o s s i b l e to w o r k with se- m a n t i c items (and in fact a s u b s y s t e m of the rules do w o r k d i r e c t l y w i t h semantic items), but it ap- pears to be more e f f i c i e n t to w o r k with s l i g h t l y more elaborate s t r u c t u r e s w h i c h we call a u g m e n t e d semantic items. These' are terms of the form
sem(Feas,Op,LP),
w h e r e Op and [2 are such that O p - L F is an o r d i n a r y s e m a n t i c item, and Fees is either a feature list
or the list terminal:nil. The latter form is used
for the initial a u g m e n t e d s e m a n t i c items a s s o c i a t e d w i t h logical terminals.
As in the two-pass mode, the number of analysis s t r u c t u r e arguments added to a n o n - t e r m i n a l by the compiler depends on w h e t h e r the n o n - t e r m i n a l is strong or weak. If the original n o n - t e r m i n a l is s t r o n g and has the form
nt(Xl, . . . , Xn)
then in the compiled version w e will have
nt(Xl, ..., Xn, Semsl,Sems2, Strl,Str2).
Here (Semsl, Sems2) is a d i f f e r e n c e list of aug- m e n t e d semantic items r e p r e s e n t i n g the list of se- m a n t i c s~ruotures for the p h r a s e a s s o c i a t e d by n ~ w i t h the w o r d s~ring given by the d i f f e r e n c e list
(Strl, Sir2). In the s y n t a c t i c (two-pass) mode,
o n l y one argument (for a 'syn') is n e e d e d here, but
now w e n e e d a list of s t r u c t u r e s b e c a u s e of a r a i s i n g p h e n o m e n o n n e c e s s a r y for p r o p e r scoping, w h i c h w e w i l l discuss in S e c t i o n s A and 5.
W h e n the n o n - t e r m i n a l nt is weak, five e x t r a a r g u m e n t s are added, p r o d u c i n g a c o m p i l e d predi- c a t i o n of the form
nt(Xl, ..., Xn, Fees, SemsO,Sems, S e m s l , S e m s 2 , Strl,Str2).
Here Fees is the feature list for the m a t r i x s t r o n g n o n - t e r m i n a l . The pair (SemsO, Sems) r e p r e s e n t s the c h a n g i n g " c o n j e c t u r e " for the c o m p l e t e list of. d a u g h t e r (augmented) semantic items for the m a t r i x node, and is analogous to first extra argument pair in the two-pass mode. T h e pair (Semsl, Sems2) holds a d i f f e r e n c e list for the sequence of s e m a n t i c items a n a l y z e d by the weak n o n - t e r m i n a l nt. Semsl will
be a final sublist of SemsO, and Sems2 will of
course be a final sub|ist of Semsl.
For each s t r o n g rule, a cal-i to 'semant' is added at the end of the c o m p i l e d form of the rule. The form of the call is
semant(Feas, Sems, Semsl,Sems2).
Here teas is the feature list for the n o n - t e r m i n a l on the left-hand side of the rule. Sems is the final v e r s i o n of the list of d a u g h t e r s e m a n t i c items
(after all adjustments for shifts) and (SemsL,
Sems2) is the d i f f e r e n c e list of semantic items r e s u l t i n g from the s e m a n t i c i n t e r p r e t a t i o n for this
level. (Think of Fees and Sems as input to
'semant', and (Semsl, Sems2) as output.) CSemsl,
Sems2) will be the s t r u c t u r e arguments for the n o n - t e r m i n a l on the left-hand side of the s t r o n g rule. A call to 'semant' is also g e n e r a t e d w h e n a
shift is encountered, as we will see below. The
actual w o r k i n g of 'semant' is the topic of the next section.
For the shift grammar fragment shown above,
the c o m p i l e d rules are as follows.
np(Sems,Sems0, Strl,Str3) <- d e t ( S e m s l , S e m s 2 , Strl,Str2) &
npl(np:nil, Semsl,Sems3, Sems2,nil, Str2,Scr3) a s e m a n t ( n p : n i l , Sems3, Sems,SemsO).
npl(Feas, Semsl,Sems3, Semsa,Sems7, Strl,St[~) <- premods(Feas, Semsl,Sems2, SemsA,Sems5,
Strl,Str2) & n o u n ( S e m s 5 , S e m s 6 , Str2,Str3) &
np2(Feas, Sems2,Sems3, Sems6,SemsT, Str3,StrA).
np2(Feas, Semsl,Sems2, Sems3,Semsd, Strl,Str2) <- p o s t m o d s ( F e a s , Semsl,Sems2, Sems3,SemsA,
Strl,Str2).
npE(Feas, Semsl.SemsA, SemsS,Sems6, Strl,Str3) <- p o s s ( S e m s S , S e m s 6 , Strl,Str2) &
semant(Feas, Semsl, S e m s 2 , S e m s 3 ) &
npl(Feas, Sems2,Sems~, Sems3,nil, Str2,Str3).
will just be one element in this list, but there can be more w h e n m o d i f i e r s of the noun phrases c o n t a i n q u a n t i f i e r s that cause the m o d i f i e r s to get p r o m o t e d s e m a n t i c a l l y to be s i s t e r s of the n o u n p h r a s e . ) T h i s d i f f e r e n c e l i s t i s t h e o u t p u t o f t h e c a l l t o ' s e m a n t ' c o m p i l e d i n a t t h e e n d o f t h e f i r s t
rule. T h e input to this call is the list Sems3
(along w i t h the feature list np:nil). W e arrive at Sems3 as follows. The list Semsl is s t a r t e d by
, !
the call to det ; its first e l e m e n t is the
d e t e r m i n e r (if there is one), and the list is con- tinued in the list Sems2 of m o d i f i e r s d e t e r m i n e d further by the call to 'npl'. In this call to 'npl', the initial list Semsl is g i v e n in the s e c o n d ar- gument of 'npl' as the "initial v e r s l o n for the final list of m o d i f i e r s of the noun phrase. Sems3, being in the next argument of 'npl', is the "final version" of the np m o d i f i e r list, and this is the list given as input to 'semant'. [f the p r o c e s s i n g of 'npl' e n c o u n t e r s no shifts, then Sems3 will just equal 5ems I.
[n the second compiled rule (for 'npl'), the
" v e r s i o n s " of the total list of m o d i f i e r s are [inked in a chain
(Semsl, 5ems2, Sems3)
in the s e c o n d and third a r g u m e n t s of the w e a k non- terminals. The actual m o d i f i e r s p r o d u c e d by this rule are linked in a chain
(SemsA, Sems51 Sems6, SemsT)
in the fourth and fifth a r g u m e n t s of the w e a k non- terminals and the first and s e c o n d arguments of the s t r o n g non-terminals. A s i m i l a r s i t u a t i o n holds for the first of the 'np2' rules.
[n the second 'npZ' rule, a shift is encount-
ered, so a call to 'semant' is generated. This is
n e c e s s a r y b e c a u s e of the shift of levels; the mod- ifiers p r o d u c e d so far r e p r e s e n t all the m o d i f i e r s in an np, and these must be c o m b i n e d by 'semant'
to get the analysis of this np. As input to this
call to 'semant', we take the list Semsl, w h i c h is the current v e r s i o n of the m o d i f i e r s of the m a t r i x np. T h e output is the d i f f e r e n c e list .(Sems2, gems3). Sems2 is given to the s u c c e e d i n g call to
'npl' as the new current v e r s i o n of the m a t r i x m o d i f i e r list. The tail Sems3 of the d i f f e r e n c e list output by 'semant' is g i v e n to 'npl' in its
fourth argument to receive further modifiers. SemsA
is the f~.nal uersion of the m a t r i x m o d i f i e r list, d e t e r m i n e d by 'npi I , and this i n f o r m a t i o n is also put in the third a,'gument of 'np2'. The d i f f e r e n c e
list (Sems5, Semsb) contains the single element
p r o d u c e d by 'poss', and this list tails off the list Semsl.
W h e n a s e m a n t i c item O p - L F occurs in a rule body, the rule compiler inserts the a u g m e n t e d se- m a n t i c item s e m ( t e r m i n a l : n i l , O p , L F ) . As an example, the w e a k rule
t r a n s v e r b ( X , Y ) ~ > +V: $tv(V,X,Y,P): I-P.
compiles into the c l a u s e
t r a n s v e r b ( X , Y , Feas, S e m s l , S e m s l ,
s e m ( t e r m i n a l : n i l , l , P ) : S e m s 2 , S e m s 2 , V . S t r , S t r ) <-
tv(V,X,Y,P).
The s t r o n g rule
det ---> +D: Sdt(D,PI,P2,P): P2/PI-P.
compiles into the c l a u s e
d e t ( S e m s l , S e m s 2 , D . S e m s A , S e m s & ) < -
d t ( D , P 1 , P 2 , P ) & s e m a n t ( d e t : n i l ,
s e m ( t e r m i n a l : n i l , P 2 / P I , P ) : n i l , Semsl,Sems2).
4. S E M A N T I C I N T E R P R E T A T I O N FOR MLG'S
T h e s e m a n t i c i n t e r p r e t a t i o n schemes for both the o n e - p a s s mode and the two-pass mode share a large core of common procedures; they d i f f e r o n l y at the top level. In both schemes, a u g m e n t e d se- m a n t i c items are c o m b i n e d with one another, forming
more and more complex items, until a single item
is c o n s t r u c t e d w h i c h represents the s t r u c t u r e of the w h o l e sentence. In this final structure, o n l y the logical form component is of interest; the other two c o m p o n e n t s are discarded. We will d e s c r i b e the top levels for both modes, then d e s c r i b e the c o m m o n core.
T h e top level f o r the o n e - p a s s mode is simpler, because s e m a n t i c i n t e r p r e t a t i o n works in tandem w i t h the parser, and does not itself have to go t h r o u g h the parse tree. The p r o c e d u r e 'semant', w h i c h has i n t e r l e a v e d calls in the c o m p i l e d s y n t a x rules, e s s e n t i a l l y is the top-level procedure, but there is some m i n o r c l e a n i n g up that has to be done. If the top-level n o n - t e r m i n a l is 'sentence' (with no arguments), then the top-level analysis p r o c e d u r e
for the o n e - p a s s mode can be
a n a l y z e C S e n t ) <-
s e n t e n c e ( S e m s , n i l , S e n t , n i l ) &
semant(top:nil,Sems,sem(*,e,iF):nil,nil) & o u t l o g f o r m ( L F ) .
Normally, the first argument, Sems, of 'sentence' will be a list c o n t a i n i n g a s i n g l e a u g m e n t e d se- m a n t i c item, and its logical form c o m p o n e n t will
be the desired logical form. However, for some
grammars, the ~dditional call to 'semant' is n e e d e d to c o m p l e t e the m o d i f i c a t i o n process. The p r o c e d u r e 'outlogform' simplifies the logical form and o u t p u t s it.
~ne d e f i n i t i o n of 'semant' itself is g i v e n in a single clause:
s e m a n t ( F e a s , S e m s , S e m s 2 , S e m s 3 ) <- r e o r d e r ( S e m s , S e m s l ) &
m o d l i s t ( S e m s l , s e m ( F e a s , i d , t ) ,
Sem,Sems2,Sem:Sems3).
orders it (permutes it), to o b t a i n p r o p e r (or most likely) scoping. This p r o c e d u r e belongs to the c o m m o n core of the two m e t h o d s of s e m a n t i c inter- pretation, and w i l l be d i s c u s s e d further below.
The p r o c e d u r e 'modlist' does the following. A call
m o d l i s t ( S e m s , S e m O , S e m , S e m s l , S e m s 2 )
takes a list Sems of (augmented) s e m a n t i c items and combines them w i t h (lets them modify) the item SemO, p r o d u c i n g an item Sem (as the combination), along w i t h a d i f f e r e n c e list (Semsl, Sems2) of items w h i c h are p r o m o t e d to be sisters of gem. The leftmost m e m b e r of Sems acts as the o u t e r m o s t modifier. Thus, in the d e f i n i t i o n of 'semant', the result list Semsl of r e o r d e r i n g acts on the trivial item sem(Feas,id,t) to form a d i f f e r e n c e list (gems2, Sem:Sems3) where the result Sem is r i g h t - a p p e n d e d
to its sisters. 'modlist' also belongs to the
common core, and will be d e f i n e d below.
The top level for the two-pass system can be d e f i n e d as follows.
analyze2(Sent) <-
s e n t e n c e ( g y n , S e n t , n i l ) & s y n s e m ( S y n , S e m s , n i l ) &
s e m a n t ( t o p : n i l , g e m s , s e m ( * , e , L F ) : n i t , n i I ) & outlogform(LF).
The only d i f f e r e n c e b e t w e e n this and 'analyze' above
is that the call to ' s e n t e n c e ' produces a syntactic
item Syn, and this is given to the procedure
'synsem'. The latter is the m a i n recursive proce-
dure of the two-pass system. A call
s y n s e m ( S y n , S e m s I , S e m s 2 )
takes a syntactic item Syn and produces a d i f f e r e n c e list (Semsl, Sems2) of a u g m e n t e d semantic items representing the s e m a n t i c s t r u c t u r e o f Syn. (Typ-
i c a l l y , this list will just have one element, but
it can have more if m o d i f i e r s get promoted to sis- ters of the node.)
The d e f i n i t i o n of 'synsem' is as follows.
s y n s e m ( s y n ( F e a s , M o d s ) , S e m s 2 , S e m s 3 ) <- s y n s e m l i s t ( M o d s , S e m s ) &
reorder(Sems,Semsl) &
modlist(Semsl,sem(Feas,id,t),
Sem,Sems2,Sem:Sems3).
Note that this differs from the d e f i n i t i o n of
'semant' only in that 'synsem' must first
recursively process the d a u g h t e r s Mode of its input
syntactic item before c a l l i n g 'reorder' and
'modlist' The p r o c e d u r e 'synsemlist' that proc- esses the daughters is d e f i n e d as follows.
s y n s e m l i s t ( s y n ( F e a s , M o d s 0 ) : M o d s , S e m s l ) <- /& s y n s e m ( s y n ( F e a s , M o d s O ) , S e m s I , S e m s 2 ) & s y n s e m l i s t ( M o d s , S e m s 2 ) .
s y n s e m l i s t ( ( O p - L F ) : M o d s ,
s e m ( t e r m i n a l : n i l , O p , L F ) : S e m s ) <- /& synsemlist(Mods,Sems).
s y n s e m l i s t ( N o d : M o d s , S e m s ) <- synsemlist(Mods,Sems). synsemlist(nil,nil).
The first c l a u s e calls 'synsem' r e c u r s i v e l y w h e n the d a u g h t e r is a n o t h e r 'syn' structure. T h e s e c o n d c l a u s e replaces a logical terminal by an a u g m e n t e d s e m a n t i c item w h o s e feature list is terminal:nil. The next c l a u s e ignores any other type of d a u g h t e r
(this w o u l d n o r m a l l y be a s u r f a c e terminal).
Now we can p r o c e e d to the common core of the two s e m a n t i c i n t e r p r e t a t i o n systems. The p r o c e d u r e 'modlist' is d e f i n e d r e c u r s i v e l y in a s t r a i g h t f o r - w a r d way:
m o d l i s t ( S e m : S e m s , Sem0, Sem2, Semsl,Sems3) <- m o d l i s t ( S e m s , SemO, Seml, Sems2,Sems3) & modify(Sem, Seml, Sem2, Semsl,Sems2). m o d l i s t ( n i l , Sem, gem, Sems,Sems).
Here 'modify' takes a single item Sem and lets it operate on Seml, g i v i n g Sem2 and a d i f f e r e n c e list (Semsl, Sems2) of sister items. Its d e f i n l t i o n is
modify(Sem, Seml, Seml, Sem2:Sems,Sems~ <- r a i s e ( S e m , S e m l , S e m 2 ) &/.
m o d i f y ( s e m ( * , O p , L F ) , s e m ( F e a s , O p l , L F I ) ,
s e m ( F e a s , O p 2 , L F 2 ) , Sems,Sems) <- mod(Op-LF, OpI-LFI, Op2-LF2).
Here 'raise' is responsible for raising the
item Seml so that it becomes a sister of the item
Seml; gem2 is a new version of Seml after the
raising, although in most cases, gem2 equals geml. R a i s i n g occurs for a noun phrase like "a c h i c k e n in every pot", w h e r e the q u a n t i f i e r "every" has higher scope than the q u a n t i f i e r "a". The s e m a n t i c item for "every pot" gets promoted to a left s i s t e r of that for "a chicken". 'raise' is d e f i n e d bas- ically by a s y s t e m of unit clauses w h i c h look at specific types of phrases. For t h e small g r a m m a r M L G R A M of S e c t i o n 2, no raising is necessary, and the d e f i n i t i o n of 'raise' can just be omitted.
The p r o c e d u r e s 'raise' and 'reorder' are two key ingredients of r e s h a p i n g (the m o v e m e n t of se- m a n t i c items to handle scoping problems), w h i c h was d i s c u s s e d e x t e n s i v e l y in McCord (1982, 1981). [n
those two systems, reshaping was a separate pass
of s e m a n t i c interpretation, but },ere, as in M c C o r d (198&), r e s h a p i n g is interleaved with the rest o f
semantic interpretation. In spite of the new top-
level
organization
for semantic interpretation ofMLG's, the low-level procedures for raising and
reordering are b a s i c a l l y the same as in the previous
systems, and we refer to the previous reports for
further discussion.
T h e p r o c e d u r e 'mod', used in the s e c o n d c l a u s e for 'modify', is the heart of semantic interpreta- tion.
mod(Sem, Seml, Sem2)
In the e x p e r i m e n t a l MLG d e s c r i b e d in the next sec- tion, there are 22 such clauses. For the g r a m m a r M L G R A M of S e c t i o n 2, the f o l l o w i n g set of clauses suffices.
m o d ( i d -~, Sem, Sem) <- / . mod(Sem, id -~, Sem) <- /.
mod(l-P, Op-Q, Op-R) <- and(P,Q,R). m o d ( P / Q - R , Op-Q, @P-R).
mod(@P-Q, Op-P, Op-Q).
The first two clauses say that the o p e r a t o r 'id' acts like an identity. T h e s e c o n d clause defines 'i' as a l e f t - c o n j o i n i n g o p e r a t o r (its c o r r e s p o n d i n g logical form gets l e f t - c o n j o i n e d to that of the
modificand). The call and(P,Q,R) makes R=P&Q, ex-
cept that it treats 't' ('true') as an identity.
The next clause for 'mod' allows a q u a n t i f i e r se- m a n t i c item like P / Q - e a c h ( Q , P ) to o p e r a t e on an item
like I-man(X) to give the item
@P-each(man(X),P).
The final clause then allows this item to o p e r a t e on I-live(X) to give l - e a c h ( m a n ( X ) , l i v e ( X ) ) .
The low-level p r o c e d u r e 'mod' is the same (in purpose) as the p r o c e d u r e 'trans' in H c C o r d (1981), amd has close s i m i l a r i t i e s to 'trans' in McCord (1982) and 'mod' in M c C o r d (198&), so we refer to this previous w o r k for m o r e illustrations of this approach to m o d i f i c a t i o n .
For MLGRAH, the only ingredient of semantic
i n t e r p r e t a t i o n r e m a i n i n g to be d e f i n e d is 'reorder'. We can d e f i n e it in a way that is s o m e w h a t more general than is n e c e s s a r y for this small grammar, but w h i c h employs a t e c h n i q u e useful for larger grammars. Each a u g m e n t e d s e m a n t i c item is a s s i g n e d a p r e c e d e n c e number, and the r e o r d e r i n g (sorting) is d o n e so that w h @ n item B has higher p r e c e d e n c e number than item A, then B is o r d e r e d to the left of A; o t h e r w i s e items are kept in their original order. The following clauses then d e f i n e 'reorder'
in a way suitable for MLGRAM.
reorder(A:L,H) <-
reorder(L,Ll) & insert(A,Li,M). reordef(nit,n£1).
insert(A,B:L,S:Ll) <-
prec(A,PA) & p r e c ( B , P B ) & gt(PB,PA) & / & insert(A,L,Li).
insert(A,L,a:L~.
p r e c ( s e m ( t e r m ~ n a l : * , e , ~ ) , 2 ) <- /. p r u c ( s e m ( r e l c ! a u s e : e , e , e ) , l ) <- /. prec(e,3).
~nus terminals are o r d e r e d to the end, e x c e p t not
after relative clauses. In particular, the subject
and object of a s e n t e n c e are o r d e r e d b e f o r e the verb
(~ terminal in the sentence), and this allows the
s s r a i g h t f o r w a r d process of m o d i f i c a t i o n in :mod' to scope the q u a n t i f i e r s of the subject and o b j e c t over the m a t e r i a l of the verb. One can alter the d e f i n i t i o n of 'prec' to get finer d i s t i n c t i o n s in ~coping, and for this we refer to M c C o r d (1982, 1981).
For a grammar as small as MLGRAM, w h i c h has no t r e a t m e n t of s c o p i n g phenomena, the total tom-
p l e x i t y of the MLG, i n c l u d i n g the s e m a n t i c inter- p r e t a t i o n c o m p o n e n t w e have g i v e n in this Section,
is c e r t a i n l y g r e a t e r than that of the c o m p a r a b l e DCG in S e c t i o n 2. However, for larger grammars, the m o d u l a r i t y is d e f i n i t e l y w o r t h w h i l e -- concep- tually, and p r o b a b l y in the total size of the sys- tem.
5. AN E X P E R I M E N T A L MLG
This s e c t i o n d e s c r i b e s b r i e f l y an e x p e r i m e n t a l MLG, c a l l e d HODL, w h i c h covers the same linguistic g r o u n d as the g r a m m a r (called HOD) in H c C o r d (198l). The s y n t a c t i c c o m p o n e n t of HOD, a DCG, is essen- tially the same as that in H c C o r d (1982). One feature of these s y n t a c t i c c o m p o n e n t s is a system- atic use of s l o t - f i l l i n g to treat c o m p l e m e n t s of verbs and nouns. This m e t h o d increases m o d u l a r i t y b e t w e e n syntax and lexicon, and is d e s c r i b e d in detail in McCord (1982).
One purpose of HOD, w h i c h is c a r r i e d over to MODL, is a good treatment of s c o p i n g of m o d i f i e r s and a good s p e c i f i c a t i o n of logical form. The logical form language used by >IODL as the target of semantic i n t e r p r e t a t i o n has been improved some- what over that used for HOD. We d e s c r i b e here some of the c h a r a c t e r i s t i c s of the new logical form language, called LFL, and give sample LFL a n a l y s e s o b t a i n e d by MODL, but we defer a more d e t a i l e d de- s c r i p t i o n of LFL to a later report.
The main p r e d i c a t e s of LFL are w o r d - s e n s e s for w o r d s in the natural language being analyzed, for' example, b e l i e v e l ( X , Y ) in the sense "X believes that Y holds". Q u a n t i f i e r s , like 'each', are special cases of w o r d - s e n s e s . T h e r e are also a small number of non-lexJcal predicates in LFL, some of w h i c h are a s s o c i a t e d with inflections of words, like 'past' for past tense, or s y n t a c t i c c o n s t r u c t i o n s , like 'yesno' for yes-no questions, or have s i g n i f i c a n c e at d i s c o u r s e level, d e a l i n g for instance w i t h topic/comment. The a r g u m e n t s for p r e d i c a t e s of LFL can be constants, variables, or other logical forms (expressions of LFL).
E x p r e s s i o n s of LFL are either p r e d i c a t i o n s (in the sense just indicated) or c o m b i n a t i o n s of LFL e x p r e s s i o n s using the c o n j u n c t i o n '&' and the in- d e x i n g operator ':'. S p e c i f i c a l l y , if P is a log- ical form and E is a variable, then P:E (read "P indexed by E"~ is also a logical form. W h e n an indexed logical form P:E appears as part of a larger
logical form Q, and the index variable E is used
e l s e w h e r e in Q. then E can be thought of roughly as s t a n d i n g for P together w i t h its "context". Contexts include references to time and place w h i c h
are normally left implicit in natural language.
W h e n P specifies an event, as in s e e ( j o h n , m a r y ) , w r i t i n g P:E and s u b s e q u e n t l y u s i n g E will g u a r a n t e e
that E refers to the same event. In the logical
of P. In fact, for PROLOG execution of logical forms without contexts, ':' can be defined by the single clause: P:P <- F.
A specific purpose of the MOD system in McCord (1981) was to point out the importance of a class of predicates called f o c a i i z e r s , and to offer a method for dealing with them in semantic interpre-
tation. Focalizers include many determiners,
adverbs, and adjectives (or their word-senses), as well as certain non-lexical predicates like 'yesno'. Focalizers take two logical form arguments called the base and the fOCUS:
focalizer(Base,Focus).
The Focus is often associated with sentence stress,
hence the name. The pair (Base, Focus) is called
the SCOpe of the focalizer.
The adverbs 'only' and 'even' are focalizers which most clearly exhibit the connection with stress. The predication only(P,Q) reads "the only case where P holds is when Q also holds". We get different analyses depending on focus.
John only buys books at Smith's. only(at(smith,buy(john,X1)), book(X1)).
John only buys books at Smith's.
only(book(Xl)&at(X2,buy(john,Xl)), X2=smith).
quantificational adverbs like 'always' and
'seldom', studied by David Lewis (1975), are also
focalizers. Lewis made the point that these
quantifiers are properly considered unseJKtJve, in
the sense that they quantify over all the free
variables in (what we call) their bases. For ex-
ample, in
John always buys books at Smith's.
always(book(Xl)&at(X2,buy(john,Xl)), X2=smith) •
the quantification is over both X1 and X2. (A
paraphrase is "Always, if X1 is a book and John buys X1 at X2, then X2 is Smith's".)
Quantificational determiners are also
focalizers (and are unselective quantifiers); they
correspond closely in meaning t o the
quantificational adverbs ('all' - 'always', 'many'
'often', 'few' - 'seldom', etc.). We have the
paraphrases:
Leopards often attack monkeys in trees.
often(leopard(Xl)&tree(X2)&in(X2,attack(Xl,X3)),
monkey(X3)).Many leopard attacks in trees are (attacks) on monkeys.
many(leopard(Xl)&tree(X2)&in(X2,attack(Xi,X3)), monkey(X3)).
Adverbs and adjectives involving comparison or degree along some scale of evaluation (a wide
class) are also focalizers. The base specifies the
base of comparison, and the focus singles out what
is being compared to the base. This shows up most
clearly in the superlative forms. Consider the
adverb "fastest":
John ran fastest yesterday.
fastest(run(john):E, yesterday(E)).
John ran fastest yesterday.
fastest(yesterday(run(X)), X=john).
I n the first sentence, with focus on "yesterday", the meaning is that, among all the events of John's running (this is the base), John's running yesterday
was fastest. The logical form illustrates the in-
dexing operator. [n the second sentence, with focus
on "John", the meaning is that among all the events of running yesterday (there is an implicit location
for
these events), John's running was fastest.As an example of a non-lexical focalizer, we have yesno(P,q), which presupposes that a case of P holds, and asks whether P & Q holds. (The pair (P, Q) is like Topic/Comment for yes-no questions.) Example:
Did John see
M@ry
yesterday?yesno(yesterday(see(john,X)), X=mary).
It is possible to give Prolog definitions for most of the focalizers discussed above which are suitable for extensional evaluation and which amount
to model-theoretic definitions of them. This will
be discussed in a later report on LFL.
A point of the grammar HODL is to be able to produce LFL analyses of sentences using the modular
semantic interpretation system outlined in the
preceding section, and to arrive at the right (or most likely) scopes for focalizers and other modi-
fiers. The decision on scoping can depend on
heuristics involving precedences, on very reliable cues from the syntactic position, and even on the specification of loci by explicit underlining in
~he input string (which is most relevant for
adverbial focalizers). Although written text does
not often use such explici~ specification of
adverbial loci, it is important that the system can get the right logical form after having some spec-
ification of the adverbial focus, because this
specification might be obtained from prosody in spoken language, or might come from the use of
discourse information. [t also is an indication
of the modularity of the system that it can use the same syntactic rules and parse path no matter where the adverbial focus happens to lie.
Most of the specific linguistic information
for semantic interpretation is encoded in the
procedures 'mod', 'reorder', and 'raise', which
manipulate semantic items. In MODL there are 22
clauses for the procedure 'mod', most of which are
unit clauses. These involve ten different modifi-
e s p e c i a l l y t h e indexing operator. T h e d e f i n i t i o n s of 'reorder' and 'raise' are e s s e n t i a l l y the same as for p r o c e d u r e s in HOD.
An i l l u s t r a t i o n of analysis in the two-pass mode in H O D L is now given. For the s e n t e n c e "Leopards o n l y a t t a c k monkeys in trees", the syn- tactic analysis tree is as follows.
sent n o u n p h
l-leopard(X) avp
(P<Q)-only(P,Q) l-attack(X,Y) n o u n p h
l-monkey(Y)
prepph
@ @ R - i n ( Z , R ) n o u n p h
l-tree(Z)
Here we d i s p l a y complete logical terminals in the
leaf nodes of the tree. An indicat[on of the
m e a n i n g s of the o p e r a t o r s (P<Q) and @ @ R will be given below.
[n the s e m a n t i c interpretation of the prepo- sitional phrase, the 'tree' item gets p r o m o t e d (by 'raise') to be a left-sister of the the 'in' item, and the list of d a u g h t e r items (augmented s e m a n t i c items) of the 'sent' node is the following.
nounph i leopard(X) avp P<Q only(P,Q) terminal I attack(X,Y) nounph 1 monkey(Y) n o u n p h I tree(Z) prepph @ @ R in(Z,R).
Here we di~:play each a u g m e n t e d s e m a n t i c item s e m ( n t : F e a s , O p , L F ) simply in the form nt Op LF. The material in the first field of the 'monkey' item
actually shows that it is stressed. The reshaping
p ~ o c e d u r e 'reorder' rearran6es these items into the order:
n o u n p h I leopard(X) nounph 1 tree(Z) p r e p p h @ @ R in(Z,R) terminal I attack(X,Y) avp P<Q only(P,Q) nounph 1 monkey(Y)
Next, these items s u c c e s s i v e l y m o d i f y (according to the rules for 'mod') the m a t r i x item, sent id t, w i t h the rightmost d a u g h t e r a c t i n g as innermost oodifier. T h e rules for 'mod' involving the oper- ator (P<Q) a s s o c i a t e d w i t h only(P,Q) are d e s i g n e d so that the logical form material to the right of 'only' goes into the focus Q of 'only' and the ma- terial to the left goes into the base P. T h e ma-
terial to the right is just monkey(Y). The items
on the left ('leopard', 'tree', 'in', 'attack') are allowed to c o m b i n e (through 'mod') in an independent w a y before b e i n g put into the base of 'only'. The o p e r a t o r ~ @ R a s s o c i a t e d with in(Z,R) causes R to be b o t m d to the logical form of the m o d i f i c a n d --
attack(X,Y). T h e c o m b i n a t i o n of items on the left of 'only' is
l e o p a r d ( X ) & t r e e ( Z ) & i n ( Z , a t t a c k ( X , Y ) )
This goes into the base, so the w h o l e logical form is
o n l y ( l e o p a r d ( X ) & t r e e ( Z ) & i n ( Z , a t t a c k ( X , Y ) ) , monkey(Y)).
For d e t a i l e d traces of logical form c o n s t r u c t i o n by this method, see M c C o r d (1981).
An i l l u s t r a t i o n of the treatment of left- e m b e d d i n g in H O D L in a two-pass analysis of the s e n t e n c e "John sees each boy's b r o t h e r ' s t e a c h e r " is as follows.
sent n o u n p h
[-(X=john) l-see(X,W) n o u n p h
nounph n o u n p h
d e t e r m i n e r Q / P - e a c h ( P , Q ) l-boy(Y)
l-poss l-brother(Z,Y)
1-poss
1-teacher(W,Z)
Logical form...
e a c h ( b o y ( Y ) , t h e ( b r o t h e r ( Z , Y ) ,
t h e ( t e a c h e r ( W , Z ) , s e e ( j o h n , W ) ) ) ) .
The M O D L noun phrase rules include the shift (in a way that is an e l a b o r a t i o n of the shift g r a m m a r fragment in S e c t i o n 2), as well as rules for slot- filling for nouns like 'brother' and 'teacher' w h i c h have more than one a r g u m e n t in logical form. Ex- actly the same logical form is o b t a i n e d by M O D L for the s e n t e n c e "John sees the teacher of the b r o t h e r
of each boy". Both of these analyses involve
raising. [n =he first, the 'poss' node r e s u l t i n g from the a p o s t r o p h e - s is raised to b e c o m e a d e f i n i t e article. In the second, the p r e p o s i t i o n a l p h r a s e s (their s e m a n t i c s t r u c t u r e s ) are p r o m o t e d to be sisters of the "teacher" node, and the order of the quantlfiers ts (correctly) reversed.
The s y n t a c t i c c o m p o n e n t of M O D L was a d a p t e d as c l o s e l y as p o s s i b l e from that of HOD (a DCG) in order to get an idea of the e f f i c i e n c y of HLG's. The fact that the MLG rule c o m p i l e r produces m o r e s t r u c t u r e - b u i l d i n g a r g u m e n t s than are in the DCG w o u l d tend to |engthen a n a l y s i s times, but it is hard to predic~ the effect of the d i f f e r e n t o r g a n - ization of the s e m a n t i c i n t e r p r e t e r (from a three- pass s y s t e m to a o n e - p a s s and a two-pass v e r s i o n of MODL). 7 " n o followin E five s e n t e n c e s w e r e u s e d for timing tests.