Aspen SCM‎ > ‎Expert System‎ > ‎1. Elements‎ > ‎

1.7 Conclusion of a Rule: Predicates


The conclusion of a rule may contain one or more predicates. Predicates consist of any set of up to 10 tokens separated by blanks. Each token can be an arbitrary character string or a variable but must not be the reserved words AND or OR. Although it is possible to write predicates which begin with a variable, e.g.


this is deprecated. Instead predicates should begin with an initial character string, the predicate verb, followed by zero or more predicate arguments, e.g.


Predicate arguments should be local variables (i.e. beginning with a question mark) but literal character strings are also permitted. The use of literal character strings is deprecated because it can lead to unexpected errors. For example


is interpreted as establishing two predicates:

AND     ?Y IS ?Z

Suppose that you have written a rule to convert a string ?STRING to lower case. Its conclusion might be


You might think that the assertion


would invoke this rule. But if ?STRING happened to be “IS”, it is equally likely that the rule would be invoked whose conclusion is THE SUM OF ?X AND ?Y IS ?Z. This is because one of the predicates which it proves is ?Y IS ?Z and this also matches the assertion.

It is to avoid such unexpected behaviour that you are strongly recommended to begin each predicate with a predicate verb and follow it with 0 – 9 predicate arguments. This also allows Predicate Unification to be turned on, speeding up the execution of rules (see Near-Duplicate Predicates below and section 2.a).

Canonical Form of Predicates and $PRED

Predicates which form the conclusions to rules are converted into canonical form by substituting an asterisk for each argument which is a variable and by replacing each set of consecutive blanks by a single blank. It is in this form that predicates are stored in the internal set $PRED and by which they are matched between assertions and conclusions. Thus the predicate SUM_OF ?X ?Y ?Z has the canonical form SUM_OF * * *.

Predicates can have up to 9 arguments after the predicate verb. The number of arguments must not exceed 9 because the maximum number of tokens in any Aspen SCM Expert System statement is 10. Because it is stored in the Description of $PRED, the length of any predicate in its canonical form must not exceed the length of $PRED’s Description, which is itself limited to 64 characters.

Predicate Verbs with Different Numbers of Arguments

Predicates are regarded as distinct if they have the same predicate verb but different numbers of arguments. Predicate verbs with different numbers of arguments can be very useful for handling text and messages; many Aspen SCM commands appear to have been implemented in this way, e.g. ERRMSG, INFOMSG. Such overloading should, however, only be done where all the rules are performing the same function.

Duplicate Predicates

It is possible to have several rules with the same predicate. For instance, rules with predicates SUM_OF ?X ?Y ?Z and SUM_OF ?RESULT ?FIRST ?SECOND have the same canonical predicate SUM_OF * * *. These are known as duplicate predicates (although there can be more than two such predicates). Clearly this can lead to confusion, especially where (as here) the meanings of the arguments differ between the instances.

Near-Duplicate Predicates

We saw that two apparently different canonical predicates

    LOWER_CASE * *
    * IS *

could match a single assertion


if ?STRING happened to be “IS”. This was an instance of near-duplicate predicates.

Near-duplicate predicates occur more commonly where canonical predicates contain the same number of tokens but different numbers of predicate arguments, e.g.


In this instance a specific rule has been written to schedule the pipe-still at a refinery but otherwise a generic rule is used. In such cases the rules are arranged so that if SCHEDULE PIPESTILL is asserted, the specific rule will be executed first. If predicate unification is switched on, there is no guarantee that the specific rule will be executed first.

Predicate unification speeds up execution and should be used. It is compatible with duplicate predicates but not near-duplicate predicates. You can use it safely provided all predicates take the form of a predicate verb followed by 0 – 9 predicate arguments.

Back                                Next