



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Prof. Eklavya Nikunj delivered this lecture at Allahabad University for Information Integration course. It includes: Parent, EDB, Relation, Skolem, Functions, Invert, Skolemization, Variables, Complex
Typology: Slides
1 / 5
This page cannot be seen from the preview
Don't miss anything!




Getting All You Can Out of Views
The situation is that we are given a collection of views and a query (p ossibly recursive). F We want to nd all the answers to the query that we can using the views.
This technology, due to Oliver Duschka, comes from \Infomaster," a pro ject of Prof. Mike Genesereth.
Example
We have a parent EDB relation, with ancestors de ned in the usual way:
anc(X,Y) :- par(X,Y) anc(X,Y) :- par(X,Z) & anc(Z,Y)
but the only view we have tells ab out grandparents:
v1(X,Y) :- par(X,Z) & par(Z,Y)
If we want the most ancestor facts that we can obtain from the view v 1 (not using the EDB, which is only abstract in applications like IM), then we should use the program:
anc(X,Y) :- v1(X,Y) anc(X,Y) :- v1(X,Z) & anc(Z,Y)
which gives us the even-distance ancestors that can b e comp osed of facts in v 1 , and nothing else.
Key Idea: Skolemization
F The function symb ols so used are called Skolem functions; it is a standard trick of logic to get rid of existential variables.
F Rememb er that the \EDB" predicates are really global, abstract concepts as in IM, not stored relations.
Example
To invert the view
v1(X,Y) :- par(X,Z) & par(Z,Y)
we get:
par(X,f(X,Y)) :- v1(X,Y) par(f(X,Y),Y) :- v1(X,Y)
Notice that :- is a misnomer as far as the view de nition is concerned, but in the inverse rules it is simply an assertion that there are no b ogus facts in the view.
A More Complex Example
Supp ose we have EDB predicates (global concepts) f (X ; Y ) and m(X ; Y ), meaning that Y is the father or mother, resp ectively, of X.
Our query is to nd all \maternal ancestors" of an individual X , i.e., all females who are ancestors: r 1 : manc(X,Y) :- m(X,Y) r 2 : manc(X,Y) :- f(X,Z) & manc(Z,Y) r 3 : manc(X,Y) :- m(X,Z) & manc(Z,Y)
The available views are:
v 1 (X,Y) :- f(X,Z) & m(Z,Y) v 2 (X,Y) :- m(X,Y)
Invert the Views
r 4 : f(X,g(X,Y)) :- v 1 (X,Y) r 5 : m(g(X,Y),Y) :- v 1 (X,Y) r 6 : m(X,Y) :- v 2 (X,Y)
Evaluating the Rules
In a sense, that's all there is to it. Treat all predicates except the views as IDB, and evaluate.
Seminaive evaluation can pro duce tuples with function symb ols, but these cannot b e real answers to the query.
Because all function symb ols are in the heads of rules for \EDB" (global, conceptual) predicates, which have no other rules, we never intro duce a function symb ol within a function symb ol, leading to a nite pro cess.
Thus, seminaive evaluation converges, and the set of manc facts without function symb ols is the closest we can get to the true answer by using only the views.
Thus we must use manc(g (:; :); :) in r 2 , r 3 , r 7 , and r 9. F Rules r 2 and r 7 yield nothing new.
F r 3 and r 9 yield, resp ectively: r 10 : manc(X,Y) :- m(X,g(E,F)) & manc(g(E,F),Y) r 11 : manc(g(C,D),Y) :- m(g(C,D),g(E,F)) & manc(g(E,F),Y)
Cleaning Up the Rules To get a program that computes the maximum answer from the views, we can:
Example (Continued)
Use manc1(X ; Y ; Z ) for manc(g (X ; Y ); Z ). F No other variants of manc are needed in this simple example. r 1 : Only r 6 can b e used for the m subgoal of r 1 (r 5 would intro duce function symb ols in the head, and we already generated r 8 , an appropriate variant of r 1 where the m subgoal has b een uni ed with the pattern of the head of r 5 ). r 1 : manc(X,Y) :- v 2 (X,Y) r 2 : No suitable replacement for the f subgoal exists. r 3 : As for r 1 , it is necessary only to use r 6 , yielding: r 3 : manc(X,Y) :- v 2 (X,Z) & manc(Z,Y)
r 4 {r 6 : These inversion rules will b e eliminated.
r 7 : We must:
a) Use r 4 for the f subgoal, which requires that A and X b e uni ed b ecause of the form of the head of r 4. b) Use manc 1 in place of manc in the second subgoal. r 7 : manc(X,Y) :- v 1 (X,B) & manc1(X,B,Y)
r 8 : Use r 5 for the m subgoal; uni cation of D and Y is necessary. r 8 : manc1(C,Y,Y) :- v 1 (C,Y)
r 9 : Similar to r 8 , but D uni ed with Z.
r 9 : manc1(C,Z,Y) :- v 1 (C,Z) & manc(Z,Y)
r 10 : Neither r 5 nor r 6 allows uni cation with the m subgoal of r 11 without intro ducing function symb ols, so this rule cannot b e used.
r 11 : Same problem as r 10.
Summary of Rules
r 1 : manc(X,Y) :- v 2 (X,Y) r 3 : manc(X,Y) :- v 2 (X,Z) & manc(Z,Y) r 7 : manc(X,Y) :- v 1 (X,B) & manc1(X,B,Y) r 8 : manc1(C,Y,Y) :- v 1 (C,Y) r 9 : manc1(C,Z,Y) :- v 1 (C,Z) & manc(Z,Y)
If we get rid of manc 1 by expanding its subgoal in r 7 in b oth p ossible ways, we get: manc(X,Y) :- v 2 (X,Y) manc(X,Y) :- v 2 (X,Z) & manc(Z,Y) manc(X,Y) :- v 1 (X,B) & manc(B,Y) manc(X,Y) :- v 1 (X,Y)
That's b eginning to make sense; it says that we can concatenate either of the views in any p ossible way, since each represents a chain ending in a female.
But note that it do esn't get all maternal ancestors, e.g., my Father's Father's Mother.