|
Forward Chainer
|
|
In this problem set, we will be using a very simple Scheme program that interprets rule
systems analogous to those in the textbook via forward-chaining.
The rule-utils.scm defines the basic data structures and operations used in the
forward and backward chainers; see the description. Please
read about the format of rules (aka "knowledge") files. Note, in particular, that
variables in the rules can be written as ?x or (? x) as you prefer.
The match.scm file defines the function match and auxiliaries,
essentially identical to that in PS 1 (without segment variables). The function
match takes two lists, a The forward.scm file defines the rule interpreter. Basically, the system keeps a global list of rules and a global list of assertions. The function call (chain) activates the interpreter with the current rules and assertions. Note that it uses try-first-rule and choose-first-instance to, respectively, compute the candidate triggered rule-instances and to choose one to fire. Other conflict-resolution strategies can be implemented by calling chain-internal with a different pair of functions, to generate rule instances and choose one. Look at zoo.k to see how these are used to implement the Zookeeper system in the text. You can run the Zookeeper rules on Athena by (read-k-file "/mit/6.034/www/psets/ps3/zoo.k"), evaluate one of the assertion functions such as (make-swifty) and then (chain) followed by (display-assertions). The Zookeeper rules are all IF-THEN (deduction) rules. Our Scheme program also supports production rules as illustrated in the Bagger system, e.g., the ability to delete as well as add assertions. It also supports a mechanism for calling arbitrary Scheme programs to perform arbitrary actions or perform tests, such as those checking the number of assertions that match a pattern, that go beyond the presence or absence of individual assertions. You can run the Bagger rules on Athena by (read-k-file "/mit/6.034/www/psets/ps3/bagger.k") and then (chain) followed by (display-assertions). In summary, rules are of the form:
(rule-name
IF antecedents
[AND-IF tests]
[THEN thens]
[ADD thens]
[DELETE deletes]
[SAYING sayings]
[EVALUATING evals])
|
|
Copyright
© 2002 by Massachusetts Institute of Technology. All rights
reserved.
MIT Send comments or questions to 6.034 On Line |