Announcements

Administration

Syllabus

Assignments

Resources

CS B552 Knowledge-Based Computation

Homework 1:  Knowledge for Rule-Based Systems

Due Date: Wed, January 25, 11:59pm

Assignment Goals

Goals of this and the following assignment are to understand rule-based systems, their implementation, and basic knowledge representation for rule-based systems.

Assignment groups

The assignment may be done individually or in groups of 2 students. If you will be working in a group, send Eriya the names of the group members by 5pm Fri Jan 20.  He will configure canvas for the groups.

Assignment tasks

In this assignment you will gain experience in writing rules for a rule-based system and will code the rules for use in a system you will implement in the next assignment. 

1.    Select a task domain for which you think a rule-based expert system could be useful, other than the medical diagnosis task below and any expert system tasks mentioned in class.  Justify why you think this would be a good domain in which to apply an expert system, in a few sentences.  Justifications should include both (1) why you believe the task is feasible for an expert system, and (2) why you believe it would be a commercially viable application.

2.    Write simple English versions of at least 10 rules for this domain, at a level of detail you consider appropriate (example below).  Number each rule. Note that:

a.     The rules should be fairly simple, so each rule captures a small and distinct piece of knowledge, relying on at most a few antecedents (you should include some examples with multiple antecedents), and

b.    The rule set should include rules relating to one another, so that chaining together multiple rules will enable drawing conclusions it would not be possible to draw from single rules. 

Both of these are important principles in designing expert system rules.

3.    Write representations of the following rules in the format described in the following section.  As in all knowledge representations, it may be necessary to “rephrase” the English versions to make your representation.  The goal is to develop a rule set that results in the same conclusions you would generate based on your English versions, rather than necessarily an exact pairing between sentences and rules.

1)    If a patient has a very high fever, the patient has a high fever.

2)    If a patient has whooping cough, the patient has a cough.

3)    If a patient has poison ivy, the patient has a rash.

4)    If a patient has a high fever and congestion, the patient has the flu.

5)    If a patient has a rash and no high fever, the patient has poison ivy.

6)    If a patient has a cough and a very high fever, the patient has whooping cough.

7)    If a patient has no fever, no cough, and no rash, the patient is healthy.

8)    If one patient has a particular disease which is contagious and that patient contacts another patient, then the other patient has the disease.

9)    If a doctor says that a patient has a particular disease or is healthy, then what the doctor says is true.

 Rule representation

Rules will be written in a form for use in a Python program. When coding your rules, you can indicate variables by preceding the variable name with a question mark, as in ?var-name. Each rule consists of a name or number identifying the rule, a left-hand side, and a right-hand side. The left-hand and right-hand sides should each be a list of expressions. Each expression in that list is itself a list. Thus the form of rules is

('rule_name', ['lhs-exp1', 'lhs-exp2',... 'lhs-expn'], ['rhs-exp1', 'rhs-exp2', ... 'rhs-expn'])

The left-hand-side gives a conjunction of conditions that must be true in order for the rule to fire (AND).   If it fires, instantiated versions of the assertions on the right-hand side are added to memory.

A concrete example is:

rules = [('v-high-fever-implies-high-fever',

                ['has-symptom fever ?patient very-high'],

                ['has-symptom fever ?patient high']),

             ('whooping-cough-causes-cough',

                ['has-disease ?patient whooping-cough'],

                ['has-symptom cough ?patient positive’])]

 

The rules will be matched against a set of facts in working memory (wm), which will be represented in a compatible form.

4.    Consistent with the representations that you chose in the previous part, write a list of expressions corresponding to the following assertions:

o    Ed has a very high fever.

o    Ed has a cough.

o    Alice doesn't have poison ivy.

o    Max says Alice has poison ivy.

o    Grace says Don is healthy.

o    Grace is a doctor.

o    Whooping cough is contagious.

o    Ed contacts Alice.


Example of Fact Representation


wm = ['has-symptom fever Ed very-high', 'has-symptom cough Ed positive']
 

Submission

The assignment will be submitted electronically, on Canvas.   Each group will make one submission. You should submit a PDF file with an answer to each part, 1 through 4. 

You may submit as many versions as you wish (only the last submission before the deadline will be graded). We recommend submitting a first version before the last minute, to make sure it's in the system. Also, please keep backup copies of all your files until you have verified that your grade for the assignment is properly recorded.