Each predicate in the Prolog system, whether built-in or user defined, belongs to a module. A predicate is generally only visible in the module where it is defined. However a predicate may be imported by another module. It is thereby made visible in that module too. Built-in predicates are visible in every module. Predicates declared as public in a module declaration (see below) are exported. Normally only public predicates may be imported by another module. For any given goal, the source module is the module in which the corresponding predicate must be visible. Similarly, for any given clause, the source module of its head is the module into which the clause is loaded.
For goals occurring in a source file with a module
declaration, the source module is the declared module.
For goals occurring in a source file without a module
declaration, the source module is the module that the
file is being loaded into. For goals typed at the
top-level, the source module is the type-in module. The
type-in module is by default the user
module but may
be changed by the built-in predicate module/1
.
The other predefined module is the prolog
module
where all the built-in predicates reside. The exported
built-in predicates are automatically imported into each new
module as it is created.