RiskWare On-line Reference Manual
Rules and RTrules
Rules are the main driving construct in both the backward and forward chaining expert system; while they share many basic syntactic features, and have a very similar format, please note that the underlying logic of the backward chaining and forward chaining rules are quite different, even though the two systems can be intricately (and fully transparently) integrated.
Rules files or sets of files are declared in the KBconfig file as RULE-FILES and RTRULE-FILES, respectively:
RULE-FILES Rules.backward END-RULE-FILES RTRULE-FILES Rules.forward END-RTRULE-FILES
Rules: backwards chaining
A detailed description of the syntax of Rules, Tables, and the associated descriptors is given in Embedded Expert System Syntax.
Please note that Rules in the backwards chaining system are driven (triggered) by the Descriptor Rule References (by Rule Number) in the Descriptor's R field.
WARNING: a backward chaining Rule does NOT automatically become effective by adding it to a Rule file; it must be referenced by a Descriptor, and will be processed only if and when this Descriptor in turn is addressed (as an editor target or within another Rule) to determine its value.
Rules in the forward chaining system are screened (for example, Rules that can trigger an ACTION that is already set to done will be ignored), and are then ALL evaluated in sequence until the first Rule meeting all conditions can be fired.
RTrules: forward chaining
Forward chaining rules (RTRULES) are similar to the backwards chaining rules; the main functional difference is that their THEN part can either:
Common SyntaxThe common Rule syntax and structure consists of:
RULE ID IF TOKEN COMPARISON_OPERATOR VALUE AND TOKEN COMPARISON_OPERATOR VALUE OR TOKEN COMPARISON_OPERATOR VALUE THEN TOKEN ASSIGNEMENT_OPERATOR VALUE ENDRULE
TOKEN can be
VALUE can be any legal value (string, numerical value, or arithmetic expression) defined in the V field(s) of the respective TOKEN;
OPERATOR can either be used for comparison (condition parts) or assignement (consequence part) of a Rule.
The condition parts of a Rule can contain AND and OR (inclusive OR) in arbitrary nesting, using [ ] to make the nesting explicit.
Where "[" (square brackets) are used for nested AND and OR contructs, please make sure to keep a blank between strings and the brackets:
RULE 01004 IF DESCRIPTOR(source_type) == road_accident AND [ ACTION(call_road_police) == done OR ACTION(call_road_police) == pending ] THEN ACTION(pick_substance) => ready ENDRULE
© Copyright 1995-2018 by: ESS Environmental Software and Services GmbH AUSTRIA | print page