Documente Academic
Documente Profesional
Documente Cultură
symptom(Patient,rash).
hypothesis(Patient,mumps):symptom(Patient,fever), symptom(Patient,swollen_glands).
hypothesis(Patient,chicken_pox):symptom(Patient,fever), symptom(Patient,rash),
symptom(Patient,body_ache), symptom(Patient,chills).
PRACTICAL - 06 Date:_____________
Aim: - Write a program to check the Medical Diagnostic System.
domains disease, indication=symbol patient = string predicates hypothesis (patient, disease) symptom (patient, indication) response char) go clauses go:write ("What is the patient's name? "), readln (Patient), hypothesis (Patient, Disease), write (Patient," probably has ",Disease,"."),nl. go:write("sorry, I don't seem to be able to"),nl, write("diagnose the disease."),nl.
symptom(Patient, fever):write("Does ",Patient," have a fever (y/n) ?"), response(Reply), Reply='Y'. symptom(Patient, rash):-
write("Does ",Patient," have a rash (y/n) ?"), response(Reply), Reply='Y'. symptom(Patient, headache):write("Does ",Patient," have a headache (y/n) ?"), response(Reply), Reply='Y'. symptom(Patient,runny_nose):write("Does ",Patient," have a runny_nose (y/n)?"), response(Reply), Reply='Y'. symptom(Patient, conjuctivitis):write("Does ",Patient," have a conjuctivitis (y/n)?"), response(Reply), Reply='Y'. symptom(Patient, cough):write("Does ",Patient," have a cough (y/n) ?"), response(Reply), Reply='Y'.
symptom(Patient, body_ache):write("Does ",Patient," have a body_ache (y/n) ?"), response(Reply), Reply='Y'. symptom(Patient, chills):write("Does ",Patient," have a chills (y/n) ?"),
response(Reply), Reply='Y'. symptom(Patient, sore_throat):write("Does ",Patient," have a sore throat (y/n) ?"), response(Reply), Reply='Y'. symptom(Patient, sneezing):write("Does ",Patient," have a sneezing (y/n) ?"), response(Reply), Reply='Y'. symptom(Patient, swollen_glands):write("Does ",Patient," have a swollen_glands (y/n)?), response(Reply), Reply='Y'. hypothesis(Patient, measles):symptom(Patient, fever), symptom(Patient, cough), symptom(Patient, conjuctivitis), symptom(Patient, runny_nose), symptom(Patient, rash). hypothesis(Patient, german_measles):symptom(Patient, fever), symptom(Patient, headache), symptom(Patient, runny_nose), symptom(Patient, rash). hypothesis(Patient, flu):-
symptom(Patient, fever), symptom(Patient, headache), symptom(Patient, body_ache), symptom(Patient, conjuctivitis), symptom(Patient, chills), symptom(Patient, sore_throat), symptom(Patient, cough), symptom(Patient ,runny_nose). hypothesis(Patient, common_cold):symptom(Patient, headache), symptom(Patient, sneezing), symptom(Patient, sore_throat), symptom(Patient, chills), symptom(Patient,runny_nose).
Output:Goal: go What is the patients name? Charlie Does Charlie have a fever?n Does Charlie have a fever?y Does Charlie have a headache?y Does Charlie have a runny_nose?y Does Charlie have a rash?y Charlie probably has german_measles. Yes
PRACTICAL - 07 Date:_____________
Aim: Write a program to demonstrate FAIL predicates.
Predicates
location(string,string) go clauses go:writef("%-10 %5 \n","CITY","STATE"), fail. go:location(City,State), writef("%-10 %2 \n",City,State), fail. go. location("Jackson","MS"). location("Washington","DC"). location("Raleigh","NC").
PRACTICAL - 08 Date:_____________
Aim: domains
name,password=symbol predicates getinput(name,password) logon user(name,password) repeat clauses repeat. repeat:repeat. logon:clearwindow, getinput(_,_), write("You are now logon."),nl. logon:repeat, write("Sorry, you are not permitted to access."),nl, write("Please try again."),nl, getinput(_,_), write("You are logged on."),nl.
Output:Goal: logon Please Enter your name:abc Please Enter Password:xyz Sorry, you are not permitted to access. Please try again. Please Enter your name:john Please Enter Password:superman You are logged on. Yes
PRACTICAL - 09 Date:_____________
Aim: domains name,password=symbol
predicates getinput(name,password) logon user(name,password) clauses logon:clearwindow, getinput(Name,Password), user(Name,Password), write("You are now logged on."),nl. logon:write("Sorry, you are not permitted access."),nl, write("Please try again."),nl, logon. getinput(Name,Password):write("Please Enter Your Name:"), readln(Name),nl, write("Please Enter Password:"), readln(Password),nl, user(Name,Password). user(john,superman). user(sue,happy). user(bill,bigfoot).
Output:Goal: logon
Enter Your Name:patel Please Enter Password:pqr Sorry, you are not permitted to access. Please try again. Enter Your Name:john Please Eenter Password:superman You are logged on. Yes
PRACTICAL - 10 Date:_____________
Aim: domains disease, indication,name = string predicates
hypothesis(name,disease) symptom(name,indication) response(char) go go_once repeat clauses go:repeat, go_once, write("Would you like to try again(y/n)?"), response(Reply), Reply='n'. go. repeat. repeat:repeat. go_once:write("what is the patient's name? "), readln(Patient), hypothesis(Patient,Disease),!, write(Patient," probably has ", Disease,"."),nl. go_once:write("sorry, I dont seem to be able to"),nl, write("diagonse the disease. "),nl. symptom(Patient,fever):-
write("Does ", Patient,"have a fever (y/n)?"), response(Reply), Reply ='y'. symptom(Patient,rash):write("Does ", Patient,"have a rash (y/n) ?"), response(Reply), Reply ='y'. symptom(Patient,headache):write("Does",Patient," have a headache (y/n)?"), response(Reply), Reply = 'y'. symptom(Patient,runny_nose):write("Does",Patient,"have a runny nose (y/n)?"), response(Reply), Reply = 'y'. symptom(Patient,conjuctivitis):write("Does", Patient,"have conjuctivitis (y/n)?"), response(Reply), Reply = 'y'. symptom(Patient,cough) :write("Does ",Patient," have a cough (y/n) ?"), response(Reply), Reply='y'. symptom(Patient,body_ache) :write("Does ",Patient," have a body_ache (y/n), ?"), response(Reply),
Reply='y'. symptom(Patient,chills) :write("Does ",Patient," have chills (y/n) ?"), response(Reply), Reply='y'. symptom(Patient,sore_throat) :write("Does ",Patient," have a sore_throat (y/n) ?"), response(Reply), Reply='y'. symptom(Patient,sneezing) :write("Is ",Patient," sneezing (y/n) ?"), response(Reply), Reply='y'. symptom(Patient,swollen_glands) :write("Does ",Patient," have swollen_glands (y/n) ?"), response(Reply), Reply='y'. hypothesis(Patient,measles):symptom(Patient,fever), symptom(Patient,cough), symptom(Patient,conjunctivitis), symptom(Patient,runny_nose), symptom(Patient,rash). hypothesis(Patient,german_measles):symptom(Patient,fever), symptom(Patient,headache),
hypothesis(Patient,common_cold):symptom(Patient,headache), symptom(Patient,sneezing), symptom(Patient,sore_throat), symptom(Patient,chills), symptom(Patient,runny_nose). hypothesis(Patient,mumps):symptom(Patient,fever), symptom(Patient,swollen_glands). hypothesis(Patient,chicken_pox):symptom(Patient,fever), symptom(Patient,rash), symptom(Patient,body_ache), symptom(Patient,chills). hypothesis(Patient,whooping_cough):-
symptom(Patient,cough), symptom(Patient,sneezing), symptom(Patient,runny_nose). response(Reply) :readchar(Reply), write(Reply),nl. Output:Goal : go What is the patient`s name? Charlie Does Charlie have a fever(y/n)? y Does Charlie have a cough(y/n)? n Does Charlie have a fever(y/n)? n Does Charlie have a fever(y/n)? n Does Charlie have a headache(y/n)? n Does Charlie have a fever(y/n)? n Does Charlie have a fever(y/n)? n Does Charlie have a cough(y/n)? n Sorry, I don`t seem to be able to diagnose the disease. Would you like to try again(y/n)? n Yes Goal :
PRACTICAL - 11 Date:_____________
Aim: - Find the roots of the Quadratic Equation for imaginary roots.
domains Delta,A,B,C,D=real X1,X2=real predicates go getinput(A,B,C) clauses
go:writef("Enter the value of A:"), readint(A),nl, writef("Enter the value of B:"), readint(B),nl, writef("Enter the vale of C:"), readint(C),nl, getinput(A,B,C). getinput(A,B,C):Delta=((B*B)-(4*A*C)), Delta>0, D=sqrt(Delta), X1=(-B+D)/(2*A), write("X1=",X1),nl, X2=(-B-D)/(2*A), write("X2",X2). getinput(_,_,_):write("Roots are imaginary.").
Output:Goal: go Enter the value of A:1 Enter the value of B:10 Enter the value of C:1 X1=-0.10102051443 X2=-9.8989794856
Yes. Goal: go Enter the value of A:10 Enter the value of B:1 Enter the value of C:10 Roots are imaginary. Yes. Goal:
PRACTICAL - 12 Date:_____________
Aim: Write a program to find Factorial of given number.
PRACTICAL - 13 Date:_____________
Aim: not. Write a program to implement given number is prime or
clauses prime:-
N=2, Sum=1, getinput(No), primenum(No,N,Sum). getinput(No):write("Enter No:"), readint(No),nl. primenum(_,_,Sum):Sum=0, write("Number is Not Prime"),nl. primenum(No,N,_):N<>No, Sum1=No mod N, N1=N+1, primenum(No,N1,Sum1). primenum(_,_,_):write("Number is Prime"),nl.
PRACTICAL - 14 Date:_____________
Aim: domains No,Sum,Sum1,Fin,Fin1,Final=integer predicates getinput(No) odd oddsum(integer,integer,integer) clauses odd:Sum=1,
Fin=0, getinput(No), oddsum(No,Sum,Fin). getinput(No):write("Enter No:"), readint(No),nl. oddsum(No,Sum,Final):Sum>No, write("Odd Sum is =",Final),nl. oddsum(No,Sum,Fin):Fin1=Fin+Sum, Sum1=Sum+2, oddsum(No,Sum1,Fin1).
PRACTICAL - 15 Date:_____________
Aim: domains X, namelist=symbol* predicates append(namelist,namelist,namelist)
PRACTICAL - 16 Date:_____________
Aim: domains X,namelist=symbol* predicates reverse_list(namelist,namelist) reverse(namelist,namelist,namelist) clauses reverse_list(Inputlist,Outputlist):reverse(Inputlist,[],Outputlist). reverse([],Inputlist,Inputlist). reverse([Head|Tail],List1,List2):-
reverse(Tail,[Head|List1],List2).
PRACTICAL - 17 Date:_____________
Aim: domains X,name=symbol* predicates last_element(name,symbol)
PRACTICAL - 18 Date:_____________
Aim: domains N,namelist=integer* predicates n_element(namelist,integer,integer) clauses n_element([Head|_],1,X):X=Head. n_element([_|Tail],N,X):NN=N-1, n_element(Tail,NN,X).