swipl
Run and interpret Prolog programs
TLDR
Start an interactive session
Execute a command without showing any output
Execute a script
Print all shell configuration variables
Display version
SYNOPSIS
swipl [options] [file ...]
PARAMETERS
-f file
Load file as a Prolog source file.
-l file
Consult file. Same as `-f file` but suppresses file existence warnings.
-g goal
Execute goal after loading files. Goal must be specified as a quoted string.
-t goal
Top-level goal. Similar to `-g goal`, but used to define the top-level interaction loop. The default top-level is `halt`.
-q
Suppress informational messages at startup.
-tty
Force the use of terminal control even if standard input and output are redirected.
-nodebug
Start without debugging facilities.
-O
Optimize loaded code.
-s file
Use file as script. The arguments are passed via the `argv/1` predicate.
--version
Print the SWI-Prolog version number and exit.
--help
Print a summary of command-line options and exit.
DESCRIPTION
The `swipl` command starts the SWI-Prolog interactive toplevel shell. This shell allows users to interact with the Prolog system, loading Prolog code, posing queries, and debugging programs. It provides a read-evaluate-print loop (REPL) environment specifically designed for Prolog. `swipl` supports a wide range of command-line options to customize the behavior of the Prolog environment, including loading files, setting flags, and specifying the initial query to execute. It is the primary way to interact with SWI-Prolog from the command line, used extensively for development, testing, and running Prolog applications. The environment provides debugging tools such as tracing and spypoints. The core functionality revolves around the Prolog engine, offering features such as backtracking, unification, and logical inference to execute Prolog programs.
CAVEATS
The precise behavior of `swipl` may vary slightly depending on the SWI-Prolog version and the operating system. Error handling and resource management within the Prolog code itself can significantly impact the stability and performance of the system.
INITIALIZATION FILES
When `swipl` starts, it looks for initialization files. These files are automatically loaded and can be used to customize the Prolog environment, e.g., by defining commonly used predicates or setting up libraries. The location and names of these files depend on the system. Usually there are some files like `.swiplrc` or `init.pl`. Consult the SWI-Prolog documentation for specific details.
ENVIRONMENT VARIABLES
Several environment variables can influence the behavior of `swipl`. For example, `SWI_HOME_DIR` can be used to specify the location of the SWI-Prolog installation directory.
RETURN VALUES
The `swipl` command returns an exit code. A return code of 0 typically indicates success, while non-zero values indicate errors. The specific meaning of non-zero exit codes is documented in the SWI-Prolog reference manual. The return value may reflect if loading a file results in an error, the execution goal fails, or some other error occurs during start up or shutdown.
HISTORY
SWI-Prolog was originally developed by Jan Wielemaker at the University of Amsterdam. It has evolved over several decades, becoming a widely used open-source Prolog implementation. The `swipl` command has been the primary entry point for interacting with SWI-Prolog since its early versions. Its design emphasizes portability, extensibility, and integration with other programming languages.
SEE ALSO
plunit(1), pldoc(1)