Previous Up Next

Chapter 2  Terminology

This chapter defines the terminology which is used throughout the manual and in related documentation.

+X
This denotes an input argument. Such an argument must be instantiated before a predicate is called.
++X
This denotes a ground argument. Such an argument can be complex, but must be fully instantiated, i.e., not contain any variables.
–X
This denotes an output argument. Such an argument is allowed to be uninstantiated at call time. When this mode is used in the description of a built-in or library predicate, it is only descriptive. This means that the predicate can be called with an instantated argument, but it will behave as if were called with an uninstantiated variable which is then unified with the actual argument after returning from the call (e.g. atom_length(abc,3) behaves the same as atom_length(abc,L),L=3). If this mode is used in a mode/1 declaration, it is prescriptive, i.e. it is taken as a promise that the predicate will always be called with an uninstantiated variable, and that the compiler is allowed to make corresponding optimizations. Violating this promise will lead to unexpected failures.
?X
This denotes an input or an output argument. Such an argument may be either instantiated or not when the predicate is called.
Arity
Arity is the number of arguments to a term. Atoms are considered as functors with zero arity. The notation Name/Arity is used to specify a functor by giving its name and arity.
Atom
An arbitrary name chosen by the user to represent objects from the problem domain. A Prolog atom corresponds to an identifier in other languages. It can be written as a conventional identifier (beginning with a lower-case letter), or a character sequnce enclosed in single quotes.
Atomic
An atom, string or a number. A term which does not contain other terms.
Body
A clause body can either be of the form
Goal_1, Goal_2, ..., Goal_k
or simply
Goal
Each Goal_i must be a callable term.
Built-in Procedures
These are predicates provided for the user by the ECLiPSe system, they are either written in Prolog or in the implementation language (usually C).
Callable Term
A callable term is either a compound term or an atom.
Clause
See program clause or goal clause.
Compound Term
Compound terms are of the form
f(t_1, t_2, ..., t_n)
where f is the functor of the compound term, n is its arity and t_i are terms. Lists and pairs are also compound terms.
Constant
An atom, a number or a string.
Determinism
The determinism specification of a built-in or library predicate says how many solutions the predicate can have, and whether it can fail. The six determinism groups are defined as follows:
                |   Maximum number of solutions
    Can fail?   |   0               1               > 1
    ------------+------------------------------------------
    no          |   erroneous       det             multi
    yes         |   failure         semidet         nondet
This classification is borrowed from the Mercury programming language, but in ECLiPSe only used for the purpose of documentation. Note that the determinism of a predicate usually depends on its calling mode.
DID
Each atom created within ECLiPSe is assigned a unique identifier called the dictionary identifier or DID.
Difference List
A difference list is a special kind of a list. Instead of being ended by nil, a difference list has an uninstantiated tail so that new elements can be appended to it in constant time. A difference list is written as List - Tail where List is the beginning of the list and Tail is its uninstantiated tail. Programs that use difference lists are usually more efficient and always much less readable than programs without them.
Dynamic Procedure
These are procedures which can be modified clause-wise, by adding or removing one clause at a time. Note that this class of procedure is equivalent to interpreted procedures in other Prolog systems. See also static procedures.
External Procedures
These are procedures which are defined in a language other than Prolog, and explicitly connected to Prolog predicates by the user.
Fact
A fact or unit clause is a term of the form:
Head.
where Head is a head.

A fact may be considered to be a rule whose body is always true.

Functor
A functor is characterised by its name (which is an atom), and its arity (which is its number of arguments).
Goal Clause
See query.
Ground
A term is ground when it does not contain any uninstantiated variables.
Head
A clause head is a structure or an atom.
Instantiated
A variable is instantiated when it has been bound to an atomic or a compound term as opposed to being uninstantiated or free. See also ground.
List
A list is a special type of term within Prolog. It is a recursive data structure consisting of pairs (whose tails are lists). A list is either the atom [] called nil as in LISP, or a pair whose tail is a list. The notation :
[a , b , c]
is shorthand for:
[a | [b | [c | []]]]
Mode
A predicate mode is a particular instantiation pattern of its arguments at call time. Such a pattern is usually written as a predicate template, e.g.,
    p(+,-)
where the symbols +, ++, - and ? represent instantiated, ground, uninstantiated and unknown arguments respectively.
Name/Arity
The notation Name/Arity is used to specify a functor by giving its name and arity.
Number
A number literal denotes a number, more or less like in all programming languages.
Pair
A pair is a compound term with the functor ./2 (dot) which is written as :
[H|T]
H is the head of the pair and T its tail.
Predicate
A predicate is another term for a procedure.
PredSpec
This is similar to Name/Arity. Some built-ins allow the arity to be omitted and to specify the name only: this stands for all (visible) predicates with that name and any arity.
Program Clause
A program clause (or simply clause) is either the term
Head :- Body.
(i.e., a compound term with the functor :-/2), or only a fact.
Query
A query has the same form as a body and is also called a goal. Such clauses occur mainly as input to the top level Prolog loop and in files being compiled, then they have the form
:- Goal_1, ..., Goal_k.
or
?- Goal_1, ..., Goal_k.
The first of these two forms is often called a directive.
Regular Prolog Procedure

A regular (Prolog) procedure is a sequence of user clauses whose heads have the same functor, which then identifies the user procedure.

Simple Procedures
Apart from regular procedures ECLiPSe recognises simple procedures which are written not in Prolog but in the implementation language (i.e., C), and which are deterministic. There is a functor associated with each simple procedure, so that any procedure recognisable by ECLiPSe is identified by a functor, or by a compound term (or atom) with this functor.
SpecList
The SpecList notation means a sequence of PredSpec terms of the form:
name_1/arity_1, name_2/arity_2, ..., name_k/arity_k.
The SpecList notation is used in many built-ins, for example, to specify a list of procedures in the export/1 predicate.
Static Procedures
These are procedures which can only be changed as a whole unit, i.e., removed or replaced.
Stream
This is an I/O channel identifier and can be a physical stream number, one of the predefined stream identifiers (input, output, error, warning_output, log_output, null) or a user defined stream name (defined using set_stream/2 or open/3).
String
A string is similar to those found in all other programming languages. A string is enclosed in double quotes.
Structure
Compound terms which are not pairs are also called structures.
Term
A term is the basic data type in Prolog. It is either a variable, a constant or a compound term.
Variable
A variable is more similar to a mathematical variable than to a variable in some imperative language. It can be free, or instantiated to a term, but once instantiated it becomes indistinguishable from the term to which it was instantiated: in particular, it cannot become free again (except upon backtracking through the point of instantiation). The name of a variable is written in the form of an identifier that begins with an upper-case letter or with an underscore. A single underscore represents an anonymous variable that has only one occurrence (i.e., another occurrence of this name represents another variable).

The notation Pred/N1, N2 is often used in this documentation as a shorthand for Pred/N1, Pred/N2.


Previous Up Next