0% found this document useful (0 votes)
34 views

Lucia S. Arce Rafael M. Manlutac

Prolog is a logic programming language created in 1972 by Alain Colmerauer. It uses logic to represent problems and solve them. Prolog programs describe relations using clauses, which can be facts or rules. A rule contains a head and body, where the head is true if the goals in the body are true. Prolog has many implementations and influenced other languages like Mercury and Erlang. It represents data as terms which can be atoms, numbers, variables, or compound terms.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Lucia S. Arce Rafael M. Manlutac

Prolog is a logic programming language created in 1972 by Alain Colmerauer. It uses logic to represent problems and solve them. Prolog programs describe relations using clauses, which can be facts or rules. A rule contains a head and body, where the head is true if the goals in the body are true. Prolog has many implementations and influenced other languages like Mercury and Erlang. It represents data as terms which can be atoms, numbers, variables, or compound terms.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Lucia S. Arce Rafael M.

Manlutac

Paradigm
Logic Programming

Appeared in
1972

Designed by
Alain Colmerauer

Major implementations
Amzi! Prolog, BProlog, Ciao Prolog, ECLiPSe, GNU Prolog, Logic Programming Associates, Poplog Prolog, P#, Quintus, SICStus, Strawberry, SWIProlog, tuProlog, YAP-Prolog, Jekejeke Prolog

Dialects
ISO Prolog, Edinburgh Prolog

Influenced
Visual Prolog, Mercury, Oz, Erlang, Strand, KL0, KL1, Datalog

Atom

Numbers

is a general-purpose name with no inherent meaning. Examples of atoms include x, blue, 'Taco', and 'some atom'.
can be floats or integers are denoted by a string consisting of letters, numbers and underscore characters, and beginning with an upper-case letter or underscore. Variables closely resemble variables in logic in that they are placeholders for arbitrary terms.

Variables

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 argument terms, which is contained in parentheses The number of arguments is called the term's arity

Special cases of compound terms


List is an ordered collection of terms. It is denoted by square brackets with the terms separated by commas 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) character codes, generally in the local character encoding, or Unicode if the system supports Unicode. For example, "to be, or not to be".

Prolog programs describe relations, defined by means of clauses. Pure Prolog is restricted to 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". A rule's body consists of calls to predicates, which are called the rule's goals.

The built-in predicate ,/2 (meaning a 2-arity operator with name ,) denotes conjunction of goals, and ;/2 denotes disjunction. Conjunctions and disjunctions can only appear in the body, not in the head of a rule.

Clauses with empty bodies are called facts. An example of a fact is:

cat(tom).

which is equivalent to the rule:

cat(tom) :- true.

The built-in predicate true/0 is always true. Given the above fact, one can ask:

is tom a cat? ?- cat(tom). Yes what things are cats? ?- cat(X). X = tom

You might also like