Lecture Notes in Computer Science 383 PDF
Lecture Notes in Computer Science 383 PDF
383
K. Furukawa H. Tanaka
T. Fujisaki (Eds.)
Springer-Verlag
Berlin Heidelberg NewYork London ParisTokyo Hong Kong
Editors
Koichi Furukawa
ICOT Research Center
Mita Kokusai Building 21 F, 4-28 Mita 1-chome
Minato-ku, Tokyo 108, Japan
Hozumi Tanaka
Department of Computer Science, Faculty of Engineering
Tokyo Institute of Technology, 12-10h-okayama 2-chome
Meguro-ku, Tokyo 152, Japan
Tetsunosuke Fujisaki
IBM, Thomas J. Watson Research Center
P.O.Box 704, Yorktown Heights, New York 10598, USA
Thiswork is subject to copyright.All rights are reserved,whetherthe whole or part of the material
is concerned, specificallythe rights of translation,reprinting, re-useof illustrations,recitation,
broadcasting, reproductionon microfilmsor in other ways,and storage in data banks. Duplication
of this publicationor parts thereof is only permitted underthe provisionsof the German Copyright
Law of September 9, 1965, in its version of June 24, 1985, and a copyright fee must alwaysbe
paid. Violationsfall under the prosecutionact of the German Copyright Law.
© Springer-VerlagBerlin Heidelberg 1989
Printed in Germany
Printing and binding: Druckhaus Bettz, Hemsbach/Bergstr.
2145/3140-543210- Printed on acid-free paper
Foreword
This volume of the Springer Lecture Notes in Computer Science contains most of
the papers presented at the Seventh Logic P r o g r a m m i n g Conference (April 11-14,
1988 Tokyo). It is the successor to volumes 221,264 and 315.
The first and second papers in the "Nonmonotonic Reasoning" section deal
with the problem of belief revision caused by adding new facts. The third paper
gives a new formalism to the problem of nonmonotonic reasoning associated with
inheritance and proposes a parallel algorithm to solve it.
"Logic p r o g r a m m i n g L a n g u a g e / S y s t e m " c o n t a i n s t h r e e p a p e r s on
debugging, explicit control of logic programs and a new programming paradigm
called lattice programming. This last one is particularly interesting both from
theoretical and practical viewpoints. It associates for each computing path of
Prolog programs a value other than true/false, thus increasing its expressive
power.
The "Guarded Horn Clauses" section includes two papers. The first tries to
realize reflection on GHC, and the second paper gives an implementation of full
GHC by communication processes.
The next "Knowledge Base System" section contains two papers. The first
one gives inference methods and semeantics for a knowledge base containing
disjunctive non-Horn clauses. The latter describes a formalism of conventional
network type database access in terms of a refutation procedure.
A. Yamamoto
Completeness of Extended Unification Based on Basic
Narrowing 1
A. Sakurai and H. Motoda
Proving Definite Clauses without Explicit Use of Inductions 11
Nonmonotonic Reasoning
J. Tanaka
A Simple Programming System Written in GHC
and Its Reflective Operations 108
M. Terada
Implementation of Full GHC by Communicating Processes 122
H. Sakai
Inference Methods and Semantics on Or-type Knowledge Bases 136
M. Takizawa, M. Katsumata and S. Nagahora
Access Program to Minimize Redundant Refutations on
the Network Database System 156
Referees
Akihiro Y A M A M O T O
Abstract
In this paper we prove the completeness of unification based on basic narrowing.
First we prove the completeness of unification based on original narrowing under a
weaker condition than the previous proof. Then we discuss the relation between basic
narrowing and innermost reduction as the lifting lemma, and prove the completeness
of unification based on basic narrowing. Moreover, we give the switching lemma to
combine the previous algorithm and our new proof.
1. I n t r o d u c t i o n ,
The main contribution of this paper is a proof that the extended unification procedure based on
basic narrowing is complete under some conditions. The procedure was first given by Hultot [2],
and then improved by Bosco et al. [1]. The improved procedure [1] was obtained by translating
every basic narrowing sequence into an SLD-refutation sequence. It is now very important as a
foundation of logic-functional programming languages, but the proof of its completeness is not
straightforward.
Hullot [2] proved the lifting lemma for basic narrowing as that of SLD-resolution. However,
his proof is incomplete since we found a counter example for Lemma 3 [2]. To prove the lifting
lemma for basic narrowing, we need to construct a basic reduction sequence from every term, but
its existence is not guaranteed in general. By clarifying the function of knnermost reduction, we
overcome this difficulty and show the existence.
We first show, under a weaker condition than [2], the completeness of unification based on
original narrowing. That is, the term rewriting system is simply assumed weakly canonical. Then
we establish the relation between innermost reduction and basic narrowing as the lifting lemma~
and prove the completeness of unification based on basic narrowing. Thus "we suppose the con-
dition that the term rewriting system is both weakly canonical and normalizing with innermost
reductions. Moreover, we show the relation between the completeness theorem and the algorithm
in [1] by clarifying the procedure which searches an innermost redex. Thus the relation is stated
as the switching lemma.
The paper is organized as follows. In the next section, we explain narrowing and basic
narrowing. In Section 3, we prove the completeness of unification based on narrowing under a
weaker condition t h a n that in [2], and discuss the problem in the case of basic narrowing. In
Section 4, we prove the completeness of unification based on basic narrowing under a weaker
condition t h a n t h a t in [2]. In Section 5, we discuss the relation of our proof and the algorithm
given in [1] as a form of the switching lemma.
W h e n we regard --* as a binary relation on the set of terms, we call it the reduction relation
on /:~.
A t e r m t is in normM form if there exists no term s such that t --* s. If there exists a finite
reduction sequence
t -~ to --* tl --+ . . . - - * t n =_ s
such that s is in normM form, then s is called a normaI form o f t and is denoted by N(t). Moreover,
let 8 be a substitution {X1 *-- t l , . . . , Xn ~- tn }. If each of t l , . . •, t,~ is in normal form, then 0 is said
to be in normal form. For every substitution 0, the substitution {X1 *-- N ( t l ) , . . . , X , e-- N(t~)},
if it exists, is called a normM form o f O.
D e f i n i t i o n 2. Let t and s be terms. T h e n t is narrowed ~o s, if there exist u ~ Og(t), a variant
--+/3 of a rule in R, and a substitution ~ such that a is an mgu of f l u and ce and s --- (t[u ~/3])~.
W h e n t is narrowed to s, we write t ~ s, or t ~ D , ~ Z , ~ ] s to give full details.
the variables in every ai -+ /~i are standardized apar~ ([3]). W e also assume that mgu's are
c o m p u t e d by the algorithm in [3, 4]. T h e n the E-uniflcation of two terms t and s based on
narrowing is to generate the set
D e f i n i t i o n 4. E-unification based on narrowing is complet;e if, for every two terms t and s,
P,(t,a) is a complete set of E-unifiers of t and s.
D e f i n i t i o n 5. A narrowing sequence
is basic if there exists a sequence of sets of occurrences U 0 , . . . , Un which satisfies the following
conditions:
(B-l) U0 = Og(to),
(B-2) ui C Ui C Oc(ti) (0 < i < n - 1) and Un C Oc(tn),
(B-a) U~+I=(U~-{v~Ui;u~_v})U{ui.v;v~Og(~0} (0<i<n-1).
Example 1. Let R = { f ( X , b) -+ g ( X ) , a --~ b } . T h e n a narrowing sequence
T h e E-unit~cation of two terms t and s based on basic narrowing is to generate the set
Definition 6. E-unification based on basic narrowing is complete if, for every two terms t and
s, ~B(t, s) is a complete set of E-unifiers of t and s.
[1] has improved E-unification based on basic narrowing by using innermost occurrences and
has given an efficient algorithm as explained below.
unify(t, s, S) /* 4 and s are terms and S is a rule to select an innermost occurrence from B */
E := eq(t, s), B := Og(eq(t, s)) - {A}, and ® := e
/ * E is a term, B is a set of occurrences, and O is a substitution * /
LOOP:
i f B = ¢ then
O := O/z and return Olv(t)uv(s) w h e r e / ~ is an mgu of # and a r w h e r e E = eq(#,s ~)
else
select an innermost occurrence u from B according to S,
nondeterministically execute either (1-1) or (1-2), and goto L O O P :
(>1) B := B - (u}
(1-2) select nondeterministically a variant a -~ ~ of a rule in R such ttmt
all the variables in V(a) are new and E / u and c~ are unifiable~
S := (E[u ~ ;31)~r, O := @~, and B := (B - {u}) O { u . v ; v e Og(3)}
w h e r e a is an mgu of E / u and
end i f
T h e o r e m 1 ( H u l l o t [2]). Let t and s be terms such that t =- szl for some normal substitution
TI. Then for a reduction sequence
The assumption of Theorem 1 is only that ~ is in normal form. Therefore we can easily
weaken the condition for Hullot's Theorem.
D e f i n i t i o n 8. R is weakly canonical if for every term t there exists only one normal form N ( t )
and for every pair of t and s
E~t=s ~ g(t)=N(s).
Then t I and s t are unifiable because there is a substitution r/n such that tl~n -~ Sl?}n. I
To show that the above theorem is a proper extension of HuUot's Theorem, we give an example
which shows the difference between canonicity and weak canonicity.
E x a m p l e 2. Let R = {repeat --, repeat, repeat --~ halt}. Then R is weakly canonical. For every
term t, its unique normal form is a term given by replacing every repeat in t by halt. Moreover,
we can decide E ~ t = s by comparing N(t) and N(s). However, R is not finitely terminating, so
R is not canonical.
Now our problem is to prove the completeness of E-unification based on basic narrowing. A
result similar to Theorem 1 is needed for basic narrowing. Thus we introduce basic reduction.
D e f i n i t i o n 9. Let t and s be terms such that t - s8 for some substitution ~. Then a reduction
sequence
is based on Og(s) if there exists a sequence of sets of occurrences U 0 , . . . , U,~ which satisfies the
conditions (B-2) and (8-3) in Definition 5 and the following condition (8-1') instead of (8-1):
(B-I') U0 = Og(s).
Definition 10. Suppose that t --~{u,a-~,e] 8 for some term s. Then t / u is an innermost redex
and the reduction is called an innermost reduction if any proper subterm of t / u is normal.
E x a m p l e 4. Let R = {f(X, b) ~ g(X), a ~ b}. Then the innermost redexes o f f ( f ( a , b), f(b, b))
are a and f(b,b). Thus
f ( f ( a , b), f(b, b)) --~ f ( f ( a , b), g(b))
f(f(a,b),f(b,b))-~f(g(a),f(b,b))
is not.
We will clarify the relation of the two definitions of 'innermost', which are in Definition 7 and
in Definition 10, as an algorithm in Section 5.
As suggested by Example 3, innermost reduction furnishes a way to construct the basic
reduction sequence. The following lemma is a key result for our proof of the completeness of
E-unification based on basic narrowing.
consists only of innermost reductions, then the reduction sequence is based on Og(t).
P r o o f . The proof is by induction on the length of the reduction. Suppose first that n = 1, and
consider the reduction sequence
iT/-- ~o --+[uo,~o-+fl,oo]tl.
Then the occurrence of every redex of to is in Og(t) because y is normal. Thus the result holds
by letting
Uo = o g ( t ) ,
u1 = (v0 - {v E u0 ; ~0 ~ v}) u { ~ 0 - v ; ~ e og(~o)).
Now suppose that the result holds for n. Consider the sequence
trl ==-to --~ " " --~ tn-1 "-~[u._~,a._,~fl,_~,0._l] tn --+[u,,a,--.fl.,o.] tn+l.
From the induction hypothesis there is a sequence of sets of occurrences [To,..., Un which satisfies
the conditions (B-I'), (B-2), and (B-3) for the sequence
Because t , - 1 / u n - 1 is aza innermost redex, all of its proper subterms are normal, and ~n-1 is also
normal. Thus the occurrence of every redex o f ~ n - l ~ n - 1 is in Og(fln--1). So because un C U,, the
sequence V0,..., Vn+l satis~es the conditions (B-V), (B-2), and (B-3) by lettin,
If R is canonical, then R has the property that there is an innermost reduction sequence from
every term t to N ( t ) because any reduction sequence from t reaches N(t). However the property
is not confirmed in general. Therefore we need to identify the class of term rewriting systems with
this property.
D e f i n i t i o n 11. R is normalizing wi*h innermost reductions if for every term there exists an
innermost reduction sequence to its normal form.
Then the completeness of E-unification based on basic narrowing is proved using the innermost
reduction sequence.
Proof. Let 8 be an E-unifier of t and s, arid ~7 be its normal form. Because R is normalizing
with innermost reductions, there exists an innermost reduction sequence
eq( t, s)~ = to --~[u0,~0~0,oo] tl -~[. . . . ~-~t,0~] t2 - * . " --+[. . . . . . . . . . p. . . . o._ ~] t , -- eq( N ( t~), N( s~) ).
Then the narrowing sequence is also basic by using U 0 , . . . , U,, because the two sequences use the
same occurrence at each step. Moreover, t f and s t are unifiable, and there is a substitution 7 such
that
g o ' " e~-l#Tiv(,)uv(~) = rliv(,)uv(~)
A l g o r i t h m 2.
innermost_reduce(t) /* t is a r~erm */
T := t, B := Oc(t), /* T is a term, and B is a set of occurrences */
LOOP:
ifB = ¢ then
return T
else
nondeterministically select an innermost occurrence u from B,
if there is no rule ~ -~/3 in R such that T / u - aO for some 0 t h e n
(2-1) B := B - {u} and goto LOOP /* T / u is in normal form*/
else
nondeterministically select a --* fl from R such that T / u = aO for some 0
T := T[u ¢= ~0], B := (B - {u}) O {u. v ; v e Og(~)}, and goto LOOP
end if
e n d if
In Algorithm 2 the procedure which searches an innermost redex from a term is clarified by
using the set B and step (2-1). This step shows the difference between Definition 7 and Definition
t0.
Now we apply Algorithm 2 to the construction of the basic reduction sequence in the proof
of Theorem 3. The reduction sequence and the basic narrowing sequence in the proof use the
same sequence U o , . . . , Un. Thus it is clear that we may add a step corresponding to (2-1) to the
procedure for basic narrowing. In Algorithm t the step is (1-1).
Then in order to prove the completeness of Algorithm 1 using Theorem 3, we need to show
that we may restrict the selection of innermost occurrences with a computation rule S. This
restriction is allowable because of the following switching lemma for Algorithm 1. To explain the
lemma, in Algorithm 1, we use symbols E(S, n), B(S, n), O(S, n) to represent the values of E, B,
and O at the beginning of the n-th execution of the LOOP when the computation rule is S.
L e m m a 2. Suppose that there are two innermost occurrences u and v in B ( S , n) and that S
selects u in the n-th execution of the LOOP and v in the (n + 1)-st. Then we m a y use the
computation rule S t which selects v instead of u at ~he n-th execution o f LOOP and u at the
(n + 1)-st. Moreover we can lot E(S, n + 2) and E(S', n + 2) be variants, e ( s , n) and e ( s ' , n) be
~ i ~ t s , and B ( S , ~ + 2) = B ( S ' , n + 2).
It should be noticed that Le~mna 2 is proved by translating every basic narrowing sequence
to an SLD-refutation and applying the switching lemma for SLD-refutation in [1]. Of course, the
false assertion was used in [1]. Thus we omit its proof.
10
6. Conclusion
We have proved the completeness of E-unification based on narrowing under a weaker restriction
and have proved the completeness of E-unification based on basic narrowing, and have given the
switching lemma. The discussion in [1] is important but was only half way to the completeness
because it showed only the switching lemma.
In the discussions above, we have used the conditions that R is weakly canonical and is
normalizing with innermost reductions. Both [1] and [2] treat the case that R is a canonical
term rewriting system, which is useful for theorem provers using reduction. In the discussions on
narrowing, the restriction for term rewriting systems should be weakened because E-unification
based on narrowing is a refutation procedure. We have shown that it can really be weakened.
We need to find sufficient conditions under which a term rewriting system is weakly canonical
and normalizing with innermost reductions. Especially, we have not clarified any properties of
term rewriting systems which are normalizing with innermost reductions. We conjecture that
weakly canonical term rewriting systems are normalizing with innermost reductions.
We need also to import the property of SLD-resolution other than the switching iemma into
the theory of narrowing. For example, we are considering the complete definitions of functions in
the same way as those of predicates in SLD-resolution.
Acknowledgements
The author would like to thank Prof. Setsuo Arikawa for his constructive comments and en-
couragements. The author also wishes to thank Dr. Makoto Haraguchi for many discussions on
narrowing and SLD-resolution.
References
[1] Bosco, P.G., Giownnetti, E., and Moiso, C. (1987): Refined Strategies for Semantic Unifica-
tion, Proc. TAPSOFT '87 (LNCS 250), 276-290.
[2] Hullot, J.M. (1980): Canonical Forms and Unification, Proc. 5th Conference on Automated
Deduction (LNCS 87), 318-334.
[3] Lloyd, J.W. (1984): Foundations of Logic Programming, Springer-Verlag.
[4] Martelli, A. and Montanari, U. (1982): An Efficient Unification Algorithm, AC1VITOPLAS,
4(2), 258-282.
[5] Yamamoto, A. (1987): A Theoretical Combination of SLD-Resolution and Narrowing, Proc.
4th ICLP, 470-487.
Proving Definite Clauses without Explicit Use of Inductions*
Akito S A K U R A I Hiroshi MOTODA
Advanced Research Laboratory, Hitachi Ltd.
1-280 Higashi-Koigakubo, Kokubunji, Tokyo 185, JAPAN
A b s t r a c t . We propose an algorithm to prove a definite clause is modeled
by an intended minimal model of a set of definite clauses. In the algorithm,
no induction scheme will be used explicitly, although in effect a mathematical
induction is implied. This algorithm corresponds to an inductionless induc-
tion method using the Knuth-Bendix algorithm in an equation problem. It
resembles the completion algorithm, but in fact it is a completely different
algorithm.
1. I n t r o d u c t i o n
The problem we are concerned with is how to determine if a definite clause is valid under
an intended minimal model of a set of definite clauses. Let us call this an implication
problem, just as the problem to determine the validity of equalities under some theory
is called an equa~ty problem.
The implication problem is the one to be solved by a theorem prover for a first-
order logic. It is, however, well known that if the theory includes inductive definitions
it is hard to determine the validity of clauses. The reason lies in the difficulties of an
inductive proof whose construction is necessary when objects of the theory are defined
inductively.
To implement an induction mechanism in a system, you have to implement heuris-
tics of induction pattern or generalization ([2] etc.). Similar difficulties lie in the equality
problem. Many researchers have tried adoption of the Knuth-Bendix completion algo-
rithm to the equality problem with an idea that if the system augmented with the
new equality to be proved can be completed by the algorithm (and satisfies certain
conditions), then the equality is consistent with the original system([6],[8]).
Can the same approach be used in the implication problem? Unfortunately "No"
is the answer. For example, Hsiang's system [4] seems not to have enough capability to
prove inductive theorems. Although Paul [11] claims his system can conduct inductive
proofs, it usually "proves" a theorem by fMling to halt.
Hsiang [5] proposed an extension of Prolog to incorporate the ability to conduct
inductive proofs. But the ability is quite limited. Firstly, the implication problem
targeted by his system is restricted so that an implication to be proved contains only
equalities in its consequence part. Secondly, the transformations adopted in the system
are so weak that efficient lelnmas are not deducible. For example, the system cannot
express an implication problem with a non-deterministic predicate in its consequence
part, as in the perm-perm problem in Appendix A.3. The rev-rev problem in Appendix
A.2 can be expressed but not proved.
We propose in this paper an algorithm to solve the implication problem, by which
inductive proof is made without using induction explicitly, which is different from Knuth-
Bendix's but to which it bears some resemblance. In Appendix B, we show an example
which is easy to understand but which conveys key ideas of the proposed algorithm.
Readers are advised to read it first• In section 2, we introduce very briefly some ter-
minologies, and in section 3, we describe the algorithm. The conditions necessary to
guarantee the validity of a proof or a disproof will be found in section 4. T h e justification
of the conditions is briefly described in section 5.
2. P r e l i m i n a r i e s
In this section we give necessary definitions of terminology to be used•
Syntax
We distinguish between sets of variables, function symbols and predicate symbols. A
constant is a 0-ary function symbol. A term is a variable, a constant, or of the form
f ( t l , . . . , t ~ ) where f is an n-ary function symbol and t l ~ . . . , t n are terms. An atomic
formula (or atom for short) is of the form P ( t l , . . . , tn), where P is an n-ary predicate
symbol and t l , . . . , tn are terms. An atom is a ground atom if it contains no occurrence
of any variables• A definite clause is a clause of the form A +-- B 1 , . . . , Bn n > 0
where A, B 1 , . . . , B~ are atoms, and variables occurring in them are universally quan-
tified. A definite clause is a definite ground clause if it contains no occurrence of any
variables. A substitution ¢r = { X i / t i } is an operation defined on an atom, which replaces
simultaneously all occurrences of given variables Xi with given terms ti. The result is
called an instance, and is denoted by Act for an atom A. A substitution is a ground
substitution if the result is ground. This naturally extends to a set of atoms, clauses
and programs. We use the following terminology in our own meaning.
• We denote an array of variables with a boldface letter.
V(F) and 3 ( F ) are the universal and existential closure of any formula F , respec-
tively.
. A program is a set of definite clauses.
• A conjunct is a conjunction of atoms, and a disjunct is a disjunction of conjuncts.
• An extended definite clause is a formula of the form r ~-- A, where e-- is the
usual logical implication, F and A are respectively a disjunct and a conjunct with
some variables existentially quantified in each conjunct, and with all other variables
universally quantified in the formula. For the sake of clarity and convenience,
existentially quantified variables in different conjuncts are named distinctly. In
other words an extended definite clause is V ( 3 X l r l v . . . v 3XnFn ~'- 3 Y A ) , where
F~ and A are conjuncts.
• If it is not ambiguous, I~1 V .. • V Fn ~-- A or F ~ A is used instead of V(3X1F1 v
• .. 3XnFn ~- 3 Y A ) .
. An internal variable is an existentially quantified variable.
• For a substitution cr = {Xi/ti}~=l, we consider only the substitutions where no Xi
appears in any tj. In our context a substitution so restricted is always available if
we choose appropriate variants of formulae for c~ to operate on.
• Equality (--) as a predicate satisfies equality theory [10], and can be considered
as defined by the following clauses: = ( a , a ) . = ( ~ ( X 1 , . . . ,Xk), ~ ( Y 1 , . . . ,Yk)) +--
=(X1, Y 1 ) , . . . , = ( X k , Yk) where a represents an arbitrary constant symbol, qo an
arbitrary function symbol~ and k its arity.
M ~ G denotes that a formula G is correct under the model M .
MR is a minimal model of a program P. For details, see the following "Semantics".
13
Note that we do not presuppose any interpreter (i.e., computation rule and search
rule). So, two conjuncts A, B and B, A (or two disjuncts AV B and B v A) are equivalent
in all means.
Semantics
The concept of "correctness" should be made clear before entering into discussing
proofs of "a goal G is correct under a program P". It is natural to consider that a
closed formula VZ(3XF . - 3YA) is correct under a program P, if and only if, for any
ground substitution ~ of the variables Z, " P ~- 3Y~o~ entails P ~- 3XlPo~" where ~- will
be discussed later. Then what should be the meaning of P ~- 3YA~ (or P ~- 3XFo-) ?
It is also natural to consider a completion of P, that is comp(P), as the meaning of
a program P rather than P itself (i.e.,the logical meaning of the program). Especially
when a program P is viewed as defining predicates inductively, employing comp(P)
corresponds to adding to a definition of each predicate the statement '~Only those defined
by the above are ...".
Defining a transformation, Tp from interpretations to interpretations, associated
with a program P under the fixed point semantics, the least fixed point of Tp is con-
sidered to be the meaning of the program P. Note that, since the optimal fixed point
also becomes the minimal fixed point under logic programming, the minimal fixed point
semantics is more appropriate [9l, Adding to this advantage, the fixed point of Tp is
also a model of comp(P) if augmented with appropriate equational theories [10]. We
adopt this minimal fixed point formalism as the semantics.
An Herbrand universe is commonly used as a domain of interpretations. There are
two reasons for this. The first is that the minimal fixed point of Tp on an Herbrand
universe coincides with the minimal Herbrand model/]V/p. The second is that G is a
logical consequence of P if and only if G is valid under/-Mp [10] when negation of the
goal G is of clausal form (general goal clauses of Prolog have this form)
But in our implication problem, naive use of the Herbrand universe is not appro-
priate. The cause is rooted in the existence of ¢r stated above. Terms substituted for
by ~r can not be restricted to the elements of Hfp. In fact if we so restrict, something
unpleasant results:
Set P = {q(a),VXp(X)} and let a goal to be proved a be VX(q(X) ~- p(X)).
Obviously IMp = {q(a),p(a)} implies IMp ~ G. But intuitively we believe that G
cannot hold since q(X) may not so for some X other than a. Moreover, G is not a
logical consequence of P.
The cure is easy. Since the trouble is ascribed to substitutions which may replace
variables with terms consisting of constants other than predicted, we adapt the Herbrand
universe to include an enurnerable (by LSwenheim's theorem) set of constants including
all that we need in future, and call it the extended Herbrand universe Up. We construct
the extended Herbrand base Bp in the same way as we construct the Herbrand base.
Since the difference between//Jp and Up is only the existence of additional constants,
constructions of models, a least model Mp, fixed point and other semantics, etc. are
no different from conventional ones. The implication problem is, therefore, to find if
Me ~ P ,--/X.
14
3. E q u i f o r m a l i z a t i o n A l g o r i t h m
In this section we describe the proposed algorithm. The algorithm proceeds, trying to
reduce difference of form on both sides of implication while conserving correctness of
implications (the details are not discussed in this paper), to make b o t h formulae be of
the same form. Hence we call it the eqniformalization algorithm.
Following the equiformalization algorithm, we non-determinlstically develop a tree
called a transformation tree. If one non-deterministically constructed transformation
tree is proved to satisfy a proof-condition stated in section 4, then the algorithm termi-
nates with a positive answer. If one tree satisfies a disproof-condition, then the answer
is negative. If all the trees constructed non-deterministically satisfy a failure-condition,
then the total algorithm (including all non-deterministic branchings) terminates with
failure. There also exist some cases when the algorithm never terminates. In this sense
the name 'algorithm' may be inappropriate. Since the name 'Knuth-Bendix algorithm'
is used fairly commonly, we use the word too. At each step of the algorithm, a trans-
formation tree is further transformed by expanding a leaf to a subtree.
Throughout this paper, H, with possible further qualifications, denotes an atom; F,
A, A and II, with possible further qualifications, usually denote conjuncts, but denote
disjuncts in an implied part of ~---; ~, 8 and ~, with possible further qualifications, denote
substitutions.
D e f i n i t i o n 3.1 A transformation tree is a tree, in which
(1) on each node is an extended definite clause (possibiy empty on a Ieaf node),
(2) nodes with an empty clause and nodes marked false have no descendants,
(3) the descendants of a node are constructed by one of the procedures in Transforma-
tions,
(4) each branch is marked either "equivalence-preserved" or "equivaJence-not-
preserved",
(5) each node is marked "false" or not marked.
The equiformalization algorithm proceeds as follows. The algorithm consists of a
big loop and twelve transformations. Here, Co denotes an extended definite clause to
prove under a program P, where all the predicates referred to in Co are defined. And
in the following, the description is for a non-deterrnin~sticalty obtained tree.
A l g o r i t h m 3.2
1. Let To be a tree with only a root node Co. i ~- O.
2. If Ti satisfies a proof-condition, then ~he algorithm terminates: the answer is posi-
tive. If Ti satisfies a dlsproof-condition, then the algorithm terminates: the answer
is negative. If Ti satisfies a failure-condition, then the algorithm fails (only one
non-deterministically selected branch fails).
3. Select non-deterministically a non-empty leaf not marked false C in Ti and also
non-deterministicadly one of the procedures in Transformations and apply k to Ti.
Let the resultant tree be Ti+l.
4. Set i +- i + 1 and go back to step 2.
Transformation procedures are applied to some non-empty leaf of the tree. The
basic idea is to transform a conjunct or a clause on the leaf by "equivalence-preserved"
transformations to obtain its descendants, and to repeat the process until all the leaves
become trivially valid formulae. Of course, the validity of a root node is equivalent to
15
• A ~- A 1 , A 2 and rio ~ A 1
• for a n y internal variable X in l'i, XO is a variable and does not occur other
t h a n in rio
• ~ replaces different internal variables in II with different internal variables in
A
t h e n let T t a tree obtained f r o m T by adding the children F +- AiO, A2 for all i to
the leaf C. T h e node N is called a reference node, and the node C a cut node•
(7) Cut-left: If there exists an extended definite clause A +-- 1I which is a variant of a
clause on a node N other t h a n C in T, and a substitution 6 which satisfies
• F --__F I , F 2 VF3 where F1 and F2 are conjuncts, and A0 -- F1
• for any internal variable X in A, X 0 is a variable and does not occur other
t h a n in A0
. 0 replaces different internal variables in A with different internal variables in
F1 and F2
t h e n let T ' be a tree obtained f r o m T by adding a child II6,F2 V F~ ~ A to the
leaf C. A is called a cut formula, and 0 is called a cut substitution. Also the node
N is called a reference node, and the node C a cut node.
• (8) Replace-right: H it is already proved t h a t A1 V - . - V An ~ II, II +- At, . . . , and
II ~-- An hold where A1, • " , An, and II are conjuncts a n d the variables in t h e m do
not a p p e a r in T, a n d there exists a substitution 0 which satisfies
A -- At, A2 and II0 _= A1
• for any internal variable X in I I , X 0 is a variable and does not occur other
t h a n in II0
8 replaces different internal variables in ri with different internal variables in
A
then let T ¢ be a tree obtained f r o m T by adding children F +- Ai0, A2 for all i to
the leaf C.
• (9) Replace-left: If it is already proved that A +- ri and II +- A hold where A and II
are conjuncts and the variables in A a n d II do not a p p e a r in T and there exists a
substitution 8 which satisfy
• F =_ F1, F2 V F3 where F1 and r2 are conjuncts, and A0 - F1
• for a n y internal variable X in A, X 0 is a variable and does not occur other
t h a n in AO
- 0 replaces different internal variables in A with different internal variables in
r l a n d F2
then let T ' be a tree obtained f r o m T by adding a child ri0,F2 V F3 +-- A to the
leaf C.
(10) Partial instantiation: If there exists a substltution cr {Xk/tk} where
=
4. C o n d i t i o n s t o s u p p o r t a p r o o f , a d i s p r o o f or f a i l u r e
In this section, we present conditions for the transformation tree generated by the
equiformalization algorithm to support a proof or a disproof, or to suggest t h a t some
transformation applied is inappropriate. Justification for them is described in the next
section. Some terminology referred in the conditions is defined afterwards.
C o n d i t i o n 4.1 ( c o n d i t i o n t o s u p p o r t a p r o o f )
(1) The leaves are a11 empty and are not marked fa/se.
(2) Any elementary directed closed path in a dependence graph of a transformation
tree is a contraction path.
C o n d i t i o n 4.3 ( c o n d i t i o n t o s u g g e s t a f a i l u r e )
(I) Condition 4.I (1) holds, but not Condition 4.1 (2).
(2) Condition 4.2 (1) holds, but not Condition 4.2 (2).
In Tamaki and Sato's Unfold/fold transformation [13], which, in a sense, is included
in our approach, replacement of equivalent conjuncts is limited, so t h a t the replacer must
be "smaller" t h a n the replacee. In contrast~ in our approach, we do not place such a
condition on replacements, but on cuts (more precisely, when the cut forms a "loop"
with other branches). Clearly our restriction is weaker t h a n theirs. A similar approach
may be applied to fold/unfold transformations.
We prove the correctness of these conditions in the next section. T h e following are
definitions and theorems to be used in the proofs.
D e f i n i t i o n 4.4 If for a substitution O = {Xi/ti}~=l, Xi's do not a p p e a r in any ti's, a
constraint expression w(8) of 8 is: w(8) = X1 = tl, .• • , X n = tn.
D e f i n i t i o n 4.5 A substitution 0 is compatible with a first order formula II if[ M p
3(nO).
D e f i n i t i o n 4.6 A dependence graph of a transformation tree T is a directed graph
whose nodes and branches are those of T with a few more branches added, where,
(1) a direction of a branch originated in T is from a parent ~o a son.
(2) a new brazlch is added from a cut node to its reference node for any cut.
D e f i n i t i o n 4.7 An example o f an extended definite clause F ~- A is a substitution 8
such that
• All the universally quantified variables in the clause are instantiated to ground
terms by O, and AO is ground, and
• M e ~ AO
A counterexample is an example 8 but M e ~ B(F0).
(a) MR ~ AiO~r e- IIOe for some i, i.e., MR ~ 3(Ai0cr). Let a" be such that
A i O ~ " is ground and Mp ~ AiOerer". Then let ~r' be a union of ~ and or" but
deleting elements whose replaced variables are not in Ai0, A 2. Since e" does
not replace internal variables in F~ a r is a counterexample.
(b) MR ~= AiOa *-- IIOa for any i, i.e., MR V= (A1 V . . . V An ~- II)0~. In other
words 7/&r is a counterexample on a reference node.
(7) Let r] be a substitution which changes a clause on the reference node to the variant
used in the transformation. We have two cases:
(a) MR ~= (rio, 1"2 v r 3 ~- A)tr. Obviously ~ is a counterexample.
(b) MR ~ (ri0, F2 V I'a ~- A)cr, i.e., MR ~ 3(riO~). It is easily shown that
M p ~: 3(A0~) from MR I= (ri0, F2 V Fs ~- A)~r and conditions on & We have
Mp ~: (A ~ II)&r. In other words, ~0a is a counterexample on a reference
node.
(8) By the equivalence of A1 V...VAn and 1I, for some i MR ~ 3((AiO, A2)tr) Therefore
we can find a ground substitution ~r" such that MR ~ (AI8, A2)er~r" and o-" does
not replace any internal variables in r . Clearly ~r~r" is a counterexample on P ~--
Ai0, A2.
T h e o r e m 4.9 ( p r o p a g a t i o n o f a n e x a m p l e ) If there is an example on a node N
in a dependence graph, there is at least one successor node of N on which there is an
example.
The proof is similar to that of Theorem 4.8, and is easily derived.
D e f i n i t i o n 4.10 A directed closed path in a dependence graph is caI1ed a contraction
path if[:
(1) for any node in the path there exists a well-founded order (~-) among the examples
of the extended de/~nite clauses on the node, and
(2) for any example a on any node (whose clause is r ¢- A ) in the path and any
example or' on the node obtained as a result of propagations of a along the path,
( r ~- A)~ ~ ( r ~- A)~' (strict i , equality)
D e f i n i t i o n 4.11 When a welI-founded order stated in Definition 4.10 is de~ned, we
accordingly define a well-founded order among examples such that:
ig
5. J u s t i f i c a t i o n o f t h e A l g o r i t h m a n d t h e C o n d i t i o n s
In this section we show justification of the basic algorithm and the conditions, that is,
if the proof-condition is satisfied then the target clause is modeled by MR, and if the
disproof-condition is satisfied then it is not.
T h e o r e m 5.1 Let N be a node and N 1 , . . . ,N~ be N ' s sons in a transformation tree.
(1) If a transformation applied to N is marked equivalence-preserved, then
M e ~ N iff M e ~ N 1 , . . . , and MR ~ N ,
(2) If it is not marked equivalence-preserved and is neither cu~-right nor cut-left, then
M p [= N if M p ~ N 1 , " ' , and M p ~ Nn
The proof is straightforward.
6. D i s c u s s i o n
Among interesting topics which we have not discussed in this paper are:
(1) how to reduce the degree of non-determinism occurring in the algorithm
(2) the relation between the Mgorithm we proposed and the inductiouless-induction
method adopting the Knuth-Bendix completion algorithm.
(3) what procedures are to be added to augment capability of the algorithm
Concerning the first item, we are currently investigating two ways. One is to
introduce an order between conjuncts, and allow on a transformation tree only clauses
reduced according to this order. The other is to implement a strategy to find the most
appropriate action to take, which, observing that unless cut or replacement is used non-
trivial simplification or delete can not be applied, incorporates a way to find appropriate
unfold sequences and appropriate lemma.
For the second item, we have three things worth mentioning.
• To simulate the Knuth-Bendix algorithm, we have to:
(i) add some procedures to imdtate the whole capability of superpositions
(ii) modify procedures to use a simplification order
(iii) make some modifications to utilize the functionality of the predicates
• Even without those modifications, the proposed algorithm has capabilities almost
matching the Knuth-Bendix algorithm. Note that "delete" procedure is a powerful
tool, which has no counterpart in the Knuth-Bendix algorithm.
• The proposed method is advantageous on the following points
(i) it proves "implication"
(ii) it knows which clauses must be proved, and which clauses are just prospective
lemma that do not need to be proved.
(iii) it does not rely on a structure-induced order of terms. In the Knuth-Bendix
algorithm it is almost always necessary to make the equality relation directed.
For the last item, we are studying two approaches: procedures to utilize nice prop-
erties of system predicates; and restrictions on transformations (1), (3) and (10), so that
equivalence can be proved by one root node.
7. A c k n o w l e d g e m e n t
We would like to express our thanks to Mr. Yutaka Takuma, general manager of Naka
Works, Hitachi Ltd.; to Dr. Eiichi Maruyama, general manager of the Advanced lZe-
search Laboratory, Hitachi Ltd.; and to Mr. Masahiro Mori, manager of the System and
Software Design Department of Naka Works, Hitachi Ltd. for their giving us the chance
to conduct this research. We also thank Mrs. Mariko Sakurai for her encouragement
and fine typing.
References
[1] Apt, K.R. and van Emden, M.H.: Contribution to the theory of logic programming,
J. A C M 29 (1982) 841-862
[2] Boyer, R.S. and Moore, J.S.: Pro-ring Theorems About LISP Functions, J. ACIVI
22 (1975) 129-144
[3] van Emden, M.tt. and Kowalski, R.A.: The semantics of predicate logic as a pro-
gramming language, J. A C M 23 (1976) 733-742
22
[4] Hsiang, J.: Refutational Theorem Proving using Term-Rewriting System, Ar~it~ciM
Intelligence 25 (1985) 255-300
[5] Hsiang, J. and Srivas, M.: Automatic Inductive Theorem Proving using Prolog,
Theoretical Computer Science 54 (1987) 3-28
[6] IIuet, G. and IIullot, J-M.: Proofs by Induction in Equational Theories with Con-
structors, Comput. Syst. Sci. 25 (1982) 239-266
[7] Kanamori, T. and Fujita, If.: Formulation of induction formulas in verification of
Prolog programs, ICOT TechnicaI Report TR-094 (1984)
[8] Kapur, D. and Musser, D.R.: Proof by Consistency, Artit~ciM Intelligence 31 (1987)
125-157
[9] Lassez, J.-L. and Maher, M.J.: Closures and fairness in the semantics of program-
ruing logic, Theoretical Computer Science 29 (1984) 167-184
[10] Lloyd, J.W.: Foundations of Logic Programming, Spfinger-Verlag (1984)
[11] Paul, E.: On solving the Equality Problem in Theories Defined by Horn Clauses,
Theoretical Computer Science 44 (1986) 127-153
[12] Sakurai, A. and Motoda, It.: Inductionless Induction Method in Prolog, Proc. 4th
Conference Proceedings of Japan Society of Software Science and Technology (1987)
231-234
[13] Tamald, If. and Sato, T.: Unfold/fold transformation of logic programs, Proc. 2nd
International Logic Programming Conference (1984) 127-138
A p p e n d i x A. E x a m p l e s
In this section some examples of apphcation of the proposed algorithm are presented.
The program under consideration is as follows.
Note that in definite clauses on transformation trees, the variables appearing on
both sides are considered universally quantified~ and those appearing on only one side
are considered existentially quantified.
~ev([],[]). (pl)
rev([AlX], Z) +- rev( X, Y), fins(A, Y, Z). (p2)
Iins(A, [], [A]). (p3)
lins(g, [BIY], [BIZ]) +- lins(A, Y, Z). (p4)
mere(A, [A[X]). (pS)
mere(A, [BtX]) +- mere(A, X ). (p6)
p~m([], []). (pT)
perm([AIX], Z) ~- perm( X, Y), ins(A, V, Z ). (p8)
ins(A, X, [AIX]). (p9)
in4A, [BIY], [BIZ]) ~- ins(A, Y, g). (plO)
A.1 R e v - r e v P r o b l e m
The first example is the "rev-rev" problem [2] stated in Prolog [7]. The problem is to
show the validity of rev(Z, X) +- rev(X, Z). The stem of a complete tree resulted in a
proof tree is created as follows.
23
We now show the second formalization of the problem. In the following, a predicate
list(X) is defined by list([]), list([AlX]) ~- list(X).
rev(X, Y), rev(Y, X) ~- list(X). (tl)
J~ unfold-right,
rev([AiX], Y), rev(Y, [AIX]) ~ list(X). (t2)
unfold-left.
rev(X, Y'), lins(A, Y', Y), rev(Y, [AIX]) ~- list(X). (t3)
cut-right with (tl)
rev(X,Y'),lins(A,Y',Y),rev(Y,[AIX]) ~-- rev(X,V),rev(V,X). (t4)
Y~ ~ U and delete
Iins(A, U, Y), rev(Y, [AIX]) e-- rev(V, X). (t5)
J~ unfold-right, cases for (pl) omitted
fins(A, [B[U], Y), rev(r, [AIX]) ~- rev(V, Y), Iins(B, V, X). (t6)
J~ unfold-left.
Iins(A, U, Y), rev([BlY], [AIX]) ~ rev(U, V), fins(B, V, X). (iT)
unfold-left.
lins(A,U,Y),rev(Y, W),tins(B, W,[A]X]) e- rev(U, Y),tins(B, V,X). (t8)
unfold-left and v-delete.
fins(A, U, Y), rev(Y, [AIW]),fins(B, W, X) ~- rev(V, Y), fins(B, V, X). (t9)
cut-right with (tS),
Iins( A, U, Y), rev(Y, [AIW]) , fins(B, W, X)
lins(A, U, Y'), rev(Y', [AIV]), fins(B, V, X). (tl0)
[]
A.2 L a s t - i s - a - m e m b e r P r o b l e m
The "last-is-a-member" is an example of a problem where we have to use many heuristics
for without knowing the proposed algorithm [7]. The problem is to show the validity of
VA, X, Z mem(A, X) ~- rev(X, [A]Z]).
One transformation tree is:
mere(A, X) ~- rev( X, [AIZ]). (ml)
J~ unfold-right.
mem(A, [BIX]) e-- rev(X, U), lins(B, U, [AIZ]). (m2)
,~, unfold-right, cases for (p3) omitted
mere(A, [B IX]) e-- rev( X, [AIU]), lins( B , U, Z ). (m3)
J~ unfold-left.
mere(A, X) ~ rev(X, [AIU]), fins(B, U, Z). (m4)
cut-left with (ml).
rev( X, [AIZ']) ~-- rev( X, [AIUI), lin~( B, u, z). (mS)
J~ Z ' ~ U .
[]
25
A.3 P e r m - p e r m Problem
Show that if a list Z is a permutation of a permutation of a list X, then Z is a per-
mutation of X. The problem seems very trivial if we understand the abstract meaning
of 'permutation', but if we refer only to the formal definition of the predicate "perm",
then it is quite complicated. Readers who have the opposite opinion are challenged to
solve it without using the proposed algorithm.
Readers may be interested in what is happening in side branches. One branch stemmed
from ( p m l l ) is as follows.
ins(B, [CIY], V), ins(A, V, Z) ~ ins(A, IT,W), ins(B, [CIW], Z). (pmll)
unfold-right, cases only for (p9)
ins(B, [CIY], V), ins(A, V, [B, ClW]) ~- ins(A, Y, W). (pm12')
unfold-left and V-delete,
ins(B, [ClY], [Big]), ins(A, V, [ClW]) ~- ins(A, Y, W). (pro13')
,~ unfold-left and V-delete.
ins(B, [CtY], [B, CIV]), ins(A, V, W) ~ ins(A, Y, W). (pro14 ~)
~L unfold-left and V-delete.
ins(A, IT,W) +-- ins(A, Y, W). (pro15')
[]
A p p e n d i x B. I n e q u a l i t y
This example is intended to show some key ideas of the proposed algorithm. In this
example, an inequality is proved using an algorithm based on the same principle as ours
for Prolog. Similar applications may be found in other fields.
Suppose you know only three things: arithmetic of non-negative integers, inequality
relations between integers, and the fact that you may deduce an identical term from
both sides of an inequality.
How do you prove (n + 1) 2 > 4n when n > 1?
1+2>4
"'--"
_
i'.'I
14 + 2 >41
±
Pseudo Extension in Default Reasoning
and
Abstract
This paper is concerned with extension and belief revision in l~eiter's default reasoning.
First we introduce a new notion of pseudo extension which is successively constructed from a
given default theory. We show that the set of pseudo extensions contains the set of extensions,
so that we can get some reasonable candidates of extension in a constructive way. This should
be a first step towards computerization of the default reasoning. We also discuss the belief
revision problem from the viewpoint of Shapiro's inductive inference of models.
1. Introduction
Reasoning we use in our daily problem solving is not always from complete information unlike mathemat-
ical reasoning. One of the main goals of artificiM intelligence research is to computerize our reasoning.
Hence much attention has been paid to such reasoning and formulations have been proposed by many
authors, l{eiter~s default reasoning is one such formulation. He used the notion of default and formulated
incomplete knowledge about a world as a pair : a set of true but incomplete knowledge and a set of
special inference rules called defaults. He enlarged the incomplete knowledge to describe the world as
completely as possible. The enlarged knowledge is ca~ed an extension, which is the set of knowledge
that seems true as a result of reasoning from incomplete knowledge and is a possible world at that time.
Thus the extension is not definite knowledge but just a belief about the world, and hence it needs to be
modified when new facts are found.
In the Reiter's default theory we can reason from incomplete knowledge in a very natural way.
However, the extension can not successively be constructed, because it is defined by using itself in
applying the defaults.
In the present paper, we first try to solve this difficulty. We define a successively constructable set
of knowledge, which we call a pseudo extension, and discuss the relationship between Reiter's extensions
and ours. We also show that our extension is a natural generalization of l~eiter's.
Unlike the reasoning in classical logic, the reasoning from incomplete knowledge is necessarily non-
monotonic. Hence we sometimes must modify the belief, i.e. the knowledge derived by such reasoning.
In the present p a p e r we take this problem of belief revision as that of extension modification. Then we
can see that the process of belief revision is very similar to Shapiro's model inference. We also discuss
We start with recalling the definitions and important results on default reasoning according to [1, 2].
if it is consistent to assume ~(x),... ,tim(X) we may infer a ( z ) ~ w(x). Note that "it is consistent to
assume t i ( x ) " means t h a t there is not sufficient information to conclude -~fli(z). T h e prerequisite a(z)
may possibly be empty, that is,
is also a default to mean that if it is consistent to assume ~ ( x ) , . . . , t , ~ ( x ) then w(x) can be concluded.
If a ( x ) , t l ( X ) , . . . , tim(Z), w(x) have no free variables, the rule is called a closed default and denoted
a : Mfll,o.-,Mflm
O3
a ( x ) : Mti(z)
ti(~)
is called a normal default.
Now let D be a set of defaults, and W be a set of closed wffs. Then A = (D, W ) is called a default
theory. A default theory A is closed if every default in D is closed, and A is normal if every default in
D is normal.
For a set D of default rules, we define Cons(D) by
For a set S of closed wffs and a closed wffw, we write S ~- ,, to denote that w is derived from S, and
S ~/w to denote that w is not derived from S. We also define a set Th(S) by
Let A _-- (D,I4/) be a closed default theory, S C L be a set of closed wffs, and r ( S ) be the smallest
set satisfying the following three properties:
(1) W C r(s).
(2) T h ( r ( s ) ) = r ( s ) .
(3) If (~ : Mill, ... ,Mflm E D, a e F(S), -~j31. . . . . -"tim f[ S then w e r ( s ) .
02
A set E C L satisfying r(E) = E is an extension of A. An intuitive characterization of the extensions is
given by the following theorem :
E= UEi.
i=0
The expression of Ei+l in Theorem 1 is slightly different from the original one. Reiter [1] used
expressions are essentially the same. In order to check a E E1,-~fll,... ,~flm C E, we need to check
whether they are derivable or not. So we have adopted our expression, which should be more intuitive.
For a closed default theory there may exist two or more extensions or none at all. The existence of
many extensions means the possibility of many worlds at that time. Selecting a correct extension and
constructing an extension are different things. The correctness will gradually become clear as new facts
about the world are known. We say that a dosed default theory has an inconsistent extension if one of
its extensions is the set of all closed wffs of L.
C o r o l l a r y 2 (Reiter [1]) A closed default theory (D, W) has an inconsistent extension if and only
if W is inconsistent.
C o r o l l a r y 3 (Reiter [1]) If a closed default theory A has an inconsistent extension then it is only
the extension of A.
Since a closed default theory with an inconsistent W has only inconsistent extensions, hereafter we
restrict our discussions to default theories with consistent W's, unless otherwise stated. Default theory
may not have extensions, but we know the tbHowing :
30
T h e o r e m 4 (Reiter [1]) Every closed normal default theory has at least one extension.
In defining extension E, l{eiter used E itself (Theorem 1). Hence it is a self-recursive definition. We can
use Theorem 1 just to confirm for a given set of closed wffs to be an extension, but can not use it to
default theory.
Definition Let & = (D,W) be a closed default theory and let Fi (i >_ 0) be sets of closed wffs
defined as follows:
F0=W
F~ V-~I~,..., t~ V -~flm
such that DFi • 0 if the above set is not empty. Then we call
F=OFi
i=O
can use an appropriate subset of defaults instead of the whole. A relation between Reiter's extension and
Theorem 5 Let E be the set of all extensions of a closed default theory A, and let ~# be the set of
Proof Let E = U~=I El be any extension, and Di be the set of defaults used in defining Ei. Then
we have
El = Th(Ei-1) U Cons(Di).
For a default
= O~ : M ~ I , . l. , M~e-~ E Di,
31
we easily have
Ei~ a
Z V-~£,-.-,E V ~ m .
By putting
D~ = {~ t~ e Di, Cons(~) ¢ FI-1},
Po= W
Fi = Th(Fi-1) U Con~(D~)
i=0 i=1
Now let us show that D~ satisfies the condition of DFI in the definition of pseudo extensions. First
assume t h a t for some j and for any k(:> j ) a default satisfies the condition but D~ = 0. T h a t is, assume
that the set
ED, w~t~ stuk= 1 k)
= a : Mfll,...,M!m Fi F- a
Hence we have
E j = Ej+I = Ej+~ . . . .
= a : M/3z,..., Mflm
ED,
which satisfies
j--1 Dk)
w ~ Cons(Uk=l !
Fj ¥ -,!1,..., Fi V -,t,~.
By Ej = Fj, obviously
Ej~-a
Ej V-~11,..., Ej V ~im.
32
Also by
¢~ oo
Since E = ~ 0 E~, there exists an i such that E~ b ~Sk- This i must be i > j , because E~ ~ ~Sk for
which contradicts
Therefore D~ satisfies the condition of D/q, and hence F = (J~0 F~ is a pseudo extension. Thus we have
E = U E~ = Fi=FE/~.
i=O i=O
H e n c e E C _ F . []
Theorem 6 In a closed normal default theory, any pseudo extension which is not an extension is
inconsistent.
Proof Let F be a set of closed wits such that F E f" and F ~ E. Let D ~ be the set of defaults
which is used in constructing F~ of F - (J~=0 Fi. Then by the assumption there exist an i and a default
~= a:M8
8
8 E Fi+l C_F.
Remark Theorem 6 is not valid if the default theory is not normal. In fact, there exists a default
theory whose pseudo extension is neither an extension nor an inconsistent set. An example follows.
Let A = (D,W) be a default theory with
W=O.
Then F = Th({A, B, C}) is a pseudo extension of A, but neither an extension of A nor an inconsistent
set.
33
(1) Pseudo extensions can successively be constructed from a given default theory.
(3) In a closed normal default theory, every pseudo extension is an extension if it is not inconsistent.
(4) If W in A = (D, W) is inconsistent then A has a unique pseudo extension, which is inconsistent
and coincides with the extension. This result immediately follows from Corollaries 2, 3 and the definition.
4. E x t e n s i o n R e v i s i o n by M o d e l Inference
Default reasoning is non-monotonic in the sense that an increase in facts does not always mean an increase
in knowledge. Thus the extension is not a definite knowledge, but may need to be revised, because some
defaults used in constructing it become inapplicable when new facts are found. Reiter has defined the
belief as a subset of the extension and has discussed revising it. In this section we define the belief as the
whole set of extensions, and the belief revision as constructing an extension as similar as possible to the
world to be described by the default theory. Thus we identify belief revision with extension revision. Let
us consider the world for the theory to describe as an unknown mode] in a first order language. Then
we can formalize the problem of extension revision in the framework of Shapiro's model inference [3, 4].
Hereafter we assume readers are familiar with the model inference. Our problem can be expressed as
follows:
a hypothesis language Lh = L, and an oracle for an h-easy unknown model K which satisfies
the closed default theory A = (D, W), to find a finite Lo-complete axiomatization of K.
We say that the model K satisfies a closed default theory A = (D, W) if it satisfies the following
three conditions:
(1) K k W
which means K satisfies W.
(2) For a default
a : M i l l , . . . , M~.~
~d
ED
(3) Let D' be a subset of D such that I~VU Cons(D ~) is consistent. Then
The condition above restricts the unknown model K in Shapiro's model inference.
A closed default theory ~ = ( D , W ) with finite D and W is called a finite closed default theory. For
Proof It suffices to show E ~ T and T ]= L~ for some finite subset T of L. By Theorem 1 any
Let Di (i >_ 1) be the set of defaults which are used in defining El. Then Di _ D and
Eo= W
Since D is finite, there exists an N such that D= = Dn-1 for any n > N. Hence we have
and
E = ~J Ei = E N .
i=o
We also have
EIv = Th(Eiv-1)
= Th(Th(EN_2)UCons(DN-1))
= T h ( T h ( W ) u U~=I
N-1 Con~(O~))
= T ~ ( w u U ~ ' Con~(DO).
Then
N-1
T = WU U Cons(Di)
i=l
is finite because so are W , D , and obviously E I= T and T t- L E. Therefore there exists a finite Lo-
complete azdomatization of E. D
Theorem 8 Let K be an h-easy unknown model which satisfies a finite closed default theory
A = (D~ W). If Shapiro's enumerative model inference algorithm identifies K in the limit and produces
a guess T as the output, then Th(T) is an extension of a default theory A' = (D, W U W'), where W ~ is
a set of clauses.
35
Proof Put
when a fact < a~,V} >, a pair of ground atom and its t r u t h value, is given as input to the algorithm.
In order to show that Th(T) is an extension of A ' = ( D , W U W'), it suffices to show Th(T) =
F(Th(T)). From the definition of W ' and K ~ W, obviously T F W U W'. Hence we have
W U W ' C_Th(T)
Th(Th(T)) = Th(T).
Since K satisfies A, there exists a default
5= a:Mfll'""Mflm ED
r(Th(T)) C__Th(T).
We now show the converse. Let v E Th(T). There are four cases to be considered.
Case I. v e W U W ' : v E r(Th(T)) by W u W ' c_ F(Th(T)).
Case 2. A default
5= a:Mfll,...,M/3,~ ED
v
Th(T) ~ a
Th(T) C_F(Th(T)).
Hence F(Th(T)) F a and v E I?(Th(T)).
Case 3. W U W ' U Cons(D") F v for the set D" of all defaults
5- ~ : Mfll''"'M3m .E D
~d
c Th(F(Th(T)))
= F(Th(T)).
36
Case 4. v E Th(T) satisfies none of (1), (2), ( 3 ) : If v is not a ground unit then K ~ v since K
satisfies A. This contradicts that Lo has an evidence to show the falsity of T. If v is a ground unit then
obviously
v e W ' C_ r ( T h ( T ) ) , o
Theorem 7 asserts that an Lo-complete axiomatization exists for any extension of finite closed default
theory. Hence the extension appeaxs in the enumeration Th(T1),Th(T2) . . . . . where T1,T~,... is the
enumeration of at] subsets of Lb. On the other hand Theorem 8 asserts that if we restrict the objects
of the inference to the unknown models which are h-easy and satisfy finite closed default theories, then
the models identified by the enumerative model inference algorithm axe extensions of some closed default
theories. The A t in Theorem 8 is finite~ and hence it has at most finite number of extensions. Therefore
if for a finite closed default theory there exist two or more extensions in which the unknown model K
is included, the algorithm will find it in the search space of all extensions. Moreover if all the pseudo
extensions of a finite closed default theory can be enumerated, the algorithm will find an extension for
the unknown model by deleting guesses which are pseudo extensions but not extensions or contradict
5. Discussions
There are some problems in Reiter's default theories. The extensions can not be constructed successively
and even their existence is not guaranteed with exception of the closed normal cases. Many efforts to
attack the problems have been made by many researchers, l~eiter and Criscuolo [5] have introduced
seminormal defaults. The seminormal default theories can describe some natural examples which the
normal default theories can not, but still the existence of extensions is not guaranteed. Lukaszewicz
[6] has studied a default theory of propositional logic and introduced another definition of extensions,
for which the existence is guaranteed. Murakami et al. [7] have constructed a set of knowledge called
a modified extensions, which is, in a sense, a generalization of IZeiter's extension, and guaranteed the
existence. [6, 7] have thus guaranteed the existence for any default theory, but still their extensions can
not be constructed successively from W. Murakami et al. [8] have dealt with this problem independently.
The)" have defined sets of knowledge called a nonrecursive extensions for closed normal default theories.
The extensions should be candidates for possible worlds. In this regard, our approach is better than the
others.
We have introduced the notion of pseudo extensions which can be constructed successively and made
a step towards the computerization of default reasoning. However, it is still not computable, because
the condition Ei ~/ "~1,..- ,El ~ ~m for applying defaults is not even semi-computable. This aspect is
common to all other approaches. To solve the problem we need some concept like the h-easiness.
References
[1] Reiter, R. : A Logic for Default Reaso~dng, Artificial Intelligence, 13, 41-72 (1980).
[2] Shinmura, T. : On the Inconsistency in Non-monotonic Logic, Master's Thesis, Dept. of Information
Systems, Kyushu Univ. (1986) (in Japanese).
[3] Shapiro, E.Y. : Inductive Inference of Theories From Facts, TR-192, Dept. Compt. Sci., Yale Univ.
(1981).
[4] Ishizaka, tI. : Model Inference Incorporating Least Generalization, Master's Thesis, Dept. Informa-
tion Systems, Kyushu Univ. (1986) (in Japanese). To appear in J. In/. Processing Soc. Japan.
[5] Reiter, R., Criscuolo, G. : On Interanting Defaults, Proc. 8th IJCAI~ 270-276 (1983).
[6] Lukaszewicz, W. : Considerations on Default Logic, Proc. AAAI Non-monotonic Reasoning Work-
shop, 165-193 (1984).
[7] Murakami, K., Aibara, T., Shitanda, H. : Modified Extension and Its Properties in Default l~eason-
ing, Trans. Inf. Processing Soc. Japan, 12, 1280-1287 (1987) (in Japanese).
[8] Murakami, K. Aibara, T., Shitanda, it, : Nonrecursive Extension and Its Properties in Default
Reasoning, J. Japanese Soc. Artificial. Intelligence, 3~ 359-367 (1988) (in Japanese).
[9] Yuasa~ It.: Pseudo Extensions in Default l~easoning and Belief t~evision Using Model Inference,
Master's Thesis, Dept. Information Systems, Kyushu Univ. (1988) (in Japanese).
An Approach to Nonmonotonic Inference Mechanism in
Production System KORE/IE
Toramatsu Shintani
IIAS-SIS FUJITSU LIMITED,
140 Miyamoto, Numazu-shi, Shizuoka 410-03, Japan
E-mail: tora%[email protected]
Abstract
1. Introduction
~ L~Confllctresolution,1
"ie_debug". The end of keeping the back data is specified by the command
"ie no debug". These commands are used for avoiding needless recording of
back data and for improving the efficiency of the inferences. The back data
are only needed for debugging a rule base and e n a b l i n g n o n m o n o t o n i c
inference.
ie debug
Inference step.~
Step 3 l---: - -~ back(2) t
Step 4
......~..~... • Undoing
Step 5 m
...... ,'"'L'""
" ie_no_debug
step 1
(~ ~step
~step 3
Inference chainq"-'~?step n
Fig.3. Recording inference chains by KORE/EDEN
1
Firing the rule exl
~ rule ex2
Fig.4. An
Inference chains
example of inference chains
default B
Inferenc s t e p s ontradicti-~n ~ x ~ _ j /
Fig.5. Using the flags in back data
which includes the default A, the flags of the back data which depend on the
default are changed to "contradiction". The backtracking is realized by using
the back command in KORE/IE. These back data are used for undoing the
backtracking when the contradiction is not resolved by the assertion. By
asserting the negation, when new inference steps are done, the flags of the
newly recorded back data are set to "unreal". The flag "unreal" used for
indicating temporary back data. If the negation causes a new contradiction,
the system checks the rest of the default knowledge (such as the default B) by
undoing the inference steps which depend on the negation. The back data
with the flag "unreal" are used for undoing the inference steps. If the
negation does not cause a new contradiction, resolving the contradiction is
achieved by removing the back data with the flag "contradiction" and
changing the flag "unreal" of the back data to the flag "real".
The elements of the list L are arranged in the order of decreasing time. The
time can be determined by using the time tags. The list L consists of nodes
which can be obtained by using the "assumption_supers" command mentioned
in Section 3.1.
Step 2: If the tist L ~sempty then stop the procedure and
the procedure fails; otherwise go to Step 3.
The procedure fails in the same manner as TMS when a contradiction needs to
be resolved by negating two or more assumptions together, since it only looks
for one at a time. If the procedure fails, the system helps us to resolve the
contradiction by showing the all default knowledge and inference chains
checked by the system. Then, for resolving the contradiction, we need to undo
and redo some inference steps by revising some default knowledge or some
rules.
Step 3: Get a defauit knowledge from the list L, which is
the first element (that is, Lhead) of the list L (that is,
L = [LheadlLtail] ), and backtrack to the inference step which
includes the default knowledge by using the back
command. Then, assert a negation of the default
knowledge. Go to Step 4.
When default knowledge was used multiple times, the procedure backtrack to
the step which includes the earliest default knowledge. As mentioned in
Section 2.2, the negation can be generated by modifying the value of the
"not_contradicted" slot to "nil" in the pattern (i.e. WM element) which
represents the default knowledge. This modification can be achieved by using
the "modify" command in KORE/tE.
Step 4: If a new contradiction is detected, then undo the
result of Step 3, let L = Ltail , and go to Step 2; otherwise
go to Step 5.
In order to undo the result, the procedure removes the back data which have
the "unreal" flags, and return the current state to the previous sate in which
Step 3 is not yet applied by using the back data which have the
"contradiction" flags.
Step 5: Change the "unreal" flags to the "real" flags, stop
the procedure, and the procedure succeeds.
In the procedure, removing the back data and changing the flag of the
back data are simply realized by using built-in Prolog predicates such as
"assert" and "retract" in which backtracking mechanism of Prolog can be
utilized effectively.
3.4. Other d e t a i l s
4. An application
run
!comparison1 I
Undoingin£erences
comparison2J
comparison1
[comparison2 change_weight]
t cOmparisOn-checkl
consis---teney contradiction
of a rule. The rule "start" is used for initializing pairwise comparisons and
does the "ie_debug" command described in Section 2.1. The rules
"comparison1" and "comparison2" are used for obtaining a pairwise
comparison matrix. By the rule "comparisonl", weighting numbers are
entered and grouped into the matrix. The rule "comparison2" determines and
enters their reciprocal values into the matrix. The rule "comparison_check"
checks whether the matrix is filled or not. The rule "check" is used for
computing the C.I. of the matrix. The rule "consistency" is used for achieving
the procedure "contradiction" if the C.I. is not less than 0.i. The rule can be
described as follows:
consistency: if matrix(ci > 0.1)then contradiction.
The rule "change_weight" is used for revising the inadequate pairwise
comparison, which can be described as follows;
change_weight:
if \matrix_element(name = X,column = C,row = R,weight = W)
then
remove(I) &
new_weight(W,W2) &
make(matrixelement(name = X,column = C,row = R,weight = W2).
where the LHS pattern corresponds to the negation of the inadequate
comparison which needs to be revised. The negation is generated by the
procedure "contradiction" if the procedure finds the inadequate comparison as
a default knowledge. By firing the rule "change_weight", the inadequate
5J
5. Conclusions
Acknowledgment
References
Chiaki S a k a m a a n d A k / r a Okumura
Abstract
1 Background
W = {WElephant(x) D Cra~,(x),
YzA frieanEIephant(x) D Elephant(x),
A f ricanEl ephant( clyde) }
In this case, Gray(clyde) is deducible from W. That is, inheritance is realized by the repeated
application of modus ponens.
However, when there are exceptions in the hierarchy, the case becomes somewhat more
complicated. Consider the following hierarchy.
Elephants are normally gray.
Royal elephants are elephants, but are not gray.
Clyde is a royal elephant.
This hierarchy can be represented by a set of first order formulae as follows.
W = {VxRoyalElephant(x) D Elephant(x),
54
Suppose we add the fact, Elephant(taro), to W. When taro is not a royal elephant, the fact,
-~RoyaIElephant(taro), also has to be represented explicitly in W to deduce Gray(taro). Thus,
to represent such an inheritance hierarchy in first order formulae, all the negative information
has to be represented explicitly.
[ER83,Eth87a] represented such an inheritance hierarchy by l~eiter's default logic [l~eiS0].
For example, the above hierarchy is represented as:
W = {Vxl~oyalElephant(x) D Elephant(x),
RoyaI E l ephant( elyde ) }
D is a set of defaults and read as: "when Elephant(z) holds, and Gray(x)A -~RoyaIElephant(x)
is consistent with this, then infer Gray(x)." As a result, Elephant(clyde) is deduced from W,
but RoyaIElephant(clyde) in W blocks the derivation of Gray(clyde) from the default D.
Besides, when Elephant(taro) is added to W and taro is not a royal elephant, Gray(taro) can
be deduced from D without -~RoyalEIephant(taro). Such an inheritance hierarchy is called a
nonmonotonic inheritance hierarchy, and it enables us to treat exceptions implicitly.
This formulation, however, seems to have some drawbacks since it requires as many in-
heritance rules as exceptions in a hierarchy. Moreover, update of such a hierarchy requires
modification of all the affected default rules as we~ as the corresponding first order state-
ments. It will become increasingly complex as the network grows, and does not make the most
of default reasoning:
The following sections present the formalization of nonmonotonic inheritance reasoning by
default logic in a different manner from Etherington, and also give a parallel algorithm based
on this approach.
2 T h e o r y of N o n m o n o t o n i c I n h e r i t a n c e R e a s o n i n g
1. IS._A(x, y): an acyclic relation between an individual x and a class y, or a subclass x and
a supercla~s y; that is, IS_A(x, y) i f f x E y, or x C_y.
2. Property(x, y) (resp. -~Property(x, y)): a class or an individual x has (resp. has not) a
property y.
D
= {IS_A(x,y)^ Property(y, ): Property( ,z)
Property(x, z)
I S-A(x, y) A -~Property(y, z ) : ~Property(x, z) } []
-~Property( x, z)
W = {IS.A(cephalopod, mollusc),
I S-A( nautil us, cephalopod),
IS_A(fred, nautilus),
Property(mollusc, has_shell),
-~P r opert y( cephaI opod, has_shell),
Property(nautilus, has_shell)}
W = {VxCephalopod(x) D Mollusc(x),
VxNautilus(x) D Cephalopod(x),
Vxgautilus(x) D Shellbearer(x),
Nautilus(fred))
modify defaults.
Such a system, which consists of a set of classes and a set of inheritable properties associated
with each class, is called a class/property inheritance system [Tou86]. Our approach defines
exceptions as nonmonotonic properties of classes, while IS_A hierarchy defines a monotonic
relation between classes. In the IS_A hierarchy, transitivity is not assumed since it generates a
redundant link. For example, IS_A(fred, cephalopod) is deduced using transitivity in Example
2.1, then it leads to an extension which contains -~Property(fred, has_shell), which is an un-
desired result. To derive a transitive class-subclass relation, it is necesarry to add, for example,
Property(nautilus, upper(cephalopod)) to W, to derive Property(fred, upper(cephalopod)).
A is called a normal default theory and has at least one consistent extension for every
consistent W [Rei80]. Nonmonotonic inheritance networks are classified by the number of
their extensions.
Definition 2.2 A nonmonotonic inheritance network A is definite iff it has only one extension.
[]
Example 2.1 is a definite case. However, there is a network with multiple extensions which
are inconsistent with each other. Consider the notorious example of Nixon diamond. The
problem is: Nixon is both a Quaker and a Republican, and Quakers are typically pacifists,
while Republicans are typically not. Then, whether Ninon is a pacifist or not?
This hierarchy is represented in A with W:
W = {IS_A(nixon, quaker),
IS_A(nixon, republican),
Property(quaker, pacifist),
-~P r operty( r epubI ican, pacifist)}.
In this case, there exists the following two extensions which are inconsistent with each
other.
E1 = W u {Property( ixon,paci/ist)}
E2 = W U {-~Property(nixon, paci fist) )
Such a network which has more than one extension is called indefinite, and there axe two
attitudes for treating such an indefinite network [THT87]. A skeptical reasoner draws no
conclusion from ambiguous information, and hence offers no conclusion as to whether Nixon is
a pacifist or not. A credulous reasoner, on the other hand, tries to draw as many conclusions
as possible, and hence offers two alternatives: Nixon is a pacifist in one case, and is not in the
other.
From an algorithmic point of view, a skeptical reasoner always generates a unique extension,
then its algorithm seems to be simpler and more efficient than that of the credulous one, which
generates multiple possible extensions that grow exponentially as ambiguity increases. The
credulous attitude, on the other hand, seems to be more expressive than the skeptical attitude,
since the explicit representation of ambiguities suggests that there is some disagreement in the
network structure.
To take advantage of each attitude, an algorithm which can treat ambiguities but does
not generate multiple extensions is considered. The next section discusses such an inheritance
algorithm and its parallel execution.
Inheritance algorithms combined with parallelism have been studied over the past few
years. NETL [Fah79] is a pioneering semantic network system. In NETL, inheritance is
performed by parallel marker propagation over nodes in a network. However, as is pointed out
by [ER83,Eth87a], NETL does not treat nonmonotonic cases correctly.
58
[Tou86] has proposed some inheritance algorithms for a nonmonotonic inheritance system.
Those algorithms are based on the choice of inference paths in multiple inheritance and limited
parallelism is achieved. They offer a credulous inference system and also a skeptical version is
discussed in [HTT87]. These methods, however, require each derived path to contain its entire
derivation history and seem to become overloaded as the size of the network increases.
[EP~83,Eth87a] have shown a parallel algorithm based on their formalization and proved its
correctness, that is, all inferences lie within a single extension. However, this algorithm is not
complete in general; there might be some extensions which do not come out of the algorithm.
l~elated to this work, [Cot85] has shown a parallel connectionist axchitecture, but there is no
assurance of correctness.
The remainder of this section shows a r (parallel inheritance} algorithm for the nonmono-
tonic inheritance network presented in the previous section. First, notation in the algorithm
corresponding to A is given:
Here, 0 denotes an empty set and notation which begins with a capital letter denotes a set.
Now, the r algorithm is presented below.
The procedure r produces a set of inheritable properties for an input class downwards
from upper classes to their subclasses. Nonmonotonic inheritance is achieved through over-
riding higher properties by conflicting lower ones. When there is more than one upper class
at is.a(class, Uppers), each upper class calls the recursive rr procedure independently. This
process will be executed in paxat]eI on a massively parallel architecture, where each processor
will have cost proportional to the length of the inheritance path. The 7r algorithm is imple-
mented in the parallel logic programming language GHC (Guarded Horn Clauses) [Ued86],
60
The next proposition assures the soundness and completeness of the ~r procedure with
respect to a nonmonotonlc inheritance network A.
4 Discussion
[San86] has defined some basic structure types for inheritance networks and given sound
inference rules for these structures. According to his inheritance system, Clyde is not gray in
the above network. Whereas Touretzky's system [Tou86] yields two alternatives; Clyde is gray
in one case and is not in the other, and our system also returns gray and not(gray) for an
input class Clyde. This shows that the above network is interpreted as definite in Sandewall's
system, and indefinite in Touretzky's and ours. In this example, it seems to be more intuitive
61
royal chaplain ~ /
african marine
Clyde George
to infer that Clyde is not gray. However, as in shown in [THT87], there is a counter-example
which has the the same structure with (a), but the Sandewall's inference seems to be doubtful
(Figure (b)). In this case, whether George drinks beer or not is not dear and it depends on
the rate of beer drinking among marines°
These examples suggest that it is difficult to infer the intended meaning of the network
from its structure alone.
Acknowledgment
We would like to thank David W. Etherington for his comments for improving earlier drafts
of this paper. We are also grateful to the colleagues at ICOT for useful discussions and
comments.
References
[ER83] Etherington,D.W. and P~eiter,R.: "On Inheritance Hierarchies with Exceptions", AAAF83,
pp.104-108, 1983.
[Fah79] Fahlman,S.E.: "NETL: A System for Representing and Using Real-World Knowledge",
MIT Press, Cambridge, MA, 1979.
[Rei80] Keiter,R.: "A Logic for Default Reasoning", Artificial Intelligence 13, pp.81-132, 1980.
[San86] Sandewall,E.: "Nonmonotonic Inference Rules for Multiple Inheritance with Excep-
tions", Proc. of IEEE, vol.74, pp.1345-1353, 1986.
[Ued86] Ueda,K.: "Guarded Horn Clauses", Lecture Notes in Computer Sciences 221, Springer-
Verlag, Berlin, 1986.
Appendix A
Here, we show an implementation of the 7r algorithm in GHC. GHC is the parallel logic
programming language developed as the kernel language of fifth generation project at ICOT.
The syntax of a clause in GHC is in the following form:
H :-G1,G2,...,Gm I B1,B2, ...,B~.
where the part preceding '[' is called a guard, and the part succeeding it is called a body.
A clause with an empty guard is a goal clause. The declarative meaning of the clause is the
same as Prolog.
The execution of a GHC program proceeds by reducing a given goal clause to the empty
clause as follows.
(a) The guard of a clause cannot export any bindings to the caller of that clause.
(b) The body of a clause cannot export any bindings to the guard of that clause before
commitment.
(c) When there are several candidate clauses for invocation, the clause whose guard first
succeeds is selected for commitment.
63
Under these conditions, the execution of goal reduction is done in parallel. Now the proce-
dure is shown with an example of shellbearers.
This GHC program is easily translated into a Prolog program, which performs sequential
inheritance in a network.
Appendix B
First, some notation used in the proof is given. For an IS_A(x, y), the closure of x is defined
as a set, Upperk(x) (k >__0), as follows:
1. x 6 Uppero(x)
Note that the IS_A hierarchy is acyclic, then x ~/[Jk>l Upperk(x). Now we show the proof
of the proposition.
In case 3Ei, Property(ck-1, uprop) E Ei, -~Property(ck_l, uprop) ~_W holds, then
uprop ¢ RevCPropsk_l and uprop E Propsk - RevCProps~_l.
So, uprop e CPropsk-1 U (Tempk_l - RevCPropsk-1).
In ease 3Ej, "~Property(ek_l, uprop) e Ej, Property(ca_l, uprop) • W holds, then
not(uprop) ~. RevCPropsk-1 and not(uprop) e Propsk -- RevC Propsk_l.
So, not(uprop) E CPropsk-1 U (Tempk-1 - RevCProp$k-1).
Hence uprop 6 Propsk-1, or not(uprop) 6 Propsk-1 holds, where r(ek-1, Propsk-1).
Therefore,
Propsk-1 ~_ {prop i 3El, Property(c~_l,prop) 6 Ei}
U{not(prop) ] 3Ej,-~Property(ek_l,prop) e Ei} (t).
§1 Introduction
Prolog is a popular language for programming prototypes
of parallel language interpreters and natural language
processors, and for knowledge representation. But it is
said that it is difficult to show Prolog's execution flow
explicitly, so one cannot understand another's programs. To
reduce the programmer's load, many Prolog debugging systems
have been proposed and used. They are classified into two
groups.
Programmer oriented
Using debugger's facilities to detect bugs by programmer.
[Byrd78][Numao85]
System oriented
Debugging system asks programmer about a test program,
analyses that information and detects bugs.
[Shapiro83][Pereira,L~M 86][Lloyd87][Maechi87]
[Takahasi86]
If there were a program-specification that did not put
additional load on programmer and did not let down the
Prolog's abilities, it would be very useful and make Prolog
more powerful. In this paper, a control specification is
proposed, that is based on the Control Flow Model [Byrd78],
very familier to Prolog users as the Box Model. This
control specification can represent the programmer's
intention of how the program is to perform.
We p r o p o s e the Deterministic Trimming Method, which uses
control specification information based on Shapiro's
Algorithmic Program Debugging [Shapiro83].
§2 Control Specification
If there are specifications of each goal's mode
declarations, argument types and determinaney, it is easy
to debug and maintain a program. Even a beginner will
understand the program's meaning easily.
There is not a general Prolog program specification
notation, even if there were a new one proposed, it
probably would be difficult to get aquainted with, and
68
Fig 2.2
O Goal @ succeeds deterministically does not allow back-
tracking (deep backtrack).
O Goal ~ finitely fails.
O Goal @ always succeeds. If there is backtracking after
the goal's success, there must be alternative solutions
of the goal. There is never the ease of no solution of the
goal.
O Goal @ permits both success of failure. If the goal
succeeds the goal does not allow backtracking (deep
backtracking).
Examples of control specifications for some built-in
predicates is shown in figure 2.3.
F A I L ~
CALE--t~XIT CALKS---" 1 CALL i 'r "i--~EXIT
i~ ~EDO FAIL ~--i, REDO
NN-
Fig 2.4
Example of actual simple control specifications are fig
2.5 and fig 2.6. There are four types of 'append' usages,
type I being most common. The control specification in fig
2.5 allows type I, H and m but not type IV. I n f i g 2.6, all
types are allowed. In this way, control specification sets
constraints on goals, therefore reducing bugs. If a
programmer wants 'append' to be used as type I and IV,
control specification must use type IV.
append( [ HIT ],L,[ H]Z ] ):- append( T,L,Z ).
append( [],L,L ).
Itripp]ei:--->lgenerate"/~[!~L~
[generatel:-'->l n ~ ....i ~
i I:' 1 'i ->
I hum I
Fig 2.7
Example of quick sort control specification
sort( X,Y ):- qsort( X,Y-[] ).
qsort( [],R-R ):- !.
qsort( [KeylOther],B1-B2 ):-
partition( Key,Other,Small,Large ),
qsort( Small,Bl-[KeylTmp] ),
qsort( Large,Tmp-B2 ).
partition( __,[],[],[] ):- !.
partition( Key,[ ToplOther ],[ ToplSmall ],Large ):-
T o p =< K e y , ! ,
partition( Key,Other,Small,Large ).
partition( Key,[ ToplOther ],Small,[ ToplLarge ] ):-
Key < Top , !.
partition( Key,Other,Small,Large ).
List 2.2 quick sort
Fig 3.1
The information ~ about unexpected values is obtained
from the user. The debugging system has facilities for
managing information regarding binding values and nodes, and
the system finds the position where an indicated argument
value was produced.
For example, it will query the user about a goal that has
an erroneous argument.
When 'qsort( [4;1,2,5,3],[3,1,2,4,5] )' succeeds, the system
asks the programmer:
Query
qsort( [4,1,2,5,3],[3,1,2,4,5] ) (yes/no) ?n
The programmer responds "no".
The second argument is indicated and we call it 'false
instance production node'.
72
note *-1
To calculate weight, assume that
- a node of a built in predicate = 0
- a leaf node ( except for built in predicate ) = 1
- other node = Z(weight of child node ) + 1
i n~tar~e
product ion node
p r ~ ion noae
O~(--bug instance
/~B E F
bug instance product i on node
O node t h a t does n o t a f f e c t
. . . . _pr~__ibly buggy p a t h
t h e above p a t h
Fig 3.4
bug i n s t a n c e
p r o d u c t i on ~) YJ~
bug i n s t a n c e g//~
d i scovery nodef/~
O node that
possibly
does n o t a f f e c t
buggy p a t h
t h e above p a t h
Fig 3.5
75
Fig 4.1
Combination of Deterministic Trimming Method and
trace query algorism
Fig 4.2
§5 Debugging Sequence
cat isort
isort( [ XlXs ],Ys ):- isort( Xs,Zs ),insert( X,Zs,Ys ).
isort( [],[] ).
insert( X , [ Y I Y s ] , [ Y J Z s ] ) : - Y > X, i n s e r t ( X,Ys,Zs ).
insert( X , [ Y I Y s ] , [ X , Y I Y s ] ) : - X ~ Y.
insert( X,[], [ X ] ).
pgdb ( invoke the debugging system }
?- [+isort].
?- pgdb( isort( [2,3,1],hns ) ).
Ans = [2,3,1]
yes
9- halt.
Iogin
lisort/Z #- 4 1 i s o r t / Z I* ~[i.~t/3r ~ $,o
[ isort/2 I
I insert/3~- ~_[ ) / z ]~._ ~_[ i n s e r t / 3 ] - *
[ insert/3~ ~1 = ( / 2 ]~
letPt(h) r i g h t ( I ) up(k) ¢k0wl(j) ctl (spc) q u i t ( q )
Fig 5.1 Modify mode of control specification
( In Figure 5.1,you can move cursor of curved box by using
"h','j','k','l' keys( this is like 'vi' mode ). Each time
you push the space bar, the cursor's box control specifi-
cation will change. '/2' and '/3' represent the number of
arguments in a goal. }
Iogin
lisortl2 ~-- -*[isort/2 ]-~ ~ [ i n s e r t / 3 f ~ ~;
I isort/2 ]
[insert/3~- ~--I )/z I~ ~-1 i n s e r t / 3 1 ~
[ insert/3~ ~[ = ( / 2 ]~
l e f t ( h ) r i g h t ( I ) up(k) doNn(j) Ctl (spc) ¢lUit(q)
Fig 5.2 Modify mode of control specification
( In Figure 5.2, there must not be 'REDO' control after the
'>' built-in predicate. The programmer can modify it with
the box cursor. }
Iogin
[isort/Z ~-- - ~ l i s o r t / Z I -~ -~1 i n s e r t / 3 1 - *
[isort/Z J
[ insertl3~--
[insert/3~-
~1 ) I Z
~1 = ( / 2
insert( 1,[3],[3,1] )
* ...? space key (space bar was pushed}
insert( 1,[3],[3,1] )
*** ...? space key
insert( 1,[3],[3,1] )
...? space key
insert( 1,[31,[3,11 )
***** ...? b
insert( 1, [ 3 ] , [ 3 , 1 ] )
...? b
nsert( 1,[3],[3,1] )
...? b
insert( 1,[3],[3,1] )
• --? It
Bug clause is
insert( 21,[181 19],[ 181 20] ):-
18 > 21,insert( 21, 19, 20 ).
called by insert( 1,[3],[3,1] )
( Bug clause was found. }
§6 Evaluation
§6.1 Shapiro's deride and query algorism
The weight of a computation tree is reduced by one query
as described below,
N N W ~ (1- IN (6.1)
"N" i s l e n g t h of computation tree
'b' is factor of branches
Figure 6.1 and 6.2 represent the example where the reduced
weight i s n o t I/2N. T h e c a s e w h e r e t h e b r a n c h i n g factor
equals 2 is shown in figure 6.1. Within the weight below
the middle node ( weight lO ) o f r o o t n o d e ( w e i g h t 20 ) ,
the heaviest node weight is only 5 not 10. If this node is
true, and adopt this middle node, trim a subtree rooted
at this node. The total weight of this computation tree is
1
{ 1--2V }N
If the middle node is false, trim outside of the subtree
rooted at that node. the total weight of this computation
tree is
1N
2b
79
IG
5 S 5
Fig 6.1 Fig 6.2
The lower bound of query times, QL, is represented by
formula ( 6.2 ).
-1
QL = logz(1/2b) x 10g~N ( 6.2 )
The upper bound of query times, Qa, i s represented by
formula ( 6.3 ).
-I × log2N ( 6.3 )
Qa . . . . [ o g z ( l - I / 2 b )
Comparing upper b o u n d Q~
Comparing Shapiro's algorism with Deterministic Trimming
Method is accomplished by comparing the coefficients of
formula ( 6.6 ) for different values of a. This comparison
is given in figure 6.3.
Figure 6.3 shows that the upper bound of query times in
Shapiro's algorism depends on the branching factor linearly,
but the Deterministic Trimming Method shows the increase in
query times by a percentage of the trimming factor.
14
--~ 13 trimming
12 f a c t o r c~ ~ j ~
"" II rl 1.00
-0
..~ I0 0 0,98, ~ - r,
v 8
• o,ss
7
0
6
S
4
3
2
1
0
I l 1 I l ) ( 1 i )
1 2 3 4 5 5 ? 8 9 10
branching f a c t o r b
Fi~ 6.3 Upper bound of query times,
0
J~
0
111
0 6-
trimminc
factor
0
0
+
A
1.00
0,80
0,60
0.40
m 0.20
0 5- • 0.I0
0 4-
0 3-
0 2-
0 I , J,,
2 3 4 5 6 ? 8 9 10
branching f a c t o r b
Fig 6.4 Lower bound of query times.
System configuration
This debugging system consists of
-Execution block for test Prolog program,
( This block is based on C-Prolog source code )
-Editor for control specification notation,
.Bug search block.
They are invoked in sequentially, communicating by
intermediate files.
81
Conclusion
The size of the intermediate files produced by the
debugging system i s 164 K B y t e s w h e n t h e n o n - b a c k t r a c k test
program fills the local stack ( 128K B y t e s ), so it has no
practical problem.
We h a v e implemented a system that support meta-predicates
( "call', "not' ) . We a r e c o n s i d e r i n g how to cope the
"assert" predicate. There are two types of bug the "retract"
predicate can cause:
Q The case where variables are bound to the arguments of
"retract',
The case where a term is deleted by the "retract"
predicate.
This system can cope with the case Q, but not ~.
Acknowledgement
This research, and the development of the debugging system,
was supported by Also Laboratory at Keio University. The
authors would like to thank Dr. Yang Rong, Mr. Show Ei Ken,
and members of the Logic Programming Group.
References
[Lloyd87]Lloyd,J.W.
Declarative Error Diagnosis,
New G e n e r a t i o n Computing,5 1987 Springer-Verlag
[Maechi87]Machi MAEJI and Tadashi KANAMORI
Top-down Zooming Diagnosis of Logic Programs,
35th Conference of Information Processing Society of Japan,
1987
shinichi MORISHITA and Masayuki NUMAO
BPM-Visual prolog computation model and debugger PROEDIT2,
Proc. of The Logic Programming Conference "86 , 1986
[Numao85]Masayuki NUMAO
PROEDIT Screen oriented Prolog programming Environment,
Proe. of the Logic Programming Conference "85, 1985
[Pereira,L.M 86] Pereira,Luis Moniz
Rational debugging in logic programming,
Lecture Note in Comp. Science 225, t986 Springer-Verlag
[Shapiro83]Shapiro,E.
Algorismic Debugging, M.I.T. Press, 1983
[Takahashi86]Hidehisa TAKAt~SHI, Etsuya SHIBAYAMA
PRESET - A Debugging Environment for Prolog,
Lecture Note in Comp. Science 1986, Springer-Verlag
Naohisa TAKAHASHI, S a t o s h i ONO a n d M a k o t o AMAMIYA
Parallel-processing-oriented Algorismie Bug-detection Method
for Functional Programming Languages,
Study of Basic Software,1984
ALEX • The Logic Programming Language
with Explicit Control and without Cut-Operators
1 INTRODUCTION
Prolog has a backtrack mechanism and enables declarative programming. Its drawbacks
are that over-strong backtrack and cut-operators make the program difficult to write, read
and debug. Prolog's mechanism has the following problems.
2) Backtrack control cannot be described on the source code level on which that control
is achieved.
If we read just one clause of' a Prolog program, we cannot tell which predicate
may fail and which predicate may be reactivated by backtracking. To find out
these things, we must read at a deeper level of the Prolog program. In other
words, in the Prolog program, the source code level on which a backtrack
is achieved cannot contain a description of which predicate is reactivated by
backtracking. The description must be made at a deeper level to insert the
cut-operators. This makes the program difficult to code, debug, and read.
In any programming language, the control of the program should be described
at the source code level on which the control is achieved. It is unnatura~ that
the callee program describes the control of the caller program.
In the hierarchy of the program, if the deeper level is related to the shallow
level, and the modification or the bugs in the deeper level affect the shallow
level, there is no point in making the program hierarchical.
We think that the most important feature of a programming language is that the user
can express what he wants to do easily and exactly. Even a programming language that
has excellent theoretical features is impractical if it is difficult to write, read and debug.
In order to make Prolog more practical and more useful, cut-operator should be scrapped.
Many Prolog debuggers have been tried, but we think that the control specification of
Prolog itself should be re-examined. In this paper, we propose "ALEX" (Advanced pro-
Log with Explicit expression), a programming language designed to improve the control
specification of Prolog.
In ALEX, the problems we have just described are solved as follows.
Problem 1)
Problem 2)
Recall:
Recall is backtrack that the clause that finished execution is abandoned, and
its alternative is re-selected.
7-1 $-1
.... p,Q . . . . . . . . p,Q ....
(a) shows a case where predicate Q fails and predicate P is reactivated by backtracking,
that is, the cIause for the call P is re-selected. Suppose that when P was called, clause
(1) was selected and the calls A,B were executed deterministically.
In this case, for the call P, clause (1) was selected and executed successfully. We
named this kind of backtrack "Recall".
(b) shows a case where predicate Q fails and predicate B (called from P) is reactivated
by backtracking. Suppose that when B was called, clause (4) was selected and the call C
and the call X were executed deterministically. In this case, as in Fig 1, the clause that
finished execution is abandoned, so this backtrack is categorized to "Recall".
Recall corresponds to "essential trial and error". Because the clause that finished
execution is abandoned and its alternative is re-selected.
Retry:
Retry is backtrack that, during the execution of a clause, the whole clause
fails and its alternative is re-selected.
85
..... e . . . .
P:-A,B,C. --(1)
~ P:-D,E.--(2)
Fig 2 Example of Retry
Fig 2 shows a case where P was called, clause (1) was selected, A finished execution
deterministically, the next B failed, and clause (2) was re-selected.
In this case, clause (1) has not finished execution. In other words, the clause for the
call P has not been decided yet. In this sense, Retry corresponds to "branch on condition"
like "if then else" or "case".
The prohibition of Recall in default state reduces the number of bugs caused by omis-
sion of cut-operators.
An ALEX procedure is a set of horn clauses like Prolog. The pattern of horn
clauses are same as Prolog, except for the following Dature.
8{5
• A predicate in the head or the body of a clause can take a prefix such as "?", ":",
"??', "::', " + ' . The prefix is used as control information.
• A clause can take control of a structure named "block". "Block" is a line of predi-
cates which is clipped between "<" and ">".
Semantics:
An ALEX clause is executed "depth first, left to right" like Prolog. The
unification mechanism and the pattern of atomic formulas are the same as in
Prolog except for the backtrack mechanism.
P<®A,B,C.--(1)
+P<-D,E. --(2)
P<-F,G. --(3)
In Fig 3, if clause (1) finishes execution successfully, (2) and (3) (alternatives Of (1))
cannot be executed in the event of a backtrack that reactivates the predicate P. If clause
(2) finishes execution successfully, (2)'s alternatives (3) can be executed in the event of
backtrack.
Retry can be performed in default state (in spite of the prefix " + ' ) . In Fig 3, if
predicate A fails, clauses (2) and (3) can be tried.
• Never fail.
• If it fails, ALEX interpreter halts with a error message.
• If it finishes execution successfully, it cannot accept "Recall".
- Error message shows the functor of the failed predicate, the contents of
the variable when the predicate was called, and the call number.
87
- After the indication of the error message, the ALEX interpreter asks the
user whether they want to continue the execution and regard the error as
a failure or to make an abort.
• It can fail.
• ff it fails, it causes Recall or Retry.
• If it finishes execution successfully, it cannot accept Recall.
• It can fail.
• If it fails, it causes Recall and Retry.
• If it finishes execution successfully, it can accept Recall.
Note that the prefix "+" is necessary on the clause level to accept
Recall, in addition to the prefix ":".
Table 1 shows the essence of the control on Recall. In this table, "possibility of failure"
cannot be described in Prolog. "Possibility of Recall" is expressed by using cut-operators
in Prolog, but it is implicit from a view point of well-understandable programming. Be-
cause when we want to know the determinicity of a predicate, we have to read the deeper
level of the program.
In ALEX, user can know "possibility of failure" and "possibility of Recall" of the
predicate only to see the prefix of the predicate. So ALEX is easier to read.
Predicate that cannot fail or accept Recall are most often used in the program. There-
fore in ALEX this kind of predicate is expressed as the predicate without prefix.
In this way, ALEX is designed to reduce the amount of the prefix for control in the
source code so far as the necessary information is available. With ALEX, it is easy to
detect bugs caused by the user omitting a prefix at a place where it was necessary.
P<- :A,B,:C,?D,?E,F.
In Fig 4, when ?D or ?E fails, only :B (inside :B) can accept Recall. C and ?D cannot
accept Recall. If :B fails, P also fails as a result. In this case, if P has alternatives, the
alternatives are tried. "Inside :B" means the predicates that are directly or indirectly
called by :B.
88
.... :P,Q,?R . . . .
P<-A,:B,C.
P<-D.
A.
+B.
B<-:B.
C.
D.
Fig 5 shows the case in which :P and Q are executed successfully, and ?R fails. Then,
as a result, :B is Recalled. In this case, the prefix ":" is necessary on both of P and B.
And P is not reactivated by a failure of ?R. Because P does not have a prefix "+" at the
head of the clause.
.... P,Q,?R . . . .
P<-A,:B,?C.
A~
+B.
B<-:B.
C.
Fig 6 shows the modularity of the ALEX program. Suppose that the user wants to
permit :B to accept Recall only from ?C. When programming in Prolog, in a case like
this, the user has to insert the cut-operator behind ?C to protect :B from the backtrack
from the upper level, (?R) in this example.
In ALEX, in this case, P has no prefix, so inside P is protected from Recall that is
caused by a failure that occurs outside P.
If the user writes B for :B by mistake, when ?C fails, P fails and the error occurs as
the result. Therefore the error is shut in a local part.
"Protection from Recall" and "Confinement of error" can achieve the easy debugging
and the higher confidence of program. And the explicit expression of the backtrack control
by the prefix of the predicate can achieve higher readability.
In Prolog, it is often difficult to see the reason why a cut-operator was inserted in a
place. Unnecessary cut-operators are often inserted, too.
To make a failure unconditionally, an operator "?" (not a prefix) can be used. When
this operator is executed, it makes a failure.
89
• It can fail.
• If it fails, its parent-predicate fails immediately.
• If it finishes execution successfully, it cannot accept Recall.
• It can fail.
• If it fails, its parent-predicate fails immediately.
• If it finishes execution successfully, it can accept Recall.
.... O,?P,Q . . . .
P<-?A,??B,C. --(1)
P<- D . - - ( 2 )
A.
B.
C.
D.
In Fig 7, if ??B fails, ?P fails immediately. (2) is not tried. In ALEX, Retry can be
prohibited in such a way. Note that, Retry is prohibited very rarely, so these two prefixes
are not often used.
To make the parent-predicate fail unconditionally, the operator "??" (not a prefix)
can be used. When this operator is executed, the parent-predicate of this operator fails
immediately.
3.5 Block
To restrict the area where Recall can be performed, the control structure "block" is
introduced. "block" can protect an area from Recall. "block" is the sequence of the
predicates clipped between "<" and ">".
"block" has the following features.
• A failure that occurs outside "block" does not reactivate inside "block".
90
• If a whole "block" fails, the "block" makes an error, and the system halts with an
error message.
Fig 8 Block
4 PROGRAMMING IN ALEX
In this section, we show an example of ALEX program.
gps(S,[l,S,[l).
gps(S,G,S,~)<-?subset(G,S).
gps(S,G,Sa,ANS)<-
sorting(G,GN),
difference(S,GN,DIFLIST), --(1]
:member(DIF,DIFLIST), --(2)
operator(DIF,OPLIST), --(3)
:member(OP, OPLIST), --(4)
precondition(OP,PRECOND), --(5)
?gps(S,PRECOND,S1,ANS1), --(6)
apply(OP,S 1,$2), --(7)
?gps(S2,G,S3,ANS2), --(8)
cat(ANS1,OP,ANS1,ANS). --(9)
difference(_,[],[]).
difference(S,[XIY],R)<-
?member(X,S), --(10)
differen-ce(S,Y,R).
difference(S,[X IY],[X t R] )<-
difference(S,Y,R).
+member(X,[X I -]).
member(X,[_ t Y])<- :member(X,Y).
Fig 9 is a part of the GPS (Genera1 Problem Solver) program to resolve the monkey
and banana problem.
The calling pattern at top-level is
to be concrete
?-gps([at(monkey,banana,),at(box,b),empty],
[hold(banana)],
FS,
ANS).
GPS calculates the difference between current state and goal state, -(1), and select the
most important difference, -(2). Next, GPS lists all operators to reduce the difference,
-(3), and select the most effective operator, -(4). Then, GPS applies the GPS algorithm
itself recursively regarding the precondition of this operator as the new goal, -(5)(6). If
this application succeeds, GPS applies the operator, -(7). Next, GPS regards that result
as the new current state, and GPS applies the GPS algorithm recursively further, -(8).
At the end, the sequences of the operators are concatenated, -(9).
In this ALEX program, we can easily know the control from the prefixes as follows.
In the 3rd clause of gps/4, when ?gps/4 at (6) ol- (8) fails, :member/2 at (4) is reacti-
vated by Recall, and if (4) has no alternative, :member/2 at (2) is reactivated next. All
predicates in the 3rd clause of gps/4 except (2) and (4) cannot be reactivated by Recall.
Thus, in ALEX program, the control of a program can be expressed on the source-code
level at which the control is achieved.
When we translate this program into a Prolog program, we have to insert the cut-
operators inside sorting/2, different/3, apply/3. It is not natural.
When we read the Prolog program that corresponds to this program, we cannot know
the control of the program only from the 3rd clause of gps/4. We have to read the deeper
levd.
Also, :member/2 at (2) and (4) has a different function from ?member/2 at (10) in
spite of calling the same substance. :member/2 at (2) and (4) are used to generate some
data repeatedly by Recall, so it is necessary to be nondeterministic. While ?member/2
at (10) is used only to test the data and it should not be reactivated by Recall, so it is
necessary to be deterministic.
In ALEX, the use of the predicate is expressed in the caller side, so only one substance
is necessary, and the use of the predicate can be clearly understood.
92
- Here, the word "freeze" is used to mean fixing the choice of clause.
- The word "procedure P" means the clauses that have the P at their heads.
Prolog
member(X,[X 1_]):-!.
member(X,[_ I Y]) :-member (X,Y).
ALEX
member(X,[X I -]).
member(X,[_t Y])<-?member(X,Y).
In this example, member/2 in Prolog freezes itself. This kind of use of cut-operator
is usually called "Confirming the Choice of a Rule". Most cut-operators are used
like this.
In ALEX, this determinicity is realized in default state, which is without prefix "'"
and "+" .
That is, Recall can be achieved only when the following two conditions are satisfied
at the same time.
- The prefix " + " is at the head of a clause, on the clause level.
- The prefix ":" is at the predicate, on the predicate level.
It means that ALEX has a twofold protection mechanism, so it is easy to find bugs.
But in ALEX, it is necessary to put the prefix "?" at member/2 in the body. Be-
cause it may fail. If the programmer forget to put this "?" and member/2 fails,
it becomes a bug. But this bug comes out as an executior~ error, so we can find it
out easily. This is the essential difference between the hug caused by the tack of the
prefix "?" and the bug caused by the lack of the cut-operator. In the latter case,
we have to spend a lot of effort looking for bugs.
93
• 2) The case that a procedure, though it can freeze itself, is frozen by the other one
Prolog
member(X,[X [ _]).
member(X,[_[ Y]):-member(X,Y).
member(X,[X i_]).
member(X,[_ I Y])(-?member(X,Y).
In case 1), member/2 freezes itself. In case 2), subset/2 freezes member/2, even
though member/2 can freeze itself. In actual programming in Prolog, cases 1) and
2) are often used redundantly. It means, for instance, cut-operators are inserted
into both member/2 and subset/2 in case 2). The larger a program becomes, the
less we can rely on determinicity of the predicate on the lower level. So we insert
more redundant cut-operators. We can also insert cut-operators to achieve higher
readability, although we know they are redundant. In ALEX, by a twofold protection
mechanism on the clause level and the predicate level, such determinicity is achieved
in default state, cases 1) and 2) are the most often used cases of cut-operators.
according to our experience, more than 80% of cut-operators are used in this way.
• 3) The case that a procedure cannot freeze itself, and is frozen by the other one
(Whether a procedure is frozen or not depends on the condition of its surroundings)
This is the case that a predicate is frozen when the test by the other predicate suc-
ceeds. It is often called "termination of generation and test". This case is essentially
different from cases (1) and (2) because a predicate cannot freeze itself.
Prolog
member(X,[X I _]):-!.
member(X,[_l Y]):-member(X,Y).
moreThanFive(X,LIST):-
member(X,LIST),X:,5,!.
ALEX
member(X,[X I _]).
member(X,[_ I Y])<- ?member (X,Y).
moreThanFive(X,LIST)<-
?< :member(X,LISW), ?(X>5) >.
• 4) The case that the special predicate "fail" forces "the parent goal" to fail
This case is often called "cut-and-fail" or "negation". In ALEX, it corresponds to
the operator "??". That is, "!,fail" has same function as "??".
Here, we tried to categorize the use of the cut-operator in Prolog. It is often ambiguous,
for what kind of purpose a cut-operator is used. In ALEX, a prefix expresses the control
explicit, so it is easier to read. The control of Recall can be expressed on the level on
which it is achieved, so we can do natural programming.
6 CONCLUSION
We believe that the most important feature of a programming language is that it should
be easy to write, debug, and read. Prolog has high potential, but it is inconvenient in
above feature. Many extensions of Prolog have been developed. But if it takes more time
to debug, the extension is not practical.
In ALEX, we suggests a way to improve the execution control of Prolog.
Backtrack mechanism is divided into two categories. One of them corresponds to
"essential trial and error" and the other corresponds to "branch on condition". We named
the former "Recall" and the latter "Retry". Generally, "branch on condition (Retry)"
appears frequently in the program, while "essential trial and error (Recall)" appears
rarely. So Recall cannot be achieved in default state in ALEX. This enables "Protection
from Recall" and "Confinement of error", and it reduces the number of bugs by omission of
cut-operators. As a result, easy debugging and higher confidence of program are achieved.
95
Control in ALEX is described with the prefix at the head of predicate. The predicates
in the body are categorized into five categories. And a prefix shows the possibility-of-
failure or possibility-of-backtrack of a predicate. By the prefix, the user can know the
control of program on the source code level on which the control is achieved.
References
[1] Clocksin,Merish "Programming in Prolog", Springer-Verlag(1981)
[2] Naish,L "PROLOG CONTROL RULES", IJCAI86(1986)
[3] Sawamura,H "The Determinacy of Prolog Predicate(Call)",
Computer Software Vol.4 No.4,(1985) in Japanese
[4] Chikayama,T "Unique Features of ESP',FGCS84(1984)
[5] Chikayama,T "ESP Reference Manual", ICOT TR-044,(1984)
[6] Nakashima,H "Prolog/KR User's Manual" METR 82-4,
Dept. of Mathematical Engineering, University of Tokyo(1983)
LATTICE PROGRAMMING METHODOLOGY
K o u l c h l ~hlkunaga Shlnichi M o r i s h l t a
IBM Research, Tokyo 1~esearch Laboratory
5-19 Sanban-ch% Chiyoda-ku, Tokyo 102 JAPAN
1 B a s i c idea
Logic programming gives us a way to look at conventional algorithms f~om a different viewpoint
and to reorganize or classify them. The separation of the logical aspect of the problem f~om
the procedural control for searching for a solution makes the comparison of algorithms easier.
As a result, in some cases algorithm derivations become easier in logic programming.
For example, many sorting algorithms can be regarded as the specializations of the following
naive algorithm.
Since the logic and control of this program are separated, it is easy to understand what this
program does. If we assume the depth-first search as the control strategy, it does generate-
and-test by backtracking between permutation and ordered. In this case, its inefficiency comes
t o m the excessive backtracking and the specializations are concerned with reducing unnecessary
backtracking by incorporating the test function of ordered into permutation. This clarity of
algorithm derivation is one of the advantages of logic programming.
However~ logic programming has still disadvantages. Since it only provides syntactic unification,
programmers have to invent the way to represent their data structures by using this unification.
These problem specific inventions sometimes obscure the declarative clarity of logic programs.
In these cases, we would rather prefer to directly represent objects and their properties of the
problem domain.
We found a way to clearly represent some algorithms whose goal is to produce minimal (or
maximal) objects under the given ordering. Examples of the category include sorting, minimum
spanning tree, and shortest path finding, which we will explain later in this paper.
We conclude that all the advantages of logic programming come f~om one theorem : its declar-
ative semantics coincides with its procedural semantics. If we look carefully at the proof of this
theorem, we find it depends on a technique which is not specific to logic but more widely appli-
cable. The technique is largely based on lattice theory. This observation suggests an extension
of logic programming as follows.
• or ~ join
As we will briefly explain in the later section~ the above theorem still holds under some conditions
on functions over complete lattices. Since lattice is the simplest algebraic structure which many
algebras of d a t a structures satisfy. Thus, this extension has the potential for ~epresenting some
d a t a structure producing algorithms in a natural way. We call this exiension lattice programming
and show its apphcations in the following sections.
In lattice programming, we use lattice valued programs in which each atom has a complete
lattice as a range and each clause is associated with a function over complete lattices.
A complete lattice Z is a partial ordered set which has least upper bound (US) and greatest
lower b o u n d ( ~ S ) for every subset S of L. The least upper bound and the g~eatest lower bound
of L itself are denoted by TL and -kL respectively.
In a lattice valued p r o g r a m P , atoms which have the same predicate symbol and the same arity
are associated with the same complete lattice. Let LA denote the complete lattice foz A. A
lattice valued program P is a finite set of clauses each of which is associated with a function over
complete lattices. Suppose that a clause A ~- B 1 , ' " , B,~ (n > 0) is given, then it is associated
with a function f : LB~ x . . - x LB~ ~ LA. If a clause has the fo~m A *--, then it is associated with
a constant function, t h a t is, an element of LA. We will denote the p a i r constitutes of a clause
A 4- B 1 , - ' - , Bn and its function f by (A ~ B I , . . . , B,~, f ) which we call a clau,e pazr. We also
associate a goal e-- A 1 , - . . , A,~ with a function F fzom LA~ x . . . x LA~ to any complete lattice
L. We will denote the pair constituting of a goal ~-- A 1 , " ' , A n and F by (~- A 1 , - - - , A n , F )
and call it a goal pair.
We assume that every function F : L1 × --- × Ln --+ L in any program satisfies the following two
properties:
• Elementwise strict :
F(ai,-", an) = -LL whenever at least one al = I-L i
98
We wilt refer this requirement on a program by (a). Note that an elementwise least upper bound
preserving function is monotonic increasing.
Informally, the declarative meaning of a clause (A *- B I & - . - &B,~, f) is that , for any ground
substitution p, the value of Ap is greate~ titan or equal to f(bi,'", b,~) (bi is the value of Bip).
Let denote this fact by Ap ~ f(Bip,"',Bnp). We also describe the value of a goal pair
(~---Aip,'",A,~p, F) by F(Aip,'", A,,p) for any ground substitution p.
Suppose that a goal pair (~- A i , ' " , A n , F) is given and ~ Ai,...,A,~ is ground. We can
restrict the value of F ( A i , " ' , An) as follows ; if Ai is selected from A i , - - - , A , , and Ai and A
in (A ~ B i , - " , B m , f} are unifiable by an mgu 0. Since A ~_ f ( B i , ' " , B m ) holds and F is
monotonic increasing~ we have
F(Ai,...,AI,...,An) D .F(AiO,'",f(BiO,'",BmO),'",A,~O).
Suppose that we have the following sequence, after deriving goal pairs repeatedly.
Then this process is called a derivation and an equality F ( A i , - . . , An) -7 F ' is obtained.
By the way, in each step of deriving goals there are two choices, that is a choice of an atom to
be selected and a choice of a clause. In our framework, we can fix one rule for selecting an atom
(see section 5), however, there still exist a choice of a clause. Due to this choice in each step, we
may have many derivations for the same goal pair.
These derivations can be made up into a tree structure like a SLD-tree in usual logic program-
ming. See Fig 1. Such a tree is called a derivation tree. Irt a derivation tree, each branch from the
root to a leaf corresponds to a derivation. Since we can regard a derivation as an inequality which
gives a lower bound of the given goal pair, each leaf node gives a lower bound for the initial goal.
For example, in Fig.l, the leaf F ' is a lowez bound for F ( A i , ' " , A,~) (F(Ai,-..,A~) ~_ F').
In this way, from a derivation tree, many lower bounds for the initial goal may be obtained.
F(A~,...,A.---,A.)
A n f(B1,---,Bm),0
Fn
Fig.1 A Derivation Tree
99
In section 5~ we show that the least upper bound of these lower bounds is equal to the solution.
In this section, we discussed the declarative and p~ocedural semantics informally. Its ~igorous
treatment is found in section 5.
3 Programming methodology
• Formulate the complete lattices to represent all of the potential data structures (including
the p~oblem solution) which may be handled by the program.
• Show the solution be restricted by a set of inequalities and represent them as clauses
• Show the least upper bound of ~he lower bounds derived from the inequalities is the
solution.
The following example illustrates this process. Suppose we are given a problem of producing a
sorted sequence out of a sequence of natural numbers (with +co). The first step is to construct
a lattice of sequences of natural numbers Z,~q. A sequence is denoted by ( z r , . - - , z,~) (n _> 0).
Let Ln,,,q be the set of sequences of the same length n. In L,,,s~q, elements are ordered in
lexicographic order _.
Note that Ln,,~q is totally ordered. The sequences of different lengths are unordered. The whole
lattice L,~q is obtained by taking the direct sum of {L. . . . q I n is a natural number } whose top
(T,¢q) and bottom (±,¢q) are newly introduced.
Next, consider a binary function % over L,~q. % concatenate two sequences. For T,cq and ±~¢a,
the meaning of % is defined as follows:
T,¢¢ % s = T,~q, s % T,~q = T,~q, ±~¢q % s = i,~¢, s % i,~q = i , e q for any s in L,~q.
Let sequence(S) be an atom with which L,¢q is associated. Let d_union(S1, $2, S) be an atom
expressing that S is a disjoint union of $1 and $2. d_union(S1, $2, S) can be defined by a
conventional logic program, .and it is associated with {true, false). The following discussion
shows sequence(S) defined below calculates the sorted sequence of S.
100
Since % satisfies requirement (a), it is obvious that f also satisfies (cO. To clarify the declarative
meaning of this p~ogram, we will replace ~ and & with .~ and % respectively. Furthermore
we will use A- as a syntax sugar for d_union. Then we get the following inequalities which
sequence(S) satisfies.
Now, let us execute a sample goal pair, for example, (4- sequence({4, 3, 1, 2}),I>, where I is the
identity function over £,eq. This goal pair is intended to calculate the value of sequence({4, 3, 1, 2})
itself. After searching exhaustively (see l~ig.2), we get the set of inequalities from the derivation
tree.
~equencK{4, 3, 1, 2})
4",
~quenc~({~, 3}) S sequence({1, 2}1
d',
(~eq~enc~({4}) % ,eq~en~e({3})) % (~eq~nee({i}) % sequen~({2}))
d',
((4) % (3)) % ((~) % (2))
( = <~, 3) s (1, 2) = (¢, 3,1, 2) )
Fig.2 (Case %) h Derivation Tree for (~---sequence({4, 3, 1,2}),I)
Since the least upper bound of {X [ X is a permutation } is (1, 2, 3, 4), the above set of inequal-
ities is reduced to sequence({4, 3,1, 2}) _~ (1, 2, 3, 4). Hence, (1, 2, 3, 4) becomes the solution of
the given goal.
There is one problem in this program. The set (2) is quite large. This is caused by the naivety
of concatenation. ]?or example, during computation, we may be able to conclude that :
Then, the above program restricts seq~ence({4, 3, 1, 2}) by using the simple concatenation as
follows.
If we use the merge operation $ defined below instead of %, we can restrict sequence((4, 3, 2, 1})
more strongly. Because (4, 3)$(1, 2} = (1,2,4, 3) is much greater than (4,3, 1,2). Moreover,
we do not lose the solution (1, 2,3,4) by this change. This observation suggests the following
program which realizes the so-called merge ,ort.
'$' meets requirement (ix). It is easily shown that, given two sorted sequences, merge produces
the sorted sequence of them. Hence, for the goal (*- seq~tence({4,3,1,2}),I), we obtain the
same lower bound (I, 2, 3, 4) f~om any derivation of this goal, however S is decomposed into $1
and $2 (see Fig.3).
sequence({4. 3.1.2})
d',
sequence({4.3}) * ~eq,,~ce({1.2})
4",
((4), (3>), ((1) * <2))
( = (3.4>, 0.2) = (1.2.3.4))
Fig.3 (Case $) A Derivation T~ee for (e- sequence({4,3, 1,2}),I)
This gives the chance to reduce the complexity by fixing the method to decompose S. For
example, if we decide $2 to be a singleton, we get the insertion aort as follows.
In this way, lattice programming give the following stepwise refinement method from naive
algorithms to more efficient ones.
* Reduce the number of derived lower bounds for each goal by introducing new operations
while retaining the solution.
• Incorporate an efficient search strategy into the program which utilizes the properties of
the resulting set of lower bounds.
4 A further example
The above argument which clarifies the relation between algorithms by showing their algorithm
derivations also applies to other problems. Due to the space limitation, we only show one example
program which solves the single source shortest paths problem and its algorithm derivation from
more naive versions is left to the reader.
Let G = (V, E ) be a directed graph which consists of a vertex set V and a edge set E each element
of which has non-negatlve length. The length of an edge e(v, ~ ) from the vertex v to the vertex ze
is denoted by length(e(v, w)). A path from vl to vn is denoted by e(vl, v2).e(v2, v 3 ) - ' - e(v,~-l, v,,).
The length of a path p denoted by length(p) is the sum of the lengths of the edges on p. The
problem is :
(For simplicity, we assume that there exists an edge from a source s to itself whose length is
zero). First of all, we construct a complete lattice £ , ~ h , whose elements are sets of paths from
s. Every element z in L,~ath, is an array whose length is the number of vertices V. Each cell is
indexed by a vertex v E V, and its content z[v] is a path p from s to v or nil which means there
is no path. We define length(nil)=+co. A order E in L,~o, th, is defined as follows.
Secondly we define another complete lattice L¢~g¢, of edges E. Leage, is a fiat lattice in which
all edges in E are unordeIed and its top(Teag¢,) and bottom(-Le~g~,) are newly introduced. It
can be proved that/~,~ath, and L,doe, are complete lattices.
Now we will give a function f : L~g~, x L , ~ h , ~ L,~h, which incrementally calculates path
sets from s by adding the effects of an edge. (By the way, to meet elementwise strictness, we
will add a-,~a~h, to L,~a~h,, where -L,~th, is less than every element in L , ~ t h , . )
103
It is easily verified f meets requiremen~ (a). Then the following program calculates the shortest
paths from s to all vertices in V.
If we rewrite this top-down recursive program to a bottom-up iterative one and apply branch
and bound strategy to the search, we get the non-deterministic version of the labeling algorithm
of Ford [9]. Further, if we adopt the shortest first search as the special case for branch and bound
strategy, we get the Dijkstra's shortest path algorithm ([8]). Note that if we change the lattice
and the operation appropriately, the same program represents an algorithm which calculates the
minimum spanning tree of G.
5 Theoretical Background
Now we give the declarative and procedural semantics special to our framework. The theoretical
results are also presented, but the details of thei~ proofs([1]) are omitted owing to the space limit.
An interpretation I of a lattice valued program P associates every gIound atom A with a value
in LA, which will be denoted by val(A,/). The order in interpretations is introduced as follows
: I i E 12 ¢ ~ val(A, I1) E val(A, I2) for any ground atom A. Using this order, the set of
interpretations of a program P forms a complete lattice.
Some notations are useful for convenience and readability. Let C be a clause A ~ B x , ' " , B n .
C + denotes the head A and C - denotes the body B 1 , " ' , B n . Let (A *-- B1,...,B,~, f) be
a clause pair and I be an interpretation. For example, f(val(Bl,I),..-,val(B,~,I)), can be
denoted by V A L ( ( B t , . . . , B n , f ) , I ) .
Let (C, f ) be a clause pair. The clause C is true in an interpretation I with ~espect to f iff
for every its ground instance C', vat(Ct+,I) _ V A L ( ( U ' - , f ) , I ) holds. In this case, I is called
"104
modelfor (C, f). An interpretation M is called modelof a program P iff M is a model for every
clause pair in P. Let M(P) denote the set of all models of a program P, then its greatest lower
bound I-]M(P) also becomes a model, which is called the minimal model of P.
In logic programming, van Emden and Kowalski [5] associate a p~ogram P with a mapping Tp
over interpretations and show that models of P are fixpoints of Tp. Furthermore, by virtue of
mathematical resulis of Tp, Tp can be used to discover properties of models and provides the
link between declarative and procedural semantics. We also follows this method and define To
as follows. Let P be a program, A be an ground atom and I be an interpretation.
val(A, Tp(I))
= U{VAL((C'-, f), I) IC' is a ground instance of C in <C, f) and C '+ = A}
-~ / L ~ t (if there exists no clause whose head and A are unifiable)
As in logic programming, it can be proved that Tp is a monotone function over the complete
lattice of interpretations and all models can be characterized in terms of Tp. Hence we can
establish a useful connection between models and fixpoints, that is the least fixpoint of Tp is
equal to the minimal model of P. Furthermore, since Tp is a continuous mapping, the least
fixpoint of Tp is equal to Tp T w. This is the very result that connect declarative and procedural
semantics of lattice valued programs.
Theorem.
Let P be a program and A be a ground atom. Then
Now we give the procedural semantics, such as a derivation, a derivation tree and a derived
value. Then we will show one result that combines declarative and procedural semantics.
Let P be a program and R be a computation rule which selects at least one atom from a goal
if it is not an empty goal. A derivation of a goal pair {Go, Fo> via R is a sequence of tuples
{{Gi, Fi},(Ci, h),O~) (i = 0,1,--.), in which a goal (Gi+l, Fi+l) is derivedby a goal (Gi, Fi)
and a clause (Ci, fl} as follows. Let Gi be ~ A 1 , - - - , A~,/~ be g ( X i , ' " , X~), Am be the atom
selected by R, Ci be A *-- B I , ' - - , B q whose head and Am are unifiable by an mgu Oi. Then
Especially, if (C~, fl) is (A e--, f~) (fi E LA), then Gi+l is ~ (A1,---, Am-l, A m + I , ' " , Ak)~i
and F~+I is g ( X 1 , . . . , X m _ l , fi, X,~+l, oo.,Xk). Note lhat if the region of F0 is I , then the
region of each F; is also L.
A derivation can be finite o~ infinite. A finite derivation can be ~uccez~l or failed. A successfui
derivation ends in a goal pair which has the form (~---,Fn). A failed derivation ends in a goal
pair (G,,F,,), where G,~ is not empty and the selected atom from G,, does not unify with the
head of the clause in any clause pair. Let D be a derivation whose initial goal is (Go, F0). The
derived value, de~((G0, F0), D), of D is defined as follows:
• If D is a successful derivation tha:; ends in (~-, F,,), then der((G0, Fo), D) = F,~.
By the way, according to the definition of derivation, there are two choices in each step of
de~iving goals;
. Choice of a clause whose head and the selected atom are unifiable.
Due to these choices, we may have to consider a large number of derivations. Fortunately,
however, since the independence of computation rules can be proved as in the usual logic pro-
gramming [t0] , we can enumerate derivations by a fixed computation rule. This fact really
reduce the number of derivations. Furthermore, we can generate all derivations systematically
and make up them into a tree, which we call derivation tree.
Let P be a program, ( G , F ) be a goal pair and R be a computation rule. The derivation tree
for (G, F ) via R is defined as follows.
* Let (G', F ' ) be a node of the tree ~nd suppose that A,,, is selected from G' by R. If there
is no clause whose head and A,,, are unifiable, then this node is called failure node and it
has no descendants. On the other hands, this node has a descendant for each clause pal1
(C, f) such that C + and Am are unifiable by an mgu 8. The descendant node is the goal
pair derived by (G', F'), (C, f), and 8.
• If a node is ( ~ , F ' ) , then this node is called succe~ node and it has no descendants.
A derivation tree T for a goal (G, F) contains all possible derived values. Each branch f~om the
root to a leaf node can be regarded as ~ derivation. A branch to a success node is a successful
106
derivation and a branch to a failure node is a failed derivation. We also define the derived value
der((G,F),T) for a derivation tree T : der((G,F),T) = U{der((G,F),D)l D is a derivation for
(c, F) in T}.
Now we give will our main result which connects the declarative and procedural semantics of
lattice valued programs.
Theorem.
Let A be a ground atom of a program P. If a derivation tree T of a goal (~-- A , I ) ( I ( X ) = X)
via a computation rule is finite,
6 Conclusion
From the programming viewpoint, the optimization process in the sorting example is similar
to what is discussed as program transformation in Clark and Darlington [3] where the initial
program is like:
However, our algorithm derivation is much easier to understand than theirs, because lattice
programming enables the explicit representation of the sequences and the separation of the
ordering relation from the other aspects of the prograra. In lattice programming, as far as prop-
erly choosing the lattice of sequences and operations on sequences which satisfies requirement
(a), the programmer can concentrate on reducing the computational complexity of permutation
without paying attention to ordered. The system takes care of calculating the ordered solution.
This property makes it easy to evaluate how much the program's computational complexity is
reduced by each programming invention.
From the theoretical viewpoint, the notion of lattice valued programs is extended from a language
P r o B o o l e ([2]) which only considers free Boolean algebras as lattices. It is also a generalization
of works done by van Emden([4]) and Sakakibara([6]) who tried to give meanings to logic pro-
grams with uncertainties. The interval [0,1] of uncertainties is one instance of complete lattices.
O'Keefe([7]) proposed propositional Horn clauses over lattices having finite depths.
We are still in an early stage of the exploration of this new paradigm and much work is to be
done before claiming its usefulness. The following list shows the part of the future research
items.
107
* Accumulation of algorithm design experiences to refine the theory for the natural repre-
sentation of various algorithms and to develop systematic programming methodologies.
• Design of a programming language which enables the declaration of lattices and functions
of interest and facilitates the verification of their correctness.
* Implementation of a language processor which enables the execution of the primitive lattice
operations in a fixed amount of time and storage.
References
[2] S.Morishita et al. , Symbolical construction of truth value domain for logic program, Proc.
of 4th ICLP, 1987
[3] K.L. Clark and J. Darlington, Algorithm classification through ,ynthesi,, The Computer
Journal, vol.23, 1980
[4] M.H. van Emden, Quantitative ])eduction and it~ fixpoint theory, J. of Logic Programming,
1986
[5] M.H. van Emden and R.A. Kowalski, The semantics o] Logic as a Programming Language,
3.ACM, vol.23, pp733-742, 1976
[6] Y.Sakakibara, On semantics of Logic Programs with Uneertaintie% ICOT Technical Report,
1987
[7] R.A. O'Keefe, Finite fixed-point problems, Proc. of 4th ICLP, MIT Pzess, 1987
[8] E.W. Dijkstra, A note on two problems in connection with graphs Numer.Math.,1, 1959
[9] L.R.Ford et al., Flows in networka Pzinceton Univ.Press, Princeton NJ, 1962
Abstract
A programming system can be defined as an environment where one can input and
execute programs. In this paper, we try to describe a simple programming system written
in GHC. We try to capture the function of the metaeall first. Input/output problems in
GHC are also considered. After describing the shell, we try to assemble these parts into
a simple programming system, and discuss how to add new features such as reflective
operations to the programming system. This paper assumes a basic knowledge of parallel
logic languages such as PARLOG, Concurrent Prolog or GHC.
1. I n t r o d u c t i o n
The goal of Fifth Generation Computer Project exists in connecting knowledge in-
formation processing and parallel computer architecture [Fuchi 86]. Since we would like
to realize everything in logic, it was quite natural for us to try to develop a logic-based
machine and write an operating system in a logic programming language.
In the first stage of our project, ESP [Chikayama 84], which is the object-oriented
dialect of Prolog, has been chosen as our tentative Kernel Language. Logic-based machine
PSI [Taki 84] and logic-based operating system SIMPOS [Takagi 84] have been developed.
However~ SIMPOS was full of side effects. It might be an object-oriented system, but far
from logic programming which we expected. What we have learned is that we need more
elegant mechanisms which realize logic in natural way. Therefore, we next paid attention
to parallel logic languages which are based on and-parallel execution of programs.
Various kinds of parallel logic languages have been proposed so far. PARLOG [Clark 85],
Concurrent Prolog [Shapiro 83] and GHC [Ueda 85] [Tanaka 86] are examples of such lan-
guages. In these languages, we can create processes dynamically and express the synchro-
nization between processes quite easily.
Therefore, it seems to be quite natural to try to describe an operating system in these
languages. In fact, various proposals have been made for system programming from the
very beginning of parallel logic languages [Clark 84] [Clark 85] [Shapiro 83] [Shapiro 84].
PPS (PARLOG Programming System) [Foster 86] [Clark 87] and Logix [Silverman 86]
are the examples of such systems. However, they are kinds of empirical systems which
consist of huge amounts of codes, and their overall structures are not clear enough.
*Authors current address: International Institute (IIAS-SIS), Fujitsu Limited, 1-17-25 Shinkamata,
Ota-ku, Tokyo 144, e-mail: jiro%[email protected]
109
In this paper, we try to describe a simple programming system written in GHC. Our
objective is not building up a practical programming system like PPS or Logix. Rather,
our interest exists in expressing a simple programming system more systematically. We
would also like to test new features of a programming system such as reflective operations.
We believe that our research will lead to the development of new programming techniques
in parallel logic languages and prove the expressive power of GHC in the long run.
The organization of this paper is as follows. Section 2 describes metacalls which
present the basic functions of our programming system. Section 3 discusses input and
output handling in the programming system. Section 4 describes the UNIX-like shell and
the overall structure of the simple programming system. Section 5 describes reflective
operations in the programming system.
call (G)
This metacall simply executes goal G. However, this form of metacall does not help us
much because it is too simple. Therefore, the following two-argument metacall has been
proposed.
call(a,B)
This metacaI1 executes goal G and returns the result by instantiating R to success
when it succeeds and to failure when it fails.
The next extension is the following three-argument metacall, which has slightly been
modified from [Clark 84].
c a l l (G, I n , 0 u t )
Here, In is called input stream and used for communication from the system to the
metacall. Out is called output stream and used for communication from the metacall.
Goal execution can be suspended, resumed, or aborted by instantiating In to [suspl I n ' I ,
[resume I In' ' ] or [abort I In' ]. When the execution of the metacall finishes successfully,
Out is instantiated to [success]. When it fails, Out is instantiated to [ f a i l u r e ( R ) ] ,
where R is instantiated to the message which shows the cause of the failure.
e x e c ( t r u e ) :- !.
exec((P,Q)) :- !, exec(P), exec(Q).
exec(P) :- clause((P:-Body)), exec(Body).
exec(P) :- P.
This meta-interpreter simply executes the goal which is given as the argument of
ezec. You may notice that this meta-interpreter corresponds to the implementation of
the single-argument metacall. The GHC version of this meta-interpreter can be written
as follows:
This program is almost the same as the Prolog program except that every clause
definition includes the ] operator.
Two-argument metacalls can be written similarly by modifying the single-argument
meta-interpreter.
exec(true,ln,0ut) :- true
0ut=[success].
exec(false(R),In,Out) :- true
0ut=[failure(R)].
exec((A,B),In,0ut) :- true
exec(A,In,Ol), exec(B,In,02),
merge_result(01,02,0ut).
exec(A,In,Out) :- sys(A),var(In)
sys_exe(A,In,0ut).
exec(A,In,Out) :- is_io(A),var(In) i
Out=[A].
exec(A,In,0ut) :- not_sys(A),var(In)
reduce(A,In,Body,0ut,New0ut),
exec(Body,In,NewOut).
exec(A,[suspiIn],0ut) :- true l
wait(A,In,Out).
exec(A,[abortiIn],Out) :- true l
Out=[aborted].
wait(A,[resumeIIn],Out) :- true
exec(A,In,0ut).
wait(A,[abortiIn],0ut) :- true I
Out=[aborted].
The unique features of this exec are In and Out which connect the object level and
the metalevel, Note that I/O is handled as a message to the metalevel. Also, v a t ( I n ) is
the special predicate which checks the absence of messages in the argument variable.
The exec_server part which is in charge of other services can be expressed as follows:
exec_server(State,G,El,[successIE0],In,0ut) :-
var(In) I
0ut=[output([success,goal=S])].
exec_server(State,G,EI,[failure(R)~E0],In,Out) :-
var(In)
EI=[abort],
Out=[output([failure,reason=B])].
exec_server(State,G,El,[GliEO3,In,Out) :-
var(In), is_io(Gl) I
Out=[GliOutl],
exec_server(State,G,EI,EO,In,Outl).
exec_server(State,G,El,[undefined(Gl) IE0],In,0ut) "-
vat(In) i
0ut=[input([tmdefined_goal=Gl,expected_result?S,NG) ioutl],
GI=NG,
exec_server(State,G,EI,EO,In,Outl).
exec_server(State,G,EI,E0,[CIIn],Out) "-
true
112
control_receiver(C,State,G,EI,EO,In,Out).
This exec_server has six arguments. The first argument shows the internal state of
the metacall. The second argument keeps the initial goal, G, and is used for printing
computation result. The third and fourth arguments are connected to exec. The fifth and
the sixth arguments are used for communication to the system. When the exec_server
receives a success or failure message from exec, it transmits the message to the system by
adding the appropriate message. I/O messages are also forwarded to the system. When
an undefined goal G1 appears in exec, the exec_server sends the message to the user and
urges us to input the new goal, NG, which corresponds to the execution result. When the
exec_server receives a control message from outside, it invokes control_receiver.
exec and exec_server can be connected as follows:
call(G,In,Out):- truei
exec_server(run,G,EI,EO,In,Out),
exec(G,EI,EO).
Note that the pair of exec_server and exec works as a metacall as a whole.
3.1. W i n d o w
The window is usually created on a bitmap display and we can input and output
messages from there. For example, a window is created when create(window,X) is
executed. The input and output to the window are expressed as messages to stream
X. (The actual input is completed when we move the cursor to the window and type
in messages from the keyboard.) The virtual processes which correspond to devices are
deleted by instantiating X to [].
keyboard(Out,In) :- truel
Out= [ i n p u t ( [©] ,T) 1 0 u t l ] ,
keyboard(T,Outl,In).
keyboard(halt,Out,In) :- trueJ
Out = [ ] ,
In=[].
keyboard(T,Out,In) :- goal_or_command(T)
In=[TIInl],
Out= [input ( [@], TI) IOut 1],
keyboard(T1,0utl,Inl).
Here, the message input ( [©], T) outputs @first, and user's input will be entered into
T. Note that @is used as a prompt for user input.
db_server([add(Code) i I n ] , r e a d y , O u t ) : - t r u e ]
add_definition(Code,Done,Out,Outl),
db_server(In,Done,Outl).
db_server([delete(Name) lIn],ready,Out):-truel
delete_definition(Name,Done,Out,Outl),
db_server(In,Done,Outl).
db_server([definition(Name) IIn],ready,Out):-truel
definition(Name,Done,Out,Outl),
db_server(In,Done,Outl).
The db_server predicate has three arguments. The first is the input from the system.
The second is used to sequentialize database access. The third is the output to the system.
4. Building a p r o g r a m m i n g s y s t e m
We have already discussed the description of metacall and the handling of I/O in the
programming system. The next step is the construction of a programming system~ In
this section, we first describe the shell which plays the central role in the programming
system. Then we try to assemble these parts into a simple programming system.
114
4.1. Shell
The shell creates the user task or enters the program to the database, depending on
messages from the user. T h e following is a programming example for the shell.
The shell has four arguments; the first is the input stream, the second is the stream
to the variable dictionary, the third is the stream to the database server, and the fourth
is the output stream. This shell is connected to the variable dictionary where the user
can freely define variables and their bindings. This variable dictionary is a kind of user
interface and provides macro facilities. The shell program works as follows:
1. If the input stream is [], it means the end of input. All streams will be closed in
this case.
2. If goal (Goal) is in the input stream, Goal is sent to the variable dictionary. The
variable dictionary checks the bindings of every variable in Goal and creates NGoal
where every variable is bound to the current bindings. A window, a keyboard
controller, an exec_server and an exec are also created.
J she 1 1
fl
C exec ) C"exec ) Cexe¢ )
~/ ,~
Co~oo-~)C~oo-@ (proc--s)
000
I-n°o-I
Figure 1 Creation of processes in the shell
Corresponding to the input goal, four processes, exec, exec-server, keyboard controller
and window, are dynamically created.
Since the four processes each have their own window and keyboard, they can run
independently from the shell. The keyboard controller always sends the read request to
the window, and the user can input the control commands to the exec-server from the
window.
4.2. E x a m p l e of a p r o g r a m m i n g s y s t e m
This section shows an example of a programming system by connecting the components
described above.
create_world :- truel
create(window,Out),
keyboard(Out,In),
shell(In,Va,Db,Out2),
vr_dictionary(Va,[],Out3),
db_server(Db,ready,Out4),
merge4(Outl,0ut2,0ut3,0ut4,0ut).
This program can be illustrated as follows:
116
f'w i n d o w
l }-
Figure 2 A simple programming system
Here, we create the system window, keyboard controUer, shell, variable dictionary and
database server. We connect the outputs of the shell, variable dictionary and database
server to the system window, together with the output of the keyboard controller.
Since the keyboard controller always generates the read request to the system window,
we can input goals from it. Commands to the database server or variable dictionary can
also be entered.
Note that this shows just an example of a programming system. A more sophisticated
programming system such as distributed programming system is also possible.
exec(T,T,In,Out,Max/~C,RC) :- true I
Out= [success (reduction.count=RC)] .
117
express queue. If the express queue becomes empty, we simply return to the six-argument
e.~ec.
The next thing is to realize the reflective operations. Here, we consider four kinds of
reflective operations, get_rc, put_rc, get_q, put_q. These can be defined as follows:
check_rc :-true [
get_rc (MaxRC ,RC),
RestRC := MaxRC-I%C,
check(MaxRC, RestRC).
check(MaxRC,RestRC) :- lO0>=RestRC I
get_q(H,T),
input ( [reduct ion_ increment, @], AddRC),
NRC :-- MaxRC+AddRC,
put_rc (NRC),
T= [check_rc~exp INT],
put_q (H, NT).
check(MaxRC,RestRC) :- 100<RestRC I
get_q(H,T),
T= [check_rc@exp INT],
put_q(H, NT).
In a sense, these reflective operations are very dangerous because we can easily access
and change the internal state of the system. However, we can say that privileged users
119
must have these capabilities for advanced system control. Our current interest exists in
examining the reflective operations in a programming system. Thus, we assumed these
it reflective operations in a very primitive manner. The more sophisticated handling of
reflective operations can be seen in may [Tanaka 88].
6. Conclusion
In this paper, we discussed various factors in the programming system and showed
an example of such a system. Reflective operations in the programming system were also
considered.
You may have noticed that these program fragments are quite simple and declarative.
Their simplicity mainly comes from the extensive use of streams, processes and meta-
interpretation techniques. The clear separation of the meta from the object also makes
the system very clean. Note that the program fragments shown here are the extremely
simplified version. The more complete version, workable on DEC 2065, is available from
the author.
We would like to answer the question of why we need to research the programming
system now. Looking back on the history of parallel logic programming, we designed
the language specification first. Then we made interpreters and compilers. Now we have
started working on programming environments and applications for those languages.
It is clear that we can program easily in GHC. Techniques for parallel problem solv-
ing, such as in [Ohwacla 87], are very similar to those of parallel programming systems.
Research in parallel programming systems leads to research in parallel problem solving.
7. Acknowledgments
This research has been carried out as a part of the Fifth Generation Computer Project.
! would like to express my thanks to Yukiko Ohta, Fujitsu Social Science Laboratory, for
her useful comments. I am indebted to her for part of this research. I would also like to
express my thanks to Koichi Furukawa, Deputy Director of ICOT, for his encouragement
and giving me the opportunity to pursue this research.
References
[Bowen 83] D.L. Bowen et al., DECsystem-10 Prolog User's Manual, University of
Edinburgh, 1983
[Clark 87] K. Clark and I. Foster, A Declarative Environment for Concurrent Logic
Programming, Lecture Notes in Computer Science 250, TAPSOFT'87,
pp.212-242, 1987
[Foster 86] I. Foster; The Parlog Programming System (PPS), Version 0.2, Imperial
College of Science and Technology, 1986
[Foster 87] I. Foster; Logic Operating Systems, Design Issues, in Proceedings of the
Fourth International Conference on Logic Programming, Vol.2, pp.910-
926, MIT Press, May 1987
[Fuchi 86] K. Fuchi and K. Furukawa; The Role of Logic Programming in the Fifth
Generation Computer Project, in Proceedings of the Third International
Conference on Logic Programming, Lecture Notes in Computer Science
225, pp.l-24, Springer Verlag, July 1986
[Maes 86] P. Maes; Reflection in an Object-Oriented Language, in Preprints of the
Workshop on Metalevel Architectures and Reflection, Alghero-Sardinia,
October 1986
[Ohwada 87] H. Ohwada and F. Mizoguchi; Managing Search in ParalM Logic Program-
ming, in Proceedings of the Logic Programming Conference '87, pp.213-
222, ICOT, June 1987
[Shapiro 83] E. Shapiro; A Subset of Concurrent Prolog and Its Interpreter, ICOT
Technical Report, TR-003, 1983
[Shapiro 84] E. Shapiro; Systems programming in Concurrent Prolog, in Conference
Record of the 11th Annum ACM Symposium on Principles of Program-
ruing Languages, pp.93-105, ACM, January 1984
[Silverman 86] W. Silverman, M. Hirsch, A. Houri and E. Shapiro; The Logix System
User Manual, Version 1.21, Weizmann Institute, Israel, July 1986
[Smith 84] B.C. Smith; Reflection and Semantics in Lisp, in Proceedings. of in Con-
ference Record of the 1lth Annual ACM Symposium on Principles of Pro-
gramming Languages, pp.23-35, ACM, January 1984
[Takagi 84] S. Takagi, T Yokoi, S. Uchida, T. Kurokawa, T. Hattori, T. Chikayarna,
K. Sakai and J. Tsuji; Overall Design of SIMPOS, in Proceedings. of the
Second International Logic Programming Conference, UppsMa, Sweden,
pp.1-12, July 1984
[Taki 84] K. TaM, M. Yokota, A. Yamamoto, H. Nishikawa, S. Uchida, H.
Nakashima and A. Mitsuishi; Hardware Design and Implementation of
the Personal Sequential Inference Machine (PSI), in Proceedings of the
International Conference on Fifth Generation Computer Systems 1984,
pp.398-409, ICOT, 1984
121
Abstract
In this paper an algorithm for interpreting the parallel logic language GHC
(Guarded Horn Clauses) is described. The algorithm interprets full GHC programs
using several communicating processes, which do not share data objects. To control
unification and suspension, an integer (called commit value) is attached to each
external references. An implementation of the algorithm on a concurrent lisp is also
reported. This algorithm is applicable to conventional languages.
1 Introduction
In this paper an algorithm for interpreting the parallel logic language GHC (Guarded
Horn Clauses)Ill is described, and an implementation of the algorithm on a concurrent
lisp mUtilisp[2, 3] is reported.
In GHC, a clause is separated into the guard part and the body part by a commit op-
erator. Several clauses start execution for a goal-literal, and only one of the clauses which
succeeded to solve its guard part gains the right to affect the outer world (the environment
belonging to the caller). This is the fundamental mechanism to achieve synchronization
in GHC, and called commit mechanism. A clause which has not committed yet (not suc-
ceeded to solve its guard part) is not permitted to affect the caller's environment, and if
the clause tries to instantiate an unbound variable belonging to the caller, it is suspended
until the variable is instantiated by another clause.
There exists a subset of GHC, called Flat GHC (or FGHC), which allows only system-
defined predicates (e.g., arithmetic comparison) on the guard part. The execution algo-
rithm for GHC is quite different from that of FGHC, especially in unification. Because
the overhead of GHC is certainly heavy compared to FGHC, FGHC is regarded to be
enough for practice, and most implementations of GHC were those of FGHC[4, 5].
When we first consider the implementation of a parallel logic language by the interpro-
cess communication, we found that full GHC can be implemented without much effort.
So we decided to implement full GHC, and tried to found the basis for the comparison of
their overheads.
Our algorithm has the following characteristics:
123
1. The execution of GHC program is divided into several processes, and their interac-
tion (such as unification) is achieved by interprocess communication with messages;
In chapter 2, we describe the restriction for the language. The detail of the algorithm
is described in chapter 3. In chapter 4, our implementation on mUtilisp is reported briefly.
Various problems of the algorithm are discussed in chapter 5.
2. We support only list (cons) for structured data types. This restriction is not essen-
tial, and the addition of general compound-term is not so difficult to do.
3 Algorithm
3.1 Control
In our algorithm, programs are executed by communicating processes. To execute one
goal-literal, several clauses that match the goal start execution in parallel (called or-
parallel). And each goal-literal included in a clause is executed in parallel (called and-
parallel). Corresponding to those two parallelisms, there are two types of process: OR
and AND. Figure 1 illustrates a simple example of execution.
The followings are the control algorithm for OR and AND:
O R (argument: one goal-literal)
1. Collect clauses that match the argument. If no clause is found, go to step 6.
2. Fork AND as a child process for each clause collected in step 1.
3. Wait for reports of commitment from the children.
4a. If any child reports success, grant the child to commit, and tell other children to
terminate.
124
a:-b,cle.
a:-dle, a :-b_, , Ic II.. e
b:-e. 1""t .....
d. [! b :- e .I
e.
--[ ell
L'E'E'~ r':Ek3
:-a. -- ~ ~L~-- I~"Ul
i H, i,'
a :- d 1 e .!
Isuc( 'ed I
r d .I [ e .! [ failed I
Figure 1: Example of execution
3.2 Value
3.2.1 T y p e of values
Variables and conses occurred in a clause belong to the AND process which is executing
the clause. The process is responsible for the values of variables and the elements of
conses. There exist 8 types of value in a cell (figure 2):
(1) Unbound
(2) Unified with another cell (left value)
IXl--4- ? YLZ_.L.J
NN
local var local car/cdr local cons
3.2.2 R e f e r e n c e to a n o t h e r process
Pointers may refer objects in another process (as shown (2b), (2d) and (3c) in last section).
Such pointer (called external reference) is not implemented by direct pointer, in order
to prevent object sharing between processes. Rather, it is represented by a record of the
following four fields:
t y p e The type of referred object, which is one of four types RVAR, RCAR, RCDR and RCONS.
126
The first has a problem because it needs broadcasting. The second may send a message
to the processes which don't need the value. (For example, a clause which receives an
argument and passes it immediately to the subgoal does not need the value.)
We adopted the third strateg}: By the constraint to the direction of pointers, the
value of a variable chain is held by the variable belonging to the highest process.
3.3 Unification
3.3.1 Difference between FGHC and GHC in unification
GHC and FGHC differ most in unification. See the following GHC program:
This example means that the information necessary to determine the suspension is
distributed among the hierarchy of processes. Neither the process trying the unification
(p3) nor the owner of the variable (pl) can determine that by itself.
On the other hand, because FGHC does not allow user-defined predicate in the guam
part, there is no child for not-committed process. So the suspension is fully determined
by the state of the process trying the unification. That is, an attempt to instantiate an
unbound external variable in the head or the guam part of a clause causes a suspension.
3.3.2 C o m m i t Value
In order to determine whether a unification causes an instantiation or a suspension, any
external reference (to cell or structure) maintains an integer, called a commit value. A
commit value is the number of processes between the referring process and the referred
process that have not committed yet. (The status of referred process is not counted while
that of referring process is counted.)
In the example in 3.3.1, the variable Z of p3 refers X of pl. The commit value for
this external reference is 1, because p2 has not committed yet. Y of p2 also refers X of
pl, and its commit value is 1. In general, commit values that reference the same cell (or
structure) may differ if referring processes differ.
The commit value makes it very easy to determine the suspension. In a unification,
any instantiation of a cell which is designated by an external reference whose commit
value is not zero must be suspended.
The cell may be designated by a chain of references, not a single direct reference (figure
3). In such cases, the commit value for the cell is the sum of the commit values of the
references.
The commit value for a structure is provided to distribute it to the components. See
the following example:
[pl] a :- b ( X ) I . . .
[p23 b(Y) :- c([Y I nil]) I ...
[p3] c(Z) : - Z = [A I B] I ...
1. When a process delivers a term to the child as an argument of the goal literal, unless
the term is not atomic (i.e. not a number nor a symbol), the commit value for the
term is incremented. If the term is local to the delivering process, it should be
transformed into an external reference with commit value 1. (That is, the commit
value for a local reference is 0 logically.)
2. When a process commits, it must decrement the commit values of all external ref-
erences held by the process.
The separate execution of the guard and body (mentioned in chapter 2) plays crucial
role for the calculation of the commit value. An intermediate process (a process waiting
for its children to terminate) never changes its commit status while the execution of the
128
[p2] [p2] GD
,,,,J I '1
Figure 3: Chain of references Figure 4: Chain through a cons
leaf children. So once a process has received an external reference, the commit value of
the reference is valid until the process terminates.
And the restriction of the direction of external reference (in 3.2.3) is also very impor-
tant for the algorithm. When a process is about to commit, the process has no children.
So the commit values affected by the commitment are only those attached to the external
references held by the process.
3.3.3 E x a m p l e s of unification
Unification is divided into two stages:
[p2] I~
c!D
stage 2 (UNIFY) pS tries to unify Y with the result of stage 1, sending a message
to p2. p2 relays the request to pl, in which the chain of reference ends. p1 is requested
to unify the final value of Y (constant 3) with the final value of X <A of pl, commit value
is 0). Because the commit value is 0, the variable is instantiated to the constant 3, and
the reply of SUCCEED is returned to p3.
[example 2] See how suspension occurs during unification. Suppose the p2 of the last
example is not committed yet:
,J
~ ~ <1>
[pl] '* [pl] ~b, " <2>"
3.3.4 C o p y - u p o f cons
As mentioned in 3.2.3, all the external references must be from-child-to-parent. When a
pointer is created as a result of unification, its direction must be considered carefully. In
almost all cases this is easy because the direction of a link between two cells is determined
by the level of the cells. But the only exception is the case when a cell is instantiated to
a cons belonging to the lower process.
[pl] a :- t r u e [ b(X).
[p2] b(Y) : - Y I - - I , Y2=2 I Y=KYI I Y2].
This program unifies the variable X of pl and a cons of p2. (Those two terms are
indicated by boldfaced rectangles in figure 6(a).) It is inhibited to make a pointer from
X to the cons, because the pointer is from-paxent-to-child. To solve the problem, a new
cons whose fields are unbound is allocated in p1 as a value of X, and these two eonses are
unified in turn (figure 6(b)).
As a result, the cons of p2 was copied to pl, saving the data which will be necessary
after the termination of the owner process (p2). That may be seen as a local garbage
collection by copying.
t81
(defunwait-for ((protocols))
(cond ((msgq-lookup p r o t o c o l s ) )
(t (do ((msg (receive)(receive)) (action))
((memq (protocol msg) protocols)
(exit msg))
(setq action (get (protocol msg) 'g:protocol-action))
(cond ((null action) (msgq-inser% msg))
(t (funcall action msg)))))))
4 Implementation
A prototype for the algorithm is implemented on a concurrent lisp mUtilisp, mUtilisp is
an extension of Utilisp[6] to include concurrent processing. It has the following charac-
teristics:
Any lisp object can be used as a message. But it is copied in order to avoid sharing.
Message is sent by the function send with an argument specifying the receiver process.
No broadcast is available.
To receive a message, the function r e c e i v e is used with an optional argument desig-
nating the sender. If there is no messages to receive, the calling process is blocked until
a message arrives.
Our algorithm requires to receive only messages of specified types, such as the result
of the guard part. And furthermore, the message for termination or unification must be
received and processed at any time. Because the language does not support the selection of
message by its contents, function w a i t - f o r was defined (figure 7). The function receives
any message to the process, inspecting the type (called protocol) of the message. If a
message of specified protocol arrives~ the function returns it. If the protocol requires
instant action (e.g., termination), the function internally calls the appropriate service
routine.
The code contains about 700 lines in the form of lisp source. Although the current
implementation lacks arithmetic operations and input-output predicates, it processes fun-
damental GHC programs. The sample session is shown in figure 8.
132
F i g u r e 8: S a m p l e session
133
[pl]
[p2]
Figure 9: Copyup of multiple conses
5 Discussion
5.1 M a i n t e n a n c e of C o m m i t V a l u e s
As mentioned in 3.3.2, when a clause commits it must decrement all commit values held
by the clause. There will be two ways to implement that:
The former seems to be too naive, but it is not so bad because external references at.
the time of commitment are usually only those given by the parent as the arguments of
the goal.
On the other hand, the overhead of the latter will be heavy because there may exist
many requests of FETCHVAR or UNIFY from child processes.
(Certainly pathological cases exist; the following program is one of such cases.
[pl] a :-b([1, 2, 3 . . . . ] ) .
[p2] b(X) : - c ( X , Y) I . . .
[p3] c(L, A) : - L = [] I A = [ ] .
[p4] c(L, A) : - L - - [H I T] A = [L] A l l , ¢(T, A1).
When p2 commits, its variable Y holds a list which is composed from the list of p1. Each
cons in the list contains an external reference to the cons cell of pl. Notice that although
X of p2 points the list of pl, it causes only a single external refeience.)
5.3 Optimization
The current version of the algorithm lacks optimizations. One of the most necessary op-
timizations is the tail recursion optimization, or more generally the tail call optimization.
It saves the number of processes by not forking a subprocess for the last goal-literal
of a clause. The parent process itself executes the literal. But in our algorithm it is not
easy to implement this because even for the last literal there may be several clauses to be
executed in parallel (OR parallelism).
One of the solutions is to merge the child process for the last literal when it is about
to commit, because at the commitment only one child process can survive. The rest of
its clause (i.e. body part) is sent to the parent along with its local variables and conses.
Several problems are left such as the conflict of variable names, the overhead of process
merging.
5.4 Deadlock
Various program errors are often detected as a deadlock in GHC, so its detection is
necessary for a practical implementation. Although current implementation lacks the
detection, it will be not so hard to implement it.
Because the suspension of the process is implemented using the blocking by receiving
messages, the process never becomes runnable again until the suspension is released. So
if there exists no runnable process, it is considered that a deadlock has occurred.
If the suspension were implemented by busy wait (the suspended process itself exam-
ines the variable periodically), more complex method would be necessary.
It will be a good property for multiprocessors that no data is shared between processes.
But the implementation on multiprocessors is not investigated yet.
6 Conclusions
An algorithm for interpreting full GHC program is presented, and a prototype implemen-
tation of the algorithm on a concurrent lisp is reported.
The algorithm can be implemented on conventional languages, and has features suit-
able for multiprocessors.
A cknowledgement s
The author would like to thank Professor Eiiti Wada for giving us the opportunity to do
this work and Dr. Hideya Iwasaki, Mr. Tetsuro Tanaka and Mr. Koichi Konishi for their
helpful discussions and useful advices.
References
[1] K. Ueda: Guarded Horn Clauses, Logic Programming '85, E. Wada (ed.), Lecture
Notes in Computer Science 221, Springer-verlag (1986).
[2] H. Iwasaki: Programming and Implementation of a Multi-processing Lisp (in
Japanese), Trans. IPS Japan, Vol. 28 No. 5 (1987).
[3] H. Iwasaki: mUtilisp Manual, METR 88-11, Department of Mathematical Engeneering
and Information Physics, Faculty of Engeneering, University of Tokyo (1988).
[4] T. Miyazaki and K. Taki: Flat GHC Implementation on Multi-PSI (in Japanese), The
Login Programming Conference '86 (1986).
[5] K. Fujimura, M. Kurihara and I. Kaji: An Implementation of GHC compiler on the
LISP Systems (in Japanese), Trans. IPS Japan, Vol. 28 No. 7 (1987).
[6] T. Chikayama: Implementation of the Utilisp System (in Japanese), Trans. IPS Japan,
Vol. 24 No. 5 (1983).
[7] Y. Tada and M. Terada: Primitives for Testing Environment of Concurrent Processes
(in Japanese), IPS Japan WGOS, No. 33-2 (1986).
[8] M. Terada, H. Iwasaki, T. Tanaka, K. Konishi, K. Shirakawa and E. Wada: Imple-
mentation of GHC on the concurrent lisp (in Japanese), IPS Japan WGSYM, No. 44-3
(1988).
Inference Methods and Semantics
on Or-type Knowledge Bases
Hiroshi SAKAI
Information Science Center, Kyushu Institute of Technology
680, Kawazu, Iizuka, Fukuoka 820, Japan
ABSTRACT
Or-type knowledge is information which has some disjunctive conclusions,
for example, (AvB)<--C. We often face with this type of knowledge in our everyday
lives. There are several problems to deal with such type of knowledge in computer
systems. In general, it is difficult to represent the or-type knowledge in Horn logic.
In this paper, we extend first order formulas and define the interpretations for them
in a three valued logic. According to the discussion, a Horn clause is also extended
so as to deal with the or-type knowledge. We show a fixpoint theorem, the soundness
1. Introduction
Let us consider the following example in order to clarify the problem of or-
type knowledge. In reality, the following rulel is not a Horn clause, and this kind of
that if the place of his employment is in Fukuoka City or Kitakyushu City or Iizuka
City, his address is in Fukuoka Prefecture. The fact1 means Taro is on the staff of
KIT.
First we consider an aspect of logical semantics of our problem. In the above
example,
( fact2 ) place(taro, kitakyushu_city)vplace(taro, iizuka_city)
is logically true by the rulel and the factl, and
( fact3 ) address(taro, fukuoka)
is also logically true by the rule2 and the fact2.
Now consider the aspect of the formal inference on the same example. We can
formally infer fact2 by the r u l e l and the factl. However, neither
place(taro, kitakyushu city)
nor
place(taro, iizuka_city)
can formally be inferred. In this case, using the closed world assumption (CWA) [1]
would lead to a contradiction. Furthermore, in most logic programming languages,
the rule2 means that one of the following clauses holds:
address(X, fukuoka) :- place(X, fukuoka_city)
address(X, fukuoka) :- place(X, kitakyushu_city)
address(X, fukuoka) :- place(X, iizuka city)
Hence, formally fact3 can not be inferred. Some logically true facts can not be
formally inferred in this example. The logically true fact3 can not be proved by
using the SLD-resolution [2], either.
The importance of the or-type knowledge and the hardness of handling it
have been pointed out in [3]. Loveland [4] has also studied the related problems, but
has not discussed the semantics of his system. Lloyd [5] has studied a system which
allows any first order formula in the body of program clauses. However, he has not
discussed the head of the program clause. Incomplete information has also been
studied in [6,7,8], but these discussions are based on relational database theory, and
138
2. D e c l a r a t i v e S e m a n t i c s of O r - t y p e K n o w l e d g e B a s e s
In this section, we extend first order formulas, and give the interpretations
for the formulas. According to the extended formulas, an or-type knowledge base is
2.1. E x t e n d e d F o r m u l a s a n d T h e i r I n t e r p r e t a t i o n s
DEFINITION 1. An alphabet consists of the following classes of symbols:
(1) variables
(2) constants
(3) predicates
(4) connectives : "V", "A", "-1 ", "'~-" and "~"
variable or a constant.
DEFINITION 2. If p is an n-ary predicate symbol and tl ..... tn are terms, then
p(tl,"',tn) is called an atomic formula ( or an atom ). An atom that contains no
variables is called a ground atom.
Now, we introduce a set of formulas called elementary formulas.
DEFINITION 3. An elementary formula is defined inductively as follows:
(1) An atom is an elementary formula.
(2) If PI,"" ,Pm are distinct finite atoms, then P1;P2;"" ;Pm is an elementary
formula.
139
We denote the set of all elementary formulas by EF, and call an elementary
formula which does not contain variables a ground elementary formula. The set of
First order formula is a special extended formula, and in the rest of this paper
we use a "formula" instead of "extended formula". A formula which does not con-
tain free variables is called a closed formula. A formula with free variables is as-
sumed to be universally quantified, and thus we always consider only closed formu-
las.
e l e m e n t a r y formulas.
DEFINITION 7. An interpretation forground elementary formulas M is a quadruple
M = < D , F, I, ~I>,
where
D is a domain,
F is an a s s i g n m e n t from a constant to an element of D,
I is a subset of Base(D),
(4 is a relation defined in Proposition 1.
Since a relation ~ is u n i q u e l y defined by I, from now on we identify I with ~/.
DEFINITION 8. Let M be an interpretation for ground elementary formulas. For
the r e l a t i o n / i n M, Ker(D is as follows:
Ker(I) = { A EI 1there is no B( EI ) s.t. Atom(B)cAtom(A) }
Ker(M) is also defined as follows:
Ker(M) = < D, F, Ker(I), ~er(I) >
By Proposition 1 and Ker operation,
{ AEBase(D) IA is assigned T by the relation Ker(I) }
141
-~P PAQ T F _k
T F T T F _I_
F T F F F F
i i 'i i r i
~Q T F ± !P~Q T F ± PoQ T F ±
T TTT iT TF± T TF±
F T E l !F TTT F FT±
± T ± ± ± T ± ± ± ± ± ±
The logic defined by the above truth table is generally called Kleene's three
valued logic [9].
DEFINITION 10. An interpretation for formulas N is a quintuple
N=<D,F,I, 6j, p > ,
where D, F, I and ~/are the same definitions as in the interpretation M, and p is the
mapping in Definition 9.
142
From now on, we also use "interpretation" for "interpretation for formulas".
(1) (P<---Q)=(~PVQ)
(2) ( ~(PVQ))=('~PA ~Q)
(3) (~(P/kQ))=('~PV~Q)
(4) ((PvQ)AR) = ((PAR)v(QAR))
2.2. M o d e l T h e o r y o f E x t e n d e d F o r m u l a s
of P.
(2) An interpretation which assigns F to the formula P is called a negative model
of P.
(3) An interpretation which assigns _k to the formula P is called an incomplete
model of P.
For a n y formula P and a n y interpretation N, if the relation I in N does not
model orS.
(2) An interpretation which assigns F for some formulas in S is called a negative
model of S.
(3) Another interpretation, except (1) and (2), is called an incomplete model of S.
Ap~sP.
(2) An interpretation N is a negative model if and only if N is a negative model
of Ap(sP.
(3) An interpretation N is an incomplete model if and only if N is an incomplete
DEFINITION 14. Let S be a finite set of closed formula and P be any closed formula.
(1) We say P is a [] -logical consequence orS if, any positive model for S is also a
positive model for P.
(2) We say P is a ~-logical consequence of S if, there exists a positive model for S
and P.
consequence. The []-logical consequence defines some formulas which strictly hold
144
under the or-type knowledge. The <~-logical consequence defines some formulas,
which may be true in some cases.
{ P ]P is a [] -logical consequence ofS } __ { P I P is a ~b_logical consequence ofS }
for constants.
DEFINITION 15. Let N and N' be interpretations which have the same domain and
and the same assignment for constants. Let I a n d / ' be a relation in N and N', respec-
tively. We say N' is included by N if/'C_I holds, and denote it by N'CN.
EXAMPLE 5. Under the same conditions as in Example 1, take four interpretations
negative model of S.
[Sketch of Proof] By Proposition 2, any closed formulas can equivalently be trans-
(2) Any positive model N ( = <D, F,/, 4, P > ) for S assigns T to a closed formula
P.
We have only to consider the set Maxm(S,D,F) for the decision of a []-logical
consequence by Proposition 5 and Definition 14.
2.3. S e m a n t i c s o f O r - t y p e K n o w l e d g e B a s e s
Now we discuss a class of closed formulas.
DEFINITION 18. Or-type knowledge base is a finite set of closed formulas made by
substituting an elementary formula for an atom in Horn clauses.
146
C e--A1;A2;A3, B1;B2;B3.
If at least one element of A1, A2 and A3 hold, and
if at least one element orB1, B2 and B3 hold, then C holds.
PROPOSITION 6. Let S be an or-type knowledge base and suppose S has a positive
model. Then S has a positive model with the Herbrand universe US as its domain
and an assignment F for constants which assigns any constant to itself.
knowledge base.
DEFINITION 19. An interpretation N for an or-type knowledge base S is a quintuple
where
US is the Herbrand universe of S,
F is a constant assignment which assigns any constant to itself,
I, ~, p are the same as in Definition 10.
PROPOSITION 7. Let S be an or-type knowledge base, and
N = <Us, F , I , ~ , p >
be an interpretation for S. Then, an interpretation with a relation
NI(Maxr(S,U~,F) I
is a non-redundant positive model of S.
We denote the relation( = nI(Maxr(S,Us,I01~ by RS, and say the interpretation
NS( = < US, F, RS, ~Rs, P >) a least positive model orS.
Now we show the relation between RS and the [] -logical consequence.
THEOREM 8. Let S be an or-type knowledge base. Then
RS =Ker( { AeBase(Us) I A is a 5 -logical consequence o r s } ).
147
[Proof]
PROPOSITION 9. Two mappings [~]T8 and ~ T 8 are continuous, and there exist
least fixpoints of them. Furthermore,
Ifp([~3TS) = D T8 ~ ~,
Ifp(C>Ts)=~Ts ~ co,
ifp(5 Ts)Clfp( ~ T8)
hold.
[ Proof ] Similar to Proposition 5.1 in [2]. ,
= Ifp(• TS)
= • T s ~ co.
(2) { A EBase(Us) IA is assigned T by the relation Ifp( ~ 7"8)}
= {A~Base(Us) IA is assigned Tby the relation ~ T s t co}
C {A(Base(Us) IA is a ~-logical consequence ofS }
Base(Us)
/ ~<~-logicalconsequence~
In Fig. 1, (Rs)* and (<> TS 1' co)* imply the ground elementary formula assigned T by
the relation RS, and ~ TS T co, respectively.
[Proof]
(1) By Theorem 8,
RS =Ker( { AEBase(Us) IA is a []-logical consequence ofS } ).
Then, by Proposition 9,
Ifp([]Ts)= []Ts T co, lfp(OTs)= (~Ts ~ co, Ifp([3Ts)C_Ifp(~Ts)
R S -- nI(Maxr(S,UsgF) [
(2) is trivial. I
C: Q <-R1,R2,"',Rm,
as follows:
G' : <--(P1," ",P I-t ,R1,R 2, " ",R m,P t + I,"" ,P n)O.
3.2. S o u n d n e s s of t h e [ ] - r e s o l u t i o n
We show the soundness of the [] -resolution in this section.
S.
[Proof] The result is proved by induction on the length of the []-refutation.
[Base step]
In this case, G is a goal of the form ~P1, and there exists Q ( ( S ) and substitution 0
such that Atom(QO)C_Atom(PlO). Since Q0 is an instance of a unit clause of S, v(P10)
is a []-logical consequence of S.
[Induction step]
Suppose that G: e-P1,P2,"" ,Pro has a D-refutation of length k, and 0 1 , ,Ok are
substitutions. Since G has a [] -refutation, there exists a rule C,
C: Q e--RI~2,"" ,RI,
151
hypothesis,
3.3. C o m p l e t e n e s s of t h e [ ] - r e s o l u t i o n
We show the completeness of the [] -resolution.
THEOREM 14. Ker( []-success set ofS ) = RS.
[Proof] By Theorem 11, RS= [] TS ~ ~). By induction on the length, we show t h a t if
Atom(A) C Atom(B).
152
By Ker operation,
[Base step]
If A E [] TS 1' 1, then A is a u n i t clause and SU{*-A} has a []-refutation.
[Induction step]
IfAE [] T8 ~ k, t h e n there exist a rule C : Q ~- PI,'"Pm which satisfies (a) and
(b).
(a) There exist a substitution 0 such t h a t A = Q0,
has a [3-refutation. !
LEMMA 15. Let S be the or-type knowledge base, A be an e l e m e n t a r y formula. If
V(A) is a g-logical consequence of S, then there exist a [:]-refutation of SU{~A}
SU{~(Pi)0} with the identity substitution as the computed answer substitution for
4. D i s c u s s i o n
three valued logic, and discussed the declarative semantics, fixpoint semantics and
[] TS T co and the E] -refutation characterize the same class of formula. We have also
shown that the []-resolution can be used as a D-theorem prover in the or-type
knowledge bases. However, there are some problems to be solved.
(1) unification algorithm
ACKNOWLEDGMENT
I am deeply grateful to Prof. Setsuo Arikawa of K y u s h u University for his
constant support and encouragement.
154
REFERENCES
[1] R. Reiter : On Closed World Databases, In Logic and Databases, H. Gallaire
Eds., 1979.
[2] J.W. Lloyd : Foundation of Logic Programming, Springer-Verlag, 1984.
[3] Tanaka and Katsuno : Ko-sui-jun Database (unpublished manuscript in
Japanese ).
[4] D.W. Loveland : Near-Horn Prolog, Proc. 4th Int. Conf. on Logic Programming,
1987.
[5] J.W. Lloyd and R.W. Toper : Making Prolog More Expressive, Journal of the
Logic Programming vol.3, 1984.
[6] E.F. Codd : Extending the Database Relational Model to Capture More Meaning,
ACM Transaction on Database Systems, vol.4, no.4, 1979.
[7] W. Lipski : On Semantic Issues Connected with Incomplete Information
Databases, ACM Transaction on Database Systems, vol.4, no.3, 1979.
[8] W. Lipski : On Databases with Incomplete Information, Journal of the ACM,
vot.28, no.l, 1981.
[9] R.Turner :Logics for A rtificial Intelligence, Ellis Horwood, 1984.
A P P E N D I X " S i m p l e R e a l i z a t i o n of a [ ] - p r o v e r in Prolog
The following program is the or-type knowledge base in introduction. We
simply realized the following interpreter for the or-type knowledge base. We have
used the unification algorithm in Prolog.
Program
or2(stay(X, kitakyu), stay(X, iizuka)) :- staff(X, kit).
address(X, fukuoka) :- or3(stay(X, fukuoka), stay(X, kitakyu), stay(X, iizuka)).
staff(taro, kit).
Interpreter
box(X) :- write('START BOX RESOLUTION!!'), nl, X, unique(b(X)),
write('FIND BOX REFUTATION!!').
155
I ?-set.
READY, PLEASE ENTER BOX QUERY!!
yes
t ?-box(or2(staff(X, kyushu), staff(X, kit))).
START BOX RESOLUTION!!
FIND BOX REFUTATION!!
X = taro;
END OF BOX RESOLUTION!!
X = X;
no
i?-
ACCESS PROGRAM TO MINIMIZE REDUNDANT
REFUTATIONS ON THE NETWORK DATABASE SYSTEM
This paper presents how to generate access programs which get a l l answer s u b s t i t u -
t i o n s from t h e network d a t a b a s e w i t h o u t d u p l i c a t e r e f u t a t i o n s from Prolog goal
c l a u s e s and a Prolog view of the conventional network d a t a b a s e system. We show an
improvement of t h e Prolog r e f u t a t i o n procedure by taking advantage of the network
model. In our system, redundant r e f u t a t i o n s , which occur w h i l e f i n d i n g a l l answer
substitutions f o r given goals, are prevented in a d d i t i o n to preventing meaningless
backtracking to find one r e f u t a t i o n by i n t e l l i g e n t backtracking. We show t h a t our
system i s s u p e r i o r to the conventional Prolog system in performance.
1 • I NTRODUCTI ON
Tuples in N are navigationally accessed according to the ordering by the data opera-
tions, which correspond to the conventional DHL operations[19].
.... v-T
. . . . . .
@bl{
@p2 ~
+---+ . . . . . +
@p3 ~
@p
+_-_+ . . . . . + ÷---+
sp ] . . . . P. . . +I . . . . s. . . +l~ pb bp I b l p t
___+ _ _ _ + ] . . . b. . +] . . . . p. . . +[ .... + . . . . . + . . . . . . . +
t<Sb6>l<@p6,h>[ I<@bS>l<@p6,h>l+
+ . . . . . + ........
+ . . . . . + . . . . . . . +
?-s_E}~Pl,$sl). ? - ~ ( $ p 2 , ~ s l ) . . . . ?- ($pl,~s2). ?- ..
{spl) sp2) ~ ~('P2"s2) ' i
ca> 7- ,p(P,Y),sp(P,S t.
Is2>
(c) ?-p (P, Y ) , ~ . ?-p (P, Y), sp (P, ~s2).
s~l) / |sp2) lsp3) sp4) [spS) sp6)]
4. ACCESS PROGRAM
F i g . 6 P r o l o g Access Program.
(I>I<t
YE ?-(p(P, ?¥),pb(B,P),b(B),bp(B,?PP),
p(~PP,X)) Oo
1
b(...).
?-(p(P ?Y~,pb(B P~_,bp(B,?PP),p(?PP,X)) 81
1 I
• pb(...).
?- (P_~ _?Y_i,bp (B, ?PP), p (?PP,X) ) 02
Oa=e Ol=0o{B/c.} 02:01 {P/e~} p(...).
•
F i g . 8 Deduction by SP.
ST
<I <I IJ <I
~-§ b(B) ~-~ P) SC-~ ?Y) SC-~ ?PP) SC-~ X ) SC-~ OUT....
I
Fig.9 Access Program.
A rightmost cell which includes target variables in the access program is said to be
a target cell. In Fig.9, (4) is a target cell of a variable PP. There exists a func-
163
tion from (I) to (2). Bence, even if ~e backtrack from (3) to (2), (2) fails since
for every clause unifiable with (I) there exists at most one clause unifiable with
(2).
I....i iilil....iiill......iill......iiill......iliill......IT
ST ~ - ~ b(B) ~ - ~ P) SC-~ ?Y) SC-~ ?PP) SC-~ X) SC-~ OUT
Next, we try to get all answer substitutions without redundant refutations. Although
the access program S in Fig. 10 can find a refutation without meaningless backtrack-
ings by taking advantage of the underlying data structure, all the answer substitu-
tions cannot be obtained. After one refutation is found, the same backtrackings as
the Prolog program are required, ~hich are denoted by edges +++> as shown in Fig. ll.
For a cell A in T, suppose that there are n cells gz..... B, where A = parent(Bj) for
j=l ..... n. Let T~ be Sub(B,). Suppose that a substitution 6 A is obtained by the
resolution of A. Let Ans(B,) be a set of refutations obtained from Tj6A. According
to the property of T, any two T~8~ and TKS~ have no common uninstantiated variable.
This means that Ans(g~) can be obtained independently of other TK(k~j). In the
Prolog program, for each ASA, a cartesian product CAA= Ans(B~) x...x Ans(B~) is ob-
tained. Here, let T~ be a subtree which includes targets in Tt ..... T~ (k=1 ..... p,
pen). In our method, only a projection of CA~ on T~ ..... T~, i.e. AA~= Ans(B,~) x...x
Ans(B~) is accessed. Since it is clear that ICA~I ~ IAA~I, we can get all the answer
substitutions in less accesses to N than the Prolog program.
In one method to get CAA, each Ans(B~) is stored in the intermediate storage and
then the cartesian product is taken by accessing them. If Ans(Bj) is so small to be
stored in a main memory, the cartesian product can be efficiently taken. In a case
of database, since Ans(B~) is too large to be stored in the main memory, it has to
be stored in the files. However, only sequential access method is supported on the
intermediate files. So, we adopt a nested-loop method in which Ans(B~) is obtained
in the outermost loop ..... and Ans(Bn) is obtained in th e innermost loop, where
tuples are accessed in every loop.
T T,,~~
A general access program is one generated by the 6P, Fig. 13 shows a general access
program T for F i g . lO. Since tlast(T) is (4), OUT:SC-~ (4):NX. Since (4) =
nrjoin(3,4), (4):LFL-*(3):NX and (3):RSC~(4):FS.
; *+++++++; ; ; ++++++++++++++++++++~ +
+ + + +
5. EVALUAT I ON
t Prolog
Fig. 14 LIP
I'_!t-'I'_!_t-'t!:t-'I_!_I
->I!'_t-`I'_It
->I!:I-`I':t->I!,_t-`yt->Ii'`!I +
++++++++++++++++++3
+
For a g o a l G = ?-St(S,_),Ls(S,L),L(L,_),TI(T,L),T(T,_),Ss(SB,S),Sb(SB,?SNAME),
t69
. . . . . . . . + . . . . . . . . . . . . + . . . . . . . . . . { t GP1 J GP2 { P r o l o g
__+ . . . . . . . ÷ . . . . . . . +. . . . . . . +. . . . . . . .
I Our system { Prolog
. . . . . . . . + . . . . . . . . . . . . + . . . . . . . . . . {icount [ 511 16231 5621
icount I 609 1 48333 Itcount I 101 8801 1060
tcount { 88 { 880 tlctime t 8901 38941
ctime { 1321 t Iatime { 93221 253169{
atime } 34436 I letime I 10212{ 257063{ 178145
- - + . . . . . . . + . . . . . . . + . . . . . . . + . . . . . . . . .
6. CONCLUDII~G RHdARKS
system, This system is now operational on M-380Q. Users can retrieve data from the
network database system as if it were a Prolog system.
Our system cannot necessarily generate an optimal access program. We are considering
the method by taking usage of knowledge of database a p p l i c a t i o n e x p e r t s on access
paths. At p r e s e n t , we t r y to provide a t r a n s a c t i o n functions[23] which manipulate
the network database system atomically.
REFERFaNCES
Abstract
1. I n t r o d u c t i o n
In these days, logics play important and even essential roles in many fields like
mathematics, computer science, artificial intelligence, and so on. In fact, various logics
such as first-order, higher-order, equational, temporal, modal, intuitionistic, and type
theoretic logics are used in these fields, and human reasoning activities based on these
logics appear in daily work.
ttere the phrase "human reasoning" is used to denote the process consisting of the
following three phases.
173
We consider the following four as the system-types which can be used for assisting
human reasoning:
(i) reasoning assistant system
(ii) automated theorem prover
(iii) proof checker
(iv) proof constructor
In the rest of this section the reasoning assistant system is comparatively charac-
terized with other types of system. In Subsection 2.1 the reasoning assistant system is
introduced, and its characteristic features are exhibited. In Subsections 2.2 to 2.4, it is
compared with each of the other types of system.
2.3 P r o o f C h e c k e r
Figure 2.4 is an illustration of how the proof constructors are used. The user
interactively uses~ a proof constructor by entering some commands and tries to find a
proof of some theorem.
Many proof constructors have been developed up to now. For example, LCF [Gor-
don 79], FOL [Weyhrauch S0], EKL [Ketonen 84] and Nuprl [Constable 86] are well
known.
The purpose of Nuprl is very similar to ours. It aims at providing the proof con-
struction environment for various logics. But the approach to the realization of it is
different from those of the reasoning assistant systems. Nuprl has a fixed underlying
logic and other logics are defined by using the expressions in this logic. In the ap-
proach of reasoning assistant system, even the syntax of the logic is specified by the
user. It aims at the complete realization of logic free systems which can assist human
reasoning in the various fields. Proof construction methodologies are also different. In
Nuprl, proofs are constructed only by refinement, while in the reasoning assistant sys-
tem, proofs are constructed by three types of deductions; i.e. by forward, backward
(same as refinement), and interpolating deductions. The interpolation is a deduction
which fills a proof gap between two formulas. Another difference is on user-interfaces;
that is, Nuprl has been based on character displays, while EUODHILOS uses bit-map
displays so that symbols can be expressed as its natural shape on a paper.
The significant difference between the proof constructors and the reasoning as-
sistant systems is that in the former, underlying logics are fixed, while in the latter,
underlying logics can be defined by the user. There are merits and demerits for fixing
the underlying logics. As a merit, it is easy to introduce some specific procedures suited
to the logic. As a demerit, if the system is applied for general cases of human reasoning,
the fixation of logic may restrict the reasoning about some objects under consideration.
In such a case, a generM framework treating a variety of logics is required.
3. O v e r v i e w of E U O D H I L O S
The issue (1) is reflected to EUODttlLOS in its logic definition feature which is
shown in Section 4. For (2), it is implemented under the overlapping window system
with bit-map display. It can be used easily because most of the operations are achieved
by selecting the menu item with the mouse. For (3) and (4), the major tools used
in EUODHILOS are "editors." The user can modify the language definitions, logic
definitions, proof constructions, and so forth directly through the visual editor windows.
Considering the importance of the proof construction, the system provides a special
proof editing environment called "sheet of thought", which is an interactive, easy to
use, and visual proof constructor.
_EUODHILOS
,~-Logical System S h e e t of T h o u g h t
--Language System ~ ~
User
i IT1 I
'i' i i
Figure 3.1 shows an overview of EUODHILOS. The system consists of two major
parts, one for defining a user's logical system and the other for constructing proofs ill
a sheet of thought. The former is concerned with the second phase of human reasoning
discussed in Section 1. It provides the feature for defining the syntax of logical expres-
sions called (well-formed) formulas and the logical structure of the mentioned objects,
as well. The latter is concerned with a proof construction which corresponds to the third
phase of human reasoning. It is a proof editing environment, where the user constructs
the proofs by trial and error. On the sheet of thought, proofs are expressed in the form
reflecting their derivation structures. In EUODHILOS proofs are represented in natural
deduction style, i.e. a tree structure, they are shown in their familiar representation.
Among the various features of EUODHILOS, we put stresses on the following topics:
(i) Defining Logics
(ii) Constructing Proofs (Sheet of Thought)
In the following Sections 4 and 5, the features of defining logical expressions and
supporting to construct proofs on the sheet of thought are explained respectively mainly
based on the specification for the current (the first) version of EUODHILOS.
179
4. Defining Logics
Syntax description:
:formula('=>' (F1,F2))---+formula(F1), "=:>", formula(F2)
formula('h' (FI ,F2))-+formula(Fl), "A", formula(F2)
formula('V' (FI,F2))-~formula(Fl), "V", formula(F2)
formula( '-~'(F))-+"-~", formula(F)
formula (F)-+at omit_formula (F)
atomic_formula (F)-+" (", formula(F), ")"
atomic_formula (F)-+predicat e_symbol (P), "( ", term_list (TL), ") ",
{F:.. [PI TL] }
t e r m - l i s t ( [T] )-~t erm (T)
t e r m _ l i s t ( [T I TL] )-+term(T), ", ", t e r m . l i s t (TL)
term (T)-+funct ion-symbol (F) ,''(", term_list (TL), ") ", {T=.. [FI TL] }
term (T)-+variabl e_symbol (T)
term (T)--~const ant_symbol (T)
Operator declaration:
"~" : xfx, I00
"A": y:fx, 50
"V": yfx, 50
"~": fy, 30
Symbol declaration:
predicate-symbol : "p .....r"
function_symbol: "f ....'h"
variable_symbol : "x"-"z"
constant-symbol : "a"-"e"
Meta symbol declaration:
formula: "P"-"T"
%erm: "A"-"D"
Figure 4.1 A description of the first-order logic
In this format, each of the assumption parts is optionM. If a premise has the as-
sumption, it indicates that the premise is obtained under the assumption, and otherwise
it is obtained unconditionally. An inference rule may have a condition on the eigenvari-
able. An inference rule is applied if all the premises are obtained in this manner, and
the restrictive condition is satisfied. Then~ the conclusion is obtained by the application
of the rule.
Rewriting rules are presented in the following format:
Pre_Expression
Post-Expression
181
A rewriting rule indicates that it is applied to an expression when the formula has
a subexpression which matches to the pre_expression part of the rule. The resultant
expression is obtained by replacing the subexpression with the expression corresponding
to the post_expression part of the rule. Rewriting rules have no condition of application
in the first version.
Iterating the applications of the derivation rules described above, one can get a
derivation (tree). The following Figure 4.2 is an example of the derivation using both
inference and rewriting rules.
5. Constructing Proofs
(1) Connection
The user can connect two proof fragments if they have equal formulas, where one of
them must be a resultant of a fragment and the other a hypothesis of another fragment.
In order to connect the two proof
fragments, one selects the two formulas
by clicking them with the mouse at first.
One of the two is a resultant, and the
other is a hypothesis which must be equal [A] [A~B]
to the resultant. And then, he invokes B [A] [A~B]
the operation menu and selects the "con- B
nect" item. As the result, the proof frag- [B] c [D]
ments are connected into the one frag- C [D] E
ment. Figure 5.1 is an illustration of this E
operation. The two fragments in the left
part of the figure are connected at the for- F i g u r e 5.1 Connection at B
mula "B", and the fragment in the right
part is obtained.
(2) Separation
This operation is just the inverse of the connection. When the user indicates a
formula in a proof fragment and selects the command "separate" in the operation menu,
then the fragment is separated into two parts at the position of the selected formula.
Suppose, for example, we have a proof fragment like the right one in the Figure 5.1.
If we point the formula "B" in the proof fragment and select the separate command in
the command menu, then we can get the two proof fragments which appear at, the left
part of Figure 5.1.
•II~IIIILI
FONT
eq~tl
SO~_~'Y8OARD
SYNTAX zerm
--->
--->
"-':
b_~arm; let
IppI~ ----> "°';
REWRI T I N G - R V ~ I
4 5 b s'c O ) I~lll
I,. . . . . I
(AZB) ox-A. (B. X) M.X~X*X
('~bs'~ O ) • , (sbs'~ O)
(A~8) • (A,B) - A - (B • ( A Z B ) ) M . (A~B) - (AZB) • (A~B)
($b~z 0 ) ('~ b,~'c 0 )
. u (, o )
"'°' '' I!i
..x..
......
(A*I~D . x - A . (M-X)
(sbsz O)
III IIII
M,x-x-x
........... (,~bsz O )
I+ ]"llI H~,~
In order to make the system user-friendly and easy to use, we have to pay much
attention to the visualization of things. For this purpose, the bit-mapped display with
multi-window environment, mouse, icon, pop-up menu, etc. are exploited in the imple-
mentation of EUODHILOS. The followings are available as the user-interface facilities
for inputting formulas, visualizing formulas, and assisting reasoning.
The software keyboard and the font editor are used to design and input special
symbols often appearing in various formal systems. It is a matter of course that provision
of special symbols which reasoners a~e accustomed to use makes it possible to reason
in a natural way of thinking on a computer. The user designs the fonts of the symbols
in the dot matrix pattern of them by using the built-in font editor. These fonts are
assigned on the software keyboard and are used with the corresponding keys. In Figure
6.1, one can see a software keyboard on which user-defined symbols such as V, A, ~ , 3,
etc. are attached.
184
:i:!:i:i:i:i x O
~uamplal
=~nkax..~di~or name : =~
| i n f e r e n c e _ r u 1 e _ e d i ~or
| rewr~ing_rule.edikor
| axzom-a~i tor
I proof_mditor ~
:il/ l l ~ ~
• i .........................
I1 {FI )
....... ~L (F21
}roo~_eait=r
The first version of EUODHILOS is now available and the second version is under
development. The system is being improved by reflecting the experience of using it.
So far, we have dealt with logics, such as first-order logic (NK), propositional modal
logic (T), intensional logic (IL), combinatory logic, and Martin-LSf's type theory. Many
logics can be treated in the current version. Though, some logics such as tableau method
can not be treated in the current framework for logic description. We intend to extend
the framework so that these "irregular" logics can be treated in the system.
From the experiments so far in EUODHILOS, the followings become aware.
(i) Describing the syntax of logical expressions is difficult at first. But, by making
good use of the experience, it becomes easier. If the system keeps descriptions for
typical logics as a library, the description of a new logic is an easy task even for
beginners.
(ii) On a sheet of thought, users are free from deduction errors. On the paper, they
may make mistakes in deriving a new formula when deduction rules are applied.
The difference is important, because the users have to pay attentions only to the
decision how to proceed the proof on the sheet of thought.
186
(iii) The reasoning assistant system can be used as a tool for CAI. In the system, users
can deM with a variety of logics.
The current state is the first step toward the realization of a practical reasoning
assistant system. To put the step forward, we have to investigate various subjects
including the followings:
,, Treatment of relationships between meta and object theories
• Maintaining dependency relations among various theories
• Opening up various new application fields of reasoning
,, Improvement and refinement of human-computer interface for the reasoning system
The experiments with different logical systems have shown the potential and use-
fulness of EUODHILOS in the realm of logics appearing in various fields.
Acknowledgements
The authors are grateful to Dr. T. Kitagawa, the president of IIAS-SIS, and Dr.
H. Enomoto, the director of IIAS-SIS, for their ceaseless encouragements. We wish to
thank also to Mr. T. Hal for his contribution to our project and to Dr. K. Kobayashi
and Mr. Y. Takada for their many valuable comments on the draft of the paper. This
work is a part of the major research and development of FGCS project conducted under
the program set up by MITL
References
Abstract
This paper describes a method of Japanese morphological analysis
which runs in a sequential or parallel logic programming language.
In the method presented here, a morphological dictionary is compiled
into a logic program which executes lexical analysis deterministically.
Morphemes and their categories are written in a morphological
dictionary. The categories are used as inputs to a non-deterministic
finite state automaton (NFSA).
The dictionary is compiled into a TRIE structure in which mor-
phemes can be quickly looked up using an index search mechanism
such as those provided in logic programming languages like ESP or
Prolog.
The layered stream technique, which records search space in recur-
sively structured data, is applied in analysis. All solutions are given
at the end of analysis. The analysis output can be used as input to
the syntactic analyser, SAX, which can also be executed in parallel
logic languages.
This method cau process unknown morphemes which are not in
the dictionary in linear order. This paper also reports the evaluation
of this method in sequential languages.
189
1 Introduction
This paper presents a morphological analysis method which can be executed
both in parallel and sequential languages, tn this method, a morphological
dictionary is transformed into sequential logic programming languages, such
as ESP or Prolog, or parallel logic programming languages, such as GHC [8].
These programs analyse a sequence of Japanese characters deterministically
[7].
Each word entry in the dictionary contains the appropriate morphological
information. The analysis procedure in LAX can be regarded as the break-
down of the input Japanese string into a concatenation of sub-strings that
correspond to words with some constraints. This mechanism can be repre-
sented as a non-deterministic finite state automaton (NFSA) [5]. The layered
stream technique [6] is applied to obtain multiple solutions. This method
gives high performance both in sequential and parallel logic languages. The
method uses local ambiguity packing [Tomita 85].
Section 2 describes the form of the lexicaI dictionary. Each lexical entry
has the sequence of surface characters, a category, and two kinds of special
features: special constraints on concatenation and state transition. This
section presents the model of concatenation in terms of a NFSA.
The compiled dictionary has a TRIE structure [3], in which lexical entries
are searched for at high speed with the indexed search mechanism provided
by logic programming languages.
Section 3 presents an elementary parallel algorithm. This algorithm can
be regarded as a parallel version of Cocke-Kasami-Younger algorithm or the
bottom up chart parsing algorithm method [4] used for regular grammars.
Section 4 presents a practical algorithm which is obtained by optimising
one of the elementary parallel algorithms. In this algorithm, the number of
processes required is reduced drastically, and data structures of morpholog-
ical constructions are packed. All results are given at the end of analysis
without backtracking, and unknown morphemes can be found in the algo-
rithm. The results can be used as input to the parser SAX [10].
Section 5 describes optimisation for sequential implementations and sec-
tion 6 evaluates the sequential implementation.
190
2 Dictionary
string~:[m + u]
r ~i .... I vJ TM
In the traditional method [11], Cry. is defined as in line (3) and the
functions /e/tf and rightf are realized as in lines (5) and (6). Here, lefff
192
and righff will return a natural number. Setconnec t in line (3) consists of a
finite number of pairs (Pre, Post) where Pre E SLF(SLF C N) and Post E
SRF(SRF C N) (N is a finite set of natural numbers). In [11], the cardinality
of N is less than 300.
e {T,F} (4)
where rightf(morpheme~:[m])e N (5)
lef~r(mo~pheme~:[~])e N (6)
In this traditional method, the definition of Setco,,~a is difficult for gram-
mar writers to handle, since the same number occurring in sets SLF and SRF
will have different meanings. An element in Set~o~,,~a does not have anything
that makes it easy to handle. However, in the LAX system, we define the
functions righff and leftf, and predicate C~.1~as follows.
= T (7)
,~ leftf(mo~pbe~e~:[m])
~ight~(~o~p~em~ :[~]) c Sro~o (8)
lefff(morpheme~:[n]) c &oo~o (9)
Sf,~,~ in (8) and (9) is the set of morphological features which represents
the relationships between morphemes. In other words, C~le holds exactly
when rightf(morpheme~:[m]) and lefff(morpheme.:[n]) have only one common
element, as shown in line (7).
If the rules are of this form, the process of finding legal concatenation
in LAX can be formalized as a non-deterministic finite state automaton as
follows.
E a4 { x l x = smng,:[.]} (12)
6( ( q, st ingj : stri,g, :[,]) = U(righff(M),stringk:[mq-n]) (13)
M
where M e get_entries(string~:[n]) A Cr~¢(q, leftf(M))
6(q,¢) = (q, st J.go:[O]) (14)
6(q, z) = U 6(p,x) (is)
where q C K , a E a , x E a*
= @ 5(q,x) (16)
(q,input_string) es
whereSCK, xEa*,q6 F
Figure 2 shows the analysis of the Japanese word "N~5 ~ ~ " [itameruna]
(do not hurt: N~5 ~ = to hurt, ~ = do not). In this figure, the input category
Id,~ of the word stem, ~ (word stem of the verb "hurt"), is accepted in the
initial state, Sdi. Then, the next state is Sdi or Sdj. The next input character
is *5. leftf(*5) is accepted in the state Se~ and the next state becomes Sek or
F, that is, the final state. The next character is accepted in the state Sdk
and the next state becomes Syi or F. Sfz is the state in the inflection table.
The last input, ~, is accepted in the inflection table and the word ~ ~ is
accepted.
Inputs:
i~a me rH n&
\Input
"N~ateg°ry [
States \ v
// I
Idn Ido
Initial ~d~ Sdi V Sdj
!t
: I
Sdi . . . . 5'dk V F
Inflection
tabte
5dj ......... Sj~ v F
Derivation table
2.3 E x p a n s i o n of N F S A
The LAX system also provides a "handle" which allows the lexicon-writer to
build arbitrary data structures in parallel with the analysis.
The arbitrary data structures can be attached by assigning the function
shown in (19) to each element of Sf~atur+. This function enables us to attach
some data structures to < : and :::-->; using them, we can write programs
195
out(O) ~f O=info(righff(Morpheme))
When Crule('-~. , ~ : ) is true, information on the right-hand-side and
left-hand-side features is unified.
3 Elementary Algorithm
The elementary algorithm is executed by multi-processes which are layered
in a well formed substring table, as shown in figure 3.
In figure 3, the input string is ~ = ~ [i-ta-me-ru-na] (do not fry). In
this figure, a string of Kana is used as input to the LAX for expository
reasons. The characters are numbered from 1 (~) to 6 (the punctuation
mark 'o ').
Pij represents a search process. F1 to F6 represent the raw numbers of
table 3.
In the LAX dictionary, a process, pnc, looks up morphemes correspond-
ing to the string which starts from the character at R and ends at C-1.
For example, process p23 looks up morphemes which have ~: as the surface.
Search processes p12 to p67 can be executed simultaneously.
Each process is connected through streams (data paths) which the searched
morphemes are passed through. Outputs from the processes at column C are
merged to be the input to processes at raw C. For example, outputs from
p14, p24 and p34 are merged to be the inputs to p45 and p46; p14, p24 and p34
197
look up morphemes corresponding to the string which ends at ~6; and p45
and p46 look up morphemes corresponding to the string which starts from
~. Therefore, connecting these processes by a stream, we can concatenate
morphemes.
An outline of the elementary algorithm is as follows.
1. Activation of processes
,~-1 (n - 1)!
=
a ~+1 x (n - 1 - i)!i!
i=O
a(1 + a) ~-1
where a is the worst ambiguity of the morpheme and
n is the character length of the input sentence
4 Practical Algorithm
tz
i ~a me ru n&
o
1 2 3 4 5 6
F2NN
F3 N N
F4 )R p~
tz
i ~a me ru n&
o
1 2 3 4 5 6
Z dict p13 p14
F2 dict
F3 dict p35
F4 dict
, F5 dict
Surface Category
Word stem of the noun ~ (stomach)
[i]
wtc Word stem of the adjective ~i (sore)
[ita]
wtc Word stem of the verb ~ (to hurt)
[ita]
wtcg) Word stem of the verb ~')g) (to fry)
[itame]
~tc26 Word stem of the noun ~ (wood grain)
[itame]
Word stem of the nominal verb ~ (trust, to entrust)
[itaku]
[l,'~, word-stem-of-noun(~/)
[i]
[to, word-stem-of-adjective(@),
Ira]
word- stem-of-verb(~),
[&, word-stem-of-verb(#.)&),
[me]
word-stem-of-noun( )],
[<, word-stem-of-nominal-verb(~)]
[ku]
dict ( ~ , R , I) :- R = [HIRR],
I = [ [word-stem-of-noun(~)] fir] ,
(H,RR,Ir).
w (~,R,I) :- R = [H]RR],
I = [ [word-stem-of-adjective(~)] ,
[word-stem-of-verb(~)] llr] ,
~ (H,R,Ir).
~( .... []).
v,,'= ( m , R , T ) :- I = [[word-stem-of-verb0:p~5)] ,
[word- st era- of- a-noun (N [~) ] ] .
~ (< ,R,I) :- I = [ [ w o r d - s t e m - o f - n o m i n a l - v e r b ( ~ ) ] ] .
~,~ (_,_, []).
i ta me ru na o
1 2 3 4 5 6
dict p13 p14
•5".~ 4
\
F2 ~dict
\,
F3 "dict p35
\
F4 'dict
k
\
F5 ~dict
N
[2,[rightf(N)], [ ,word-stem-of-noun,[]]],
[3,[rightf( )],[ ,word-stem-of-adjective,[]]],
[3, [rlgh tf(f word-stem-of- verb,D]] ,
[4,[right@') 5 )], [t' ,word- stem-of- verb,[]]],
[4,[rightf( N )],[ N,word-stem-of-noun,[]]]
4.2.2 C o n c a t e n a t i o n w i t h d a t a packing
On receiving the inputs, as shown in figure 10, the 'diet' in F2 picks up data
whose position(datad~) is 2, and outputs data whose position(datad~J is
greater than 2 to the 'diet' in line F3. The 'diet' in F2 will check whether
the data picked up can be concatenated with a morpheme corresponding to
character strings starting from point 2. K there is no such morpheme, the
'diet' in F2 will output [] and stop. Otherwise, the ~dict' in F2 will work like
the 'dict' in F3.
The 'diet' in F3 inputs data as follows.
205
[3,[rightf(f~)l,[~,word-stem-of-adjective,[]]],
[3,[righff(~)],[~,word-stem-of-verb,[]]],
[4,[righff(~'P*5)],[~')*5,word-stem-of-verb,D]],
[4,[rightf(N H )],[~ ~,word-stem-of-a-noun,~]]
ieftf(inttect(~)) f~ rigbtf(word-stem-of-adjective(~)) ¢ ¢
teftf(~) fl rightf(word-stem-of-verb(~)) ¢ ¢
Then, the output from the 'dict' in F3 will be as follows.
[4,[~iehtf((*5)),[*5,inflect,
[ [~,word-stem-of-adjective,[]],
[~,word-stem-of-verb,[]]]]],
[4,rightf(~,)*5),[~')~,word-stem-of-verb,[lt],
[4,rightf(~N )),[~N,word-stem-of-noun,[]]]
(a) Do input(Data).
If Data is the tail of a data stream, do output(tail, Process2b) and
stop.
Otherwise, do output(Data,Process2b).
Go to 2a.
(b) The fiIstr process
Do input(Data).
If Data is the tail of a data stream, do output(tail, Process2c),
output(tail, Process2d), ou~put(~ait,Process2~), and stop.
If position(Datad.,J is equal to position(dicQ.,J,
do output(Data,Process o) and ou*put(Data,P ocess, ).
If posi~ion(Datad.t.) is greater than position(dictda~J,
do output(Data, Process2J.
Go to 2b.
207
"l Input j ~
IUnknown words
.......
filstr
I l 1--
. . . . . . . . . . . . . . . . I- ...
1 .... t
Figure 12: 'dict' procedure
208
5 Complexity
This section discusses the complexity of the elementary and practical algo-
rithms in sequential and parallel execution.
n--1 n
T = c ~ ( a i+~x , - l C i ) + E d j ( n - j + l ) (29)
~=0 j=l
= c x a ( 1 + ~ ) ~ - 1 + d ~ ( ~, + 1 ) ( ~ + 2)
6
wherea, n > _ l , c,d>O
o(r) = O(a n) (30)
and thus,
C l , C2, . . . , 0 o , C o + l , . . . , Cb , ..., C , ~ + l , . .. , C ~
1 2 i
209
T = cA. (31)
wheFc
I
A~ = EA~-, (k > 0 (32)
i=1
Ak = cak(k < t) (33)
where c > O, k > l
n--1 n
T = c~(ix(n-i) xa2)+~dj(n-j+l)
i=l j=l
= a 2 x (n 3 n) + dn(n + 1)(n + 2)
- -
6 6
0 = O(n 3) where a is the worst ambiguity of the morpheme and
n is the character length of the input sentence
1¢
i n-i
n t
T = c~a2+d~j(n-j+l) (34)
i=1 j=l
= C X a2 X n + d(1 + I)l/2 × n + K (35)
1 l
where K = - d ~ j ' +~ (36)
j=l i=l
0 = 0(~) (37)
210
• I n p u t : a string of n characters
• Output: the result of morphological analysis (a packed structure)
• First phase:
Make a stack vector of size n + 1, and set the right-hand feature of the
start of the sentence and left-hand feature of the end of the sentence to
the first and last positions of the stack vector, respectively. For each
number i (1 < i < n), do the following.
o Look up all the morphemes that start from the ith character
and register them in the stack vector at t h e / t h position. Each
morpheme has two kinds of features, the left-hand feature
and right-hand feature, and is represented as a list structure
with its tail unbound.
• Second phase:
For each number i (1 < i < n), do the following.
This result shows that the LAX sequential algorithm can analyse Japanese
sentences in linear order.
7" C o n c l u s i o n
This paper described the LAX algorithm, its time complexity and its imple-
mentation on a sequential logic based machine. It also reported the evalua-
tion of the result of analysis for two types of Japanese sentences. We believe
that there are two areas for further research. One is to refine the algorithm to
allow a more precise retrieval of unknown words. The second is to implement
the parallel LAX algorithm in terms of GHC.
A Sample Sentences
Extracts of the text F~ * ~ ~ J ("Nature Conservation")
214
B Result of Analysis
S a m p l e text: FR~'t'~J ("Nature Conservation")
References
[1] Akasaka, K., Sugimura, R. and Matsumoto, Y., "Chikuji
Shorikei-j8 deno LAX no Mondai-ten to sono Kaiketsu-h6"
("Problems in LAX in sequential implimentation, and their So-
lutions" (in Japanese)), Proceedings of the 35th Conference of
Information Processing Society of Japan, pp.1355-1356, 1987
[2] Aizawa, T. and Ebara. T., "Mechanical Translation System of
Kana Representations to Kanji-kana Mixed Representations"
(in Japanese), NHK Gijutsu-Kenky~t, Vol.25 No.5, pp.23-60,
1973
[3] Kamiwaki, T. and Tanaka, H., "Jisho no TRIE KSz6-ka to
Jukugo Shori" ("Idiom Handling Using the TRIE Structure
Dictionary" (in Japanese)), Proceedings of the Logic Program-
ming Conference '85, pp.329-340, 1988
[4] Kay, M., "Algorithm Schemata and Data Structures in Syntac-
tic Processing", TechnicalReport, CSL-80-12, XEROX PARC.,
Oct. 1980
[5] Mizutani, S., "Kokubunp5 ShibyS" ("Sketch of Japanese Gram-
mars" (in Japanese)), Bunp~ to Imi I, Asakura Nihongo K6za
No.3, Asakura Shoten, 1983
[8] Okumura, K. and Matsumoto, Y., "Layered Stream wo Mochi-
ita Heiretsu Pogramming" ("Parallel Programming using Lay-
ered Stream" (in Japanese)), Proceedings of the Logic Program-
ming Conference '87, pp223-232, 1987
[7] Sugimura, R., Akasaka, K. and Matsumoto, Y., "Heiretsu
Keitaiso Kaiseki System LAX no Jitsugen" ("Imprementation
of Parallel Morphological Anatyser LAX" (in Japanese)), Pro-
ceedings of the 35th Conference of Information Processing So-
ciety of Japan, pp.!323-1324, 1987
[8] Ueda K., Guarded Horn Clauses, ICOT Technical Report
No.103, 1985
2t6
Abstract
This paper presents a formalization of the summary generation process, which takes a set of observed
facts as input and generates its summary in the form of natural language text. Our assumption is that
human summarization process consists of the following four phrases : (1) reconstructing the original
semantic structure in his/her mind from observed facts, (2) extracting the characteristic facts from the
reconstructed structure, (3) constructing the surface structure of text in the macroscopic view and finally
(4) generating a natural language text from the surface structure. Our system generates newspaper-like
texts in the domain of baseball games. The implementation is also briefly presented.
1 Introduction
In this paper we present a formalization of the summary generation process, which takes a sequence of
observed facts as input and generates a summary in natural language text from the facts. We also present
a part of its implementation which is written in C-Prolog.
Among the wide current studies of text or story understanding, text summarization is one of the
difficult themes which require highly advanced processes of semantic analysis. In summary generation, the
mechanism to decide whether a fact is important or not is primarily significant. The following approaches
seem to be typical: (1) an approach based on the frequency of key words, (2) an approach based on scripts
[7], (3) an approach based on the connective relation between sentences [2,8], (4) an approach based on
the story grammars and rules for summarization [6]. We assume that the human process of extracting
characteristic facts can be described only with semantic information manipulation. Therefore we focus on
semantic information processing and consider the input information, which is a series of facts (we will ca~
this facts observation), to have no surface structure. And we restrict the domain of summarization to be
so small that sufficient understanding and deep inferences can be performed for as many cases as possible.
Our system basically uses summarization rules in the extraction process. However, there are some text
generation systems which decide the degree of refinement of generated texts with the importance decision
mechanism based on semantic analysis [1,3]. In our system the semantic information is represented in
networks. We aim at construction of the human model of interest~ the importance decision mechanism and
the summarization model by arranging all of the networks.
The world to which we apply our summarization system is that of games with wins and defeats,
especially the world of baseball game. The reasons why we chose this are the overall goals of a group
218
(to win the game, to hit a ball at a chance, to defend at a disadvantage) is obvious, it is possible to
appropriately formalize the game by simplifying rules of baseball and suificient inferences axe possible in
the small domain.
Our aim is to generate sentences in aewspaper-hke style which we think it is easy to deal with outwardly,
not only because we want to lighten a burden on the generation process but aJso because our final object
is to build a sports journalist robot who can write news from the scorebook of a game.
In chapter 2, we present a formalization of the extraction process in the most abstract model, and we
extensively study the model of human interests, the existence of a reader and the hierarchy of semantic
representation. In chapter 3, we concretely reconsider the extraction process again for an implementation.
Especially, we study the similarities of our importance decision mechanism with the connectioulst model.
In the final chapter, chapter 4, we present an implementation of our system and some inner representations
of knowledge or information. We also explain each sentence of generated texts.
In this chapter, we present a model of the human summarization process which comprehends a sequence
of facts and generates a text as a summary.
2.1 A m o d e l of e x t r a c t i o n
First, we study the process of summary generation and present a model of extraction.
Given information about a series of facts~ we divide the summary generation process into three phases.
2. Transformation to "the macroscopic structure " (the surface structure) and the text planning: We
will call a structure stating assertions of a mass (members participate in events) in the macroscopic
view "the macroscopic structure '~. The macroscopic structure is reconstructed from facts of each
element in order to generate more natural sentences. In our objective world, the world of baseball
games, structures collectively describing a movement of a team or describing win or loss of a team
are macroscopic ones, whereas descriptions of each member's movement are microscopic ones. Topic
of paragraphs or documents correspond to such structure.
3. Generation of surface sentences: We consider the text generation phase as an isomorphism except for
a rhetorical transformation.
We define the process of the extraction of characteristic facts as in Definition 1. In the definition,
each domain of discourse is a set of information, more concretely speaking, which corresponds to a set
of assertions and rules about facts. And we think the deletion and the extraction of information are
219
influenced "persona] interests'~ so we deal with human interests as a parameter in the process of the
summary generation.
1. Let F be a set of information about series of original events to be considered, the act of observation
is an apphcation of the function o to F. We define the result O to be an observation.
o = 0(F)
R = r(O, K)
3. The set S of characteristic facts is constzucted by an application of the function s to the reconstruction
/ / a n d paxameter P of human interests.
S = s(R, P)
In our apphcation of this definition, the knowledge K of an objective world consists of rules of baseball,
some information about each player and so on. The outline of the summarization process is shown in Fig.1.
Though we wi~ mention in more details in section 3.1, the input of the system is currently the observation
O.
Let us consider "the quantity of knowledge" as the number of assertions in a domain, where each
element is an assertion for a knowledge. Fig.2 shows the domain and the region of each function (i.e. set of
origiital events F, reconstruction R, observation O and characteristic facts S). Next, we study the relation
of each domain.
1. The observation O is included in the set F of original events, because O has less information than F.
OCF
2. The reconstruction R has more information than the observation O because R is made from O by a
supplementation of some obvious facts.
OCR
From Fig.2 we find the followings. (O, R stand for the complement set of O, R, respectively.)
S N O is the important information from the observation.
R N 6 is the important information supplemented by the inference and is obvious to the observer.
220
function o
(
Fig.2 Inclusion relation }n the domain
M = m(S, P)
The parameter P of human interests indicates what standpoints the macroscopic structure is viewed
from, for example in a baseball game, P is used to indicate whether one scene is favorable to one team or
not favorable to the other team.
The parameter of human interests, which appeared in Definition 1, is referred at the characteristic facts'
extraction and the transformation to the surface structure. This parameter was introduced to model the
human interests (or view points) which a man referes at writing text from a series of events. Hereafter, this
we will call this model She model of(human) interests, or simply interests. The model of human interests is
221
represented by a set of items about what the man is interested in. The model of human interests depends
on the objective world of summarization. Also, there are some common interests among people and some
kinds of personal interests of a man who generate summaries or surface structures, although both view
points are not strictly distinguishable. We show an example model of human interests, which is represented
in natural language. The items are selected for the summarization of baseball games, and ace partially
implemented as rules of a production system.
[The m o d e l of h u m a n interests]
In this model, (1) seems to be common interests among almost people. (l-d) and (l-e) relate to a
method in which events not matching a script iemain in the summary. We thought, items in (2) represent
a personahties of the writer who 5kes/dislikes a specific team. On the other hand we can say that items in
(2) also represent common interests in a sense the he has favorite/notfavodte particular one team. In this
sense we can think of models of specific interests focused on runnings or, extremely speaking, the second
base. In actual newspaper articles of professional baseball league, victory in a season and the record of
players usually become a major subjects of discussion. To generate newspaper-like texts, more precise
models of interests are necessary, in which time transitions and the relation to other games have to be
taken into account. However we left these p~oblems to be future works.
The process told in Definition 1 proceeds from the inference of original events to the extraction of character-
istic facts. We think such a process of summarization corresponds to one in which the summary writer has
222
his own standards of extraction and he doesn't recognize the existence of a reader. On the other hand there
may be another style of summary generation, i.e. the summary writer has a reader model and through the
model the writer proceeds with the summarization while he is considering reader ~s ability of Ieconstructing
the points of original events from the summarization. In this section we present the summarization process
with areader model.
At first, we abstractly redefine Definition 1. Let i be a function which has the domain and the region
both on the world of knowledge K(R, O, S E K) and infers a set of information as much as it can infer.
Conversely let s be a function to get summaries from a set of information.
i,s:K~K
Then the process of Definition 1 can also be represented by the following way:
where the writer generates summaries on the base of his interests only.
Now
R' = i( S)
S'= s(R')
represents one more summarization from the re-reconstruction.
We next dei~ne a function s~ which repeats reconstructions and summarization n times.
s0(x) - s(i(x))
~÷1(*) -~ s(i(s,(*)))
s~ - ~ . ( o )
Fig,3 represents the model of summarization process considering the existence of readers. In this
summarization model the summary writer knows the existence of readers, ltowever, the writer thinks
readers are interested in the same points that the writer has and readers can infer in the same way that
the writer does.
We can study more precise models of summarization. For example, distinguishing interests of a reader
(or the knowledge of a reader's world) from that of the writer will make a model with more ~espect for
readers. In these summarization models deletion is the only operation, however, summaries are to be
polished not only by deletion of information but also by restoration of deleted information. To formalize
the restoration, extension of inference mechanism, such as ~eference to the reconstruction R which is the
information with no deletion performed, is necessary.
223
inference i
summariaztion s
2.4 T r a n s f o r m a t i o n to m a c r o s c o p i c s t r u c t u r e
Each event in the reconstruction of original events were described separately. However, the information
represented by several sentences usually can be processed together. Moreover, when the summarization
process has finished, the whole text is often gathered into one sentence. Thus there is an hierarchy in
representation level. We call this hierarchy the hierarchy of representation. We divide this hierarchy into
three levels.
1. fine description level: each sentence in the text summarization and each player's movement in our
application.
2. middle description level: a summary fo~ one paragraph in text summarization and topics in a game
in our application.
3. inclusively description level: a theme in the text summarization and win or loss in our application.
In this chapter, we formalize more concretely ~he obsezvation which is the input of the system, the inference
process of original events and the extraction process of characteristic facts.
At first, let us define what is the input to be summarized. A series of events to be summarized is a sequence
of facts in which a group cooperates to accomplish a goal, for instance to win a baseball game. The input
is defined as follows. This is called set of events observation.
224
Definition 3 (Observation)
1. An evenl is a triple of a time point, an agen$ and an action. Therefore the domain of event is
where Tp stands for an ordered set repiesenting time points (this relation is denoted by e.g. t l < t2),
Ag¢ stands for a finite set of agents and Act stands for a finite set of actions.
In our system, which deals with the world of baseball games, Agt corresponds to a set of players of
both teams, and Act to a set of simplified action.
Note that all facts that occurred in the objective world axe not entered into the system. The sequence
of events is entered into the system through some kind of means such as an observer. In this style of
input we must recognize the existence of a filter on the objective world. But viewing the observation as
abstractly represented original events, we take the existence of a filter as a future work.
In this section we define the form of semantic network and the inference process for original events as a
N=WUD
K = (N', L')
there exists an event node n a m e d e, and the initial semantic network/to = (No, L0) h a s the following links.
for the event (tp,agt, act) where time points of state nodes sl and Si+l correspond to tpi and tp~+~,
respectively.
these events as one event. Trivial facts and inferable facts from other facts are usually o m i t t e d from
t h e observation when given as an input. Bu*, we a s s u m e t h a t facts represented as a group include all
exceptional related fa~ts. This is because exceptional related facts are difficult to reconstruct. Therefore,
there is no inference for g~oup facts (Definition 6, 3-a).
For a initial semantic network Ko = (No, Lo), we define the process o£infexence as a construction of
semantic network
K = (N', L')
according to 2 a n d 3 given as follows.
to each state node in the initial semantic network K0, where function S~* = fs(e, s~-l) maps occurring
event e and state s~-l*, which is the state before event e occurs~ to next state. And
(si-l,uex~,s~) e Lo.
3. Replace event node e in the initial semantic network Ko by a set of node re(e, si), where sl stands for
a state before event e occurs (which is indicated by a link named s~a~eB), and function fe is defined
as follows:
(b) Otherwise
re(e, s~) = {events derived from even~ ¢ a~ s~a~e s~}
Fig.4 show an example semantic network in our application. Some of the node names and link names
which are specia~y used in the net are explained as follows.
1. nodes
event~N represents an event node.
state~N represents a state node related to an event.
team~N represents an object at middle description level.
game~N represents an object at inclusively description level.
other atoms
2. links
effect links an effected node.
cause links a cause node.
other case labels
The situation presented by Fig.4 is as follows: at second half of the first inning, when Shinozuka and
Matsumoto are on the second and the third base, respectively, batter tiara makes a timely two base hit,
then Shinozul~ and Matsumoto come back to home base and turn the table to score 1-2.
Note that this scene is extracted as a cha~acterlstic facts because turning the table is in the model of
1-0
• [2:shinozuka,3:matsumoto]
In this section, we formalize the extraction process of characteristic facts. The principle of extraction is
based on weighting on the network: ]) Select significant items according to the model of human interests
mentioned in section 2.2 and give them initi~, vaaues of importance, 2) Compute new value of importance
for each node by summing up the multiplication between values of importance of those nodes which connect
to the node and the predifined weights of links between them.
K = (N', L')
is defined as follows.
po:N~R
agent~is a
the giants
( " rnm~home
ag~sa~
' ~ ~ shin~oVzuka
2nV~a gethome
Fig,5Anexampleofsemantnet
ic work
inmoremacroscopivicew,
For each link (u{, l, nj), let the weight of the ]ink be
4. when
tp~+~(~) - p~(~) i2<
for some threshold number 5, we define pro(u) to be the importance decision function p(n) for semantic
network K = (N', L').
We ca~ think our extraction mechanism of characteristic facts on the connectionist model. Making
importance factors correspond with activity levels on neural net, the computation of importance decision
function p is very similar to that of activity level of connectionist model. On the other hand, we use the
model of human interests to initialize the importance factors, however, assignment to the weight of hnks
is also thought to be a kind of the model of human interests. These problems are left to be further works.
229
In order to generate natural and readable texts, transformation flom microscopic description to macroscopic
structure and how to make that structure into text (planning) is very important. So far, we considered the
extraction process and the transformation process separately. However, in the implementation, it is more
effective to use the information obtained at the extraction of characteristic facts for the transformation
to the macroscopic structure or planning. Moleover, theoretically, we think that such transformation to
macroscopic structure has its meaning in the process of extraction. Because of these reasons, formalization
is not sufficient. In chapter 4 we will show several examples of the transformation using experimental
results.
Fig.5 shows a transformed macroscopic structure obtained from that of Fig.4. In Fig.4 events are found
on the focus of each player, but in Fig.5 the view point is moved to higher level, i.e., the team level, where
~he agent of the representative event (event#1000) is a team (team#]0). Fig.5 corresponds to the sentence
"The Giants turned the table by ttara's two-base hit ..."
4 I m p l e m e n t a t i o n and e x p e r i m e n t
In this chapter we present our summary generation system based on the formalism shown in chapter 2, 3,
and we also present texts generated by the system from observations of (imaginary) baseball games.
4.1 Implementation
Our system is built on a Prolog system and the semantic network is represented in DCKR [5]. An example
of network in DCKR is as follows, which corresponds to event#6 in Fig.4. ~#' and ':' found in the followings
are infix operators (xfx) with precedence 200 and 250, respectively.
Searching is quite simple by DCKR representation, such as omission of inverse links. Note that our
DCKR representation is simple because searching doesn't need any complex operations on the isa hierarchy.
Rules of inference for the reconstruction (Definition 4,5,6) are written in production rule format and
we implemented a very simple production system for them. The format of the rule is
pattern on the semantic network is written in a conjunction (or disjunction) of prolog clauses in
DCKR format, and t r a n s f o r m a t i o n on the network is mainly to assert a new relation of objects. Even
230
though for simplified baseba~ rules mentioned in section 3.1, production rules are so comphcated that we
will not mention them any more.
We defined the importance decision function in Definition 7 and mentioned the relation to the connec-
tionist model, however, the function has not yet implemented.
Grammar for the generation of surface sentences consists of about 40 DCG rules, whose nontermi-
nal symbols have difference lists and a pointer to a macroscopic structure on the semantic network as
parameters.
1. Common view points of human interests (eg. score or the issue of the game).
4. Importance decision function (i.e. weights of links and initial values of nodes).
Here we have implemented two models of interests as common view points, that is 1 in the above list.
Other parameters are not implemented so the system generate summaries at the neutral standpoint and
pays no attention to the summary readers.
[ I n t e r e s t s 1]
2. same points
3. getting ahead
6. home run
[Interests 2]
2. winning hit
4. home run
231
represents that %romatie ~ was put out and ~'yoshimura" was also put out on the second base (out(2)) at
time point 28.
Prolog clauses given below are two parts of the observation, the former represents a defense of "Hanshin"
team at first half of the first inning, the latter represents that of ~Giants ~ team at second half of the third,
respectively.
The input to our system is the observation of the following form only, and information such as "first
half of the first inning" is inferred automatically by the system. We made experiments for three more
imaginary games. (cf. Appendix A)
In this chapter we present two results by two models of interests (shown in section 4.2) f~om one (input)
observation and explain some expression generations. Because texts generated are in Japanese, we give
232
word-to-word translations of the outputs. The originals in Japanese texts are given at Appendix B. The
time taken to generate texts for one model is about four minutes (in elapsed time, Suu-3/140, C-Prolog
Interpreter). Results from other three inputs are also given in the Appendix A.
Note that the generated text by Interest 2 is shorter than by Interest 1, because there is less items in
Interests 2.
Sentence (1) is a macroscopic expression for the whole game.
Sentence (2) represents a situation from "home run" view point. Because the system has no interests in
"same points" and "getting ahead" view points the situation occurred before this situation is not extracted.
Sentence (3) represents a situation f~om "turning the table" view point.
In sentence (4) "settled the game by ... Hara's home run" ( r ~ ¢ ~ 3 ~ > " ~ ' ~ . j ) represents a
situation f~om "winning hit" view point. Note that in Interests I this situation was extracted from "turning
the table" view points so the surface sentences in both Interests are different.
In this paper we have formalized the summarization process, that is reconstruction of the original events
f~om an observation and the extraction mechanism of characteristic facts. And we have also presented our
summary generation system and explained the transformation to the surface structure through generated
texts. In those texts, considerably advanced expressions are found. The reason seems to be that by
limitation of the objective world to baseball game, goals of each event in the world are clear, that decision
of connectives between sentences are simple because, for instance, advantage of one team is disadvantage
of the other, and that the system can cover almost all of transformation to surface structures.
Some processes axe not fully formalized and implementation has not completed. Finally we collect these
problems which are still left to be further research.
1. Investigation and formalization of the transformation to macroscopic structures and the planning.
2. More realistic model of human interests. In actual newspaper scripts of base ball games, contents are
selected not only by events in one game but also by events in the past games. How does the system
use such an information ?
3. Investigation of the existence of readers. We must study the convergence of ~polishment ~model when
the system distinguishes the world of summary writer and readers.
4. Relation to the connectionist model in the extraction process. How does the system assign initial
values to nodes and weights to links in the importance decision function ? Convergence and so called
local minimum must be investigated.
5. More natural sentence generation. Because of poor grammar, only stereotyped sentences are gener-
ated in our system. Not only newspaper-like style but also any styles of sentences would be generated.
Pronominalization, omission of subjects and varying sentence styles are also important.
6. Investigation of the relation between the parameter of human interests and texts generated.
234
Acknowledgement
We are grateful to Prof. Hozumi Tanaka of the department of computer science, Tokyo Institute of
Technology and members of artificial intelligence research group AIUEO fo~ their valuable suggestive
opinions.
Bibliography
[1] K. t~asida, S. Ishizaki, and It. Isahara. A connectionist approach to the generation of abstracts. In G.
Kempen, editor, Natural Language Generation, pages 149-156, Martinns Nijhoff Publishers, 1987.
[2] J.R. Hobbs. Coherence and coreference. Cognitive Science, (3):69-90, 1979.
[3] Kakiuchi, Makimoto, Uehara, and Toyoda. Explanation generation on manualless system. ICOT NLS
WG, 1986.
[4] K. Kita, E. Komatsu, and H. Yasuhara. Summarization support system, cogito. Preprints Work.Gr.for
Natural Language Processing, 1986. IPSJ, 86-NL-58-7.
[5] It. Koyama and It. Tanaka. Definite clause knowledge representation. In Logic Programming Confer-
ence.'85, pages 95-106, ICOT, 1985. (in Japanese).
[6] D.E. Rumelhart. Notes on a schema for stories. Academic Press, 1975.
[7] R. Schank and R. Abelson. Script Plan8 Goals and Understanding. Lawrence Eflbaum Associates,
1977.
[8] K. Uchiumi and M. Shigenaga. Abstract generation of english text. Preprints Work.Gr.for Natural
Language Processing, 1986. IPS3, 86-NL-54-8.
[Game 2, Interests 1]
Hanshin won by one side game. At ~rst half of the first inning with no out~ Hanshin gained the tlrst
one point by Mayumi's hit, Mayumi's advance to the second base during Tao's out and Kakefu~s timely
two-base hit. Also at first half of the third inning, Hanshin added three points by Tao's walk, Kakefu's
two runners home run and Bass's home run. At second half of the third inning with no out, score 5-1,
the Giants loaded bases by Egawa's hit, Shinozuka's hit and Yoshimura's walk, but lost t]~e chance by
Cromatie's strikeout. At the last inning with no out, score 5-1, Hanshin added one point by Bass's home
run.
[Game 2, Interests 2]
Hanshin won by one side game. At first half of the first inning with one out, Hanshin settled the game by
Kakefu's timely two-base hit and Bass's timely hit. Also at first half of the third inning, Hanshin added
235
three points by Tao's walk, Kakefu's two runners home run and Bass's home ~un. At the last inning,
ttanshin added one point by Bass's home run.
[Game 3, I n t e r e s t s 1]
tIaushin shut out the Giants by pitcher's game, such as Ikeda's three strikeouts at the third inning and
Egawa's three strikeouts at the fifth inning. At first half of the first inning with no out, tIanshin got the
first point by Mayumi's hit, Maynmi's advance to the second base during Tao's out and Kakefn's timely
two-base hit. At ssecond half of the first inning with no out, score 1-0, the Giants lost the chance by Itara's
strikeout in spite of Matsumoto's hit, Shinozuka's hit and advance to the third base during Yoshimara's
out.
[Game 3, Interests 2]
Hanshin shut out the Giants by pitcher's game, such as Ikeda's three strikeouts at the third inning and
Egawa~s three strikeouts at the fifth inning. At first half of the first inning with no out, ttanshin settled
the game by Maynmi's hit, Mayumi's advance to the second base daring Tao's out and Kakefu's timely
two-base hit.
[Game 4, Interests 1]
The Giants won by one side game. At second half of the first inning with no out, the Giants added
four points by Matsnmoto's hit, Shinozuka's hit, Matsumoto's advance to the third base and Shinozuka's
advance to the second base during Yoshimnra's out, Itara's two points timely hit and Cromatie's two
runners home rnn. At first half of the second inning with no out, score 0-4, Hanshin added one point by
Bass's home run.
[Game 4, Interests 2]
The Giants won by one side game. At second half of the first inning with no oat, the Giants settled the
game by Matsumoto's hit, Shinozuka's hit, Matsumoto's advance to the third base and Shinozuka's advance
to the second base during Yoshimura's out, Hara's two points timely hit and Cromatie's two runners home
run. At first half of the second inning with no out, score 0-4, ttanshin added one point by Bass's home
run.
[Game 1, Interests 1]
o N + ~ * - a 4 :, b - c I ~ , ~ J . (3) 1 ~ - c ~ _ t c - - N ~ , ~_At;t~¢) ~ .~ ~, ~ ¢ ) 7 ~
236
~ a m e 1, I~erests2]
[Game 2, Interests 1]
[Game 2, Interests 2]
[Game S, Interests 1]
[Game 3, Interests 2]
[Game 4, Interests 1]
237
[Game 4, Interests 2]
Knowledge Representation and Reasoning for Discourse Understanding*
ABSTRACT
Extra-linguistic knowledge is necessary for discourse understanding. In
this paper, we classify the knowledge, and present a framework to describe it
using frames and rules. With this framework, it is easy to represent an IS-A
hierarchy, which is based on a classification by different viewpoints, and to
describe functions of objects as declarative knowledge. Furthermore, to treat
ambiguities in discourse understanding and to process utterances based on
assumptions, the system has a world mechanism for inference. Lastly, we
report the evaluation of this framework through the knowledge representation
of a VCR and the conversation experiment by the dialogue system.
1. Introduction
Context processing technology is most important in building a question-answering
system which reads sentences and answers the user's questions, or a machine
translation system which translates sentences correctly, based on their contexts.
Determining anaphoric reference and complementing ellipses are two of the most
fundamental problems in context processing, and they are especially difficult in
understanding conversations.
For context understanding, it is obvious that the extra-linguistic knowledge and
reasoning based on it are necessary as well as the linguistic one. However, how the
extra-linguistic knowledge should be represented and used has not been fully discussed.
In this paper, we propose a framework for representing the extra-linguistic knowledge,
which is a multi-paradigm knowledge representation system based on frames and rules.
Knowledge representation based only on frames is insufficient in the following points.
(a) In classifying the concepts in a task domain, we can classify them in a different way
by changing the view point, but frames cannot express the taxonomy based on such
classification simply.
(b) Negative expression and inference concerning negation are insufficient.
(c) We cannot describe the behavior of objects and logical relations between attributes
as declarative knowledge.
*This work is supported by ICOT (Institute for New Generation Computer Technology).
239
The framework we propose here solves these problems. Moreover, the inference
system is based on a world mechanism, which offers multiple hypothetical worlds for
discourse analysis and problem solving.
We have been developing a consulting system which helps the user to use electrical
equipment such as a VCR (video cassette recorder) through conversation. We then
report the appraisal of the framework, which is obtained through the description of
knowledge for this task and experiment of the consulting system.
F ,,---]
The process of context understanding is to select the most appropriate context world.
To do so, we must evaluate every possible interpretation. But in some cases, we can't
evaluate them unless we make some inferences from the interpretation fin'st, which may
change the contents of the working memory, and for that, we must be able to create
context worlds simultaneously.
The interpretation which is decided by the context analysis is not always correct. If the
system finds an inconsistency, it must resolve it. In the field of expert systems, Doyle
proposed an inference system called TMS [Doyle 79]. A context understanding system
should have this sort of inference system, and the world mechanism is a key to its
realization.
Considering human language activity, we can find that we talk not only about objects
and events in a real world but also about those in an imaginary world. So the system
should process utterances based on conditionals. We think this is possible by utilizing
context worlds. For processing such sentences, the system has only to create a new
context world and process the following sentences in this world. The context world which
corresponds to the imaginary world per se differs from the one which is created for context
understanding, but can be processed in the same framework.
schema(cls, vcr_model_750,
[(superC, type_of_.soundrecording, [(value,[hi_fi_ver])]),
(superC, type of easette, [(value,[vhs_vcr])]),
(haspart, [(value,[power_switch, play_back_switch,...])]),
(status, [(car_num,1 ),
(enumeration,[stand_.by,play_back, record, ...])]),
(power, [(car_num,1 ), (enumeration,Ion,off ])]),
(channel [(car_hum, 1),
(value__class, integer),
(value_.condition, (_,V,(V>=I,V=<12))) ])
],
[s_rule(power, Power__on,VCR,
( kr_schema(VCR, [(power, [off] )],true),
event(push, 1,[(object,[SW])] ) ),
kr_schema(VCR, [(power, [on] )],true),
[('$var.constraint',(
SW#powerswitch :- parLof(SW,VCR) ))]),
s_rule(power,power_lampon,VCR,
kr_schema(VCR,[(power, [on] )],true),
kr_schema(LP, [(lamps tams, [on] )] ,true),
[('$var_constraint',(
LP#power_.lamp :- part_of(LP,VCR))])
]).
Figure 3 Schema example for a VCR (a part).
Kr_schema is a predicate that extracts or verifies slot values.
Words beginning with a capital letter denot~ variables.
243
q) ®
B O
A A B
(saMe viewpoint)
® ®
C A
A B B
(different
viewpoint )
Knowledge of events
We use case representation to describe an event. Using a schema, a case
representation is described quite naturally by representing each case as a slot. Figure 6
shows an example description for a verb "rokuga-suru (to record something on a video
tape)", where slots (agent, object and tool) have a special facet describing constraints on
fillers of these cases. In this example, the constraint is that the agent, object and tool
schema(cls, record,
[(super(], [(value, [action])])]),
(agent, [(value_class, human_being)]),
(object, [(value_class, tv program)]),
(tool, [(value class, vtr)]),
(obligatory_case,
[(value, [object,tool])] ) ], []).
Figure 6 Eventexpressionby schema.
245
must be a human, a TV program and a VCR respectively. The requirement for slot
fulfillment, in implementing a task, is described in an 'obligatory-case' slot. These
constraints are used to reduce search space in interpreting an input sentence.
3.3 Implementation
We implemented the knowledge representation system on a PSI (Personal Sequential
Inference machine) developed by ICOT. The programming language is ESP (Extended
Self-contained Prolog). The size of the program is about 7000 lines including comment
lines.
Since ESP is a kind of object oriented language, it is possible to translate all knowledge
written in a schema to an object of ESP. However, in the current system, for ease of
debugging and loading speed, we transform a set of schemata in one file to an object of
ESP, and load it into the main memory.
Execution speed is not satisfactory because the system processes the frame data by
interpretation. By compiling frame data to a Prolog program like DCKR (Definite Clause
Knowledge Representation)[Tanaka 86], we can make the system faster.
This corresponds to a situation where an expert could consult via telephone conversation.
Discourse analysis
Here we briefly introduce a procedure of discourse analysis for interpreting an input
sentence[Ukita 88]. The procedure consists of four major steps; anaphora detection,
referent candidate extraction, non-contradiction testing, and optimal candidate selection.
First the procedure detects anaphoric indicators in a sentence, which are pronouns or
nouns, with or without definite articles. Furthermore, the omitted obligatory cases of the
events (predicates) are detected as ellipses.
Next, for every anaphoric indicator, the procedure searches for referent candidates that
have already emerged in the context, tn the system, they are usually defined as instance
schemata. If the procedure can't find an appropriate candidate for an indicator, it creates a
new instance schema and treats it as the candidate. The inter-object relationships such
as whole-part or attribute-value are also checked here.
When more than two possible interpretations remain after the non-contradiction test,
the procedure tries to find causal links between the interpretations and the context, and
decides on the most informative interpretation. This is the step of optimal candidate
selection. In inspecting causal connections, the procedure searches for rules that describe
the usage of a VCR. Let's consider an example sequence of sentences, whose preceding
context contains a cassette tape and a practical image on a television set.
(5) I pushed the eject button. It didn't come out.
Assume that the referent candidates of "if' are the cassette tape and the image. To
decide on the appropriate referent, the procedure finds a rule such as follows:
If (a cassette is inserted in a VCR),
and (the eject button is pushed),
then (the cassette comes out).
Using this rule, the procedure prefers the interpretation that the cassette didn't come out.
Currently we don't use schema rules which are described in a schema for this step. In
referent candidate extraction, if an anaphoric indicator is a noun, the procedure searches
for an object that is an instance of a concept meant by the noun. This is just the case in
(a) and (c) described in Figure 5. We have to improve the discourse analyzing program to
treat other cases.
Problem solving
The current task of the consulting system is categorized into 3 sub-tasks as follows.
(a) Answering an inquiry about an operating procedure
(example: Would you tell me how to play back this tape?)
(b) Solution of a fault which originates in an operation mistake
(example: I pushed the play-back switch, but it didn't work.)
(c) Prediction of an action of the VCR
(example: What happens if I push the play-back switch now?)
An input sentence is classified into one of these types, and the problem solving module
for this type is activated. Finally the result of the task is output as a question or an
answer to the user.
Dialogue example
Figure 8 shows a conversation example using the experimental system. Before this
248
conversation, the system was given the situation that there is a VCR and a television set,
and that the initial state of the devices is such that the power is off. Unless such an initial
state is given, the system asks the user about it and about his/her actions, and continues
the consultation.
w°- 1
~
(7)
~ (8)
5. Conclusions
In this paper, we discussed a classification of knowledge for context understanding, and
a framework for its representation and reasoning based on this knowledge. We first
classified the knowledge into four categories; knowledge of objects, knowledge of events,
concept hierarchy, and relationships between events. The first three are described in a
framework called a schema, and the last one is described by rules. Using schemata, we
can naturally represent an IS-A hierarchy based on different viewpoints, and also describe
a negative slot value, and use the open/closed assumption properly. Furthermore, by
using schema rules, we can describe functions of an object and logical relations between
attributes declarativety. As for inference, we pointed out the need for a context world for
resolving an ambiguity in context understanding, and its validity in problem solving. Then
we discussed our knowledge representation system which is implemented as a part of an
experimental question-answering system for a VCR usage application. By representing
the knowledge of the task domain, we found the above points to be advantages in our
system. At present, there is some knowledge that can't be written in the current
framework, but the framework reported here is thought basically applicable to context
understanding in other task domains.
References
[Bobrow 77] Bobrow,D.G. and Winograd,T., "An Overview of KRL, a Knowledge
Representation Language", Cognitive Science, Vol. 1, 1977, pp.3-46.
[Doyle 79] Doyle,L, "A Truth Maintenance System", Artificial Intelligence 12, 1979,
pp.231-272.
251
[Ishizaki 86] Ishizaki,S. and Isahara, H., "Contextual Processing Technology", Vol.27,
No.8, 1986, pp.897-905(in Japanese).
[Minsky 75] Minsky,M., "A framework for representing knowledge", in Winston,P. (ed.),
The psychology of computer vision, McGraw- Hill, 1975, pp.211-277.
~Rieger 75] Reiger,C.J., "CONCEPTUAL MEMORY AND INFERENCE", ha Schank,R.
(ed.), Conceptual Infomation Processing, NORTH-HOLLAND, 1975, pp. 157-288.
[Schank 77] Schank,R. and Abelson,R., "Scripts,Plans,Goals and Understanding",
Lawrence Erlbaum Associates, 1977.
[Tanaka 86] Tanaka,H., "DCKR - Knowledge Represetation in Prolog and Its Application
to Natural Language Understanding", in Nagao,M.(ed.), Language and Artificial
Inteligence, Else Ver Science Publishers, B.V. (North Holland), 1987, pp.353-366.
[Uldta 88] Ukita,T., Sumita,K., Kinoshita,S., Sano,H., and Amano,S., "Preference
Judgement in Comprehending Conversational Sentences Using Multi-Paradigm World
Knowledge", Proc. of FGCS' 88, 1988(to appear).
[Wilensky 83] Wilensky,R., "Planning and Understanding", Addison-Wesley, 1983.
[Winograd 72] Winograd,T., "Understanding Natural Language", Academic Press, 1972.