IEC 13211-1-97:2013 (identical to ISO/IEC 13211-1:2013) defines the General Core of the Prolog programming language. It establishes the syntax, semantics, execution model, and built-in predicates that form the foundation of the logic programming paradigm. This article provides a technical overview of the standard’s scope, core requirements, implementation considerations, and compliance obligations for language implementers and application developers.
Scope
The standard specifies the general core of the Prolog language. It includes:
- Lexical and syntactic structure – character set, tokens, terms (constants, variables, compound terms), clauses, and directives.
- Data types – atomic terms (numbers, atoms) and compound terms (structures, lists).
- Execution model – goal execution, the selection rule, depth-first search with backtracking, and the cut operator.
- Unification and resolution – the algorithm for term unification and SLD-resolution.
- Built-in predicates – a comprehensive set of predefined predicates for type testing, arithmetic, term manipulation, input/output, stream control, and program reflection.
The standard does not cover:
- Module systems (deferred to ISO/IEC 13211-2).
- Constraint handling, meta-programming extensions, or object-oriented features.
- Implementation-specific optimization or concurrency.
It is designed to facilitate portable Prolog programs and to provide a common foundation for interoperable implementations.
Tip: IEC 13211-1-97:2013 is the third edition of the standard. The first edition (1995) established the baseline; the 2013 revision refined definitions, corrected ambiguities, and aligned with modern language practice. Always refer to the latest edition for conformance.
Technical Requirements
Lexical and Syntactic Conventions
The standard defines a concrete syntax based on a set of graphical and non‑graphical characters. A Prolog program consists of a sequence of clauses and directives. Terms are built from:
- Variables – start with an uppercase letter or underscore.
- Atoms – quoted or non‑quoted sequences of characters.
- Numbers – integers (decimal, hexadecimal, binary) and floating‑point.
- Compound terms – a functor (an atom) followed by a parenthesised sequence of arguments.
- Lists – syntactic sugar for the compound term
'.'/2. - Strings – a list of character codes (implementation‑defined if mapped to atom or list).
Data Types and Term Classification
| Category | Examples | Notes |
| Integer | 42, 0x1A, 0b101 | Integers are unbounded but support is implementation‑defined. |
| Float | 3.14e-2, -0.5 | Floating‑point as defined by IEC 60559. |
| Atom | hello, 'Hello World' | Any sequence of characters delimited by single quotes if needed. |
| Variable | X, _Result, _ | Anonymous variable _ denotes a distinct variable at each occurrence. |
| Compound term | f(a, b), g(X, 2.5) | Functor/arity combination uniquely identifies a term type. |
| List | [a, b, c], [], [Head | Tail] | Syntactic form; internally '.'(Head, Tail). |
| String | "Hello" | Double‑quoted character sequences are lists of character codes unless implementation defines otherwise. |
Execution Model
A Prolog program is executed by proving a conjunctive goal using a sequence of clauses. The standard mandates a depth‑first left‑to‑right search strategy:
- The selection rule chooses the leftmost subgoal.
- Clauses for a predicate are tried in the order they appear in the source (textual order).
- Backtracking occurs when a subgoal fails, reverting to the most recent choice point.
The standard specifies the behaviour of the cut (!) and the if‑then construct (->) for controlling backtracking.
Built‑in Predicates
The standard defines about 100 built‑in predicates, grouped into categories. Examples:
- Type testing:
var/1, nonvar/1, atom/1, integer/1, float/1, compound/1, atomic/1. - Term unification and comparison:
=/2, =/2, ==/2, ==/2, @, =../2 (univ). - Arithmetic:
is/2, =:=/2, =, >/2, etc. All arithmetic expressions are evaluated. - Input/output:
read/1, write/1, nl/0, get_char/1, stream operations with see/1, tell/1, and named streams. - Program reflection:
clause/2, asserta/1, retract/1, abolish/1. - Control:
call/1, catch/3, throw/1.
For several predicates the standard provides a deterministic vs. non‑deterministic specification. Conformant implementations may produce additional choice points only if they are later cut or fail.
Implementation Highlights
Implementing a conforming Prolog engine requires careful attention to several areas:
- Unification – must follow the occurs‑check semantics (though the standard permits a rational tree extension). A sound unification that checks the occurs‑check is optional; many implementations skip it for performance and rely on the programmer to avoid cyclic terms.
- Arithmetic – integers may be bounded or unbounded. Floating‑point behaviour must follow IEC 60559 (IEEE 754). The standard allows implementation‑defined overflow handling.
- Input/output – character encoding and stream buffering are not fully defined. Portability across platforms requires careful encoding handling (e.g., UTF‑8 / ISO 8859-1).
- Error handling – the standard defines error classes (
instantiation_error, type_error, domain_error, etc.) and mandates that built‑in predicates raise these under specific conditions. Implementation of error terms must conform to the ISO Prolog error term structure.
Warning: Some parts of the standard allow implementation‑defined behaviour (e.g., maximum character codes, maximal arity of compound terms, representation of integers). When writing portable code, avoid relying on such values and use built‑in predicates like max_arity/1 if available.
Compliance Notes
A Prolog implementation claiming conformance to IEC 13211-1-97:2013 must satisfy all shall requirements of the standard. Key compliance obligations include:
- Correct implementation of the entire defined syntax and semantics of the general core.
- Exact behaviour of all built‑in predicates when called with appropriate arguments – including detection of error conditions and generation of proper error terms.
- Availability of a documented processor that conforms; the processor must be accompanied by a description of any implementation‑defined features (e.g., limits on term sizes, character encoding, exception handling mechanism).
- If the implementation provides extensions (e.g., a module system or constraints), those extensions must be enabled via a distinct flag or file extension to avoid conflicts with the standard core.
Conformance is typically verified by running a comprehensive test suite. Several test suites exist, such as the ISO Prolog Test Suite maintained by the Prolog community. Implementations may also self‑certify by providing a compliance report documenting deviations.
Good Practice: Use the standard’s prolog_flag/3 mechanism to query implementation-defined properties (e.g., current_prolog_flag(bounded, B)). This helps write portable code that adapts to different implementations.
Important: An implementation that does not support unbounded integers, does not provide the full set of built‑in predicates, or uses a selection rule that violates the deterministic requirement cannot be considered conformant. Always test with official validation suites before claiming conformance.
Frequently Asked Questions
Q: What is the relationship between IEC 13211-1-97 and ISO/IEC 13211‑1?
A: They are identical. IEC 13211-1-97 is the IEC designation corresponding to the joint ISO/IEC standard ISO/IEC 13211‑1:2013. The “97” in the IEC identifier is a part–series number (not the year). The standard is also known as ISO/IEC 13211‑1:2013 (third edition).
Q: Does the standard cover Constraint Logic Programming (CLP) or concurrency?
A: No. The general core is limited to pure Prolog with built‑in predicates. CLP is addressed by other standards (e.g., ISO/IEC 13211‑3, when developed). Concurrency and parallel execution are outside the scope.
Q: How can I test whether my implementation meets the standard?
A: Use a conformance test suite such as the “ISO Prolog Test Suite” (available in the Prolog community) or the “Prolog Conformance Tests” provided by individual implementers. Run all tests without failures and ensure that error conditions produce the correct ISO‑prolog error terms.
Q: Are there tools that help ensure Prolog code is portable across conforming implementations?
A: Yes. Many Prolog systems include a compatibility flag (e.g., iso or prolog_flag(language, iso)) that restricts the system to core standard features. Additionally, linters and static checkers can flag non‑standard constructs.
Article prepared in accordance with the 2026 edition of the international standards documentation guide.