Assignment 2: Inference With Knowledge Using Partial-Order Properties
CSE 415: Introduction to Artificial Intelligence
The University of Washington, Seattle, Autumn 2012
The reading for this assignment is Knowledge Representation in The Elements of Artificial Intelligence with Python.
Due Friday, October 12 through Catalyst CollectIt at 2:00 PM.
 
Part I. Written Answers (20 points).
  1. Exercise 3 on page 154.
  2. Exercise 4 on page 155.

Part II. ISA Hierarchy Manipulation (80 points plus up to 15 points of extra credit). The Python code for a program called Linneus that manages a small knowledge base is available here. Add the following features to the Linneus program:
  1. cycle detection (20 points). Have Linneus detect possible cycles in the database, so it can have the following type of dialog.
    > A being is a creature.
    I understand.
    > A creature is an animal.
    I understand.
    > An animal is a being.
    Yes, but a being is an animal, because a being is a creature and a creature is an animal.
    I'm not going to remember that an animal is a being unless you insist.
    > OK
    I don't understand.
    
  2. cycle processing (40 points). Have Linneus handle cycles by making one element of a cycle the representative in the ISA hierarchy and making others into synonyms without separate nodes. It should be able to carry on the following continuation of the above dialog.
    > I insist that an animal is a being.
    Then I am inferring that an animal, a being, and a creature
    are all names for the same thing.
    I will use the name animal for this class, and I will
    consider the others to be aliases for it.
    > What is a creature?
    Creature is another name for animal.
    > A creature is an organism.
    I'll remember that an animal is an organism.
    > What is an animal?
    An animal is an organism.
    > An organism is a living-thing.
    I understand.
    > A living-thing is an organism.
    Yes, but an organism is a living-thing, because you told me that.
    I'm not going to remember that a living-thing is an organism unless you insist.
    > I insist that a living-thing is an organism.
    Then I am inferring that a living-thing, and an organism
    are both names for the same thing.
    I will use the name living-thing for this class, and I will
    consider the other to be an alias for it.
    > Is a being an organism?
    Yes, an animal is a living-thing.
    
  3. Why, with antisymmetry. (20 points) Extend your Linneus program's functionality to be able to handle the following kind of continuation of the previous conversation.
    > Why is a being an organism?
    Because being is another name for animal, an animal is a living-thing, and 
    organism is another name for living-thing.
    
  4. Optional, for extra credit. Persistence. (10 points). Have Linneus read in a file of facts, isa-data.txt, at the beginning of its session and write out the (updated) file at the end. Ideally, it will also automatically make a backup copy of isa-data.txt with the name isa-data.txt.bak or similar name involving a version number, before it writes out the new version.
Updates and Corrections The link to the Linneus3.py file was corrected on Oct. 8 at 10:52 AM. Two additional corrections were made on October 10: (a) all occurrences of "living thing" in the dialog should have been "living-thing", and this was fixed; (b) the dialog part
> A living-thing is an organism.
Yes, but a living thing is an organism, because....
was corrected to:
> A living-thing is an organism.
Yes, but an organism is a living-thing, because....
Thanks go to Kathryn Nichols for pointing out the error.

Update (October 10): Here is what to turn in: a file PartI.txt and a file PartII.py. Your PartI.txt file should contain your name and the answers to the questions in Part I. Your PartII.py file should begin with a multiline string that gives, on the first line, your name, and on the next four lines, the status of your solutions to each of the four exercises in Part II. For example, you might have something like this:

'''John Doe
1. (cycle detection) implemented and working.
2. (cycle processing) implemented and working.
3. (Why, with antisymmetry) implemented but only partially working -- seems to only handle
a situation involving one use of synonyms.
4. (persistence) implemented and works but does not make a backup file when updating.
'''
The rest of your file PartII.py should contain a version of the Linneus3 program that provides the implementation of the features according to your status comments.

If necessary, additional updates and corrections will be posted here and mentioned in class or on GoPost.