# D Glossary of Terms

anonymous [variable]
  The variable `_` is called the anonymous variable. Multiple occurrences of `_` in a single term are not shared.
arguments
  Arguments are terms that appear in a compound term. A1 and a2 are the first and second argument of the term `myterm(A1, a2)`.
arity
  Argument count (= number of arguments) of a compound term.
assert
  Add a clause to a predicate. Clauses can be added at either end of the clause-list of a predicate. See asserta/1 and assertz/1.
atom
  Textual constant. Used as name for compound terms, to represent constants or text.
backtracking
  Search process used by Prolog. If a predicate offers multiple clauses to solve a goal, they are tried one-by-one until one succeeds. If a subsequent part of the proof is not satisfied with the resulting variable binding, it may ask for an alternative solution (= binding of the variables), causing Prolog to reject the previously chosen clause and try the next one.
binding [of a variable]
  Current value of the variable. See also backtracking and query.
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 redefine_system_predicate/1.
body
  Part of a clause behind the neck operator (``:-``).
choice point
  A choice point represents a choice in the search for a solution. Choice points are created if multiple clauses match a query or using disjunction (;/2). On backtracking, the execution state of the most recent choice point is restored and search continues with the next alternative (i.e., next clause or second branch of ;/2).
clause
  ‘Sentence’of a Prolog program. A clause consists of a head and body separated by the neck operator (``:-``) or it is a fact. For example:

      parent(X) :-
              father(X, _).

  Expressed as “X is a parent if X is a father of someone” . See also variable and predicate.

compile
  Process where a Prolog program is translated to a sequence of instructions. See also interpreted. SWI-Prolog always compiles your program before executing it.
compound [term]
  Also called structure. It consists of a name followed by N arguments, each of which are terms. N is called the arity of the term.
context module
  If a term is referring to a predicate in a module, the context module is used to find the target module. The context module of a goal is the module in which the predicate is defined, unless this predicate is module transparent, in which case the context module is inherited from the parent goal. See also module_transparent/1 and meta-predicate.
dcg
  Abbreviation for Definite Clause Grammar.
det [determinism]
  Short for deterministic.
determinism
  How many solutions a goal can provide. Values are‘nondet’(zero to infinite),‘multi’(one to infinite),‘det’(exactly one) and‘semidet’(zero or one).
deterministic
  A predicate is deterministic if it succeeds exactly one time without leaving a choice point.
dynamic [predicate]
  A dynamic predicate is a predicate to which clauses may be asserted and from which clauses may be retracted while the program is running. See also update view.
exported [predicate]
  A predicate is said to be exported from a module if it appears in the public list. This implies that the predicate can be imported into another module to make it visible there. See also use_module/[1,2].
fact
  Clause without a body. This is called a fact because, interpreted as logic, there is no condition to be satisfied. The example below states `john` is a person.

      person(john).

fail
  A goal is said to have failed if it could not be proven.
float
  Computer's crippled representation of a real number. Represented as‘IEEE double’.
foreign
  Computer code expressed in languages other than Prolog. SWI-Prolog can only cooperate directly with the C and C++ computer languages.
functor
  Combination of name and arity of a compound term. The term `foo(a, b, c)` is said to be a term belonging to the functor foo/3 . foo/0 is used to refer to the atom `foo`.
goal
  Question stated to the Prolog engine. A goal is either an atom or a compound term. A goal either succeeds, in which case the variables in the compound terms have a binding, or it fails if Prolog fails to prove it.
hashing
  Indexing technique used for quick lookup.
head
  Part of a clause before the neck operator (``:-``). This is an atom or compound term.
imported [predicate]
  A predicate is said to be imported into a module if it is defined in another module and made available in this module. See also chapter 6.
indexing
  Indexing is a technique used to quickly select candidate clauses of a predicate for a specific goal. In most Prolog systems, indexing is done (only) on the first argument of the head. If this argument is instantiated to an atom, integer, float or compound term with functor, hashing is used to quickly select all clauses where the first argument may unify with the first argument of the goal. SWI-Prolog supports just-in-time and multi-argument indexing. See section 2.17.
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 current_prolog_flag/2, flags bounded, max_integer and min_integer.
interpreted
  As opposed to compiled, interpreted means the Prolog system attempts to prove a goal by directly reading the clauses rather than executing instructions from an (abstract) instruction set that is not or only indirectly related to Prolog.
instantiation [of an argument]
  To what extend a term is bound to a value. Typical levels are‘unbound’(a variable),‘ground’(term without variables) or‘partially bound’(term with embedded variables).
meta-predicate
  A predicate that reasons about other predicates, either by calling them, (re)defining them or querying properties.
mode [declaration]
  Declaration of an argument instantiation pattern for a predicate, often accompanied with a determinism.
module
  Collection of predicates. Each module defines a name-space for predicates. built-in predicates are accessible from all modules. Predicates can be published (exported) and imported to make their definition available to other modules.
module transparent [predicate]
  A predicate that does not change the context module. Sometimes also called a meta-predicate.
multi [determinism]
  A predicate is said to have determinism multi if it generates at least one answer.
multifile [predicate]
  Predicate for which the definition is distributed over multiple source files. See multifile/1.
neck
  Operator (``:-``) separating head from body in a clause.
nondet
  Short for non deterministic.
non deterministic
  A non deterministic predicate is a predicate that may fail or succeed any number of times.
operator
  Symbol (atom) that may be placed before its operand (prefix), after its operand (postfix) or between its two operands (infix).

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

operand
  Argument of an operator.
precedence
  The priority of an operator. Operator precedence is used to interpret `a+b*c` as `+(a, *(b,c))`.
predicate
  Collection of clauses with the same functor (name/arity). If a goal is proved, the system looks for a predicate with the same functor, then uses indexing to select candidate clauses and then tries these clauses one-by-one. See also backtracking.
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 indicator (or reference) to a predicate or DCG rule.
priority
  In the context of operators a synonym for precedence.
program
  Collection of predicates.
property
  Attribute of an object. SWI-Prolog defines various *_property predicates to query the status of predicates, clauses. etc.
prove
  Process where Prolog attempts to prove a query using the available predicates.
public list
  List of predicates exported from a module.
query
  See goal.
retract
  Remove a clause from a predicate. See also dynamic, update view and assert.
semidet
  Shorthand for
semi deterministic
  .
semi deterministic
  A predicate that is semi deterministic either fails or succeeds exactly once without a choice point. See also deterministic.
shared
  Two variables are called shared after they are unified. This implies if either of them is bound, the other is bound to the same value:

      ?- A = B, A = a.
      A = B, B = a.

singleton [variable]
  Variable appearing only one time in a 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 `_` (see anonymous). Rules for naming a variable and avoiding a warning are given in section 2.15.1.10.
solution
  Bindings resulting from a successfully proven goal.
structure
  Synonym for compound term.
string
  Used for the following representations of text: a packed array (see section 5.2, SWI-Prolog specific), a list of character codes or a list of one-character atoms.
succeed
  A goal is said to have succeeded if it has been proven.
term
  Value in Prolog. A term is either a variable, atom, integer, float or compound term. In addition, SWI-Prolog also defines the type string.
transparent
  See module transparent.
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:

      ?- foo(a, B) = foo(A, b).
      A = a,
      B = b.

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

update view
  How Prolog behaves when a dynamic predicate is changed while it is running. There are two models. In most older Prolog systems the change becomes immediately visible to the goal, in modern systems including SWI-Prolog, the running goal is not affected. Only new goals ‘see’the new definition.
variable
  A Prolog variable is a value that‘is not yet bound’. After binding a variable, it cannot be modified. Backtracking to a point in the execution before the variable was bound will turn it back into a variable:

      ?- A = b, A = c.
      false.

      ?- (A = b; true; A = c).
      A = b ;
      true ;
      A = c .

  See also unify.