SWI-Prolog

Last updated
SWI-Prolog
Original author(s) Jan Wielemaker
Developer(s) Jan Wielemaker, Anjo Anjewierden, etc
Initial release1987;37 years ago (1987)
Stable release
9.2.2 [1]   OOjs UI icon edit-ltr-progressive.svg / 29 February 2024;9 months ago (29 February 2024)
Preview release
9.3.2 / 29 February 2024;9 months ago (2024-02-29)
Repository
Written in C, Prolog
Operating system Cross-platform
Available in English
Type Logic programming
License Simplified BSD, LGPL prior to version 7.3.33
Website swi-prolog.org

SWI-Prolog is a free implementation of the programming language Prolog, commonly used for teaching and semantic web applications. It has a rich set of features, libraries for constraint logic programming, multithreading, unit testing, GUI, interfacing to Java, ODBC and others, literate programming, a web server, SGML, RDF, RDFS, developer tools (including an IDE with a GUI debugger and GUI profiler), and extensive documentation.

Contents

SWI-Prolog runs on Unix, Windows, Macintosh and Linux platforms.

SWI-Prolog has been under continuous development since 1987. Its main author is Jan Wielemaker.

The name SWI is derived from Sociaal-Wetenschappelijke Informatica ("Social Science Informatics"), the former name of the group at the University of Amsterdam, where Wielemaker was employed when he initiated the development of SWI-Prolog. [2]

Execution model

SWI-Prolog is not based on the Warren Abstract Machine execution model of Prolog.

Instead, it is based on an extended version of the ZIP virtual machine, a minimal virtual machine for Prolog implementing a simple language consisting of only seven instructions. SWI-Prolog-specific extensions aim at improving performance in several ways: ad hoc instructions are introduced to support unification, predicate invocation, some frequently used built-in predicates, arithmetic, control flow, and negation as failure. Prolog can easily be compiled into this language, and the abstract machine code is easily decompiled back into Prolog. This feature is often exploited to interleave compiled and interpreted code execution. [3]

Constraint logic programming

Constraint logic programming functionality came rather late in the lifetime of SWI-Prolog, because it lacked the basic support. [4] This changed early in 2004, when attributed variables were added to the language. The Leuven CHR library was then the first CLP library to be ported to SWI-Prolog. We mention SWI-Prolog's INCLP(R) library (De Koninck et al. 2006), which provides non-linear constraints over the reals and was implemented on top of CHR. Later came a port of Christian Holzbaur's CLP(QR) library and a finite-domain CLP(FD) solver. Finally, a boolean CLP(B) solver was added. [5]

Extensions for SWI-Prolog

SWI-Prolog installs with a web framework based on definite clause grammars. [6] SWI-Prolog queries may be distributed over several servers and web pages through the Pengines system. [7]

XPCE

XPCE is a platform-independent object-oriented [8] GUI toolkit for SWI-Prolog, Lisp and other interactive and dynamically typed languages. Although XPCE was designed to be language-independent, it has gained popularity mostly with Prolog. The development XPCE graphic toolkit started in 1987, together with SWI-Prolog. It supports buttons, menus, sliders, tabs and other basic GUI widgets. XPCE is available for all platforms supported by SWI-Prolog.

PceEmacs is a SWI-Prolog builtin editor. PceEmacs is an Emacs clone implemented in Prolog (and XPCE). It supports proper indentation, syntax highlighting, full syntax checking by calling the SWI-Prolog parser, warning for singleton variables and finding predicate definitions based on the source information from the Prolog database.

Interfaces

JPL is a bidirectional interface between Java and Prolog. [9] It requires both SWI-Prolog and Java SDK. [10] It is installed as a part of SWI-Prolog.

See also

Related Research Articles

Logic programming is a programming, database and knowledge representation paradigm based on formal logic. A logic program is a set of sentences in logical form, representing knowledge about some problem domain. Computation is performed by applying logical reasoning to that knowledge, to solve problems in the domain. Major logic programming language families include Prolog, Answer Set Programming (ASP) and Datalog. In all of these languages, rules are written in the form of clauses:

Mercury is a functional logic programming language made for real-world uses. The first version was developed at the University of Melbourne, Computer Science department, by Fergus Henderson, Thomas Conway, and Zoltan Somogyi, under Somogyi's supervision, and released on April 8, 1995.

Prolog is a logic programming language that has its origins in artificial intelligence, automated theorem proving and computational linguistics.

Constraint Handling Rules (CHR) is a declarative, rule-based programming language, introduced in 1991 by Thom Frühwirth at the time with European Computer-Industry Research Centre (ECRC) in Munich, Germany. Originally intended for constraint programming, CHR finds applications in grammar induction, type systems, abductive reasoning, multi-agent systems, natural language processing, compilation, scheduling, spatial-temporal reasoning, testing, and verification.

<span class="mw-page-title-main">Class browser</span> Feature of coding platforms

A class browser is a feature of an integrated development environment (IDE) that allows the programmer to browse, navigate, or visualize the structure of object-oriented programming code.

ECLiPSe is a software system for the development and deployment of constraint logic programming applications, e.g., in the areas of optimization, planning, scheduling, resource allocation, timetabling, transport, etc. It is also suited for teaching most aspects of combinatorial problem solving, e.g., problem modeling, constraint programming, mathematical programming, and search techniques. It contains constraint solver libraries, a high-level modeling and control language, interfaces to third-party solvers, an integrated development environment and interfaces for embedding into host environments.

An Abstract Agent Programming Language or Artificial Autonomous Agents Programming Language or 3APL is an experimental tool and programming language for the development, implementation and testing of multiple cognitive agents using the Belief-Desire-Intention (BDI) approach.

Logtalk is an object-oriented logic programming language that extends and leverages the Prolog language with a feature set suitable for programming in the large. It provides support for encapsulation and data hiding, separation of concerns and enhanced code reuse. Logtalk uses standard Prolog syntax with the addition of a few operators and directives.

B-Prolog was a high-performance implementation of the standard Prolog language with several extended features including matching clauses, action rules for event handling, finite-domain constraint solving, arrays and hash tables, declarative loops, and tabling. First released in 1994, B-Prolog is now a widely used CLP system. The constraint solver of B-Prolog was ranked top in two categories in the Second International Solvers Competition, and it also took the second place in P class in the second ASP solver competition and the second place overall in the third ASP solver competition. B-Prolog underpins the PRISM system, a logic-based probabilistic reasoning and learning system. B-Prolog is a commercial product, but it can be used for learning and non-profit research purposes free of charge. B-Prolog is not anymore actively developed, but it forms the basis for the Picat programming language.

The following Comparison of Prolog implementations provides a reference for the relative feature sets and performance of different implementations of the Prolog computer programming language. A comprehensive discussion of the most significant Prolog systems is presented in an article published in the 50-years of Prolog anniversary issue of the journal Theory and Practice of Logic Programming (TPLP).

CLP(R) is a declarative programming language. It stands for constraint logic programming (real) where real refers to the real numbers. It can be considered and is generally implemented as a superset or add-on package for a Prolog implementation.

XPath is an expression language designed to support the query or transformation of XML documents. It was defined by the World Wide Web Consortium (W3C) in 1999, and can be used to compute values from the content of an XML document. Support for XPath exists in applications that support XML, such as web browsers, and many programming languages.

OptimJ is an extension for Java with language support for writing optimization models and abstractions for bulk data processing. The extensions and the proprietary product implementing the extensions were developed by Ateji which went out of business in September 2011. OptimJ aims at providing a clear and concise algebraic notation for optimization modeling, removing compatibility barriers between optimization modeling and application programming tools, and bringing software engineering techniques such as object-orientation and modern IDE support to optimization experts.

<span class="mw-page-title-main">Ciao (programming language)</span>

Ciao is a general-purpose programming language which supports logic, constraint, functional, higher-order, and object-oriented programming styles. Its main design objectives are high expressive power, extensibility, safety, reliability, and efficient execution.

SICStus Prolog is a proprietary, ISO-conforming implementation of the logic programming language Prolog. It is developed by the Swedish Institute of Computer Science since 1985 and puts a strong focus on performance and scalability.

Jan Wielemaker is a Dutch computer scientist. He initiated the SWI-Prolog implementation of the Prolog programming language in 1987 while employed at the University of Amsterdam, and he continued its development after moving to the Vrije Universiteit Amsterdam. Since 2017, he has been associated with the Centrum Wiskunde & Informatica. In 2020, he became the Director of SWI-Prolog Solutions b.v.

Shapes Constraint Language (SHACL) is a World Wide Web Consortium (W3C) standard language for describing Resource Description Framework (RDF) graphs. SHACL has been designed to enhance the semantic and technical interoperability layers of ontologies expressed as RDF graphs.

BNR Prolog, also known as CLP(BNR), is a declarative constraint logic programming language based on relational interval arithmetic developed at Bell-Northern Research in the 1980s and 1990s. Embedding relational interval arithmetic in a logic programming language differs from other constraint logic programming (CLP) systems like CLP(R) or Prolog-III in that it does not perform any symbolic processing. BNR Prolog was the first such implementation of interval arithmetic in a logic programming language. Since the constraint propagation is performed on real interval values, it is possible to express and partially solve non-linear equations.

Quintus Prolog is a proprietary implementation of the Prolog programming language based on the Warren Abstract Machine. Originally developed by Quintus Computer Science, it is currently maintained by SICS. It was long known as the most highly-performing implementation of Prolog, and the early 1990s, it defined a de facto standard for Prolog implementations.

References

  1. "Release V9.2.2".
  2. Tate, Bruce (2022). "Logic Programming Basics (Chapter 1)". Programmer Passport: Prolog. Pragmatic Bookshelf. ISBN   9781680509359.
  3. Körner, Philipp; Leuschel, Michael; Barbosa, João; Costa, Vítor Santos; Dahl, Verónica; Hermenegildo, Manuel V.; Morales, Jose F.; Wielemaker, Jan; Diaz, Daniel; Abreu, Salvador; Ciatto, Giovanni (2022). "Fifty Years of Prolog and Beyond". Theory and Practice of Logic Programming. 22 (6): 776–858. doi:10.1017/S1471068422000102. hdl: 10174/33387 . ISSN   1471-0684. Creative Commons by small.svg  This article incorporates textfrom this source, which is available under the CC BY 4.0 license.
  4. Jan Wielemaker, Tom Schrijvers, Markus Triska, Torbjörn Lager: SWI-Prolog. TPLP 12(1–2): 67–96 (2012).
  5. Markus Triska: The Boolean Constraint Solver of SWI-Prolog (System Description). FLOPS 2016: 45–61.
  6. Wielemaker, Jan; Huang, Zhisheng; van der Meij, Lourens (2008). "SWI-Prolog and the Web" (PDF). Theory and Practice of Logic Programming. 8 (3): 363–392. doi:10.1017/S1471068407003237. S2CID   5404048.
  7. Wielemaker, Jan; Lager, Torbjorn (14 May 2014). "Pengines: WebLogic Programming Made Easy". Theory and Practice of Logic Programming. 14 (special issue 4–5): 539–552. arXiv: 1405.3953 . doi:10.1017/S1471068414000192. S2CID   9949345.
  8. Programming in XPCE/Prolog.
  9. Paul Singleton; Fred Dushin; Jan Wielemaker (February 2004). "JPL: A bidirectional Prolog/Java interface". SWI-Prolog.
  10. Paul Singleton (February 2004). "JPL 3.x installation". SWI-Prolog.