<s>
The	O
Rete	B-Algorithm
algorithm	I-Algorithm
(	O
,	O
,	O
rarely	O
,	O
)	O
is	O
a	O
pattern	B-Language
matching	I-Language
algorithm	O
for	O
implementing	O
rule-based	O
systems	O
.	O
</s>
<s>
The	O
Rete	B-Algorithm
algorithm	I-Algorithm
was	O
designed	O
by	O
Charles	O
L	O
.	O
Forgy	O
of	O
Carnegie	O
Mellon	O
University	O
,	O
first	O
published	O
in	O
a	O
working	O
paper	O
in	O
1974	O
,	O
and	O
later	O
elaborated	O
in	O
his	O
1979	O
Ph.D.	O
thesis	O
and	O
a	O
1982	O
paper	O
.	O
</s>
<s>
A	O
naive	O
implementation	O
of	O
an	O
expert	B-Application
system	I-Application
might	O
check	O
each	O
rule	O
against	O
known	O
facts	O
in	O
a	O
knowledge	O
base	O
,	O
firing	O
that	O
rule	O
if	O
necessary	O
,	O
then	O
moving	O
on	O
to	O
the	O
next	O
rule	O
(	O
and	O
looping	O
back	O
to	O
the	O
first	O
rule	O
when	O
finished	O
)	O
.	O
</s>
<s>
The	O
Rete	B-Algorithm
algorithm	I-Algorithm
provides	O
the	O
basis	O
for	O
a	O
more	O
efficient	O
implementation	O
.	O
</s>
<s>
A	O
Rete-based	O
expert	B-Application
system	I-Application
builds	O
a	O
network	O
of	O
nodes	O
,	O
where	O
each	O
node	O
(	O
except	O
the	O
root	O
)	O
corresponds	O
to	O
a	O
pattern	O
occurring	O
in	O
the	O
left-hand-side	O
(	O
the	O
condition	O
part	O
)	O
of	O
a	O
rule	O
.	O
</s>
<s>
The	O
path	O
from	O
the	O
root	B-Application
node	I-Application
to	O
a	O
leaf	B-Data_Structure
node	I-Data_Structure
defines	O
a	O
complete	O
rule	O
left-hand-side	O
.	O
</s>
<s>
Each	O
node	O
has	O
a	O
memory	B-General_Concept
of	O
facts	O
which	O
satisfy	O
that	O
pattern	O
.	O
</s>
<s>
This	O
structure	O
is	O
essentially	O
a	O
generalized	O
trie	B-General_Concept
.	O
</s>
<s>
When	O
a	O
fact	O
or	O
combination	O
of	O
facts	O
causes	O
all	O
of	O
the	O
patterns	O
for	O
a	O
given	O
rule	O
to	O
be	O
satisfied	O
,	O
a	O
leaf	B-Data_Structure
node	I-Data_Structure
is	O
reached	O
and	O
the	O
corresponding	O
rule	O
is	O
triggered	O
.	O
</s>
<s>
Rete	O
was	O
first	O
used	O
as	O
the	O
core	O
engine	O
of	O
the	O
OPS5	B-Language
production	O
system	O
language	O
which	O
was	O
used	O
to	O
build	O
early	O
systems	O
including	O
R1	O
for	O
Digital	O
Equipment	O
Corporation	O
.	O
</s>
<s>
Rete	O
has	O
become	O
the	O
basis	O
for	O
many	O
popular	O
rule	O
engines	O
and	O
expert	B-Application
system	I-Application
shells	O
,	O
including	O
CLIPS	B-Application
,	O
Jess	B-Language
,	O
Drools	B-Language
,	O
IBM	B-Application
Operational	I-Application
Decision	I-Application
Management	I-Application
,	O
BizTalk	B-Application
Rules	O
Engine	O
,	O
and	O
Soar	B-Architecture
.	O
</s>
<s>
The	O
Rete	B-Algorithm
algorithm	I-Algorithm
is	O
designed	O
to	O
sacrifice	O
memory	B-General_Concept
for	O
increased	O
speed	O
.	O
</s>
<s>
In	O
very	O
large	O
expert	B-Application
systems	I-Application
,	O
however	O
,	O
the	O
original	O
Rete	B-Algorithm
algorithm	I-Algorithm
tends	O
to	O
run	O
into	O
memory	B-General_Concept
and	O
server	O
consumption	O
problems	O
.	O
</s>
<s>
Other	O
algorithms	O
,	O
both	O
novel	O
and	O
Rete-based	O
,	O
have	O
since	O
been	O
designed	O
which	O
require	O
less	O
memory	B-General_Concept
(	O
e.g.	O
</s>
<s>
The	O
Rete	B-Algorithm
algorithm	I-Algorithm
provides	O
a	O
generalized	O
logical	O
description	O
of	O
an	O
implementation	O
of	O
functionality	O
responsible	O
for	O
matching	O
data	O
tuples	B-Application
(	O
"	O
facts	O
"	O
)	O
against	O
productions	O
(	O
"	O
rules	O
"	O
)	O
in	O
a	O
pattern-matching	B-Language
production	O
system	O
(	O
a	O
category	O
of	O
rule	O
engine	O
)	O
.	O
</s>
<s>
Conditions	O
test	O
fact	O
attributes	B-General_Concept
,	O
including	O
fact	O
type	O
specifiers/identifiers	O
.	O
</s>
<s>
The	O
Rete	B-Algorithm
algorithm	I-Algorithm
exhibits	O
the	O
following	O
major	O
characteristics	O
:	O
</s>
<s>
This	O
,	O
in	O
turn	O
,	O
allows	O
production	O
systems	O
to	O
avoid	O
complete	O
re-evaluation	O
of	O
all	O
facts	O
each	O
time	O
changes	O
are	O
made	O
to	O
the	O
production	O
system	O
's	O
working	O
memory	B-General_Concept
.	O
</s>
<s>
Instead	O
,	O
the	O
production	O
system	O
needs	O
only	O
to	O
evaluate	O
the	O
changes	O
(	O
deltas	O
)	O
to	O
working	O
memory	B-General_Concept
.	O
</s>
<s>
It	O
allows	O
for	O
efficient	O
removal	O
of	O
memory	B-General_Concept
elements	O
when	O
facts	O
are	O
retracted	O
from	O
working	O
memory	B-General_Concept
.	O
</s>
<s>
The	O
Rete	B-Algorithm
algorithm	I-Algorithm
is	O
widely	O
used	O
to	O
implement	O
matching	O
functionality	O
within	O
pattern-matching	B-Language
engines	O
that	O
exploit	O
a	O
match-resolve-act	O
cycle	O
to	O
support	O
forward	O
chaining	O
and	O
inferencing	O
.	O
</s>
<s>
They	O
are	O
generally	O
represented	O
at	O
run-time	O
using	O
a	O
network	O
of	O
in-memory	O
objects	O
.	O
</s>
<s>
These	O
networks	O
match	O
rule	O
conditions	O
(	O
patterns	O
)	O
to	O
facts	O
(	O
relational	O
data	O
tuples	B-Application
)	O
.	O
</s>
<s>
Rete	B-Algorithm
networks	I-Algorithm
act	O
as	O
a	O
type	O
of	O
relational	O
query	O
processor	O
,	O
performing	O
projections	B-Algorithm
,	O
selections	B-Algorithm
and	O
joins	O
conditionally	O
on	O
arbitrary	O
numbers	O
of	O
data	O
tuples	B-Application
.	O
</s>
<s>
Productions	O
(	O
rules	O
)	O
are	O
typically	O
captured	O
and	O
defined	O
by	O
analysts	O
and	O
developers	B-Application
using	O
some	O
high-level	O
rules	O
language	O
.	O
</s>
<s>
When	O
facts	O
are	O
"	O
asserted	O
"	O
to	O
working	O
memory	B-General_Concept
,	O
the	O
engine	O
creates	O
working	O
memory	B-General_Concept
elements	O
(	O
WMEs	O
)	O
for	O
each	O
fact	O
.	O
</s>
<s>
Facts	O
are	O
n-tuples	O
,	O
and	O
may	O
therefore	O
contain	O
an	O
arbitrary	O
number	O
of	O
data	O
items	O
.	O
</s>
<s>
Each	O
WME	O
may	O
hold	O
an	O
entire	O
n-tuple	O
,	O
or	O
,	O
alternatively	O
,	O
each	O
fact	O
may	O
be	O
represented	O
by	O
a	O
set	O
of	O
WMEs	O
where	O
each	O
WME	O
contains	O
a	O
fixed-length	O
tuple	B-Application
.	O
</s>
<s>
In	O
this	O
case	O
,	O
tuples	B-Application
are	O
typically	O
triplets	O
(	O
3-tuples	O
)	O
.	O
</s>
<s>
Each	O
WME	O
enters	O
the	O
Rete	B-Algorithm
network	I-Algorithm
at	O
a	O
single	O
root	B-Application
node	I-Application
.	O
</s>
<s>
The	O
root	B-Application
node	I-Application
passes	O
each	O
WME	O
on	O
to	O
its	O
child	O
nodes	O
,	O
and	O
each	O
WME	O
may	O
then	O
be	O
propagated	O
through	O
the	O
network	O
,	O
possibly	O
being	O
stored	O
in	O
intermediate	O
memories	O
,	O
until	O
it	O
arrives	O
at	O
a	O
terminal	O
node	O
.	O
</s>
<s>
The	O
"	O
left	O
"	O
(	O
alpha	O
)	O
side	O
of	O
the	O
node	O
graph	O
forms	O
a	O
discrimination	O
network	O
responsible	O
for	O
selecting	O
individual	O
WMEs	O
based	O
on	O
simple	O
conditional	B-Language
tests	O
which	O
match	O
WME	O
attributes	B-General_Concept
against	O
constant	O
values	O
.	O
</s>
<s>
Nodes	O
in	O
the	O
discrimination	O
network	O
may	O
also	O
perform	O
tests	O
that	O
compare	O
two	O
or	O
more	O
attributes	B-General_Concept
of	O
the	O
same	O
WME	O
.	O
</s>
<s>
In	O
most	O
engines	O
,	O
the	O
immediate	O
child	O
nodes	O
of	O
the	O
root	B-Application
node	I-Application
are	O
used	O
to	O
test	O
the	O
entity	O
identifier	O
or	O
fact	O
type	O
of	O
each	O
WME	O
.	O
</s>
<s>
Within	O
the	O
discrimination	O
network	O
,	O
each	O
branch	O
of	O
alpha	O
nodes	O
(	O
also	O
called	O
1-input	O
nodes	O
)	O
terminates	O
at	O
a	O
memory	B-General_Concept
,	O
called	O
an	O
alpha	O
memory	B-General_Concept
.	O
</s>
<s>
WMEs	O
that	O
fail	O
to	O
match	O
at	O
least	O
one	O
condition	O
in	O
a	O
branch	O
are	O
not	O
materialised	O
within	O
the	O
corresponding	O
alpha	O
memory	B-General_Concept
.	O
</s>
<s>
Each	O
beta	O
node	O
sends	O
its	O
output	O
to	O
a	O
beta	O
memory	B-General_Concept
.	O
</s>
<s>
A	O
WME	O
list	O
in	O
a	O
beta	O
memory	B-General_Concept
represents	O
a	O
partial	O
match	O
for	O
the	O
conditions	O
in	O
a	O
given	O
production	O
.	O
</s>
<s>
Agendas	O
are	O
typically	O
implemented	O
as	O
prioritised	B-Application
queues	I-Application
.	O
</s>
<s>
An	O
alpha	O
memory	B-General_Concept
holds	O
WM	O
and	O
performs	O
"	O
right	O
"	O
activations	O
on	O
the	O
beta	O
node	O
each	O
time	O
it	O
stores	O
a	O
new	O
WME	O
.	O
</s>
<s>
A	O
beta	O
memory	B-General_Concept
holds	O
WME	O
lists	O
and	O
performs	O
"	O
left	O
"	O
activations	O
on	O
the	O
beta	O
node	O
each	O
time	O
it	O
stores	O
a	O
new	O
WME	O
list	O
.	O
</s>
<s>
When	O
a	O
join	O
node	O
is	O
right-activated	O
,	O
it	O
compares	O
one	O
or	O
more	O
attributes	B-General_Concept
of	O
the	O
newly	O
stored	O
WME	O
from	O
its	O
input	O
alpha	O
memory	B-General_Concept
against	O
given	O
attributes	B-General_Concept
of	O
specific	O
WMEs	O
in	O
each	O
WME	O
list	O
contained	O
in	O
the	O
input	O
beta	O
memory	B-General_Concept
.	O
</s>
<s>
When	O
a	O
join	O
node	O
is	O
left-activated	O
it	O
traverses	O
a	O
single	O
newly	O
stored	O
WME	O
list	O
in	O
the	O
beta	O
memory	B-General_Concept
,	O
retrieving	O
specific	O
attribute	O
values	O
of	O
given	O
WMEs	O
.	O
</s>
<s>
It	O
compares	O
these	O
values	O
with	O
attribute	O
values	O
of	O
each	O
WME	O
in	O
the	O
alpha	O
memory	B-General_Concept
.	O
</s>
<s>
Each	O
beta	O
node	O
outputs	O
WME	O
lists	O
which	O
are	O
either	O
stored	O
in	O
a	O
beta	O
memory	B-General_Concept
or	O
sent	O
directly	O
to	O
a	O
terminal	O
node	O
.	O
</s>
<s>
Logically	O
,	O
a	O
beta	O
node	O
at	O
the	O
head	O
of	O
a	O
branch	O
of	O
beta	O
nodes	O
is	O
a	O
special	O
case	O
because	O
it	O
takes	O
no	O
input	O
from	O
any	O
beta	O
memory	B-General_Concept
higher	O
in	O
the	O
network	O
.	O
</s>
<s>
In	O
order	O
to	O
eliminate	O
node	O
redundancies	O
,	O
any	O
one	O
alpha	O
or	O
beta	O
memory	B-General_Concept
may	O
be	O
used	O
to	O
perform	O
activations	O
on	O
multiple	O
beta	O
nodes	O
.	O
</s>
<s>
During	O
any	O
one	O
match-resolve-act	O
cycle	O
,	O
the	O
engine	O
will	O
find	O
all	O
possible	O
matches	O
for	O
the	O
facts	O
currently	O
asserted	O
to	O
working	O
memory	B-General_Concept
.	O
</s>
<s>
The	O
order	O
may	O
be	O
based	O
on	O
rule	O
priority	O
(	O
salience	O
)	O
,	O
rule	O
order	O
,	O
the	O
time	O
at	O
which	O
facts	O
contained	O
in	O
each	O
instance	O
were	O
asserted	O
to	O
the	O
working	O
memory	B-General_Concept
,	O
the	O
complexity	O
of	O
each	O
production	O
,	O
or	O
some	O
other	O
criteria	O
.	O
</s>
<s>
Many	O
engines	O
allow	O
rule	O
developers	B-Application
to	O
select	O
between	O
different	O
conflict	O
resolution	O
strategies	O
or	O
to	O
chain	O
a	O
selection	O
of	O
multiple	O
strategies	O
.	O
</s>
<s>
Conflict	O
resolution	O
is	O
not	O
defined	O
as	O
part	O
of	O
the	O
Rete	B-Algorithm
algorithm	I-Algorithm
,	O
but	O
is	O
used	O
alongside	O
the	O
algorithm	O
.	O
</s>
<s>
However	O
,	O
the	O
sequence	O
of	O
production	O
instance	O
firings	O
may	O
be	O
interrupted	O
at	O
any	O
stage	O
by	O
performing	O
changes	O
to	O
the	O
working	O
memory	B-General_Concept
.	O
</s>
<s>
Rule	O
actions	O
can	O
contain	O
instructions	O
to	O
assert	O
or	O
retract	O
WMEs	O
from	O
the	O
working	O
memory	B-General_Concept
of	O
the	O
engine	O
.	O
</s>
<s>
This	O
includes	O
"	O
updates	O
"	O
to	O
WMEs	O
currently	O
in	O
the	O
working	O
memory	B-General_Concept
.	O
</s>
<s>
They	O
may	O
also	O
provide	O
automatic	O
loop	B-Algorithm
detection	I-Algorithm
in	O
which	O
never-ending	O
loops	O
are	O
automatically	O
halted	O
after	O
a	O
given	O
number	O
of	O
iterations	O
.	O
</s>
<s>
As	O
for	O
conflict	O
resolution	O
,	O
the	O
firing	O
of	O
activated	O
production	O
instances	O
is	O
not	O
a	O
feature	O
of	O
the	O
Rete	B-Algorithm
algorithm	I-Algorithm
.	O
</s>
<s>
However	O
,	O
it	O
is	O
a	O
central	O
feature	O
of	O
engines	O
that	O
use	O
Rete	B-Algorithm
networks	I-Algorithm
.	O
</s>
<s>
Some	O
of	O
the	O
optimisations	O
offered	O
by	O
Rete	B-Algorithm
networks	I-Algorithm
are	O
only	O
useful	O
in	O
scenarios	O
where	O
the	O
engine	O
performs	O
multiple	O
match-resolve-act	O
cycles	O
.	O
</s>
<s>
Conditional	B-Language
tests	O
are	O
most	O
commonly	O
used	O
to	O
perform	O
selections	B-Algorithm
and	O
joins	O
on	O
individual	O
tuples	B-Application
.	O
</s>
<s>
However	O
,	O
by	O
implementing	O
additional	O
beta	O
node	O
types	O
,	O
it	O
is	O
possible	O
for	O
Rete	B-Algorithm
networks	I-Algorithm
to	O
perform	O
quantifications	B-Language
.	O
</s>
<s>
Existential	B-Algorithm
quantification	I-Algorithm
involves	O
testing	O
for	O
the	O
existence	O
of	O
at	O
least	O
one	O
set	O
of	O
matching	O
WMEs	O
in	O
working	O
memory	B-General_Concept
.	O
</s>
<s>
Universal	O
quantification	B-Language
involves	O
testing	O
that	O
an	O
entire	O
set	O
of	O
WMEs	O
in	O
working	O
memory	B-General_Concept
meets	O
a	O
given	O
condition	O
.	O
</s>
<s>
A	O
variation	O
of	O
universal	O
quantification	B-Language
might	O
test	O
that	O
a	O
given	O
number	O
of	O
WMEs	O
,	O
drawn	O
from	O
a	O
set	O
of	O
WMEs	O
,	O
meets	O
given	O
criteria	O
.	O
</s>
<s>
Quantification	B-Language
is	O
not	O
universally	O
implemented	O
in	O
Rete	O
engines	O
,	O
and	O
,	O
where	O
it	O
is	O
supported	O
,	O
several	O
variations	O
exist	O
.	O
</s>
<s>
A	O
variant	O
of	O
existential	B-Algorithm
quantification	I-Algorithm
referred	O
to	O
as	O
negation	O
is	O
widely	O
,	O
though	O
not	O
universally	O
,	O
supported	O
,	O
and	O
is	O
described	O
in	O
seminal	O
documents	O
.	O
</s>
<s>
In	O
another	O
approach	O
,	O
the	O
node	O
maintains	O
an	O
additional	O
memory	B-General_Concept
on	O
each	O
WME	O
list	O
received	O
from	O
the	O
left	O
input	O
.	O
</s>
<s>
These	O
memories	O
are	O
a	O
form	O
of	O
beta	O
memory	B-General_Concept
,	O
and	O
store	O
WME	O
lists	O
for	O
each	O
match	O
with	O
WMEs	O
received	O
on	O
the	O
right	O
input	O
.	O
</s>
<s>
If	O
a	O
WME	O
list	O
does	O
not	O
have	O
any	O
WME	O
lists	O
in	O
its	O
memory	B-General_Concept
,	O
it	O
is	O
propagated	O
down	O
the	O
network	O
.	O
</s>
<s>
In	O
this	O
approach	O
,	O
negation	O
nodes	O
generally	O
activate	O
further	O
beta	O
nodes	O
directly	O
,	O
rather	O
than	O
storing	O
their	O
output	O
in	O
an	O
additional	O
beta	O
memory	B-General_Concept
.	O
</s>
<s>
Negation	O
nodes	O
provide	O
a	O
form	O
of	O
'	O
negation	B-Application
as	I-Application
failure	I-Application
 '	O
.	O
</s>
<s>
When	O
changes	O
are	O
made	O
to	O
working	O
memory	B-General_Concept
,	O
a	O
WME	O
list	O
that	O
previously	O
matched	O
no	O
WMEs	O
may	O
now	O
match	O
newly	O
asserted	O
WMEs	O
.	O
</s>
<s>
Existential	B-Algorithm
quantification	I-Algorithm
can	O
be	O
performed	O
by	O
combining	O
two	O
negation	O
beta	O
nodes	O
.	O
</s>
<s>
The	O
Rete	B-Algorithm
algorithm	I-Algorithm
does	O
not	O
mandate	O
any	O
specific	O
approach	O
to	O
indexing	O
the	O
working	O
memory	B-General_Concept
.	O
</s>
<s>
A	O
good	O
indexing	O
strategy	O
is	O
a	O
major	O
factor	O
in	O
deciding	O
the	O
overall	O
performance	O
of	O
a	O
production	O
system	O
,	O
especially	O
when	O
executing	O
rule	O
sets	O
that	O
result	O
in	O
highly	O
combinatorial	O
pattern	B-Language
matching	I-Language
(	O
i.e.	O
,	O
intensive	O
use	O
of	O
beta	O
join	O
nodes	O
)	O
,	O
or	O
,	O
for	O
some	O
engines	O
,	O
when	O
executing	O
rules	O
sets	O
that	O
perform	O
a	O
significant	O
number	O
of	O
WME	O
retractions	O
during	O
multiple	O
match-resolve-act	O
cycles	O
.	O
</s>
<s>
Memories	O
are	O
often	O
implemented	O
using	O
combinations	O
of	O
hash	B-Algorithm
tables	I-Algorithm
,	O
and	O
hash	O
values	O
are	O
used	O
to	O
perform	O
conditional	B-Language
joins	O
on	O
subsets	O
of	O
WME	O
lists	O
and	O
WMEs	O
,	O
rather	O
than	O
on	O
the	O
entire	O
contents	O
of	O
memories	O
.	O
</s>
<s>
This	O
,	O
in	O
turn	O
,	O
often	O
significantly	O
reduces	O
the	O
number	O
of	O
evaluations	O
performed	O
by	O
the	O
Rete	B-Algorithm
network	I-Algorithm
.	O
</s>
<s>
When	O
a	O
WME	O
is	O
retracted	O
from	O
working	O
memory	B-General_Concept
,	O
it	O
must	O
be	O
removed	O
from	O
every	O
alpha	O
memory	B-General_Concept
in	O
which	O
it	O
is	O
stored	O
.	O
</s>
<s>
Memory	B-General_Concept
indexing	O
may	O
be	O
used	O
in	O
some	O
cases	O
to	O
optimise	O
removal	O
.	O
</s>
<s>
The	O
resulting	O
Rete	B-Algorithm
network	I-Algorithm
contains	O
sets	O
of	O
terminal	O
nodes	O
which	O
,	O
together	O
,	O
represent	O
single	O
productions	O
.	O
</s>
<s>
Most	O
implementations	O
use	O
type	O
nodes	O
to	O
perform	O
the	O
first	O
level	O
of	O
selection	O
on	O
n-tuple	O
working	O
memory	B-General_Concept
elements	O
.	O
</s>
<s>
They	O
discriminate	O
between	O
different	O
tuple	B-Application
relation	O
types	O
.	O
</s>
<s>
For	O
a	O
more	O
detailed	O
and	O
complete	O
description	O
of	O
the	O
Rete	B-Algorithm
algorithm	I-Algorithm
,	O
see	O
chapter	O
2	O
of	O
Production	O
Matching	O
for	O
Large	O
Learning	O
Systems	O
by	O
Robert	O
Doorenbos	O
(	O
see	O
link	O
below	O
)	O
.	O
</s>
<s>
The	O
index	O
may	O
be	O
implemented	O
using	O
a	O
hash	B-Algorithm
table	I-Algorithm
.	O
</s>
<s>
Each	O
memory	B-General_Concept
holds	O
WMEs	O
that	O
match	O
a	O
single	O
conditional	B-Language
pattern	O
,	O
and	O
the	O
index	O
is	O
used	O
to	O
reference	O
memories	O
by	O
their	O
pattern	O
.	O
</s>
<s>
This	O
approach	O
is	O
only	O
practical	O
when	O
WMEs	O
represent	O
fixed-length	O
tuples	B-Application
,	O
and	O
the	O
length	O
of	O
each	O
tuple	B-Application
is	O
short	O
(	O
e.g.	O
,	O
3-tuples	O
)	O
.	O
</s>
<s>
In	O
addition	O
,	O
the	O
approach	O
only	O
applies	O
to	O
conditional	B-Language
patterns	O
that	O
perform	O
equality	O
tests	O
against	O
constant	O
values	O
.	O
</s>
<s>
When	O
a	O
WME	O
enters	O
the	O
Rete	O
,	O
the	O
index	O
is	O
used	O
to	O
locate	O
a	O
set	O
of	O
memories	O
whose	O
conditional	B-Language
pattern	B-Language
matches	I-Language
the	O
WME	O
attributes	B-General_Concept
,	O
and	O
the	O
WME	O
is	O
then	O
added	O
directly	O
to	O
each	O
of	O
these	O
memories	O
.	O
</s>
<s>
However	O
,	O
in	O
order	O
to	O
implement	O
non-equality	O
tests	O
,	O
the	O
Rete	O
may	O
contain	O
additional	O
1-input	O
node	O
networks	O
through	O
which	O
WMEs	O
are	O
passed	O
before	O
being	O
placed	O
in	O
a	O
memory	B-General_Concept
.	O
</s>
<s>
A	O
common	O
variation	O
is	O
to	O
build	O
linked	B-Data_Structure
lists	I-Data_Structure
of	O
tokens	O
where	O
each	O
token	O
holds	O
a	O
single	O
WME	O
.	O
</s>
<s>
In	O
this	O
case	O
,	O
lists	O
of	O
WMEs	O
for	O
a	O
partial	O
match	O
are	O
represented	O
by	O
the	O
linked	B-Data_Structure
list	I-Data_Structure
of	O
tokens	O
.	O
</s>
<s>
Instead	O
,	O
a	O
beta	O
node	O
needs	O
only	O
to	O
create	O
a	O
new	O
token	O
to	O
hold	O
a	O
WME	O
it	O
wishes	O
to	O
join	O
to	O
the	O
partial	O
match	O
list	O
,	O
and	O
then	O
link	O
the	O
new	O
token	O
to	O
a	O
parent	O
token	O
stored	O
in	O
the	O
input	O
beta	O
memory	B-General_Concept
.	O
</s>
<s>
The	O
new	O
token	O
now	O
forms	O
the	O
head	O
of	O
the	O
token	O
list	O
,	O
and	O
is	O
stored	O
in	O
the	O
output	O
beta	O
memory	B-General_Concept
.	O
</s>
<s>
A	O
token	O
is	O
a	O
unit	O
of	O
storage	O
within	O
a	O
memory	B-General_Concept
and	O
also	O
a	O
unit	O
of	O
exchange	O
between	O
memories	O
and	O
nodes	O
.	O
</s>
<s>
The	O
new	O
tokens	O
are	O
then	O
stored	O
in	O
the	O
output	O
memory	B-General_Concept
.	O
</s>
<s>
Although	O
not	O
defined	O
by	O
the	O
Rete	B-Algorithm
algorithm	I-Algorithm
,	O
some	O
engines	O
provide	O
extended	O
functionality	O
to	O
support	O
greater	O
control	O
of	O
truth	O
maintenance	O
.	O
</s>
<s>
If	O
a	O
subsequent	O
change	O
to	O
working	O
memory	B-General_Concept
causes	O
the	O
first	O
match	O
to	O
become	O
invalid	O
,	O
it	O
may	O
be	O
that	O
this	O
implies	O
that	O
the	O
second	O
match	O
is	O
also	O
invalid	O
.	O
</s>
<s>
The	O
Rete	B-Algorithm
algorithm	I-Algorithm
does	O
not	O
define	O
any	O
mechanism	O
to	O
define	O
and	O
handle	O
these	O
logical	O
truth	O
dependencies	O
automatically	O
.	O
</s>
<s>
The	O
Rete	B-Algorithm
algorithm	I-Algorithm
does	O
not	O
define	O
any	O
approach	O
to	O
justification	O
.	O
</s>
<s>
For	O
example	O
,	O
an	O
expert	B-Application
system	I-Application
might	O
justify	O
a	O
conclusion	O
that	O
an	O
animal	O
is	O
an	O
elephant	O
by	O
reporting	O
that	O
it	O
is	O
large	O
,	O
grey	O
,	O
has	O
big	O
ears	O
,	O
a	O
trunk	O
and	O
tusks	O
.	O
</s>
<s>
Some	O
engines	O
provide	O
built-in	O
justification	O
systems	O
in	O
conjunction	O
with	O
their	O
implementation	O
of	O
the	O
Rete	B-Algorithm
algorithm	I-Algorithm
.	O
</s>
<s>
This	O
article	O
does	O
not	O
provide	O
an	O
exhaustive	O
description	O
of	O
every	O
possible	O
variation	O
or	O
extension	O
of	O
the	O
Rete	B-Algorithm
algorithm	I-Algorithm
.	O
</s>
<s>
For	O
example	O
,	O
engines	O
may	O
provide	O
specialised	O
support	O
within	O
the	O
Rete	B-Algorithm
network	I-Algorithm
in	O
order	O
to	O
apply	O
pattern-matching	B-Language
rule	O
processing	O
to	O
specific	O
data	O
types	O
and	O
sources	O
such	O
as	O
programmatic	O
objects	O
,	O
XML	B-Protocol
data	O
or	O
relational	B-Application
data	I-Application
tables	I-Application
.	O
</s>
<s>
Another	O
example	O
concerns	O
additional	O
time-stamping	O
facilities	O
provided	O
by	O
many	O
engines	O
for	O
each	O
WME	O
entering	O
a	O
Rete	B-Algorithm
network	I-Algorithm
,	O
and	O
the	O
use	O
of	O
these	O
time-stamps	O
in	O
conjunction	O
with	O
conflict	O
resolution	O
strategies	O
.	O
</s>
<s>
Engines	O
exhibit	O
significant	O
variation	O
in	O
the	O
way	O
they	O
allow	O
programmatic	O
access	O
to	O
the	O
engine	O
and	O
its	O
working	O
memory	B-General_Concept
,	O
and	O
may	O
extend	O
the	O
basic	O
Rete	O
model	O
to	O
support	O
forms	O
of	O
parallel	O
and	O
distributed	O
processing	O
.	O
</s>
<s>
The	O
Rete	B-Algorithm
algorithm	I-Algorithm
is	O
suited	O
to	O
scenarios	O
where	O
forward	O
chaining	O
and	O
"	O
inferencing	O
"	O
is	O
used	O
to	O
calculate	O
new	O
facts	O
from	O
existing	O
facts	O
,	O
or	O
to	O
filter	O
and	O
discard	O
facts	O
in	O
order	O
to	O
arrive	O
at	O
some	O
conclusion	O
.	O
</s>
<s>
It	O
is	O
also	O
exploited	O
as	O
a	O
reasonably	O
efficient	O
mechanism	O
for	O
performing	O
highly	O
combinatorial	O
evaluations	O
of	O
facts	O
where	O
large	O
numbers	O
of	O
joins	O
must	O
be	O
performed	O
between	O
fact	O
tuples	B-Application
.	O
</s>
<s>
Other	O
approaches	O
to	O
performing	O
rule	O
evaluation	O
,	O
such	O
as	O
the	O
use	O
of	O
decision	B-Algorithm
trees	I-Algorithm
,	O
or	O
the	O
implementation	O
of	O
sequential	O
engines	O
,	O
may	O
be	O
more	O
appropriate	O
for	O
simple	O
scenarios	O
,	O
and	O
should	O
be	O
considered	O
as	O
possible	O
alternatives	O
.	O
</s>
<s>
Performance	O
of	O
Rete	O
is	O
also	O
largely	O
a	O
matter	O
of	O
implementation	O
choices	O
(	O
independent	O
of	O
the	O
network	O
topology	O
)	O
,	O
one	O
of	O
which	O
(	O
the	O
use	O
of	O
hash	B-Algorithm
tables	I-Algorithm
)	O
leads	O
to	O
major	O
improvements	O
.	O
</s>
<s>
2	O
)	O
the	O
use	O
of	O
an	O
old	O
implementation	O
;	O
for	O
instance	O
,	O
the	O
references	O
in	O
the	O
following	O
two	O
sections	O
(	O
Rete	B-Algorithm
II	I-Algorithm
and	O
Rete-NT	O
)	O
compare	O
some	O
commercial	O
products	O
to	O
totally	O
outdated	O
versions	O
of	O
CLIPS	B-Application
and	O
they	O
claim	O
that	O
the	O
commercial	O
products	O
may	O
be	O
orders	O
of	O
magnitude	O
faster	O
than	O
CLIPS	B-Application
;	O
this	O
is	O
forgetting	O
that	O
CLIPS	B-Application
6.30	O
(	O
with	O
the	O
introduction	O
of	O
hash	B-Algorithm
tables	I-Algorithm
as	O
in	O
Rete	B-Algorithm
II	I-Algorithm
)	O
is	O
orders	O
of	O
magnitude	O
faster	O
than	O
the	O
version	O
used	O
for	O
the	O
comparisons	O
(	O
CLIPS	B-Application
6.04	O
)	O
.	O
</s>
<s>
In	O
the	O
1980s	O
,	O
Charles	O
Forgy	O
developed	O
a	O
successor	O
to	O
the	O
Rete	B-Algorithm
algorithm	I-Algorithm
named	O
Rete	B-Algorithm
II	I-Algorithm
.	O
</s>
<s>
Rete	B-Algorithm
II	I-Algorithm
claims	O
better	O
performance	O
for	O
more	O
complex	O
problems	O
(	O
even	O
orders	O
of	O
magnitude	O
)	O
,	O
and	O
is	O
officially	O
implemented	O
in	O
CLIPS/R2	O
,	O
a	O
C/	O
++	O
implementation	O
and	O
in	O
OPSJ	O
,	O
a	O
Java	O
implementation	O
in	O
1998	O
.	O
</s>
<s>
Rete	B-Algorithm
II	I-Algorithm
gives	O
about	O
a	O
100	O
to	O
1	O
order	O
of	O
magnitude	O
performance	O
improvement	O
in	O
more	O
complex	O
problems	O
as	O
shown	O
by	O
KnowledgeBased	O
Systems	O
Corporation	O
benchmarks	O
.	O
</s>
<s>
Rete	B-Algorithm
II	I-Algorithm
can	O
be	O
characterized	O
by	O
two	O
areas	O
of	O
improvement	O
;	O
specific	O
optimizations	O
relating	O
to	O
the	O
general	O
performance	O
of	O
the	O
Rete	B-Algorithm
network	I-Algorithm
(	O
including	O
the	O
use	O
of	O
hashed	O
memories	O
in	O
order	O
to	O
increase	O
performance	O
with	O
larger	O
sets	O
of	O
data	O
)	O
,	O
and	O
the	O
inclusion	O
of	O
a	O
backward	O
chaining	O
algorithm	O
tailored	O
to	O
run	O
on	O
top	O
of	O
the	O
Rete	B-Algorithm
network	I-Algorithm
.	O
</s>
<s>
Backward	O
chaining	O
alone	O
can	O
account	O
for	O
the	O
most	O
extreme	O
changes	O
in	O
benchmarks	O
relating	O
to	O
Rete	O
vs.	O
Rete	B-Algorithm
II	I-Algorithm
.	O
</s>
<s>
Jess	B-Language
(	O
at	O
least	O
versions	O
5.0	O
and	O
later	O
)	O
also	O
adds	O
a	O
commercial	O
backward	O
chaining	O
algorithm	O
on	O
top	O
of	O
the	O
Rete	B-Algorithm
network	I-Algorithm
,	O
but	O
it	O
cannot	O
be	O
said	O
to	O
fully	O
implement	O
Rete	B-Algorithm
II	I-Algorithm
,	O
in	O
part	O
due	O
to	O
the	O
fact	O
that	O
no	O
full	O
specification	O
is	O
publicly	O
available	O
.	O
</s>
<s>
The	O
Rete	O
III	O
algorithm	O
,	O
which	O
is	O
not	O
Rete-NT	O
,	O
is	O
the	O
FICO	O
trademark	O
for	O
Rete	B-Algorithm
II	I-Algorithm
and	O
is	O
implemented	O
as	O
part	O
of	O
the	O
FICO	O
Advisor	O
engine	O
.	O
</s>
<s>
It	O
is	O
basically	O
the	O
Rete	B-Algorithm
II	I-Algorithm
engine	O
with	O
an	O
API	O
that	O
allows	O
access	O
to	O
the	O
Advisor	O
engine	O
because	O
the	O
Advisor	O
engine	O
can	O
access	O
other	O
FICO	O
products	O
.	O
</s>
<s>
In	O
2010	O
,	O
Forgy	O
developed	O
a	O
new	O
generation	O
of	O
the	O
Rete	B-Algorithm
algorithm	I-Algorithm
.	O
</s>
<s>
In	O
an	O
InfoWorld	O
benchmark	O
,	O
the	O
algorithm	O
was	O
deemed	O
500	O
times	O
faster	O
than	O
the	O
original	O
Rete	B-Algorithm
algorithm	I-Algorithm
and	O
10	O
times	O
faster	O
than	O
its	O
predecessor	O
,	O
Rete	B-Algorithm
II	I-Algorithm
.	O
</s>
<s>
Considering	O
that	O
Rete	O
aims	O
to	O
support	O
first	O
order	O
logic	O
(	O
basically	O
if-then-else	B-Language
statements	O
)	O
,	O
Rete-OO	O
aims	O
to	O
provide	O
a	O
rule-based	O
system	O
that	O
supports	O
uncertainty	O
(	O
where	O
the	O
information	O
to	O
make	O
a	O
decision	O
is	O
missing	O
or	O
is	O
inaccurate	O
)	O
.	O
</s>
<s>
For	O
this	O
it	O
extends	O
Drools	B-Language
language	O
(	O
which	O
already	O
implements	O
the	O
Rete	B-Algorithm
algorithm	I-Algorithm
)	O
to	O
make	O
it	O
support	O
probabilistic	O
logic	O
,	O
like	O
Fuzzy	O
logic	O
and	O
Bayesian	O
networks	O
.	O
</s>
