University of Washington, Bothell
CSS 482: Expert Systems
Fall 2010
Homework 2
Assigned: Monday, October 4, 2010
Due: Wednesday, October 13, 2010

In this homework, you will work through a series of successively more general representations for genealogical facts. Coupled with that, you will write simple rules to infer additional facts.

1 Ordered Facts

Ordered facts are merely sequences or lists or symbols that you can assert. They are called “ordered” because the meaning of each item in the fact depends only on its location in the list — there is no other information present that can signal meaning. To start things off, create the following types of ordered facts, filling in details from your own family (or some fictional family, if you prefer):

(assert (male Bob))  
(assert (male Joe))  
(assert (female Mary))  
(assert (Bob is-father-of Joe))  
(assert (Mary is-mother-of Joe))  
(assert (Bob is-husband-of Mary))  
(assert (Mary is-wife-of Bob))

You will want to create a large enough number of facts that you can write rules to infer a wide range of relationships. Think about how you would define fact representations and write rules to infer:

What is wrong with this fact representation that makes it difficult to write rules? How can you make a simple change to the ordered facts that will make it possible to write single rules that work with multiple “is-father-of”, etc., ordered facts? Modify your facts and write the rules to complete the task above.

2 Unordered Facts

Facts are called “unordered” when their structure is defined with a deftemplate. In these facts, values have meaning because they are tagged with slot names that indicate so. Using the same family information as above, create your set of facts (in a deffacts construct) using the following deftemplates:

(deftemplate father-of (slot father) (slot child))  
(deftemplate mother-of (slot mother) (slot child))  
(deftemplate male (slot person))  
(deftemplate female (slot person))  
(deftemplate wife-of (slot wife) (slot husband))  
(deftemplate husband-of (slot husband) (slot wife))

Now, write rules to infer the following relations, defining additional deftemplates as needed:

  1. parent
  2. uncle, aunt
  3. cousin
  4. sister, brother
  5. grandfather, grandmother
  6. grandparent
  7. ancestor

Make sure that your family information includes enough people to allow you to exercise all of your rules.

3 More General Facts

One of the things you may have noticed in your work is that you ended up with multiple rules that looked very similar, but had to be distinct rules because the facts they depended on, though they had the same structure, had different names. We can sometimes make our rules simpler (or, at least, reduce the number of very similar rules) by incorporating more information into the slot values of our facts, rather than the fact or slot names. Consider, instead of the above deftemplates, the following ones:

(deftemplate individual (slot name)  
                        (slot sex)  
                        (slot family-as-spouse)  
                        (slot family-as-child))  
(deftemplate family (slot name))

Using these definitions, we can infer all of the relationships that we could before, but with fewer rules. One major reason for this is that we moved an individual’s sex from two possible separate facts to a slot value in the individual fact. Another is that we have established families as defined entities, with individuals linked via their participation in families. So, for example, we can infer that individual X is a parent of individual Y if X is in family F as a spouse and Y is in family F as a child. We can produce sex-specific relationships (mother, father, etc.) simply by testing a sex slot, rather than by having two separate rules. Rewrite your example from above using these new fact representations, inferring both sex-neutral and sex-specific relationships.

Deliverables

Please submit your three programs with comments sufficient for someone else (i.e., me) to understand how your program works (remember to also include all documentation strings) to the class drop box. Make sure it is clear which program is which (of the three that you will be writing). Please also submit example runs showing correct operation for all three programs.

Coding Standards

Your code should be easy to read and understand. Use consistent indentation. Each file should start with a comment that includes the file name, your name, the date and a summary of the file purpose/contents. Each deftemplate, defrule, etc. should have a useful comment string and comments indicating what each slot means.

Grading Scheme

There are a total of 100 points available in this assignment. The first program is worth 30 points; the second and third 35 points. In each program, 10 points will awarded for understandable comments and the remaining points will be allocated based on correct operation.