Программа пролог для linux
The official packages are often out of date. PPAs and snaps are created automatically for every release.
-
are available for Ubuntu. are available for Linux distributions with snapd installed.
Installing from source
Installing from source is often the best option for installing on Linux and *BSD based systems. Building is not complex. This document describes building 7.7.20 or later using cmake. See this page for building older versions using GNU autoconf and make.
Downloading SWI-Prolog
Download the SWI-Prolog source
- As a tar ball from the download page
- Using GIT from GIThub
Preparing the source (when downloading using GIT)
The tar ball is self contained. The GIT repository contains sub modules. The git repository is downloaded (cloned) using the commands below:
Similarly, the sequence to update the source using git and rebuild is
Getting the prerequisites
Building SWI-Prolog from source requires tools as well as libraries. We maintain pages that describes the required dependencies by platform. The last entry of the list below describes the dependencies in platform independent way.
Building using cmake
Using cmake the system is typically build in a subdirectory of the downloaded sources. The build system does not add or modify any file in the source tree and (thus) multiple subdirectories can be created holding different configurations. A built system can simply be removed by removing the build directory. Basic instruction to build the system are below. The first alternative installs the system in your home directory and used ninja to build the system. The second alternative uses classical make and installs in `/usr/local`. The `ctest -j 4` tests the system using 4 parallel jobs. Testing is encouraged but not required.
A full description for installing a particular configuration in a particular location, dealing with development workflows, etc. can be found in the file CMAKE.md
Post installation (JPL)
If you want to call Java from Prolog using JPL, you need to add the directory holding the JVM shared objects to the dynamic linker search path. Using default installation on Ubuntu, this is achieved by adding the following to your ~/.profile . Check your Java configuration to find the exact path.
Tag confusing pages with doc-needs-help | Tags are associated to your profile if you are logged in | Report abuse
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.
- 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.
- 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.
- 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)
- the general README file.
- the NEWS file.
- the ChangeLog file.
- HTML entirely on one web page
- HTML with one web page per chapter
- HTML compressed entirely on one web page (gzipped tar file)
- HTML compressed with one web page per chapter (gzipped tar file)
- PostScript
- Microsoft HTMLHelp (chm) version
- TeX dvi (gzipped tar file)
- Old versions can be found in this directory.
- Unstable versions can be found in this directory.
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.
- Bedevere - a SWIG wrapper
- CLIP - a CLP(Intervals) interpreter - 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 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.
Copyright (C) 1999-2021 Daniel Diaz
Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
I need to write some Prolog programs for a class.
14 Answers 14
Prolog mode for (X)Emacs.
As mentioned you can use SWI-Prolog. If you like Eclipse there is an Eclipse plug-in that integrates SWI-Prolog into Eclipse. This way you have the best of both worlds, for example the SVN etc functions of Eclipse and the graphic debugger of SWI-Prolog. Worth checking out.
@user2278330 - Welcome to Stack Overflow. If you have a question, please open a new thread, rather than modifying an existing answer. You can include a link to this response if its relevant.
SWI-Prolog comes with excellent IDE tools, an Emacs-clone text editor, interactive debugger, complete browseable help system and docs. Give it a try.
I've not tried it (mostly because I never thought to combine the words "Prolog" and "NetBeans" before now), but there appears to be Prolog support for NetBeans. It's not a simple plugin, but a tutorial that shows how to add Prolog support to NetBeans.
I'd say NetBeans was way overkill for Prolog. I find any old text editor (gedit does okay, but I use a Mac with SubEthaEdit). If you can change a mode so that comments are marked, there isn't really much syntax to highlight!
If you were already using NetBeans for Java, C++, or Ruby, though, you'd be familiar with it and want to use it for Prolog too.
NB ide doesn't support Prolog. What you refer to is how to create an IDE that supports Prolog based on NB Platform.
@simpatico: Thanks, I updated my answer to try and make it more clear that the link goes to a tutorial, not a plugin.
A good point to start is to use Emacs' default Prolog mode plus the additions described here. You can also try ediprolog, which aims for a tighter Emacs-Prolog integration.
Ideone supports Prolog. You can use it online just with a browser.
Prolog Development Tools (ProDT) is a Prolog Integrated Development Environment (IDE) aiming to be as rich in functionality as the Eclipse's java IDE, giving the developer a single environment where it can control the development of a Prolog project from code edition, test execution, etc.
This project stands on top of Eclipse's projects to take advantage of its already existent features and its extensibility and works on any environment Eclipse works including windows, linux and mac OSX.
I have an interest in playing and fuxing with prolog, I have installed the swi-prolog and added the repository, just in case anyone is interested on which one commands I used:
How do I actually begin to write prolog codes on my linux machine? for my regular programming I use VIM to write/edit/debug and terminal to compile. Can I use vim to write prolog? How do i compile or use the prolog interpreter(i think that is what it is called)?
Note that SWI-Prolog can be installed directly from the Ubuntu repositories (i.e. without PPA): sudo apt-get swi-prolog .
6 Answers 6
Yes, you can use any text editor, incl. VIM. Once you have written a Prolog source file, say, file.pl , you can load it into SWI-Prolog like so:
This will compile your file and take you to an interactive shell where you can then ask queries against the definitions in your file.
If you want to use your Prolog program in batch mode, you can use:
where goal is the goal/query you want to evaluate. Note that in this case you won't be getting the option to ask for alternative solutions.
Thank you, I will play around with those, is there a command where I can exit the the prolog shell? I hate to open and close my terminal for every time I want to re-run or edit the code
On Ubunutu, I started off using emacs, which at least does syntax highlighting:
(2 emacs suggestions on that page ^)
But now I use prolog in anger, I use an Eclipse plugin called PDT:
Especially useful is the real-time line by line debug and trace, so you can step into, step over individual predicates, monitor variables names etc.. just like an other real IDE you would find in eclipse.
Probably only worth installing if you're going to use it a LOT, since the install is a lot of work, but it's a great IDE.
But if you like your low level editors like VIM, you will have to use the debug and trace tools built into swi-prolog, see:
To work out how the strange and beautiful prolog interpreter works, using a tracer of some kind is a must-have.
Linux versions are often available as a package for your distribution. We collect information about available packages and issues for building on specific distros here. We provide a PPA for Ubuntu and snap images
Android binaries are available for Termux as the package swi-prolog . See also Building SWI-Prolog on Android using LinuxOnAndroid
Please check the windows release notes (also in the SWI-Prolog startup menu of your installed version) for details.
Self-installing executable for Microsoft's Windows 64-bit editions. Requires at least Windows 7. See the reference manual for deciding on whether to use the 32- or 64-bits version. This binary is linked against GMP 6.1.1 which is covered by the LGPL license.
Self-installing executable for MS-Windows. Requires at least Windows 7. Installs swipl-win.exe and swipl.exe. This binary is linked against GMP 6.1.1 which is covered by the LGPL license.
Installer with binaries created using Macports. Installs /opt/local/bin/swipl . Needs xquartz (X11) and the Developer Tools (Xcode) installed for running the development tools
Installer with binaries created using Macports. Installs /opt/local/bin/swipl . Needs xquartz (X11) and the Developer Tools (Xcode) installed for running the development tools
Sources in .tar.gz format, including packages and generated documentation files. See build instructions.
SWI-Prolog reference manual as PDF file. This does not include the package documentation.
SWI-Prolog version 8
The SWI-Prolog 8.0 major release marks mostly a milestone for the internals, stability, deployment options and maintainability of the system. SWI-Prolog extensions and incompatibilities wrt. traditional Prolog are described in extensions.
SWI-Prolog 8.4.x Adds interfaces to Redis and STOMP micro services, isolated transactions and additional thread synchronization, new support for deterministic coding using $/0, $/1 and det/1 and monotonic tabling.
Читайте также: