Ai File With Front Page
Ai File With Front Page
Some facts about family relationships could be written as: sister( sue,bill)
parent( ann.sam)
male(jo)
female( riya)
b) RULES:
To represent the general rule for grandfather, we write:
grand father( 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
OUTCOME: Students will get the basic idea of how to program in prolog and its working
environment.
PROGRAM: 2
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):-
write ("does", Patient,"has a rash (y/n)?" ),nl,
response(Reply),
Reply='y',
symptom(Patient_body,ache):-
write("does",Patient,"has a body ache (y/n)?"),nl,
response(Reply).
Reply='y',nl.
symptom(Patient,runny_nose):-
write("does",Patient,"has a runny_nose (y/n)?"),
response(Reply),
Reply='y'
hypothesis(Patient,flu):-
symptom(Patient,fever),
symptom(Patient,body_ache),
hypothesis(Patient,common_cold):-
symptom(Patient,body_ache),
Symptom(Patient,runny_nose).
response(Reply):-
readchar(Reply),
write(Reply).
Output:
makewindow(1,7,7"Expert Medical Diagnosis",2,2,23,70),
go.
PROGRAM: 6