Doc Rules
Back to current version Restore this version

Improve this page... more examples, more complete (eval(...) an such)
Tim Baier-Loewenstein

Rules#

At this page, one can find the documentation concerning rules.

Definition #

Rules can be defined as one means for creating derivation knowledge. Thereby, a basic syntax exists that can be slightly varied to create different types of rules. Those types substantially vary in their distinct rule actions and they are explained in more detail after the presentation of the basic syntax.

Syntax - Basics #

Rules are defined by the Rule tag in KnowWE. The basic syntax is as follows (rc = rule condition):
%%Rule
IF (rc) 
THEN (rule action) 
%

Since the Leeloo release it is possible to define more than one action to be executed for a rule. Different rule actions are separated by a semicolon in the THEN clause.

%%Rule
IF (rc) 
THEN (action1; action2; action3) 
%

Furthermore it is possible to add an exception condition to the rule, like in the following example:

IF (rc) 
THEN (rule action) 
EXCEPT (rc2) 

It is also possible to define the EXCEPT(...) statement as AND NOT wihtin the IF clause. The advantage of EXCEPT(...) is that this part is not necessarily evaluted, i.e. the rule will also fire even if the except clause is not fulfilled.

The following operators can be used to build more complex expressions from simple rule conditions:


Using eval()#

eval(...) expressions can also be used as rule condition if more than one question or complex formulas shall be used:
IF eval(questionA = questionB)
THEN (rule action)

IF eval(questionA = 2*x+b)
THEN (rule action)

or if a complex action shall be conducted

IF questionA < 2
THEN eval(questionB = max(questionC, questionD))

eval(...) must not be used in combination with KNOWN/UNKOWN

 
IF questionA = UNKNOWN
THEN questionB = 2

Different rule types #

As previously mentioned, the different rule types vary in their rule actions, that is, the part of the rule following the THEN keyword. In the following the rule types available in KnowWE are listed and shortly explained. For a more detailed explanation and syntax examples please refer to the separate pages for each rule type.

Scoring Rules #

Scoring rules (diagnosis rules) are used to assign specific score points to a solution. See the page about scoring rules. for the syntax and an overview of the possible score points.

Abstraction Rules #

It is possible to assign values to a question via abstraction rules. That way, the program sets certain answer values depending on those answer values provided by the user for previous questions. See the page about abstraction rules for the syntax and further detail.

Indication Rules #

Indication rules basically initiate the presentation of certain, subsequent questions or questionnaires to the user depending on previously provided answers. For syntax and further detail see the page about indication rules.