AI_file
AI_file
Experiment No: 1
male(jo)
female( riya)
b) RULES:-
To represent the general rule for grandfather, we write:
grand f.gher( X2)
parent(X,Y)
parent( Y,Z)
male(X)
c) QUERIES:-
Given a database of facts and rules such as that above, we may make queries by typing
after a query a symbol’?’ statements such as:
?-parent(X,sam) Xann
?grandfather(X,Y)
X=jo, Y=sam
PROLOG IN DISGINING EXPERT SYSTEMS
An expert system is a set of programs that manipulates encoded knowledge to solve problems in
a specialized domain that normally requires human expertise. An expert system’s knowledge is
obtained from expert sources such as texts, journal articles. databases etc and encoded in a form
suitable for the system to use in its inference or reasoning processes. Once a sufficient body of
expert knowledge has been acquired, it must be encoded in some form, loaded into knowledge
base, then tested, and refined continually throughout the life of the system PROLOG serves as a
powerful language in designing expert systems because of its following features.
➢ Use of knowledge rather than data
are interested in implementing new ideas quickly. New ideas are rapidly implemented and
experimented with.
Experiment No: 2
Output:-
?-likes(ram,What).
What= mango
?-likes(Who,cindy).
Who= cindy
?-red(What).
What= rose
?-owns(Who,What).
Who= john
What= gold.
Experiment No: 3
Experiment No. 4
Experiment No. 5
Objective:- WAP in turbo prolog for medical diagnosis and show the advantage and
disadvantage of green and red cuts.
Program:-
Domains:-
disease,indication=symbol
name-string
Predicates:-
hypothesis(name,disease)
symptom(name,indication)
response(char)
go
goonce
clauses:
go:-
goonce
write("will you like to try again
(y/n)?"), response(Reply),
Reply='n'.
go.
goonce:-
write("what is the patient's name"),nl,
readln(Patient),
hypothesis(Patient,Disease),!,
write(Patient,"probably has",Disease),!,
goonce:-
write("sorry, i am not ina position to
diagnose"), write("the disease").
symptom(Patient,fever):-
write("does",Patient,"has a fever
(y/n)?"),nl, response(Reply),
Reply='y',nl.
symptom(Patient,rash):-
Experiment No. 6
Fibonacci:-
fib(0, 0).
fib(X, Y) :- X > 0, fib(X, Y, _).
fib(1, 1, 0).
fib(X, Y1, Y2) :-
X>1,
X1 is X - 1,
fib(X1, Y2, Y3),
Y1 is Y2 + Y3.
Output:-
Experiment No. 7
Experiment No. 8
Experiment No. 9