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
22
votes
2 answers

In GNU-Prolog, can I 'catch' a linux signal?

Is there a way to 'trap' (e.g. 'catch') an operating system signal within GNU Prolog? (I'm using Ubuntu/Linux, latest gprolog). I think a long time ago I used this approach in WAMCC, before that morphed into GNU Prolog: :-…
Bambam
  • 3,729
  • 1
  • 16
  • 16
17
votes
3 answers

Programming in the large with prolog

I'm trying to keep my Prolog code modular, and I was wondering if anyone had any advice as to how to do this. The way I was doing this with simple consults, but that is getting cumbersome as the number of my files increase and succumbs to name…
Sean Kelleher
  • 1,952
  • 1
  • 23
  • 34
11
votes
3 answers

Prolog - generating numbers fitting given range

I'd like to use predicates like: range(X,0,5) range(X,4,200) range(X,-1000000,1000000) dom_range(X,-1000000,1000000) with meaning : range(X,0,5) :- member(X,[0,1,2,3,4,5]). range(X,4,200) :-…
Grzegorz Wierzowiecki
  • 10,545
  • 9
  • 50
  • 88
10
votes
1 answer

SWI Prolog vs. GNU Prolog - CLP(FD) issues under SWI

I wrote a quick predicate in Prolog trying out CLP(FD) and its ability to solve systems of equations. problem(A, B) :- A-B #= 320, A #= 21*B. When I call it in SWI, I get: ?- problem(A,B). 320+B#=A, 21*B#=A. Whereas in GNU, I get the…
Name McChange
  • 2,750
  • 5
  • 27
  • 46
9
votes
2 answers

gprolog: Getting a stacktrace after an exception

While using gprolog I often have exceptions without any kind of line numbers or context like this one: uncaught exception: error(instantiation_error,(is)/2) Without any kind of context. I know I can do a trace but it would take very long to debug…
damio
  • 6,041
  • 3
  • 39
  • 58
7
votes
1 answer

GNU Prolog assert error

I am new to Prolog, but I am stuck at this supposedly simple command. I have loaded a knowledge base with no errors, and whenever I try do assert (and even help) I get the following message: uncaught exception:…
zpavlinovic
  • 1,507
  • 1
  • 17
  • 36
7
votes
1 answer

how can I make prolog print query results when running a prolog script

I'm new to prolog and want to save all queries in a file instead of typing them by hand. I have these facts in facts.pl: likes(wallace, cheese). likes(grommit, cheese). likes(wendolene, sheep). friend(X, Y) :- \+(X = Y), likes(X, Z), likes(Y,…
Javran
  • 3,394
  • 2
  • 23
  • 40
6
votes
2 answers

Prolog existence_error procedure in basic example

I'm trying to learn the basics of Prolog and keep running into a existence_error with the following code. comes_after(m1, m2). comes_after(m2, m3). comes_after(m3, m4). comes_after(m4, m5). comes_after(m5, m6). does_come_after(X, Y) :-…
Zoroshino
  • 81
  • 1
  • 5
6
votes
1 answer

Simple PROLOG issue: How do you test multiple queries against your Prolog database?

I have a Prolog database file (test_inserts.p) that I used to insert all my data. I also have a Prolog query file (test_queries.pl) that has all of the Prolog queries I wrote up to receive specific information from my database. I was wondering how…
Mr Prolog
  • 521
  • 1
  • 5
  • 4
5
votes
1 answer

Prolog Compatibility Layers - available programming libraries

There is a lack of some predicates in one Prolog implementations, that are available in others. We can implement lacking predicates, let's call this "Prolog Compatibility Layer". Do you know "Prolog Compatibility Layers" for Prolog (especially for…
Grzegorz Wierzowiecki
  • 10,545
  • 9
  • 50
  • 88
5
votes
4 answers

Problem with `\+` in Prolog queries with variables

I'm reading "Seven languages in seven weeks" atm, and I'm stumped over some Prolog query that I don't understand the 'no' response to. The friends.pl file looks like this: likes(wallace, cheese). likes(grommit, cheese). likes(wendolene,…
Marc Mutz - mmutz
  • 24,485
  • 12
  • 80
  • 90
5
votes
1 answer

Find a boolean circuit with prolog

The problem is the following : considering three inputs A,B,C, find a boolean circuit with AND,OR and NOT gates such that the output is not(A), not(B), not(C) using at most 2 NOT gates. I would like to find the circuit with prolog. My idea is to…
Saroupille
  • 609
  • 8
  • 14
5
votes
1 answer

What does it mean when gprolog says "true?" instead of "yes" in this instance?

I am attempting to write a gprolog program that affirms that, given some "reasonable" background from this song (listen here :-) ), will answer yes when I query grandpa(me, me) (i.e., Am I indeed my own grandpa?). This was given as an assignment for…
norman
  • 5,128
  • 13
  • 44
  • 75
5
votes
3 answers

Making Prolog code that works in GNU and SWI

I realize there are going to be limits to this, but is there a reasonable way to put in conditional directives in Prolog code so that it an work reasonably in either GNU or SWI? I'm thinking at least the simplest cases, where built-in predicates…
lurker
  • 56,987
  • 9
  • 69
  • 103
4
votes
1 answer

Unit testing in GNU Prolog

I'm trying to migrate my SWI Prolog application into the GNU Prolog. Unfortunately I have a problem with unit tests. In SWIPL we can simply use plunit module and write the test cases like the following one: :-…
trivelt
  • 1,913
  • 3
  • 22
  • 44
1
2 3 4 5 6 7