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
1
vote
0 answers

Prolog existence_error: not obvious

I am pulling my hair out! I have installed gprolog (1.4.4) on my Mac, and I am following (I think) the instructions in the Gnu Prolog manual to the letter, but the interactive environment is not remembering my definitions: GNU Prolog 1.4.4 (64…
Amittai Aviram
  • 2,270
  • 3
  • 25
  • 32
1
vote
1 answer

How to define a dummy/placeholder predicate in GNU Prolog

I have a Prolog file with the following structure: % LIBRARY SECTION % foo(X) :- bar(X); baz(X). % USER DATA SECTION % % e.g. bar(charlie). The user data of the file is intended to be allowed to extended by the user but by default…
DanielGibbs
  • 9,910
  • 11
  • 76
  • 121
1
vote
2 answers

Getting list elements from Prolog in a C interface

I try to implement a C interface using a Prolog script based on GNU Prolog. My problem is to get single elements of a nested Prolog list. Actually my C code looks like ... int func; PlTerm arg[10]; PlTerm *sol_gb; PlBool res; int nmb; char…
kiw
  • 155
  • 6
1
vote
2 answers

Workaround ensure_loaded/1 GNU Prolog?

Is there a workaround to make ensure_loaded/1 work in GNU Prolog as it works in many other Prolog systems? The goal is to have a preamble so that the rest of code can use ensure_loaded/1 independent of whether which Prolog system I use. I tried the…
user502187
1
vote
2 answers

Why I can not store the address of one variable in "Prolog+C"?

So basically I want to call some C code from Prolog, and here is the code: Prolog: :-foreign(fun1(+integer,-integer)). :-foreign(fun2(+integer,-integer)). % p = b; testfuna(Var, Val) :- fun1(Val, Var). % p = &b; testfunb(Var, Val) :- fun2(Val,…
lllllllllllll
  • 8,519
  • 9
  • 45
  • 80
1
vote
0 answers

Is there any tool that can automatically generate Prolog callable interface from C functions?

So basically I am using Prolog to call a large number of C functions using GNU-Prolog. Here is an example: int add(int a, int b) { int res = a + b; return res; } If I want to call this function from Prolog code, I need to create this…
lllllllllllll
  • 8,519
  • 9
  • 45
  • 80
1
vote
1 answer

GNU Prolog: Displaying WAM code for query?

Is it possible to display the WAM code for a query using GNU Prolog? I know I can use pl2wam to generate the WAM for the program, but what about the queries I perform on the program? Is there a way to show the WAM code for this? I'm using version…
1
vote
2 answers

gprolog include directive not working

I am running gprolog version 1.4.2 on a Fedora 17 Linux machine. I wrote a small prolog program which runs fine. I defined a few predicates in it that I want to hoist out and use in other prolog programs. So I thought I would put them in a separate…
lurker
  • 56,987
  • 9
  • 69
  • 103
1
vote
1 answer

Prolog find minimum in list error

Im trying to make my code work, but somehow I got stuck on a problem, Im very newbie to prolog. This is my code. dist(valmiera, riga, 107). %dist(riga, valmiera, 107). dist(cesis, riga, 70). dist(valmiera, rujiena, 50). dist(rujiena, valka,…
Ginters Ozols
  • 79
  • 1
  • 1
  • 7
1
vote
2 answers

Using (nb_)setarg/3 with gnu.prolog in Java

I'm currently trying to use prolog out of java using gnu.prolog (http://www.gnu.org/software/gnuprologjava/). Thanks to the great help of CapelliC I now have a prolog program which works perfect for my purpose. The problem is that gnu.prolog does…
Markus
  • 291
  • 1
  • 4
  • 18
1
vote
1 answer

Prolog pipe partial input, user-input the rest

I'm writing a prolog program with an input loop. A good deal of the input is pre-scripted in a response file. I execute this as prolog < response.txt. When the response file has finished, I would like the program to continue through keyboard user…
lildigiman
  • 137
  • 7
1
vote
1 answer

Changing global stack size, GNU Prolog

So I'm working with GNU Prolog on a bash server at my university and I need to increase the global stack size. I've tried compiling with the following options: gprolog --global-size 16384 --init-goal 'consult('test')' where test is just a…
BCsorba
  • 23
  • 1
  • 5
0
votes
2 answers

Prolog read compound term and treating it like an expression

The following code isn't working :- arithmetic_function(i/2). i(X,Y,Z) :- Z is X+Y. calcola :- write('Give me an expression'),nl, read(ESP), Z is ESP,nl,nl, write(Z). but the following is :-…
Marco A.
  • 43,032
  • 26
  • 132
  • 246
0
votes
2 answers

Saving GProlog database

In my program I have a dynamic clauses, they works fine, but when I closing my program, they are disappears. I've tryed that saveState :- write_pl_state_file('backup.dat'). loadState :- file_exists('backup.dat'), …
skayred
  • 10,603
  • 10
  • 52
  • 94
0
votes
2 answers

How can I fix this syntax error in prolog?

I am writing in Prolog and keep getting the error; syntax error: current or previous operator needs brackets When referring to te=he following code: convert_to_tokens([Word|Rest], [Token|RestTokens]) :- atom_string(Atom, Word), ( Atom ==…
Madi92998
  • 1
  • 1