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) 2006 Cisco Systems, Inc. All Rights Reserved. 18% 19% Contributor(s): 20% 21% END LICENSE BLOCK 22 23\chapter{Review of Terminology} 24\label{terminology} 25\label{chapterm} 26 27General terms used in Prolog and \eclipse. 28\begin{description} 29% ------------------------------------------------------------------- 30\item[Arity] 31\index{arity} 32Arity is the number of arguments to a term. 33Atoms are considered as functors with zero arity. 34The notation {\it Name/Arity} is used to specify a functor of name 35{\it Name} with arity {\it Arity}. 36\index{Name/Arity} 37 38% ------------------------------------------------------------------- 39\item[Atom] 40An arbitrary name chosen by the user to represent objects from the 41problem domain. 42A Prolog {\it atom} corresponds to an identifier in other languages. 43\index{atom} 44 45% ------------------------------------------------------------------- 46\item[Atomic] 47An atom, string or a number. A terms which does not contain other terms. 48\index{atomic} 49 50% ------------------------------------------------------------------- 51\item[Body] 52A clause {\it body} can either be of the form 53\begin{verbatim} 54Goal_1, Goal_2, ..., Goal_k 55\end{verbatim} 56or simply 57\index{clause!regular} 58\begin{verbatim} 59Goal 60\end{verbatim} 61\index{clause!iterative} 62Each {\it Goal_i} must be a callable term. 63 64% ------------------------------------------------------------------- 65\item[Built-in Predicates] 66\index{procedure!built_in} 67These are predicates provided by the 68{\eclipse} system, they are either written in Prolog or in the implementation 69language (usually ``C''). 70 71 72% ------------------------------------------------------------------- 73\item[Clause] 74\index{clause} 75See program clause or goal. 76 77% ------------------------------------------------------------------- 78\item[Callable Term] 79\index{callable term} 80A {\it callable term} is either a compound term or an atom. 81 82% ------------------------------------------------------------------- 83\item[Compound Term] 84\index{compound term} 85Compound terms are of the form 86\begin{verbatim} 87f(t_1, t_2, ..., t_n) 88\end{verbatim} 89where {\it f} is the {\it functor} of the compound term 90\index{functor} 91and {\it t_i} are terms, n is its arity. Lists and Pairs are also 92compound terms. 93 94% ------------------------------------------------------------------- 95\item[Fact] 96\index{fact} 97\index{clause!unit} 98A fact or {\it unit clause} is a term of the form: 99\begin{verbatim} 100Head. 101\end{verbatim} 102\index{head!clause} 103where {\it Head} is a structure or an atom. 104\index{clause!head} 105A fact may be considered to be a rule whose body is always {\it true}. 106 107% ------------------------------------------------------------------- 108\item[Functor] 109\index{functor} 110A functor is characterised by its name which is an atom, and its arity 111which is its number of arguments. 112 113% ------------------------------------------------------------------- 114\item[Goal Clause] 115\index{clause!goal} 116\index{goal} 117See {\it query}. 118 119% ------------------------------------------------------------------- 120\item[Ground] 121\index{ground} 122A term is ground when it does not contain any uninstantiated variables. 123 124% ------------------------------------------------------------------- 125\item[Head] 126\index{head} 127A head is a structure or an atom. 128 129% ------------------------------------------------------------------- 130\item[Instantiated] 131\index{instantiated} 132A variable is instantiated when it has been bound to an atomic or a 133compound term as opposed to 134being {\it uninstantiated} or {\it free}. See also {\it ground}. 135 136 137 138% ------------------------------------------------------------------- 139\item[List] 140\index{list} 141A list is a special type of term within Prolog. It is a 142recursive data structure consisting of {\it pairs} (whose tails are lists). 143A {\tt list} is either the atom {\tt []} called {\tt nil} as in LISP, 144or a pair whose tail is a list. 145The notation : 146\begin{verbatim} 147[a , b , c] 148\end{verbatim} 149is shorthand for: 150\begin{verbatim} 151[a | [b | [c | []]]] 152\end{verbatim} 153\index{nil} 154\index{[]} 155 156 157% ------------------------------------------------------------------- 158\item[Name/Arity] 159\index{Name/Arity} 160The notation {\tt Name/Arity} is used to specify a functor of name 161{\bf Name} with arity {\bf Arity}. 162 163% ------------------------------------------------------------------- 164\item[Predicate, Procedure] 165\index{predicate} 166\index{procedure} 167The most important unit of a Prolog or {\eclipse} program. 168Defined by the set of clauses whose {\bf Head} has the same functor. 169Although often used as synonyms, the word {\it predicate} 170highlights more the declarative meaning while the word {\it procedure} 171reminds of the operational behaviour of the definition. 172 173 174% ------------------------------------------------------------------- 175\item[Program Clause] 176A {\it program clause} or {\it clause} is either the term 177\index{clause} 178\index{program clause} 179\index{clause!program} 180\begin{verbatim} 181Head :- Body. 182\end{verbatim} 183\index{body} 184i.e. a compound term with the functor {\it :-/2}, or only a fact. 185 186% ------------------------------------------------------------------- 187\item[Query] 188A query has the same form as {\it Body} 189and is also called a {\it goal}. 190\index{query} 191Such clauses occur mainly as input to the top level Prolog loop 192and in files being compiled, then they have the form 193\begin{verbatim} 194:- Goal_1, ..., Goal_k. 195\end{verbatim} 196or 197\begin{verbatim} 198?- Goal_1, ..., Goal_k. 199\end{verbatim} 200 201% ------------------------------------------------------------------- 202\item[Structures] 203Compound terms which are not pairs are also called {\it structures}. 204\index{structure} 205 206% ------------------------------------------------------------------- 207\item[Term] 208A {\it term} is the basic data type in Prolog. 209\index{term} 210It is either a {\it variable}, a {\it constant}, 211i.e. an {\it atom}, a {\it number} or a {\it string}, 212\index{string} 213\index{number} 214or a {\it compound term}. 215 216% ------------------------------------------------------------------- 217\item[+X] 218\index{+X} 219Used in predicate descriptions, this denotes an input argument. 220Such an argument must be instantiated before the predicate is called. 221 222% ------------------------------------------------------------------- 223\item[$-$X] 224\index{$-$X} 225Used in predicate descriptions, this denotes an output argument. 226Such an argument must be not instantiated before the predicate is called. 227 228% ------------------------------------------------------------------- 229\item[?X] 230\index{?X} 231Used in predicate descriptions, this denotes an input or an output argument. 232Such an argument may be either 233instantiated or not when the predicate is called. 234 235% ------------------------------------------------------------------- 236\end{description} 237 238