A Rule-Based Inference Engine PDF
A Rule-Based Inference Engine PDF
ABSTRACT
An inference engine for rule based expert systems which forms part
of the EXPRES system is developed and presented. It is shown to be
universal, correct, and optimal with respect to time. In addition, a
VLSI implementation of the system is proposed which allows
automatic design of universal as well as special purpose expert
systems on a chip.
Introduction.
Expert systems have become a popular method for representing large bodies of
knowledge for a given field of expertise and solving problems by use of this
knowledge. An expert system often consists of three parts, namely: a knowledge
base, an inference engine, and a user interface
A dialogue is conducted by the user interface between the user and the system.
The user provides information about the problem to be solved and the system
then attempts to provide insights derived (or inferred) from the knowledge
base. These insights are provided by the inference engine after examining the
knowledge base. This interaction is illustrated by the picture in figure 1.
Optimal Inference Engine - Griffin and Lewis 2
Inference
User Interface
Engine
User
Knowledge
Base
Knowledge bases consist of some encoding of the domain of expertise for the
system. This can be in the form of semantic nets [Qu68], procedural
representations [WiT75], production rules [DBS77], or frames [BW77]. We shall
consider only production rules for our knowledge base. These rules occur in
sequences and are expressions of the form:
where if the conditions are true then the actions are executed.
When rules are examined by the inference engine, actions are executed if the
information supplied by the user satisfies the conditions in the rules. Two
methods of inference often are used, forward and backward chaining. Forward
chaining is a top-down method which takes facts as they become available and
attempts to draw conclusions (from satisfied conditions in rules) which lead to
actions being executed. Backward chaining is the reverse. It is a bottom-up
procedure which starts with goals (or actions) and queries the user about
information which may satisfy the conditions contained in the rules. It is a
verification process rather than an exploration process. An example of
backward chaining is MYCIN [vMS81], and an example of forward chaining is
Expert [WK81]. A system which uses both is Prospector [DGH79].
System Overview.
Although the major thrust of this paper is the development and presentation of
an optimal inference engine, we will provide a brief overview of EXPRES, which
is a prototype expert system tool developed at the University of Kentucky. It
consists of a parser and a shell (which includes the inference engine)
implemented in the C programming language [Gr87]. .bp Features of the system
include a Pascal-like rule representation language, a parser/code generator,
support of external libraries and subroutines, a menu driven user interface, and
an executable system written in portable C code.
Conditions are expressions involving attributes and the logical connective and.
Several examples are:
Attributes are of course like programming language variables and have types
which must be numerical or string. (A string type variable can possess a value
from a set of strings, for example: {true, false} or {red, yellow, green}.)
An action list consists of one or more of the actions described in the table
below.
Action Description
print("<string>") Output the string
call <subsystem> Transfer to subsystem
return Transfer to calling (sub)system
halt Terminate processing
<attribute> := <expr> Assignment to attribute
This has been a very brief introduction to the EXPRES system and the
formulation of rule-based expert systems which can be designed using the
system. There are more options which will are described elsewhere [Gr87], but
this should be an adequate amount of material for the presentation of the
inference engine in the next section.
Several points about this require consideration. First, some conflict resolution
strategy needs to be employed in order to decide which rules are fired first.
Our method is to fire the rule which the system designer defined first. Also, we
wish to cut down on computational time. To do this we must not do anything
which does not absolutely need to be done. This means that conditions are
only evaluated at the time they might change and that rules are checked (to see
if all of their conditions are satisfied) only when they might be ready to be
fired, not before. We shall do this as attributes are assigned values and shall
only consider rules and conditions affected by the new attribute assignment.
conditions in the rule are currently satisfied. Thus, we only check to see if a
rule is ready to fire when one of its conditions has become true. In turn, a
condition need be evaluated only when all of its attributes have been defined
and one has changed. This is kept track of with a counter assigned to that
condition. In addition, an attribute is flagged as defined or undefined.
Going the other way, we can determine which conditions need be checked and
maybe evaluated with the aid of a condition list assigned to each attribute.
Then, the rules which need checking and possibly firing appear on a rule list
allocated to each condition. And, each rule possesses an action list which
enumerates the actions to be executed when the rule is fired.
Then the various lists are set up and the rules and the relationships between
the attributes, conditions, rules, and actions may be presented as the graph in
figure 2.
X1 X2
C1 C2 C3
R1 R2
A1 A2 A3
This graph is also in some sense an illustration of the inference engine for a
system containing the above two rules since the engine operates by doing a
depth-first search of the graph, beginning at the attribute being changed and
continuing down the graph whenever the counter assigned to a condition or a
rule indicates that all of the information required is present. (Note that this is
very much a finite state machine process. And as such it is related to others
such as Petri nets and pattern matchers [BM77, Fo82].)
Assign(Xi, v)
PRECONDITION: Xi ≠ v and the knowledge base is correct
POSTCONDITION: all appropriate actions have been executed
and the knowledge base has been updated correctly
Xi = value v
for each Cj on the condition list of Xi do
if Xi is undefined then increment the counter for Cj
if all attributes needed for Cj are defined then
evaluate Cj
if the value of Cj changed then
for each Rk on the rule list of Cj do
if Cj became true then
increment the counter for Rk
if all conditions in Rk are true then Fire(Rk)
otherwise decrement the counter for Rk
mark Xi as defined
Correctness will be carefully examined in the next section, but several points
need to be emphasized now. We note that whenever an attribute changes in
value: .(l .(c a) All conditions which might change are checked, and b) All rules
which might fire are examined. .)c .)l This will form the basis for the proof of
correctness. We also note that nothing is examined unless there is a need to
examine it. This is the basis for our optimality proof in the next section.
An essential observation which must be made at this point is that whenever the
Assign(Xi, v) procedure is called, its preconditions are satisfied. This means that
values are assigned to attributes only when they change. This also is central to
the algorithm's correctness.
In this section we shall present theorems which show that the knowledge
representation and inference engine of the EXPRES system possess great
computational power and are correct and optimal. Proofs will be briefly
discussed and appear in the full paper.
This means that we have a universal expert system capability and that every
expert system can be designed with this knowledge representation language. A
possibly negative aspect of this computational power is that unsolvability rears
its head. Expert systems can be designed which contain undetectable infinite
loops - just like computer programs. Thus a designer must take great care
when developing a system.
The entire proof of correctness for the inference engine consists of a very
detailed examination of the above intuitive discussion.
Showing optimal execution time follows from a careful look at exactly what is
checked by the inference engine. The basis of the proof is that no conditions or
rules are checked unless absolutely necessary. The proof proceeds by induction
on the number of attribute assignments processed. And, at the core of this
induction is an advocacy argument which states that after a sequence of
assignments has been made, then any evaluation of conditions or checking of
conditions and rules which is omitted might cause a necessary action not to be
executed.
VLSI Implementation.
C1 C2 C3 C4 A1 A2 A3
The AND plane (on the left) receives inputs on its columns and produces
outputs on its rows which are logical products of its inputs. The logical product
output on a row consists of those input columns which contain a personality or
connection (represented by a dot in our example) on that row. The first three
rows of the above PLA's AND plane correspond to the products:
C1 C2 and C3 C2 and C4
These rows or product lines are shared by the OR plane and form the inputs to
that plane. The outputs of the OR plane occur on the columns and are sums of
the products. The output at A1 is true when:
We now have a direct correspondence between PLA's and expert system rules.
Consider the following relationships:
Our three PLA rows now can be seen to represent the following rules.
IN
Rc Cc RAM
OUT
Sc
P P P P
C s S p Sa
Rp
Cp Ra
First we shall examine the knowledge base. The rules (as we indicated above)
are encoded in the AND and OR planes of the PLA at the center of the chip. The
remainder of the knowledge base that is available from the system description
is stored in three read-only memory (ROM) areas. The print ROM (Rp) contains
all of the messages printed out by actions. The condition ROM (Rc) and
assignment ROM (Ra) hold small assembly language programs which are used to
evaluate conditions and compute new values for attributes if called for by an
action.
X + Y = 23*Z
LOAD X, 1
ADD Y, 1
LOAD 23, 2
MULT Z, 2
EQU 1, 2
All of the design of the ROM's and the PLA can be done by a slightly modified
version of the EXPRES system compiler. Then they can be mask programmed
for large numbers of chips or field programmed for either prototypes or for
situations when small batches are desired. (Field programmable ROM's and
PLA's do require extra space, so this does cut down on the size of the system
which may be realized.)
Condition Evaluation.
1. The user interface sends an attribute value to the I/O controller buffer.
2. This value is recorded in RAM by the IN box that then notifies the condition
controller and waits until this assignment has been fully executed.
3. For every condition containing this attribute, the condition controller
extracts:
a) attribute values (from RAM through the OUT box) needed to evaluate
the condition and
b) a program from the condition ROM (Rc).
4. For each of these conditions, if all of the attributes have been defined, the
condition controller selects a processor (P) and transmits the program and
values to it.
5. After evaluation, the processor returns a Boolean value to the condition
controller.
6. The condition controller conveys this value to the condition selector (Sc).
Rule Selection.
1. Values for the conditions are recorded by the condition selector in flip-flops
(circles) which lead into the AND plane of the PLA.
2. If a rule is satisfied and actions are to be executed, the print selector (Sp) and
the assignment selector (Sa), and the system controller (Cs) are notified by the
OR plane of the PLA.
3. The selectors pass on appropriate information. For actions which are system
calls, the system controller (Cs) sets flip-flops on the AND plane of the PLA
which enable or disable the appropriate systems.
Optimal Inference Engine - Griffin and Lewis 12
(A final note on the PLA. Between the AND and OR planes reside pairs of delay
elements and AND gates on each product line. These ensure that after a rule
has fired, it will not fire again until it becomes resatisfied.)
Action Execution.
1. The print controller (Cp) merely extracts messages from print ROM and sends
them to the user interface.
2. If the assignment selector notifies the assignment processor (Pa) of an
assignment to an attribute, the assignment processor in turn fetches: .in +1
a) attribute values from RAM through the OUT box
b) and a program from assignment ROM (Ra)
and evaluates the assignment statement. Then it sends the new value to the
I/O controller buffer.
3. When all actions have been executed, the IN box is requested to continue
processing.
The processors, selectors, and controllers all can be designed with the aid of
current CAD tools [Ga88, Mu82]. Much of the design of this system appears
elsewhere [IL89] and is of a distinct electrical engineering flavor. So ends this
brief overview of the design and operation of the EXPRESS system as VLSI
circuitry.
Conclusion.
A correct and optimal inference engine for rule based expert systems was
developed and presented. Its correctness is due to to the following facts.
Optimality of execution time is primarily due to the fact that nothing is done
which does not need doing. In particular:
Another reason for the efficiency of the inference engine is that it is a finite
state machine that operates on a graph rather than a tree. As it traverses the
graph, it only explores paths when it is absolutely necessary to do so. The full
Optimal Inference Engine - Griffin and Lewis 13
system also owes much of its speed to the fact that it is totally implemented in
C code.
It was found that production rules for expert systems correspond naturally to
VLSI array logic. This logic is very easy to design and fabricate and this leads to
the possibility of straightforward automatic silicon compilation for rule-based
expert systems. Thus universal or special purpose chips can be inexpensively
designed and used to construct dedicated computing devices using expert
system methodology.
Optimal Inference Engine - Griffin and Lewis 14
References
BW77 Bobrow, D. G. and Winograd, T., "An Overview of KRL a Knowledge
Representation Language," Cognitive Science (1977).
DGH79Duda, R. O., Gaschnig, J. G., and Hart, P. E., "Model Design in the Prospector
Consultant System for Mineral Exploration," in Expert Systems in the
Microelectronic Age, ed. D. Michie, Edinburgh University Press, Edinburgh, 1979.
Fo82 Forgy, C. L., "Rete: A Fast Algorithm for the Many Pattern/Many Object Pattern
Match Problem," Artificial Intelligence 19 (1982).
FM75 Fleisher, H. and Maissel, L. I., "An Introduction to Array Logic ," IBM J. Res. and
Dev. (1975).
Gr87 Griffin, N. "A Fast Architecture for Rule-Based Systems," MS Thesis, University of
Kentucky,, 1987. Also in Proc. 1988 Southeastern Regional ACM Conf.
Mu82 Muroga, S.,VLSI System Design, John Wiley & Sons, New York, 1977.
vMS81 van Melle, W., Shortliffe, E. H., and Buchanan, B. G., "EMYCIN: A Domain-
Independent System that Aids in Constructing Knowledge-Based Consultation
Programs," Machine Intelligence 3 (1981).
WK81 Weiss, S. M. and Kulikowski, C. A., "EXPERT Consultation Systems: The Expert
and Casnet Projects," Machine Intelligence 3 (1981).