BBESS - Bare
Bones Expert System Shell
Overview
Basic
Components
0. Terminology
help
w A set
is a group of
items or elements in which the order does
not matter
w Frequently, a list
is taken to be an ordered set of elements
w Basic Lisp gives us lists
v Therefore, lists are used
to represent both ordered and unordered sets of
elements
v It is up to the user to
distinguish between the two and treat each list according
to whether or not order matters.
1. User
Interface
w Top level loop
v Tell user system is ready
v Receive a query
v Supply answer
w During inference process -
ask user for observable information
v Issue predetermined prompt
X prompts supplied by expert
X prompts catalogued on
system startup
X system recognizes need for
prompt
X system chooses prompt
v Receive answer from user
v Validate user response
2. Knowledge
Base
w Fact Base
v On each cycle fact base
starts out empty
X Note: This is not usually the
case. It is a decision made for
simplicity
v Facts are added to the
system from two sources
X User: Supplies answer to prompt
for observation
X Inference
Engine: Draws
conclusion from rule that fired
w Rule Base
v Supplied by domain expert
v Stored as Lisp lists
v See below for detailed
description
3. Inference
Engine
w Is handed a query by user
interface
w Attempts to answer query
w Returns answer to user
interface, or else signals failure (if rule base is
incomplete)
w A bit more is given below.
Detailed algorithm is found here.
Basic
Concepts
1. Attribute
Value knowledge organization
w Individual objects can be
described in terms of a set of attributes and their values
w Example: car
v Possible attributes: make,
model, year, color
v Possible values:
X make: Ford, Chevrolet, Nissan
X model: Altima, Maxima, Courier
2. Facts
w Facts are attribute-value
pairs (also called AV-pairs), stored as Lisp lists
v Example: car
X (make Ford)
Translation: the make of the car is Ford
X (model Altima)
Translation: the model of the car is
Altima
w Fact base is a set of
facts, stored as a list
v Example: ( (make Nissan)
(model Altima) (color red) )
X Translation: the make of the car is
Nissan and the model of the car is
Altima and the color of the
car is red.
3. Rules
w Basically, rules express an
if-then piece of information
w Rules are in the antecedent-consequent format
v Each rule is comprised of a
set of premises; this forms the
antecedent . .
X Each premise is a single
fact
X So the set of premises is a
set of facts
X Thus the antecedent can be
represented as a list of attribute-value pairs
Example: ( (make BMW) (model 330xi) )
Translation: If the make of the car is BMW and the
model of the car is 330xi
v . . followed by a single conclusion; this forms the consequent
X The conclusion is a single
fact
X Thus the consequent (or
conclusion) can be represented as an
attribute-value pair
Example:
(cost prohibitive)
Translation: Then the cost of the car is prohibitive
w When implementing a set of
rules in Lisp we have several choices; which we
choose depends on perspicuity,
convenience, and - to a certain extent - our own
programming style.
Two Examples:
v An antecedent-consequent
pair
Example: ( ( (make BMW) (model 330xi) ) (cost
prohibitive) )
X The first
of this rule
format is: ( (make BMW) (model 330xi) )
X The second
of this rule
format is: (cost prohibitive)
v A list containing one or
more premises and one conclusion; basically, a list of
pairs.
Example: ( (make BMW) (model 330xi) (cost
prohibitive) )
X The butlast
of this rule
format is: ( (make BMW) (model 330xi) )
X The first
of the last of
this rule format is: (cost prohibitive)
v Both formats have the same
translation
Translation: If the make of the car is BMW and the
model of the car is 330xi,
then the cost of the car is prohibitive
v The translation is usually
expressed in a simpler, stylized format:
Translation: If the make is BMW and the model
is 330xi then the cost is prohibitive
w Implementation
note: It is a
good idea to write a set of retrieval functions. E.g.,
premises-of, conclusion-of, etc.
Advantages:
v Perspicuity - it makes your
code a lot more readable
v Convenience - it allows you
to change the rule format without changing the
internals of your program.
v Information hiding - it
follows accepted software engineering practice
4.
Observables/Prompts
w Most expert systems are
used in conjunction with a person who is not a domain
expert, but who can still carry out
certain fact finding functions
v For our system these will
consist of making observations about the aspect of
the domain under investigation.
v The expert system user
would then be asked to answer questions.
X The questions would involve
the value of an observable attribute.
X Example: What is the color
of the car?
v In a more restrictive
design the questions are phrased in a restricted way,
giving the non-expert a restricted set of values for the attribute in
question.
X Example: Is the color
of the car red
or blue?
X Such a system is easier to
implement
w These questions must be
supplied by the domain expert
v They are known as prompts.
v They always involve
attributes whose value can be obtained by a non-expert.
5. Queries
w A query originates when the
non-expert wants to obtain a non-observable fact
about the domain.
v Since all facts are
attribute-value pairs, the non-expert, in essence, is asking:
What is the value of some
particular attribute?
X For simplicity, the query
will be expressed, with a single word, as the
attribute, with the understanding
that the system is seeking to determine
the value of that attribute.
w In trying to answer the
query given, the system itself may need to know, of some
particular facts, whether or not they
are true.
v To determine this, the
system will itself generate queries.
w Thus, queries can be
generated by the user or by the system itself.
This will be
explained in more detail in The Basic
Inference Algorithm.
6. The
Inference Engine
w The inference engine drives
the entire system.
v It is given a query and
then tries to find an answer to that query by:
X Looking in the fact base
X Prompting the user, if the
attribute is observable
X Trying to find the answer
from the conclusion of a rule
w This is explained in detail
in The Basic Inference Algorithm.
7. The PIES
expert system
w Recall that we are building
an expert system shell
v An expert system shell is a
generic system which can be used in any
knowledge domain for which rules and prompts can be formulated in the
stipulated format.
w Therefore, to test our
program we will have to apply it to a particular domain
v Our domain will be botany,
in particular, the identification of plants in terms
of the botanical taxonomy
v Our completed system will
be known as PIES - Plant
Identification Expert
System
v The plant identification
domain is particularly well suited to backward
chaining expert systems, since plants are classified in a hierarchical
set of
classifications, known as a taxonomy.
X For the knowledge base we
will implement, that set of classifications, from
broader classes to more
restrictive ones, is: type, class, and family.
X These will form
non-observable attributes, with the following possible
values:
type: herb, vine, shrub, tree
class: gymnosperm, angiosperm
family: cypress, pine, bald cypress
X The remaining attributes,
such as leaf shape, are observable and the non-
expert will be prompted for
their values.
v The rules for PIES.
v The prompts for PIES.