Due in class, Wednesday, November 6, 1996.
4 Questions, 100 pts.

Problem 1 (20 pts.)

Consider the conjunctive queries with negation P and Q.
p(X) :- q(X,Y) & q(Y,X) & r(Y,Y) & NOT q(X,X) & NOT r(Y,X).
p(B) :- q(A,B) & r(A,A) & NOT r(A,B).
Use the Levy-Sagiv test to show that P is contained in Q and Q is not contained in P.

Problem 2 (25 pts.)

Consider the conjunctive queries (with arithmetic subgoals) P and Q.
p(X) :- q(X,Y,Z) & q(X,Z,Y) & q(Y,Z,X).
p(X) :- q(X,Y,Z) & X<=Z & Y<=Z.
Use the Klug-Levy-Sagiv test to show that P is contained in Q.

Problem 3 (30 pts.)

This problem involves a "mystery" predicate m. There are two things known about m. ("panic" is a generic 0-ary predicate or, equivalently, a propositional variable, that we may use as the head of a CQ that represents a constraint.) Prove that the conjunctive query

panic :- q(X,Y,Z) & m(Y,X) & m(Y,Z)

contains the conjunctive query

panic :- q(X,Y,X) & q(Y,Z,Y) & q(X,Z,X).

Problem 4 (25 pts.)

Determine whether each of the conjunctive queries
p(X,Y) :- arc(X,A) & arc(A,Y) & arc(X,B) & arc(B,Y) & X<A & B<Y.
p(X,Y) :- arc(X,Z) & arc(Z,Y) & X<Z & Z<Y.
is contained in the other. If not, give a counterexample database.

Hint: The Gupta test is messy here, since there are a lot of containment mappings after we replace duplicate occurrences of variables. However, in general, and here in particular, when there is implication of the OR over all containment mappings, we can usually identify one or a few of the containment mappings that are really involved in the implication. Try first to understand what the CQ's are saying, and the focus on the containment mappings you really need.