- Reference manual
- Initialising and Managing a Prolog Project
- Built-in Predicates
- SWI-Prolog extensions
- Tabled execution (SLG resolution)
- Constraint Logic Programming
- CHR: Constraint Handling Rules
- Multithreaded applications
- Coroutining using Prolog engines
- Foreign Language Interface
- Deploying applications
- The SWI-Prolog library
- Hackers corner
- Compatibility with other Prolog dialects
- Glossary of Terms
- SWI-Prolog License Conditions and Tools
- Reference manual
- anonymous [variable]
_is called the anonymous variable. Multiple occurrences of
_in a single term are not shared.
- Arguments are terms
that appear in a compound term. A1
and a2 are the first and second argument of the term
- Argument count (= number of arguments) of a compound term.
- 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.
- Textual constant. Used as name for compound terms, to represent constants or text.
- 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.
- Part of a clause
behind the neck
- 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).
- `Sentence' of a Prolog program. A clause
consists of a head
body separated by
the neck operator (
) or it is a fact. For example:
parent(X) :- father(X, _).
- 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.
- Abbreviation for Definite Clause Grammar.
- det [determinism]
- Short for deterministic.
- 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).
- 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].
without a body.
This is called a fact because, interpreted as logic, there is no
condition to be satisfied. The example below states
johnis a person.
- A goal is said to haved failed if it could not be proven.
- Computer's crippled representation of a real number. Represented as `IEEE double'.
- Computer code expressed in languages other than Prolog. SWI-Prolog can only cooperate directly with the C and C++ computer languages.
- 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
- 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.
- Indexing technique used for quick lookup.
- Part of a clause
before the neck
). 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 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.18.
- 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.
- 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).
- 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.
- 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.
- Operator (
) separating head from body in a clause.
- Short for non deterministic.
- non deterministic
- A non deterministic predicate is a predicate that mail fail or succeed any number of times.
- Symbol (atom)
that may be placed before its operand
(prefix), after its operand
(postfix) or between its two operands
In Prolog, the expression
a+bis exactly the same as the canonical term
- Argument of an operator.
- The priority
of an operator.
Operator precedence is used to interpret
- 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.
- In the context of operators a synonym for precedence.
- Collection of predicates.
- Attribute of an object. SWI-Prolog defines various *_property predicates to query the status of predicates, clauses. etc.
- Process where Prolog attempts to prove a query using the available predicates.
- public list
- List of predicates exported from a module.
- See goal.
- Remove a clause from a predicate. See also dynamic, update view and assert.
- 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.
- 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]
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
_(see anonymous). Rules for naming a variable and avoiding a warning are given in section 188.8.131.52.
- Bindings resulting from a successfully proven goal.
- Synonym for compound term.
- 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.
- A goal is said to have succeeded if it has been proven.
- Value in Prolog. A term is either a variable, atom, integer, float or compound term. In addition, SWI-Prolog also defines the type string.
- See module transparent.
- 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.
- 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.