Docsity

Inverting Rules and Implementing Datalog Programs with Views and Skolem Functions, Slides of Information Integration

Partial preview of the text

Download Inverting Rules and Implementing Datalog Programs with Views and Skolem Functions and more Slides Information Integration in PDF only on Docsity!

Using Views to Implement

Datalog Programs

Inverse Rules

Duschka’s Algorithm

docsity.com

Inverting Rules

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

Skolem Functions

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

Example

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

Example

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

Running Example: Maternal

Ancestors

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

Evaluating the Rules

Treat views as EDB.

Apply seminaïve evaluation to query (Datalog program).

In general, function symbols -> no convergence.

docsity.com

Evaluating the Rules

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

Example --- (2)

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

Example --- (3)

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

Example --- Concluded

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

a ] is.

docsity.com

Rule-Rewriting

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

Example

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

Elimination of Function Symbols

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