Partition | Canonical DB | |
---|---|---|
1 | {X},{Y},{Z} | {q(0,1), q(0,2), r(1,2)} |
2 | {X,Y},{Z} | {q(0,0), q(0,1), r(10,1)} |
3 | {X},{Y,Z} | {q(0,1), r(1,1)} |
4 | {X,Z},{Y} | {q(0,1), q(0,0), r(1,0)} |
5 | {X,Y,Z} | {q(0,0), r(0,0)} |
For 3, 4, and 5, Q1(D) does not contain the frozen head.
For 1: Q1(D) contains its own frozen head, p(0). Q2(D) contains the frozen head of Q1: B->0, A->2, C->1, D->2. For the extended database D', adding tuples consisting of 0's, 1's, and 2's cannot change things as long as we don't add q(2,0), which is a frozen negative subgoal of Q1. Q2(D') contains Q1's frozen head.
For 2: Q1(D) contains its own frozen head, p(0). Q2(D) contains the frozen head of Q1: B->0, A->1, C->0, D->1. For the extended database D', adding tuples consisting of 0's and 1's cannot change things as long as we don't add q(1,0), which is a frozen negative subgoal of Q1. Q2(D') contains Q1's frozen head.
Q1 doesn't contain Q2:
As a counterexample, take the partion: {A},{B},{C},{D}. The canonical DB is {q(1,0), q(1,2), r(3,4)}. The frozen head of Q1 is p(1). Q2(D) = {}, so Q2(D) does not contain the frozen head of Q1. (The heads force X to map to 1; Y can map to 0 or 2, but there is no r(0,?) or r(2,?).)
Partition | Canonical DB | Q2(D) contains the head of Q1? | Mapping |
---|---|---|---|
{X},{Y},{Z} | D1 = {q(0,1), q(1,2), q(2,0)} | Yes | A->0, B->1, C->2 |
{X},{Z},{Y} | D2 = {q(0,2), q(2,1), q(1,0)} | Yes | A->0, B->2, C->1 |
{Y},{X},{Z} | D2 = {q(0,2), q(2,1), q(1,0)} | Yes | A->0, B->2, C->1 |
{Y},{Z},{X} | D1 = {q(0,1), q(1,2), q(2,0)} | Yes | A->0, B->1, C->2 |
{Z},{X},{Y} | D1 = {q(0,1), q(1,2), q(2,0)} | Yes | A->0, B->1, C->2 |
{Z},{Y},{X} | D2 = {q(0,2), q(2,1), q(1,0)} | Yes | A->0, B->2, C->1 |
{X},{Y,Z} | D3 = {q(0,1), q(1,1), q(1,0)} | Yes | A->0, B->1, C->1 |
{X,Y},{Z} | D4 = {q(0,0), q(0,1), q(1,0)} | Yes | A->0, B->0, C->1 |
{X,Z},{Y} | D4 = {q(0,0), q(0,1), q(1,0)} | Yes | A->0, B->0, C->1 |
{Y},{X,Z} | D3 = {q(0,1), q(1,1), q(1,0)} | Yes | A->0, B->1, C->1 |
{Y,Z},{X} | D4 = {q(0,0), q(0,1), q(1,0)} | Yes | A->0, B->0, C->1 |
{Z},{X,Y} | D3 = {q(0,1), q(1,1), q(1,0)} | Yes | A->0, B->1, C->1 |
{X,Y,Z} | D5 = {q(0,0)} | Yes | A->0, B->0, C->0 |
Q1 contains it's own head for all the canonical databases above; there are no negated subgoals or arithmetic subgoals. Since there are no negated subgoals in Q2, when we check to see if Q2(D) contains the frozen head of Q1, we don't need to extend the database. Since for all canonical databases, Q2(D) contains the frozen head of Q1 (p), Q2 contains Q1.
Q1 does not contain Q1:
As a counterexample, take the partition: {A},{B},{C}. D = {q(0,1), q(1,2)}. Q1 contains its own frozen head, p. However, Q2(D) = {}, so Q2(D) doesn't contain the frozen head of Q1.
Q1: p(X,Y) :- q(X1,Y1) & q(Y2,X2) & X>=0 & Y>=0 & X1=X &Y1=Y & X2=X
& Y2=Y
Q2: p(A,B) :- q(A1,B1) & q(B2,C) & A+B>=C & A1=A & B1=B & B2=B
Four containment mappings:
For Q2 to contain Q1, the following implication must hold:
(X>=0 & Y>=0 & X1=X &Y1=Y & X2=X & Y2=Y)
=> m1(A+B>=C & A1=A & B1=B & B2=B) |
=> (X+Y>=Y1 & X1=X & Y1=Y & X1=Y) |
We know that Y=Y is alway true.
(X>=0) => X+Y>=Y
(X>0 & Y1= Y) = Y => X+Y>Y1
Thus, (X>=0 & Y>=0 & X1=X &Y1=Y & X2=X & Y2=Y) => (X+Y>=Y1 & X1=X & Y1=Y & X1=Y).
Therefore, the implication holds. Q1 is contained in Q2.
Q: p(X) :- e(X) & m(X,X,X)
R1: p(X) :- e(X) & m(X,X,1)
R2: p(X) :- e(X) & m(X,X,0)
Q contains p(0) and p(1). R1 contains p(1). R2 contains p(0).
Q1 is contained by the union of R1 and R2. However, Q is not contained by R1, and is not contained by R2.
Q1: panic :- e(X) & m(X,X,X)
Q2: panic :- e(X) & e(Y) & m(X,Y,Y)
Q1 contained in Q2:
Check:
By the rules of arithmetic, m(X,Y,Y) => X=1 | Y=0. And, X=1 | Y=0 => m(X,X,X) | m(Y,Y,Y).
Thus, the implication holds. Therefore, Q2 is contained in Q1.