-2 A: if database for Q1 was given
-1 per missing partition
A: {} -> qr, instead of {} -> pqr.
The rule/goal graph should have the following arcs:
q^bf -> r3.0[X|YZ]
r3.0[X|YZ] -> b^ff
r3.0[X|YZ] -> r3.1[XYZ|]
r3.1[XYZ|] -> p^bb
p^bb -> r1.0[XY|]
r1.0[XY|] -> a^bb
p^bb -> r2.0[XY|Z]
r2.0[XY|Z] -> a^bf
r2.0[XY|Z] -> r2.1[XYZ|]
r2.1[XYZ|] -> q^bb
q^bb -> r3.0[XY|Z]
r3.0[XY|Z] -> b^fb
r3.0[XY|Z] -> r3.1[XYZ|]
r3.1[XYZ|] -> p^bb
p_bf(X,Y) :- a(X,Y)
p_bb(X,Y) :- a(X,Y)
p_bf(X,Y) :- a(X,Z) & q_bf(Z,Y)
p_bb(X,Y) :- a(X,Z) & q_bb(Z,Y)
q_bf(X,Y) :- b(Z,Y) & p_bb(X,Z)
q_bb(X,Y) :- b(Z,Y) & p_bb(X,Z)
q(X,Y) :- p(X,Z) & b(Z,Y)
The rule/goal graph should have nodes for p^bf, a^bf, q^bf, b^bf.
The rule/goal graph should have the following arcs:
q^bf -> r3.0[X|YZ]
r3.0[X|YZ] -> p^bf
r3.0[X|YZ] -> r3.1[XZ|Y|]
r3.1[XYZ|] -> b^bf
ans^bff(X,Y,Z) :- par(X,Z) & par(Z,A) & par(Z,W) & par(W,B)
& par(W,Y) & par(Y,C)
-1 A: no counterexample database, but showed there was no containment mapping.
-2 B: wrong database.
ans^bff(X,Y,Z) :- v2^bf(X,Z) & v1^bf(Z,Y)
E(R):
ans^bff(X,Y,Z) :- par(X,Z) & par(Z,B) & par(Z,C) & par(C,Y)
E(R) is contained in Q. Containment mapping: X->X, Y->Y, Z->Z, W->C.
Q is contained in E(R). Containment mapping: X->X, Y->Y, Z->Z, B->W, C->W.
Thus, E(R) is equivalent to Q.
-1 A: forgetting subl(nil, nil).
m_subl(Ys) :- sup2.1(X,Ys)
m_subl(Ys) :- sup3.1(Y,Ys)
Group II;
sup2.0(X,Ys) :- m_subl(cons(X,Ys))
sup3.0(Y,Ys) :- m_subl(cons(Y,Ys))
Group III;
sup2.1(X,Ys) :- sup2.0(X,Ys) & elt(X)
sup3.1(Y,Ys) :- sup3.0(Y,Ys) & elt(Y)
Group IV;
subl(nil,nil) :-
subl(cons(X,Xs),cons(X,Ys)) :- sup2.1(X,Ys) & subl(Xs,Ys)
subl(Xs,cons(Y,Ys)) :- sup3.1(Y,Ys) & subl(Xs,Ys)
Group V;
m_subl(cons(0,cons(1,nil)))
m_subl(Ys) :- sup2.1(X,Ys)
m_subl(Ys) :- sup3.1(Y,Ys)
sup2.1(X,Ys) :- m_subl(cons(X,Ys)) & elt(X)
sup3.1(Y,Ys) :- m_subl(cons(Y,Ys)) & elt(Y)
subl(nil,nil) :-
subl(cons(X,Xs),cons(X,Ys)) :- sup2.1(X,Ys) & subl(Xs,Ys)
subl(Xs,cons(Y,Ys)) :- sup3.1(Y,Ys) & subl(Xs,Ys)
m_subl(cons(0,cons(1,nil)))
doctor(D) :- Admits(P,I,D) patient(P) :- Admits(P,I,D) illness(I) :- Admits(P,I,D) treats(D,P) :- Admits(P,I,D) has(P,I) :- Admits(P,I,D)
Part (b):
ans(D) :- Admits(P1,I1,D) & Admits(P,I2,D2) & Admits(P3,mumps,D3) & Admits(P,I4,D) & Admits(P,mumps,D5)
Part (c):
ans(D) :- Admits(P,I4,D) & Admits(P,mumps,D5)
Common error: 6A: mapping the first of the subgoals above to the second, and winding up with only one subgoal. You can't do the mapping, because D is a distinguished variable and can't map to D5. You lost 3 points, and if you made a similar error on part (e), you lost another 2 points.
Part (d):
doctor(D) :- Assigned(D,R) patient(P) :- Beds(P,R) illness(I) :- Wards(R,I) treats(D,P) :- Beds(P,R) & Assigned(D,R) has(P,I) :- Beds(P,R) & Wards(R,I)
Part (e):
Ans(D) :- Assigned(D,R1) & Beds(P,R2) & Wards(R3,mumps) & Beds(P,R4) & Assigned(D,R4) & Beds(P,R5) & Wards(R5,mumps)
Part (f):
Ans(D) :- Beds(P,R4) & Assigned(D,R4) & Beds(P,R5) & Wards(R5,mumps)
Notice that neither of the two Beds subgoals maps to the other because either R4 or R5 gets in the way.
Part (b): Patients should have zero or more history subobjects. Those objects will have atomic date subobjects and atomic diagnosis subobjects. They will also have subobjects that are doctor objects. In the diagram on p. 8, the arrow should go to the doctor object, not the name of the doctor.
Common errors included pointing to the name of the doctor rather than the doctor object itself (7B -1), and creating an addition level of object, called ``histories'' or something, of which each individual history was a subobject. I didn't take off for the latter, but it is wasted effort and serves no purpose.
Part (c):
<patient{<name N> <phone P>}> @ medMed :- <doctor{<patient{<name N> <phone P>}>}> @ docSource
A common error was excluding doctor from the path in the doctor source (7C -2). Since there apparently are no patients at the top level at that source, you need to specify doctor in the path.
Part (d): This part was flawed. I thought it was harder than it was, but you can make a simple modification to (c) and avoid using function symbols as OID's.
<patient{<name N> <phone P> <doctor D>}> @ medMed :- <doctor{<name D> <patient{<name N> <phone P>}>}> @ docSource
p(1) :- NOT q(1) p(3) :- NOT q(3) q(1) :- p(2) q(2) :- p(3) q(3) :-
Part (b): No; there is recursive negation involving p and q.
Part (c): Yes, it is locally stratified, as the graph of the six instantiated predicates q(i) and p(i) for i = 1, 2, 3 will show. Stratum 0 consists of {q(3), p(2), q(1)}, and stratum 1 is the other three ground atoms.
Part (d): Only q(3) is inferred.
Part (e): The largest unfounded set is {p(2), p(3), q(1), q(2)}.
Common error (8A -3): Many people failed to discover one or more of these and lost roughly one point per.
Part (f): The table looks like:
p(1) 0 1 1 1 p(2) 0 0 0 0 p(3) 0 1 0 0 q(1) 0 0 0 0 q(2) 0 1 0 0 q(3) 0 1 1 1
Common errors: First, many people thought that q(2) was false at the second round (8B; -2). The mistake was probably failing to complete the inferences at that round. Since p(3) is inferred at that round, we can use the fourth rule to infer q(2).
The second mistake was making q(2) true on the third round (8C; -2). The mistake there was probably assuming that we could use p(3), which was true on round 2, to infer q(2) on round 3. Again --- in this or the GL procedure (which are really the same), you can use negative facts from the previous round, but you must infer positive facts anew on the present round.
par(X,f(X,Y)) :- v1(X,Y) par(f(X,Y),Y) :- v1(X,Y) par(X,g(X,Y)) :- v2(X,Y) par(g(X,Y),h(X,Y)) :- v2(X,Y) par(h(X,Y),Y) :- v2(X,Y)
A common mistake was not using the three different function symbols that you need, and you lost one point for each lapse (9C -1).
Part (b):
par(0,f(0,1)) par(f(0,1),1) par(1,g(1,2)) par(g(1,2),h(1,2)) par(h(1,2),2)
Part (c): There are many possible answers, such as anc(1,h(1,2)), anc(g(1,2),2), and anc(f(0,1),g(1,2)).
Part (d): anc(0,1), anc(1,2), and anc(0,2). You lost one point for each one you missed, usually the third of these.
Part (a): First, you had to realize that every hypergraph with two hyperedges is acyclic. Then, you had to count them right. Many people said there were 2^5-1 = 31 nonempty values of H, and an equal number of values of I. However, multiplying 31 * 31 = 961 is wrong, because it ignores the condition that each node is in at least one edge.
The correct way to count is to let each of the five nodes be assigned to one of three categories: only in H, only in I, or in both. There are thus 3^5 = 243 assignments. That would be the number of hypergraphs that meet the conditions, but at the exam we said that neither hyperedge could be empty. Thus, we must subtract the two assignments in which one is empty, and all five nodes are in the other. The correct answer is 241, but 243 was also accepted.
Part (b): The answer is u AND s AND w. If this condition is satisfied, then it is easy to see that none of the three edges is an ear.
We need to check that if the condition is false, then there is an ear. Once we know there is an ear, then coupled with the fact that any two-edge hypergraph is acyclic, we know that the three-edge hypergraph is also acyclic.
Suppose for example that u is empty. Then hyperedge H consists of regions r, s, and v only. Nodes in r belong only to H, while nodes in the other two regions are shared only with I. Thus, H is an ear.
Part (c): Now to count the number of hypergraphs that satisfy the condition of (b). The easiest way, which I had forgotten, is to use the law of inclusion-exclusion. Start with the total number of hypergraphs, which is 7^5 = 16,807. The justification for this number is that each of the five nodes can go into any of the seven regions. From these, we must subtract the number that do not have a node in u, which is 6^5 = 7776. Likewise, we must subtract the number that do not have a node in s, and those that do not have a node in w --- the same number, 7776, in each case.
However, that calculation double-counts the hypergraphs that are missing nodes in both u and s, or missing nodes in two of the other three regions mentioned in the formula of part (b). Thus, we must add back 3*5^5 = 3*3125 = 9375, the extent of this double counting. However, we are not done, because the hypergraphs that are missing nodes in all three of the part-(b) regions have been subtracted three times and added back three times; they must thus be subtracted again. These are 4^5 = 1024 hypergraphs. The final answer is thus 16807 - 3*7776 + 3*3125 - 1024 = 1830.
If that methodology is unfamiliar, there is a more seat-of-the-pants argument that gets the same answer. There are four ways that the nodes can be distributed:
Note that 960 + 720 + 90 + 60 = 1830.
Common errors: (10A -1): not expanding an expression. (10B -2): Failure to account for duplicate counting in part (c).