SWI-Prolog is a
free implementation of the
programming language
A programming language is a system of notation for writing computer programs.
Programming languages are described in terms of their Syntax (programming languages), syntax (form) and semantics (computer science), semantics (meaning), usually def ...
Prolog
Prolog is a logic programming language that has its origins in artificial intelligence, automated theorem proving, and computational linguistics.
Prolog has its roots in first-order logic, a formal logic. Unlike many other programming language ...
, commonly used for teaching and
semantic web
The Semantic Web, sometimes known as Web 3.0, is an extension of the World Wide Web through standards set by the World Wide Web Consortium (W3C). The goal of the Semantic Web is to make Internet data machine-readable.
To enable the encoding o ...
applications. It has a rich set of features,
libraries
A library is a collection of Book, books, and possibly other Document, materials and Media (communication), media, that is accessible for use by its members and members of allied institutions. Libraries provide physical (hard copies) or electron ...
for
constraint logic programming
Constraint logic programming is a form of constraint programming, in which logic programming is extended to include concepts from constraint satisfaction. A constraint logic program is a logic program that contains constraints in the body of claus ...
,
multithreading,
unit testing
Unit testing, component or module testing, is a form of software testing by which isolated source code is tested to validate expected behavior.
Unit testing describes tests that are run at the unit-level to contrast testing at the Integration ...
,
GUI, interfacing to
Java
Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
,
ODBC
In computing, Open Database Connectivity (ODBC) is a standard application programming interface (API) for accessing database management systems (DBMS). The designers of ODBC aimed to make it independent of database systems and operating systems. An ...
and others,
literate programming
Literate programming (LP) is a programming paradigm introduced in 1984 by Donald Knuth in which a computer program is given as an explanation of how it works in a natural language, such as English, interspersed (embedded) with snippets of macr ...
, a
web server
A web server is computer software and underlying Computer hardware, hardware that accepts requests via Hypertext Transfer Protocol, HTTP (the network protocol created to distribute web content) or its secure variant HTTPS. A user agent, co ...
,
SGML
The Standard Generalized Markup Language (SGML; International Organization for Standardization, ISO 8879:1986) is a standard for defining generalized markup languages for documents. ISO 8879 Annex A.1 states that generalized markup is "based on t ...
,
RDF,
RDFS, developer tools (including an
IDE with a GUI
debugger
A debugger is a computer program used to test and debug other programs (the "target" programs). Common features of debuggers include the ability to run or halt the target program using breakpoints, step through code line by line, and display ...
and GUI
profiler), and extensive documentation.
SWI-Prolog runs on
Unix
Unix (, ; trademarked as UNIX) is a family of multitasking, multi-user computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
,
Windows
Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
,
Macintosh
Mac is a brand of personal computers designed and marketed by Apple Inc., Apple since 1984. The name is short for Macintosh (its official name until 1999), a reference to the McIntosh (apple), McIntosh apple. The current product lineup inclu ...
and
Linux
Linux ( ) is a family of open source Unix-like operating systems based on the Linux kernel, an kernel (operating system), operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically package manager, pac ...
platforms.
SWI-Prolog has been under continuous development since 1987. Its main author is
Jan Wielemaker
Jan Wielemaker (1960, Koudekerke) 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 name SWI is derived from ("Social Science Informatics"), the former name of the group at the
University of Amsterdam
The University of Amsterdam (abbreviated as UvA, ) is a public university, public research university located in Amsterdam, Netherlands. Established in 1632 by municipal authorities, it is the fourth-oldest academic institution in the Netherlan ...
, where Wielemaker was employed when he initiated the development of SWI-Prolog.
Execution model
SWI-Prolog is not based on the
Warren Abstract Machine
In 1983, David H. D. Warren designed an abstract machine for the execution of Prolog consisting of a memory architecture and an instruction set. This design became known as the Warren Abstract Machine (WAM) and has become the ''de facto'' standard ...
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
Arithmetic is an elementary branch of mathematics that deals with numerical operations like addition, subtraction, multiplication, and division. In a wider sense, it also includes exponentiation, extraction of roots, and taking logarithms.
...
, control flow, and
negation as failure
Negation as failure (NAF, for short) is a non-monotonic inference rule in logic programming, used to derive \mathrm~p (i.e. that p is assumed not to hold) from failure to derive p. Note that \mathrm ~p can be different from the statement \neg p o ...
. 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.
Constraint logic programming
Constraint logic programming functionality came rather late in the lifetime of SWI-Prolog, because it lacked the basic support. 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.
Extensions for SWI-Prolog
SWI-Prolog installs with a
web framework
A web framework (WF) or web application framework (WAF) is a software framework that is designed to support the development of web applications including web services, web resources, and web APIs. Web frameworks provide a standard way to build a ...
based on
definite clause grammar A definite clause grammar (DCG) is a way of expressing grammar, either for natural or formal languages, in a logic programming language such as Prolog. It is closely related to the concept of attribute grammars / affix grammars.
DCGs are usually as ...
s.
SWI-Prolog queries may be distributed over several servers and web pages through the Pengines system.
XPCE
XPCE is a
platform-independent object-oriented
Object-oriented programming (OOP) is a programming paradigm based on the concept of '' objects''. Objects can contain data (called fields, attributes or properties) and have actions they can perform (called procedures or methods and impleme ...
GUI toolkit
A widget toolkit, widget library, GUI toolkit, or UX library is a library or a collection of libraries containing a set of graphical control elements (called ''widgets'') used to construct the graphical user interface (GUI) of programs.
Most wid ...
for SWI-Prolog,
Lisp
Lisp (historically LISP, an abbreviation of "list processing") is a family of programming languages with a long history and a distinctive, fully parenthesized Polish notation#Explanation, prefix notation.
Originally specified in the late 1950s, ...
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
A button is a fastener that joins two pieces of fabric together by slipping through a loop or by sliding through a buttonhole.
In modern clothing and fashion design, buttons are commonly made of plastic but also may be made of metal, wood, o ...
,
menus,
sliders,
tabs and other basic
GUI widget
A graphical widget (also graphical control element or control) in a graphical user interface is an element of interaction, such as a button or a scroll bar. Controls are software components that a computer user interacts with through direct m ...
s. XPCE is available for all platforms supported by SWI-Prolog.
PceEmacs is a SWI-Prolog builtin editor. PceEmacs is an
Emacs
Emacs (), originally named EMACS (an acronym for "Editor Macros"), is a family of text editors that are characterized by their extensibility. The manual for the most widely used variant, GNU Emacs, describes it as "the extensible, customizable, s ...
clone implemented in Prolog (and XPCE). It supports proper
indentation
__FORCETOC__
In the written form of many languages, indentation describes empty space ( white space) used before or around text to signify an important aspect of the text such as:
* Beginning of a paragraph
* Hierarchy subordinate concept
* Qu ...
,
syntax highlighting
Syntax highlighting is a feature of text editors that is used for programming language, programming, scripting language, scripting, or markup language, markup languages, such as HTML. The feature displays text, especially source code, in differe ...
, full syntax checking by calling the SWI-Prolog
parser
Parsing, syntax analysis, or syntactic analysis is a process of analyzing a string of symbols, either in natural language, computer languages or data structures, conforming to the rules of a formal grammar by breaking it into parts. The term '' ...
, 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. It requires both SWI-Prolog and
Java SDK.
It is installed as a part of SWI-Prolog.
See also
*
Prolog
Prolog is a logic programming language that has its origins in artificial intelligence, automated theorem proving, and computational linguistics.
Prolog has its roots in first-order logic, a formal logic. Unlike many other programming language ...
*
Comparison of Prolog implementations
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 Pro ...
*
Prolog syntax and semantics
References
External links
* {{Official website, www.swi-prolog.org
Free and open source compilers
Prolog programming language family
Constraint programming
Integrated development environments
Free software programmed in C
Free software programmed in Prolog
Cross-platform free software
Software using the BSD license
Software using the GNU Lesser General Public License