{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

ullman-LS - CS345 Notes for Lecture Proof L/S Algorithm...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS345 Notes for Lecture 10/21/96 Proof L/S Algorithm Works: Only-If Suppose Q1 Q2. Let D be any of the canonical DB's. If Q1(D) contains the frozen head of Q1, then since Q1 Q2, so does Q2(D). Therefore, the L/S test will be positive for all canonical DB's. Proof of L/S: If Assume that for every canonical DB, the L/S test is positive. Let D be some DB, and suppose Q1(D) contains tuple t. We must show Q2(D) contains t. Let be the substitution for the variables of Q1 that yields t. I.e., for every positive subgoal G of Q1, (G) is in D, and for no negative subgoal F of Q1 is (F ) in D. Also, (H1) = t (Hi is the head of Qi). Partition the variables of Q1 according to the value assigns them. This partition yields a basic canonical DB, C . Let be the 1-1 correspondence from the symbols of C to the symbols of D such that if maps variable X to constant a of D, and canonical DB C uses constant b for the block of the partition that contains X , then (b) = a. It must be that Q1(C ) contains the frozen H1. For each positive subgoal of Q1 is mapped by to a member of D, and ?1 maps that tuple to a member of C (the one formed from that positive subgoal). And each negative subgoal of Q1 is mapped by to something not in D, and therefore, ?1 cannot map this negative subgoal to a member of C (because 1 (C ) is a subset of D). Now consider C 0, the extended canonical DB that is formed from C by taking all tuples of D formed from the symbols that are in the range of and applying ?1 to them. Thus, C 0 \looks like" that part of D consisting of symbols that were involved in the demonstration that t is in Q1(D). Since Q1(C ) contains its own frozen head, we had to conduct the more extensive test where we looked at the supersets of C . Evidently, these were all positive. Since C 0 was constructed from D, it must be that Q1(C 0) also contains Q1's frozen head. Thus, Q2(C 0) also contains the frozen head of Q1 . If we apply to the constants involved in the demonstration that Q2(C 0) contains the frozen head of Q1, we have a demonstration that Q2(D) contains t. Remember that D is identical to (C 0) on the symbols that are in the range of . Thus, t is in Q2(D), completing the proof. CQ's With Arithmetic Suppose we allow subgoals with <, 6=, and other comparison operators. Negated subgoals also permitted. We must assume database constants can be compared. Technique is a generalization of the L/S algorithm, but it is due to Tony Klug (an interesting story). We shall work the case where < is a total order; other assumptions lead to other algorithms, and we shall later give an all-purpose technique using a di erent approach. 2 Example: Consider the rules: C1: C2: p(X,Z) :- a(X,Y) & a(Y,Z) & X<Y p(A,C) :- a(A,B) & a(B,C) & A<C Both ask for paths of length 2. But Q1 requires that the rst node be numerically less than the second, while Q2 requires that the rst node be numerically less than the third. Klug/Levy/Sagiv Test As before, construct a family of canonical databases by considering all partitions of the variables of Q1 (assuming we are testing Q1 Q2). However, now we need to consider also the order of the values we assign to each partition. And if there is negation, we also need to consider extended canonical DB's; without negation, the basic canonical DB's are su cient. Example: To test C1 C2 (the two CQ's of the previous example) we again need to consider the partitions of fX; Y; Z g. But now, order of the values counts too. The number of di erent basic canonical databases is 13. For partition fX gfY gfZ g we have 3! = 6 possible orders of the blocks. For the three partitions that group two variables and leave the other separate we have 2 di erent orders. For the partition that groups all three, there is one order. In this example, the containment test fails. We have only to nd one of the 13 cases to show failure. For instance, consider X = Z = 0 and Y = 1. The canonical database D for this case is fa(0; 1); a(1; 0)g, and since X < Y , the body of C1 is true. 3 Thus, C1(D) includes p(0; 0), the frozen head of C1. However, no assignment of values to A, B, and C makes all three subgoals of C2 true, when D is the database. Thus, p(0; 0) is not in C2(D), and D is a counterexample to C1 C2. 4 ...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online