Equipped with rich interfaces, Prolog is an attractive language for realizing applications. It’s 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 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 24×7 (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 optimization, 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 internally. Ideal for the 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.
- 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-Reference. gxref/0 provides a graphical front-end for the extensible Prolog cross-references (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.
- A 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 support 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 much 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.