Previous Up Next

Chapter 2  Terminology

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

This denotes an input argument. Such an argument must be instantiated before a predicate is called.
This denotes a ground argument. Such an argument can be complex, but must be fully instantiated, i.e., not contain any variables.
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.
This denotes an input or an output argument. Such an argument may be either instantiated or not when the predicate is called.
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.
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.
An atom, string or a number. A term which does not contain other terms.
A clause body can either be of the form
Goal_1, Goal_2, ..., Goal_k
or simply
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.
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.
An atom, a number or a string.
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.
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.
A fact or unit clause is a term of the form:
where Head is a head.

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

A functor is characterised by its name (which is an atom), and its arity (which is its number of arguments).
Goal Clause
See query.
A term is ground when it does not contain any uninstantiated variables.
A clause head is a structure or an atom.
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.
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 | []]]]
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.,
where the symbols +, ++, - and ? represent instantiated, ground, uninstantiated and unknown arguments respectively.
The notation Name/Arity is used to specify a functor by giving its name and arity.
A number literal denotes a number, more or less like in all programming languages.
A pair is a compound term with the functor ./2 (dot) which is written as :
H is the head of the pair and T its tail.
A predicate is another term for a procedure.
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.
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.
?- 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.
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.
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).
A string is similar to those found in all other programming languages. A string is enclosed in double quotes.
Compound terms which are not pairs are also called structures.
A term is the basic data type in Prolog. It is either a variable, a constant or a compound term.
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