KnowledgeWorks and Prolog User Guide > 6 Advanced Topics > 6.2 Optimization > 6.2.3 Backward Chaining

NextPrevUpTopContentsIndex

6.2.3.1 Pattern Matching

The KnowledgeWorks Backward Chainer indexes clauses for a backward rule based on the first argument. If the first arguments to backward rule clauses are distinct non-variables, the backward chainer can pre-select possible matching clauses for a call.

For example, in the following rule:

(defrule age-of :backward
                ((age-of charlie 30) <--)
                ((age-of william 25) <--)
                ((age-of james 28) <--))

The call: (age-of james ?x) would jump directly to the third clause and bind ?x to 28 without trying the other two.

The call: (age-of tom ?x) would fail immediately without doing any pattern matching.

Clauses are distinguished first by the types and then the values of their first arguments.


KnowledgeWorks and Prolog User Guide (Macintosh version) - 22 Dec 2009

NextPrevUpTopContentsIndex