Document 14835708

advertisement
Published in: Proc of the 5th Workshop on Logic Programming Environments, 29-30 October 1993, in conjunction with International Logic Programming Symposium (ILPS ’93) Vancouver, Canada, 1993, pp. 8-13
Generating Explanation Trees even for Negations
in Deductive Database Systems
Günther Specht
Technische Universität München
Institut für Informatik
Orleansstr. 34
D-81667 München
email: specht@informatik.tu-muenchen.de
Abstract:
Although there were enormous research efforts on explanation and debugging tools for Prolog in
the last years, good tools for bottom-up evaluating logic programming systems are still missing,
since the generation of the underlying proof trees matches several problems in presence of negation and recursion. This paper wants to fill the gap and presents a source-to-source transformation
to compute complete proof trees for bottom-up evaluating systems, so that advanced techniques,
developed for top-down systems, will once be usable for bottom-up systems as well. The presented
technique is implemented and in use in the deductive database system LOLA.
1. Introduction:
Most explanation and debugging tools for logic programs are based on proof trees (also called
explanation trees). If a logic program is not evaluated top-down and "tuple at a time" like Prolog
does, but bottom-up and "set at a time" like most of the deductive database systems (e.g. LOLA,
LDL, NAIL, ADITI, CORAL, IDEA, etc.)1 do it, it is rather difficult to generate proof trees, especially in the case of negation, since restrictions like range restriction, stratification and safe negation are required in the bottom-up approach. That is the reason why most of the currently available
deductive databases include no or only rudimental explanation facilities.2
This paper wants to fill that gap and presents a new technique to compute complete proof trees for
bottom up evaluating logic programming systems (henceforth called deductive databases): A
source-to-source transformation converts a given logic program into a program that includes explanation or trace information. Even recursive and negated subgoals can be explained correctly.
"Why-not" queries are possible too, showing why an expected result cannot be deduced form the
given rules and facts. The computed proof trees can either be shown directly as explanation trees
within a graphical user-interface, allowing zooming and shrinking operations, or be used as input
for advanced explanation and debugging tools as developed in the top-down environment (e.g. [1,
2, 4, 9, 11]).
The paper is organized as follows: Section 2 motivates, why we select a source-to-source transformation as best technique. In section 3 the positive explanation transformation is presented and in
section 4 we solve the problems arising, when negation occurs. Finally section 5 shows how one
can ask why-not queries using this technique.
__________________
1
for an overview see e.g. [6].
Wieland [10] developed proof trees on datalog programs, but his approach can not handle terms, negations and
source-to-source optimizations. Shmueli and Tsur [7] connected the Prolog debugger in [4] to LDL.
2
-9-
2. Why using a Source-to-Source Transformation?
Published in: Proc of the 5th Workshop on Logic Programming Environments, 29-30 October 1993, in conjunction with International Logic Programming Symposium (ILPS ’93) Vancouver, Canada, 1993, pp. 8-13
The architecture of a deductive database system looks in general as follows: A logic program and a
query are translated by a compiler into a relational algebra expression, including joins, selections,
Generating
Trees
for
Negations
seminaive-iterations,
etc. .Explanation
This code is evaluated
in aeven
runtime
system.
The evaluation mode is
bottom-up and set atin
a time,
using
the
iterative
fixpoint
semantics.
Logic
programs can be arbiDeductive Database Systems
trarily recursive, include terms, stratified negation, built-in predicates (defined outside the logic
programming language) and calls to Günther
external Specht
databases, which deal as fact-servers. Only safety,
stratification and range restriction are required.
Universität
München
Considering which might be Technische
the best place
to integrate
a proof tree generator in the system, one
Institut
für
Informatik
immediately thinks about the final internal representation (commonly called operator graph) before
Orleansstr.
the code-generator is called. At that level
we have34all collected informations. But if we do so, we
D-81667
München optimization techniques, like the magic set
obtain an enormous drawback: If we use rule-rewriting
email: specht@informatik.tu-muenchen.de
transformation, then we explain
the transformed program, not the original one.
That can be avoided by putting the proof tree generator as a source-to-source transformation right at
Abstract:
the beginning, which transforms a logic program into another one, containing additional attributes
with explanation
Now, later
rule-rewriting
techniques
don’t matter
anyfor
more.
Although
there wereinformation.
enormous research
efforts
on explanation
and debugging
tools
Prolog in
the This
last years,
tools for
bottom-up evaluating logic programming systems are still missing,
methodgood
has several
advantages:
since
the
generation
of
the
underlying
proof trees
matchesdatabase
several problems
• It is a modular extension of the underlying
deductive
systems, in presence of negation• and
This
wants to fill the(=compiler)
gap and presents
a source-to-source transformation
norecursion.
modification
of paper
the inference-system
are required,
to compute
complete
proof
trees
for
bottom-up
evaluating
systems,
so compiler,
that advanced techniques,
• independent from the internal representation of the program in the
developed
for top-down
will once
be usable for techniques
bottom-up and
systems as well. The presented
• independent
from systems,
rule-rewriting
and optimization
technique
is
implemented
and
in
use
in
the
deductive
database
system
LOLA.
• independent from the evaluation system (run time system).
1.
I.e. in the result:
• independence from the underlying deductive database system: I.e. this proof tree generator is
Introduction:
usable for every bottom-up evaluating logic programming system.
Most explanation and debugging tools for logic programs are based on proof trees (also called
explanation
trees). If a logic
program is not evaluated
andSubgoals
"tuple at a time" like Prolog
3. Proof-Tree
Transformation
fortop-down
positive
does, but bottom-up and "set at a time" like most of the deductive database systems (e.g. LOLA,
LDL, NAIL, ADITI, CORAL, IDEA, etc.)1 do it, it is rather difficult to generate proof trees, espeTheinbase
technique
is to introduce
one new attribute
in each
predicate,
for constructing
derivacially
the case
of negation,
since restrictions
like range
restriction,
stratification
and safethe
negaThis
be illustrated
by an That is the reason why most of the currently available
tiontion
are term.
required
in may
the bottom-up
approach.
Example:
deductive
databases include no or only rudimental explanation facilities.2
flight(From,
To)
Thisr1:paper
wants to fill that
gap:anddirectflight(From,
presents a new techniqueTo).
to compute complete proof trees for
r2:
flight(From,
To)
:directflight(From,
Via),
bottom up evaluating logic programming systems (henceforth called deductive databases): A
flight(Via,
To).
source-to-source transformation converts a given
logic program
into a program that includes explar3: directflight(munich, frankfurt).
nation or trace information. Even recursive and negated subgoals can be explained correctly.
Here wequeries
have aare
very
simpletoo,
program
with
one
concatenating
direct
flights
"Why-not"
possible
showing
why
an recursive
expected clause,
result cannot
be deduced
form
the to
flights.
It
is
transformed
to:
given rules and facts. The computed proof trees can either be shown directly as explanation trees
within
user-interface,
allowing
zooming
and:shrinking operations, or be used as input
r1’: a graphical
flight(flight(r1(S1),
From,
To), From,
To)
directflight(S1,
To).
for advanced explanation and debugging tools as developedFrom,
in the top-down
environment (e.g. [1,
flight(flight(r2(S1, S2), From, To), From, To) :2, 4,r2’:
9, 11]).
directflight(S1, From, Via),
The paper is organized as follows: Section 2 motivates, why we select a source-to-source transforflight(S2, Via, To).
mation as best technique. In section 3 the positive explanation transformation is presented and in
r3’: 4 directflight(directflight(base,
munich,
frankfurt),
frankfurt).
section
we solve the problems arising, when
negation
occurs. munich,
Finally section
5 shows how one
can ask why-not queries using this technique.
__________________
1
for an overview see e.g. [6].
Wieland [10] developed proof trees on datalog programs, but his approach can not handle terms, negations and
source-to-source optimizations. Shmueli and Tsur [7] connected the Prolog debugger in [4] to LDL.
2
--10
9 --
2. Why using a Source-to-Source Transformation?
Published
in: Proc of
the 5th Workshop
on bold
Logicprinted
Programming
October
in con-S1 of
The informal
meaning
of the new,
part ofEnvironments,
rule r2’ is: If29-30
we know
the1993,
derivation
junction
with
International
Logic
Programming
Symposium
(ILPS
’93)
Vancouver,
Canada,
1993,
pp.
8-13up the
directflight and if we know already the derivation S2 of flight, then we can build
derivation
term in
next step,database
by concatenating
theinsubterms,
the rule-ID
functorand
anda
The
architecture
of the
a deductive
system looks
general asusing
follows:
A logic as
program
inserting
term inby
a term
containing
bindings of
the head.
query
arethis
translated
a compiler
intothe
a relational
algebra
expression, including joins, selections,
The
same
transformation
has
to
be
done
for
facts,
where
the
derivation
termThe
is marked
as "base".
If
Generating
Explanation
Trees
even
for
Negations
seminaive-iterations, etc. . This code is evaluated in a runtime
system.
evaluation
mode is
we evaluate and
a transformed
logicusing
program
with more
rules and
facts weLogic
get e.g.
the following
bottom-up
set atin
a time,
the iterative
fixpoint
semantics.
programs
can be proof
arbiDeductive
Database
Systems
tree:
trarily recursive, include terms, stratified negation, built-in predicates (defined outside the logic
programming language) and calls to Günther
external Specht
databases, which deal as fact-servers. Only safety,
trip(munich,
vancouver)
stratification and range restriction are required.
|
| a proof tree generator in the system, one
Universität
München
Considering which might be Technische
the best place
to integrate
r4
Institut
für
Informatik
immediately thinks about the_________________________|__________________________________
final internal representation (commonly called operator graph) before
/ At that level
|
\ we
Orleansstr.
the code-generator is called.
we have34all collected informations.
But if we do so,
flight(munich, vancouver)
conference(vancouver, ilps93) interesting(ilps93)
D-81667
München
obtain an enormous drawback:
If we use rule-rewriting optimization techniques,
like the magic
|
|
| set
|
|
|
email:
specht@informatik.tu-muenchen.de
transformation, then we explain
the
transformed
program,
not
the
original
one.
r2
base
r5
_______________|______________
| at
That can be
avoided by putting the proof tree
generator as a source-to-source transformation right
/
\
|
Abstract:
the beginning, which
transforms aflight(frankfurt,
logic program intovancouver)
another one, containing additional
attributes
directflight(munich,
frankfurt)
logic_prog(ilps93)
|
|
|
with explanation
information. Now, later rule-rewriting
techniques don’t matter any more.
Although
there
| were enormous research efforts|on explanation and debugging tools for Prolog in
|
basegood tools for bottom-up evaluating
r2
base
the This
last years,
logic programming systems are still missing,
method
has several advantages:
____________|____________
since
the underlying
proof trees
matchesdatabase
several
problems
\
• the
It isgeneration
a modular of
extension
of/the underlying
deductive
systems, in presence of negadirectflight(frankfurt,
ny)
flight(ny,
vancouver)
tion• and
This
wants
to fill the(=compiler)
gap and presents
a source-to-source transformation
norecursion.
modification
of paper
the inference-system
are required,
|
|
to compute
complete
proof
trees
for
bottom-up
evaluating
systems,
so compiler,
that advanced techniques,
|
|
• independent from the internal representation of the program in the
base
r1
developed
for top-down
will once
be usable for techniques
bottom-up
systems as well. The presented
• independent
from systems,
rule-rewriting
and optimization
and
|
|
technique
is
implemented
and
in
use
in
the
deductive
database
system
LOLA.
• independent from the evaluation system (run time system).
directflight(ny, vancouver)
1.
|
I.e. in the result:
|
• independence from the underlying deductive database system:
I.e. this proof tree generator is
base
Introduction:
usable for every bottom-up evaluating logic programming system.
Problems
arise,and
if cyclic
data exists.
Then
theprograms
bottom-upareapproach,
the(also
fixpoint,
Most
explanation
debugging
tools for
logic
based oncomputing
proof trees
calleddoes
not terminate
If
we haveis anot
cycle
in our flight
net, then
building
the derivation
explanation
trees).any
If longer:
a logic
program
evaluated
top-down
andSubgoals
"tuple
at auptime"
like Prologterm
3.
Proof-Tree
Transformation
for
positive
in
the
first
attribute
influences
the
termination,
since
the
derivation
path
going
straight
ahead is
does, but bottom-up and "set at a time" like most of the deductive database systems (e.g. LOLA,
1
different
thatCORAL,
one cycling
once,etc.)
and from
cycling
twice
so on.proof trees, espeLDL,
NAIL,from
ADITI,
IDEA,
do it, that
it isone
rather
difficult
to and
generate
The
base
technique
is
to
introduce
one
new
attribute
in
each
predicate,
for
constructing
the
derivacially
in the
of negation,
since
like rangeand
restriction,
stratification
and safe
negaWhat
cancase
be done
to get back
therestrictions
original termination
semantics?
Two possible
solutions
can
term.
This
may
be illustrated
by an That is the reason why most of the currently available
tiontion
are
required
in
the
bottom-up
approach.
be found: One - strictly saving the source-to-source approach - is to include additional attributes,
2
Example:
deductive
databases
noconnections,
or only rudimental
explanation
facilities.
containing
a list include
of all old
and new
test predicates,
like $not member, testing if the
r1:paper
flight(From,
To)
connections
are that
not
already
elements
the old
ones. To).
(By
the way:complete
memberproof
should
be impleThisnew
wants to fill
gap:anddirectflight(From,
presents in
a new
technique
to compute
trees
for
r2:
flight(From,
To)
:directflight(From,
Via),
mented
as
built-in
predicate.)
bottom up evaluating logic programming systems (henceforth called deductive databases): A
flight(Via,
To).
source-to-source
transformation
converts
a given
logic program
into the
a program
that includes
explaA more elegant
solution to the
problem
is possible,
if we know
implementation
of the
internal
r3: directflight(munich, frankfurt).
nation
or trace
information. Then
Evenwerecursive
anditnegated
be explained correctly.
seminaive
Delta-Iterator.
can modify
to ignoresubgoals
specifiedcan
attribute-positions.
In our conHere
wequeries
have
aare
very
program
with
one
recursive
concatenating
direct
flights
to
"Why-not"
possible
too,
showing
why
expected
result
cannot
be which
deduced
form
text the
first
attribute
issimple
not 6-relevant,
since
it an
contains
justclause,
the proof
tree,
is only
athe
result
flights.
It
is
transformed
to:
given
rules and
facts.
computed
proof treesAll
canwhat
either
shown
directly
as explanation
trees
parameter
and
neverThe
restricts
the evaluation.
webehave
to do
is to extend
the set-difference
within
a
graphical
user-interface,
allowing
zooming
and
shrinking
operations,
or
be
used
as
input
r1’:
flight(flight(r1(S1),
From,
To),
From,
To)
:within the Delta-Iteration in that way, that it just compares all but the first term position. That’s the
3
directflight(S1,
From,
To).
for reason
advanced
and
debugging
tools as developed
in details
the top-down
(e.g. [1,
whyexplanation
I call this an
one-eyed
Delta-Iteration.
(for more
see [8])environment
flight(flight(r2(S1, S2), From, To), From, To) :2, 4,r2’:
9, 11]).
directflight(S1, From, Via),
The paper is organized as follows: Section 2 motivates, why we select a source-to-source transforflight(S2, Via, To).
mation
as best technique. In section 3 the positive explanation transformation is presented and in
__________________
r3’:3 4 directflight(directflight(base,
munich,
frankfurt),
munich,section
frankfurt).
section
solveisthe
problems
arising,
negation
occurs.
5 shows
how one
Thatwe
technique
useful
also in other
parts of awhen
deductive
database system.
TheFinally
set-difference is an expensive
operation.
It
might
be
a
good
optimization
using
the
one-eyed
Delta-Iteration,
looking
just
at
the
primary-keys
of
the
relations,
can ask why-not queries using this technique.
since all others can’t influence the set-difference.
__________________
1
for an overview see e.g. [6].
Wieland [10] developed proof trees on datalog programs, but his approach can not handle terms, negations and
source-to-source optimizations. Shmueli and Tsur [7] connected the Prolog debugger in [4] to LDL.
2
---11
10
9 --4.
forTransformation?
negative Subgoals
2. Proof-Tree
Why using aTransformation
Source-to-Source
Published
in: Proc of
the 5th Workshop
on bold
Logicprinted
Programming
October
in con-S1 of
The informal
meaning
of the new,
part ofEnvironments,
rule r2’ is: If29-30
we know
the1993,
derivation
junction
with
International
Logic
Programming
Symposium
(ILPS
’93)
Vancouver,
Canada,
1993,
pp.
8-13up the
directflight and if we know already the derivation S2 of flight, then we can build
derivation
term
in
next this
step,database
by concatenating
thesubgoals,
the rule-ID
as
functorand
and
The
architecture
problem
arising,
of the
a deductive
using
technique
system
for negated
looks
insubterms,
generalisasusing
the
follows:
violation
A logic
of safe
program
negation.
Ifa
inserting
this
term inby
a term
containing
bindings of
the head.
query
we
have
arethe
translated
rule:
a compiler
intothe
a relational
algebra
expression, including joins, selections,
The same
transformation
to becode
done for facts,
whereeven
the derivation
term is marked as "base". If
Generating
Trees
for Negations
seminaive-iterations,
etc. has
.Explanation
This
qq(X,Y) :- g(X,Y),
$not
p(Y).is evaluated in a runtime system. The evaluation mode is
we evaluate and
a transformed
logicusing
program
with more
rules and
facts weLogic
get e.g.
the following
bottom-up
set atin
a time,
the iterative
fixpoint
semantics.
programs
can be proof
arbiDeductive
Database
Systems
and
if we transform this
clause
straight ahead,
then we would
get the wrong clause:
tree:
trarily recursive, include terms, stratified negation, built-in predicates (defined outside the logic
qq(qq(r1(S1,
$not(S2)),X,Y),X,Y)
:- databases, which deal as fact-servers. Only safety,
programming language)
and calls to Günther
external
Specht
X, Y),
trip(munich, vancouver)
stratificationg(S1,
and range
restriction are required.
|
$not p(S2, Y)).
| a proof tree generator in the system, one
Universität
München
Considering which might be Technische
the best place
to integrate
r4 positively in the rule body. All what we
Unfortunately S2 is not safe now, since
it für
doesInformatik
not occur
Institut
immediately thinks about the_________________________|__________________________________
final internal representation (commonly called operator graph) before
can do is to bind S2 existentially
within
the negation,
which means to| cut off the explanation
at
/ At that
\ we
Orleansstr.
the code-generator is called.
level
we have34all collected informations.
But if we do so,
conference(vancouver,
ilps93)
interesting(ilps93)
negation. That’sflight(munich,
the reason whyvancouver)
mostD-81667
deductive
database
systems
are
not
able
to
explain
negation.
München optimization techniques,
obtain an enormous drawback:
If we use rule-rewriting
like the magic
|
|
| set
|
|
| the
Our
solution is to
introduce
an specht@informatik.tu-muenchen.de
additional
positive
predicate
for
the
negative
explanation. Then
email:
transformation,
then
we explain
the
transformed
program,
not
the
original
one.
r2
base
r5
rule above _______________|______________
can be transformed into:
| at
That can be
avoided by putting the proof tree
generator as a source-to-source transformation right
/
\
|
qq(qq(r1(S1,$not(S2)),X,Y),
X,Y)
:Abstract:
the beginning, which
transforms aflight(frankfurt,
logic program intovancouver)
another one, containing additional
attributes
directflight(munich,
frankfurt)
logic_prog(ilps93)
|
|
|
g(S1,
X,Y),Now, later rule-rewriting
with explanation
information.
techniques don’t matter any more.
Although
there
| were enormous research efforts|on explanation and debugging tools for Prolog in
|
$not
p(_,Y),
basegood tools for bottom-up evaluating
r2
base
the This
last years,
logic
programming
systems
are
still
missing,
method
hasexplain_not_p(S2,
several advantages:
Y).
____________|____________
since
the underlying
proof trees
matchesdatabase
several
problems
\
• the
It isgeneration
a modular of
extension
of/the underlying
deductive
systems, in presence of negaNow
the
negation
is
safe
and
we
obtain
the
explanation
tree
for
the negated subgoal
p from the
directflight(frankfurt,
ny)
flight(ny,
vancouver)
tion• and
This
wants
to fill the(=compiler)
gap and presents
a source-to-source
transformation
norecursion.
modification
of paper
the inference-system
are required,
|
|
new explain-not
predicate.
But|for
how
must theevaluating
predicate explain_not_p
be defined?
the original
to compute
complete
proof
trees
bottom-up
systems,
so compiler,
that
advanced Let
techniques,
| in the
• independent
from
the internal
representation
of the program
clauses
be:
base
r1
developed
for top-down
will once
be usable for techniques
bottom-up
systems as well. The presented
• independent
from systems,
rule-rewriting
and optimization
and
|
r1:
qq(X,Y)
:g(X,Y),
$not
p(Y).
|
technique
is
implemented
and
in
use
in
the
deductive
database
system
LOLA.
• independent from the evaluation system (run time system).
r2:
:- r(X,Y), s(Y,Z).
I.e. inp(X)
the result:
r3: p(X) :- t(X,Y), s(Y,Z).
• independence from the underlying
directflight(ny, vancouver)
|
|
deductive database system:
I.e. this proof
base
1. r4:Introduction:
g(1,2).
usable
for every bottom-up evaluating logic programming system.
tree generator is
Why
is then
$not
p(2)data
valid?
Of course
ruleprograms
r2 and rule
r3
haveonto
fail. For
each
of them
n+1
Problems
arise,
if cyclic
exists.
Then
the
bottom-up
computing
the(also
fixpoint,
Most
explanation
and
debugging
tools
for
logic
areapproach,
based
proof
trees
calleddoes
(n
=
number
of
subgoals)
different
cases
can
be
distinguished
for
the
failure:
Either
the
rule
head
is
not terminate
If
we haveis anot
cycle
in our flight
net, then
building
the derivation
explanation
trees).any
If longer:
a logic
program
evaluated
top-down
andSubgoals
"tuple
at auptime"
like Prologterm
3.
Proof-Tree
Transformation
for
positive
not
unifiable
- thatand
case
doesn’t
occur
here,
sinceofthe
head
ofpath
p contain
only
in but
the
first attribute
influences
the termination,
since
thepredicates
derivation
goingvariables
straight
ahead- or
is
does,
bottom-up
"set
at a time"
like most
the
deductive
database
systems
(e.g. LOLA,
1
the
relation
of
the
first
predicate
contains
no
unifiable
tuple,
or
it
does,
but
the
join
with
the
second
different
thatCORAL,
one cycling
once,etc.)
and from
cycling
twice
so on.proof trees, espeLDL,
NAIL,from
ADITI,
IDEA,
do it, that
it isone
rather
difficult
to and
generate
The
base
technique
is
to
introduce
one
new
attribute
in
each
predicate,
for
constructing
the
derivais
empty,
or
....
the
first
i
subgoals
are
satisfiable,
but
the
join
to
the
i+1st
subgoal
empty.
Each
cially
in the
of negation,
since
like rangeand
restriction,
stratification
andissafe
negaWhat
cancase
be done
to get back
therestrictions
original termination
semantics?
Two possible
solutions
can
tion
term.
This
may
be
illustrated
by
an
case
can
be
expressed
in
an
own
explain-not
rule:
tionbe
arefound:
required
in
the
bottom-up
approach.
That
is
the
reason
why
most
of
the
currently
available
One - strictly saving the source-to-source approach - is to include additional attributes,
2
Example:
deductive
databases
noconnections,
or only rudimental
explanation
facilities.
containing
a list include
of all old
and new
test predicates,
like $not member, testing if the
Transformation
example:
r1:paper
flight(From,
To)
connections
are that
not
already
elements
the old
ones. To).
(By
the way:complete
memberproof
should
be impleThisnew
wants to fill
gap:anddirectflight(From,
presents in
a new
technique
to compute
trees
for
r2:
p(X)
:r(X,Y),
s(Y,Z).
flight(From,
To)
:directflight(From,
Via),
mented
as
built-in
predicate.)
bottom up evaluating logic programming systems (henceforth called deductive databases): A
flight(Via,
To).
becomes:
source-to-source
transformation
converts
a given
logic program
into the
a program
that includes
explaA more elegant
solution to the
problem
is possible,
if we know
implementation
of the
internal
r3: directflight(munich, frankfurt).
nation
or trace
information. Then
Evenwerecursive
anditnegated
be explained correctly.
r2_1:
explain_not_p(because_not(p(r2(S1),X)),
X):- can
seminaive
Delta-Iterator.
can modify
to ignoresubgoals
specified
attribute-positions.
In our conHere
wequeries
have
aare
very
program
with
one
recursive
concatenating
direct
flights
to
"Why-not"
possible
too,
showing
expected
result
cannot
be which
deduced
form
$not
Y,why
r(X,Y)),
text the
first
attribute
issimple
not ($exists
6-relevant,
since
it an
contains
justclause,
the proof
tree,
is only
athe
result
flights.
It
is
transformed
to:
given
rules and
facts.
computed
proof treesAll
canwhat
either
shown
directly
as explanation
trees
explain_not_r(S1,
X,’Y’).
parameter
and
neverThe
restricts
the evaluation.
webehave
to do
is to extend
the set-difference
within
a
graphical
user-interface,
allowing
zooming
and
shrinking
operations,
or
be
used
as
input
r1’:
flight(flight(r1(S1),
From,
To),
From,
To)
:within the Delta-Iteration in that way, that it just compares all but the first term position. That’s the
explain_not_p(because_not(p(r2(S1,S2),X)),
X):3
directflight(S1,
From,
To).
for r2_2:
advanced
explanation
and
debugging
tools as developed
in details
the top-down
(e.g. [1,
reason
why
I call this an
one-eyed
Delta-Iteration.
(for more
see [8])environment
r(S1,X,Y),
flight(flight(r2(S1, S2), From, To), From, To) :2, 4,r2’:
9, 11]).
$not ($exists
Z, s(Y,Z)), From, Via),
directflight(S1,
The paper is organized as follows: Section 2 motivates, why we select a source-to-source transforexplain_not_s(S2,
Y,’Z’). Via, To).
flight(S2,
mation
as best technique. In section 3 the positive explanation transformation is presented and in
__________________
r3’:3 4 directflight(directflight(base,
munich,
frankfurt),
munich,section
frankfurt).
section
solveisthe
problems
arising,
negation
occurs.
5 shows
how one
Thatwe
technique
useful
also in other
parts of awhen
deductive
database system.
TheFinally
set-difference is an expensive
operaWith
the
informal
meaning:
If
there
exists
no
Y
so
that
r(X,Y)
is
valid,
then
explain_not_r.
If
tion.
It
might
be
a
good
optimization
using
the
one-eyed
Delta-Iteration,
looking
just
at
the
primary-keys
of
the
relations,
can ask why-not queries using this technique.
r(X,Y)
is valid,
but thethejoin
to the second subgoal is empty, then explain_not_s.
since
all others
can’t influence
set-difference.
__________________
1
for an overview see e.g. [6].
Wieland [10] developed proof trees on datalog programs, but his approach can not handle terms, negations and
source-to-source optimizations. Shmueli and Tsur [7] connected the Prolog debugger in [4] to LDL.
2
---11
10
12
9 --4.
forTransformation?
negative Subgoals
2. Proof-Tree
Why using aTransformation
Source-to-Source
Published
in: the
Procnew
of
the
5th Workshop
on
Logicprinted
Programming
Environments,
October
1993,
in con-which
The call
We
informal
meaning
body
predicates
of the new,
positive
bold
or negative
part ofdecision
rule r2’ predicates,
is: If29-30
we know
sincethe
they
derivation
decide
S1 of
junction
with
International
Logic
Programming
Symposium
(ILPS
’93)
Vancouver,
Canada,
1993,
pp.
8-13
explain-not predicates
directflight
and ifare
werelevant.
know already the derivation S2 of flight, then we can build up the
derivation
term
in
next
step,
bywe
concatenating
thesubgoals,
thebound
rule-ID
as
functor
and
Some
of the
variables,
aboutthis
which
definitely
know,
that
they
can’t
be
any
time,and
have
The
architecture
problem
arising,
of the
a deductive
using
database
technique
system
for negated
looks
insubterms,
general
isasusing
the
follows:
violation
A logic
of at
safe
program
negation.
Ifa
inserting
this
term to
inby
a term
containing
bindings
of
thepropagated
head.
to be
transformed
special
constants,
which
have to
be
in aincluding
separate way,
that also
query
we
have
arethe
translated
rule:
a compiler
intothe
a relational
algebra
expression,
joins,soselections,
The
same
transformation
to becode
done
facts,
where
the
derivation
termThe
is the
marked
"base".
If
Generating
Trees
for
Negations
unification
andg(X,Y),
propagation
paths
for
unbindable
variables
will
be
visible
in
finalasexplanation
seminaive-iterations,
etc. has
.Explanation
This
isfor
evaluated
in aeven
runtime
system.
evaluation
mode is
qq(X,Y)
:$not
p(Y).
we
a transformed
logicusing
program
with more
rules and
facts
weLogic
get e.g.
the following
tree.evaluate
Different
propagation
paths
can be
byfixpoint
augmenting
the literals.
bottom-up
and
set atin
a time,
thereached
iterative
semantics.
programs
can be proof
arbiDeductive
Database
Systems
and
if we transform this
clause
straight ahead,
then we would
get the wrong clause:
tree:
trarily
recursive,
include
terms, trees
stratified
negation,
The finally
received
explanation
will look
like: built-in predicates (defined outside the logic
qq(qq(r1(S1,
$not(S2)),X,Y),X,Y)
:- databases, which deal as fact-servers. Only safety,
programming language)
and calls to Günther
external
Specht
g(S1, X, Y),
trip(munich, vancouver)
stratification
and
range
restriction
are
required.
qq(1,2)
qq(1,2)
|
$not p(S2, Y)).
| a|proof tree generator in the system, one
Universität
München
Considering||which might be Technische
the best place
to integrate
r4 |
Unfortunately S2 is not safe now, since
it für
doesInformatik
not occur
positively in the rule body. All what we
Institut
immediately
final internal
representationr1
(commonly called operator graph) before
r1 thinks about the
_________________________|__________________________________
can do
is to bind S2 existentially
within
the negation,
which means to| cut off the explanation
at
______|______
__________|_________
/ At that
\ we
Orleansstr.
34all collected
the code-generator
is
called.
level
we have
informations.
But if we do so,
/
\ reason whyvancouver)
/ database
\not able
flight(munich,
conference(vancouver,
ilps93)
interesting(ilps93)
negation.
That’s
the
most
deductive
systems
are
to
explain
negation.
München optimization
g(1,2)
$notdrawback:
p(2) |
g(1,2)
$not
p(2)
obtain
an enormous
If weD-81667
use rule-rewriting
techniques,
like the magic
|
| set
|
|
|
||
|
| the
Our
solution is to
introduce
an specht@informatik.tu-muenchen.de
additional
positive
predicate
for
the
negative
explanation. Then
email:
transformation,
then
we
explain
the
transformed
program,
not
the
original
one.
|
|
|
|
r2
base
r5
rule
aboveneither
can be transformed
into: r2
base
r2 nor r3, here:
base
neither r2 nor r3, here: r3
_______________|______________
| at
That can be
avoided |by putting the proof tree
generator as a source-to-source
transformation right
________|_______
/
\
|
qq(qq(r1(S1,$not(S2)),X,Y),
X,Y)
:Abstract:
| transforms a
/ one, containing \
the beginning, which
logic program intovancouver)
another
additional
attributes
directflight(munich,
frankfurt)
flight(frankfurt,
logic_prog(ilps93)
r(2,Y)
t(2,4)
but_not s(4,Z)
| because_not
|
|
g(S1,
X,Y),Now, later rule-rewriting
with explanation
information.
techniques
don’t matter
any
more.
Although
there
research efforts|on explanation
tools
Prolog in
|
|and debugging
| for
| were enormous
|
$not
p(_,Y),
|
|
|
basegood tools
r2
base
the This
last years,
for
bottom-up
evaluating
logic
programming
systems
are
still
missing,
method
has
several
advantages:
no_such_fact
r4
no_such_fact
explain_not_p(S2,
Y).
____________|____________
___|___
since
the underlying
proof trees
matchesdatabase
several
problems
\
• the
It isgeneration
a modular of
extension
of/the underlying
deductive
systems, in presence of nega/ treevancouver)
\ the negated subgoal p from the
the negation
is safe
and
we obtain
the
explanation
directflight(frankfurt,
ny)
flight(ny,
tionNow
This
wants
to fill the
gap
and
presents
afor
source-to-source
transformation
• and
norecursion.
modification
of paper
the inference-system
(=compiler)
are required,
t2(2,3)
t3(3,4)
|
|
new explain-not
predicate.
But|for
how
must theevaluating
predicate explain_not_p
be defined?
Let
the original
|
|
to compute
complete
proof
trees
bottom-up
systems,
so
that
advanced
techniques,
|
• independent from the internal representation of the program in the compiler,
|
|
clauses
be:
base
r1
developed
for top-down
will once
be usable for techniques
bottom-up
systems as well. The presented
• independent
from systems,
rule-rewriting
and optimization
and
base |
base
r1:
qq(X,Y)
:g(X,Y),
$not
p(Y).
|
technique
is
implemented
and
in
use
in
the
deductive
database
system
LOLA.
• independent from the evaluation system (run time system).
directflight(ny, vancouver)
r2:
:- r(X,Y), s(Y,Z).
|
I.e. inp(X)
the result:
What
we presented
now was
the base idea of our transformation
approach. But the transformation
|
r3: p(X)
:- t(X,Y),
s(Y,Z).
• independence from the underlying deductive database system: I.e. this proof tree generator is
A number of techniques
have to cooperate, so that all works correctly:
negated
strata is much more complex than it looks atbase
the first view.
1. of
Introduction:
r4:
g(1,2).
usable
for every bottom-up evaluating logic programming system.
then
$not
p(2)data
valid?
Of course
rule
r2 and in
rule
r3
have
fail.
each
ofmight
them
n+1
-Why
Ofiscourse
the
Delta-Iteration
isthe
necessary
negated
strata
too, For
since
there
also
Problems
arise,
if"one-eyed
cyclic
exists.
Then
bottom-up
approach,
computing
the
fixpoint,
Most
explanation
and
debugging
tools
for
logic
programs
are
based
onto
proof
trees
(also
calleddoes
(n
=
number
of
subgoals)
different
cases
can
be
distinguished
for
the
failure:
Either
the
rule
head
is
recursive
with
cyclic
data.
not occur
terminate
any
If
we
have
cycle
in our flight
net, then
building
the derivation
explanation
trees).
If longer:
apredicates
logic
program
is anot
evaluated
top-down
andSubgoals
"tuple
at auptime"
like Prologterm
3.
Proof-Tree
Transformation
for
positive
unifiable
- thatand
case
doesn’t
occur
here,
since
ofpath
p then
contain
only
in but
the
first
attribute
thepredicates
termination,
since
thepredicates
derivation
going
straight
ahead- or
is
does,
bottom-up
"set
at a time"
like most
ofthe
the
deductive
database
systems
(e.g. LOLA,
-not
The
generation
ofinfluences
explain-not
stops
athead
the
next
negation,
thevariables
positive
explana1
the
relation
of
the
first
predicate
contains
no
unifiable
tuple,
or
it
does,
but
the
join
with
the
second
different
thatCORAL,
oneAt
cycling
once,
and from
cycling
twice
and
sobe
on.proof
LDL,
NAIL,
ADITI,
etc.)
dothe
it, that
it
isone
rather
difficult
tohas
generate
trees,
espe-That
tion isfrom
sufficient.
theIDEA,
next
negation
negative
explanation
to
invoked
again.
The
base
technique
is
to
introduce
one
new
attribute
in
each
predicate,
for
constructing
the
derivais
empty,
or
....
the
first
i
subgoals
are
satisfiable,
but
the
join
to
the
i+1st
subgoal
is
empty.
Each
cially
incan
the
of negation,
since
like range
restriction,
stratification
andthesafe
negabecase
expressed
additional
strata-concept,
which
starts
at the
query
not at
facts.
What
can
be
done
to in
getanback
therestrictions
original
termination
and
semantics?
Two possible
solutions
can
tion
term.
This
may
be
illustrated
by
an
case
can
be
expressed
in
an
own
explain-not
rule:
tion-be
arefound:
required
in
the
bottom-up
approach.
That
is
the
reason
why
most
of
the
currently
available
One mentioned,
- strictly saving
the source-to-source
approach
is to include
additional attributes,
As already
a distinction
has to be made
for all -negated
variable-positions,
if there
2
Example:
deductive
databases
include
no
or
only
rudimental
explanation
facilities.
containing
a
list
of
all
old
connections,
and
new
test
predicates,
like
$not
member
,
testing
the
will be a variable-binding at run-time or not. Variable-positions have to be adorned in v-if and
Transformation
example:
r1:
flight(From,
To)
:directflight(From,
To).
connections
areboth
not already
elements
in
the
old
ones.
(By
the way:
member
should
bea impleThisnew
paper
wantswhere
to fill
that
gap
presents in
a new
technique
to since
compute
complete
proof
trees
for
t-terms,
are and
propagated
different
paths,
a v-term,
containing
metar2:
p(X)
:r(X,Y),
s(Y,Z).
flight(From,
To)
:directflight(From,
Via),
mented
as
built-in
predicate.)
bottom constant,
up evaluating
logic programming
systems
(henceforth
called
is not allowed
to be unified with
a t-term,
containing
termsdeductive
of the userdatabases):
program. A
flight(Via,
To).
becomes:
source-to-source
transformation
converts
a
given
logic
program
into
a
program
that
includes
explaA
elegant
solution
to the problem
is possible,
we knowtothegetimplementation
of the
internal
- more
Since
we have
to propagate
variable
bindings iftop-down
the right restrictions
in the
r3:
directflight(munich,
frankfurt).
nation
or
trace
information.
Even
recursive
and
negated
subgoals
can
be
explained
correctly.
r2_1:
explain_not_p(because_not(p(r2(S1),X)),
X):seminaive
Delta-Iterator.
Then
we
can
modify
it
to
ignore
specified
attribute-positions.
In
our
connegated decision predicates, a following magic set transformation for partially instantiated
Here
we
have
a
very
simple
program
with
one
recursive
clause,
concatenating
direct
flights
to
"Why-not"
queries
are
possible
too,
showing
why
an
expected
result
cannot
be
deduced
form
the
$not
($exists
Y,
r(X,Y)),
textterms
the first
is templates
not 6-relevant,
it contains just the proof tree, which is only a result
likeattribute
the magic
[5] is since
needed.
flights.
It
is
transformed
to:
given
rules and
facts.
computed
proof treesAll
canwhat
either
shown
directly
as explanation
trees
explain_not_r(S1,
X,’Y’).
parameter
and
neverThe
restricts
the evaluation.
webehave
to do
is to extend
the set-difference
- aPropagating
partially instantiated
terms
via magic
sets into negations
leads
to used
unification-joins
within
graphical
user-interface,
allowing
zooming
and
shrinking
operations,
or
be
as
input
r1’:
flight(flight(r1(S1),
From,
To),
From,
To)
:within the Delta-Iteration in that way, that it just compares all but the first term position. That’s the
within
the negation,and
since
the magic
predicates
are noFrom,
longer
range
restricted.
But since
explain_not_p(because_not(p(r2(S1,S2),X)),
X):3
directflight(S1,
To).
for r2_2:
advanced
explanation
debugging
tools
as developed
in
the top-down
(e.g.most
[1, of
reason
why
I call this an one-eyed
Delta-Iteration.
(for more
details
see [8])environment
deductive database
systems
an underlying unification algebra,
r(S1,X,Y),
flight(flight(r2(S1,
S2),
From,nowadays
To), From,don’t
To) support
:2, 4,r2’:
9, the
11]).
including unification-joins,
unification-selections
etc.,
we
have to eliminate the generated
$not ($exists
Z, s(Y,Z)), From, Via),
directflight(S1,
The paper
is
organized
as
follows:
Section
2
motivates,
why
we
select
a source-to-source
transforunification-join. This
can be done using
a Y,’Z’).
second magic
transformation
within the
negation
explain_not_s(S2,
flight(S2,
Via,setTo).
mation
as best
technique.
In section
3 the that
positive
explanation
transformation
is presented
and
in to
__________________
with
an
inverse
SIP.
We
proved,
that’s
the
way
to
solve
one-sided
unification
joins
r3’:3 4 directflight(directflight(base,
munich,
frankfurt),
munich,
frankfurt).
section
we
solve
the
problems
arising,
when
negation
occurs.
Finally
section
5
shows
how
one
That technique is useful
also
in other
of a deductive database system. The set-difference is an expensive opera(For
details
see
[8]).
Withground-joins.
the informal
meaning:
If parts
there
exists no Y so that r(X,Y) is valid, then explain_not_r. If
might be aqueries
good optimization
usingtechnique.
the one-eyed Delta-Iteration, looking just at the primary-keys of the relations,
can tion.
askItwhy-not
using this
r(X,Y)
is valid,
but thethejoin
to the second subgoal is empty, then explain_not_s.
since
all others
can’t influence
set-difference.
__________________
1
for an overview see e.g. [6].
Wieland [10] developed proof trees on datalog programs, but his approach can not handle terms, negations and
source-to-source optimizations. Shmueli and Tsur [7] connected the Prolog debugger in [4] to LDL.
2
---11
10
12
13
9 --4.
forTransformation?
negative Subgoals
2. Proof-Tree
Why using aTransformation
Source-to-Source
Published
in: the
Proc
of
the
5th Workshop
on
Logicprinted
Programming
Environments,
October
1993,
in conTheFinally
-We
call
informal
some
new
meaning
body
optimizations
predicates
of the new,
(in
positive
particular
bold
or to
negative
minimize
part ofdecision
rule
ther2’
number
predicates,
is: If29-30
we
of decision
know
sincethe
they
predicates)
derivation
decide
can
which
S1 be
of
junction
with
International
Logic
Programming
Symposium
(ILPS
’93)
Vancouver,
Canada,
1993,
pp.
8-13
explain-not
included.predicates
Of and
course
one
relevant.
does already
not needthetoderivation
generate each
time
all decision
some
are
directflight
ifare
we
know
S2 of
flight
, then predicates,
we can build
up the
redundant,
some
be this
omitted
subgoal-reordering
andthey
soisas
on.
derivation
term
in
next
step,
byby
concatenating
thesubgoals,
using
thebound
rule-ID
as
functor
and
Some
of the
variables,
about
which
we
definitely
know,
that
can’t
be
any
time,and
have
The
architecture
problem
arising,
of the
acan
deductive
using
database
technique
system
for negated
looks
insubterms,
general
the
follows:
violation
A logic
of at
safe
program
negation.
Ifa
inserting
this
termthat
inby
a the
term
containing
bindings
of
theabove
head.
It
to can
be
transformed
bethe
shown
to
special
transformation,
constants,
which
including
have to
the
be
propagated
itemsinisaincluding
correct
separateand
way,
complete
soselections,
that also
and
query
we
have
are
translated
rule:
a compiler
intothe
a relational
algebra
expression,
joins,
The
same
transformation
has
torestriction
becode
done
facts,
where
the
derivation
termThe
is the
marked
"base".
If
Generating
Trees
Negations
preserves
unification
stratification,
andg(X,Y),
propagation
range
paths
for
unbindable
and
safe
negation.
variables
will
Thefor
be
last
visible
three
items
in
guarantee
finalasexplanation
that the
seminaive-iterations,
etc.
.Explanation
This
isfor
evaluated
in aeven
runtime
system.
evaluation
mode
is
qq(X,Y)
:$not
p(Y).
we
alogic
transformed
logic
program
with more
rules For
and
facts
weLogic
get e.g.
thefor
following
transformed
tree.evaluate
Different
propagation
paths
is bottom-up
can be
evaluable
byfixpoint
again.
augmenting
detailed
the literals.
proofs
and
ancan
estimation
bottom-up
and
setprogram
atin
a time,
using
thereached
iterative
semantics.
programs
be proof
arbiDeductive
Database
Systems
and
if we transform this
clause
straight ahead,
then we would
get the wrong clause:
tree:
of
showing
that
this trees
approach
isnegation,
stilllike:
efficient,
see predicates
[8].
trarily
recursive,
include
terms,
stratified
built-in
(defined outside the logic
Thecomplexity,
finally
received
explanation
will look
qq(qq(r1(S1,
$not(S2)),X,Y),X,Y)
:- databases, which deal as fact-servers. Only safety,
programming language)
and calls to Günther
external
Specht
g(S1, X, Y),
trip(munich, vancouver)
stratification
and
range
restriction
are
required.
qq(1,2) p(S2, Y)).
qq(1,2)
|
5.
Why|$not
-which
Notmight
Queries
| a|proof tree generator in the system, one
Technische
Universität
München
Considering
be
the
best
place
to
integrate
| S2 is not safe now, since it does not occur
r4 |
Unfortunately
positively in the rule body. All what we
Institut für
Informatik r1
immediately
final internal
representation
(commonly called operator graph) before
r1 thinks about the
_________________________|__________________________________
can do
is to bind S2 existentially
within
the negation,
which means to| cut off the explanation
at
______|______
__________|_________
\ are
Orleansstr.
34allproof
thethe
code-generator
is
called.
At", that
we
have
collected
if we
do we
so,
we
thenlevel
there
exists
no
tree. informations.
But \especiallyBut
in this
case,
If
to a query
is /"no
/ answer
\ reason
/ database
flight(munich,
vancouver)
conference(vancouver,
ilps93)
interesting(ilps93)
negation.
That’s
the
why
most
deductive
systems
are
not
able
to
explain
negation.
München
g(1,2)
p(2)
g(1,2)
$not
p(2)
obtain
an enormous
drawback:
If weD-81667
use
rule-rewriting
techniques,
like the
magic
set
interested
in one.$not
The
idea|is simple:
Allowing
the user optimization
why-not queries,
we just have
to negate
|
| the
|
|
|
||
|
| the
Our
solution
is to
introduce
an specht@informatik.tu-muenchen.de
additional
positive
predicate
for
the
negative
explanation.
Then
email:
transformation,
then
we
explain
the
transformed
program,
not
the
original
one.
query
and
start
the
explain-not
transformation.
The
transformation
is
powerful
enough
to
handle
|
|
|
|
r2
base
r5
rule
above
canqueries
be transformed
into: r2
base
neither
r2 without
nor r3, modifications
here:
base
neither r2 nor r3, here: r3
_______________|______________
| at
also
why-not
or
additions.
That can be
avoided
by
putting
the
proof
tree
generator
as
a
source-to-source
transformation
right
|
________|_______
/
\
|
qq(qq(r1(S1,$not(S2)),X,Y),
X,Y)
:Abstract:
| transforms a
\
the
beginning,
which
logic program
another
one,
containing
additional
attributes
So the
explanation
transformation
becomes
a usefulinto
base
tool/for
further
debugging
tools
for
deducdirectflight(munich,
frankfurt)
flight(frankfurt,
vancouver)
logic_prog(ilps93)
r(2,Y)
t(2,4)
but_not s(4,Z)
| because_not
|
|
g(S1,
X,Y),
with
explanation
information.
Now, later
don’t matter any
more.
tive databases,
especially
by expected,
butrule-rewriting
not
computedtechniques
answer tuples.
Although
there
research
efforts
Prolog in
|
| for
| were enormous
|on explanation |and debugging tools
|
$not
p(_,Y),
|
|
|
basegood tools
r2
base
the This
last years,
for
bottom-up
evaluating
logic
programming
systems
are
still
missing,
method
has
several
advantages:
no_such_fact
r4
no_such_fact
explain_not_p(S2,
Y).
____________|____________
___|___
since
the underlying
proof trees
matchesdatabase
several
problems
\
• the
It isgeneration
a modular of
extension
of/the underlying
deductive
systems, in presence of nega/ treevancouver)
\ the negated subgoal p from the
the negation
is safe
and
we obtain
the
explanation
directflight(frankfurt,
ny)
flight(ny,
6.
and
Outlook
tionNow
recursion.
This
wants
to fill the
gap
and
presents
afor
source-to-source
transformation
• and
noConclusion
modification
of paper
the
inference-system
(=compiler)
are required,
t2(2,3)
t3(3,4)
|
|
new explain-not
predicate.
But|for
how
must theevaluating
predicate explain_not_p
be defined?
Let
the original
|
|
to compute
complete
proof
trees
bottom-up
systems,
so
that
advanced
techniques,
|
• independent from the internal representation of the program in the compiler,
|
|
clauses
be:
base
r1
developed
for top-down
systems,
willa once
be usable fortransformation
bottom-up
systems
as well. The
presented
• independent
from
rule-rewriting
and optimization
techniques
and
We
presented
the
basic
ideas of
source-to-source
for constructing
complete
proof
base |
base
r1:
qq(X,Y)
:g(X,Y),
$not
p(Y).
|
technique
is
implemented
and
in
use
in
the
deductive
database
system
LOLA.
• independent
from the evaluation
system
(run timewith
system).
trees
for logic programs,
when deductive
databases
bottom-up evaluation mode are used. Even
directflight(ny, vancouver)
r2:
p(X)
:r(X,Y),
s(Y,Z).
negation
and
recursion
can
be
explained,
so
that
why-not
queries
are possible too. The proof trees
|
I.e. in the result:
What
we
presented
now
was
the
base
idea
of
our
transformation
approach.
But the techniques
transformation
|
r3:
p(X)
:t(X,Y),
s(Y,Z).
correspond
to thefrom
original
user program
in any
case, system:
even when
rule-rewriting
• independence
the underlying
deductive
database
I.e. this
proof tree generator
is are
base
of
negated
strata
is
much
more
complex
than
it
looks
at
the
first
view.
A
number
of techniques
1. r4:
Introduction:
applied.
The
main
problems
have
been
the
preservation
of
safe
negation
and
range
restriction.
The
g(1,2).
usable for every bottom-up evaluating logic programming system.
have
to
cooperate,
so
that
all
works
correctly:
transformation together with some further explanation tools are implemented and in use in the
then
$not
p(2)data
valid?
Of
rule
r2
and trees
rule
r3
have
fail.
each
of
them
n+1
deductive
database
system
LOLA
[3].course
Since
now
proof
and
explanation
trees
are
available
for
-Why
Ofiscourse
the
Delta-Iteration
isthe
necessary
in
negated
strata
too, For
since
there
might
also
Problems
arise,
if"one-eyed
cyclic
exists.
Then
bottom-up
approach,
computing
the
fixpoint,
Most
explanation
and
debugging
tools
for
logic
programs
are
based
onto
proof
trees
(also
calleddoes
(n
=
number
of
subgoals)
different
cases
can
be
distinguished
for
the
failure:
Either
the
rule
head
is
bottom-up
evaluating
systems,
many
results
of our
the flight
research
and
interm
the
recursive
with
cyclic
data.
not occur
terminate
any
If
we
have
cycle
in
net,on
then
building
thedebugging
derivation
explanation
trees).
If longer:
apredicates
logic
program
is anot
evaluated
top-down
andexplanation
"tuple
at aup
time"
like Prolog
3.
Proof-Tree
Transformation
for
positive
Subgoals
unifiable
- thatand
case
doesn’t
occur
here,
since
ofpath
p then
contain
only
top-down
approach
can
be at
linked
topredicates
deductive
databases
aspredicates
well.
in but
the
first
attribute
influences
the
termination,
since
the
derivation
going
straight
ahead- or
is
does,
bottom-up
"set
a time"
like most
ofthe
the
deductive
database
systems
(e.g. LOLA,
-not
The
generation
of
explain-not
stops
athead
the
next
negation,
thevariables
positive
explana1
the
relation
of
the
first
predicate
contains
no
unifiable
tuple,
or
it
does,
but
the
join
with
the
second
different
thatCORAL,
oneAt
cycling
once,
and from
cycling
twice
and
sobe
on.proof
LDL,
NAIL,
ADITI,
etc.)
dothe
it, that
it
isone
rather
difficult
tohas
generate
trees,
espe-That
tion isfrom
sufficient.
theIDEA,
next
negation
negative
explanation
to
invoked
again.
The
base
technique
is
to
introduce
one
new
attribute
in
each
predicate,
for
constructing
the
derivais
empty,
or
....
the
first
i
subgoals
are
satisfiable,
but
the
join
to
the
i+1st
subgoal
is
empty.
Each
cially
incan
the
of negation,
since
like range
restriction,
stratification
andthesafe
negabecase
expressed
additional
strata-concept,
which
starts
at the
query
not at
facts.
What
can
be
done
to in
getanback
therestrictions
original
termination
and
semantics?
Two possible
solutions
can
tion
term.
This
may
be
illustrated
by
an
case
can
be
expressed
in
an
own
explain-not
rule:
tionReferences:
are
required
in
the
bottom-up
approach.
That
is
the
reason
why
most
of
the
currently
available
One mentioned,
- strictly saving
the source-to-source
approach
is to include
additional attributes,
-be found:
As already
a distinction
has to be made
for all -negated
variable-positions,
if there
2
[7] Shmueli
O., Tsur
S.: Logical Diagnosis of LDL
[1]
Ducasse
M.: Aninclude
Extendable
Trace
Analyser
to Sup- explanation
Example:
deductive
databases
no
or
only
rudimental
facilities.
containing
a
list
of
all
old
connections,
and
new
test
predicates,
like
$not
member
,
testing
the
will
be a variable-binding
at run-time
or not. Variable-positions
have
beConf.
adorned
in v-if and
Programs, Proc.
7th toInt.
on Logic
Proport Automated
Debugging, Ph.D.
thesis, UniverTransformation
example:
r1:
flight(From,
To)
:directflight(From,
To).
connections
areboth
not
already
elements
in
the
old
ones.
(By
the (ICLP
way:
member
should
bea implegramming
’90),
Jerusalem,
Israel,
MITsite
de
Rennes,
Tech.
Report
ECRC-92-33
Thisnew
paper
wants
to 1992,
fill
that
gap
and
presents in
a new
technique
to since
compute
complete
proof
trees
for
t-terms,
where
are
propagated
different
paths,
a v-term,
containing
metaPress
1990,
pp.
112-129
r2:
p(X)
:r(X,Y),
s(Y,Z).
flight(From,
To)
:directflight(From,
Via),
mented
as
built-in
predicate.)
[2]
Ducasse
M.:
Opium+:
A
Meta-Debugger
for
Probottom constant,
up evaluating
logic programming
systems
(henceforth
called
is not allowed
to be unified with
a t-term,
containing
termsdeductive
of the userdatabases):
program. A
flight(Via,
[8] To).
Specht
G.:aSource-to-Source
Transformationen
zur
log, Proc. 8th
European Conference
onaArtificial
becomes:
source-to-source
transformation
converts
given
logic
program
into
program
that
includes
explaA
elegant
solution
to 272-277
the problem
is possible,
weErklärung
knowtothe
of bei
the
internal
- more
Since
we (ECAI
have
to propagate
variable
bindings iftop-down
getimplementation
the right restrictions
in the
des
Programmverhaltens
deduktiven
Intelligence
’88),
pp.
r3:
directflight(munich,
frankfurt).
nation
or
trace
information.
Even
recursive
anditnegated
subgoals
befor
explained
correctly.
Ph.D.
thesis,
TU München
r2_1:
explain_not_p(because_not(p(r2(S1),X)),
X):- can
seminaive
Delta-Iterator.
Then
to ignore
specified
attribute-positions.
In our 1992,
connegated
decision
a can
following
setDatenbanken,
transformation
partially
instantiated
[3]
Freitag
B.,
Schütz H.,predicates,
Specht
G.:we
LOLA
- modify
A Logic magic
DISKI
42, infix-Verlag,
1993
Here
we
have
a
very
simple
program
with
one
recursive
clause,
concatenating
direct
flights
to
"Why-not"
queries
are
possible
too,
showing
why
an
expected
result
cannot
be
deduced
form
the
Language
for
Deductive
Databases
and
its
Imple$not
($exists
Y,
r(X,Y)),
textterms
the first
is templates
not 6-relevant,
it contains just the proof tree, which is only a result
likeattribute
the magic
[5] is since
needed.
[9]
Sterling
L.,
Yalcinalp
L.U.
:
Explaining
Prolog
mentation,
Proc.
2nd
Int.
Symp.
on
Database
Sysflights.
It
is
transformed
to:
given
rules and
facts.
computed
proof treesAll
canwhat
either
behave
shown
directly
as explanation
trees
explain_not_r(S1,
X,’Y’).
parameter
neverThe
restricts
the (DASFAA
evaluation.
webased
to do
is
to extend
thea set-difference
systems
using
layered metatems forand
Advanced
Applications
’91),
- aPropagating
partially
instantiated
terms
via magic
sets into expert
negations
leads
to used
unification-joins
within
graphical
user-interface,
allowing
zooming
and
shrinking
operations,
or
be
as
input
r1’:
flight(flight(r1(S1),
From,
To),
From,
To)
:within
the1991,
Delta-Iteration
all but the
term position. That’s the
interpreter,
Proc.first
of IJCAI’89
Tokyo
pp. 216-225 in that way, that it just compares
within
the negation,and
since
the magic
predicates
are noFrom,
longer
range
restricted.
But since
most of
explain_not_p(because_not(p(r2(S1,S2),X)),
X):3
directflight(S1,
To).
for r2_2:
advanced
explanation
debugging
tools
as developed
in
the top-down
(e.g.
Wieland
C.:
zu [1,
einem
reason
why
I call
this an one-eyed
Delta-Iteration.
(for[10]
more
details
seeErklärungskomponente
[8])environment
[4]
Lloyd
J.W.:
Declarative
Error
Diagnosis,
New
deductive
database
systems
nowadays
an underlying
unification algebra,
r(S1,X,Y),
flight(flight(r2(S1,
S2),
From,Ltd.
To), From,
To) support
:deduktiven
Datenbank-Verwaltungssystem,
Generation
Computing,
Ohmsha,
and don’t
2, 4,r2’:
9, the
11]).
including
unification-joins,
unification-selections
we Via),
have to eliminate
the generated
Informatik-Dissertationen
ETH Zürich,
Band 25,
Springer-Verlag,
1987$not
(5) pp. ($exists
133-154
Z, s(Y,Z)),etc.,
directflight(S1,
From,
The[5]
paper
is
organized
as
follows:
Section
2
motivates,
why
we
select
a
source-to-source
transforVerlag
der
Fachvereine
Zürich,
1991
Ramakrishnan R.: Magic
Templates:
A Spellbindunification-join.
This
can
be done
using
a Y,’Z’).
second magic
transformation within the negation
explain_not_s(S2,
flight(S2,
Via,setTo).
mation
as best
technique.
InPrograms,
section
3Proc.
the that
positive
explanation
transformation
presented
and
inInter[11]
Yalcinalp
L.U.,one-sided
Sterlingis L.:
An Integrated
ing
Approach
to Logic
5th
Int.
__________________
with
an
inverse
SIP.
We
proved,
that’s
the
way
to
solve
unification
joins
to
r3’:3 Conf.
directflight(directflight(base,
munich,
frankfurt),
frankfurt).
pretermunich,
for Explaining
Prolog’s
Successes
and
on
Logic
Programming
(ICLP ’88),
1988,
section
4
we
solve
the
problems
arising,
when
negation
occurs.
Finally
section
5
shows
how
one
That
technique
is
useful
also
in
other
parts
of
a
deductive
database
system.
The
set-difference
is
an
expensive
opera(For
details see
[8]). exists no Y so that
Failures,
of then
Workshop
on Meta-Propp.the
140-159
Withground-joins.
informal
meaning:
If the
there
r(X,Y) Proc.
is valid,
explain_not_r.
If
might be aqueries
good optimization
usingtechnique.
one-eyed Delta-Iteration, looking just at the primary-keys of the relations,
can tion.
askItwhy-not
using this
gramming
in
Logic
Programming
(META
88),
[6]
Ramakrishnan
R.,theUllmann
J.: second
A Survey
of
r(X,Y)
is valid,
but
join
to the
subgoal
is empty, then explain_not_s.
since
all others
can’t influence
the
set-difference.
__________________
1
Research on Deductive Database Systems, Journal
Bristol, June 1988
for an overview see e.g. [6].
of Logic Programming, New York, to appear 1993
2 Wieland [10] developed proof trees on datalog programs, but his approach can not handle terms, negations and
source-to-source optimizations. Shmueli and Tsur [7] connected the Prolog debugger in [4] to LDL.
Download