study of prolog
study of prolog
Using Prolog
Study of PROLOG
Introduction
Artificial Intelligence (or simply AI) is the study and development
of machines that are capable of having an intelligence equal to or
better than a human being. As a result, AI has many different
applications today. AI is used in everything from gaming, to creating
smarter computerized opponents, to robots that can assist humans in
nearly every facet of life.
predicates
This section contains the declarations of the predicates that would be later
defined in the clauses section of the code. e.g.:
father(person,person)
symptom(disease, indication)
clauses
It contains the actual definitions of the previously declared predicates.
goal
This section is used to query prolog database
Example:
In making a query you are asking Prolog whether it can prove that your
query is true. If so, it answers "yes" and displays any variable
bindings that it made in coming up with the answer. If it fails to prove the
query true, it answers "No".
Example:
Facts
English meanings
food(burger). // burger is a foodf
food(sandwich). // sandwich is a food
food(pizza). // pizza is a food
lunch(sandwich). // sandwich is a lunch
dinner(pizza). // pizza is a dinner
Rules
meal(X) :- food(X). // Every food is a meal OR Anything is a meal if it is a food
Queries / Goals
?- food(pizza). // Is pizza a food?
true.
?- meal(X), lunch(X). // Which food is meal and lunch?
X = sandwich .
?- dinner(sandwich). // Is sandwich a dinner?
false.
Write predicates One converts centigrade temperatures to
Fahrenheit, the other checks if a temperature is below
freezing.
Output:
c_to_f(100,X).
X = 212.