The Rete Algorithm was invented by Dr. Charles L. Forgy of Carnegie Mellon University in 1979 and is widely regarded as the breakthrough that made rule-based inference efficient enough to be practical. It is an efficient pattern matching algorithm for implementing rule-based (“expert”) systems. Rete has become the basis for many popular expert systems, including JRules, OPS5, CLIPS, JESS, Drools, Soar and LISA.
A naive implementation of an expert system might check each rule against the known facts in the Knowledge base, firing that rule if necessary, then moving on to the next rule (and looping back to the first rule when finished). For even moderate sized rules and facts knowledge-bases, this naive approach performs far too slowly.
The Rete algorithm (usually pronounced either ‘REET’ or ‘REE-tee’, from the Latin ‘rete’ for net, or network) provides the basis for a more efficient implementation of an expert system. A Rete-based expert system builds a network of nodes, where each node (except the root) corresponds to a pattern occurring in the left-hand-side of a rule. The path from the root node to a leaf node defines a complete rule left-hand-side. Each node has a memory of facts which satisfy that pattern.
As new facts are asserted or modified, they propagate along the network, causing nodes to be annotated when that fact matches that pattern. When a fact or combination of facts causes all of the patterns for a given rule to be satisfied, a leaf node is reached and the corresponding rule is triggered.
The Rete algorithm is designed to sacrifice memory for increased speed. In most cases, the speed increase over naive implementations is several orders of magnitude (because Rete performance is theoretically independent of the number of rules in the system). In very large expert systems, however, the original Rete algorithm tends to run into memory consumption problems. Other algorithms, both novel and Rete-based, have since been designed which require less memory.
The animations of Rete available here follow the descriptions of the implementation of Rete in the Jess system described in Ch 8, Jess In Action, by Dr. Ernest Friedman-Hill. A copy of Jess can be obtained at: http://herzberg.ca.sandia.gov/jess/index.shtml. A copy of the book, Jess in Action, can be obtained at: http://www.manning.com/friedman-hill/index.html . Besides, Jess reference manual contains Rete algorithm in Ch 19,
Drools is an open source rules engine implementation Rete information on Drools.org.
There are flash animations to describe Rete:
- Rete Network, the corresponding Jess rules, Test1
- Rete Mismatch the corresponding Jess rules, Test2
- Rete Chaining the corresponding Jess rules, Test3
External Links
- Charles Forgy, “Rete: A Fast Algorithm for the Many Pattern/Many Object Pattern Match Problem”, Artificial Intelligence, 19, pp 17-37, 1982
- Robert B. Doorenbos Production Matching for Large Learning Systems, Chapter 2 (Detailed and accessible description of Rete), 1995.