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
41
votes
6 answers

Prolog Programming in Ubuntu

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: % sudo apt-add-repository ppa:swi-prolog/stable % sudo apt-get update %…
octain
  • 964
  • 3
  • 10
  • 24
33
votes
5 answers

SWI-Prolog - show long list

I'm using SWI-Prolog and I'm trying to print a list but if the list has more than 9 items - it look like that - [1, 15, 8, 22, 5, 19, 12, 25, 3|...] is there a way to show the whole list?
TamarG
  • 3,522
  • 12
  • 44
  • 74
33
votes
6 answers

Running prolog on a mac

I am having the hardest trouble trying to run SWI-prolog on my Mac. When I type: /opt/bin/local/swipl I get an error saying: /opt/local/bin/swipl: No such file or directory When I just type "swipl" I get: swipl: command not found I've tried…
user3278629
  • 331
  • 1
  • 3
  • 3
31
votes
2 answers

Why is this prolog query both true and false?

My SWI-Prolog knowledge base contains the following two facts: f(a,b). f(a,c). Now if I pose the query ?- f(a,c). true. But ?- f(a,b). true ; false. Why is f(a,b) both true and false? This also happens when there are three facts in the KB. If…
del
  • 311
  • 1
  • 3
  • 3
25
votes
3 answers

SWI-Prolog in Semantic Web

I would like to hear from people who have real world programming experience in using SWI-Prolog's semantic library. Edit: The reason for this question is, among the many people I talked to with prolog experience, most of them seem to have used it…
uncaught_exceptions
  • 21,712
  • 4
  • 41
  • 48
25
votes
3 answers

swipl: how to reload file

First I load the file with SWI-Prolog $ swipl file.pl then I modify the file and save. Now how do I reload the file like ?- reload for this modified file.pl?
Rahn
  • 4,787
  • 4
  • 31
  • 57
22
votes
5 answers

Read a file line by line in Prolog

I'd like to read a plain text file and apply a predicate to each line (the predicates contain write which does the output). How would I do that?
Igor Marvinsky
  • 387
  • 1
  • 4
  • 17
19
votes
3 answers

How to run SWI-Prolog from the command line?

Is there a way to just create a prolog script called hello.pl like this: #!/usr/local/bin/swipl -q -s -t main main:- write('Hello World\n'). And be able to run it from the terminal like this? $ hello.pl Hello World $ When I do that it gives me…
Lance
  • 75,200
  • 93
  • 289
  • 503
16
votes
3 answers

Stack overflow in Prolog DCG grammar rule: how to handle large lists efficiently or lazily

I'm parsing a fairly simple file format consisting of a series of lines, each line having some space separated fields, that looks like this: l 0x9823 1 s 0x1111 3 l 0x1111 12 ⋮ I'm using SWI-Prolog. This is the DCG I have so far: :-…
Daniel Lyons
  • 22,421
  • 2
  • 50
  • 77
15
votes
7 answers

Objected Oriented Programming in SWI-Prolog

I read somewhere that you can think of modules as objects in Prolog. I am trying to get my head around this, and if it a good way to code. If I have two files, one defining a class dog and then another one that uses this class to make two dog…
user27815
  • 4,767
  • 14
  • 28
15
votes
3 answers

SWI Prolog change working directory/get current working directory?

in SWI Prolog terminal how do I view the current working directory and change the current working directory? I found: working_directory(CWD, CWD) but I dont think its what I need
intrigued_66
  • 16,082
  • 51
  • 118
  • 189
12
votes
2 answers

Prolog: Making a procedure to print Hello World

I want to load this simple something into my Editor: Write:-repeat,write("hi"),nl,fail. So that it prints "hi". What should I do? I'm currently trying to do File->New and Saving a file named Write into E:\Program Files\pl\xpce\prolog\lib When doing…
andandandand
  • 21,946
  • 60
  • 170
  • 271
12
votes
2 answers

Is there a package manager for Prolog?

I would like to know what are the best practices for sharing Prolog code / libraries with other programmers (and with oneself between multiple projects). I am using SWI-Prolog myself, but are also interested in how other Prologs tackle this. For…
Wouter Beek
  • 3,307
  • 16
  • 29
12
votes
4 answers

Prolog - DCG parser with input from file

As part of a project I need to write a parser that can read a file and parse into facts I can use in my program. The file structure looks as follows: property = { el1 , el2 , ... }. What I want in the end…
Floris Devriendt
  • 2,044
  • 4
  • 24
  • 34
11
votes
4 answers

Is there a program that can draw a search tree of Prolog queries?

I was wondering if there exists a tool that can draw a step-by-step search tree of a Prolog program? Thanks.
IDDQD
  • 3,543
  • 8
  • 29
  • 40
1
2 3
81 82