





























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






























Inverse Rules
Duschka’s Algorithm
docsity.com
Idea: “invert” the view definitions to give the global predicates definitions in termsof views and function symbols.
Plug the globals’ definitions into the body of the query to get a direct expansion ofthe query into views.
Even works when the query is a program.
docsity.com
Logical trick for getting rid of existentially quantified variables.
In terms of safe Datalog rules:
For each local (nondistinguished) variableX, pick a new function symbol
f
(the
Skolem constant
).
Replace
X
by
f (head variables).
docsity.com
v(X,Y)
p(X,Z)
p(Z,Y)
Replace Z
by f(X,Y) to get:
v(X,Y)
p(X,f(X,Y))
p(f(X,Y),Y)
Intuition: for v(X,Y) to be true, there must be some value, depending on X andY, that makes the above body true.
docsity.com
v(X,Y)
p(X,f(X,Y))
p(f(X,Y),Y)
becomes:
p(X,f(X,Y))
v(X,Y)
p(f(X,Y),Y)
v(X,Y)
docsity.com
Global predicates:
m(X,Y) = “
Y
is the mother of
X.”
f(X,Y) = “
Y
is the father of
X.”
manc rules:
r1:
manc(X,Y)
m(X,Y)
r2:
manc(X,Y)
f(X,Z)
manc(Z,Y)
r3:
manc(X,Y)
m(X,Z)
manc(Z,Y)
docsity.com
Treat views as EDB.
Apply seminaïve evaluation to query (Datalog program).
In general, function symbols -> no convergence.
docsity.com
But here, all function symbols are in the heads of global predicates.
These are like EDB as far as the query is concerned, so no nested functionsymbols occur.
One level of function symbols assures convergence.
docsity.com
r1:
manc(X,Y)
m(X,Y)
r2:
manc(X,Y)
f(X,Z)
manc(Z,Y)
r3:
manc(X,Y)
m(X,Z)
manc(Z,Y)
r4:
f(a,g(a,b))
v1(a,b)
r5:
m(g(a,b),b)
v1(a,b)
r6:
m(X,Y)
v2(X,Y)
Assume v1(a,b).
docsity.com
r1:
manc(g(a,b),b)
m(g(a,b),b)
r2:
manc(X,Y)
f(X,Z)
manc(Z,Y)
r3:
manc(X,Y)
m(X,Z)
manc(Z,Y)
r4:
f(a,g(a,b))
v1(a,b)
r5:
m(g(X,Y),Y)
v1(X,Y)
r6:
m(X,Y)
v2(X,Y)
Assume v1(a,b).
docsity.com
Notice that given v1(a,b), we were able to infer manc(a,b), even though wenever found out what the value ofg(a,b) [the father of
docsity.com
Duschka’s approach moves the function symbols out of the seminaïve evaluationand into a rule-rewriting step.
In effect, the function symbols combine with the predicates.
Possible only because there are never anynested function symbols.
docsity.com
The unification of p(f(X,Y), Z) and p(A,g(B,C)) is p(f(X,Y),g(B,C)).
Uses A -> f(X,Y); Z -> g(B,C); identity mapping on other variables.
p(X,X) and p(Y,f(Y)) have no unification.
Neither do p(X) and q(X).
docsity.com
Repeat:
Take any rule with function symbol(s) inthe head.
Unify that head with any subgoals, of anyrule, with which it unifies.
But first make head variables be new,uniquesymbols.
Finally, replace IDB predicates +function-symbol patterns by newpredicates.
docsity.com