0% found this document useful (0 votes)
15 views13 pages

Ai File With Front Page

The document outlines a series of programming objectives focused on Prolog, a logic programming language developed in the 1970s, emphasizing its capabilities for symbolic computation and problem-solving involving objects and relationships. It details various programs, including writing simple facts, predicates for temperature conversion, medical diagnosis, and solving classic problems like the Monkey Banana problem and the 4-Queen problem. The aim is to provide students with foundational knowledge and practical experience in Prolog programming.

Uploaded by

bechuyiwari20
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views13 pages

Ai File With Front Page

The document outlines a series of programming objectives focused on Prolog, a logic programming language developed in the 1970s, emphasizing its capabilities for symbolic computation and problem-solving involving objects and relationships. It details various programs, including writing simple facts, predicates for temperature conversion, medical diagnosis, and solving classic problems like the Monkey Banana problem and the 4-Queen problem. The aim is to provide students with foundational knowledge and practical experience in Prolog programming.

Uploaded by

bechuyiwari20
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

PROGRAM: 1

Objective: Study of Prolog.


PROLOG-PROGRAMMING IN LOGIC
PROLOG stands for Programming, In Logic — an idea that emerged in the early 1970’s to use
logic as programming language. The early developers of this idea included Robert Kowaiski at
Edinburgh (on the theoretical side), Marrten van Emden at Edinburgh (experimental
demonstration) and Alian Colmerauer at Marseilles (implementation). David D.H. Warren’s
efficient implementation at Edinburgh in the mid -1970’s greatly contributed to the popularity
of PROLOG. PROLOG is a programming language centred around a small set of basic
mechanisms, Including pattern matching, tree based data structuring and automatic
backtracking. This Small set constitutes a surprisingly powerful and flexible programming
framework. PROLOG is especially well suited for problems that involve objects- in particular,
structured objects- and relations between them.
SYMBOLIC LANGUAGE
PROLOG is a programming language for symbolic, non-numeric computation. It is especially
well suited for solving problems that involve objects and relations between objects. For
example, it is an easy exercise in prolog to express spatial relationship between objects, such
as the blue sphere is behind the green one. It is also easy to state a more general rule: if object
X is closer to the observer than object Y. and object Y is closer than Z, then X must be closer
than Z. PROLOG can reason about the spatial relationships and their consistency with respect
to the general rule. Features like this make PROLOG a powerful language for ArtJIcia1
LanguageA1,) and non- numerical programming. There are well-known examples of symbolic
computation whose implementation in other standard languages took tens of pages of
indigestible code, when the same algorithms were implemented in PROLOG, the result was a
crystal-clear program easily fitting on one page.
FACTS, RULES AND QUERIES
Programming in PROIOG is accomplished by creating a database of facts and rules about
objects, their properties, and their relationships to other objects. Queries then can be posed
about the objects and valid conclusions will be determined and returned by the program
Responses to user queries are determined through a form of inference control known as
resolution.
a) FACTS:

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: Write simple fact for the statements using PROLOG.


PROGRAM: 3

Objective: Write predicates one converts centigrade temperatures to


Fahrenheit, the other checks if a temperature is below freezing.
PROGRAM: 4

Objective: Write a program to solve the Monkey Banana problem.


PROGRAM: 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):-
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

Objective: WAP to implement factorial, Fibonacci of a given number.


PROGRAM: 7

Objective: Write a program to solve 4-Queen problem.


PROGRAM: 8

Objective: Write a program to solve traveling salesman problem.


PROGRAM: 9

Objective: Write a program to solve water jug problem using LISP.

You might also like