Consider the query:rd(co(H,co(H,T)),T). rd(co(A,T),co(A,R)) <- rd(T,R).
ask rd(co(a,co(co(a,X),co(B,co(c,co(d,em))))),W).
Answer: There are two answers. One with B=co(a, X) and W=co(a,co(c,co(d,em))), and one with B=c and W=co(a, co(co(a, A), co(d, em))).
Answer: The answer clause corresponding to the query is
yes(X,B,W) <-rd(co(a,co(co(a,X),co(B,co(c,co(d,em))))),W)this can be resolved with a copy of the second clause:
rd(co(A1,T1),co(A1,R1)) <-rd(T1,R1).using the substitution
{A1/a, T1/co(co(a,X),co(B,co(c,co(d,em)))),W/co(a,R1)}The resulting answer clause is
yes(X,B,co(a,R1)) <-rd(co(co(a,X),co(B,co(c,co(d,em)))),R1)we can use a copy of the first clause
rd(co(H2,co(H2,T2)),T2).with substitution
H2/co(a,X),B/co(a,X),T2/co(c,co(d,em)),R1/co(c,co(d,em))this results in answer clause
yes(X,co(a,X),co(a,co(c,co(d,em)))) <-.which corresponds to the first answer above.
Answer Selecting the second clause instead of the first clause in the aove derivation, gives the answer clause clause
yes(X,B,co(a,co(co(a,X),R3))) <-rd(co(B,co(c,co(d,em))),R3)selecting a copy of the second clause again results in the answer clause
yes(X,B,co(a,co(co(a,X),co(B,R4)))) <-rd(co(c,co(d,em)),R4)selecting a copy of the second clause again results in the answer clause
yes(X,B,co(a,co(co(a,X),co(B,co(c,R5))))) <-rd(co(d,em),R5)selecting a copy of the second clause again results in the answer clause
yes(X,B,co(a,co(co(a,X),co(B,co(c,co(d,R6)))))) <-rd(em,R6)which fails because there are no applicable rules.
Possible Alternative Answer: (although not as good as the first) Selecting the first rule on the initial query does not lead to a successful derivation as we can't unify rd(co(H1,co(H1,T1)),T1) with rd(co(a,co(co(a,X),co(B,co(c,co(d,em))))),W) as then H1 would need to be replaced by both a and co(a,X) and these cannot be made the same.
You should assume that the video is annotated using the relation
where SegId is an identifier for the segment. (In a real application this will be enough information to extract the segment from the video disk). Duration is the time of the segment (in seconds). Covers is a list of topics that is covered by the video segment.segment(SegId, Duration, Covers)
That is true if Segments is a presentation whose total running time is less than or equal to Maxtime seconds, such that all of the topics in the list MustCover are covered by a segment in the presentation. The aim of this predicate is to design presentations that cover a certain number of topics within a time limit.presentation(MustCover, Maxtime, Segments).
Answer: I have three different solutions.
For the first solution, a segment is chosen that covers the first topic, and all of the topics that this segment also covers are removed from the list of topics left to cover.
The second solution is a directly recursive definition with no predicates defined other than in the question.
The third solution uses an iterative method, where we define another predicate add_to_presentation that adds to existing an presentation to also include more topics. Presentation then asks to add the topics it must cover to an empty presentation.
The fourth solution generates presentations that satisfy the length criterion, and then tests them to see if they cover all of the topics. This is the only one that defines more than one extra predicate.
Assuming you have a good user interface and a way to actually view the presentations, list three things that the above program doesn't do that you may want in such a presentation system.
[There is no right answer for this part, you need to be creative to get full marks]. Here are some ideas: