Chapter - 4
Chapter - 4
people think when they are trying to make decesions and solve
way C S J :
51
h um ans ,because they involve such higher mental processes as
reasoning.
4. 2 Expi&rt, cyBtoma
52
exists. The expert system can use its internal knowledge and rules
reasoning.
area, called a domain. The computer can analyze and solve only
realm as possible.
is the knowledge engineer who roust observe, talk to, and work with
53
theory or rules that can be used in expert system design. The
4. 4L K n o w l«id g » ra p r c iB o n t ft'tlo n
and applied during the search for a solution C138Ii. Knowing what
one knows, and knowing when and how to use it, seems to be an
4. 5 T h A p r o d u c t i o n cys'Lom
when to apply which rules, and a working memory that can hold
Fig. 4.1. It has two primary components: the knowledge base and
54
Th A k n o w l « d g « b a s «
make decisions. The knowledge base contains the rules and facts to
memory and the rule base. The rule base consists of facts and
memory.
The InferetMie e n g i n e
uses facts that are known to derive new facts by means of rules.
rules are tested and what happens when a rule succeeds or fails.
The inference engine takes the facts that it knows are true from
55
the rule base (static database) and working memory (dynamic
database) and uses these to test the rules in the database. When a
the user has less control. For example, Prolog scans the rules
alternative goal.
system.
with the system. With most consultation systems, the user can
question with why. The system then responds with information about
56
A. 6 Cartaird-ty factor
AND.
Exttnyl<i A. i
THEN C( CF = 0.5).
57
IF D( CF = 0.4) AND E( CF = 0.7)
THEN C( CF = 0.9).
0.7 * 0.9))
= 0.36
ExamplA A . 2
IF A ( CF = 0.3) AND
B ( CF = 0.6) OR
D ( CF = 0.5)
THEN C { CF = 0.4).
The CF for C is
= 0.5 # 0.4
= 0 .2
0.8). The accumulated value is less than the level and therefore
the knowledge base search proceeds. The next time the same
58
inference isencountered in the knowledge base search, the CF for
the equation comes from the absolute certainity value = 1. Now the
continued.
The equation is s
rule )
Exampla 3
Accumulated CF = 0.6
4r. 7 U s i n g P r o l o g to d A s l g n r u l « b A s « d syst.»ine
59
then knowledge base of rules and facts is examined to see if it
are useful when no algorithm exists. Prolog uses only data about
processing.
objective), and the computer must find both the procedure and
is a database.
core language.
Prolog. It has many features that are not a part of CAM Prolog,yet
it does not support many features that are supported in the core
60
will not run under Turbo Prolog without modification -
are pr*dleat*ss, i.e., expressions that say simple things about the
is C r 'lg h t .- s s p A a ik « r » d a a d 3 .
example :
user to use six different object types viz, char, integer, real,
61
within the parentheses are the argum*nt,B of the predicate, which
amployaoCblll>
studentC tonO
marrlcrd_toCbob, mary;>
complete clause.
property, or a value.
fa c t s .
hypo-thttBlsC vltc_dAflclanc;y3 If
62
depends are stated next, each connected iiy the word and. The
fails.
hypo-thAslsCvile deficiency!)
B ympt.oimC ar llu'11.1 B ) f
hypo'theslaCvlt.c def’ldencyZ* t —
B 3m^'tomC ari.hrlt.la:) ^
syn^tomClnfectlon sensltlvltyD .
h y p o i.h H »B lB C v lt .c d e fic ie n c y ^ i -
syn^tomClnfectlon Benslt.lvlty:> .
63
or other pair of premises is true, the conclusion is true. The
formal r«asonlz^ .
Thtt T u r b o P r o l o g pr-ograre
The main body of the program the clauses section, contains the
clauses and consists of facts and rules. The relations used in the
If Turbo Prolog can match the goal with a fact or rule in the data
variable name must begin with a capital letter and may be from 1
to S50 characters long. Except for the first character in the
sections. Most program only use a few of these sections, but the
64
for modular programming, dynamic d a t ab as es ,internal goals, and
compiling directions.
those that are used must be in the following order for the compile
operation.
1. Compiler directives.
2. Domains.
3. Global domains.
4. Database.
5. Predi.cates.
6. Global predicates.
7. Goal.
8. Clauses.
Unification
matching process.
P r o l o g AK*cut,lon r u l « s
65
1. Prolog executes using a matching process.
goal
All variables are local to the clause of which they are a part.
backtracks and tries to solve the same goal another way using
clauses.
Bullt.-ln prttdlcat,aB
siich as control and data input and output. Turbo Prolog offers
66
operations, but graphics, file operations, string handling and
groups s
file to a variable.
or a file.
■
4. File system predicates - For managing disk files from a Turbo
Prolog program.
data.
67
t.AB't t ••
displays
predicate nl .
predicate is used.
the screen.
wr-lt,a<lttvlcaC printer) ,
wrltedeviceC screen!) .
68
Bymf»t.onCPat^l«(nt,^ i—
Reply ■ "yes"
carriage return. The rule will succeed if the user enters y « and
programming.
always fails.
Example 4 . A
go I —
tttst,
69
t«st. 1 -
fall.
the head of the first rule and then try to prove it premises. The
test premise will unify with the head of the second rule, whose
premise is fail, and the goal will fail. Prolog will backtrack to
the first rule, and the go goal will fail again. The write
go 1 —
tesst..
test 1 -
fail.
Again the goal will fail, but the text string will be
r«rplacaCrlgKi,-Bp*alcar^ i-
notClsCr-lght-speakar^ f unctlonai;>;> .
In this case, if
isCrighi>Bp«rak«r, functional^,
70
The eut predicate
path. If the rule itself fails and the cut is the last premise, no
other rules with the same head can be tried. Prolog must accept
clause.
the grftan. and the r*<i cuts. The green type of cut is used to force
conditions.
more acceptable type. One can often use the not predicate instead
71
Exan^l« ‘
A. 5
got -
premlsely
premlscrS^ ! ^
premised^
pretmliBe‘
4.
prAmlBttl and prAinlBoS as necessary until both are true. Once this
fails without going back to premises before the cut and attempting
the cut.
predicate is
72
string or symbol.The arguments are explained as follows:
window display.
Exanipl« 4,. G
predicate: shlflwlndowCWlndowNo)
Prolog da'bAbaBOB
unification .
73
permit to add facts to or remove facts from this dynamic database
this section. The section must fallow the domains section and
E x a m p l a -4. 7
Donwklns
query ■ s'trlng
reply ■ char
database
predicates
Kypot/Hesi sC dl seaae^
ayinp'toinC aynipt.oiiO
one can store the facts, learned from the questions, in the
74
database (facts proven true in xpoBltiv* and facts proven false in
xnegallve) and query the database before asking the same question
again.
the program depends upon where one wishes to put the fact in the
database.
Examplo ■*.8
o p o w ln g p r ^ a d i.c a 't ^ B
75
2. openwrit,® Opens the file only for
deleted.
execution.
access.
and type of arguments. Any of them can be used to open a file. The
first argument is the symbolic file name that will be used for the
file in the program. The symbolic file name can be any name so
on the disk. The name is a string value and contains from one to
fllAposCSymbollcFllttriama^ PoBlt,lon^
76
0 = from begining of the file
The end of the file during a read operation may be checked using
close a file after using it. The general form of the closefile
O Coneludlrvg v^Amarks
Language is presented.
people who are experts in that domain. These expert (or knowledge
77
User