Did you know ... Search Documentation:
SWI-Prolog owl logoSWI-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 140,000 lines of code spread over 500 source files in 2.3 seconds on an AMD 5400+ system.
  • 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. 40MB hard disk. The non-graphical kernel is about 650KB, the graphics library adds about 1.2MB to the image.
  • 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.
  • 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 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.
  • 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.


  • 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.


  • 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 (Vista 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.