GNU Prolog is a free Prolog compiler with constraint solving over finite domains developed by Daniel Diaz.
GNU Prolog accepts Prolog+constraint programs and produces native binaries (like gcc does from a C source). The obtained executable is then stand-alone. The size of this executable can be quite small since GNU Prolog can avoid to link the code of most unused built-in predicates. The performances of GNU Prolog are very encouraging (comparable to commercial systems).
Beside the native-code compilation, GNU Prolog offers a classical interactive interpreter (top-level) with a debugger.
The Prolog part conforms to the ISO standard for Prolog with many extensions very useful in practice (global variables, OS interface, sockets,...).
GNU Prolog also includes an efficient constraint solver over Finite Domains (FD). This opens contraint logic programming to the user combining the power of constraint programming to the declarativity of logic programming.
- conforms to the ISO standard for Prolog (floating point numbers, streams, dynamic code,...).
- a lot of extensions: global variables, definite clause grammars (DCG), sockets interface, operating system interface,...
- more than 300 Prolog built-in predicates.
- Prolog debugger and a low-level WAM debugger.
- line editing facility under the interactive interpreter with completion on atoms.
- powerful bidirectional interface between Prolog and C.
- native-code compiler producing stand alone executables.
- simple command-line compiler accepting a wide variety of files: Prolog files, C files, WAM files,...
- direct generation of assembly code 15 times faster than wamcc + gcc.
- most of unused built-in predicates are not linked (to reduce the size of the executables).
- compiled predicates (native-code) as fast as wamcc on average.
- consulted predicates (byte-code) 5 times faster than wamcc.
- FD variables well integrated into the Prolog environment (full compatibility with Prolog variables and integers). No need for explicit FD declarations.
- very efficient FD solver (comparable to commercial solvers).
- high-level constraints can be described in terms of simple primitives.
- a lot of predefined constraints: arithmetic constraints, boolean constraints, symbolic constraints, reified constraints,...
- several predefined enumeration heuristics.
- the user can define his own new constraints.
- more than 50 FD built-in constraints/predicates.
The GNU Prolog compiler is based on the Warren Abstract Machine (WAM). It first compiles a Prolog program to a WAM file which is then translated to a low-level machine independent language called mini-assembly specifically designed for GNU Prolog. The resulting file is then translated to the assembly language of the target machine (from which an object is obtained). This allows GNU Prolog to produce a native stand alone executable from a Prolog source (similarly to what does a C compiler from a C program). The main advantage of this compilation scheme is to produce native code and to be fast. Another interesting feature is that executables are small. Indeed, the code of most unused built-in predicates can be excluded from the executables at link-time.
GNU Prolog also includes an efficient constraint solver over Finite Domains (FD). The key feature of the GNU Prolog solver is the use of a single (low-level) primitive to define all (high-level) FD constraints. There are many advantages of this approach: constraints can be compiled, the user can define his own constraints (in terms of the primitive), the solver is open and extensible (as opposed to black-box solvers like CHIP),...Moreover, the GNU Prolog solver is rather efficient, often more than commercial solvers.
GNU Prolog is inspired by two systems developed by the same author:
- wamcc: a Prolog to C compiler. the key point of wamcc was its ability to produce stand alone executables using an original compilation scheme: the translation of Prolog to C via the WAM. Its drawback was the time needed by gcc to compile the produced sources. GNU Prolog can also produce standalone executables but using a faster compilation scheme.
The development of GNU Prolog started in January 1996 under the name Calypso.
- clp(FD): a constraint programming language over FD. Its key feature was the use of a single primitive to define FD constraints. GNU Prolog is based on the same idea but extends the power of primitive to make it possible more complex constraint definitions. In comparison to clp(FD), GNU Prolog offers new predefined constraints, new predefined heuristics, reified constraints,...
Currently the following architectures are supported:
If you are interested in porting GNU Prolog to another architecture read the PORTING file in src.
- ix86 / GNU/Linux
- ix86 / Win32 using Cygwin (see file src/WINDOWS-OLD)
- ix86 / Win32 using MinGW (see file src/WINDOWS-OLD)
- ix86 / Win32 using MSVC++ (see file src/WINDOWS-OLD)
- ix86 / SCO
- ix86 / Solaris
- ix86 / FreeBSD
- ix86 / OpenBSD
- ix86 / NetBSD
- ix86 / Darwin (Mac OS X)
- x86_64 / GNU/Linux
- x86_64 / Solaris
- x86_64 / Win64 using MinGW64 (see file src/WINDOWS)
- x86_64 / Win64 using MSVC++ (see file src/WINDOWS)
- x86_64 / Darwin (Mac OS X)
- PowerPC / GNU/Linux
- PowerPC / Darwin (Mac OS X)
- PowerPC / NetBSD
- sparc / SunOS (4.1.3 or higher)
- sparc / Solaris
- sparc / NetBSD
- alpha / GNU/Linux
- alpha / OSF1
- mips / irix
- arm 32bits / GNU/Linux (armv6, armv7)
- arm 64bits (aarch64)/ GNU/Linux (armv8)
- arm 64bits (aarch64) / Darwin (Mac OS X) (armv8)
You can consult the following files:
This manual is available in the following formats:
We provide both source and binary distributions for GNU Prolog.
- the main source distribution gprolog-1.5.0.tar.gz.
- Mac OS X installer package created on Big Sur using MacPorts by Paulo Moura (installs GNU Prolog in /opt/local/ and /opt/local/bin).
- Windows intel 32 bits auto-install setup (compiled under ix86 / Windows 10 with MSVC++).
- Windows intel 32 bits auto-install setup (compiled under ix86 / Windows 10 with MinGW gcc under MSys2).
- Windows intel 64 bits auto-install setup (compiled under x86_64 / Windows 10 with MSVC++).
- Windows intel 64 bits auto-install setup (compiled under x86_64 / Windows 10 with MinGW64 gcc under MSys2).
The GIT repository is hosted by GitHub.
For windows users, a Notepad++ User Defined Lanuage (UDL) profile file for GNU Prolog (also available from the Notepad++ wiki about UDL). To install: launch Notepad++, in the "Language" menu, chose "Define your own language", click on "Import" and select the downloaded .xml file. Then close and restart Notepad++. Files suffixed with ".pl" and ".pro" should be now recognized as Prolog files (else select "Prolog (GNU)" from the "Languages" menu). For more information see the Notepad++ wiki.
GNU Prolog is present on the Black Duck Open Hub site.
Contributions are welcome. If you want to include your contribution please post a mail to firstname.lastname@example.org (for more information on this list click here). Here is a list of available contributions:
- Bedevere - a SWIG wrapper
- CLIP - a CLP(Intervals) interpreter
- CLPGUI - a graphical user interface for CLP
- cTI - a constrained-based left Termination Inference tool for ISO-Prolog
- GNU Prolog/CX - an extension of GNU Prolog for Contextual Logic Programming
- gnuprolog-json - a GNU Prolog JSON library
- gnuprolog-redisclient - a GNU Prolog redis client
- gprolog-rh - an extension of gprolog with attributed variables, coroutinings and CLP over reals
- Logtalk - Object Oriented extension to Prolog
- Muscle PS/SC - an interface to the Muscle PC/SC library
- MySQL/Prolog - an interface to MySQL database
- ODBC/Prolog - a small ODBC interface module for gprolog
- XGP - a Mac OS X IDE connecting gprolog and Cocoa
- CGI programming - an introduction to CGI-Programming with GNU-Prolog
The mailing list email@example.com: is for communicating with other GNU Prolog users and/or implementors:
The mailing list firstname.lastname@example.org: is for reporting bugs:
- To inform other uses send a mail to email@example.com.
- To (un)subscribe to this list send a mail to firstname.lastname@example.org with (un)subscribe in the subject line.
- You can also (un)subscribe via the web at http://mail.gnu.org/mailman/listinfo/users-prolog.
- From the same site you can also browse the archive.
To inform other uses send a mail to email@example.com. To (un)subscribe to this list send a mail to firstname.lastname@example.org with (un)subscribe in the subject line. You can also (un)subscribe via the web at http://mail.gnu.org/mailman/listinfo/bug-prolog.
From the same site you can also browse the archive.
Bug reports are crucial for our work. If we don't know about problems, we cannot fix them. On the other hand it is a waste of time to read/check/answer for bugs which are not bugs ! Please consult the manual (an on-line version is available). If you can try to check if the bug occurs with the last unstable version (all unstable versions are here). If you already use the last unstable version try the last stable version. When you are sure you have discovered a bug, please report it to email@example.com (for more information on this list click here).
Your report should include all these things:
- The type of machine you are using (use uname -a under Unix).
- GNU Prolog version (use gprolog --version).
- The operands given to the `configure' and the output of the configuration if the bug concerns the compilation/installation phase.
- The complete text of any files needed to reproduce the bug. Try to obtain a minimal example showing the bug.
- The precise commands we need to type to reproduce the bug.
- A description of what behavior you observe that you believe is incorrect.
- If you wish to mention something in the GNU Prolog source, show the line of code with a few lines of context. Do not just give a line number.
Verbatim copying and distribution of this entire article is permitted
in any medium, provided this notice is preserved.