Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
The ISO/IEC 13211 series defines the international standard for the logic programming language Prolog. While Part 1 of this series establishes the core language syntax, semantics, and built-in predicates, Part 2—widely adopted internationally as IEC 13211-2-02—addresses the critical requirement for program structuring through a formally defined module system. This article explores the architectural principles, technical requirements, and compliance landscape of this enduring standard, which remains foundational for engineering large-scale logic-based systems, knowledge bases, and artificial intelligence applications.
ISO/IEC 13211-2 (originally published in 2000 and adopted as CAN/CSA-ISO-IEC 13211-2-02) specifies a module system that extends the requirements of Core Prolog defined in Part 1. The standard is designed to provide a minimal yet complete set of mechanisms for encapsulation, namespace management, and interface control in Prolog programs. It covers the representation and semantics of module declarations, import and export mechanisms, meta-predicate annotations, and the operational semantics of qualified goal execution across module boundaries. The scope specifically excludes object-oriented extensions, focusing strictly on predicate-level modularity.
The standard serves as a baseline for portability. By adhering to the IEC 13211-2-02 specification, developers can design program libraries and components that interoperate across compliant Prolog systems without sacrificing the declarative nature of the language.
Every module must be explicitly declared using the module/2 directive, which defines the module name and its public interface (export list). Predicates not listed in the export list are considered private. The import mechanism relies on the use_module/1 and use_module/2 directives. The standard mandates that an imported predicate brings the public definition of another module into the importing module’s namespace, resolving naming conflicts through explicit qualification or import lists.
A key technical feature of the standard is the qualified goal syntax (Module:Goal). This allows a predicate in one module to be called irrespective of whether it has been imported into the current context. The standard strictly defines the resolution order for qualified calls, ensuring that the explicit module qualifier takes precedence over any imported or local definitions.
To correctly propagate module context to arguments that represent goals or closures (e.g., call/1, findall/3), ISO/IEC 13211-2 introduces the meta_predicate/1 directive. This is a critical requirement for maintaining referential transparency in higher-order logic programming. The standard defines specific indices for meta-arguments (e.g., 0 for a goal, ^ for existential quantification).
| Directive / Concept | Standard Requirement | Syntax Example |
|---|---|---|
module/2 | Declares the module name and public export list. Must be the first term in the source file. | :- module(db, [connect/2, query/3]). |
use_module/1 | Imports all public predicates from the specified module. | :- use_module(library(error)). |
use_module/2 | Imports only the listed predicates from the specified module. | :- use_module(db, [connect/2]). |
reexport/1 | Imports and immediately re-exports the public predicates of another module. | :- reexport(library(http)). |
meta_predicate/1 | Declares meta-arguments that require contextual module expansion. | :- meta_predicate foldl(3, +, -, -). |
While the IEC 13211-2-02 standard defines a baseline, various Prolog systems extend this model. For example, SWI-Prolog offers an autoloading mechanism and a more sophisticated packager system, while SICStus Prolog provides a strict, file-level module system that is largely considered the closest reference implementation to the standard. GNU Prolog implements a subset aligned with the standard but without some of the more advanced meta-predicate expansions.
module/2, use_module/2, and meta_predicate/1. Relying on system-specific features like autoloading or dynamic module creation can break conformance with the core standard. lists:append/3) in qualified calls. This eliminates ambiguity and improves code maintainability across large teams. use_module/1 (without an explicit import list) imports all public symbols. This can rapidly pollute the namespace and lead to dynamic area overflows or spurious predicate clashes. Always explicitly import only the predicates required. Verifying conformance to ISO/IEC 13211-2 requires a Prolog system to pass a specific suite of conformance tests established by the ISO working group. These tests evaluate the correct behavior of module loading, qualified delegation, meta-predicate context, and operator scope propagation.
The IEC 13211-2-02 designation corresponds to the Canadian national adoption (CAN/CSA-ISO/IEC 13211-2-02), which is technically identical to the international standard. Implementers seeking certification should reference this national adoption for regional compliance requirements, particularly in government or defense projects requiring explicit standards adherence.
Another frequent deviation involves operator declarations. The standard specifies that operator declarations are local to the module in which they are defined unless explicitly imported. Failure to manage operator scope consistently is a leading cause of syntax errors in multi-module Prolog systems.
© 2026 International Technical Standards Review. All rights reserved. This article provides an independent technical analysis and is not affiliated with ISO, IEC, or CSA.