1% BEGIN LICENSE BLOCK
2% Version: CMPL 1.1
3%
4% The contents of this file are subject to the Cisco-style Mozilla Public
5% License Version 1.1 (the "License"); you may not use this file except
6% in compliance with the License.  You may obtain a copy of the License
7% at www.eclipse-clp.org/license.
8%
9% Software distributed under the License is distributed on an "AS IS"
10% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See
11% the License for the specific language governing rights and limitations
12% under the License.
13%
14% The Original Code is  The ECLiPSe Constraint Logic Programming System.
15% The Initial Developer of the Original Code is  Cisco Systems, Inc.
16% Portions created by the Initial Developer are
17% Copyright (C) 1994 - 2006 Cisco Systems, Inc.  All Rights Reserved.
18%
19% Contributor(s):
20%
21% END LICENSE BLOCK
22%
23% @(#)umsterm.tex	1.3 94/01/11
24%
25%
26% umsterm.tex
27%
28% REL	DATE	AUTHOR		DESCRIPTION
29% 2.10	080489	David Miller 	convert to Latex and update for rel 2.10
30%
31\chapter{Terminology}
32\label{terminology}
33\label{chapterm}
34%HEVEA\cutdef[1]{section}
35
36This chapter defines the terminology which is used throughout the manual and
37in related documentation.
38
39\begin{description}
40
41% -------------------------------------------------------------------
42\item[\Index{+X}]
43This denotes an input argument. Such an argument must be instantiated before
44a built-in is called.
45
46% -------------------------------------------------------------------
47\item[\Index{++X}]
48This denotes a ground argument. Such an argument can be complex,
49but must be fully instantiated, i.e., not contain any variables.
50
51% -------------------------------------------------------------------
52\item[\Index{--X}]
53This denotes an output argument. Such an argument must be not
54instantiated before a built-in is called.
55
56% -------------------------------------------------------------------
57\item[\Index{?X}]
58This denotes an input or an output argument. Such an argument may be either
59instantiated or not  when a built-in is called.
60
61% -------------------------------------------------------------------
62%\item[Array]
63%\index{Array}
64%An array specification is a compound term the form Name(Dim_1,...,Dim_n),
65%where Name is the array name, the arity denotes the number of dimensions and
66%the arguments are integers indicating the size in each dimension.
67%An array element is selected with a similar term.
68
69% -------------------------------------------------------------------
70\item[Arity\index{arity}]
71Arity is the number of arguments to a term.
72Atoms are considered as functors with zero arity.
73The notation \patternidx{Name/Arity}
74is used to specify a functor by giving its name and arity.
75
76% -------------------------------------------------------------------
77\item[Atom\index{atom}]
78An arbitrary name chosen by the user to represent objects from the
79problem domain.
80A Prolog atom corresponds to an identifier in other languages.  It can be
81written as a conventional identifier (beginning with a lower-case letter), or
82a character sequnce enclosed in single quotes.
83
84% -------------------------------------------------------------------
85\item[Atomic\index{atomic}]
86An atom, string or a number. A term which does not contain other terms.
87
88% -------------------------------------------------------------------
89\item[Body\index{body of a clause}\index{clause!body}]
90A clause body can either be of the form
91\begin{quote}
92\begin{verbatim}
93Goal_1, Goal_2, ..., Goal_k
94\end{verbatim}
95\end{quote}
96or simply
97\begin{quote}
98\begin{verbatim}
99Goal
100\end{verbatim}
101\end{quote}
102Each \about{Goal_i} must be a \about{callable term}.
103
104% -------------------------------------------------------------------
105\item[Built-in Procedures\index{built_in procedure}\index{procedure!built_in}]
106These are predicates provided for the user by the
107{\eclipse} system, they are either written in Prolog or in the implementation
108language (usually C).
109
110% -------------------------------------------------------------------
111\item[Callable Term\index{callable term}\index{term!callable}]
112A callable term is either a compound term or an atom.
113
114% -------------------------------------------------------------------
115\item[Clause\index{clause}]
116See \about{program clause} or \about{goal clause}.
117
118% -------------------------------------------------------------------
119\item[Compound Term\index{compound term}\index{term!compound}]
120Compound terms are of the form
121\begin{quote}
122\begin{verbatim}
123f(t_1, t_2, ..., t_n)
124\end{verbatim}
125\end{quote}
126where \about{f} is the \aboutidx{functor} of the compound term, \about{n} is its
127arity and \about{t_i} are terms.
128\about{Lists} and \about{pairs} are also compound terms.
129
130% -------------------------------------------------------------------
131\item[Constant\index{constant}\index{term!constant}]
132An \about{atom}, a \about{number} or a \about{string}.
133
134% -------------------------------------------------------------------
135\item[Determinism\index{determinism}]
136The determinism specification of a built-in or library predicate says
137how many solutions the predicate can have, and whether it can fail.
138The six determinism groups are defined as follows:
139\begin{quote}
140\begin{verbatim}
141                |   Maximum number of solutions
142    Can fail?   |   0               1               > 1
143    ------------+------------------------------------------
144    no          |   erroneous       det             multi
145    yes         |   failure         semidet         nondet
146\end{verbatim}
147\end{quote}
148This classification is borrowed from the Mercury programming language,
149but in {\eclipse} only used for the purpose of documentation.
150Note that the determinism of a predicate usually depends on its calling mode.
151
152% -------------------------------------------------------------------
153\item[\Index{DID}\index{dictionary identifier}]
154Each atom created within {\eclipse} is assigned a unique
155identifier called the \about{dictionary identifier} or \about{DID}.
156
157% -------------------------------------------------------------------
158\item[Difference List\index{difference list}\index{list!difference}]
159A difference list is a special kind of a list.
160Instead of being ended by \about{nil}, a difference list
161has an uninstantiated tail so that new elements
162can be appended to it in constant time.
163A difference list is written as \about{List - Tail}
164where \about{List} is the beginning of the list and \about{Tail}
165is its uninstantiated tail.
166Programs that use difference lists are usually more efficient
167and always much less readable than programs without them.
168
169% -------------------------------------------------------------------
170\item[Dynamic Procedure\index{dynamic procedure}\index{procedure!dynamic}]
171These are procedures which can be modified clause-wise, by adding or removing
172one clause at a time. Note that this class of procedure is equivalent to
173interpreted procedures in other Prolog systems. See also \about{static
174procedures}.
175
176%% -------------------------------------------------------------------
177%\item[ElemSpec]
178%\index{array}
179%An \about{ElemSpec} specifies a global variable (an atom) or an array
180%element (a ground compound term with as much arguments (integers) as
181%the number of dimensions of the array).
182
183% -------------------------------------------------------------------
184\item[External Procedures\index{external procedure}\index{procedure!external}]
185These are procedures which are defined in a language
186other than Prolog, and explicitly connected to Prolog predicates by the user.
187
188% -------------------------------------------------------------------
189\item[Fact\index{fact}]
190A fact or \aboutidx{unit clause}\index{clause!unit} is a term of the form:
191\begin{quote}
192\begin{verbatim}
193Head.
194\end{verbatim}
195\end{quote}
196where \notation{Head} is a \about{head}.
197
198A fact may be considered to be a rule whose body is always \about{true}.
199
200% -------------------------------------------------------------------
201\item[Functor\index{functor}]
202A functor is characterised by its name (which is an atom), and its arity
203(which is its number of arguments).
204
205% -------------------------------------------------------------------
206\item[Goal Clause\index{clause!goal}\index{goal}]
207See \about{query}.
208
209% -------------------------------------------------------------------
210\item[Ground\index{ground term}\index{term!ground}]
211A term is ground when it does not contain any uninstantiated variables.
212
213% -------------------------------------------------------------------
214\item[Head\index{head of a clause}\index{clause!head}]
215A clause head is a structure or an atom.
216
217% -------------------------------------------------------------------
218\item[Instantiated\index{instantiated variable}\index{variable!instantiated}]
219A variable is instantiated when it has been bound to an atomic or a
220compound term as opposed to being \about{uninstantiated}%
221\index{uninstantiated variable}\index{variable!uninstantiated}
222or \about{free}\index{free variable}\index{variable!free}.
223See also \about{ground}.
224
225
226% -------------------------------------------------------------------
227\item[List\index{list}]
228A list is a special type of term within Prolog. It is a
229recursive data structure consisting of \about{pairs} (whose tails are lists).
230A \about{list} is either the atom \notationidx{[]} called \notationidx{nil}
231as in LISP,
232or a pair whose tail is a list.
233The notation :
234\begin{quote}
235\begin{verbatim}
236[a , b , c]
237\end{verbatim}
238\end{quote}
239is shorthand for:
240\begin{quote}
241\begin{verbatim}
242[a | [b | [c | []]]]
243\end{verbatim}
244\end{quote}
245
246% -------------------------------------------------------------------
247\item[Mode\index{mode}]
248A predicate mode is a particular instantiation pattern of its arguments
249at call time.  Such a pattern is usually written as a predicate template, e.g.,
250\begin{quote}
251\begin{verbatim}
252    p(+,-)
253\end{verbatim}
254\end{quote}
255where the symbols \notation{+}, \notation{++}, \notation{-} and \notation{?}
256represent
257instantiated, ground, uninstantiated and unknown arguments respectively.
258
259% -------------------------------------------------------------------
260\item[Name/Arity]
261The notation \patternidx{Name/Arity} is used to specify a functor by giving its
262name and arity.
263
264% -------------------------------------------------------------------
265\item[Number\index{number}]
266A number literal denotes a number, more or less like in all programming
267languages.
268
269% -------------------------------------------------------------------
270\item[Pair\index{pair}]
271A pair is a compound term with the functor \predspec{./2} (dot)
272which is written as :
273\begin{quote}
274\begin{verbatim}
275[H|T]
276\end{verbatim}
277\end{quote}
278\about{H} is the \defnotionni{head}\index{head of a pair}\index{pair!head}
279of the pair and \about{T} its
280\defnotionni{tail}\index{tail of a pair}\index{pair!tail}.
281
282
283% -------------------------------------------------------------------
284%\item[Permanent Procedures]
285%\index{procedure!permanent}
286%These are procedures which cannot be changed in any way, they are statically
287%linked to other procedure's calls.
288%
289% -------------------------------------------------------------------
290\item[Predicate\index{predicate}]
291A predicate is another term for a \about{procedure}.
292
293% -------------------------------------------------------------------
294\item[\Index{PredSpec}]
295This is similar to \pattern{Name/Arity}.
296Some built-ins allow the arity to be omitted and to specify the name only:
297this stands for all (visible) predicates with that name and any arity.
298
299% -------------------------------------------------------------------
300\item[Program Clause\index{clause}\index{program clause}\index{clause!program}]
301A program clause (or simply \about{clause}) is either the term
302\begin{quote}
303\begin{verbatim}
304Head :- Body.
305\end{verbatim}
306\end{quote}
307\index{body}
308(i.e., a compound term with the functor \predspec{:-/2}), or only a fact.
309
310% -------------------------------------------------------------------
311\item[Query\index{query}]
312A query  has the same form as a \about{body} and is also called a \about{goal}.
313Such clauses occur mainly as input to the top level Prolog loop
314and in files being compiled, then they have the form
315\begin{quote}
316\begin{verbatim}
317:- Goal_1, ..., Goal_k.
318\end{verbatim}
319\end{quote}
320or
321\begin{quote}
322\begin{verbatim}
323?- Goal_1, ..., Goal_k.
324\end{verbatim}
325\end{quote}
326The first of these two forms is often called a \aboutidx{directive}.
327
328% -------------------------------------------------------------------
329\item[Regular Prolog Procedure%
330\index{regular procedure}\index{procedure!regular}]
331
332A regular (Prolog) procedure is a sequence of user clauses whose heads
333have the same functor, which then identifies the user procedure.
334
335
336% -------------------------------------------------------------------
337\item[Simple Procedures\index{simple procedure}\index{procedure!simple}]
338Apart from regular procedures {\eclipse} recognises simple procedures
339which are written not in Prolog but in the implementation language (i.e., C),
340and which are deterministic.
341There is a functor associated with each
342simple procedure, so that
343any procedure recognisable by {\eclipse} is identified by a functor,
344\index{functor!of a procedure}\index{procedure!functor}
345or by a compound term (or atom) with this functor.
346
347% -------------------------------------------------------------------
348\item[\Index{SpecList}]
349The SpecList notation means a sequence of \about{PredSpec} terms of the form:
350\begin{quote}
351\begin{verbatim}
352name_1/arity_1, name_2/arity_2, ..., name_k/arity_k.
353\end{verbatim}
354\end{quote}
355The SpecList notation is used in many built-ins, for example,
356to specify a list of procedures in the
357\bipref{export/1}{../bips/kernel/modules/export-1.html} predicate.
358
359% -------------------------------------------------------------------
360\item[Static Procedures\index{static procedure}\index{procedure!static}]
361These are procedures which can only be changed as a whole unit, i.e., removed or
362replaced.
363
364% -------------------------------------------------------------------
365\item[Stream\index{stream}]
366This is an I/O channel identifier and can be a physical stream number, one of
367the predefined stream identifiers (\notation{input}, \notation{output},
368\notation{error}, \notation{warning_output}, \notation{log_output},
369\notation{null})
370or a user defined stream name (defined using
371\bipref{set_stream/2}{../bips/kernel/iostream/set_stream-2.html} or
372 \bipref{open/3}{../bips/kernel/iostream/open-3.html}).
373
374% -------------------------------------------------------------------
375\item[String\index{string}]
376A string is similar to those found in all other programming languages.  A string
377is enclosed in double quotes.
378
379% -------------------------------------------------------------------
380\item[Structure\index{structure}]
381Compound terms which are not pairs are also called \about{structures}.
382
383% -------------------------------------------------------------------
384\item[Term\index{term}]
385A term is the basic data type in Prolog.
386It is either a \about{variable}, a \about{constant} or a \about{compound term}.
387
388% -------------------------------------------------------------------
389\item[Variable\index{variable}\index{term!variable}]
390A variable is more similar to a mathematical variable than to a variable in some
391imperative language.  It can be free, or instantiated to a term, but once
392instantiated it becomes indistinguishable from the term to which it was
393instantiated: in particular, it cannot become free again (except upon
394backtracking through the point of instantiation).
395The name of a variable is written in the form of an identifier that begins with
396an upper-case letter or with an underscore.  A single underscore represents an
397\aboutidx{anonymous variable}\index{variable!anonymous} that has only one
398occurrence (i.e., another occurrence of this name represents another variable).
399
400% -------------------------------------------------------------------
401\end{description}
402
403The notation \pattern{Pred/N1, N2} is often used in this documentation
404as a shorthand for \pattern{Pred/N1, Pred/N2}.
405
406%HEVEA\cutend
407