Skip to content

ISO Prolog Compatibility Report

Re-measured on engine main at e7a59c8f, 2026-10-16. Every goal on this page was run through the .pl front end, and a sample through .clausal; both gave the same answer for every goal sampled. The previous edition was measured at 9fe1ee48 on 2026-09-28. Earlier editions (March 2026) recorded design decisions taken with Markus Triska; their outcome is summarised under History.

For practical instructions on importing and running Prolog programs, see Importing Prolog Code. For why we measure against ISO and the order of authority we use (Ulrich Neumerkel's conformity tables first, then the standard text, then Scryer), see ISO Prolog Conformity.

Two Prolog dialects, one standard

Clausal Prolog reads two kinds of Prolog source, and both aim to conform to ISO/IEC 13211-1:

.clausal files .pl files
What it is Clausal Prolog proper: a deliberately restricted subset of ISO Prolog A compatibility mode for existing ISO Prolog code
What it is for Encoding ontologies, rules and policy, where we want firm guarantees about what can be expressed: every predicate stays monotonic and explainable Running Prolog programs written for other ISO systems
Cut, if-then-else, committed choice Not part of the dialect, by design (see Purity and Monotonicity); from 2.0 neither are \+/1, once/1, forall/2, call_nth/2, setup_call_cleanup/3 and call_cleanup/2 (operator rulings 2026-11-28), refused at load and at run time with existence_error(procedure, Name/Arity) Part of ISO, so part of this mode: the native front end runs them (ISO 7.8); *-> and a cut over a tabled call are refused
Status Supported Experimental (Public API)

The restriction in .clausal does not take it outside the standard. A program that uses only part of what ISO defines is still ISO Prolog text, as long as it does not redefine what the standard defines. .clausal leaves out cut and committed choice, and from 2.0 negation as failure and the committing meta-calls (\+/1, once/1, forall/2, call_nth/2, setup_call_cleanup/3, call_cleanup/2), so that properties like monotonicity can be guaranteed; memberchk/2 and \=/2, sound on ground terms, stay. The .pl mode reads and runs files under the full ISO rules, so existing code can be used unchanged.

Both dialects share one reader and one engine. Every ISO builtin either offers must behave as ISO 13211-1 specifies; this page records where that holds and where it does not yet. A third route runs Prolog alongside Clausal Prolog in a complete external ISO system, by embedding Scryer or Trealla (optional packages).

The seam (.seam files) is a different thing: a Python-syntax surface for the boundary between Python and Clausal Prolog. It is not Prolog syntax and is not measured against ISO; see Syntax.


Syntax

Measured against Ulrich Neumerkel's Conformity Testing I: Syntax on 2026-10-24, on commit 51d0c64e. Of its 366 numbered rows, judged against the expected-answer ("Codex") column: 358 pass, 5 fail, 3 untestable (#3, #126 and #214, whose expected answer is that read/1 waits for more input). Each row ran in its own session through the .pl native front end: its goals were read one at a time with the operators in force when each is read, as read(G), G reads them, and a row that begins with /**/ first ran the entry it stands for. Any syntax_error(_) counts as a syntax error; variable names and error contexts are not compared; where the Codex gives an example ("e.g."), an equivalent answer counts.

The five failures:

  • set_prolog_flag(double_quotes, chars) as a goal (#170) raises permission_error, by design (see Flags).
  • The NUL character is written '\x0\' (#225, #250), where the Codex lists '\0\' or a representation error. It is the same atom, and Scryer writes it the same way.
  • get_char(C) (#270, #271) answers C = end_of_file, where the Codex expects the character after the end token (' ' and '%'). get_char/1 exists now, but in this measurement current input is not the rest of the row's text, so these two rows test the toplevel's input handling rather than get_char/1.

Since the measurement on commit 16b700ae (357 pass, 6 fail, 3 untestable, the same morning), one row has passed and none has regressed: writeq(-0.0) (#364) now writes 0.0, as the Codex does. Fourteen other rows answer differently but keep their verdict: #270 and #271 now answer C = end_of_file instead of raising existence_error (still failures), and twelve syntax errors now carry a position or a hint in their message (#3, #44, #46, #48, #107, #111, #112, #113, #117, #126, #214, #297; #3,

126 and #214 stay untestable). The same row-by-row run on 16b700ae reproduces that

commit's answers on all 366 rows.

On the 2026-10-16 measurement (323 pass, 40 fail, 3 untestable, re-run the same way on that commit) 35 rows have since passed and none has regressed: the ISO lexer was tightened (unknown escapes, raw control characters in quoted tokens, bare-exponent floats, uppercase radix prefixes and 0'': 28 rows), [] and '[]' became the same atom (#302), the answer printer brackets operator atoms and terms (#45, #119, #122, #262, #299), and negative zero reads as 0.0 (#364).

Re-run row by row against Scryer on 2026-10-24, on commit 16b700ae (each row's goals in one session, through the .pl native front end and Scryer's own toplevel): every row answers as Scryer does except get_char/1 (#270, #271), writeq(-0.0) (#364: Clausal keeps the sign, Scryer writes 0.0), and eight rows where Scryer departs from the Codex and Clausal follows it (#348, #352, #353, #357, #358, #360, #361, #362 are syntax errors).


What conforms

Error terms

Errors are terms in ISO's form, error(Formal, Context), with the predicate indicator as context, as Scryer reports them (or an unbound variable when there is no single culprit). The explanatory prose, when there is any, is LogicException.message. See Exceptions.

Goal Clausal Prolog raises
atom_length(1, X) error(type_error(atom, 1), atom_length/2)
atom_length(X, 3) error(instantiation_error, atom_length/2)
atom_length(abc, foo) error(type_error(integer, foo), atom_length/2)
atom_length(abc, -1) error(domain_error(not_less_than_zero, -1), atom_length/2)
atom_chars(1, X) error(type_error(atom, 1), atom_chars/2)
char_code(ab, X) error(type_error(character, ab), char_code/2)
char_code(C, -1) error(representation_error(character_code), char_code/2)
sub_atom(X, B, L, A, S) error(instantiation_error, sub_atom/5)
call(1) error(type_error(callable, 1), call/1)
undefined_pred(1) error(existence_error(procedure, undefined_pred/1), undefined_pred/1)
functor(F, N, A) error(instantiation_error, functor/3)
functor(F, foo, a) error(type_error(integer, a), functor/3)
functor(F, foo, -1) error(domain_error(not_less_than_zero, -1), functor/3)
arg(x, f(a), X) error(type_error(integer, x), arg/3)
X =.. Y error(instantiation_error, (=..)/2)
sort(a, L), msort(a, L) error(type_error(list, a), sort/2), … msort/2)
length(L, -1) error(domain_error(not_less_than_zero, -1), length/2)
number_chars(X, [a]), number_codes(X, []) error(syntax_error(unexpected_end_of_file), context(number_chars/2, [line(1), column(2), found(end_of_file)])), … number_codes/2 …
term_to_atom(T, 'foo('); a file with foo(a, at its end error(syntax_error(incomplete_reduction), context(term_to_atom/2, [line(1), column(5), expected(term), found(end_of_file)])); … context(read_term/3, …)
a file or text with X = 'abc and then a newline error(syntax_error(invalid_single_quoted_character), context(read_term/3, [line(1), column(5), expected('\''), found('\n')]))
between(1, a, X) error(type_error(integer, a), between/3)
X is foo + 1 error(type_error(evaluable, foo/0), (is)/2)
X is Y + 1 error(instantiation_error, (is)/2)
X is 1 / 0 error(evaluation_error(zero_divisor), (/)/2)
X is 7.5 // 2 error(type_error(integer, 7.5), (//)/2)
X is 2 ^ -1 error(type_error(float, 2), (^)/2)
assertz(p(2)), retract(p(1)) on a static p/1 error(permission_error(modify, static_procedure, p/1), assertz/1), … retract/1)

The earlier edition listed thirteen of these goals as failing silently. Every one of them now raises the ISO error.

A syntax error's formal term is Scryer's atom for the same input, on every surface the native reader serves (ISO 7.12.2 h leaves it implementation dependent; Scryer's vocabulary is followed for portability): measured row by row against Scryer on 96 malformed texts (tests/iso/test_syntax_error_terms_scryer.py). Its context, which ISO leaves implementation defined, is context(PI, Details) with the fault's line(L) and column(C) and, where the parser knows them, expected(What) and found(Token) (operator ruling 2026-10-24; Q3 of the open questions). Portable code matching error(syntax_error(_), _) sees no difference. A file that fails to load raises a SyntaxError carrying the same term (PrologSyntaxError.term), with its caret on the fault and a hint in the message where one is certain (a float needs a fraction: write 1.0e+9).

Arithmetic

is/2 and the comparison predicates are ISO's. Evaluation is described in Arithmetic.

Expression Result Matches
+, -, *, unary - exact ISO
7 / 2, 6 / 2 3.5, 3.0 Scryer
-7 // 2 -3 (truncates) ISO
div(-7, 2) -4 (floors) ISO
mod(-7, 2) 1 (sign of divisor) ISO
2 ** 3 8.0 ISO / Scryer
2 ^ 3 8 ISO
rdiv(7, 2) 7 rdiv 2 (exact rational) Scryer
abs(-3), abs(-3.5) 3, 3.5 ISO
max(2, 5), min(1, 2.0), max(1, 1.0) 5, 1, 1.0 ISO Cor.2 / Scryer
rem(-7, 2), sign(-2.5), gcd(12, 18) -1, -1.0, 6 ISO / Scryer
truncate(-3.7), round(-2.5), ceiling(2.1), floor(-2.1) -3, -3, 3, -3 ISO / Scryer
float(3), float_integer_part(-3.7), float_fractional_part(3.75) 3.0, -3.0, 0.75 ISO / Scryer
sqrt(4), sin, cos, tan, asin, acos, atan, atan2, exp, log floats (sqrt(4) is 2.0) ISO / Scryer
sqrt(-1), log(0), atan2(0, 0) evaluation_error(undefined) ISO
atan(1, 1) 0.7853981633974483 ISO Cor.2 (Scryer: not evaluable)
pi, e 3.141592653589793, 2.718281828459045 ISO / Scryer
-7 >> 1, 1 << 3, 12 /\ 10, 12 \/ 10, \ 5, xor(12, 10) -4, 8, 8, 14, -6, 6 ISO / Scryer
a zero divisor evaluation_error(zero_divisor) naming the operator ISO
-0.0, X is 0.0 * -1, X is -(0.0) 0.0 (negative zero reads and evaluates as 0.0; an inner step keeps its sign, so atan2(-(0.0), -1) is -pi) Scryer (operator ruling 2026-10-24)

Scryer's non-ISO evaluables (msb/1, log/2, max_tagged_integer, …) are not provided: they raise type_error(evaluable, F/N). An evaluation error names the evaluable (error(evaluation_error(undefined), sqrt/1)), where Scryer names is/2.

Inside an arithmetic constraint (CLP(ℤ)'s #= family) / is exact and a zero divisor makes the constraint fail, as in Scryer's clpz. See Constraints.

CLP(ℤ) propagation matches Scryer's clpz through every operator (+ - * // div mod rem ^ min max abs, unary -) under every relation, whichever variable is bound or narrowed first: a generated matrix of 2036 rows (tests/iso/test_clpz_propagation_matrix_scryer.py) agrees with Scryer or narrows further and stays sound on each row. One difference is open: a float operand of the # family is CLP(ℝ) in Clausal and a domain_error(clpz_expression, F) in Scryer (todo/clp-domain-spans-reals-while-clpz-is-integers-2026-09-09.md).

Comparison and standard order

Goal Result
1 == 1.0 fails
1 = 1.0 fails (an integer and a float are distinct terms, ISO 7.3; so do f(1) = f(1.0), [1] = [1.0] and X = 1, X = 1.0)
a \== b succeeds
compare(O, 1, 1.0) O = (>) (a float precedes an integer)
compare(O, 1, 2.0) O = (>) (every float precedes every integer, whatever their values: ISO 7.2.1)
msort([3, 2.5, 1, 0.5], L) L = [0.5, 2.5, 1, 3]
compare(O, 1, a) O = (<)
compare(O, f(a), b) O = (>)
compare(O, "abc", abc) O = (>) (a string is a list, a compound)
f(b) @> f(a, a) fails (arity is compared before name)
sort([1, 1.0, 1], L) L = [1.0, 1]
1 =:= 1.0 succeeds
1 < a type_error(evaluable, a/0)

==/2 compares the whole term: a variable bound anywhere inside reads as its value, as ISO 8.4.1.1 requires.

Builtins that behave as ISO specifies

Type tests: var/1, nonvar/1, atom/1, number/1, integer/1, float/1, atomic/1, compound/1, callable/1, ground/1, is_list/1. Terms: functor/3, arg/3, (=..)/2, copy_term/2, term_variables/2, numbervars/3, unify_with_occurs_check/2, subsumes_term/2. Atoms and characters: atom_length/2, atom_chars/2, atom_codes/2, atom_concat/3, sub_atom/5, char_code/2, number_chars/2, number_codes/2, atom_number/2, upcase_atom/2. Control and all-solutions: call/1..8, once/1, \+/1, catch/3, throw/1, findall/3, bagof/3, setof/3, forall/2, halt/0,1, repeat/0 (since 2026-10-24; it used to be an existence error). From 2.0, once/1, \+/1, forall/2, call_nth/2, setup_call_cleanup/3 and call_cleanup/2 are .pl only: .clausal refuses them. Lists and sorting: length/2, member/2, memberchk/2, append/3, nth0/3, nth1/3, between/3, sort/2, msort/2, keysort/2, compare/3. Operators: op/3, current_op/3. Output: write/1,2, writeq/1,2, write_canonical/1,2, write_term/2,3, nl/0,1. write_canonical([a]) writes '.'(a,[]), as Ulrich's tables expect. Streams (8.11–8.13, since 2026-10-24): open/3,4, close/1,2, current_input/1, current_output/1, set_input/1, set_output/1, flush_output/0,1, at_end_of_stream/0,1, set_stream_position/2, stream_property/2, get_char/1,2, get_code/1,2, peek_char/1,2, peek_code/1,2, put_char/1,2, put_code/1,2, get_byte/1,2, peek_byte/1,2, put_byte/1,2, with ISO's error terms (checked against Scryer in tests/iso/test_streams_scryer.py; where that build departs from the standard -- a compound stream argument, the culprit of set_input/1's permission error, user_output's mode, set_output(user_output), closing the current stream -- the ISO answer is kept). Reading (8.14.1): read/1,2, read_term/2,3 with variables/1, variable_names/1, singletons/1, honouring the operator table and the reading module's double_quotes flag (tests/iso/test_read_term_scryer.py; Scryer raises a syntax error for layout before the end of a stream, where ISO reads end_of_file). Database: asserta/1, assertz/1, retract/1, retractall/1, abolish/1, clause/2, current_predicate/1 (a static predicate raises permission_error(modify, static_procedure, PI)). The ISO built-ins are static (7.5.1): a .pl or .clausal file with a clause for one, or dynamic/1 of one, is refused at load with permission_error(modify, static_procedure, PI), the whole file, as Scryer refuses it (Scryer ignores dynamic/1 of a builtin instead). A library predicate such as append/3 or length/2 is no ISO built-in and a file may define it. Grammar rules: phrase/2,3. Common non-ISO extras, as SWI-Prolog defines them (Scryer has none): sort/4, predsort/3, print/1, atom_string/2, term_to_atom/2, atom_to_term/3, errors included (tests/iso/test_common_extras_scryer.py). predsort/3 tries every answer of its comparator, so it is cut-free. Constraints: dif/2, CLP(ℤ), CLP(B), CLP(ℚ).

Reading and writing terms

The -g answer printer writes a binding as writeq/1 writes the right operand of =, as Scryer's toplevel does: T = (a,b), X = (-), and F = ('.') while . is an operator. A prefix operator followed by a token that cannot start a term is an atom (ISO 6.3.4.2): - . and \ . read as - and \, and - (1) and -(1) are both -(1).

Procedures and modules

A procedure is a name and an arity, as in ISO: p/1 and p/2 in one file are two procedures, and a DCG nonterminal s//1 is s/3. See Predicates.

ISO 13211-1 has no module system, so here Scryer is the reference. use_module(m, [p/1]) imports one arity of p, and a bare name imports every arity. A name clash between two modules is resolved with a module-qualified call, m:p(X). Renaming an import with as is not supported, because neither ISO nor Scryer has it.

Flags

set_prolog_flag/2 and current_prolog_flag/2 are provided, with every ISO flag and ISO's error terms (Prolog Flags). A read-only flag gives permission_error(modify, flag, F) and a bad value domain_error(flag_value, F+V), following ISO 8.17.1.3 (for set_prolog_flag(unknown, foo) Scryer reports domain_error(prolog_flag, unknown)). char_conversion is off; max_integer and min_integer have no value (integers are unbounded), and max_arity is unbounded. assert_creates_dynamic (implementation-defined) selects ISO 7.5.2(2)'s assert, and is on in a .pl module. unknown takes error, fail and warning (ISO 7.11.2.4), process-wide. char_conversion/2 and current_char_conversion/2 (ISO 8.14.5–8.14.6, the directive too) keep the process-wide conversion table with ISO's errors; no reader applies it, so the char_conversion flag stays off (Scryer has none of the three). ISO 7.11.2.1 makes on the flag's default; Clausal keeps it off and refuses on because its reader does not convert, so a program that tests current_prolog_flag(char_conversion, on) fails here.

Cyclic terms (rational trees) and deep terms

=/2 has no occurs check (ISO 7.3.2), so X = f(X) builds a cyclic term, and every later question about it is answered as Scryer answers it, as a question about a rational tree: X = f(X), X = f(f(X)) succeeds; two cyclic terms unify, are == and compare(=, X, Y) exactly when they are one tree (X = f(X, a), Y = f(Y, b) fails on the second argument, compare(<, X, Y)); copy_term/2 copies the cycle; ground/1 is true; term_variables/2 gives []; findall/3 collects it; writeq/1 prints f(...), [a|...], g(f(...),f(f(...))) -- a cell already being written is .... Partial lists built through their tail are rational trees too (X = [1|X], Y = [1,1|Y], X = Y, X == Y). A term too deep for the recursive walkers (a 100k-element list, a 100k-nested f(f(...))) unifies, compares, copies, and can be asserted and read back with clause/2. An operation that has no answer for a cyclic term raises an ISO error, never a raw Python RecursionError: resource_error(finite_memory) where the engine saw the cycle (assertz of a cyclic term, where Scryer panics; ruling 2026-10-24, provisional), resource_error(stack) for a depth overflow. Pinned row by row against Scryer in tests/iso/test_cyclic_terms_scryer.py. Evaluating a cyclic term (X = X+1, Y is X, the comparisons, eval_/2) is Scryer's type_error(evaluable, Name/Arity), naming the term where the cycle closes: (+)/2 for X = 1+X, Y is X*2 (operator ruling 2026-11-04; tests/iso/test_cyclic_eval_scryer.py). Posting one to CLP(Z) (X = X+1, X #= 1, the reified connectives, the seam's == and <) is clpz's domain_error(clpz_expression, Side), or domain_error(clpz_reifiable_expression, Operand) for an operand of a reified connective, as in Scryer (tests/iso/test_clpz_cyclic_scryer.py); CLP(B) does not refuse one, since Scryer's clpb defines no answer (ruling 2026-11-04). The same holds at the Python entry: a cyclic or deep term handed to solve() works as inside a program, and to_python/term_key raise those two errors (tests/test_python_entry_cyclic_deep.py). Running out of memory is resource_error(memory) (7.12.2 h): in is/2 and the arithmetic comparisons, which used to report it as type_error(evaluable, F/N), and to a catch/3 (tests/test_async_exception_propagation.py).

One standard-order difference from Scryer: a list against a list with another tail. This engine reads every list as the cons cells it is (ISO 7.2.1, each '.'/2, compared argument by argument), so compare(R, [a|T], [a]) is < (a variable before []), compare(R, [a,b], [a|c]) is > ('.'(b,[]) after the atom c), and, with X = [a|X], compare(R, [a|foo], X) is <; Scryer says >, < and >, as if it ordered a list's elements before its tail. Trealla agrees with this engine (tests/iso/test_fuzz_findings_scryer.py). A partial list [B|A] is the compound '.'(B, A) to functor/3, arg/3, =.. and the standard order, as in Scryer.

The printing of a cyclic term is not fixed by ISO: writeq/1 writes a cell already being written as ..., and where that falls depends on where the cycle is closed in memory -- a copy (copy_term/2, findall/3) or a cell built through a partial list closes it one cell further on in one system than in the other ([[_A|...]] in Scryer, [[_A,_A|...]] here, for one rational tree). Scryer also writes ... for a shared subterm that closes no cycle ([B|g(B)] = A, A = [g(D)|C], writeq(A) gives [g(_A)|g(...)]), and writes a list whose tail is a list of characters with the tail as a string ([C|"a"] for [C,a]). The differential fuzzer (tests/fuzz/scryer_diff.py) compares terms unfolded to a fixed depth, which do agree. dif/2 on a cyclic or 100k-deep pair answers as Scryer does: it fails on one rational tree, succeeds on a ground difference, and otherwise suspends (X = f(X), dif(Y, X) leaves dif(Y,f(...)); a goal woken by freeze/2 that posts such a dif too), and since its trial unify has no occurs check dif(X, f(X)) suspends and a later X = f(X) fails (tests/iso/test_dif_cyclic_scryer.py). =/2 and ==/2 on two hole-built lists are linear (tests/test_hole_list_unify_scaling.py). One open gap is filed: a list a clause head builds after its body (mk(N, L, [N|T]) :- ..., mk(N1, L, T)) copies its tail at every level, so building it is quadratic (todo/a-list-a-clause-head-builds-after-its-body-copies-the-tail-quadratic-2026-11-03.md).


Known gaps

Flags

  • double_quotes is never changed at run time (a design choice, ruled 2026-10-18): set_prolog_flag(double_quotes, V) as a goal gives permission_error(modify, flag, double_quotes), where ISO allows the change (Ulrich #170). A .pl file sets it by directive (chars, codes or atom); in .clausal it is always chars. The question is Q2 for Ulrich.

Missing builtins

Every builtin this report used to list here is provided now: the ISO stream predicates (8.11–8.13, including get_char/1,2, peek_char/1,2, put_char/1,2, their _code and _byte versions, nl/1 and the stream arguments of the writers), term reading (read/1,2, read_term/2,3), character conversion (char_conversion/2, current_char_conversion/2), and the common extras term_to_atom/2, atom_to_term/3, atom_string/2, sort/4, predsort/3 and print/1,2.

One common non-ISO extra is left out by design: ignore/1, which is committed choice (ruling D13). Calling it raises existence_error(procedure, ignore/1).

Reading and writing

These are from the syntax measurement:

  • [] and '[]' are the same atom, as ISO says (ruling D70, 2026-10-17): X = '[]', X == [] succeeds and writeq('[]') prints [], which reads back as itself.
  • A digit group separator is one _ between two digits of a decimal integer, as in Scryer (operator ruling 2026-11-03): 1_000 is 1000, 1_000_ and 1__000 are syntax_error(cannot_parse_big_int), and a fraction or a 0x/0o/0b integer takes no _ (1.0_0 and 0x1_2 are incomplete_reduction). Layout and comments may follow the _: 1_ 000 and 1_/*c*/000 are 1000. One difference is left: after 1_ and layout, a 0'c char code is one token here, while Scryer reads its 0 as a digit of the number and the rest from the quote as a quoted atom; both refuse such a text, with different formals (tests/iso/test_digit_groups_scryer.py, READER_DIFFERENCES). number_chars/2 reads the same digit groups, but refuses a _ that ends the text (1_000_), which Scryer's number_chars takes and its reader refuses. See todo/done/reader-digit-group-trailing-underscore-2026-10-24.md.

History

The first edition of this report (2026-03-25) recorded decisions reached with Markus Triska. Their outcome:

Question Decision then Where it stands
Cut and if-then-else Out of scope; reject on import Split: never in .clausal, by design; part of the .pl compatibility mode (done on the native front end). From 2.0 the same split holds for \+/1, once/1, forall/2 and call_nth/2
Strings Lists of characters Done: "…" is a list of characters by default
Atoms A distinct type Done
Modules use_module .pl import works for plain programs and is experimental
Operators and arithmetic Translation layer only Superseded: .clausal and .pl are read with ISO syntax and operators directly
Names Rename between conventions Superseded: predicate and variable names cross unchanged in both directions
Missing builtins Add incrementally, compare/3 first Most are done; the rest are listed above
Error terms Verify ISO structure Done: error(Formal, Context) in Scryer's form

The Scryer and Trealla embeddings were added later as the route for programs that need a complete ISO system today.