Did you know ... Search Documentation:
SWI-Prolog's features

SWI-Prolog is a versatile implementation of the Prolog language. Its robust multi-threading, extended data types, unbounded arithmetic and Unicode representation of text allow for natural representation of documents (e.g., XML, JSON, RDF) and exchange of data with other programming paradigms. Its comprehensive low-level interface to C is the basis for high-level interfaces to C++, Java (bundled), C#, Python, etc (externally available). SWI-Prolog is equipped with an extensive web server (HTTP) framework that can be used both for providing (REST) services and end-user applications based on HTML5+CSS+JavaScript. Pengines (Prolog engines) allow clients to run queries against a client-provided program on a remote server using a generic API. Such programs can be executed in a sandbox.

Equipped with rich interfaces, Prolog is an attractive language for realising applications. Its incremental compilation combined with generally local and backtrackable data structures (undo) allows for patching the program and keep testing it without restarting. Its relational paradigm fits well with tabular data (RDBMS), while its recursive strength fits well with tree and graph shaped data. Prolog can naturally express simple rule sets required to implement the application logic.

Constraints and coroutining attach rules to (changing) data. Combined with backtracking, this can be used to solve many complicated combinatorial problems using a simple declarative specification. Classical examples are puzzles and planning problems.

SWI-Prolog offers a variety of development environments, most of which may be combined at will. The native system provides an editor written in Prolog that is a close clone of Emacs. It provides semantic highlighting based on real time analysis of the code by the Prolog system itself. Complementary tools include a graphical debugger, profiler and cross-referencer. Alternatvely, there is a mode for GNU-Emacs and an Eclipse plugin, both of which may be combined with the native graphical tools. Finally, SWISH provides a web-based environment based on the forementioned Pengines that can both be used to provide sandboxed access or full access after authentication. SWISH offers editing multiple sources using semantic highlighting. SWISH can manage plugins for rendering Prolog data using HTML5+CSS+JavaScript. This can be used to render data as tables, graphs, charts, etc.

SWI-Prolog provides an add-on distribution and installation mechanism called packs. A pack is a directory with minimal organizational conventions and a control file that describes the origin, version, dependencies and automatic upgrade support. Packs can be installed from an archive, GIT repository or URL using pack_install/1. Packs are used to share code in the community. The pack system has grown a couple of eco systems for dealing with types, coroutining, etc.

Below is a list of what we consider key features of SWI-Prolog with links to the relevant documentation.


  • fast compilation. E.g., loads WordNet 3.0 in 14 seconds from the Prolog source or 0.4 seconds from quick load file format (see qcompile/1). The WordNet source counts 821,515 lines. System: Ubuntu 16.04 on Intel i7-3770, 32Gb memory.
  • Robust and free of memory leaks. In use for several servers that run 24x7 (including this web service).
  • Small. The full development environment, including graphics, libraries and many interface packages, requires approx. 100MB hard disk. The kernel is about 1.4MB (Ubuntu 16.04 .so file)
  • Scales well for large applications. No limits on program size, atom length, term arity or integer values. No performance degradation on predicates with many (indexed) facts.
  • Just-In-Time indexing of both static and dynamic code on any argument greatly simplifies handling multi-moded relations with many clauses. As of version 7.5, multi-argument JITI is supported. This creates an index for the combined value of two arguments if there is no selective single-argument index.
  • Unbounded integer and rational number arithmetic based on GMP library.
  • The goodies: modules (upward compatible to Quintus and SICStus), garbage-collection (transparent to C/C++-code, including atom and clause garbage collection), last-call optimisation, dynamic expansion of the runtime stacks, ISO exception-handling (including C/C++ interface for catching and throwing exceptions).
  • attributed variables, coroutining (freeze/2, when/2, dif/2), global variables, cyclic terms.
  • Flag-controlled handling of occurs-check (false/true/error) see current_prolog_flag/2.
  • UNICODE character set handling internal. Ideal for web and international applications.
  • Multi-threading support: run multiple pre-emptively scheduled prolog engines on the same database.
  • Engines, also known as interactors provide coroutines that can be used for state accumulation and massive concurrency for e.g., swarm intelligence and similations.
  • Delimited continuations is a powerful building block for new control structures.
  • Tabling (SLG resolution) provides a more robust resolution technique for solving queries over complex interrelated rules.

Development tools

  • Source-level debugger on all platforms that supports graphics through XPCE (Windows, Unix/Linux, MacOSX).
  • Execution profiler (time and call statistics) for all major platforms (Windows, Linux, MacOSX).
  • Cross-Referencer. gxref/0 provides a graphical front-end for the extensible Prolog cross-referencer (xref).
  • Literate programming support through PlDoc. Provides integrated view on manual and application documentation and producing LaTeX documentation for your application.
  • Unit testing support through PlUnit.
  • SWISH provides a web-based platform for developing and running Prolog code in a collaborative environment.


  • Comprehensive set of built-in predicates, covering Part 1 of the ISO standard, the de-facto Edinburgh Prolog standard and important parts of Quintus and SICStus Prolog. Fair compatibility to Ciao, YAP and GNU-Prolog. Although the aim is to maintain compatibility wherever possible, SWI-Prolog deliberately deviates from the ISO standard to accomodate additional functionality and synchronise with modern languages. Read more in [Extensions](<pldoc/man?section=extensions> and Directions


  • Constraint Logic Programming, providing libraries for CHR (Constraint Handling Rules), clp(FD), clp(R,Q) and various others.


  • SWI-Prolog provides extensive client and server libraries for HTTP. The HTTP server framework deals with generating HTML, exchange of JSON or XML, authentication, sessions, and much more. Both client and server supports HTTPS.
  • Flexible and fast interface to the C- and C++-language. The interface allows for calling both ways, handling of non-determinism both ways and embedding of the SWI-Prolog kernel in C/C++ projects.
  • Interfaces to high level languages such as Java using JPL, Python and C# are available.
  • Database connectivity is provided by the ODBC interface.
  • Low level network support includes sockets (both TCP and UDP), SSL and TIPC.
  • Fast and flexible libraries for parsing SGML/XML (HTML), parsing RDF, store and query the RDF triple model.


  • Portable to many platforms, including almost all Unix/Linux platforms, Windows (7 and later, both 32 and 64-bit versions), MacOS X (using Xquartz for graphics) and many more. Both 32-bit and 64-bit hardware is supported. Sources are plain C99, configured automatically using GNU autoconf (configure, make, make install).
  • Machine-independent saved-states (save on one platform, run using the virtual machine of another platform).
  • Regular binary distributions for Windows (32/64 bits) and MacOS X (64 bits)) and PPAs for Ubuntu (stable and development)
  • Regular distribution of the full source packages. The sources are also accessible through GIT.


  • SWI-Prolog is distributed under the Simplified BSD license, also known as the BSD-2 license. Some of the used libraries and extension packages have different license conditions. The licenses applicable to a running configuration can be examined by running license/0. See license for details.