Upload
luci-arce
View
220
Download
0
Embed Size (px)
Citation preview
8/3/2019 Prolog Report
http://slidepdf.com/reader/full/prolog-report 1/10
Lucia S. Arce
Rafael M. Manlutac
8/3/2019 Prolog Report
http://slidepdf.com/reader/full/prolog-report 2/10
Paradigm◦ Logic Programming
Appeared in◦ 1972
Designed by◦ Alain Colmerauer
8/3/2019 Prolog Report
http://slidepdf.com/reader/full/prolog-report 3/10
Major implementations◦ Amzi! Prolog, BProlog, Ciao Prolog, ECLiPSe, GNU
Prolog, Logic Programming Associates, PoplogProlog, P#, Quintus, SICStus, Strawberry, SWI-
Prolog, tuProlog, YAP-Prolog, Jekejeke Prolog Dialects
◦ ISO Prolog, Edinburgh Prolog
Influenced◦ Visual Prolog, Mercury, Oz, Erlang, Strand, KL0,
KL1, Datalog
8/3/2019 Prolog Report
http://slidepdf.com/reader/full/prolog-report 4/10
Atom ◦ is a general-purpose name with no inherent
meaning. Examples of atoms include x, blue, 'Taco',and 'some atom'.
Numbers◦ can be floats or integers
Variables ◦ are denoted by a string consisting of letters,
numbers and underscore characters, and beginning
with an upper-case letter or underscore. Variablesclosely resemble variables in logic in that they areplaceholders for arbitrary terms.
8/3/2019 Prolog Report
http://slidepdf.com/reader/full/prolog-report 5/10
compound term◦ composed of an atom called a "functor" and a
number of "arguments", which are again terms.Compound terms are ordinarily written as a functor
followed by a comma-separated list of argumentterms, which is contained in parentheses
◦ The number of arguments is called the term's arity
8/3/2019 Prolog Report
http://slidepdf.com/reader/full/prolog-report 6/10
Special cases of compound terms◦ List is an ordered collection of terms. It is denoted
by square brackets with the terms separated bycommas or in the case of the empty list, []. For
example [1,2,3] or [red,green,blue].◦ Strings: A sequence of characters surrounded by
quotes is equivalent to a list of (numeric) charactercodes, generally in the local character encoding, orUnicode if the system supports Unicode. Forexample, "to be, or not to be".
8/3/2019 Prolog Report
http://slidepdf.com/reader/full/prolog-report 7/10
Prolog programs describe relations, definedby means of clauses. Pure Prolog is restrictedto Horn clauses. There are two types of clauses: Facts and rules. A rule is of the form
Head :- Body.
and is read as "Head is true if Body is true". Arule's body consists of calls to predicates,
which are called the rule's goals.
8/3/2019 Prolog Report
http://slidepdf.com/reader/full/prolog-report 8/10
The built-in predicate ,/2 (meaning a 2-arityoperator with name ,) denotes conjunction of goals, and ;/2 denotes disjunction.
Conjunctions and disjunctions can onlyappear in the body, not in the head of a rule.
8/3/2019 Prolog Report
http://slidepdf.com/reader/full/prolog-report 9/10
Clauses with empty bodies are called facts.An example of a fact is:
cat(tom).
which is equivalent to the rule:cat(tom) :- true.