Simple Example


Let's now look at a simple example that includes a number of rules and a variety of facts in a working memory. We'll use a subset of the ZOOKEEPER rules first proposed by Patrick Henry Winston, the Ford Professor of the Artificial Intelligence and Computer Science Department at the Massachusetts Institute of Technology [Winston 1993].

Consider the following rules shown in Listing 8.1.

Listing 8.1: Sample Problem Adapted from Winston's ZOOKEEPER Example.
start example
 (defrule bird-test       (has-feathers ?) =>       (bird ?) ) (defrule mammal-test       (gives-milk ?) =>       (mammal ?) ) (defrule ungulate-test1       (mammal ?)       (chews-cud ?) =>       (is-ungulate ?) ) (defrule ungulate-test2       (mammal ?)       (has-hoofs ?) =>       (is-ungulate ?) ) 
end example
 

Now consider that our working memory contains the following facts:

 (gives-milk animal) (has-hoofs animal) 

We begin with the match phase where we try to match the facts in our working memory with the antecedents in our rule set. Neither fact matches the antecedents of the first rule ( bird-test ), but an antecedent is matched in the second test ( mammal-test ). We save this rule off into our conflict set and continue our search through the remaining rules. No other rules match given the current working memory, so in this case we have the simple case of a conflict set containing one rule. Since there is no conflict, the mammal-test rule is permitted to fire (the action phase), resulting in the working memory as shown below:

 (gives-milk animal) (has-hoofs animal) (mammal animal) 

We begin again at the match phase and walk through the rules looking for matching antecedents. In this case, our conflict set contains two rules, mammal-test and ungulate-test2 . Conflict resolution is also simple given this case, because only one rule here has any affect on the working memory ( ungulate-test2 ). The first rule has previously fired ; therefore, nothing new can be added to our working memory and the rule can be omitted from the conflict set. Moving on to the action phase and firing the ungulate-test2 rule results in the following working memory:

 (gives-milk animal) (has-hoofs animal) (mammal animal) (ungulate animal) 

From this very simple example, our rules system has deduced that the animal in question is an ungulate (a hoofed animal). It reasoned this after first determining that the animal was a mammal (knowing that it gave milk) and then using this information, along with the hoof information, determined that the animal was an ungulate.

Conflict resolution in the example shown included two of the most basic mechanisms for determining which rule to fire. Other mechanisms could be provided for scenarios that are more complicated. For example, the conflict resolver could pick the rule to fire from the conflict set that had the largest number of antecedents. This provides for the most complicated case and could help the system reason to the most relevant goal state and ignore the simpler cases, which might lead the system down unnecessary paths.




Visual Basic Developer
Visual Basic Developers Guide to ASP and IIS: Build Powerful Server-Side Web Applications with Visual Basic. (Visual Basic Developers Guides)
ISBN: 0782125573
EAN: 2147483647
Year: 1999
Pages: 175

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net