The rule editor is used to enter, view, update and delete sentence rules in the form of rule-trees. The rule editor consists of two windows: a rule-tree window containing the rule and a rule-tree palette window from which rule components and commands can be selected. This page describes the structure and elements of rule-tree windows, and how the rule tree is created (drawn) by using the rule-tree palette window. Mastering the rule-tree editor is essential for building knowledge bases with Pro/3!

The rule editor is entered from the New Sentence Rule-window (when creating a new rule), from the Sentence Rule-window (when viewing or changing an existing rule),  or by a clicking a sentence rule rectangle in a knowledge dependency tree (or from the Record-window).

Entering a new rule

After returning from the New Sentence Rule-window, the rule tree will include the rule type (the rule tree's root node), two branches from the root i.e. an upper branch with a so far empty condition and a lower branch with the skeleton of the rule's conclusion:
Note the following:
  • The [world region[2]]-rectangle is shown in "reverse video". This indicates the current node in the tree. The current node is the location (target) for the next insert, delete or other operations. You move the current node simply by clicking on another node.
  • The rectangles containing a single underscore are empty nodes. These nodes need to be replaced by a non-empty node, (or be deleted). The empty nodes in the rule tree above can not be deleted since the rule must have a condition and values must be assigned to each and all data element types in the conclusion.
  • The rule's conclusion sentence type cannot be changed, neither can the rule type shown by the root node be changed. The rule must be scrapped if these aspects of the rule no longer are desired.
ROOT NODE SYMBOL RULE TYPE

=>

simple implication rule
GEN=> generalization rule
CR=> rule with inexact rule call
STAT=> statistical rule
MIN=> minimum value selection
MAX=> maximum value selection
UN=> unique value selection
ACC=> accumulation rule
IP=> interpolation rule
CORR=> correlation rule
The rule editor palette is used to insert new rule tree elements or delete existing ones (there is no change-function - rule tree elements are deleted or inserted).
The skeleton for the new rule is generated via the New Sentence Rule-window:  
The first part of the condition is the manufacturer is located in country sentences (referred to as a sentence condition in the rule editor). The Sentence condition radio button is selected and the sentence type is selected from the list. The Insert-button is finally used to insert the new node in the rule tree:

Argument numbering

The same entity type can occur several times in the rule (e.g. manufacturer in the example), and the different entity type arguments can have one or more data element types in common. It is thus necessary to qualify data element references. This is done by numbering the arguments (entity types and predicate types) in each sentence condition and in the conclusion. The sentence conditions are numbered sequentially from top to bottom starting with 10, then 20, 30 etc. The conclusion has number 0. The first entity argument in a sentence condition has sub-number 1 and the optional second has sub-number 2. Data elements of parameterized predicate types also need qualifications. These are per convention considered to belong to argument 0. The first entity argument in the third sentence condition thus gets argument number 31. The argument numbers are shown in brackets [ ].

The condition has second part joined with logical AND - the country is part of world region sentence condition. There is no empty node where this condition can be inserted, and the trick is to insert an AND-operator as a root node for the existing condition. Make this node current and press the &-button: 

The second sentence condition can now be inserted in the same was as the first:
Note that the data element types in the conclusion are assigned to empty elements. These empty elements need to be replaced by non-empty elements - literal values or rather data element types from the condition. Clearly, the name data element in the conclusion is to be assigned the value of name data element in manufacturer entity type (argument) in condition (i.e. argument no. 11). The DE radio button is selected in the palette and name[11] data element is selected from the list:

The region name data element in the conclusion is similarly assigned the value of region name[22]  i.e. from the world region entity type in the condition. The conclusion is then complete.

The condition is still missing something. There is no association between the country where a manufacturer is located (the first sentence condition), and the country which is a part of a world region (the second sentence condition). This is accomplished by assigned the name[12] data element (the name in argument 12) to the name[21] data element (the name in argument 21).

Set name in argument 21 as current:
Press the = button (since an equality type condition is need between name[21] and name [12]:

An empty element is automatically inserted to the right of the = (since clearly an element needs to be placed there for the = to make sense). That element is name[12], which is selected in the same way as the data element types inserted in the conclusion.

A complete simple implication rule has been entered. The rule is inserted in the KB by pressing the Store-button.

  The Rule Editor Palette

DYNAMIC ELEMENTS

The radio buttons correspond the different types of dynamic rule tree elements (dynamic because the sets of these elements either are found in the knowledge base, such as data element types (DE), or entered on the fly such as simple variables used locally in the rule (Variable). The list-edit control contains all elements of the selected type.

Note that the Inexact rule radio button only is visible in relevant rule types. The place is either blank (e.g. for simple implication rules) or there is instead a Procedure radio button (set rules).

An element is inserted in the rule tree by first selecting it (or entering it) in the list-edit, and then by pressing the Insert-button.
ELEMENT

POPULATION

Sentence condition All sentence types concluded by existing rules. Entered sentence types as well as external sentence types, must be typed into the control.
Function All KE-defined functions.
Pro/3 function All standard and built-in functions.
Variable condition All simple variables in the rule - new variables can be typed into the control. Note that a new variable will be of the domain given by the current value of the domain listbox.

Variable All simple variables in the rule.
DE All data element types in the rule which can be used in expressions, as parameters etc.
Literal All literals enter so far - new literals can be typed into the list edit control (under the radio buttons). See inserting literals under.
Identifier All KE-defined identifiers.
Pro/3 identifier All standard identifiers.
Inexact rule All inexact rules.
Procedure All procedures (relevant for the current rule type)

The Delete-button is used to delete the current rule tree node.

The Auto Assign-button is used to automatically assign data elements (references to data elements in the rule) to the current node which either must be an argument in a sentence condition (or conclusion) or an argument's root node. The editor assigns a data element type with the same name from a sentence condition sub-tree above the current node in the tree. The assignments can of course be changed later as desired.

The ST population-button displays the sentence counts for the current sentence type on the format:

Ni / Nd ( Nr )

where Ni=no of input sentences, Nd=no of derived sentences while Nr is the no. of sentence rules which conclude the sentence type.

EQUALITY/ASSIGNMENT CONDITIONS

The = button is used to insert an equality/assignment operator on the right side of the current node (which must be a terminal node - either a data element or a simple variable).

The =* button is similarly used to assign a non-deterministic function call to the current node (which must be a simple variable).

Insertion of an equality/assignment operator always inserts an empty element on the right side of the operator.

The = operator is an equality comparison operator when its parent node is a data element in the condition, or a simple variable which is already assigned a value higher up in the rule tree. The operator is an assignment operator when its parent node is a data element in the conclusion, or the first occurrence of a simple variable in the tree.

See also values, expressions and assignments.

 

The #-button inserts a sentence count node with an empty element on its right side (this must eventually be replaced by a sentence condition element). The current node must be an = node (on the right side of a simple variable node).

The NOT-button inserts a not-node at the current node's position and makes the current node its sub-tree. The current node must be a sentence condition or a variable condition (i.e. a condition which can be evaluated as either being true or false, an assignment type of rule element will for example not make sense). Nothing can be concluded if the sub-tree of the not-node is true. The TRUE-button is used in the same way. Nothing can be concluded if the sub-sub-tree of the true-node is false. [This is of course the normal operations of the rule for any sentence and variable condition. The true-node is thus logically redundant].

Inserts a comparison operator (and an empty element on its right side) to the right of the current node (which must be a simple variable or data element).
= deterministic assignment or equality
=* non-deterministic assignment
< less than
<= les than or equal
> greater than
>= greater than or equal
<> not equal
like like-operator for strings
unlike unlike-operator for strings

Replaces the current empty node with an arithmetical operator and two empty nodes to the right of the operator. These empty nodes must eventually be replaced by actual operands (e.g. literals, simple variables, data elements or another arithmetical operator in case of nested expressions).
+ addition; concatenation
- subtraction
* multiplication
/ division
/i integer division
MOD modulo
^ exponentiation

LOGICAL OPERATORS

The & and V replace the current node (if empty) with a logical AND and OR node with two empty sub-nodes.

If the current node is a sentence condition, a variable condition or an assignment/comparison operator, then a logical AND or OR node is inserted in the current node's place, with the current node as a sub-node and a new empty node under it.

The vv and ^^ buttons are used to add an additional AND or OR branch over (^^) or under (vv) the current node (which must be sub-node under a & or V node).

 

 

 

Opens the rule editor Help-window (this topic) in the browser.

INSERTING LITERALS

Press the Literal-radio button described over and enter the literal in the list edit control under the radio buttons. Entered literals are remembered and if used more than once, simply select the literal from the list edit control rather than entering it again.

Domain List Edit Control

The literal's domain is determined by the domain list edit control under the Auto assign-button, i.e. when entering a literal you must ascertain that the domain list edit is displaying the appropriate domain.

You can select the appropriate domain in the list edit directly, or you can change it indirectly by making a data element, variable or parameter (procedure-, function-, inexact rule parameter) current node. (This will set this data element, variable or parameter's domain as the current domain).

The Long-button is used when the width of the list edit control is insufficient for the value to be entered. A pop-up dialog with a long edit field will be displayed when the button is pressed. 
List literals are shown with a [] header node as shown in the example to to the right:

See also notes on the use and limitations of list domains.

 

The XML-button displays the rule (possibly incomplete with empty elements) in an editor window in XML PR format (the text is also saved to a text file). The PR-button displays the rule in an editor window in PR-format (the text is also saved to a text file). The Print-button prints the rule tree. The Store-button stores (or restores) the rule in the KB.

 

SENTENCE CONDITIONS

Sentence condition elements (in a rule's condition) optionally have conditions specified for one or more of its data element types:

The conditions are specified by using one of the comparison operators and value (literal, data element, simple variable or expression) on this operator's right side. Two or more conditions can be used with logical AND or OR:

Note the automatically assigned argument numbers used to qualify multiple occurrences of the same data element type.

Sentence conditions can also correspond to a sentence group. The first entity type argument to the is located in predicate is simply specified as an entity type argument variable X, which can represent any entity type in this sentence group (likewise the entity argument to is conditionally projected in the conclusion).

Inexact rule calls

Inexact rule calls are treated in exactly the same way as function calls, however, they can only be used as assignments to a data element type in the rule's conclusion. Inexact rule names have [C] concatenated. Rule calls can not form a part of an expression, and can not be used as actual parameters to a function, inexact rule or procedure.

Procedure calls

Procedures can only be assigned to data elements in the conclusion of statistical rules. Procedure calls can not form a part of an expression, and can not be used as an actual parameter to a function, certainty rule or other procedure.

Procedure calls are only permitted in the conclusion. Most, but not all, procedures have parameters. These appears in the same way as function call parameters. Note that two or more different procedures can be used in the conclusion of the rule.

 

VARIABLE CONDITIONS

Variable condition sub-trees consists of a simple variable (local to the rule tree), with either a value assigned to the variable or a condition imposed on it. The structure of the assignment or condition is the same as that for data element types in sentence conditions.

Note that a variable can occur in more than condition, however the first (highest up in the rule tree), must be an assignment-type condition. The domain of the variable is indicated in the first occurrence by /SD (where SD is the short domain name). The variable's domain is determined by the selected domain in the domain list edit control when the variable is introduced. See also values, expressions and assignments.

Variables can be used in expressions further down in the rule tree (including obviously in the rule's conclusion).

Function calls

Function calls (as in the example above) are included in the rule-tree as a sub-tree where the root-node is the function name (with [F] concatenated for clarify). The branches of this sub-tree are the formal parameters of the function with the actual parameters assigned through the equality/assignment operator.

Note that the =* operator must be used when calling the non-deterministic function integer series (otherwise the function will return only the first value).

Function calls can not form a part of an expression, and can not be used as an actual parameter to a function, certainty rule or procedure.

Sentence-count conditions

Sentence-count conditions assign an integer representing the number of sentences which satisfy a given sentence condition. The integer is assigned to a variable in a variable condition-component of the rule. Use the #-button and then insert the sentence condition to the right side of the #-node.

 

AND/OR BRANCHES

The &-button inserts logical AND over the current node:

The v-button works in the same way for logical OR. The vv- and ^^-buttos are used to insert more empty branches under an AND or OR node. The new branches are inserted under (vv) or over (^^) the current node:

The vv and ^^ buttons can also be used to insert elements in list literals.

Mouse Gestures

MOUSE GESTURE

EFFECT

left button single click Highlights the clicked node.
left button double click Toggle for opening/closing the clicked node's sub-tree.
right button double click Opens sentence model window if current node is a sentence model object. Lists sentences if a sentence type object.