RIT Scholar Works
Theses
Thesis/Dissertation Collections
1987
A Comparative study of four major knowledge
representation techniques used in expert systems
with an implementation in Prolog
JoAnn T. Hudgick
Follow this and additional works at:
http://scholarworks.rit.edu/theses
This Thesis is brought to you for free and open access by the Thesis/Dissertation Collections at RIT Scholar Works. It has been accepted for inclusion
in Theses by an authorized administrator of RIT Scholar Works. For more information, please contact
ritscholarworks@rit.edu
.
Recommended Citation
School of Computer Science and Technology
A Comparative Study of Four Major Knowledge Representation Techniques
U sed in Expert Systems with an Implementation in Prolog
by
JoAnn T. Hudgick
A thesis, submitted to
The Faculty of the School of Computer Science and Technology,
in
partial fulfillment of the requirements for the degree of
Master of Science
in
Computer Science
Approved by:
_
John A. Biles
Andrew T. Kitchen
Peter G. Anderson
Knowledge
Representation
Techniques
Used
in
Expert
Systems
withan
Implementation
in
Prolog
I,
JoAnn
T.
Hudgick,
hereby
grant
permission
to
the
Wallace
Memorial
Library
ofRIT
to
reproducemy
thesis
in
whole orin
part.
Any
reproduction will notbe
for
commercial use or
profit.
Knowledge
representationis
a centralissue in
Artifical Intelligence
(AI)
research.In
orderto
solve
the
diverse
andcomplexproblemsencountered,
one needsboth
alarge
amount ofknowledge
andsome mechanism
for
the
management and skillfulutilization ofthat
knowledge.
The
basic
problemin
knowledge
representationis
the
development
of an adequateformalism
to
representthat
knowledge.
In
this thesis
I
willdiscuss four
ofthe
majortechniques
for
representing knowledge in
expertsystems:first
order
logic,
productionrules,
semanticnetworks,
andframes.
Using Prolog
asthe
implementation
language,
I
willdemonstrate
that
all ofthe
above mentioned representationtechniques,
when usedin
actualimplementations,
willbe
reducedto
anequivalency
-that
being
a setofProlog
facts
and rules.Prolog
limits
usto
a setoffacts
expressed as"predicate(argumentl,
argument,
...,argumentn)"
and
"IF
...THEN"
rules,
thus
eliminating many
ofthe
uniquefeatures
which characterizethe
variousrepresentaChapter 1.0 Statement
of
the
Problem
2
Chapter 2. 0
An
Overview
of
Expert
Systems
2.1
What
is
an
Expert
System?
4
Chapter 3.
0
Knowledge
and
its
Representation
3.1
Knowledge
and
Expertise
7
3.2
Organization
of
Knowledge in Expert
Systems
8
3.3
Introduction
to
Representation
10
Chapter
4. 0
Logic
and
Knowledge Representation
4.1
A
Brief
History
of
Logic
15
4.2
The Logic Debate
15
4.3
Logic
and
Reasoning
16
4.4
Knowledge
Representation
Using
Predicate
Logic
20
4.5
An
Overview
of
Prolog
24
4.6
Implementation
27
4.7
Conclusions
29
4.8
Other
Logics
4.8.1
Incomplete
Knowledge
30
4.8.2
Default
Reasoning
30
4.8.3
Fuzzy
Logic
31
Representation
5.1
What is
a
Production
System?
40
5.2
Production Rules
40
5.3
The Data
Base
41
5.4
The Inference Method
42
5.5
Uncertainty
and
Incomplete
Knowledge
44
5.6
Implementation
45
5.7
Conclusions
46
Chapter
6.0
Semantic Networks
and
Knowledge
Representation
6.1
A Brief
Background
48
6.2
The Structrue
of
a
Semantic
Network
48
6.3
The
Knowledge Base
49
6.4
The Inference Method
51
6.5
Uncertainty
and
Incomplete
Knowledge
55
6.6
Demons
55
6.7
Implementation
56
6.8
Conclusions
57
Chapter
7.0
Frames
and
Knowledge
Representation
7.1
The
Structure
of
a
Frame
64
7.2
The
Knowledge Base
66
7.3
The
Inference Method
67
7.4
Exception
Handling
69
7.5
Implementation
69
8.1
Conclusions
73
8.2
Related Future Thesis Topics
74
Appendices
Appendix
A
75
Appendix B
76
Appendix C
82
Appendix D
83
Appendix E
84
Bibliography
86
Figures
2.1.1.
A Typical Expert System
6
3.3.1.
Mapping
Between
Facts
and
Representation.
.1
4
4.3.1.
Statements
for Resolution
Example
35
4.3.2.
Corresponding
Clauses
in
Database
36
4.3.3.
Sequence
of
Resolvents
37
4.4.1.
Simple
Facts in
Propositional Logic
38
4.8.3.
Example
of
Fuzzy
Sets
39
6.2.1.
A
Semantic
Network
59
6.4.1.
Exception
Handling
inNETL
60
6.5.
1
.Dealing
with
Incomplete Knowledge
in
a
Semantic
Net
61
6.5.2.
Dealing
with
Uncertainty
in
a
Semantic
Network
62
6.6.
1
.Example
of
a
Demon in
a
Semantic Network..
63
7.1.1.
Tennis Match
Frame
71
Statement
ofthe
Problem
There
existsmany
different
methodsfor
representing
knowledge
in
expertsystems,
eachoffering
special or unique
features.
Certain
methods supportthe
representation ofspecifictypes
ofknowledge.
Various languages have
been
developed
to
implement
these
representationtechniques.
Is
it
possibleto
useone
language
to
implement
variousknowledge
representationtechniques?
If so, how
wouldthe
useofa
language
suchasProlog
impact
the
practical use ofdifferent
representation systems?In
this thesis
I
willexaminefour
ofthe
majorknowledge
representation methods:first
orderlogic,
production
rules,
semantic networks andframes
and attemptto
write expert systemsin
Prolog
using
these
four
methods.The
structure ofProlog's
facts,
predicate(argumentl,...,argumentn)
andIF...THEN
rules,
establishes constraints onthe
knowledge
representationformalism.
The
attemptedimplementa
tions
ofthese
four
techniques
areallreducedto the
samething:
a setofProlog
facts
andrules.Thus,
Prolog
itself,
canbe
viewed notonly
as animplementation
language,
but
as aknowledge
representationtechnique.
Even
though
each ofthe
representationtechniques, in theory,
representsknowledge in
aspecific
way, the
implementation
language
candictate
whichtechnique
is feasible.
In
chapter2
we willlook
at an overview of expertsystems,
discussing
some ofthe
basic
design
issues
andhow
they
differ
from
conventional computer programs.Chapter 3 is
anintroduction
to
knowledge
representationin
expert systems.We
willdiscuss
the
organization ofknowledge,
the types
of
knowledge
(declarative,
procedural andcontrol)
and examine some ofthe
major concernsin
the
selection ofa
knowledge
representationtechnique.
In
chapter4
we willfocus
onlogic
andknowledge
representation.
Here
variouslogics
are examined:propositional,
predicatecalculus,
first-order
predicatelogic,
fuzzy
logic,
default reasoning
andcertainty
factors.
We
willtalk
aboutProlog
as animplementa
tion
language
andas aknowledge
representationtechnique.
Next
wewilllook
at anexpertsystembuilt
in
Prolog
using
first-order logic. Chapter 5 describes
the
componentsofa production system.In
chaptermechanisms, the
knowledge
base,
expressive powerandimplementation in Prolog.
When
Prolog
is
usedas
the
implementation
language,
we are confinedby
its
structure andtherefore
loose many
ofthe
features
otherwise available whenusing
the
various schemes.Appendix A
describes
the
knowledge
domain
usedfor
the
expert system.Appendix
B
containsthe
Prolog
implementations
and appendicesC,
D
andE
illustrate how
the
knowledge base
of appendixA
might appearusing
languages
suitedfor
Chapter
2.
An
Overview
ofExpert Systems
2.1
What is
anExpert System?
Definitions
of expert systems abound.The
underlying
theme
is
that
they
areinformation
systemsthat
achieve expertisein
a particularfield.
We
coulddebate extensively
the
issue
of"expertise in
afield",
but for simplicity let
ussay
that
if
a systemdoes
achieveexpertise,
it
emulatesthe
behavior
ofthe
human
expertin
that
field.
Hayes-Roth
andWaterman
present agooddefinition:
"An
expert system
is
a computer programthat
embodiesthe
expertise of one or more expertsin
somedomain
andapplies
this
knowledge
to
make usefulinferences."[HAY
83].
Expert
systemscan givethe
illusion
of expertisebased
on superficialknowledge,
whilethey
lack
the
insights
that
human
experts acquire over along
period oftime.
It
is
unlikely
that
expert systemswill ever
be
ableto
mimicthe
human
qualities ofintuition
and common sense.Nonetheless,
expertsystem
designers
areattempting
to
modelasclosely
as possiblehuman
thought
processes.Expert
systems mustbe
ableto
solvecomplex problems atan expertlevel.
They
mustbe
ableto
incorporate
newknowledge
easily,
be easily
understandableby
both
experts and non-expertsin
the
particular
field,
and shouldbe
ableto
justify
their
solutions.They
are a classofcomputer programsthat
can
"advise,
analyze,
categorize, communicate, consult,
design, diagnose,
explain,
explore,
forecast,
form
concepts,
identify, interpret, justify,
manage, monitor, plan, present, retrieve,
schedule,
leam,
test,
and
tutor"
[MIC
85].
Expert
systems arefinding
widespread application as adviserson subjectsranging
from
medicineto
finance.
As
embeddedsystems,
they
also serve asthe
"brains" ofrobots,
automaticweapons,
andphotocopiers.An
expert systemderives its
problem-solving
powerprimarily
from
the
quality
andcompleteness
of
its knowledge base.
Facts,
rules ofthumb
(heuristics),
models,
and other generalknowledge
aboutknowledge
and generalproblem-solving
proceduresto
find
andapply
a specific solution.A
typical
expert system consists of aninference
engine,
aknowledge
base,
and aworkspace(see
figure 2.1.1).
The
inference
engine solves a problemby interpreting
the
domain knowledge
containedin
the
knowledge base
which containsfacts
and rules.Facts
are short-terminformation
that
canchange,
for
example,
during
the
courseofa consultation.Rules
arelonger-term
information
abouthow
to
generate new
facts
orhypotheses from
whatis
presently known.
"Marie is
apatient"
is
an example ofafact,
and"If
the
patienthas
arunny
nosethen
prescribeanantihistamine"
is
an example ofa rule.The
workspace
is
an area ofmemory
set asidefor storing
adescription
ofthe
problem constructedby
the
system
from facts
suppliedby
the user,
orinferred
from
the
knowledge base
during
a consultation.A
system
may
alsoinclude
a naturallanguage interface for
communicating
withauser,
areasoning
explanation subsystem
to
justify
the
sequence ofinferences,
and aknowledge
acquisition subsystemfor
expanding
the
knowledge
base.
In
contrastto
conventionaldatabase
systems,
expert systems require aknowledge base
withdiverse
kinds
ofknowledge:
knowledge
aboutobjects,
knowledge
aboutprocesses,
andhard-to-represent
commonsense
knowledge
aboutgoals, motivation,
time,
actions,
etc.This
thesis
addresses some ofthe
important issues
raisedin
attemptsto
representthis
breadth
ofknowledge:
(1)
How
do
we structurethe
explicitknowledge
in
aknowledge base?
(2)
How
do
we encode rulesfor manipulating
aknowledge base's
explicitknowledge
to
infer
knowledge
containedimplicitly
withinthe
knowledge
base?
+-00
CO
t-l
<D
CX
X
W
o
-*
ex,
<
3
P-,
-o
s
H
H
<
to
<!
co
J
9
w
W
w
5!
<
<
a
fe
$
s
Chapter 3.
Knowledge
andits Representation
3.1
Knowledge
andExpertise
Knowledge
canbe
viewed asconsisting
ofboth facts
andheuristics.
The
facts
constitute abody
of
information generally
agreed uponby
expertsin
afield.
The heuristics
are rules ofgoodjudgement
(rules
ofplausiblereasoning,
rulesofgoodguessing)
that
characterizeexpert-leveldecision
making.In
orderfor
the
expert systemto
reflectan expert'sknowledge
andability,
it may have
to
reflectthe
expert'smemory
andinformation
processing,
problemdefinition,
heuristics
andskills.(1)
Memory
andInformation
Processing:
Research
has
shownthat
expertsdo
nothave
alarger
memory capacity
than
novices.However, they
arebetter
atusing
their
memory capacity
then
novices.
First,
experience allows expertsto
combine or"chunk"
small
bits
ofinformation into
larger,
meaningful unitsofknowledge.
These
chunks are easierto
recallfrom
memory.Chunk
ing
allows physiciansto
storeand recall complicatedprocedures.Second,
experienced expertsarecapable of
"automatically"
linking
familiar inputs
with appropriateresponses storedin
memory.An
experienced physicianquickly
recognizes configurations or patterns ofviruses.These
inputs
are
automatically linked
to
a set of possible actions.Because
these
responses are automaticthey
savevaluable
time
whichwouldbe
wastedif deliberation
were necessary.(2)
Problem Definition:
Experts
excel at "decomposing" problemsthat
appearill-defined
to the
restof us.
As
anexample, the
difficult
problem ofbuilding
ahouse is easily broken down
by
anexpert architect
into
smaller,
more structured problems.First,
possible constraints mightbe
identified
(i.e.,
sizelimitations,
design,
financial limitations).
Then
the
architectconsiders
that the
house
musthave
afloor,
a roof and a structure.The
structure consists ofaframe,
plumbing,
electrical
fixtures,
etc.In
this way, the
problembecomes
manageable and choices are narrowedto
abil-ity
that
mustbe
capturedin
the
expert system.(3)
Heuristics:
Experts
are ableto
articulate rulesofthumb
for solving
certain classes of problems.These heuristics
are often expressedin
anif...then
format.
They
mustbe
identified
andincor
porated
into
the
expert system.As
an example:"if
the
patienthas
ahead
injury,
checkfor
aconcussion".
(4)
Skill:
Skill
canbe
thought
ofas ablending
ofthought
and actionin
orderto
efficiently
meet aparticular objective.
This
meansthat
a skill requires specializedknowledge
combined with amotor response.
Performing
anappendectomy is
a skillbecause it
combinesknowledge
ofthe
human anatomy
withthe
physical actionsto
performthe
operation.Experts
aresopracticedthat
much of what
they
do
is
automatic.Because
a well-developed
skillis
automatic
it
becomes
difficult for
the
expertto
describe it
in
detail.
Still,
domain
experts andknowledge
engineersmust articulate
the
components of a skillif
it is
to
be
performedby
an expert system.3.2
Organization
ofKnowledge
in
Expert
Systems
Ordinary
computerprograms organizeknowledge into
two categories,
data
and program.In
orderfor
an expert systemto
"perform
the
task
of anexpert"
it
needs alarge
amount ofknowledge. There
fore,
these
systems needto
be
organizedto
avoidconfusion.Generally,
knowledge
is divided into
three
categories:
declarative,
procedural,
and control.Declarative knowledge
(factual)
represents aparticular situation andis
usually
acquiredthrough
adialogue
withthe
domain
expert.It
caninclude facts
aboutobjects,
aboutevents,
and abouthow
they
relate
to
each other."Declarative knowledge
canbe
retrieved and storedbut
cannotbe
immediately
executed.
To be
effective,
it
mustbe interpreted
by
procedural knowledge."[BRO 85]. The
way
in
whichsuch
information
is
representedis
significant,
asthe
structure ofthe
representationcontains
information
itself.
(This
willbe discussed
in
subsequentchapters.)
knowledge
asdata but may
notbe
examined."[BRO 85]. This forms
the
reasoning
part ofthe
systemin
order
to
infer
conclusions.Knowledge
ofhow
to
do things, heuristic knowledge
to
find
short-cut solutions,
and non-factual(probablistic
anddefault)
knowledge
are proceduralin
nature.Both
declarative
and proceduralknowledge
arenecessary in
mostknowledge
domains;
therefore,
most systems
employ
a combinationofboth.
The basic idea is
to
usethese
facts
and rulesto
create amodel
that
accurately
representssomething
aswell asthe
actionsthat
canbe
performedby
it
and onit
Then
by
testing
actions onthe
model,
one can predictwhatis
likely
to
happen in
the
real world.Control knowledge is
acomputer programthat
"is
usedto
direct
the
sequencein
whichproblem-solving
steps are carried out"[BRO
85].
A
number of control strategies canbe
used,
all withthe
sameunderlying objective,
to
achievethe
goalby
applying
an appropriate sequence of operatorsto
aninitial
situation.
Briefly,
we will examinethe three
mostcommon strategies.(1)
In
forward (data
driven)
chaining
the
system attemptsto
reasonforward
from
facts
to
a solution.The
sequence ofbehavior may
be illustrated
by
the
following:
Ask
a question ortake
whatthe
user
provides;
makeinferences from
that
data;
ask anotherquestion,
and so on until anhypothesis
(the
goalstate)
has
been
reached.(2)
Backward (goal
driven)
chaining is
a methodin
whichthe
system starts with anhypothesis (the
goal
state)
then
worksbackwards
to
find
the
evidencesupporting
the
solution.This
often entailsformulating
andtesting
intermediate hypotheses (subgoals).
(3)
The
rule value approach or sidewayschaining
assigns a valueto
eachitem
ofevidence and asksthat
question withthe
highest
valuefirst.
As
questions are answeredtheir
rule values aremodified.
The
system calculates a rulevalue,
usually applying
someprobability
function,
for
each
item
of evidencein
the
knowledge
base.
The
specificimplementation
of a controlstrategy
depends
uponthe
representation ofthe
knowledge
it
manipulates and onthe
purpose ofthe
reasoning.Generally,
forward chaining is
usedto
verify
ordeny
a conclusion.Data-driven
reasoning
will neverterminate
if
the
initial
evidencedoes
notlead
to
a conclusion.For
this reason,
most expert systems areprimarily
goal-driven.Some
systemscombine goal- and
data-driven inferencing.
First,
data-driven
inferencing
is
usedto
suggest a set ofhypotheses based
oninitial data.
The
systemthen
begins
to
consider eachhypothesis
in
turn.When
ever a new
item
ofevidenceis discovered
during
backward
inferencing,
the
system switchesto
forward
inferencing
to
seeif
the
new evidence would suggest another goal or a short-cutto
achieving
the
currentgoal
[KIN 84].
In
an expertsystem,
the
knowledge
about a problem(declarative
orprocedural)
is
segregatedfrom
the
controlknowledge
andis
representedin
modular chunks.This
makesknowledge
based
systems
relatively easy
to
modify.In
the
succeeding
chapters we will examine methods ofrepresenting
declarative
and proceduralknowledge
in
expert systems andlook
at animplementation
in Prolog.
3.3
Introduction to Representation
There
aremany
waysin
whichknowledege
canbe
representedin
expert systems.The four
mostwidely
used are:(1)
first-order
predicatelogic
(2)
production rules(3)
semantic networks(4)
frames
or schemataWhen
building
an expert systemit is important
that
a representationformalism be
chosenthat
is
both "usable
by
the
system and comprehensibleto
human
beings"[MIC
82].
There is
noprescribed
method
for
accomplishing this; therefore,
it is
asource ofcontroversy among knowledge
engineers.
Facts
aretruths
in
somedomains.
These
arethe things
we wantto
represent.Representations
ofthe
facts
arethe
things
wewillactually
manipulate.In
orderto
getinformation into
andout ofthe
systemthere
mustbe
some sort ofmapping (func
tion
orrelation)
from facts
to
representations andfrom
representationsto
facts.
A
naturallanguage
interface may be necessary
to
facilitate
this transfer
ofinformation,
but in
this
casewe will alsoneed amapping from
the
naturallanguage
sentenceto the representation,
andfrom
the
representationback
to
the
sentence(see figure
3.3.1)
[RIC 83].
For example,
the
fact
Washington
was aU.S.
presidentcan
be
represented asUSpresident(Washington).
The
fact
AH
U.S.
presidentsmustbe
nativeborn
citizenscan
be
representedasUSpresident(x)
->native-born(x).Using
deductive reasoning
the
representationofanewfact
native-born(Washington)
is
generated.From
this
fact,
using
the
appropriatemapping
function,
we could generatethe
sentence(fact)
Washington
wasa nativeborn
citizen.representation scheme.
This
willbe discussed in
depth
in
chapter4.
An
important
questionthat
needsto
be
answered,
regardless ofthe
representationformalism
wechoose,
is "At
whatlevel
ofdetail
shouldthe
knowledge be
represented?".In
otherwords,
"What
should
be
the
primitives?".Should
we useasmall number oflow-level
primitives ormany
that
coverarangeof
levels?
[DAV 82].
For
example,
supposewe wereto
look
atthe
following
fact
Infotech
employsSusan.
This
couldbe
represented asemploy(Infotech,Susan)
and
the
question"Does
Infotech employ
Susan?"could
easily be
answered.But,
the
question"Does
Susan
work at Infotech?" could notbe
answereddirectly
from
this
onefact.
We
would needto
addanother
fact
to the
knowledge
base,
empIoy(x,y)
->work-at(y,x)
to
infer
the
answer.Here
wehave
addedmoreprimitivesto
cover a wider range oflevels.
On
the
otherhand,
if
we representedthe
samefact
in
terms
ofasmallsetofprimitivessuchas,
pays(agent(Infotech),
object(Susan),
to-perform(work))
we
have
broken
the
term
"employ"
down
into
more primitive concepts of "pays" and"to-perform(work)".
With
this
representation we are notdirectly
ableto
answer either ofthe
questions.But,
"Who
paysSusan
to
performwork?"
could
be
answereddirectly.
The
major advantage of representationin
terms
ofa small set of primitivesis
that the
rules ofinference
needbe
writtenonly in
terms
ofthe
primitives ratherthan
in
terms
ofthe
many
waysthe
The
majordrawbacks
arethat
a greatdeal
of workis
requiredto
convert eachfact into its
low-level
primitives.This
leads
to
another problem.In
certaindomains it
may
notbe
clear whatthe
primitives
shouldbe
orthere
may
notbe
enoughinformation in
the
high-level forms
to
convertthem
to their
primitive
forms.
A
greatdeal
ofgenerality
and potentialdesign optimality
arelost
when restrictedto
low-level descriptions.
It
appearsthat the
lower
the
level
wechoose,
the
less inference
is
required,
but
the
moreinference is
requiredto
createthe
representationfrom
naturallanguage.
What,
then, is
the
correctlevel
of representation?This
is
to
alarge
extentdependent
uponthe
domain itself
andto
what usethe
knowledge is
to
be
putIn general,
knowledge
in
anaturallanguage
understanding
systemis
represented as a small setoflow level primitives,
whereasin
mostexpert systems
knowledge is
representedby
alarger
set ofprimitivescovering
arange of values.Whatever level
wechoose
it is
essentialthat
webear
in
mindthat the
powerof anexpertsystemis
primarily
afunction
of
the
quality
and completenessofits knowledge base.
In
orderto
convey
the
intended meaning
of apiece of
knowledge
it is important
that
werepresentit
appropriately.Thus,
to
convertnaturallanguage
sentences
into
some othertype
ofrepresentation,
wemustfirst decide
whatfacts
the
sentences representthen
convertthose
facts into
the
chosenrepresentation.If
an expert systemis
to
emulatehuman
intelligence,
it
mustcontain a greatdeal
ofdeclarative
andprocedural
knowledge.
A
key
questionthroughout the
history
ofAI
has
been
how
to
best
representthis
knowledge.
At
presentthere
is
no "best"technique.
"There is
notheory
ofknowledge
representation.
We don't know
why
somes schemes are goodfor
certaintasks
and others are not.But
eachscheme
has
been successfully
usedin
avariety
ofsystemsthat
do
exhibitintelligent
behavior."[BAR
CO
<
"0>
2:
O
<
<
H
PL,
g
<
G
co
ex
a
c
o
HJ C3 H
c
<u -(
Oh
<DP<
C
o
P-,
c
PQ
'ex,
Oh
CO
co
0) )-,
Chapter
4.
Logic
andKnowledge Representation
4.1
A Brief
History
ofLogic
Deductive reasoning first
appearedin
ancientGreece
about600 BC. Thales
ofMiletus
appearsto
have been
the
first
to
attempt aproofusing
some sortofdeductive
reasoning.For
along
time the
study
oflogic
was madedifficult because logicians had
to
use wordsin
their
analysis of
the
reasoning
process,
andthe
meaning
ofthe
wordsis
often vague andimprecise.
The
English
mathematicianGeorge Boole
(1815-1864)
wasthe
first
to
attemptto
expressthe
operations oflogical reasoning in
the
language
of a calculus.He
showedthat
any
class ofobjects,
for
example,
"analgesics"
or
"all
purplethings",
canbe
representedby
a symbol such as"x".
He
then showedthat
such symbols can
be
combinedby
the
samerules asthose that
governthe
operations of algebra.Logic
has
provedto
be relatively
straightforwardto
implement
on acomputer whichis,
afterall,
based
ontheories
of mathematicallogic.
In
this
chapter we will examinelogic
as a methodfor
representing
andreasoning
withknowledge in
expert systems.4.2
The
Logic Debate
The
usefullness oflogic (first-order
logic)
in
aknowledge
representation contextbecame
evidentduring
the
1960's primarily
as a result of researchinto
mechanical theorem-proving.Much
researchwas
directed
atinvestigating
the
use ofthe
resolution principle as aninferencing
technique
in
variousapplications
(i.e.,
question-answering).Other
researchtended toward
viewing
logical formalisms in
amore
computationally
orientedframework
(i.e.,
Planner
[ROS
79]
andStrips
[FIK
71]
).
This has led
major
opposing
viewpointsare expressedbelow.
John
McCarthy
[Stanford
University]
believes
that the
way
to
solvethe
knowledge
representation problemis
to
design
computer programsto
reasonaccording
to the
well-worked-outlanguages
ofmathematicallogic,
whether or notthat
is actually
the
way
peoplethink.
"Whether logical reasoning is really
the
way
the
brain
worksis beside
the
point.This is
Artifical
Intelligence
and so wedon't
careif it's psychologically
real."[KOL 82].
Marvin
Minsky
[MIT]
believes
that
a good approachis
to
try
to
get computersto
imitate
the
way
the
human
mindworks,
which,
he
thinks,
is
almostcertainly
notwith mathematicallogic.
"Logical reasoning
is
more appropriate
for
displaying
orconfirming
results ofthinking
than
for
thinking
itself.
That
is,
I
suspect we useit
less for
solving
problemsthan
we useit for
explaining
the
solutionsto
other people and much moreimportant
-to
ourselves."
[MIN
82].
4.3
Logic
andReasoning
Logic
is
the
study
of valid reasoning.In logic
we areinterested in
the
truth value of a givenstatement; that
is,
whethera sentenceis
consistent within agiventheory.
There
aretwo
important
components
in
alogical
system axioms anddeductive
reasoning.Axioms
arethe
statements acceptedwithout
proof;
they
are statements aboutthe
relationshipsbetween
objects andimplications
aboutthe
objects,
for
example,
(1)
Birds have
feathers
(2)
An
eagleis
abird
Deductive
(formal)
reasoning
is
the
process ofarriving
at a conclusionby
determining
what canbe
inferred from
certain axioms.From
the
abovetwo
axioms we can concludethe
fact
(3)
An
eaglehas
feathers
This
deduction
is
permittedbased
onthe
syntax ofthe two
axioms andthe
idea
that the
newfacts
true.
We
can provethat the
statement"An
eaglehas
feathers"is
true
by
chaining backward
from
the
fact
to the
axioms.For example,
to
provethe
statementAn
eaglehas
feathers
is true,
we movebackwards from
this
statementto the
statement establishedearlierAn
eagleis
abird
thus, concluding
by
the
law
oftransitivity,
the
statementA bird
has feathers
is
true.
Let's
rewritethese two
statementsto
showhow
the
deduction
process works:All
birds
have
feathers
bird
(X)
->feathers
(X)
An
eagleis
abird
bird
(eagle).
This deduction
requiresthe
substition of "eagle"for
the
variableX.
The
substitutionis found
by
arecursive pattern
matching
algorithm called unification which comparestwo
literals
anddiscovers
whether
there
exists a set of substitutionsthat
makesthem
identical.
The
basic idea in
an attemptto
unify
two
literals
is
to
checkif
their
first
elementsmatch.If
so,
continue withthe
second,
and soon,
calling
the
procedure recursively.Only
identical
predicates,
constants,
orfunctions
canmatch.A
variable can match another
variable,
any
constant,
or afunction
or predicate expression withthe
restrictionthat the
function
or predicate expression must not containany
instances
ofthe
variablebeing
matched.It is necessary
that
a consistantsubstitutionis
madefor
the
entireliteral [HUN
75]. For
example,
if
wewant
to
unify
the
expressionsthe
first
elements(flies)
match.Next
we compareA
andB
anddecide
to
substituteB
for
A,
denoted
B/A. (We
couldjust
aseasily have
substitutedA for
B.)
Now
the
second elements will match.Con
tinuing,
the
last
pairdoes
notmatch,
so another substitution mustbe
made.We
mustbe
consistentin
our substitution
-wecannot substitute
B
for
A
in
one pair andC for
A
in
another.Therefore,
weneedto
substituteB
for
A
in
the
remaining literals.
Now
we canunify
these
literals
by
substituting C for B.
The
unification procedure returns alist containing
the
substitutionsthat
were performed.Thus,
(
B/A,
C/B
)
is
returned.One
ofthe
most straightforward rules ofinference
usedin
proof proceduresis
Modus Ponens
whichsays
that
if
there
is
an axiom ofthe
form
XI
->X2
andthere
is
another ofthe
form
XI,
then
X2
logically
follows.
In
our exampleabove, if
we assumethat
both
(1)
and(2)
aretrue,
then
Modus
Ponens
tells
usthat
(3)
alsomustbe
true.
The
mathematicianJ.A.
Robinson
proposed another method of problemsolving
based
onaprinciplecalled
"resolution".
Resolution
is
a method ofinference
that says,
if
there
is
anaxiom ofthe
form
(XI
OR
X2)
and another axiom ofthe
form (NOT X2 OR
X3),
then
(XI OR
X3) logically
follows.
The
expression(XI
OR
X3)
is
calledthe
"resolvent" of(XI OR
X2)
and(NOT X2
OR
X3)
[WIN
84].
The
resolutionprincipleis
refutationcomplete,
which allowsit
to
be
usedin generating
proofsby
refutation.
In
otherwords, to
proveastatement,
resolution attemptsto
showthat
the
negation ofthe
statement produces acontradiction with
the
known
statements.Basically,
this
is
done
by
converting
allstatements
to
a standard clauseform.
Then,
taking
two
clauses(parent clauses)
that
each containthe
same
literal (in
positiveform in
one clause andin
negativeform
in
the other), the
resolventis
obtainedby
combining
all ofthe
literals
ofthe two
parent clauses exceptthe
ones that cancel.If
the
clausethat
is
producedis
the
empty
clause, then
a contradictionhas
been found.
In
otherwords, the
resolutionprocess
takes
a set of clauses all of which are assumedto
be
true
and generates new clausesthat
represent restrictions on
the
way
eachofthese
original clauses canbe
madetrue, based
oninformation
by
the
original clauses.A
contradiction occurs when a clausebecomes
so restrictedthat there
is
noway it
canbe
true.
This is
indicated
by
the
generation ofthe
empty
clause.We have
reasonedback
to the
final
contradiction.Resolution
has
provedto
be both
valid andcomplete.
In
otherwords, the
resolutionprocess continues
until either a contradictionis
found,
no progress canbe
made,
or apredetermined
amount oftime
has
elapsed.This
procedure,
then, is
not guaranteedto
halt if
given anontheorem(a
nonprovable statement)
to
prove.It is
guaranteedto
halt
andfind
a contradictionif
one exists.Let
uslook
at a simple example[HUN 75].
Suppose
we are giventhe
axioms shownin figure
4.3.1
andwe wantto
provethat
"John is
not sick".First
weconvertthe
axioms andthe
statementto
be
proved
to
clauseform
as shownin figure 4.3.2. We
then
negate"John
is
notsick",
producing
"John
is
sick".
Next
webegin selecting
pairsofclausesto
resolve.We
startby
resolving
withthe
clause"John
is
sick"since
that
is
one ofthe
clausesthat
mustbe invalid in
the
contradiction we aretrying
to
find.
Figure 4.3.3 illustrates
the
sequence ofresolventsthat
mightbe
generated.This leads
to
a contradiction,
and since allthe
axiomsin
ourlist
were assumedto
be
true,
it
cannotbe
true
that
NOTin(john,office)
andin(john,office)
areboth
true.
Therefore,
the
assumptionthat
led
to this
contradiction,
sick(john),
mustbe
false,
hence
NOTsick(john)
mustbe
true.
"Modus
Ponens
canbe
viewed as a special case of resolutionbecause anything
concluded withModus Ponens
canbe
concluded with resolution as well"[WIN 84].
For example, according
to
Modus
Ponens,
if
XI
and(XI
->X2)
aretrue,
then
X2
mustbe
true.
Since
(XI
->X2)
canbe
written as(NOT
XI
OR
X2),
resolution canbe
applied.We
seethat
XI
andNOT XI cancel,
thus
producing X2.
This
is
the
same resultobtainedusing
Modus Ponens.
Similarily,
resolutionis
also a generalization of another rule ofinference
calledModus Tolens.
According
to
Modus
Tolens,
if
there
aretwo
axioms,
(XI
->X2)
and(NOT
X2),
then(NOT
XI)
logi
cally
follows.
Resolution
has
been
shownto
be
quite successful as a theorem prover given asmall setofsimpleproblems.
However,
asthe
number of statementsin
the
domain
increases,
this methodbecomes
increasingly
slowdue
to the
combinatorial explosion of choicesin
resolvents.Strategies do
existfor
4.4
Knowledge
Representation
Using
Predicate Logic
There
areseveral speciesoflogic. Two
ofthe
mostcommonly
usedarepropositional calculus andpredicate calculus.
In
propositional calculus simplefacts
are represented aslogical
propositions writtenas simple constants.
Propositions
are statementsthat
areeithertrue
orfalse.
The
propositions canbe
linked
together
with connectives suchas,
AND, OR, NOT, IMPLIES,
andEQUIVALENT.
Figure 4.4.1
illustrates
some simplefacts
representedin
propositionallogic.
From
fact 5
we caneasily
deduce
(infer)
using
modus ponensthat tomorrow
is
Tuesday
if
today is
Monday,
(i.e.,
if
xis
true
and(x
implies
y)
is true,
then
y
is
true).
Although
it is
simple andstraightforward,
propositional calculushas
seriouslimitations.
If
wewant
to
representthe
facts
that
Watson
is
a new studentand
Holmes
is
a new studentwe could write
watsonnewstudent
holmesnewstudent
but
would notbe
ableto
makeany
inferences
aboutthe
relationship between Watson
andHolmes.
We
areeven
in
more ofadilemma
when wetry
to
representthe
fact,
All freshmen
are newstudents,
because
we wouldhave
to
write separate statementsfor
each newstudent.We
can concludethat
as a representationalformalism
in
expertsystems,
propositionallogic
is
rela-tionships
overclassesofobjects.A
solutionto this
problemis
to
usepredicate calculus.Predicate
calculusis
an extension ofpro-positional
logic in
whichfacts
are represented as statements written as wellformed formulas (wffs).
The
five
connectivesfrom
propositionallogic
are retainedbut
the
focus is
changed.We
nolonger look
at statements
merely for
their truth
value.In
predicate calculusweareinterested in representing
statements aboutspecificobjects and relations
among
those
objects.Statements
about objects are called predicates.Predicates
can address one or moreobjects,
that
is,
have
one or more arguments.For
example,
(1)
new-student(watson)
asserts
that
Watson
is
anewstudent,
andthis
assertionis
eithertrue
orfalse.
The
statement(2)
son-of(watson,doctor)
asserts
that
Watson
is
the
son of adoctor.
We
can expressany
one-argument expression as atwo-argumentexpression.
Thus,
new-student(watson)
canbe
written(3)
is-a(watson,
new-student).Quite
often we needto
usetwo types
of statements called quantifiersto
make statements aboutsets of objects.
The
universal andthe
existentialquantifiers providethe
mechanismto
express relationships
between
agroup
ofobjects and makeinferences
from
these
relationships.Following
is
abrief
explanationof
these
quantifiers.A
variableis
a symbol usedto
represent an objectAn
open sentenceis
a sentencethat
containsone or more
variables,
for
example x +2y
=7x.
Two
statements canbe
made about an opensentence,
p(x),
having
variablex:(5)
there
exists an xsuchthat p(x)
is
true
(existential
quantification).Statement
(4)
is
symbolized
asand
is
taken
astrue
if
andonly if for every
meaningful valuefor
x,
p(x)
is
true.
Statement
(5)
is
symbolized
as3
x, p(x),
and
is
true
if
andonly
if
there
is
atleast
one value of xthat
makesthe
statementtrue.
As
anexample,
the
sentence"All freshmen
are newstudents"
can
be
expressed asVx,
freshman(X)
->new-student(X)
and
is interpreted
as"For
allX,
if X is
afreshman,
thenX
is
a new student".The
statement"Some
freshmen
eatcustard"
can
be
expressedas3
X, freshman(X)
*eat-custard(X)
and
is
interpreted
as"There
existsatleast
oneX,
suchthat
X
is
afreshman
andX
eats custard".The
statementV
X,p(X)
can
simply be
writtenp(X), thus
eliminating
the
"for
all"quantifier.
This
allows amovefrom
ageneralstatement
to
a specific statement.For
example,
from
the
statementY
X,
freshman(X)
->new-student(X)
we can
infer
Many
situations requiremorethan
just
aTRUE
orFALSE
answer.There
arealsotimes
when weneed a
large
number ofsimple,
similarfacts
suchasless-than(l,2)
greater-than(2,l)
less-than(2,3)
greater-than(3,2)
and we
do
not wantto
have
to
write each ofthese
individually.
Augmenting
predicate calculus withcomputable predicates or
functions is
abranch
oflogic
known
as"first-order
logic"(FOL)
or"first-order predicate logic"
(FOPL).
The
two
desirable
situations mentioned above(returning
a value otherthan true
orfalse
andeliminating
the
needto
representsimilarfacts
individually)
caneasily
be
achievedusing
FOL.
For example,
to
evaluatethe
statementless-than(2
*3,4),
the
value ofthe
multiply
(*)
function is first
computedthen the
value ofthe
less-than
predicateis
computed
using
the
resultsfrom
the
multiply.Using
variables,
we wouldeliminatethe
needto
storeallthe
required statements:
less-than(X
*Y,Z).
The
result ofthis
evaluationis
TRUE
orFALSE.
Looking
at another example(from
statement(2)),
the
statement
son-of(watson,X)
would return
"doctor",
i.e. X
wouldbe instantiated
to
(replaced
by)
"doctor",
whenthe
son-offunction
is
evaluated.From
statements(1)
and(2)
we can seethat that
oneway
to
representdeclarative knowledge is
by
meansofformulas in
first-order
logic.
Procedural
knowledge
canalsobe
representedin
FOL,
if
the
formulas
aresuitably
interpreted.
For
example, the
formula
can
be
thought
of eitheras alogical
statement
that
A
is
true
wheneverB]
,B2 , . . . ,Bnare
true,
oras aprocedurefor producing
a statesatisfying
conditionA.
In
otherwords,
if
you wantA
then
do
B[
then
B2
,. . . ,Bn.In
the
nextsection we will examine aprogramming
language
that
allows usto
representknowledge
in
terms
oflogic.
4.5
An
Overview
ofProlog
The
idea
that
logic
could serve as a general purposeprogramming
language
was madeareality in
1972
by
A.
Colmerauer
andP. Roussel in
the
form
ofProlog
[COL
83]. The
introduction
ofProlog
has
made
it
possibleto
representknowledge
in
terms
oflogic
andto
draw inferences
automatically
PROLOG
standsfor
PROgramming
in
LOGic
andthe
inference
mechanismis built into
the
language.
Prolog
was atfirst
atheorem proverbased
onthe
resolution principle.It
has
undergonemuch reformulation,
andtoday
seemslike
an appropriatetool to
usein
anexpert systememploying
aFOL
representation.
Both FOL
andProlog
use resolution asthe
basis for inference.
The
control mechanism providedby
Prolog
is
depth-first
search withbacktracking.
The
order ofthe
appearance ofthe
facts
and rulesin
the
data
base
also guidesthis
control process.The
essenceof adepth-first
searchis
to
select an alternative
at some point then moveforward
untilthe
goalis
reached orit is
nolonger
possibleto
movefor
ward.
When further forward
motionis
not possiblethe
searchis backed
up
to
resume atthe
nearestpoint