COMP9414/9814 Artificial Intelligence

Review Questions on Prolog Programming, Rules, Semantic Nets, Frames - Solutions

It is best not read the answers until you've tried to answer the questions yourself.

  1. What is the difference between [[1] | [2, 3]] and [1 | [2, 3]] ?

    Answer: In the first case, the first element of the list is [1], the list containing just the number 1. In the second case, the first element is 1. If you don't get it, try the queries:

    ?- X = [[1] | [2, 3]].
    ?- Y = [1 | [2, 3]].
    

  2. What would be the output from the query
    ?- likes(jane, Y) = likes(X, pizza).
    

    Answer:

       Y = pizza,
       X = jane.
       
    Remember that = is a matching operator.

  3. Write and test a Prolog procedure to compute the sum of whole numbers from 1 to N.

    Answer:

    % sum1toN(N, Sum) binds Sum to the sum of the numbers 1 to N
    
    sum1toN(1, 1).
    sum1toN(N, Sum) :-
    	N > 1,
    	Nminus1 is N - 1,
    	sum1toN(Nminus1, Sum1toNminus1),
    	Sum is N + Sum1toNminus1.
    

  4. What is the difference between the Specificity Ordering and Rule Ordering conflict resolution strategies?

    Answer: With specificity ordering, the clauses in the condition part of the eligible rules are known to be subsets or supersets of each other - in this case, the most specific eligible rule is chosen to fire - i.e. the one with the most clauses in the condition.
    With rule ordering, the rules are numbered, and the eligible rule with the lowest number is chosen to fire.
    In the BAGGER example, the rules are ordered in such away that specificity ordering coincides with rule ordering, but this need not be the case in general.

  5. Explain what is meant by the term partitioned production system.

    Answer: In a partitioned production systems, the rules are partitioned into subsets. At any given time, only one subset is "active". In each subset, there will be at least one rule that transfers control to some other subset, or at least one rule that stops the system.

  6. In a semantic net, explain the difference between an isa link and an ako link. What does ako stand for?

    Answer: An "isa" like connects an instance - a particular object - to its type - so it might connect a particular penguin named Percy to the "generic penguin". An "ako" link connects two types in a subset relation, so it might connect the penguin type to the bird type.

  7. Below are some Prolog facts. Draw them as a semantic network. How do you think semantic nets might be implemented in Prolog (don't cheat and look at the sample code linked to the lecture notes!) OK ... you can look at the sample code after you've written down an answer. :-)
    can_fly(bird, yes).
    ako(bird, vertebrate).
    have_feathers(bird, yes).
    ako(emu, bird).
    can_fly(emu, no).
    isa(ernie, emu).
    steals_potato_crisps(ernie, yes).
    

    Answer: picture of semantic net

  8. What do frames have that semantic nets don't have?

    Answer: Procedural attachment - i.e. demons.

  9. List all seven types of demon in the frame system described in lectures. When are their associated bits of code executed?

    Answer: if_new, if_needed, if_added, if_removed, if_replaced, range, help.
    Check lecture notes for when they are executed ("triggered").


Bill Wilson's contact info

UNSW's CRICOS Provider No. is 00098G