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
8
votes
1 answer

Prolog delayed evaluation: LIFO or FIFO wake-up?

Many Prolog systems have a freeze/2 predicate, a predicate that should possibly have the name geler/2 since it was even invented before Prolog-II. Assume I have a condition on the same variable, but two different goals, i.e.: ?- freeze(X, G1),…
user502187
8
votes
5 answers

SWI-Prolog how to show entire answer (list)?

I'm trying to convert a string to a list of ascii-codes like so: 7 ?- string_to_list("I'm a big blue banana in space!", C). C = [73, 39, 109, 32, 97, 32, 98, 105, 103|...]. 8 ?- This doesn't give me the entire list as you can see, but I need…
Mossmyr
  • 909
  • 2
  • 10
  • 26
8
votes
5 answers

Stream reasoning / Reactive programming in prolog?

I was wondering if you know of any way to use prolog for stream processing, that is, some kind of reactive programming, or at least to let a query run on a knowledge base that is continuously updated (effectively a stream), and continuously output…
Samuel Lampa
  • 4,336
  • 5
  • 42
  • 63
7
votes
1 answer

How is Prolog `shift`/`reset` like other languages?

I found an example of shift-reset delimited continuations in Haskell here: resetT $ do alfa bravo x <- shiftT $ \esc -> do charlie lift $ esc 1 delta lift $ esc 2 return 0 zulu x This…
Lynn
  • 10,425
  • 43
  • 75
7
votes
4 answers

How to use call_with_depth_limit/3

I'm trying to use call_with_depth_limit/3 in SWI-Prolog to implement iterative deepening and either I don't understand how it works or it's misbehaving. I have an example where the following happens: ?- call_with_depth_limit(mygoal, 29,…
Joan
  • 99
  • 4
7
votes
3 answers

Does Prolog need GC when the occurs check is globally enabled?

As far as I can tell, with sound unification, SLD resolution should not create cyclic data structures (Is this correct?) If so, one could, in theory, implement Prolog in such a way that it wouldn't need garbage collection (GC). But then again, one…
7
votes
1 answer

Different results in swi-prolog and yap

The sample program enumerates and counts the number of 8-queen solutions. (sorry if the code is hard to read; this is machine-generated from an S-expression. The original code is…
7
votes
4 answers

Defining operators including vertical bars(|) in SWI-prolog

I am trying to encode basic logical inferences in Prolog, and I want to define some custom operators to streamline the notation. It would be handy if I can type |- for ⊢. So I tried :- op(1150, xfy, [ '|-' ]). gamma |- a. Gamma |- or(A,_) :- Gamma…
user287393
  • 1,221
  • 8
  • 13
7
votes
1 answer

How to turn off "true" and "false" outputs in Prolog?

I would like to write a small text-based adventure game using Prolog (this might be a dumb idea but I am not here to discuss that). The only problem is that I can't manage to print text on screen without the "true" and "false" values to appear as…
gatsu
  • 237
  • 3
  • 8
7
votes
2 answers

catch/3 and call_with_time_limit/2 predicates in SWI-Prolog

I want to use catch(:Goal, +Catcher, :Recover) where Goal is call_with_time_limit(+Time, :Goal) It's messed up and I can't find the right way to know when one of the above happened: 1) Goal stopped because of time out. 2) Goal failed (it's…
Mockingbird
  • 1,023
  • 9
  • 17
7
votes
2 answers

Implementing XOR function with Prolog CLPFD for 32-bit numbers

I try to implement efficient exclusive-or (XOR) in Prolog CLPFD. This should be simple predicate like: xor(A, B, AxorB). A, B, AxorB are natural numbers (with 0) and AxorB is a result of A xor B. My main problem is with efficiency. Firstly, I…
Grzegorz Adam Kowalski
  • 5,243
  • 3
  • 29
  • 40
7
votes
2 answers

Random items in Prolog

I know I can do X is random(10). to get a random number from 0 to 10, but is there a similar command to get a random matching item?
Pieter
  • 31,619
  • 76
  • 167
  • 242
7
votes
3 answers

What security risks are posed by using a local server to provide a browser-based gui for a program?

I am building a relatively simple program to gather and sort data input by the user. I would like to use a local server running through a web browser for two reasons: HTML forms are a simple and effective means for gathering the input I'll need. I…
Shon
  • 3,989
  • 1
  • 22
  • 35
7
votes
3 answers

Prolog list membership, multiple results returned

I have a standard procedure for determining membership of a list: member(X, [X|_]). member(X, [_|T]) :- member(X, T). What I don't understand is why when I pose the following query: ?- member(a,[a,b]). The result is True; False. I would have…
Justin
  • 322
  • 3
  • 13
7
votes
4 answers

Integrating prolog into other environments

I'm using Prolog for an academic project. I wanted to know if there is a way for Prolog to interact with other programming languages. What I want is an easy input/output redirection of Prolog question and answers. I'm aware that Prolog can call C…
David James
  • 635
  • 6
  • 16
1 2
3
81 82