Questions tagged [gnu-prolog]

GNU Prolog is an ISO compliant Prolog dialect developed by Daniel Diaz. GNU Prolog features constraints over finite domains, produces native binaries, and provides a bidirectional interface with C.

GNU Prolog is an ISO compliant Prolog dialect developed by Daniel Diaz.

In addition to traditional Prolog functionality GNU Prolog supports constraints solving over finite domains. Furthermore, GNU Prolog produces native binaries and provides a powerful bidirectional interface with C.

It spots a very clean WAM based architecture, giving access to the intermediate language at both bytecode and C levels.

103 questions
4
votes
1 answer

uncaught exception: error(existence_error(procedure,likes/0),friend/0) (Seven Languages)

Currently working through the Seven Languages in Seven Weeks book, and am stuck on getting the first prolog examples to run. This concerns the same code piece as this question; however I believe my question is quite different. I have defined likes…
codeling
  • 11,056
  • 4
  • 42
  • 71
4
votes
2 answers

Why doesn't gnu prolog support the "false" predicate? (I've changed to swi)

I've been using the gprolog thingy to do some things in prolog. But now when testing some more code I discovered that it does not support "false". Which is supported by swi?
Algific
  • 1,470
  • 2
  • 18
  • 33
4
votes
6 answers

How to list all predicates that has an specific atom?

another way to ask the question is: How I can list all the properties of an atom? For example: movie(agora). director(agora, 'Alejandro Amenabar') duration(agora, '2h'). so, I will like to receive all the predicates that has agora for argument. In…
titusfx
  • 1,896
  • 27
  • 36
4
votes
1 answer

How truncate file length in Prolog?

How do I truncate the file length in Prolog? I only find a set_stream_position/2 predicate in the ISO standard. But I don't find a set_stream_length/2 predicate in the major Prolog systems. Similarly there is a stream property position/1, but…
user502187
3
votes
2 answers

What would cause Prolog to succeed on a match, but fail when asked to label outputs?

I'm trying to solve a logic puzzle with Prolog, as a learning exercise, and I think I've correctly mapped the problem using the GNU Prolog finite domain solver. When I run the solve function, Prolog spits back: yes and a list of variables all…
CptOatmeal
  • 33
  • 3
3
votes
2 answers

Prolog: how to do "check(a++b++c++d equals d++a++c++b) -> yes"

Let's define custom operators - let it be ++,equals :- op(900, yfx, equals). :- op(800, xfy, ++). And fact: check(A equals A). I try to make predicate, let it be check/1, that will return true in all following situations: check( a ++ b ++ c ++ d…
Grzegorz Wierzowiecki
  • 10,545
  • 9
  • 50
  • 88
3
votes
1 answer

Why does gprolog not chain together uses of modus ponens?

I am reading Learn Prolog Now, 1.1.2 Knowledge Base 2 where they write about chaining together uses of modus ponens. The KB2.pl file: listensToMusic(mia). happy(yolanda). playsAirGuitar(mia) :- listensToMusic(mia). playsAirGuitar(yolanda) :-…
Geoffrey
  • 5,407
  • 10
  • 43
  • 78
3
votes
1 answer

Term expansion before compiling in GNU Prolog

Given the following tuple of directive + predicate: :- web_resource(plaintext/1, [content_type(text/plain)]). plaintext(Result) :- ...code... how do I tell gplc to transform this code into plaintext([headers(['Content-Type'-'text/plain']), …
vasily
  • 2,850
  • 1
  • 24
  • 40
3
votes
1 answer

How to create an executable file to a GNU-Prolog program?

I have written a prolog program in GNU-Prolog and successfully compiled it , now I want to create an executable file so that the other person only need to click on that file and run the program. I want to know if there is a way to create an…
user15840105
3
votes
1 answer

Lists conversion

I am newbie to prolog and I am trying to flatten a list which is like this: X = [[[0,0,1],[1,0,2]],[[0,1,3],[0,2,2]],[[0,3,5],[0,4,4]],[[0,5,4],[0,6,5]]] The desired output is: X =…
Josh
  • 249
  • 3
  • 11
3
votes
3 answers

Up-to-date Prolog implementation benchmarks?

Are there any up-to-date Prolog implementation benchmarks (with results)? I found this on the mercury web site. Surprisingly, it shows a 20-fold gap between swi-prolog and Aquarius. I suspect that these results are pretty old. Does this gap still…
MWB
  • 11,740
  • 6
  • 46
  • 91
3
votes
2 answers

Can't load library(readutil) module in GNU prolog?

I am trying to import library(readutil) module in order to read a line from my file. However when I try the following: :- use_module(library(readutil)). read_from_file(File) :- open(File,read,Stream), read_line_to_codes(Stream,Codes), …
Mandy
  • 145
  • 6
3
votes
1 answer

How to use a "long int" in GNU Prolog?

So basically it seems that GNU Prolog use 28bit integer on my 32bit x86 Linux. The code below can not be compiled: foo(A) :- A0 is 0xdeadbeef, A1 is A0 >> 8, A2 is A0 >> 16, A3 is A0 >> 24. Then I am confused with two typical situations…
lllllllllllll
  • 8,519
  • 9
  • 45
  • 80
3
votes
1 answer

maplist error?

The following used maplist works in swi-prolog not in gprolog: GNU Prolog 1.3.1 By Daniel Diaz Copyright (C) 1999-2009 Daniel Diaz | ?- maplist(writeln,[1,2,3]). uncaught exception: error(existence_error(procedure,maplist/2),top_level/0) |…
3
votes
2 answers

How can I print unification results when using prolog script?

I'm using prolog script to do all queries, the code goes like: :- initialization(run). writeln(T) :- write(T), nl. queryAll :- forall(query(Q), (Q -> writeln('yes':Q) ; writeln('no ':Q))). run :- queryAll, …
Javran
  • 3,394
  • 2
  • 23
  • 40