swipl(1)

πŸ’… swipl β€” the SWI-Prolog girlies' manual (General Commands Manual, section 1)

okay so bestie, welcome to the swipl(1) page πŸ¦‹ this is the command you type to summon SWI-Prolog 10.0.2 into existence. it's giving main character energy for the whole Prolog ecosystem, and we're gonna walk through it together, no cap ✨


✨ NAME ✨

swipl β€” SWI-Prolog 10.0.2 πŸ’– (yes the version number is right there in the name, she's not shy)


🌸 SYNOPSIS 🌸

swipl [--help|--version|--arch|--dump-runtime-variables]
swipl [options] prolog-file ... [--] [arg ...]
swipl [options] [-o output] -c file ...
swipl [options] [-o output] -b initfile ...

so like, there are four whole moods here and they do completely different things, let me break it down πŸŽ€

  • the first one? that's the info-drop version. it tells you stuff about the system and then immediately dips, like "k bye" πŸ‘‹
  • the second one is the one you'll be living in, fr fr. it's the primary way to call Prolog on one or more Prolog source file(s), and you can pass arguments through to the application β€” the app can grab them with current_prolog_flag(argv, Argv) πŸ”₯
  • the third one is for creating a saved state 🫢
  • and the last one is for boot-compilation of the Prolog parts of the system. iykyk, that's the deep lore πŸ’€

πŸ’œ DESCRIPTION πŸ’œ

okay so picture this: SWI-Prolog is a comprehensive and stable implementation of the Prolog language, and she comes with a large set of libraries. like, a whole wardrobe πŸ‘‘

among its distinguishing features β€” and bestie, these are the iconic ones:

  • mature support for multi-threading 🧡
  • a mature embedded web-server library 🌐
  • graphical development tools β€” the debugger, profiler, cross-referencer, and editor 🎨
  • an embedded efficient RDF store πŸ“š
  • support for XML/SGML/HTML and Unicode 🌈

and the more widely supported features, because she contains multitudes:

  • support for constraint programming
  • atom garbage collection πŸ—‘οΈ
  • interfaces to databases (ODBC), C, C++, and Java (JPL) πŸ’…

also, SWI-Prolog implements the ISO core standard ⭐ β€” yes, she follows the rules. but also, many of its extensions are largely compatible to YAP and SICStus Prolog, so if you're coming over from those, you're gonna be fine πŸ’–

real talk though: this manual page only lists the commandline options. that's it. that's the whole assignment here.

full documentation is available on-line, plus in HTML and PDF format, from the WWW home page at http://www.swi-prolog.org 🌸 go look, she's got range


✨ OPTIONS ✨

okay bestie, this is the big one, the main character list πŸ’… every single flag, no skips, let's go

  • --help β€” gives you a lil summary of the most important options. just the hits πŸ’–
  • --version β€” shows off the version and architecture info. slay, who is she? πŸ‘‘
  • --abi-version β€” prints the ABI version key. this key is literally the thing that tells you whether different interfaces are binary-compatible with each other πŸ¦‹
  • --arch β€” prints the architecture identifier. that's it, that's the whole vibe πŸŽ€
  • --dump-runtime-variables[=format] β€” dumps info that's generally useful for installation scripts, in whatever form format says. the defined formats are sh (the default, bourne shell) and cmd (Windows CMD). swipl-ld(1) uses this to grab the deets it needs about Prolog. you normally call it like this:
eval `swipl --dump-runtime-variables`

which sets these shell variables, no cap:

  • CC β€” the C-compiler used to compile SWI-Prolog.
  • PLBASE β€” the home directory of SWI-Prolog. same value as what the current_prolog_flag home returns.
  • PLARCH β€” the architecture identifier in use. together with PLBASE this pins down where all the components live. for example, the library for embedding is in $PLBASE/lib/$PLARCH/libswipl.a
  • PLBITS β€” address bits for the VM. either 32 or 64.
  • PLLIB β€” the CC identifier to link against SWI-Prolog. typically -lswipl
  • PLLIBSWIPL β€” the full path name to the shared object (DLL) that provides the Prolog core.
  • PLLIBS β€” additional libraries needed for linking PLLIB
  • PLCFLAGS β€” flags you need to pass to the C-compiler to generate compatible code.
  • PLLDFLAGS β€” flags you need to pass to the C-linker for linking embedded executables.
  • PLSOEXT β€” the extension the hosting OS uses for shared objects. on most Unix systems this is "so"; on MS-Windows it's "dll". AIX uses "o", HPUX uses "sl".
  • PLSOPATH β€” the environment variable the hosting OS uses to extend the search path for shared objects. for example, on ELF systems this is "LD_LIBRARY_PATH" and on MS-Windows it's "PATH".
  • PLVERSION β€” numeric representation of the SWI-Prolog version.
  • PLVERSIONTAG β€” if present, a version tag like "rc1".
  • PLSHARED β€” has the value yes if Prolog supports linking shared libraries using load_foreign_library/[1,2] and no otherwise.
  • PLTHREADS β€” has the value yes if Prolog was compiled for multi-threading and no otherwise.
  • --home=DIR β€” use DIR as the home directory 🏠
  • --stack-limit=size[bkmg] β€” sets the combined stack limit to size bytes. the suffix is case insensitive and says what the unit is: b (bytes), k (Kbytes), m (Mbytes) or g (Gbytes) 🌈
  • --table-space=size[bkmg] β€” sets the table space limit for SLG resolution (tabling) to size bytes. same suffixes as --stack-limit ✨
  • --shared-table-space=size[bkmg] β€” sets the table space limit for shared tabling to size bytes. again, same suffixes as --stack-limit πŸ’«
  • -O β€” optimised compilation. go peep set_prolog_flag/2 in the SWI-Prolog Reference Manual for the tea πŸ”₯
  • -b initfile ... -c file ... β€” boot compilation. the initfile ... ones get compiled by the C-written bootstrap compiler, and file ... get compiled by the normal Prolog compiler into an intermediate code file. heads up bestie: this option is for system maintenance and is given for reference only 🚧
  • -c file ... β€” compile file ... into an intermediate code file.
  • -d level β€” set debug level to level. also for system maintenance, given for reference only πŸ› οΈ
  • --packs[=bool] β€” disable attaching extension packs (aka add-ons).
  • --pce[=bool] β€” disable the XPCE GUI subsystem.
  • --pldoc[=port] β€” starts the PlDoc documentation system on a free network port and launches your browser on http://localhost:port. if port is given, the server starts at that port but the browser does not get launched. no auto-open, you're on your own πŸ¦‹
  • -f file β€” use file as the initialisation file instead of init.pl. and -f none stops SWI-Prolog from even searching for an initialisation file πŸ‘€
  • -F file β€” pick the startup script from the SWI-Prolog home directory. file gives the base-name of the script, and the extension is .rc. the default script gets deduced from the basename of the executable, taking all the leading alphanumerical chars (letters, digits and underscore) from the program name. so if the program is named swi-2.0 it'll try to load the file swi.rc from the SWI-Prolog home directory. if the file doesn't exist, or you don't have read-access to it, the script is silently not loaded. ghosted, basically πŸ™ˆ
  • -s file β€” load file as a script. you can use this from the shell to make Prolog load a file before it enters the toplevel. deprecated though, since file names with a Prolog extension (.pl or .qlf) are used to load the program πŸ’€
  • -l file β€” load file as a script. this is a synonym for -s that plays nice with several other Prolog implementations. if you pass multiple -s or -l arguments, all the specified files get loaded in the order they appear on the argument list πŸ’–
  • --quiet[=bool], -q β€” operate silently. suppresses all informational messages. the introvert flag 🀫
  • --debug[=bool] β€” disable generating code that can be debugged using trace/0, spy/1, etc.
  • --debug-on-interrupt[=bool] β€” immediately start handling SIGINT (Control-C) to start the debugger. by default this is enabled when the interactive toplevel is entered ⚑
  • --on-error=style β€” how to handle a (printed) error message. default is print, which causes errors to be printed while execution continues. using status continues just like print, but halt/0 makes the process exit with status 1 β€” and halt makes the process exit with status 1 on the first error 🚨
  • --on-warning=style β€” same energy as --on-error, but for warning messages ✨
  • -g goal β€” goal is executed right before entering the top level. this option can appear multiple times, and goals are executed in the order they appear. possible choice points get pruned. if a goal fails, an error is printed (depending on the -q flag) and the process stops with exit code 1. if a goal raises an exception, the error is printed and the process stops with exit code 2. if no goal is present, version/0 is called to write the welcome message β€” so you can suppress the welcome message by giving -g true. goal can be a complex term, and in that case you'll normally need quotes to protect it from being expanded by the Unix shell 😌
  • -o output β€” used together with -b or -c to determine the output file for compilation.
  • -p alias=pathlist β€” define a path alias for file_search_path/2. pathlist is a ":" separated list of values for the alias. peep file_search_path/2 in the SWI-Prolog Reference Manual for more πŸ’œ
  • -t goal β€” use goal as the interactive top level instead of the default goal prolog/0. goal can be a complex term. if the top level goal succeeds, SWI-Prolog exits with status 0. if it fails, the exit status is 1. this flag also determines the goal started by break/0 and abort/0. and if you wanna stop the user from entering interactive mode, start the application with -g goal and give halt as the top level πŸ›‘
  • -x bootfile β€” start from an intermediate code file that resulted from a Prolog compilation using the -b or -c option, or that was created using qsave_program/[1,2] πŸ“¦
  • --tty[=bool] β€” switches tty control (using ioctl(2)). normally tty control is switched on, and this default depends on the installation. you might wanna switch tty control off if SWI-Prolog is used from an editor like GNU Emacs. if it's switched off, get_single_char/1 and the tracer will wait for a carriage return ⌨️
  • --win-app β€” this option is available only in swipl-win.exe. the Start menu shortcut uses it to change the working directory to ...\Documents\Prolog. the Prolog subdirectory will be created if it doesn't exist πŸͺŸ
  • --signals[=bool] β€” disable handling of signals. often used when SWI-Prolog is embedded in another application on Unix systems πŸ“‘
  • --sigalert=NUM β€” use NUM for unblocking system calls. default is SIGUSR2. using 0 disables installing a signal handler, delaying the delivery of thread signals until the blocking system call completes ⏳
  • --threads[=bool] β€” disable creating threads in the multi-threaded version. notably this prevents running global garbage collection on a separate thread, and it may be used for situations where multiple threads are not desirable 🧡
  • --traditional β€” disable SWI-Prolog version 7 extensions that are incompatible with earlier versions. old-school mode, vintage vibes πŸ‘‘
  • -- β€” stop scanning for more arguments. that's the cut, periodt βœ‚οΈ

🌸 ENVIRONMENT VARIABLES 🌸

  • SWI_HOME_DIR β€” the location for finding the startup file and the libraries. normally discovered from the executable or the configured default location. providing the value through the environment may be needed if SWI-Prolog is embedded into another executable 🏑

πŸ’– ON-LINE HELP πŸ’–

SWI-Prolog has on-line help, and it's honestly iconic. it gives you a fast lookup and browsing facility for the SWI-Prolog Reference Manual, and the on-line manual can show predicate definitions as well as entire sections of the manual πŸ¦‹

  • help β€” equivalent to help(help/1).
  • help(+What) β€” show a specified part of the manual. What is one of:
    • Name/Arity β€” give help on the specified predicate 🎯
    • Name β€” give help on the named predicate with any arity, or a C interface function with that name πŸ”
    • Section β€” display the specified section of the SWI-Prolog Reference Manual. section numbers are dash separated numbers: e.g. 2-3 refers to section 2.3 of the manual πŸ“–

if Prolog is used together with the GUI tool XPCE, these predicates start a graphical interface, giving you a coherent interface to help/1, apropos/1 and explain/1 ✨

πŸ“ FILES πŸ“

okay so bestie, this particular install of SWI-Prolog got built with the configure option --prefix=/usr. iconic. that means everything should live where we say it lives below. but if the files are NOT chillin' at the spot we promised? red flag 🚩 β€” the install has probably been moved around. no stress, you can always find your local install directory with this lil query:

?- current_prolog_flag(home, Home).
  • ~/.config/swi-prolog/init.pl β€” your personal initialisation files, which SWI-Prolog peeks at on startup. πŸ’… the exact location depends on the OS, so don't @ me if it's somewhere slightly different on your machine.

πŸ‘€ SEE ALSO πŸ‘€


πŸ’€ WARRANTY πŸ’€

ngl bestie, this is the part where the lawyers speak, and they are not playing. listen up:

The software is provided as is, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and non infringement. In no event shall the author or his employer be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.

fr fr: no warranty, no liability, no take-backs. it's giving "you're on your own, but lovingly." 😭

πŸ“œ LICENSE INFORMATION πŸ“œ

SWI-Prolog is distributed under the Simplified BSD or BSD-2 License. πŸŽ€ a particular configuration may contain components that are subject to other license conditions. use license/0 to find components with less permissive license conditions. see the SWI-Prolog license page at http://www.swi-prolog.org/license.html for details. πŸ¦‹


Copyright (c) 1986-2020 University of Amsterdam, VU University Amsterdam


🌸 AUTHOR 🌸

Jan Wielemaker


and that's the whole page, bestie, you made it to the end 🫢✨ this was the SWI-Prolog 8 manual, dated Oct 10, 2020, section swipl(1) β€” go forth and slay your Prolog, you absolute main character πŸ’…πŸŒˆ

πŸ“¦ where this page comes from
  • fedora 44: swi-prolog-core 10.0.2-1.fc44 Β· BSD-2-Clause AND (Brian-Gladman-3-Clause OR GPL-1.0-or-later) AND BSD-3-Clause AND dtoa AND LicenseRef-Fedora-Public-Domain AND MIT AND Unicode-DFS-2016 AND Zlib
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms