Analogical Reasoning For Logic Programming: Recognition, Elab-Oration, Evaluation, Consolidation, As

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Analogical Reasoning for Logic Programming

Birgit Tausend Siegfried Bell


Institut ffir Informatik, Universit£t Stuttgart
Forststr. 86, D-7000 Stuttgart 1, Germany
emaih tausend@informatik.uni-stuttgart.de

Abstract cludes four main steps, recognition, elab-


oration, evaluation, and consolidation, as
Analogical reasoning is useful to exploit described in [Hall 89]. First, recognition
knowledge about similar predicates to determines a minimal set of source prob-
define new ones. This paper presents lems that are analogical to a given target
MARs 1, a tool that supports the defini- problem. The next step is to elaborate a
tion of new Prolog predicates with respect mapping between the source and the tar-
to known ones. Starting from similar ex- get problem and to make analogical infer-
amples, one of the known predicate and ences. Then the mapping and the infer-
one of the new, the tool proposes a def- ences have to be evaluated in a particular
inition for the new predicate. The algo- context and in addition justified, extended
rithm for constructing this new definition or repaired if necessary. The last step con-
by analogy includes four main steps that cerns the consolidation of the result of the
will be described in detail in this paper. analogical reasoning process to make fur-
ther use of it.
Most of the machine learning approaches
1 Introduction to analogical reasoning can be described
and compared within this framework, as
Analogical reasoning is concerned with shown in [Hall 89]. They mainly differ in
finding a solution for a new problem by the particular method preferred in each
making use of the known solution of a step and in the application domain.
similar problem. Basically, analogical rea- The organization of this paper is as fol-
soning aims at mapping knowledge from lows: in the first section we introduce ba-
a well understood domain, the so called sic terms and a four step model of analog-
source domain, to a new domain called the ical reasoning. The next section presents
target domain in order to solve the new the learning situation of MARs. Section
problem. According to this terminology 3 describes each of the four steps of the
the new problem is called target problem analogical reasoning process of MARs in
and the solved one source problem. detail. The last section discusses briefly
The process of analogical reasoning in- some limitations of the existing approach
and concludes with the goals of further
1MARsis a n acronymfor Model of Analogical work.
Reasoning
392

2 Learning Situation similar because they can be programmed


in a similar way. So the Prolog predicates
Machine learning approaches to analog- member and append could be defined ana-
ical reasoning aim at solving problems logically because their structure and their
in very different domains, as shown in arguments are similar. In the other case
[Hall 89]. Some apply to physical do- similarity concerns the meaning that is the
mains [Greiner 88], [Gentner 881, oth- relation of input and output of the pro-
ers are concerned with concept learning gram pieces and disregards any structural
[KedarCabelli 88],[Burstein86] or plan- similarity. For instance the Prolog predi-
ning [Carbonell 83]. cates first and last could be said to have
The application problem we address is a similar meaning because they cut one el-
the analogical definition of a new Prolog ement off a list, first at the beginning and
predicate according to a known one. This last at the end of the list, but they have to
is a task novices in programming language be programmed in a different way. MARs
are often involved with. In exercises they deals with the first kind of similarity that
are told to find a solution for a problem is the source and the target problem are
that is similar to one solved before. Thus, supposed to have a both similar structure
they are requested to slightly modify a and arguments.
known piece of code instead of program-
ming the solution from scratch.
The task of MARs is nearly the same as 3 A M o d e l of Analogi-
the students task. Starting from an ex-
ample of the source predicate and a sim-
cal Reasoning
ilar of the target predicate MARs should MARs intends to support the definition of
construct a definition of the new predicate
new Prolog predicates with respect to sim-
by analogical reasoning. Figure 1 shows ilar known predicates. The input required
an example where the Prolog predicate includes two analogical examples and a
member should be defined analogically to knowledge base. Both examples have to
the predicate append.
be ground literals. The knowledge base
is supposed to store at least all rules and
Target a n d s o u r c e example: facts needed to prove the source example.
member(2,[l,2,3D ~ append([l],[2,3],[1,2,3]) The target example can not be solved di-
rectly according to the knowledge base,
Source problem: append(Ill,[2,3],[1,2,3])
but it is required to be provable in a sim-
Knowledge base: append(~,L,L) ilar way. The output of MARs consists of
append([XlT],L,[XlT1]) ~append(W,L,Wl) the rules and facts necessary to prove the
New definition: member(L,[LIT1]) target problem. This knowledge has to be
member(L,[X]T1]) ~-- member(L,T1) justified by an oracle before it is added to
the knowledge base for further use.
Figure h Analogical definition The construction of the missing rules
and facts involves four basic steps. First,
Before explaining how MARs constructs the recognition step compares the argu-
the new predicate we have to clarify which ments of the source and the target ex-
problems we consider to be analogical. ample. In addition, the proof tree of the
In general the hint that two problems are source example is constructed. The elab-
analogical can address two different kinds oration step maps the ground literals of
of similarity. In one case the problems are the proved source example onto the target
393

problem. During evaluation MARs uses


forward chaining to construct a proof tree Example of analogy:
for the target problem. The last step gen- member(2,[l,2,3]) ,,~ append([l],[2,3],[1,2,3])
eralizes the proof tree in order to get the
missing predicates. Source problem: append([1],[2,3],[1,2,3])
Mter,n: {(member, append)
((2,1, [2, ai, 2), ([1, 2, al, 2, [1, 2, a], a))}
3.1 Recognition
Recognition starts with the determination Figure 2: A recognition step
of the analogical argument terms of the ex-
amples. In general, there are many possi- In addition to the term mapping the
bilities to map argument terms but we as- refutation tree of the append example has
sume that the user has given the most sim- to be constructed. The refutation tree is
ilar examples. Therefore, we prefer iden- built up using resolution.
tical terms to be mapped first and then A single resolution step can be repre-
try to find further similarities between the sented by a V representing an inverted
unmapped terms with the help of other re- tree, as shown in Figure 3. The clause
lations, e.g. subset or membership. Thus, Resi+l is inferred from the two given
the mapping relations are ranked where clauses Resl and Cll with the particular
the identity relation has the highest rank. substitutions ORes~ and Oct,. The refuta-
The term mapping Mt¢~m is stored in a tions are established using a special kind
replacement list with the following struc- of resolution, the SLD resolution, that ap-
ture: plies to a negative clause, the so called re-
solvent, and a positive clause to transform
{(Pt,P,)(..., (argt,, i, arg,j,j),.. .))} them into a negative clause.
where Pt is the target predicate symbol,
p, is the source predicate symbol. The 4-
tuples (argti, i, arg,~, j) describe the term Resi Cli
mappings where argt~ is the ith argument
of the target example, arg,~ is the j t h ar-
gument of the source example, and i and
j are the argument positions needed for
later recovery of the term mappings. R e si+ 1
Figure 2 shows an example of two ana-
logical predicates, where six mappings of Figure 3: A single resolution step
terms are possible. Given a ranking of
the candiate mapping relations, we use the
highest ranking relation, identity, to corre- Resolvent: Let Resl and Cll be two
late the third argument of append with the clauses with no variables in common.
second argument of member. Also, using Let L1 E Resl, L= E Cl and 0 is the
the same ranking, the membership rela- most general unifier or mgu such that
tion is established between the first term L10 -- ~-~. We write the resolvent
of member and the second of append. This as
term mapping is choosen for further pro-
Resi+t = (Real \ {L1})O O (ell \ {L2})O
cessing and only if the analogical reason-
ing fails MARs tries to establish another The result of recognition includes the
term mapping with lower ranked relations. term mapping and the refutation tree. For
394

further work we have to extend the refu- reverse. The other case is more compli-
tation tree so that the resolvent and the cated because we do not have any infor-
positive clauses of each particular resolu- mation about the corresponding literal in
tion step together with their substitutions the target domain. So, only the argument
are contained. We use the following struc- terms will be replaced but the predicate
ture of a refutation tree where the symbol symbols will not be changed.
[] stands for an empty clause: The definition for determining the
Tree= { (Resl,Cll, 01),..., ground literals needed to prove the target
example is given by the following replace
(Res,,_l, Ct,,-1, ON-l>,
(o) } mapping M, ept where f is a mapping rela-
tion like identity, inclusion or subset:
where Oi = Oct,, because Resl are in-
stantiated clauses and On,s~ is empty. M, ept(ps(. . . , ar gs~, . . .) ) =
I p~(...,arg,,,...) : (pt,p,) e M,,~,~
--,append([1],[2, 3], [1, 2, 3]) and (argt,,i,arg~,j) • Mte~m
append([XlT], L, [XIT1]) pt(...,argt,,...) : (pt,p~) • Mte,n
append(T, L, T1) and (f(argt,),i,f(arg~,),j) • Mt~,~
pt(...,argtj,...) : (pt,ps) ¢ Mte,~
-~appc,d(O, [2, 31,[2, 31) and (argt¢,j, arg~,j) • Mt~m
t/append(0,L, L) pt(...,arg~,...) :otherwise
M~vt transforms the ground literal
O p~(..., arg~i,...) of the source proof tree
into the ground literal needed for the tar-
Figure 4: The refutation tree get proof tree according to the informa-
tion about term mappings stored in Mt~,~.
The following tree is generated of the ex- Figure 5 shows an example of elabora-
ample of figure 4. tion where the terms and the predicate
symbol of the ground literal of the source
Tree = refutation tree, append([], [2, 3], [2, 3]), are
{ (~append([1],[2,3],[1,2,3])), mapped onto member(2, [2, 31). For exam-
(append([XIT],L,[XIT1]) ple, the first rule of M~pt applies to the
V-~append(T,L,T1)), second argument of append([], [2, 3], [2, 3])
(X--,1, T~[], L~[2,3], T1~[2,3])), and the second rule to the third argument.
(-~append([],[2,3],[2,3])),
(append([],L,L)), Mt~m: ((member, append)
(L-*[2,3])), ((2, 1, [2, 3], 2), ([1, 2, 3], 2, [1, 2, 3], 3))}
o)} Ground literal: append(I],[2,3],[2,3])
Mrepz(append([], [2, 31, [2, 3]))
3.2 Elaboration
= member(2, [2, 31)
Elaboration maps all ground literals of
the proof tree into the domain of the tar- Figure 5: An elaboration step
get example. Two cases can be distin-
guished depending on the ground literals
3.3 Evaluation
and the term mapping Mte~,~: if the pred-
icate symbol occurs in Mt,~m, then, the The evaluation step uses the mapped
argument mapping can be used simply in ground literals and the refutation tree of
395

the known example to construct a refuta-


tion tree for the target example. Start-
ing from the ground literals the missing -.append([l], [2, 3], [1, 2, 31)
nodes of the new refutation tree are de- append([1], [2, 3], [1, 2, 31)V
termined by forward chaining. In general, ~pp~,,d(l], [2, 3], [2, 31)
the search space of this problem is large
-~vv~n~([1], [2, 3], [1, 2, 3])
but the structure of the known proof tree
restricts it considerably because the new
proof tree should be as similar as possible. ..-imembe~(~} [1, 2,
Forward chaining can be done by simply 3])member(2, [1, 2, 3])V
inverting the resolution step as described
in [MuggletonBuntine 88],[Wirth 89].
~ -..~.~b~(2, [2, 31/

With this mechanism, called inverse reso- -,m~mbeK2, [2, 31)


lution, we can determine clause Resi from
Figure 6: A forward chaining step
the clauses Cli and Resi+l in a configura-
tion like it is shown in figure 3.
The formula of the inverse resolution The double resolvent of n resolution
Resi is a simple algebraic manipulation of steps is determined by:
the resolution formula with five unknown Resd. = {(~t~ i, ~%)}
parameters in the general case as shown in
[Wirth 89]: where sii represents the j ground liter-
als included in the refutation tree of the
[Resi+l \ clleol, u { ~ e c t , } U SOct,]OR~,,
-~ source domain and tit are the j resulting
ground literals of the elaboration step.
Here, we make the assumption for Resl
ne~d, = he.d,+, \ { (ti., %)} 0 { (-.l,,, -q.,)}
that we only use instantiated clauses and
that S is empty. Therefore, the formula where s b E Res,~+~, Cl,~Ovt, = 1~ V
used for forward chaining in the source do- ",si,... V "~slk, (Ress~, Clsi, Oct,) E Tree
main is defined by: and0 <i<n.
Forward chaining suceeds if the resolvent
Res,, = ( Res,,+, \ Cl,, Ocz,, u {-q,, Oct,, }) Resaa contains both examples.
where all parameters are known and The unknown clauses Clt, = It~ V
l,~ E Cl,,. The formula of the target do- "~ti~,...,'~tlk are conjectured using M~pt
main is:
Re,,, = (Re,,,+, \ eli, U {-~It,})
ReSd, = { (-,member(2, [1,2, 3]),
where Itl E Clti. Itl and Clti are instanti- --,append([1], [2, 3], [1, 2, 3])) }
ate& Clti can be conjectured by M,,pt and \ \ append([1], [2, 3], [1,2, 31)
the resolution literal can be effectively de-
~ V-~append(~,[2, 31, [2, 31:
termined.
Figure 6 shows one forward chaining step
for each example. For efficient construc- x.x~v-.memb~K2, [2, all
tion of the refutation tree it is useful to
tie together both refutation resolvents into Resd,+t = { (--,member(2, [2, 3]),
-..pp~.d([l], [2, 3], [x, 2, 31)) }
one. Figure 7 shows the same example re-
solvents as figure 6 but tied together in a Figure 7: Refutation with a double resol-
double resolvent. vent
396

and the instantiated clauses Cl,,. the substitution ( X ~ I ) of Ocz~ results in


M~,pt(l~, V "-'si,... V ",si~) = the inverse substitution ((2,1)--+L).
The inverse substitution is applied in or-
Itl V "tla , . . . , V"~ti~ der to generalize each literal of the con-
The result of the evaluation step is a jectured clauses of the target domain as
refutation tree of the target example with shown in figure 9. Using this procedure
the instantiated clauses Cltl. Figure 7 the m e m b e r clause of the example is con-
shows an example of a forward chaining structed. For instance, the inverse sub-
step. tltution Octk applied to member(2,[2,3])
results in mcmber(L,T1).
3.4 Consolidation
The last step called consolidation general- Ois,(Ool,) =
izes the conjectured rules of the previous {((2,1)-~L),((1,2)-~x),(([2,aI,2)~T1)}
step. For this purpose we use the term re- (Ois Octk)(member(2,[1,2,3])) =
placement set Mt,r,~ and the substitutions
member(L,[XIT1])
of the refutation tree generated during the
recognition step. Thus, generalization is ( Oi~ Octk)(member(2,[2,3])) =
performed through inverse substitution as member(L,T1)
defined by Result:
member(L,[XlTll) ,- meinber(L,T1)
O.~(Oct~) =
O . ~ ( { . . . , X j --. arg,;,...}) =

{
Figure 9: A consolidation step
{..., ( ( a r g , , , 0 ---, x,)...}
: (argt,,i, a r g , j , j ) E Mt~,m
{ . . , ((a,'o,,, i) --, x~)...}
: (f(arg,,),i,f(arg,~),j) ~ M,o,,, 4 Concluding Remarks
{..,0,...} : otherwise
where Oolk are the substitutions of the In this paper we introduced MARs, a tool
recognition step and Mt,,m is the term re- for defining new Prolog predicates by anal-
placement set. f is a mapping relation for ogy. Particular methods are presented for
two argument terms. each of the four steps of the analogical rea-
soning process. The main contribution of
MARs is that it is a logically well founded
Mt~m: {(member, append) but simple model of analogical reasoning.
((2,1, [2, 31,2), ([1, 2, 3], 2, [1, 2, 3], 3))) However, MARs has to be evaluated in
more detail and to be extended to be ap-
OClk : plicable for more complex kinds of anal-
{ X--*l, T-*[], L--*[2,3],TI--*[2,3])} ogy.
Oi,k (Ocl,,) = We plan to improve MARs along serveral
{((2,1)~L),((1,2)~X),(([2,3],2)-+T1)} lines. First, applying MARs to other ana-
logical pairs of predicates, e.g. union ..,
Figure 8: The inverse substitution intersection or s u m I i s t ,.. multlist, has
shown that it is useful to submit more
Figure 8 shows an example of establish- than one example or to use an oracle. In
ing the inverse substitution. For instance, many cases the information included in
the application of the first rule of O;~k to the term mappings and the source proof
397

tree is not sufllcent to determine the cor- A. Prieditis (Hrsg.), Analogica. Mor-
rect target literals. For instance, using gan Kaufmann, 1988.
more examples, e.g. union([], [2, 3], [2, 31),
union([1,21, [2, 31, [1, 2, 3]), in addition to [Greiner 88] R. Greiner. Learning by un-
the analogical example union(J1,21, [2, 31, derstanding analogies. PhD thesis,
[1,2,31) ..o intersection([1,2], [2,31, [2]) Stanford University, 1988.
makes it possible to define union analog- [Hall 89] R. P. Hall. Computational ap-
ically to intersection without asking an proaches to analogical reasoning: A
oracle. comparative analysis. Artificial In-
Second, we intend to resolve the limita- telligence, 39:3-120, 1989.
tions on the structure of the known pred-
icates that have to be very similar. Espe- [KedarCabelli 88] S. Kedar-Cabelli. To-
cially the treatment of the predicates ap- wards a computational model of pur-
pearing in the proof tree of an example pose-directed analogy. In A. Priedi-
but not in the replacement list has to be tis (Hrsg.), Analogica. Morgan Kauf-
investigated in more detail. mann, 1988.
Third, we plan to apply MARs to other
domains like language processing in or- [MuggletonBuntine 88] S. Muggleton und
der to define new grammar rules analog- W. Buntine. Machine invention
ically. Comparing grammar rules shows of first-order predicates by inverting
that they are often very similar especiMly resolution. In A. Arbor (Hrsg.), Fifth
in their structure so that an analogical def- International Conference on Mach-
inition will succeed in many cases. Using ine Learning. Morgan Kaufmann,
the DCG formalism to describe grammar 1988.
rules makes it possible to use MARs be-
[Wirth 89] R. Wirth. Lernverfahren zur
cause the grammar rules can be treated in
Vervollstiindigung yon Hornklausel-
a similar way as logical predicates.
mengen durch inverse Resolution.
Doktorarbeit, Institut ffir Informa-
References tik, Universit£t Stuttgart, 1989.

[Burstein 86] M. Burstein. Incremen-


tal learning from multiple analogies.
In R. Michalski, J. Carbonell und
T. Mitchell (Hrsg.), Machine Learn-
ing: An Artificial Intelligence Ap-
proach. Morgan Kaufmann, 1986.
[Carbonell 83] J. Carbonell. Learning
by analogy: Formulating and gener-
alizing plans from past experience.
In R. Michalski, J. Carbonell und
T. Mitchell (Hrsg.), Machine Learn-
ing: An Artificial Intelligence Ap-
proach. Tioga, 1983.
[Gentner 88] D. Gentner. Analogical in-
ference and analogical access. In

You might also like