next up previous

2.5.1 Heuristic Knowledge ñ Rules

One of the primary methods of representing knowledge in CLIPS is a rule. Rules are used to represent heuristics, or ìrules of thumbî, which specify a set of actions to be performed for a given situation. The developer of an expert system defines a set of rules which collectively work together to solve a problem. A rule is composed of an antecedent and a consequent. The antecedent of a rule is also referred to as the if portion or the lefthand side (LHS) of the rule. The consequent of a rule is also referred to as the then portion or the righthand side (RHS) of the rule.

The antecedent of a rule is a set of conditions (or conditional elements) which must be satisfied for the rule to be applicable. In CLIPS, the conditions of a rule are satisfied based on the existence or nonexistence of specified facts in the factlist or specified instances of userdefined classes in the instancelist. One type of condition which can be specified is a pattern. Patterns consist of a set of restrictions which are used to determine which facts or objects satisfy the condition specified by the pattern. The process of matching facts and objects to patterns is called patternmatching. CLIPS provides a mechanism, called the inference engine, which automatically matches patterns against the current state of the factlist and instancelist and determines which rules are applicable.

The consequent of a rule is the set of actions to be executed when the rule is applicable. The actions of applicable rules are executed when the CLIPS inference engine is instructed to begin execution of applicable rules. If more than one rule is applicable, the inference engine uses a conflict resolution strategy to select which rule should have its actions executed. The actions of the selected rule are executed (which may affect the list of applicable rules) and then the inference engine selects another rule and executes its actions. This process continues until no applicable rules remain.

In many ways, rules can be thought of as IFTHEN statements found in procedural programming languages such as C and Ada. However, the conditions of an IFTHEN statement in a procedural language are only evaluated when the program flow of control is directly at the IFTHEN statement. In contrast, rules act like WHENEVERTHEN statements. The inference engine always keeps track of rules which have their conditions satisfied and thus rules can immediately be executed when they are applicable. In this sense, rules are similar to exception handlers found in languages such as Ada.


next up previous