HOW TO INVERT A NATURAL LANGUAGE PARSER INTO AN EFFICIENT GENERATOR: 
AN ALGORITHM FOR LOGIC GRAMMARS 
Tomek Strzalkowski 
Courant Institute of Mathematical Sciences 
New York University 
251 Mercer Sueet 
New York, NY 10012 
ABSTRACT 
The use of a single grammar in natural language pars- 
ing and generation is most desirable for variety of rea- 
sons including efficiency, perspicuity, integrity, robust- 
hess, and a certain ,amount of elegance. In this paper 
we present an algorithm for automated inversion of a 
PROLOG-coded unification parser into an efficient 
unification generator, using the collections of minimal 
sets of essential arguments (MSEA) for predicates. 
The algorithm is also applicable to more abstract sys- 
tems for writing logic grammars, such as DCG. 
INTRODUCTION 
In this paper we describe the results obtained 
from the experiment with reversing a PROLOG parser 
for a substantial subset of English into an efficient gen- 
erator. The starting point of the experiment was a 
string parser for English (Grishman, 1986), which is 
used in an English-Japanese MT project. The PROLOG 
version of this parser was inverted, using the method 
described here, into an efficient PROLOG generator 
working from regularized parse forms to English sen- 
tences. To obtain a PROLOG parser (or any PROLOG 
program) working in the reverse, requires ~ some mani- 
pulation of the clauses, especially the ordering of the 
literals on their right-hand side, as noted by Dymetman 
and Isabelle (1988). We do not discuss here certain 
other translbrmations used to "normalize" the parser 
code in order to attain maximum efficiency of the 
derived generator progrmn (Strzalkowski, 1989). 
1N AND OUT ARGUMENTS 
Arguments in a PROLOG literal can be marked as 
either "in" or "out" depending on whether they are 
bound at the time the literal is submitted for execulion 
or after the computation is completed. For exmnple, in 
tovo ( \[to, eat, fish\], T4, 
\[np, \[n, john\] \] , P3) 
the first and the third arguments are "in", while the 
Barring the presence of non-reversible operators. 
remaining two are "out". When tovo is used for genu 
eration, i.e., 
tOvo (TI, T4, Pl, 
\[eat, \[np, \[n, john\] \] , 
\[np, \[n, fish\] \] \] ) 
then the last argument is "in", while the first and the 
third are "out"; T4 is neither "in" nor "out". The 
infixmation about "in" and "out" status of arguments is 
important in determining the "direx'tion" in which 
predicates containing them ca~ be run 2. As a further 
example consider the literal 
stibject (AI, A2, WHQ, h~JM, P) 
where A1 and A2 arc input and output strings of 
words, WttQ indicates whether the subject phrase is a 
part of a clause within a wh-question, ~ is the 
number of the subject phrase, and P is the final trans- 
lation. During parsing, the "in" arguments are: A1 
and WgQ, the "out" arguments are A2, ~ and P; 
during generation, the "in" arguments are p and WrlQ, 
the "out" arguments are A1 a~d NUN. In generating, 
A2 is neither "in" nor "out". 'lqms, upon reversing the 
diroction of computation, ar~ "out" argument does not 
automatically become an '%" argument, nor does an 
"in" argument automatically become an "out" argu- 
ment. Below is a method for computing "in" and "out" 
status of arguments in any given literal in a PROLOG 
program, as required by the inversion procedure. This 
algorithm is already general enough to handle any PRO- 
LO(~ program. 
An argument X of literal pred( • •. X • •. ) on the rhs of 
a clause is "in" if 
(A) it is a constant; or 
(B) it is a function and all its arguments are "in"; or 
(C) it is "in" or immediately "out" in some previous 
literal predo on the rhs of the same clause, i.e., 
l (Y) :-- pred o (X, Y),pred (X); or 
(D) it is "out" in an rhs literal predo delayed until after 
some predicate pred~ such that predo precedes 
2 For more discussion on directed predicates in PROLOO see 
Shoham and McDermott (1984), and Debray (1989). 
1 347 
predl, and predt precedes pred on the rhs; 3 or 
(E) it is "in" in the head literal L on lhs of the same 
clause. 
An argument X is "in" in the head literal 
L = pred (" • X... ) of a clause if (A), or (B), or 
(F) L is the top-level literal and X is "in" in it (known 
a priori); or 
(G) X occurs more than once in L and at least one of 
these occurrences is "in"; or 
(H) for every literal L 1 : pred (. • • Y. •. ) unifiable 
with L on the rhs of any clause with the head 
predicate predl different than pred, and such that 
Y unifies with X, Y is "in" in L 1. 
We distinguish two categories of "out" arguments in 
literals appearing on the right-hand side of a clause: 
immediate and delayed. An argument X occurring in 
literal pred(... X... ) is immediately "out" if it is 
fully bound 4 immediately after pred(...X...) is 
executed. An argument X in pred ( • • • X • • • ) is "out" 
delayed until after predo, if it is fully bound only after 
predo, following pred on rhs, is executed. For exam- 
ple, consider the following fragment: 
vp(SN) :- agree(SN, VN),v(VN) . 
agree (N, N) . 
If VN is immediately "out" in v, then SN in agree 
is "out" delayed until after v. For arguments with 
their "out" status delayed until after predo, the "out" 
status is assigned only after predo is executed. 
An argument X of literal pred (.. • X • • • ) on the rhs of 
a clause is immediately "out" if 
(A) it is "in" inpred(...X ... ); or 
(B) it is a functional expression and all its arguments 
are either "in" or immediately "out"; or 
(C) tbr every clause with the head literal 
pred( . . . Y ...) unifiable with pred( . . . X • ..) 
and such that Y unifies with X, Y is either "in", 
"out" or "unknwn", and Y is marked "in" or "out" 
in at least one case. 
An argument X of literal pred( • • • X • •. ) on the rhs of 
a clause is "out" delayed until after predo(" • • Y" "" ) 
following pred if 
(D) Y is immediately "out" in predo and X=f (Y); or 
(E) X is a functional expression and all of its argu- 
ments are either "in" or immediately "out" or "out" 
delayed until after predo; or 
3 The precedence is with respect to the order of evaluation, 
which in PROLO6 is left-to-right. 
" An argument is considered fully bound if it is a constant or it 
is bound by a constant; an argument is partially bound if it is, or is 
bound by, a te.n in which at least one variable is unbound. 
(F) there is a predicate predl('"X"'Z''") 
preceding predo on the rhs, where Z* is a subset 
of arguments ofpredl such that every argument in 
Z* is "out" delayed until after predo and whenever 
Z* is "in" then X is immediately "out" in pred,. 
An argument X of literal pred (. • • X • • • ) on the lhs of 
a clause is "out" if 
(G) it is "in" inpred(... X. • • ); or 
(H) it is "out" (immediately or delayed) in literal 
pred i ( " "" X • • • ) on the rhs of this clause, provid- 
ing that predl ~pred (again, we must take provi- 
sions to avoid infinite descend, cf. (H) in "in" 
algorithm); if predl =pred then X is marked 
"unknwn". 
ESSENTIAL ARGUMENTS 
Some arguments of every literal are essential in 
the sense that the literal cannot be executed success- 
fully unless all of them are bound, at least partially, at 
the time of execution. A literal may have several alter- 
native, possibly overlapping, sets of essential argu- 
ments. If all arguments in any one of such sets of 
essential arguments are bound, then the literal can be 
executed. Any set of essential arguments which have 
tile above property is called essential. We shall call 
the set MSEA of essential arguments a minimal set of 
essential arguments if it is essential, and no proper 
subset of MSEA is essential. If we alter the ordering of 
the rhs literals in the definition of a predicate, we may 
also change its set of MSEA's. We call the set of 
MSEA's existing for a current definition of a predicate 
the set of active MSEA's for this predicate. To run a 
predicate in a certain direction requires that a specific 
MSEA is among the currently active MSEA's for this 
predicate, and if this is not already the case, then we 
have to alter the definition of this predicate so as to 
make this MSEA become active. As an example con- 
sider the following clause from our PROLOG parser: 
objectbe (01,02, PI, P2, PSA, P) -- 
venpass (01,02, P1, P3) , 
concat(\[P2,P3\],PSA, P) . 
Assuming that {O1} and {P3} are MSEA's of ven- 
pass and that P3 is "out" in venpass whenever 
el is "in", we obtain that {O1} is the only candidate 
for an active MSEA in objectbe. This is because 
P3 is not present on the argument list of objectbe, 
and thus cannot receive a binding before the execution 
of venpass commences. Moving to the coneat 
literal, we note that its first argument is partially bound 
since P3 is "out" in venpass. This is enough for 
eoneat to execute, and we conclude that O1 is in 
fact the only essential argument in objeetbe. If we 
reverse the order of venpass and concat, then 
{p} becomes the new active MSEA for objectbe, 
while {O1} is no longer active. Given the binding to 
its third argument, eoneat returns bindings to the 
348 2 
first two, and thus it also binds P3, which is an essen- 
tial argument in venpaas. 5 Below is the general pro- 
cedure MSEAS for computing the active sets of essen- 
tial arguments in the head literal of a clause as pro- 
posed in (Strzalkowski and Peng, 1990). 
Let's consider the following abstract clause 
defining a predicate R~: 
R i(X 1,"" ,Xk) :- (R) 
Q1('" "), 
02('' "), 
• , , 
Q.(...). 
Suppose that, as defined by (R), R i has the set MSi = 
{m 1, " " ' ,mj} of active MSEA's, and let MRI ~_ MSI be 
the set of all MSEA for R~ that can be obtained by per- 
muting the order of literals on the right-hand side of 
(R). Let us assume further that R i occurs on rhs of 
some other clause, as shown below: 
P (X~,... ,X,) :- (P) 
Rl(Xl,1, " " " ,X1,,1), 
R2(X2,1, ''' ,X2,k2), 
• . ° 
R,.(x~, ~,-.. ,x~,k~). 
We want to compute MS, the set of active MSEA's for 
P, as defined by (P), where s >_ 1, assuming that we 
know the sets of active MSEA for each R~ on the rhs. 6 
In the following procedure, the expression VAR (T), 
where 7" is a set of terms, denotes the the set of all vari- 
ables occurring in the terms in T. 
MSEAS (MS,MSEA, VP,i, OUT) 
(1) Start with VP = VAR ({X1, " " ,X.}), MSEA = f~, 
i=1, and OUT = O. When the computation is 
completed, MS is bound to the set of active 
MSEA's for P. 
(2) Let MR 1 be the set of active MSEA's of R 1, and 
let MRU1 be obtained from MR ~ by replacing all 
variables in each member of MR1 by their 
corresponding actual arguments of R~ on the rhs 
of (C1). 
(3) IfR I = P then for every rnl,k e MRU1 if every 
argument Yt e m 1,k is always unifiable 7 with its 
s We note that since concat could also be executed with 
P2 bound, the set {O1, P2} constitutes another active MSEA for in- 
verted objeetbe. Ilowever, this MSEA is of little use since the 
binding to O'I is unlikely to be, known in generation. 
6 MSEA's of basic predicates, such as concat, are assumed to 
be known a priori; MSEA's for recursive predicates are first comput- 
ed from non-recursive clauses. We assume that symbols Xi in 
definitions (P) and (R) above represent terms, not just variables. For 
more details see (Strzalkowsld and Peng, 1990). The case of s=O is 
discussed below. 
7 A term Y is always unifiable with a term X if they unify re- 
gardless of the possible bindings of any variables occurring in Y 
(variables standardized apart), while the variables occurring in X are 
unbound. Any term is always unifiable with a variable, but the in- 
verse is not necessarily true. 
corresponding .argument Xt in P then remove m I,k 
from MRU 1. For every set ml,kj = ml,k vo {X I,j}, 
where X 1,j is an argument in R 1 such that it is not 
already in m l,k and it is not always unifiable with 
its corresponding argument in P, and m 1,kj is not a 
superset of any other ml,t remaining in MRUt, 
add ml&. to MRU 1. 
(4) For each ml,j e MRU1 O'=l ''' rl) compute bh,j 
:= VAR(ml,j) c~ VP. Let MP1 = {t/1,./ I 
~(t-tx,j), j=l ... r}, where r>0, and ~(I-q,j) = \[I-h,j 
¢ ~ or (lth,j = O and VAR (m I,j) = ~D)\], If MP 1 = 
O then QUIT: (C1) is ill-formed and cannot be 
executed. 
(5) For each I-q,j 6 MP1 we do the following: (a) 
assume that bh,j is "in" in R1; (b) compute set 
OUT1, j of "out" arguments for R i; (c) call 
MSEAS (MS Lj,btl.j,VP, 2,0UTI,j); (d) assign MS 
:= ~ MSI,j. 
j=l..r 
(6) In some i-th step, where l<i<_s, and MSEA = 
~/i-l,k, let's suppose that MR i and MRUi are the 
sets of active MSEA's and their instantiations with 
actual arguments of R i, for the literal R i on the rhs 
of (p). 
(7) If Ri = P then for every mi,. e MRUi if every 
argument Y, e mi,u is always unifiable with its 
corresponding argument Xt in P then remove mi, u 
from MRUi. For every set mi,~, 1 = mi.u u \[Xi,j} 
where X~.i is an argument in R i such that it is not 
already in mi, u and it is not always unifiable with 
its corresponding argument in P and mi,.j is not a 
superset of any other mi, t remaining in MRUi, add 
mi..j to MRU 1 . 
(8) Again, we compute the set MP i = {t.ti,j I 
j=l ... ri}, where P-i,j = (VAR (mi,j) - OUTi<,k), 
where OUT~<.k is the set of all "out" arguments in 
litemls R 1 to Ri_ 1 . 
(9) For each \].ti, j remaining in MP i where i<_s do the 
following: 
(a) if bti,j = ~ then: (i) compute the set OUTj of 
"out" .arguments of Ri; (ii) compute the union 
OU'I}j := OU~I) vo OU~<,k; (iii) call 
MSEAS (MSi,j, I.ti-1,k, VP,i +1, OUTi,j); 
(b) otherwise, if bti,j ~ ~ then find all distinct 
minimal size sets v, c VP such that whenever 
the arguments in vt are "in", then the argu- 
ments in ~i,j are "out", If such v/s exist, then 
for every vt do: (i) assume v, is "in" in P; (ii) 
compute the set OUT~,j, of "out" arguments in 
all literals from R 1 to Ri; (iii) call 
MSEA S (MSi,j, , ~i- 1, k WV t, VP, i + 1,0 UT i,j, ); 
(c) otherwise, if no such vt exist, MSi,j := O. 
(10) Compute MS := U M&,j; 
j =l..r 
3 349 
(ll)For i=s+l setMS := {MSEA}. 
In order to compute the set of all MSEA's for P, the 
procedure presented above need to be modified so that 
it would consider all feasible orderings of literals on 
the rhs of (P), using information about all MSEA's for 
Ri's. This modified procedure would regard the rhs of 
(P) as an unordered set of literals, and use various 
heuristics to consider only selected orderings. We out- 
line the modified procedure briefly below. 
Let RR denote this set, that is, RR = {Ri I 
i=1 "'s}. We add RR as an extra argument to 
MSEAS procedure, so that the call to the modified ver- 
sion becomes MSEAS (MS,MSEA,VP,RR,i, OUT). 
Next we modify step (2) in the procedure as follows: 
(2') F:or every element Rt. 1 ~ RR, do (2) to (5): 
(2) Let MR,. 1 be the set of all MSEA's of R,. 1, and let 
MRU,. 1 be obtained from MR,. 1 by replacing all 
variables in each member of MR,, 1 by their 
corresponding actual arguments of R,, 1. 
Further steps are modified accordingly. The reader 
may note that the modified MSEAS procedure will 
consider all feasible ways of ordering elements of RR. 
In the steps shown above, we select all literals as 
potential leading elements on the right hand side, even 
though most of them will be rejected by steps (3) and 
(4). For those that survive, we will select elements 
from the rest of RR that can follow them. In step (5) 
the recursive call to MSEAS will be 
M SEAS (MS,. 1.y,l-t,, 1,j, VP,RR-{R,. 1},2,OUT,. 1.j). In 
step (6), that is, in i-th step of the recursion, we con- 
sider all elements of RR-{R,,j I j=l • • • i-1}, for selec- 
tion of the i-th literal on the right-hand side. By this 
time we will have already generated a number of pos- 
sible orderings of {R t I l=l • •. i-1}. We add step (6') 
which contains the head of an iteration over the 
remaining elements of RR, and covering steps (6) to 
(11). Again, some of the elements of RR will be 
rejected in steps (7) and (10). We continue until RR is 
completely ordered, possibly in several different ways. 
For each such possible ordering a set of MSEA's will 
be computed. Step (12) is an end condition with 
RR=~. To obtain a meaningful result, MSEA's in 
MR,,j's must be grouped into sets of these which are 
active at the same time, that is, they belong to the set 
of active MSEA's for a specific definition of P (i.e., 
ordering of RR). MSEA's belonging to different 
groups give rise to alternative sets of MSEA's in the 
final set MS. Note that in this modified algorithm, MS 
becomes a set of sets of sets. 
An important part in the process of computing 
essential arguments for literals is the selection of 
MSEA's for lexicon access and other primitives whose 
definitions are not subject to change. As an example, 
consider a fragment of a lexicon: 
verb ( \[looks IV\] ,V, sg, look) . 
verb( \[looklV\] ~V,pl, look) . 
verb ( \[arrives IV\], V, sg, arrive) . 
verb ( \[arrive IV\], V, pl, arrive) . 
The lexicon access primitive verb (VI, V2, Nm, P) 
has two sets of essential arguments: {Vl} and 
{Nm, P}. This is because {vl} can be consistently 
unified with at most one of {\[lookalV\]}, 
{ \[look I Vl }, { \[arrive I V\] }, etc., at a time. Simi- 
larly, {Nm, P} can be consistently unified at any one 
time with at most one of {sg, look}, {pl, look}, 
{sg, arrive}, etc. Note that neither {P} nor {Nm} 
alone are sufficient, since they would unify with 
corresponding arguments in more than one clause. 
This indeterminacy, although not necessarily fatal, 
may lead to severe inefficiency if the generator has to 
make long backups before a number agreement is esta- 
blished between, say, a verb and its subject. On the 
other hand, if the representation from which we gen- 
erate does not include information about the lexical 
number for constituents, we may have to accept {P } as 
the generation-mode MSEA for verb, or else we risk 
that the grammar will not be reversed at all. 
REORDERING LITERALS IN CLAUSES 
When attempting to expand a literal on the rhs of 
any clause the following basic rule should be observed: 
never expand a literal before at least one its active 
MSEA's is "in", which means that all arguments in at 
least one MSEA are bound. The following algorithm 
uses this simple principle to reorder rhs of parser 
clauses for reversed use in generation. This algorithm 
uses the information about "in" and "out" arguments 
for literals and sets of MSEA's for predicates. If the 
"in" MSEA of a literal is not active then the rhs's of 
every definition of this predicate is recursively reor- 
dered so that the selected MSEA becomes active. We 
proceed top-down altering definitions of predicates of 
the literals to make their MSEA's active as necessary, 
starting with the top level predicate parse(S,P), where 
P is marked "in" (parse structure) and S is marked 
"out" (generated sentence). We continue until we 
reach the level of atomic or non-reversible primitives 
such as concat, member, or dictionary look-up rou- 
tines. If this process succeeds at reversing predicate 
definitions at each level, then the reversed-parser gen- 
erator is obtained. 
INVERSE("head :- old-rhs",ins,outs); 
{ins and outs are subsets of VAR(head) which 
are "in" and are required to be "out", respectively } 
begin 
compute M the set of all MSEA's for head; 
for every MSEA m e M do 
begin 
OUT := ~; 
if m is an active MSEA such that me ins then 
begin 
compute "out" arguments in head; 
add them to OUT; 
4 350 
if outs cOUT then DONE("head:-old-rhs") 
end 
else if m is a non-active MSEA and mc_ins then 
begin 
new-.rhs := O; QUIT := false; 
old-rhs-1 := old-rhs; 
for every literal L do M L := ~; 
{done only once during the inversion} 
repeat 
mark "in" old-rhs-1 arguments which are 
either constants, or marked "in" in head, 
or marked "in", or "out" in new-rhs; 
select a literal L in old-rhs-1 which has 
an "in" MSEA m L and if m L is not active in L 
then either M L = 0 or m L e ML; 
set up a backtracking point containing 
all the remaining alternatives 
to select L from old-rhs-1; 
if L exists then 
begin 
if m L is non-active in L then 
bbegin 
if M L = O then M~, := M L ~3 {mL} ; 
for every clause "L1 :- rhSL/' such that 
L1 has the same predicate as L do 
begin 
INVERSECL1 :- rhsu",ML,~); 
if GIVEUP returned then backup, undoing 
all changes, to the latest backtracking 
point and select another alternative 
end 
end; 
compute "i~f' and "out" arguments in L; 
add "out" arguments to OUT; 
ncw-rhs := APPEND-AT-THE-END(ncw-rhs,L); 
old-rhs- 1 := REMOVE(old-rhs- 1,L) 
end {if} 
else begin 
backup, undoing all changes, to the latest 
backtracking point and select another 
alternative; 
if no such backtracking point exists then 
QUIT := true 
end {else} 
until old-rhs-1 = O or QUIT; 
if outscOUT and not QUIT then 
DONE C head:-new -rh s") 
end {elseif} 
end; {for} 
GIVEUPCgrammar can't be inverted as specified") 
end; 
MOVING LITERALS BETWEEN CLAUSES 
The inversion algorithm, as realized by the pro- 
cedure INVERSE, requires that for each clause in the 
parser code we can find a definite order of literals on 
its right-hand side that would satisfy the requirements 
of running this clause in the reverse: appropriate 
minimal sets of essential arguments (MSEA's) are 
bound at the fight time. However, this requirement is 
by no means guaranteed and INVERSE may encounter 
clauses for which no ordering of the literals on the 
right-hand side would be possible. It may happen, of 
course, that the clause itself is ill-formed but this is not 
the only situation. It may be that two or more literals 
on tile right-hand side of a clause cannot be scheduled 
because each is waiting for the other to deliver the 
missing bindings to some essential arguments. As an 
example, consider the grammar fragment below: 
sent(P) "- sub(NI,PI), 
vp (NI,PI, P). 
vp(NI,PI,P) :- v(N2,P2), 
agree (NI, N2), 
obj(P1,P2,P) . 
In the generation mode, that is, with the variable P 
instantiated by the parse structure of a sentence, the 
following active MSEA's and "out" arguments have 
been computed: 
predicate MSEA "out" 
sent {P} 
sub {PI} N1 
vp {NI,P} P1 
v {P2} N2 
agree {NI,N2} 
obj {P} PI,P2 
In order to use these rules for generation, we 
would have to change the order of literals on the right- 
hand side of sent clause, so that the vp is expanded 
first. However, doing so would require that the variable 
N1 is bound. This we could get by firing subj first, 
but we can't do this either, since we wouldn't know 
the binding to P1. We note, however, that if we con- 
sider the two clauses together, then a consistent order- 
ing of literals can be found. To see it, we expand vp 
on the right-hand side of the first clause replacing it 
with the appropriately unified literals in the right-hand 
side of the second clause, and obtain a single new 
clause that can be reordered for generation as follows: 
sent(P) :- obj(PI,P2,P), 
v (N2, P2) , 
sub (NI, PI) , 
agree (NI, N2 ) . 
Now we can reintroduce the non-terminal vp, and 
break the above rule back into two. Note that as a 
result agree migrated to the first clause, and N2 
replaced N1 on the argument list of vp. Note also 
that N2 is not an essential argument in the new vp. 
sent(P) :- vp(N2,Pl,P), 
sub (NI, Pl) , 
agree (NI, N2 ) . 
vp(N2,PI,P) :- obj(PI,P2,P), 
v (N2, P2) . 
5 351 
The only thing that remains to be done is to automati- 
cally determine the arguments of the new vp predi- 
cate. Doubtless, it will be a subset of the arguments 
occurring in the literals that create the right-hand side 
of the new clause. In the example given this set is 
{N2,1?1, I72,17}. From this set, we remove all those 
arguments which do not occur in other literals of the 
original clause, that is, before the break up. The only 
such argument is 172, and thus the final set of argu- 
ments to vp becomes {N2,P:I.,1?}, as shown above. 
The complete algorithm for interclausal reordering of 
goals can be described by a largely straightforward 
extension to INVERSE (Strzalkowski, 1989) 8 
CONCLUSIONS 
In this paper we presented an algorithm for 
automatic inversion of a unification parser for natural 
language into an efficient unification generator. The 
inverted program of the generator is obtained by an 
off-line compilation process which directly manipu- 
lates the PROLOG code of the parser program. We dis- 
tinguish two logical stages of this transformation: com- 
puting the minimal sets of essential arguments 
(MSEA's) for predicates, and generating the inverted 
program code with INVERSE. We have completed a 
first implementation of the system and used it to derive 
both a parser and a generator from a single DCG gram- 
mar for English (Strzalkowski and Peng, 1990). 
This method is contrasted with the approaches 
that seek to define a generalized but computationally 
expensive evaluation strategy for running a grammar 
in either direction without a need to manipulate its 
rules (Shieber, 1988), (Shieber et al., 1989), and see 
also (Colmerauer, 1982) and (Naish, 1986) for some 
relevant techniques, employing the trick known as goal 
freezing. To reduce the cost of the goal freezing, and 
also to circumvent some of its deficiencies, Shieber et 
al. (1989) introduce a mixed top-downPoottom-up goal 
expansion strategy, in which only selected goals are 
expanded during the top-down phase of the interpreter. 
This technique, still substantially more expensive than 
a fixed-order top-down interpreter, does not by itself 
guarantee that the underlying grammar formalism can 
be used bidirectionally, and it may need to be aug- 
mented by static goal reordering, as described in this 
paper. 
ACKNOWLEDGMENTS 
Ralph Grishman, Ping Peng and other members 
of the Natural Language Discussion Group provided 
valuable comments to earlier versions of this paper. 
s It should be noted that recursive clauses are never used for 
literal expansion during interclausal ordering, and that literals are not 
moved to or from recursive clauses, although argument lists of recur- 
sive literals may be affected by literals being moved elsewhere. 
This paper is based upon work supported by the 
Defense Advanced Research Project Agency under 
Contract N00014-85-K-0163 from the Office of Naval 
Research. 

REFERENCES 

Colmerauer, Alain. 1982. PROLOG II: Manuel de 
reference et modele theorique. Groupe 
d'Intelligence Artificielle, Faculte de Sciences de 
Luminy, Marseille. 

Dymetman, Marc and Isabelle, Pierre. 1988. "Rever- 
sible Logic Grammars for Machine Translation." 
Proc. of the Second Int. Conference on Machine 
Translation, Pittsburgh, PA. 

Debray, Saumya, K. 1989. "Static Inference Modes 
and Data Dependencies in Logic Programs." 
ACM Transactions on Programming Languages 
and Systems, 11(3), July 1989, pp. 418-450. 

Grishman, Ralph. 1986. Proteus Parser Reference 
Manual. Proteus Project Memorandum #4, 
Courant Institute of Mathematical Sciences, New 
York University. 

Naish, Lee. 1986. Negation and Control in I'ROLOG. 
Lecture Notes in Computer Science, 238, 
Springer. 

Shieber, Stuart, M. 1988. "A uniform architecture for 
parsing and generation." Proceedings of the 
12th COLING, Budapest, Hungary, pp. 614-619. 

Shieber, Stuart M., van Noord, Gertjan, Moore, Robert 
C. and Pereira, Fernando C.N. 1989. A 
Semantic-ttead-Driven Generation Algorithm for 
Unification-Based Formalisms. Proceedings of 
the 27th Meeting of the ACL, Vancouver, B.C., 
pp. 7-17. 

Shoham, Yoav and McDermott, Drew V. 1984. 
"Directed Relations and Inversion of PROLOG 
Programs." Proc. of the Int. Conference of Fifth 
Generation Computer Systems, 

Strzalkowski, Tomek. 1989. Automated Inversion of a 
Unification Parser into a Unification Generator. 
Technical Report 465, Courant Institute of 
Mathematical Sciences, New York University. 

Strzalkowski, Tomek. 1990. "An algorithm for invert- 
ing a unification grammar into an efficient 
unification generator." Applied Mathematics 
Letters, vol. 3, no. 1, pp. 93-96. Pergamon Press. 

Strzalkowski, Tomek and Peng, Ping. 1990. 
"Automated Inversion of Logic Grammars for 
Generation." Proceedings of the 28th Annual 
Meeting of the ACL, Pittsburgh, PA. 
