This preview shows page 1. Sign up to view the full content.
Unformatted text preview: Using Views to Implement Datalog Programs
Inverse Rules
Duschka’s Algorithm 1 Inverting Rules
x Idea: “invert” the view definitions to give the global predicates definitions in terms of views and function symbols.
x Plug the globals’ definitions into the body of the query to get a direct expansion of the query into views.
x Even works when the query is a program.
2 Inverting Rules (2)
x But the query may have function symbols in its solution, and these symbols actually have no meaning.
x We therefore need to get rid of them.
x Trick comes from Huyn > Qian > Duschka. 3 Skolem Functions
x Logical trick for getting rid of existentially quantified variables.
x In terms of safe Datalog rules: For each local (nondistinguished) variable X, pick a new function symbol f (the Skolem constant).
Replace X by f (head variables).
4 Example
v(X,Y) : p(X,Z) & p(Z,Y)
x Replace Z by f(X,Y) to get:
v(X,Y) : p(X,f(X,Y)) &
p(f(X,Y),Y)
x Intuition: for v(X,Y) to be true, there must be some value, depending on X and Y, that makes the above body true.
5 HQD Rule Inversion
x Replace a Skolemized view definition by rules with: 1. A subgoal as the head, and
2. The view itself as the only subgoal of the body. 6 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) 7 Running Example: Maternal Ancestors
x Global predicates: m(X,Y) = “Y is the mother of X.”
f(X,Y) = “Y is the father of X.” 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)
8 Example Continued
x The views:
v1(X,Y) : f(X,Z) & m(Z,Y)
v2(X,Y) : m(X,Y)
x Inverse rules:
r4: f(X,g(X,Y)) : v1(X,Y)
r5: m(g(X,Y),Y) : v1(X,Y)
r6:...
View Full
Document
 Spring '09

Click to edit the document details