\chapter{Glossary of Terms}		\label{sec:glossary}

\newcommand{\glossitem}[1]{\item [{#1}]\mbox{}\\}
\newcommand{\g}[1]{{\em #1}}

\begin{description}
    \glossitem{anonymous [variable]}\index{anonymous variable}\index{variable,anonymous}%
The variable \verb$_$ is called the \g{anonymous} variable.  Multiple
occurrences of \verb$_$ in a single \g{term} are not \g{shared}.

    \glossitem{arguments}
Arguments are \g{terms} that appear in a \g{compound} \g{term}. \arg{A1}
and \arg{a2} are the first and second argument of the term
\term{myterm}{A1, a2}.

    \glossitem{arity}\index{arity}%
Argument count (= number of arguments) of a \g{compound} \g{term}.

    \glossitem{assert}\index{assert}%
Add a \g{clause} to a \g{predicate}. Clauses can be added at either
end of the clause-list of a \g{predicate}.  See \index{asserta/1}\predref{asserta}{1} and \index{assertz/1}\predref{assertz}{1}.

    \glossitem{atom}\index{atom}%
Textual constant.  Used as name for \g{compound} terms, to represent
constants or text.

    \glossitem{backtracking}\index{backtracking}%
Search process used by Prolog.  If a predicate offers multiple
\g{clauses} to solve a \g{goal}, they are tried one-by-one until
one \g{succeeds}.  If a subsequent part of the proof is not satisfied
with the resulting \g{variable} \g{binding}, it may ask for
an alternative \g{solution} (= \g{binding} of the \g{variables}),
causing Prolog to reject the previously chosen \g{clause} and try the
next one.

    \glossitem{binding [of a variable]}\index{binding}%
Current value of the \g{variable}.  See also \g{backtracking} and
\g{query}.

    \glossitem{built-in [predicate]}\index{built-in predicate}%
Predicate that is part of the Prolog system.  Built-in predicates cannot
be redefined by the user, unless this is overruled using
\index{redefine_system_predicate/1}\predref{redefine_system_predicate}{1}.

    \glossitem{body}\index{body}%
Part of a \g{clause} behind the \g{neck} operator (\const{\Sneck}).

    \glossitem{choice point}\index{choice point}%
A \g{choice point} represents a choice in the search for a \g{solution}.
Choice points are created if multiple clauses match a \g{query} or using
disjunction (\predref{\Ssemicolon}{2}). On \g{backtracking}, the execution state
of the most recent \g{choice point} is restored and search continues
with the next alternative (i.e., next clause or second branch of
\predref{\Ssemicolon}{2}).

    \glossitem{clause}\index{clause}%
`Sentence' of a Prolog program. A \g{clause} consists of a \g{head} and
\g{body} separated by the \g{neck} operator (\const{\Sneck}) or it is a
\g{fact}.  For example:

\begin{code}
parent(X) :-
        father(X, _).
\end{code}

\noindent
Expressed as ``X is a parent if X is a father of someone''.  See also
\g{variable} and \g{predicate}.

    \glossitem{compile}
Process where a Prolog \g{program} is translated to a sequence of
instructions.  See also \g{interpreted}.  SWI-Prolog always
compiles your program before executing it.

    \glossitem{compound [term]}\index{compound}%
Also called \g{structure}.  It consists of a name followed by \arg{N}
\g{arguments}, each of which are \g{terms}.  \arg{N} is called the
\g{arity} of the term.

    \glossitem{context module}\index{context module}\index{module,contex}%
If a \g{term} is referring to a \g{predicate} in a \g{module}, the
\g{context module} is used to find the target module.  The context
module of a \g{goal} is the module in which the \g{predicate} is
defined, unless this \g{predicate} is \g{module transparent}, in
which case the \g{context module} is inherited from the parent
\g{goal}.  See also \index{module_transparent/1}\predref{module_transparent}{1} and \g{meta-predicate}.

    \glossitem{dcg}\index{dcg}%
Abbreviation for \g{Definite Clause Grammar}.

    \glossitem{det [determinism]}\index{det}%
Short for \g{deterministic}.

    \glossitem{determinism}\index{determinism}%
How many solutions a \g{goal} can provide.  Values are `nondet' (zero
to infinite), `multi' (one to infinite), `det' (exactly one) and
`semidet' (zero or one).

    \glossitem{deterministic}\index{deterministic}%
A \g{predicate} is \g{deterministic} if it succeeds exactly one time
without leaving a \g{choice point}.

    \glossitem{dynamic [predicate]}\index{dynamic predicate}\index{predicate,dynamic}%
A \g{dynamic} predicate is a predicate to which \g{clauses} may be
\g{assert}ed and from which \g{clauses} may be \g{retract}ed while
the program is running.  See also \g{update view}.

    \glossitem{exported [predicate]}\index{exported predicate}\index{predicate,exported}%
A \g{predicate} is said to be \g{exported} from a \g{module} if it
appears in the \g{public list}.  This implies that the predicate
can be \g{imported} into another module to make it visible there.
See also \index{use_module/[1,2]}\predref{use_module}{[1,2]}.

    \glossitem{fact}\index{fact}%
\g{Clause} without a \g{body}. This is called a fact because, interpreted
as logic, there is no condition to be satisfied. The example below
states \const{john} is a person.

\begin{code}
person(john).
\end{code}

\noindent
    \glossitem{fail}
A \g{goal} is said to haved failed if it could not be \g{proven}.

    \glossitem{float}
Computer's crippled representation of a real number.  Represented as
`IEEE double'.

    \glossitem{foreign}
Computer code expressed in languages other than Prolog.  SWI-Prolog can
only cooperate directly with the C and C++ computer languages.

    \glossitem{functor}\index{functor}%
Combination of name and \g{arity} of a \g{compound} term.  The term
\term{foo}{a, b, c} is said to be a term belonging to the functor
\nopredref{foo}{3}. \nopredref{foo}{0} is used to refer to the \g{atom}
\const{foo}.

    \glossitem{goal}\index{goal}\index{query}%
Question stated to the Prolog engine.  A \g{goal} is either an \g{atom}
or a \g{compound} term. A \g{goal} either succeeds, in which case the
\g{variables} in the \g{compound} terms have a \g{binding}, or it \g{fails}
if Prolog fails to prove it.

    \glossitem{hashing}\index{hashing}%
\g{Indexing} technique used for quick lookup.

    \glossitem{head}\index{head}%
Part of a \g{clause} before the \g{neck} operator (\const{\Sneck}).   This is an \g{atom}
or \g{compound} term.

    \glossitem{imported [predicate]}%
\index{imported predicate}\index{predicate,imported}%
A \g{predicate} is said to be \g{imported} into a \g{module} if it is
defined in another \g{module} and made available in this \g{module}.
See also \chapref{modules}.

    \glossitem{indexing}\index{indexing}%
Indexing is a technique used to quickly select candidate \g{clauses} of
a \g{predicate} for a specific \g{goal}. In most Prolog systems,
indexing is done (only) on the first \g{argument} of the \g{head}. If
this argument is instantiated to an \g{atom}, \g{integer}, \g{float} or
\g{compound} term with \g{functor}, \g{hashing} is used to quickly select
all \g{clauses} where the first argument may \g{unify} with the first
argument of the \g{goal}. SWI-Prolog supports just-in-time and
multi-argument indexing.  See \secref{jitindex}.

    \glossitem{integer}\index{integer}%
Whole number.  On all implementations of SWI-Prolog integers are
at least 64-bit signed values.  When linked to the GNU GMP library,
integer arithmetic is unbounded.  See also \index{current_prolog_flag/2}\predref{current_prolog_flag}{2},
flags \prologflag{bounded}, \prologflag{max_integer} and \prologflag{min_integer}.

    \glossitem{interpreted}\index{interpreted}%
As opposed to \g{compiled}, interpreted means the Prolog system attempts
to prove a \g{goal} by directly reading the \g{clauses} rather than
executing instructions from an (abstract) instruction set that is not
or only indirectly related to Prolog.

    \glossitem{instantiation [of an argument]}\index{instantiation}%
To what extend a term is bound to a value.  Typical levels are
`unbound' (a \g{variable}), `ground' (term without variables) or
`partially bound' (term with embedded variables).

    \glossitem{meta-predicate}\index{meta-predicate}%
A \g{predicate} that reasons about other \g{predicates}, either by
calling them, (re)defining them or querying \g{properties}.

    \glossitem{mode [declaration]}\index{mode}%
Declaration of an argument \g{instantiation} pattern for a
\g{predicate}, often accompanied with a \g{determinism}.

    \glossitem{module}\index{module}%
Collection of predicates.  Each module defines a name-space for
predicates.  \g{built-in} predicates are accessible from all modules.
Predicates can be published (\g{exported}) and \g{imported} to make
their definition available to other modules.

    \glossitem{module transparent [predicate]}\index{module transparent}\index{transparent}%
A \g{predicate} that does not change the \g{context module}.  Sometimes
also called a \g{meta-predicate}.

    \glossitem{multi [determinism]}\index{multi}%
A \g{predicate} is said to have \g{determinism} multi if it generates at
\emph{least} one answer.

    \glossitem{multifile [predicate]}
Predicate for which the definition is distributed over multiple
source files.  See \index{multifile/1}\predref{multifile}{1}.

    \glossitem{neck}\index{neck}%
Operator (\const{\Sneck}) separating \g{head} from \g{body} in a \g{clause}.

    \glossitem{nondet}\index{nondet}%
Short for \g{non deterministic}.

    \glossitem{non deterministic}\index{non deterministic}%
A \g{non deterministic} predicate is a predicate that mail fail or
succeed any number of times.

    \glossitem{operator}\index{operator}%
Symbol (\g{atom}) that may be placed before its \g{operand} (prefix),
after its \g{operand} (postfix) or between its two \g{operands} (infix).

In Prolog, the expression \verb$a+b$ is exactly the same as the
canonical term \verb$+(a,b)$.

    \glossitem{operand}\index{operand}%
\g{Argument} of an \g{operator}.

    \glossitem{precedence}\index{precedence}%
The \g{priority} of an \g{operator}.  Operator precedence is used
to interpret \verb$a+b*c$ as \verb$+(a, *(b,c))$.

    \glossitem{predicate}\index{predicate}%
Collection of \g{clauses} with the same \g{functor} (name/\g{arity}).
If a \g{goal} is proved, the system looks for a \g{predicate} with the
same functor, then uses \g{indexing} to select candidate \g{clauses}
and then tries these \g{clauses} one-by-one.  See also \g{backtracking}.

    \glossitem{predicate indicator}\index{predicate indicator}%
Term of the form Name/Arity (traditional) or Name//Arity (ISO
DCG proposal), where Name is an atom and Arity a non-negative integer.
It acts as an \emph{indicator} (or reference) to a predicate or
\g{DCG} rule.

    \glossitem{priority}\index{priority}%
In the context of \g{operators} a synonym for \g{precedence}.

    \glossitem{program}\index{program}%
Collection of \g{predicates}.

    \glossitem{property}\index{property}%
Attribute of an object.  SWI-Prolog defines various {\em *_property}
predicates to query the status of predicates, clauses. etc.

    \glossitem{prove}\index{prove}%
Process where Prolog attempts to prove a \g{query} using the available
\g{predicates}.

    \glossitem{public list}\index{public list}%
List of \g{predicates} exported from a \g{module}.

    \glossitem{query}
See \g{goal}.

    \glossitem{retract}\index{retract}%
Remove a \g{clause} from a \g{predicate}.  See also \g{dynamic},
\g{update view} and \g{assert}.

    \glossitem{semidet}\index{semidet}%
Shorthand for \glossitem{semi deterministic}.

    \glossitem{semi deterministic}\index{semi deterministic}%
A \g{predicate} that is \g{semi deterministic} either fails or
succeeds exactly once without a \g{choice point}.  See also
\g{deterministic}.

    \glossitem{shared}\index{shared}%
Two \g{variables} are called \g{shared} after they are \g{unified}. This
implies if either of them is \g{bound}, the other is bound to the same
value:

\begin{code}
?- A = B, A = a.
A = B, B = a.
\end{code}

\noindent
    \glossitem{singleton [variable]}\index{singleton}%
\g{Variable} appearing only one time in a \g{clause}. SWI-Prolog
normally warns for this to avoid you making spelling mistakes.  If a
variable appears on purpose only once in a clause, write it as \verb$_$
(see \g{anonymous}).  Rules for naming a variable and avoiding a warning
are given in \secref{singleton}.

    \glossitem{solution}\index{solution}%
\g{Bindings} resulting from a successfully \g{prove}n \g{goal}.

    \glossitem{structure}\index{structure}%
Synonym for \g{compound} term.

    \glossitem{string}
Used for the following representations of text: a packed array
(see \secref{strings}, SWI-Prolog specific), a list of character
codes or a list of one-character \g{atoms}.

    \glossitem{succeed}\index{succeed}%
A \g{goal} is said to have \g{succeeded} if it has been \g{proven}.

    \glossitem{term}\index{term}%
Value in Prolog. A \g{term} is either a \g{variable}, \g{atom}, \g{integer},
\g{float} or \g{compound} term.  In addition, SWI-Prolog also defines the
type \g{string}.

    \glossitem{transparent}
See \g{module transparent}.

    \glossitem{unify}\index{unify}%
Prolog process to make two terms equal by assigning variables in one
term to values at the corresponding location of the other term.  For
example:

\begin{code}
?- foo(a, B) = foo(A, b).
A = a,
B = b.
\end{code}

\noindent
Unlike assignment (which does not exist in Prolog), unification is
not directed.

    \glossitem{update view}\index{update view}\index{view,update}%
How Prolog behaves when a \g{dynamic} \g{predicate} is changed while
it is running.  There are two models.  In most older Prolog systems the
change becomes immediately visible to the \g{goal}, in modern systems
including SWI-Prolog, the running \g{goal} is not affected.  Only
new \g{goals} `see' the new definition.

    \glossitem{variable}\index{variable}%
A Prolog variable is a value that `is not yet bound'.  After \g{binding}
a variable, it cannot be modified.  \g{Backtracking} to a point in the
execution before the variable was bound will turn it back into a
variable:

\begin{code}
?- A = b, A = c.
false.

?- (A = b; true; A = c).
A = b ;
true ;
A = c .
\end{code}

\noindent
See also \g{unify}.

\end{description}
