This page lists the programs that load and run Prolog files, and the tools around them. No Prolog system is installed on the machine that wrote these pages, so no command or example here was run; the commands are the ones the systems' manuals give, and the examples were read by this site's scanner only. To check the pages and the viewer against a real system, the SWI-Prolog package (brew install swi-prolog on macOS) is the one to use: it has the largest manual and the best error messages for syntax.
Running a file
| System | Program | Load a file and run a goal |
|---|---|---|
| SWI-Prolog | swipl | swipl file.pl loads the file and opens the top level; swipl -g main -t halt file.pl runs main and exits; swipl -c file.pl compiles; swipl -o prog -c file.pl makes an executable |
| GNU Prolog | gprolog, gplc | gprolog --consult-file file.pl; gplc file.pl makes a native executable |
| Scryer Prolog | scryer-prolog | scryer-prolog file.pl |
| Trealla Prolog | tpl | tpl file.pl |
| SICStus Prolog | sicstus, spld | sicstus -l file.pl; spld makes a stand-alone program |
| YAP, XSB, ECLiPSe | yap, xsb, eclipse | each loads a file given on the command line or with [file]. at the prompt |
| Tau Prolog | a JavaScript library | a page or a Node.js program creates a session and consults the text |
| Ciao | ciao, ciaosh | loads a module with use_module; ciao build makes a program |
The program name and the options are as the manuals of each system state them; the exact options change with the version.
Tests, documentation and checking
| Tool | What it does |
|---|---|
plunit (library(plunit)) | unit tests written in Prolog, in .plt files or in the source: :- begin_tests(lists). ... test(append) :- append([a], [b], [a, b]). ... :- end_tests(lists).; run with run_tests/0 |
PlDoc (library(pldoc)) | documentation from comments that start with %! or /**, which describe a predicate, its arguments (+ input, - output, ? either) and its determinism; served as a web page by doc_server/1 |
listing/1, portray_clause/1 | print the clauses of a predicate, or one clause, in a standard layout |
check/0, list_undefined/0 (SWI-Prolog) | find undefined, unused and ill-formed predicates in the loaded program |
make/0 (SWI-Prolog) | reload the files that changed |
style_check/1 | turn the warnings for singleton variables, discontiguous clauses and similar checks on and off |
profilers and tracers: profile/1, trace/0, spy/1, the graphical tracer (SWI-Prolog) | find where time goes, and step through a run |
:- begin_tests(lists).
test(append) :-
append([a], [b], L),
L == [a, b].
test(member, [nondet]) :-
member(_, [a, b]).
:- end_tests(lists).
.plt file. The begin_tests directive is one of the marks of Prolog on the file types page.Editors and web tools
- SWI-Prolog ships an editor mode for Emacs and starts the editor you choose from
edit/1; a Visual Studio Code extension (VSC-Prolog and others) and the Emacs prolog-mode colour and run the files. - SWISH is a web page where SWI-Prolog runs in a server, and Tau Prolog and Trealla run in the browser.
- Highlighters for Prolog are in most editors; they often mistake
0'c, a%comment or a/* */comment, as a Perl highlighter does, which is why this site has its own scanner.
Not described
Known, not yet covered
- Reference: the command-line options of each system, the packs and package managers, the foreign-language interfaces (C, Java, Python) and the toolchains for building a stand-alone program are not described.
- Reference: no Prolog system could be run here, so the commands above have not been tried; the report of a syntax error by a real system could not be compared with the viewer's Problems list.
- Viewer: the viewer does not run a program, run tests or load other files; it reads the text only.