Rule Based System - RETE Algorithm
Rule Based System - RETE Algorithm
Rule Based System - RETE Algorithm
(Slot B)
Dr. M. Suguna
Assistant Professor, CSE Dept., TCE
mscse@tce.edu
Knowledge Representation
If-Then Rules
Production Systems
Forward Chaining
Backward Chaining
Rule Based System
13
The part of an expert system that does not contain any domain
specific or case specific knowledge is the expert system shell.
A single expert system shell can be used to build a number of
different expert systems.
An example of an expert system shell is CLIPS.
INFERENCE
WORKING ENGINE
MEMORY
PATTERN EXECUTION
MATCHER ENGINE
RULE
BASE
AGENDA
RBS Inference Cycle
Match Conflict Set (CS)
Select
Act (Execute)
RBS strategy
Rule chaining direction: forward, backward
Rule selection from CS
Computational effort
Match – 80-90%
Large computational requirement to perfrom match of LHS
– determine if all instantiations of rules are satisfied by the content
of the WM (Working Memory)
Patterns
Rules
RETE Graph
(defrule show-act WM
(a ?x) (a 1)
(b ?x ?y) (b 1 2) (b 2 3) (b 2 4)
(c ?y ?z) (c 3) (c 2)
=> …
show-act
a c select
b
a 1 b 1 2 c 3 Resulting relations
b 2 3 c 2 (alpha memories)
b 2 4
Join x
a 1 b 1 2
Intermediate partial result
(beta memories)
Join y
a 1 b 1 2 c 2
a c select
b
a 1 b 1 2 c 3 Resulting relations
+ a 2 b 2 3 c 2 (alpha memories)
b 2 4
Join x
a 1 b 1 2
Intermediate partial result
(beta memories)
+ a 2 b 2 3
+ a 2 b 2 4
Join y
(defrule show-act
a 1 b 1 2 c 2 (a ?x)
(b ?x ?y)
+ a 2 b 2 3 c 3 (c ?y ?z)
=> …
Changes to conflict set
Activity of the RETE Match during a Deletion
- a 2
a c select
b
a 1 b 1 2 c 3 Resulting relations
- a 2 b 2 3 c 2 (alpha memories)
b 2 4
Join x
a 1 b 1 2
Intermediate partial result
(beta memories)
- a 2 b 2 3
- a 2 b 2 4
Join y
(defrule show-act
a 1 b 1 2 c 2 (a ?x)
(b ?x ?y)
- a 2 b 2 3 c 3 (c ?y ?z)
=> …
Changes to conflict set
Given the facts and Rules Rules:
form the RETE graph
Facts:
PROs
Sufficient state is maintained so that the comparison of 2 WMEs on two
different cycles is minimized
Similar rules will compile to similar networks
CONs
Every time a WME is removed, the same sequence that occurred during
addition must be performed and the stored state unwound
A beta-memory may contain the full Cartesian product of its two-input
memories – size combinatorially explosive
To maintain beta-memories, the join operation must be performed in a fixed
order, determined statically at compile time
Takes knowledge from experts and inputs it into the expert system
Usually choose which expert system shell to use
Responsible for entering meta-rules
If…Then Rules
Forward chaining
Backward chaining
Rule Based System (RBS)
RETE graph
Examples for RETE graph
Next lecture
Game Planning
******