Q260 - Computation in the Cognitive and Information Sciences
Homework Assignment 9
Due: Tuesday, Nov 25. Accepted late without penalty up to
class on Dec 2.
The Big Picture
Production systems are important both as a technology and as a
model of cognitive processing. This assignment will introduce you
to production systems through Jess, the Java Expert System Shell.
You will first write a simple system for advising students on
class choices to gain familiarity with the approach, and then
write a bigger system dealing with a topic of your choice. As
you do this, you should think about the
the design principles for
production systems and their strengths and weaknesses. You may
wish to consider going deeper into
production systems for the class project.
To start Jess, type
To exit Jess, type
Basic Jess commands
In order to complete the homework, you will need to use the
following basic Jess commands discussed in class. Each one is
followed by examples of its use:
- (assert (cost car-5 high))
- (assert (mortal socrates))
- Retract: Retracts the fact with the given number.
- (retract 1)
- See the example below for how to retract a fact in a rule.
- Every person is mortal
(assert (mortal ?x)))
- Animals that perform exertion are healthy. (Note that this
uses multiple patterns in the antecedent. You may also include
multiple actions in the consequent.)
(participant ?x ?y)
(assert (healthy ?x)))
- To have a rule retract a fact, you need to set a veriable that
points to the fact, and then do a retract on the variable (because
you don't know the fact number).
You do this with an operator "<-".
For example, to delete all records of parking tickets
?t <- (parking-ticket ?x)
- Not: Negation, used in patterns to make sure a fact isn't in
working memory. Warning: It appears that Jess doesn't allow
"not" in the first pattern of a rule.
- If you aren't short, you're tall:
(not (short ?x))
(assert (tall ?x)))
- Or: Makes a disjunction of facts instead of a conjunction
- Facts: show the facts in memory
- Run: run the inference engine until no more rules fire.
Always (reset) before running..
- Reset: clear working memory but keep the current program.
- Clear: clear working memory and get rid of the current
program (used before loading a new program or new version of an
- Batch: Runs Jess code as a "batch job" from a file.
To run the cryptarithmetic example (assuming you did "cd
- (batch "examples/wordgame.clp")
- Load-facts: Loads facts from a file
- (load-facts "~myname/file")
- Watch all: Print each rule firing.
- (watch all)
- Unwatch all: Turn off the tracing
- (unwatch all)
You will write a mini-expert system for deciding which classes a
student should take next, based on the information on core
courses in the major area requirements of the CS BA
You need to decide how to represent information about the courses
that are available, the courses the
student has taken, and the prerequisites for each course. You also need to
define rules for determining if prerequisites
have been satisfied, and for proposing the next course the student
You system will be run by asserting facts about the
courses the student has taken. It will finish by asserting a
fact with a course that needs to be taken next. If you then enter
an assertion that the student has taken that course and run it
again, the system should update its facts and correctly assert the next
course to be taken.
- Do one of the following:
Pick an everyday task and write a mini- expert system to
solve it. Your solution should involve at least 10 rules that
can be "chained together" in chains at least 3 steps long, and
should be able to reach at least three major conclusions.
Implement the following rules and test them by running them on
the given facts. (This fact and rule set comes from an
assignment developed by Mike Gasser.)
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
5 If a patient has a rash and no high fever, the patient has poison
6 If a patient has a cough and a very high fever, the patient has
7 If a patient has no fever, no cough, and no rash, the patient is
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.
10 If a person says that a patient has a particular disease or is
healthy and that is not true of the patient, then that
person is not a doctor.
Ed has a very high fever.
Ed has a cough.
Alice doesn't have poison ivy.
Max says Alice has poison ivy.
Grace says Don is healthy.
Grace is a doctor.
Whooping cough is contagious.
Ed contacts Alice.
Following good design principles makes a significant difference in the
extensibility and maintainability of production systems. To
illustrate these points, we will warn you about some possible pitfalls
Submitting the assignment
E-mail your code to Doug at
firstname.lastname@example.org. Also e-mail him:
Last modified: Mon Nov 10 17:14:05 EST 1997
- A short description of how each program
is used and a paragraph describing strengths and weaknesses in its
design for the task, as well as how it could be improved.
- A paragraph of commentary on how your program models (or
doesn't model) the way a person performs the task, and why.
Comments: email@example.com or