Suppose the following five views are provided:
- published(P,B,A,Y) :- publisher(P,B) & author(A,B) & copyright(B,Y)
- bookInfo(B,A,Y,C) :- author(A,B) & copyright(B,Y) & cost(B,C)
- storeInfo(S,L,T) :- bookstore(S,L) & phone(L,T)
- stocks(S,B,C) :- sells(S,B) & cost(B,C)
- BordersInfo(L,T,B) :- bookstore("Borders",L) & phone(L,T) & sells("Borders",B)
- published(P,B,A,Y) - fbff
- bookInfo(B,A,Y,C) - bfff or fbff
- storeInfo(S,L,T) - fff
- stocks(S,B,C) - bff
- BordersInfo(L,T,B) - bff or ffb
Find all minimal solutions (in terms of the adorned views) to each of the following queries:
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)
but with the following altered views:
v1(X,Y) :- f(X,Z) & m(Z,Y)
v2(X,Y) :- f(X,Y)
Use the Duschka/Genesereth method to find all possible answers to the query obtainable from the given views.
red(X,Y) and green(X,Y) are global predicates. They represent colored arcs, and for both, X is the starting node and Y is the ending node.
There are the following two source views:
v1^ff(X,Y) :- red(X,Y)
v2^fb(X,Y) :- green(X,Z) red(Z,Y)
"v1^ff" means that the v1 is the view, with bindings f and f, and similarly for v2^fb.
Write a Datalog program that uses the views as EDB predicates, in such a way that the views can be queried with their proper binding patterns. Your program must find as many nodes as it can, from which a green arc can eventually be reached (there exists some path starting at that node which contains a green arc). For example, if we have green(1,2), red(2,3), red(3,4), green(4,5), and green(5,6) then the answer should contain nodes 1, 2, 3, and 4. Note that even though there is a green arc (5,6) reachable from node 5, there is no way to determine that fact from the views, so 5 will not be in the result of your program.