4 Built-in Predicates
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • Built-in Predicates
        • Notation of Predicate Descriptions
        • Character representation
        • Loading Prolog source files
        • Editor Interface
        • List the program, predicates or clauses
        • Verify Type of a Term
        • Comparison and Unification of Terms
        • Control Predicates
        • Meta-Call Predicates
        • Delimited continuations
        • Exception handling
        • Handling signals
        • DCG Grammar rules
        • Database
        • Declaring predicate properties
        • Examining the program
        • Input and output
        • Status of streams
        • Primitive character I/O
        • Term reading and writing
        • Analysing and Constructing Terms
        • Analysing and Constructing Atoms
        • Localization (locale) support
        • Character properties
        • Operators
        • Character Conversion
        • Arithmetic
        • Misc arithmetic support predicates
        • Built-in list operations
        • Finding all Solutions to a Goal
        • Forall
        • Formatted Write
        • Global variables
        • Terminal Control
        • Operating System Interaction
        • File System Interaction
        • User Top-level Manipulation
        • Creating a Protocol of the User Interaction
        • Debugging and Tracing Programs
        • Obtaining Runtime Statistics
        • Execution profiling
        • Memory Management
        • Windows DDE interface
        • Miscellaneous
    • Packages

4.1 Notation of Predicate Descriptions

We have tried to keep the predicate descriptions clear and concise. First, the predicate name is printed in bold face, followed by the arguments in italics. Arguments are preceded by a mode indicator. There is no complete agreement on mode indicators in the Prolog community. We use the following definitions:44These definitions are taken from PlDoc. The current manual has only one mode declaration per predicate and therefore predicates with mode (+,-) and (-,+) are described as (?,?). The @-mode is often replaced by +.

++Argument must be ground, i.e., the argument may not contain a variable anywhere.
+Argument must be fully instantiated to a term that satisfies the type. This is not necessarily ground, e.g., the term [_] is a list, although its only member is unbound.
-Argument is an output argument. Unless specified otherwise, output arguments need not to be unbound. For example, the goal findall(X, Goal, [T]) is good style and equivalent to findall(X, Goal, Xs), Xs = [T]45The ISO standard dictates that findall(X, Goal, 1) raises a type_error exception, breaking this semantic relation. SWI-Prolog does not follow the standard here. Note that the determinism specification, e.g., ``det'' only applies if this argument is unbound.
--Argument must be unbound. Typically used by predicates that create `something' and return a handle to the created object, such as open/3 which creates a stream.
?Argument must be bound to a partial term of the indicated type. Note that a variable is a partial term for any type. Think of the argument as either input or output or both input and output. For example, in stream_property(S, reposition(Bool)), the reposition part of the term is input and the uninstantiated Bool is output.
:Argument is a meta-argument. Implies +. See chapter 6 for more information on module handling.
@Argument is not further instantiated. Typically used for type tests.
!Argument contains a mutable structure that may be modified using setarg/3 or nb_setarg/3.

Referring to a predicate in running text is done using a predicate indicator. The canonical and most generic form of a predicate indicator is a term <module>:<name>/<arity>. If the module is irrelevant (built-in predicate) or can be inferred from the context it is often omitted. Compliant to the ISO standard draft on DCG (see section 4.13), SWI-Prolog also allows for [<module>]:<name>//<arity> to refer to a grammar rule. For all non-negative arity, <name>//<arity> is the same as <name>/<arity>+2, regardless of whether or not the referenced predicate is defined or can be used as a grammar rule. The //-notation can be used in all places that traditionally allow for a predicate indicator, e.g., the module declaration, spy/1, and dynamic/1.