A Prolog program consists of a set of Prolog clauses. It is possible to put all clauses of a Prolog program inside a single file but usually it is better to divide them over several files and modules.
The set of all clauses available to the Prolog interpreter is called the clausebase. The clausebase is divided into one or more modules. If a file is loaded and compiled by Trinc-Prolog then it becomes a module, but each file with Prolog clauses is not a separate Prolog module, i.e. a Prolog module can consist of one or more source files with Prolog clauses. It is possible to include other files into a single module. By including other files it is very easy to re-use Prolog source code.
The logical structure of the clausebase is:
![]() |
To be able to distinguish between different loaded modules it is necessary to specify a unique name to each module when it is being created. Many built-in predicates like close_module/1 use this name to identify a module with clauses.
Only one module inside the clausebase is the active module, usually this is the module that was opened most recently. The active module can be set with the built-in predicate set_active_module/1. The active module is the module where the search for a clause is started if no previous match was found for the clause. So Trinc-Prolog starts searching for a goal, if it is not a built-in predicate or operator, in the module that is the active module of the clausebase.