CS322 Fall 1997
Assignment 3

Due: 1:30pm, Friday 26 September 1997.

Question 1

[10 marks] Given the clauses:
rd(co(H,co(H,T)),T).
rd(co(A,T),co(A,R)) <-
   rd(T,R).
Consider the query:
ask rd(co(a,co(co(a,X),co(B,co(c,co(d,em))))),W).
  1. [2 marks] How many answers are there to this query? What are they (give just the values for the variables B and W in the answer)?

    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))).

  2. [5 marks] Give an SLD derivation showing all substitutions for one of the answers in the above query.

    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.
  3. [3 marks] Give a failing derivation for this query.

    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.

Question 2

In this question you are to write a CILog knowledge base for the design of custom video presentations.

You should assume that the video is annotated using the relation

segment(SegId, Duration, Covers)
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.
  1. [7 marks] Axiomatize a predicate
    presentation(MustCover, Maxtime, Segments).
    
    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.

    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.

  2. [3 marks] Note that what is required for part 1 is reasonably straightforward. However, this example domain will be used for future assignments, so it is worthwhile thinking about what you may want in such a presentation design program.

    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: