AI Wiki中文/EN

Prolog: clauses, choices and the next answer

Prolog 与逻辑编程

Run real Prolog route queries, explain variable freshness and backtracking, and test how order, negation and cut change execution.

On this pageIntuitionMathematics & methodImplementationLimitationsExercisesResearch connections

Three routes, but which one arrives first?

Imagine a small research campus. Its one-way walkways connect atrium → lab, atrium → cafe, lab → garden, cafe → garden, garden → exit and lab → exit. A sixth place, island, has no walkway. A visitor asks for every route from the atrium to the exit.

A graph algorithm could answer this question. Prolog lets us describe a route as a relation: either one edge connects the endpoints, or an edge reaches an intermediate place with a route onward. The same predicate can answer a yes/no question, return a path, or search for an endpoint. It does not automatically choose a shortest path.

Prolog is a programming language with a particular execution strategy. Reading its pure rules as logic explains which answers are justified; following its search explains which answers appear, in what order, and whether a query finishes. This chapter runs an original program in SWI-Prolog itself, then changes one execution choice at a time. Learn Prolog Now!, rule and goal order

A relation becomes a sequence of calls

In the source below, edge(atrium,lab). is a fact. route/3 names a predicate with three arguments; edge/2 is a different predicate. A rule puts its head before :- and its body after it. Commas join body goals. A period ends a clause. Lowercase words here are atoms; uppercase names such as X are variables. [X|Rest] is a list with head X and tail Rest. At the interactive prompt, a query such as route(atrium,exit,P). asks for bindings of P; the displayed ?- is the prompt, not part of the file. Learn Prolog Now!, facts, rules and queries

For a graph with no parallel edges, the intended relation is:

Route⁡(x,y,[v0,…,vk])  ⟺  k≥1∧v0=x∧vk=y∧⋀i=0k−1Edge⁡(vi,vi+1).\operatorname{Route}(x,y,[v_0,\ldots,v_k])\iff k\ge1\land v_0=x\land v_k=y\land\bigwedge_{i=0}^{k-1}\operatorname{Edge}(v_i,v_{i+1}).

The requirement of at least one edge is deliberate: this program has no zero-length route. On the acyclic campus graph every walk is a simple path. On a graph containing a cycle, the same definition permits revisiting vertices; it does not contain a visited-set check.

For the pure predicates here, ordinary untabled execution selects the leftmost remaining goal and tries applicable clauses in source order. It unifies the selected goal with a clause head and replaces that goal by the clause body. On failure, backtracking restores the relevant variable bindings and tries a saved alternative. Each use of a clause has fresh variables, even when its source names match an earlier call. Clause indexing may skip incompatible heads; it does not make this program a breadth-first search. Learn Prolog Now!, execution order

Watch the first answer. The direct clause cannot find edge(atrium,exit). The recursive clause chooses edge(atrium,lab) and asks for the remaining path. The next call tries its own direct clause and finds edge(lab,exit):

route⁡(atrium,exit,P)⇝route⁡(lab,exit,R),P=[atrium∣R]⇝P=[atrium,lab,exit].\operatorname{route}(\mathrm{atrium},\mathrm{exit},P)\leadsto\operatorname{route}(\mathrm{lab},\mathrm{exit},R),\quad P=[\mathrm{atrium}\mid R]\leadsto P=[\mathrm{atrium},\mathrm{lab},\mathrm{exit}].

That is a trace of this successful branch, not an assertion that all intermediate alternatives were successful. Asking for another answer makes the lab call try its recursive clause, yielding the garden route. After that branch is exhausted, the outer call tries cafe.

Freshness matters. In route(atrium,exit,P), route(cafe,exit,Q), the two calls have independent internal variables and produce three pairs. Reusing P in both goals requires exactly the same list, so this conjunction fails. Plain _ creates a new anonymous variable at each occurrence; _Same is a named variable and repeated occurrences share. Displayed names are not global storage locations. SWI-Prolog, variable naming

Run the clauses, then change their order

Save the complete program as routes.pl. Its route definitions are pure; the reporting code also uses collection, negation as failure, cut and SWI’s inference limit. These additions are discussed separately below.

% Original finite route example. Load this file; call main/0 to print the demo.
node(atrium). node(lab). node(cafe).
node(garden). node(exit). node(island).

edge(atrium, lab).
edge(atrium, cafe).
edge(lab, garden).
edge(cafe, garden).
edge(garden, exit).
edge(lab, exit).

route(X, Y, [X,Y]) :- edge(X, Y).
route(X, Y, [X|Rest]) :- edge(X, Z), route(Z, Y, Rest).

route_deep(X, Y, [X|Rest]) :- edge(X, Z), route_deep(Z, Y, Rest).
route_deep(X, Y, [X,Y]) :- edge(X, Y).

reach_bad(X, Y) :- reach_bad(X, Z), edge(Z, Y).
reach_bad(X, Y) :- edge(X, Y).

reach_late(X, Y) :- edge(X, Y).
reach_late(X, Y) :- reach_late(X, Z), edge(Z, Y).

closed(exit).
open_node(X) :- node(X), \+ closed(X).
open_bad(X) :- \+ closed(X), node(X).

first_step(X, Y) :- edge(X, Y), !.

% Bound the whole findall computation, not each returned route separately.
% No partial bag is exposed when the inference budget is exceeded.
bounded_all(Template, Goal, Limit, Status, Answers) :-
    call_with_inference_limit(findall(Template, Goal, Bag), Limit, Result),
    ( Result == inference_limit_exceeded
    -> Status = unknown, Answers = []
    ;  Status = complete, Answers = Bag
    ).

main :-
    findall(P, route(atrium, exit, P), Routes),
    writeq(routes(Routes)), nl,
    findall(P, route_deep(atrium, exit, P), Deep),
    writeq(recursive_clause_first(Deep)), nl,
    findall(X, open_node(X), Open),
    writeq(open_nodes(Open)), nl,
    findall(X, open_bad(X), BadOpen),
    writeq(negation_first(BadOpen)), nl,
    findall([P,Q], (route(atrium, exit, P), route(cafe, exit, Q)), Pairs),
    length(Pairs, Count), writeq(independent_calls(Count)), nl,
    findall([X,Y], (member(X, [atrium,lab]), first_step(X,Y)), First),
    writeq(cut_inside_call(First)), nl,
    ( first_step(atrium,cafe) -> writeln(bound_cut_query(true))
    ; writeln(bound_cut_query(false)) ),
    bounded_all(Y, reach_bad(atrium,Y), 1000, S1, A1),
    writeq(left_recursive(S1,A1)), nl,
    ( once(reach_late(atrium,lab)) -> writeln(base_first_once(true))
    ; writeln(base_first_once(false)) ),
    bounded_all(Y, reach_late(atrium,Y), 1000, S2, A2),
    writeq(base_first_all(S2,A2)), nl,
    bounded_all(P, route(island,exit,P), 1000, S3, A3),
    writeq(island_routes(S3,A3)), nl.

A machine with native SWI-Prolog can load the file and execute main/0 with the following command. Native swipl was unavailable in this chapter’s validation environment, so this command is a reproduction option, not a claimed native test.

swipl -q -s routes.pl -g main -t halt

The actual run used Node v26.7.0, package swipl-wasm@8.0.7 and engine swi(10,1,13,[]), architecture wasm-emscripten, on 2026-09-05. The package and engine have different version numbers. The package was published on 2026-08-21; the verification date is recorded separately from the encyclopedia’s fact cutoff. The official package loads the compiled SWI-Prolog engine; it is not a JavaScript or Python imitation of these rules. Official SWI-Prolog WASM package

For a standalone reproduction, put the following driver at runtime/run.mjs, keeping routes.pl one directory above it. Install the fixed package in that runtime directory with npm install --save-exact --ignore-scripts swipl-wasm@8.0.7, then run node runtime/run.mjs from the parent directory. The accompanying test bundle includes a lockfile; npm ci --ignore-scripts in runtime recreates those exact dependencies. Once installed, these examples run locally without a model API or an online Prolog service.

In this repository, run npm run setup:prolog, npm run demo:prolog and npm run test:prolog from the root. The companion source and lockfile live in src/examples/prolog/; setup uses npm ci with lifecycle scripts disabled.

import { readFileSync } from 'node:fs';
import SWIPL from 'swipl-wasm';

const engine = await SWIPL({ arguments: ['-q'] });
engine.FS.writeFile('/routes.pl', readFileSync(new URL('../routes.pl', import.meta.url)));
if (!engine.prolog.query("consult('/routes.pl').").once().success) {
  throw new Error('Cannot load routes.pl');
}
const version = engine.prolog.query(
  'current_prolog_flag(version_data,V), current_prolog_flag(arch,A).'
).once();
console.log(JSON.stringify({ node: process.version, engine: version.V, arch: version.A }));
if (!engine.prolog.query('main.').once().success) throw new Error('main/0 failed');

The process exited with code 0 and no stderr. After its JSON version line, its complete demonstration output was:

routes([[atrium,lab,exit],[atrium,lab,garden,exit],[atrium,cafe,garden,exit]])
recursive_clause_first([[atrium,lab,garden,exit],[atrium,lab,exit],[atrium,cafe,garden,exit]])
open_nodes([atrium,lab,cafe,garden,island])
negation_first([])
independent_calls(3)
cut_inside_call([[atrium,lab],[lab,garden]])
bound_cut_query(true)
left_recursive(unknown,[])
base_first_once(true)
base_first_all(unknown,[])
island_routes(complete,[])

The two route lists contain the same three paths. route_deep/3 puts the recursive clause first, so the lab → garden → exit path precedes lab → exit. Neither order is a length-sorting guarantee. Adding a duplicate edge fact can produce duplicate path answers: execution enumerates successful derivations, and distinct derivations need not yield distinct values. findall/3 retains that sequence and returns [] when a goal finitely has no answers; it does not deduplicate. SWI-Prolog, findall/3

reach_bad/2 is more revealing. Its first goal calls itself again before consulting any edge. Another fresh Z appears, but no graph information restricts the recursion. Thus even a query about island takes this endless branch in ideal unbounded execution. Putting the base clause first in reach_late/2 lets once(reach_late(atrium,lab)) succeed. Asking for all answers still eventually descends into arbitrarily deep recursive calls. The unchanged graph cannot rescue that search order.

bounded_all/5 puts one inference limit around the entire findall computation. unknown,[] means the run was stopped and its answer collection discarded; complete,[] means enumeration finished with no answers. The empty lists have different meanings. The helper does not return a partial answer bag or a continuation. The bound counts SWI calls/redos under the engine’s rules; some built-ins are uncounted VM instructions or single counted calls containing substantial work. It is not a bound on seconds, bytes, or abstract proof length. Exceptions other than the handled inference limit propagate. SWI-Prolog, call_with_inference_limit/3

Failure, pruning and cost need their own meanings

In this program, \+ closed(garden) succeeds because closed(garden) finitely fails. It does not derive a classical negative fact. The positive fact closed(exit) alone permits a classical model in which the garden is closed too. Treating an absent closure record as permission to enter requires an explicit completeness policy for that record system.

The variable query explains why order matters beyond recursion. open_node(X) first enumerates the six known nodes, then tests each ground instance. open_bad(X) instead tries closed(X) with X unbound. It finds exit, so the enclosing negation fails and no nodes are enumerated. Negation as failure does not generate the complement of a relation, does not export tentative bindings, and cannot turn a looping goal into a terminating answer. SWI-Prolog, control and negation

Cut, written !, commits choices within its scope. In first_step/2 it removes the alternatives created since entry into that predicate, including alternative matching edges to its left. The caller’s separate choice between atrium and lab survives, as the two output pairs show. Yet first_step(atrium,Y) gives only lab, while the bound query first_step(atrium,cafe) succeeds: the earlier edge did not match that call. This predicate cannot be treated as a complete logical definition of one globally selected next stop. Cuts inside meta-calls or control structures require the precise scope rules; this example does not implement or demonstrate every case. SWI-Prolog, cut scope

The finite-term assumption in unification also needs attention. SWI’s ordinary unification can create cyclic terms. For example, a fresh X can satisfy X=walk(X) as a rational tree, whereas unify_with_occurs_check(X,walk(X)) fails. The latter prevents creating a cycle; it is not a blanket rejection of every already-cyclic input. The campus data and answers are acyclic, so no such term is needed here. SWI-Prolog, occurs check

For a finite DAG with n vertices and m explicitly stored edge facts, a recursive route call follows an edge to a later vertex in a topological ordering. Hence route depth is at most n−1 edges, and the finite branching search finishes for the endpoint queries tested here. Let T be the number of route-call activations across the complete backtracking execution and L the total number of list cells in returned paths. With ground source/target names, unit-cost atom comparisons, and even a naive scan of all edge facts per activation, a safe operation bound for this specific algorithm is:

O(1+T(1+m)+L).O\bigl(1+T(1+m)+L\bigr).

This excludes loading/compilation and external I/O; it does not model every SWI optimization or string-character cost. Finding every path can still require enormous output. In the complete ordered DAG on n≥2 vertices, the paths from the first to the last vertex correspond to subsets of the n−2 intermediate vertices:

Npaths=2n−2,L≥2Npaths.N_{\mathrm{paths}}=2^{n-2},\qquad L\ge2N_{\mathrm{paths}}.

The answer collection alone requires Ω(L) storage. A visited set would change the permitted walks on cyclic graphs; tabling would change the execution strategy and requires its own termination conditions. Neither is silently supplied by these clauses. Prolog can support parsing, relational queries and constraint systems, but a language name does not settle a program’s termination, soundness conditions or application cost. An undefined predicate or a resource error is also not evidence that a logical query is false.

Predict the next answer before running it

1. Swap only the two route clauses. Which atrium-to-exit path comes first? Are answers lost?

Answer: The garden path [atrium,lab,garden,exit] comes first, followed by [atrium,lab,exit] and [atrium,cafe,garden,exit]. This finite DAG makes both clause orders terminate, and induction on path length shows both generate exactly its nonempty paths. The claim does not extend to arbitrary recursive programs whose first branch may never finish.

2. How many answers do independent P and Q produce? What changes if both calls use P, or both use plain _?

Answer: route(atrium,exit,P), route(cafe,exit,Q) produces 3×1=3 pairs. Reusing P produces none because the two lists must begin with different atoms. Two plain _ occurrences remain independent, so the conjunction has three successful derivations. Repeating _Same would share one variable despite its underscore prefix.

3. Why does open_bad(X) return nothing? Would a negation around reach_bad(island,exit) fix the recursion?

Answer: The unbound closed(X) succeeds with exit, causing its negation to fail before node(X) runs. Generate candidate nodes first to perform a finite ground absence check, while keeping the record-completeness assumption explicit. Negating reach_bad(island,exit) still follows its infinite recursive attempt; our bounded collector reports unknown,[], not success or a proof of absence.

4. Can first_step(atrium,cafe) succeed when the unbound query returns only lab? Does base_first_all(unknown,[]) prove there are no routes?

Answer: Yes. With cafe supplied, the lab edge fails to unify; the cafe edge succeeds and then cut commits that choice. The caller’s bindings affect which choice reaches cut. The second result says the inference budget stopped complete enumeration and discarded its bag. The direct route to lab was already demonstrated by the separate once query, so interpreting unknown,[] as “no route” would contradict an actual success.

Check the interpreter with a different description of a path

The test suite executes the actual Prolog file with the fixed WASM engine. Its independent Python oracle does not interpret Prolog, perform unification, or recursively follow graph edges. It enumerates permutations of vertices, retains those whose consecutive pairs are edges, and sorts them by the sequence of clause choices and edge-fact positions that a successful proof would use. This checks both path values and answer order.

The exhaustive group contains all 64 edge subsets consistent with one ordering of four vertices, each in forward and reversed fact order. Both route variants are tested for all 16 endpoint pairs, giving 4,096 endpoint/variant cases, grouped into 256 engine queries. Further cases exercise duplicate proofs, independent and shared variables, anonymous occurrences, cut scope, negation, zero and positive inference budgets, propagated exceptions, and real cyclic-term versus occurs-check behavior. These tests accompany the DAG argument; a finite run that reaches a budget cannot by itself prove nontermination. The nontermination examples are justified by the repeatedly selected recursive goal. The work is an AI technical check of this example, not human expert review or a validation of all SWI-Prolog features. For the underlying distinction between an interpretation and a query, continue with first-order logic.

Make a prediction, then check

bounded_all returns unknown,[] after a separate once query has succeeded. What does this mean?

Choose one answer

Learning objectives

  • Read facts, rules and queries with fresh variables; predict route answers and backtracking from actual clause/goal order.
  • Use actual Prolog to distinguish complete enumeration from budget interruption, finite failure from classical negation and local cut from a global relation.

Prerequisites & connections

Explore related knowledge →

References

  1. Learn Prolog Now! — 1.1 Some Simple Examples
    Patrick Blackburn; Johan Bos; Kristina Striegnitz
  2. Learn Prolog Now! — 3.2 Rule Ordering, Goal Ordering, and Termination
    Patrick Blackburn; Johan Bos; Kristina Striegnitz
  3. SWI-Prolog Reference Manual — Singleton variable checking
    SWI-Prolog contributors
  4. SWI-Prolog Reference Manual — Control Predicates
    SWI-Prolog contributors
  5. SWI-Prolog Reference Manual — findall/3
    SWI-Prolog contributors
  6. SWI-Prolog Reference Manual — call_with_inference_limit/3
    SWI-Prolog contributors
  7. SWI-Prolog Reference Manual — unify_with_occurs_check/2
    SWI-Prolog contributors
  8. SWI-Prolog npm-swipl-wasm — fixed package 8.0.7
    SWI-Prolog npm-swipl-wasm contributors

Version1 · Editorial status: Recorded technical checks completed

View technical check record (AI)

Codex · 2026-09-05 · Codex technical check: primary-source locations, original runnable models, independent finite-state oracles, bilingual review and second-agent cross-checks; not independent human peer review.

  • Complete original bilingual prose with6 anchors,4 displays and4 answered exercises; Prolog, Node, commands and full output match byte-for-byte. Reread under the repository humanizer neutral technical style; no human-review claim.
  • Actual SWI-Prolog WASM execution of original routes.pl: Nodev26.7.0, package8.0.7, engine10.1.13/wasm-emscripten; all11 main output lines, exit0 and empty stderr preserved in runtime-check.json. Native CLI absence explicit. npm lock/integrity fixed without repository or system dependency changes.
  • Eight tests passed with actual engine calls, no Python imitation of Prolog.64 four-vertex fixed-order DAGs×2 fact orders×2 route predicates×16 endpoint pairs=4096 combinations in256 engine queries. Independent Python enumerates vertex permutations and sorts by clause/edge-position proof keys, checking both values and answer order.
  • Also tested duplicate-edge proof multiplicity, no zero-length routes/isolated node, fresh calls versus explicit sharing, separate _ versus shared _Same, restored findall variable, NAF complement/binding counterexamples, cut preserving caller choices and bound-input first match, finite-term occurs checking and rational trees.
  • reach_bad/reach_late tested at limits50/100/1000 yieldingunknown; also0 budget, complete empty/nonempty bags and propagated throw(boom). Nontermination argued from repeated left recursion/arbitrary depth, not inferred merely from budget exhaustion. Limit encloses the whole findall, not each route answer; no time/memory guarantee.
  • Checked path-length induction for both route clauses and DAG termination; four-vertex exhaustive testing is restricted to DAGs. BoundO(1+T(1+m)+L) counts complete-backtracking route activationsT, edge factsm and output list cellsL, with ground endpoints and unit atom comparisons, excluding compilation/I/O. Independently derived2^(n−2) paths in a complete ordered DAG andΩ(L) answer storage.
  • Strict MDX+remark-math+repository display-math plugin+strict KaTeX and actual React static HTML passed:4 displays/6 headings/4strong answers in each locale, no math errors or emphasis remnants outside code. Per-article verification only, no whole-site build/browser acceptance claim.
  • A second AI agent read both full articles, routes.pl, both Node adapters, all eight tests, README, lockfile and metadata without edits. Checked at-least-one-edge routes, pure-clause soundness/completeness on the finite DAG, source-ordered depth execution, fresh variables/explicit sharing and one success versus answer exhaustion; no substantive defect found.
  • All eight author tests executed successfully in real SWI WASM. Separate Node/Python review code imports no author oracle, enumerates no vertex permutations, sorts by no proof keys and does not simulate Prolog unification/backtracking. The reference builds ordered suffix-path languages in reverse topological order, checking values/multiplicities/order by sequence concatenation; a second (visited subset,last vertex) DP independently checks multiplicities for4,000 endpoint pairs.
  • Independent real-engine checks cover8,000 endpoint/predicate cases: the original64 four-vertex DAGs×two fact orders×two predicates×16 endpoints=4,096; another72 seeded DAGs with n=2–7, shuffled topological names, edge multiplicities1–3 and shuffled facts give3,336; complete ordered DAGs n=2–9 give568. All agree across208 independent modules and416 engine queries. Complete-DAG first-to-last counts equal2^(n−2) and output cell counts satisfy L≥2N.
  • Another68 real control queries check cut first matches for each source,36 fully bound endpoint calls, fully free/target-bound modes, preservation of caller choices, independent/shared call variables, anonymous/named underscores, findall restoration, NAF absence/binding behavior, rational trees/occurs checking including existing cycles, once success and propagated errors. An undefined predicate was actually caught as existence_error rather than treated as false.
  • All220 budget checks passed:44 limits(0–40,50,100,1000)×five goals. Normal/isolated route collection returns either the exact complete bag or unknown with an empty bag; reach_bad, reach_late and negated left recursion return unknown/empty. Infinite behavior remains justified by recursive goal structure, not these finite checks. An initial reviewer-query whitespace error made a NAF operator parse as a wrong binary predicate; only the review script was corrected and rerun, not the author files.
  • Checked complexity under ground endpoint names, unit-cost atom comparison, T full-backtracking activations, m explicit edge facts and L output cells. Per activation, finite edge scans plus recursive/output work support the stated O(1+T(1+m)+L) operation bound. It is not a guarantee for all SWI optimizations, character costs, compilation/I/O or cyclic/tabled evaluation. Output storage Ω(L) and exponential path counts are stated separately.
  • Final actual demo exits0 with no stderr and12 lines(one version plus11 main). Both text fences exactly match main output and Node fences match the executed driver. Both locales have six anchors/four displays/four answers and matching code/commands/output. Independent strict MDX/KaTeX plus React static rendering passes with four displays/four strong answers each. Every declared final SHA matches. Only /tmp review files were written; no author/repository edits, whole-site build, browser acceptance, system install or human-peer-review claim.
  • Promotion preserves full prose, equations, program and exercises. Tests load published articles only, with draft fallback/skip paths removed and the Prolog review assertion updated to checked, with real-engine tests separated; algorithm and independent oracle logic are unchanged. Final review binds both MDX SHA-256 hashes.
  • Publication integration: added matching root setup/demo/test commands to both locales without changing Prolog or JS driver code. Bound five standalone runtime files by SHA-256. The newly added driver comparison initially searched a javascript fence instead of the actual js fence; corrected the extractor while retaining exact driver equality. Engine expectations and path oracle are unchanged.

Source locations checked:

  • Learn Prolog Now! — 1.1 Some Simple Examples · Read §1.1 official author-hosted mirror lines14–31,65–99,113–144,157–176 for facts, rule syntax, goals, variables and alternatives. Explicitly exclude simplified undefined-predicate behavior and semicolon-efficiency remarks; no claim to read the whole book or verify its publication year.
  • Learn Prolog Now! — 3.2 Rule Ordering, Goal Ordering, and Termination · Read §3.2 lines13–93, especially16–17 (execution order),39–48 and70–90 (reordering and termination caveat),59–69 (fresh variables and left recursion). Our graph and proof-order keys are independently derived, not copied descendants.
  • SWI-Prolog Reference Manual — Singleton variable checking · Read §2.15.1.10 lines88–99: plain _ differs from repeated _Name; same source names share within a clause. Tested read_term_from_atom with pair(_,_) and pair(_Same,_Same) then actual identity comparison.
  • SWI-Prolog Reference Manual — Control Predicates · Read §4.7 lines132–212; cut at146–154, conjunction/disjunction155–174, if-then-else175–195, and finite-failure negation209–212. Ordinary cut example and fresh/bound mode counterexample actually run; no complete cut interpreter or meta-call-scope test claimed.
  • SWI-Prolog Reference Manual — findall/3 · Read official predicate description lines84–88 on successive backtracking instances, empty-list success and existential treatment of variables. All answer lists in the article generated by the actual engine.
  • SWI-Prolog Reference Manual — call_with_inference_limit/3 · Read official description lines90–100: per-solution limit; Result=inference_limit_exceeded versus failure, ! or true; exceptions propagate; calls/redos and potentially expensive foreign/VM operations. Limits50/100/1000 and0 tested; numeric counter value not compared across implementations.
  • SWI-Prolog Reference Manual — unify_with_occurs_check/2 · Read official description lines86–103, particularly94–101 on rational trees and guarding newly introduced cycles, not all existing cycles. Our fresh-term tests use original walk/1, and the cyclic output itself is not serialized to JavaScript.
  • SWI-Prolog npm-swipl-wasm — fixed package 8.0.7 · Read official GitHub README lines180–206/229–236 for Node,387–401 for independent package/engine versions and BSD-2-Clause. Read installed8.0.7 package.json and LICENSE.txt including possible bundled-component licenses. npm view swipl-wasm@8.0.7 dist repository verified official provenance URL, integrity sha512-oO5dsXeTwSHjbk3xsb6PfQDv9slJDc7QQm4qLgEXewTGsclg1MtAc6qpGnHsvvS/817yRYceDHpLE1bsbu6IMQ==; npm time records2026-08-21T00:30:48.246Z. Actual runtime Nodev26.7.0 / swi(10,1,13,[]) / wasm-emscripten, run on2026-09-05. Direct v8.0.7 GitHub tag fetch failed; package identity read from registry and installed locked bytes, not that failed HTML fetch. Also read official wasm-query §13.2.1 lines82–94 for query.once success/error/closure, without copying upstream driver text.
  • Learn Prolog Now! — 1.1 Some Simple Examples · Independently opened the official Learn Prolog Now! mirror and read §1.1 lines14–31 (facts/query prompt),65–99 (rules, head/body, clauses/predicates),113–144 (conjunction/disjunction) and157–183 (variables, binding and alternatives). Did not adopt its simplified treatment of undefined predicates or broad efficiency remarks. No source program was executed or copied in this review.
  • Learn Prolog Now! — 3.2 Rule Ordering, Goal Ordering, and Termination · Independently read official §3.2 lines13–92: source/goal order and backtracking; reordered pure clauses; fresh variables under left recursion; distinction between finding a success and eventual exhaustive search. Checked that the article restricts answer-order preservation and termination to its finite DAG and gives a structural recursion argument, rather than treating budget exhaustion as proof of nontermination.
  • SWI-Prolog Reference Manual — Singleton variable checking · Independently opened official §2.15.1.10 and read lines89–99, especially plain _ versus repeated named _X. Executed fresh/shared parsed-variable identity checks in the fixed actual engine, without representing variable identities as strings.
  • SWI-Prolog Reference Manual — Control Predicates · Independently read official §4.7 lines133–156 for ordinary cut, clause/caller choice points and opaque meta-calls; lines175–198 for control context; lines209–212 for finite-failure negation and its scope. Tested the demonstrated ordinary-predicate cut, bound/free modes, caller enumeration and NAF bindings. Did not claim to test every control/metacall scope combination.
  • SWI-Prolog Reference Manual — findall/3 · Independently read official findall/3 lines85–88 for successive backtracking instances, empty-list success and existentially scoped goal variables. Actual fixed-engine runs check ordered repeated answers, independent/shared templates and external variable restoration.
  • SWI-Prolog Reference Manual — call_with_inference_limit/3 · Independently read official call_with_inference_limit/3 lines92–100: per-solution counting, exceeded/failure/success/exception behavior, call/redo counts, uncounted VM instructions and potentially expensive single foreign calls. Confirmed the article wraps the one result of the whole findall, not each route answer, and makes no time/memory bound.
  • SWI-Prolog Reference Manual — unify_with_occurs_check/2 · Independently read official unify_with_occurs_check/2 lines87–103: rational trees, preventing fresh cycles and tolerating pre-existing cycles. Tested fresh walk-cycle creation, fresh occurs-check failure and successful unification of two already-cyclic walk terms. Cyclic values were inspected inside Prolog and only ground result markers were serialized.
  • SWI-Prolog npm-swipl-wasm — fixed package 8.0.7 · Independently opened the official SWI-Prolog GitHub README and read lines180–206/229–236 for Node use and387–401 for separate package/engine versions and BSD-2-Clause. Read installed8.0.7 package.json and LICENSE.txt, including possible bundled-library requirements. Verified the retained npm-cache tarball bytes against package-lock SHA512 and package version/provenance. Actual review ran Nodev26.7.0, swi(10,1,13,[]), wasm-emscripten. Read retained registry time evidence2026-08-21T00:30:48.246Z; fresh web access to the registry version endpoint returned an internal error, so no independent fresh publication-date fetch is claimed. No dependency installation or binary redistribution was performed by the reviewer.

Related topics

No matches. Try a synonym or acronym.

0 results shown

Wrap the whole query in double quotes for a phrase match.