Questions tagged [swi-prolog]

SWI-Prolog is an open source implementation of Prolog that runs on Unix, Windows and Mac.

is an open source implementation of the programming language , commonly used for teaching and semantic web applications. It has a rich set of features and libraries including:

  • Constraint logic programming
  • Multithreading
  • Unit testing
  • GUI
  • Interfacing to Java
  • ODBC and others
  • Literate programming
  • A web server
  • SGML
  • RDF and RDFS

Along with developer tools (including an IDE with a GUI debugger and profiler).

SWI-Prolog runs on Unix, Windows, and Macintosh 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 is employed. The name of this group has changed to HCS (Human-Computer Studies).

http://www.swi-prolog.org/

Useful links

1221 questions
6
votes
1 answer

How to use JPL (bidirectional Java/Prolog interface) on windows?

I'm interested in embedding a Prolog interpreter in Java. One option is using JPL, but the download links on the JPL site are broken, and the installation page mentions a jpl.zip that I can't find. I downloaded SWI-Prolog which seems to include JPL…
Firas Assaad
  • 25,006
  • 16
  • 61
  • 78
6
votes
1 answer

Using maplist with a lambda that does not have a body?

Having a list List filled with numbers, I want to obtain a list of pairs Pairs, where each pair in Pairs is in the form -0, i.e., each number of List should be followed by -0. I came up with following solution to this, using maplist and a…
Markus Weninger
  • 11,931
  • 7
  • 64
  • 137
6
votes
2 answers

What occurs-check optimizations is SWI Prolog using?

To quote the SICStus Prolog manual: The usual mathematical theory behind Logic Programming forbids the creation of cyclic terms, dictating that an occurs-check should be done each time a variable is unified with a term. Unfortunately,…
MWB
  • 11,740
  • 6
  • 46
  • 91
6
votes
1 answer

How add SWI-Prolog terminal in VSCode?

How can an SWL-Prolog terminal be added in VSCode? Like PowerShell but SWI-Prolog terminal.
Greg.malyuga
  • 61
  • 1
  • 1
  • 3
6
votes
4 answers

Call prolog predicate from python

I have some .pl file and I want to call predicate declared in it from python script. How can I do that? For example, test.pl rD( [], Ans, Ans ). rD( [X|Xs], Ans, Acc ) :- member( X, Acc ), rD( Xs, Ans, Acc ), !. rD( [X|Xs], Ans, Acc ) :- …
6
votes
1 answer

How to read a csv file into a list of lists in SWI prolog where the inner list represents each line of the CSV?

I have a CSV file that look something like below: i.e. not in Prolog format james,facebook,intel,samsung rebecca,intel,samsung,facebook Ian,samsung,facebook,intel I am trying to write a Prolog predicate that reads the file and returns a list that…
6
votes
1 answer

Optimizing CLPFD performance (cumulative, global_cardinality)

I've written some predicates to solve large scheduling problem and they work well but I'd like them to have some better performance. I've run profile/1 and what I see is that CLPFD-related predicates take 99% of the time. Especially garbage_collect…
Grzegorz Adam Kowalski
  • 5,243
  • 3
  • 29
  • 40
6
votes
4 answers

SWI-prolog - how to clear terminal screen with a keyboard shortcut or global predicate?

I want to clear screen inside SWI-prolog console using either keyboard shortcut or command (i guess in Prolog you call that "predicate"). Here is similar question where i kinda find what i need - there is predicate that works for…
TTB_Detagari
  • 81
  • 1
  • 1
  • 5
6
votes
1 answer

SWI-Prolog read http header

I don't fully understand how SWI Prolog handles http. I have the following code which mostly works apart from the get_header/1. I need to be able to reader the header file of the http request to get a value. How do I do that? Do I use…
user27815
  • 4,767
  • 14
  • 28
6
votes
3 answers

how to split a sentence in swi-prolog

I am trying my hands on SWI-Prolog in win xp. I am trying to understand how to split a sentence in Prolog into separate atoms. Ex : Say I have a sentence like this : "this is a string" Is there any way to get individual words to get stored in a…
JPro
  • 6,292
  • 13
  • 57
  • 83
6
votes
1 answer

Why no division in CLP(FD) in Prolog?

I could not find division (/) symbol on this page of CLP(FD): http://www.swi-prolog.org/man/clpfd.html Also this simple code give error: :-use_module(library(clpfd)). afn(A,B,C):- C #= B / A. ?- afn(23, 56, C). ERROR: Domain error:…
rnso
  • 23,686
  • 25
  • 112
  • 234
6
votes
1 answer

Optimisation in swi prolog

Say I want to find argmax(x,y,z) -1/2(20x^2+32xy +16y^2)+2x+2y. subject to: x>=0, y>=0,z>=0 and -x-y+z =0. I know the partial derivatives being set to 0 is : -20x-16y+2=0 and -16x-16y+2 =0 so we could have x= 0 and y =1/8 and z=1/8. How would I do…
user27815
  • 4,767
  • 14
  • 28
6
votes
0 answers

SWI-prolog memory to upload a file

I have a problem, I followed this tutorial, but when I upload a file, it remains in memory and is never released. I use swi-prolog 6.6.6 and I tried with swi-prolog 7.1.36 How I can do to free up memory?
6
votes
1 answer

Two stars in a Prolog list

what are the two stars in a list? [53, 5, 1, 53, 97, 115, 53, 50, 52, 121, 55, 56, 55, 97, 4, 1, 98, **] I tried searching but no success.
Jan
  • 61
  • 1
6
votes
3 answers

Will using member within a forall clause in SWI-Prolog always output the elements in the same order?

Having recently got into Prolog I've been using it for a few simple tasks and began to wonder about using member within forall loops like the one in the trivial example below: forall(member(A,[1,2,3,4]), print(A)). In the case that you do something…
Jonathan Rainer
  • 144
  • 1
  • 14