{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

cs345-9

# cs345-9 - DatalogPrograms InverseRules DuschkasAlgorithm 1...

This preview shows pages 1–11. Sign up to view the full content.

1 Using Views to Implement  Datalog Programs Inverse Rules Duschka’s Algorithm

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2 Inverting Rules Idea: “invert” the view definitions to give  the global predicates definitions in terms of  views and function symbols. Plug the globals’ definitions into the body  of the query to get a direct expansion of  the query into views. Even works when the query is a program.
3 Inverting Rules --- (2) But the query may have function  symbols in its solution, and these  symbols actually have no meaning. We therefore need to get rid of them. Trick comes from Huyn -> Qian ->  Duschka.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
4 Skolem Functions Logical trick for getting rid of  existentially quantified variables. 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).
5 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 and Y,  that makes the above body true.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
6 HQD Rule Inversion 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.
7 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)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
8 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)
9 Example --- Continued The views: v1(X,Y) :- f(X,Z) & m(Z,Y) v2(X,Y) :- m(X,Y) Inverse rules: r4:  f(X,g(X,Y)) :- v1(X,Y) r5:  m(g(X,Y),Y) :- v1(X,Y) r6:  m(X,Y) :- v2(X,Y)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
10 Evaluating the Rules Treat views as EDB.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}