Swi Prolog For Mac



  1. That SWI-Prolog is now using ECLiPSe Prolog algorithm, could mean that its now also slower, gcd(a,b)=1 is a little weaker than canonical. For example gcd(4,-3)=1 and gcd(-4,3)=1, but usually -4r3 is chosen as canical. So in my system rational(-,+,+) does this step. But SWI-Prolog might be more complicated, inspecting the source I also see check.
  2. Find SWI-Prolog software downloads at CNET Download.com, the most comprehensive source for safe, trusted, and spyware-free downloads on the Web.
  3. We're using SWI Prolog, version 6.2.6. When you start Prolog, you should see an introductory greeting and then the Prolog command prompt. (so requires X for linux/Mac). Editing Prolog Code. Prepare source files using any convenient editor. The standard file extension for Prolog files is.pl.

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.

Portability[edit]

On Mac OS X there is a command, javahome, that returns the path for the user's enabled and preferred JVMs in the Java Preferences application. This command is Apple's advised way of defining the JAVAHOME environment variable.

There are Prolog implementations that are radically different, with different syntax and different semantics (e.g. Visual Prolog)[1] and sub-communities have developed around different implementations.[1]

Code that strictly conforms to the ISO-Prolog core language is portable across ISO-compliant implementations. However, the ISO standard for modules was never accepted by most Prolog implementors.[1]

Factors that can adversely affect portability include: use of bounded vs. unbounded integer arithmetic, additional types such as string objects, advanced numeric types (rationals, complex), feature extensions such as Unicode, threads, and tabling.[2] Use of libraries unavailable in other implementations and library organisation:[1]

Currently, the way predicates are spread over the libraries and system built-ins differs enormously. [...] Fortunately, there are only few cases where we find predicates with the same name but different semantics (e.g. delete/3)

Main features[edit]

PlatformFeaturesToolkitProlog Mechanics
NameOSLicenceNative GraphicsCompiled CodeUnicodeObject OrientedNative OS ControlStand Alone ExecutableC Interface[3]Java Interface[3]Interactive InterpreterDebuggerCode ProfilerSyntax
BPrologUnix, Windows, Mac OS XFree for non-commercial usesYesYesYesYesYesYesYesYesYesYesISO-Prolog, plus event-handling, CLP(FD), and tabling
JIPrologJVM, AndroidShareware/Commercial and AGPLYesYesYes via JavaYesYes via JavaYesYesYesISO-Prolog
CiaoUnix, Windows, Mac OS XGPL, LGPLYesYesYesYesYesYesYesYesYesISO-Prolog, plus extensions
DOS-PROLOGMS-DOSSharewareYesYesYesYesYesYesEdinburgh Prolog
ECLiPSeLinux, Windows, Solaris, macOSMPLYesYesYesYesYesYesYesExtended Prolog, Multi-dialect, including ISO
GNU PrologUnix, Windows, Mac OS XGPL, LGPLYesYesYesYesYesYesISO-Prolog
Jekejeke PrologJVM, AndroidDistribution EvaluationYesYesYesYesYesYesYesYesISO-Prolog, Java API
JLogJVMGPLYesYesYesYesISO-Prolog
JScriptLogWeb BrowserGPLYesISO-Prolog
jTrologJVMLGPLYesYesYesYesISO-Prolog tests[permanent dead link]
LPA-PROLOGWindowsCommercialYesYesYesYesYesYesYesYesYesYesYesEdinburgh Prolog with extensions
Open PrologMac OSFreewareYes
Poplog PrologLinux (32- and 64-bit), Unix, WindowsFree Open SourceOnly through POP-11, on LinuxYesYesYesYesYesYesEdinburgh Prolog, with interfaces to Poplog Common Lisp and Pop-11
SICStus PrologUnix, Linux, Windows, macOSCommercialYesYesYesYesYesYesYesYesYesYesYesISO-Prolog
Strawberry PrologWindows, UnixFreeware, CommercialYesYesYesYesYesNot ISO-Prolog + extensions
SWI-PrologUnix, Linux, Windows, macOSBSD LicenseYesYesYesYesYesYesYesYesYesYesISO-Prolog, Edinburgh Prolog
tuPrologJVM, AndroidLGPLYesYesYesYesYesYesISO-Prolog
Visual PrologWindowsFreeware, CommercialYesYesYesYesYesYesYesYesYes
XSB PrologLinux, Windows, Solaris, macOSLGPLYesYesYesYesYesYesYesYesYesISO-Prolog, tabled WFS
YAP-PrologLinux, Windows, Solaris, Mac OS X, HP-UXGPL or Artistic (user choice)YesYesYesYesYesYesYesYesEdinburgh, ISO-Prolog, Quintus and SICStus Prolog compatible

Operating system and Web-related features[edit]

Web-related
NameConditional compilationSocketsMulti-threadingTablingHTTP clientHTTP serverHTML ParserRDF Triple store
BPrologYes
CiaoYesYesYesYesYesYesYes
ECLiPSeYesYesYesYesYes
GNU PrologYes
Jekejeke PrologYesYesYesYesYes
LPA-PrologYesYesYesYes
SICStus PrologYesYesYes
SWI-PrologYesYesYesYesYesYesYesYes
Visual PrologYesYesYesYesYesYes
XSBYesYesYesYesYes
YAP-PrologYesYesYesYes

Static analysis[edit]

NameType checkerDeterminacy checkerCall-pattern checker
CiaoYesYesYes
GNU Prolog
Jekejeke Prolog
SICStus PrologYes
SWI-PrologYes
Visual PrologYesYesYes
XSB
YAP-Prolog

Optimizations[edit]

NameTail-Call OptimizationChoice Point EliminationEnvironment TrimmingJust-in-Time Indexing
CiaoYesYesYes?
ECLiPSeYesYesYesmulti-argument (compile time)
GNU PrologYesYesYes?
Jekejeke PrologYes (runtime)Yes (runtime)Yes (runtime)Yes
SICStus PrologYesYesYes
SWI-PrologYesYesYesYes
Visual PrologYes (compile time)Yes (compile time)N/AN/A (compile time)
XSBYesYesYes?
YAP-PrologYesYesYesYes
Swi

Release[edit]

NameVersionDate
BProlog8.12014-02-23
JIProlog4.1.6.12018-03-17
Ciao1.19.02020-03-21
DOS-PROLOG6.0
ECLiPSe7.0_542020-02-26
GNU Prolog1.4.52018-07-14
Jekejeke Prolog1.3.12018-11-02
JLog1.3.62007-09-13
JScriptLog0.7.5 beta2007-09-10
jTrolog
LPA-PROLOG7.02019-12-19
Open Prolog
Poplog PrologV15.652015-10-14
SICStus Prolog4.6.02020-05-04
Strawberry Prolog3.0 Beta 42013-12-10
SWI-Prolog8.2.02020-05-27
tuProlog3.2.12017-02-14
Visual Prolog9.0, Build 9022019-04-26
XSB Prolog3.82017-10-29
YAProlog6.3.32013-01-21
Machine

Benchmarks[edit]

  • Benchmarking issues: Odd Prolog benchmarking, Performance differences.[4]
  • Benchmarking software: older, Dobry[permanent dead link], Aquarius benchmark suite, (Bothe, 1990),[5](Demoen et al. 2001), benchmark descriptions
  • Benchmarking results: B-Prolog, SICStus, XSB,[6] SICStus vs Yap vs hProlog[7]
  • Benchmarking results: Survey of java prolog engines by Michael Zeising
  • Benchmarking results: OpenRuleBench yearly open-source benchmark of rule engines

References[edit]

  1. ^ abcdWielemaker, J.; Costa, V. T. S. (2011). 'On the Portability of Prolog Applications'. Practical Aspects of Declarative Languages. Lecture Notes in Computer Science. 6539. p. 69. CiteSeerX10.1.1.1030.9396. doi:10.1007/978-3-642-18378-2_8. ISBN978-3-642-18377-5.
  2. ^Jan Wielemaker and Vıtor Santos Costa: Portability of Prolog programs: theory and case-studies. CICLOPS-WLPE Workshop 2010.
  3. ^ abC/Java interface can also be used for graphics and OS control.
  4. ^B. Demoen, and P. Nguyen, About unnecessary performance differences between Prolog implementations, Proceedings of the Colloquium on Implementation of Constraint and Logic Programming Systems (CICLOPS 2001)
  5. ^Bothe, K. (1990). 'A prolog space benchmark suite'. ACM SIGPLAN Notices. 25 (12): 54–60. doi:10.1145/122193.122197.
  6. ^A Summary of XSB Performance (1993)
  7. ^Demoen, B.; Nguyen, P. L.; Vandeginste, R. (2002). 'Copying Garbage Collection for the WAM: to Mark or Not to Mark?'. Logic Programming. Lecture Notes in Computer Science. 2401. pp. 194–208. CiteSeerX10.1.1.13.2586. doi:10.1007/3-540-45619-8_14. ISBN978-3-540-43930-1.

External links[edit]

  • Overview of Prolog Systems by Ulrich Neumerkel
Retrieved from 'https://en.wikipedia.org/w/index.php?title=Comparison_of_Prolog_implementations&oldid=976451969'

CSE 341 - Programming Languages

We're using SWI Prolog, version 6.2.6.

When you start Prolog, you should see an introductory greeting and then the Prolog command prompt:

Running Prolog on attu

If you're planning on loading a file, it will simplify things to first navigate to the directory that contains your file, so that Prolog can find it easily.

In any case run Prolog from the command line using

Running Prolog on the CSE Undergrad Windows Machines

Run Prolog from the “Start” menu. It's here:
All Programs / DEV TOOLS & LANGUAGES / SWI-Prolog

If you want to load a file, you'll either need to specify an absolute file path, or change the current working directory to the appropriate place. Here's how to change the current working directory. If your files are in your home directory on the Z drive in the cse341 subdirectory, type this at the Prolog command prompt:

(The double backslash is needed because a single backslash indicates some special character, e.g. n for newline. And in case you're wondering, X will be unified with the previous working directory.)

Double-clicking on a .pl Prolog source file is going to start perl, so that's not going to work.

Running Prolog on a Personal Machine

SWI Prolog is available for Windows, Mac, and Linux. Here's the download page: http://www.swi-prolog.org/Download.html.

A few additional Macintosh hints: if you use the Finder and double-click on SWI Prolog in Applications, depending on your security settings, you may get an error. If you do, try right-clicking (or control-clicking) on the application instead, and say “run it anyway”. You can also run it from the command line using the swipl executable in /Applications/SWI-Prolog.app/Contents/MacOS, assuming you installed it in the default location. To use the graphical debugger, install xquartz (X11), then open a X11 terminal, and run Prolog from there.

Basic Prolog Commands

A few essential commands:

halt.
exit Prolog (short form: control-d)
consult(filename).
load the file named filename.pl (note the added .pl extension). If you need some more complex name (for example with a path), put it in single quotes, for example consult('/Users/schmertzkopf/squid.pl').
[filename].
shorthand for consult
help(topic) or apropos(topic).
Brings up the relevant section of the manual in a separate window (so requires X for linux/Mac).

Editing Prolog Code

Swi Prolog Editor Mac

Prepare source files using any convenient editor. The standard file extension for Prolog files is .pl

If you want to use emacs, include this in your .emacs file in your home directory: (Without this, emacs is going to think you're writing in perl.)

There are other versions of emacs Prolog mode if you want to try one - see e.g. Using SWI-Prolog with GNU-Emacs. However, the default mode should be fine for 341.

Debugging

SWI Prolog provides two interfaces to the debugger: a text-based and a graphical interface:

The graphical debugger doesn't seem to be installed with the version of Prolog on the Lab linux machines, unfortunately. It is on the Lab Windows machines, though.

Swi-prolog Macos Brew

For old-school debugging use the write goal. For example, here it is in the body of a rule: