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

Standard way to see what phrase/3 translates?

I am trying to dig into the GNU Prolog behaviour of: test(X,I,O) :- phrase(X,I,O). ?- test(("a",!,"b"),"ab",""). Is there a standard way to see to what phrase/3 translates? According to the ISO DCG proposal (*), there is the requirement that we…
user502187
3
votes
2 answers

Finite Domain Solver fd_minimize/2

I need to minimize a predicate in Prolog. Currently I am using GNU Prolog Java. I have got this fact army( Territory,X ). It says that the given Territory has got X army. Now I want to find the minimum number of armies owned by a given player. So…
Otacon
  • 314
  • 2
  • 11
2
votes
3 answers

Tautology Checker for GNU Prolog

I am looking for open-source implementations of tautology checkers written in GNU Prolog (implementation for SWI-Prolog is acceptable as well, but GNU Prolog is preferred). I'd like to feed program input with queries like: A and (B or C) iff (A or…
Grzegorz Wierzowiecki
  • 10,545
  • 9
  • 50
  • 88
2
votes
1 answer

Using a Bash Script To Automate Testing of A Prolog File

I am in the process of grading student assignments, and wish to automatically run queries on the students database, and print the results of those queries to a file. The issue that I am running into is that I wish to run the multiple queries, but…
2
votes
1 answer

Unexpected result with a system of (in)equations in Prolog

I'm using GNU Prolog. If I ask: | ?- X #= Y+1, Y #< 4, Y #\= 2. I get: X = _#20(1..4) Y = _#3(0..1:3) but, since Y!=2 and X=Y+1, I was expecting also that X!=3. What is this behavior due to?
user402843
  • 89
  • 1
  • 9
2
votes
1 answer

Compilation error "4:12: syntax error: . or operator expected after expression" / problems with defining dynamic in prolog

Please help. I'm encounter this compilation error in GNU prolog, when I use SWISH it looks like code compile but when I try to ?- current_room(X). it shows me error anyway (just false), so I expect something is not right with way I defined…
2
votes
2 answers

Problem with bagof/3 in Prolog

As far as I understand the predicates setof/3 and bagof/3 can be used generate a list of solutions to a problem. (Link to gprolog manual). As expected the solutions to the following query are a, b and c. ?- nth(_, [a,b,c], X). X = a…
tfeldmann
  • 3,108
  • 1
  • 23
  • 34
2
votes
1 answer

Writing to a file in gprolog

How do I write all the solutions obtained from a prolog program to a file?
Sankalp
  • 21
  • 2
2
votes
2 answers

Mutually exclusion in a logic task

There is three friends - misha, petya, vova. Surnames: ivanov, semyonov, gerasimov. name(misha). name(vova). name(petya). surname(ivanov). surname(semyonov). surname(gerasimov). misha isn't gerasimov. full_name(misha,X) :- surname(X), X \=…
demsee
  • 53
  • 9
2
votes
1 answer

How to convert a list of numbers to a list of words in Prolog?

I am trying to write a Prolog program such that given a list of numbers like [1, 2, 3], it will convert them into a list of words representing those numbers ['one', 'two', 'three']. My code so far: totext(0, 'zero'). totext(1, 'one'). totext(2,…
user5597655
2
votes
2 answers

Compile GTK with GPLC

Trying to compile a C GTK gui + Prolog file using GPLC. I read that I can pass multiple flags to the gcc compiler from GPLC by using-C 'gcc flags here' Ok so I can comiple my GUI alone with gcc foo.c `pkg-config --cflags --libs gtk+-2.0` -o…
Zeth
  • 68
  • 6
2
votes
2 answers

Examples for calling (GNU) Prolog from C as stand-alone

I want to build an executable based on a C-File in which Prolog predicates are used. I want to use GNU Prolog. I succeed (based on the gnu prolog tutorial) to build the examp_c.c, examp.pl: #include #include…
kiw
  • 155
  • 6
2
votes
1 answer

Weird situation in using a pointer as the argument for a C call Prolog Process

So basically my test is on 32bit x86 Linux, I use GNU Prolog 1.4.4 Here is the case, I have function ptr.c + pro.pl + interface.c In the ptr.c, I use a wrapper to call a Prolog function in the pro.pl, then in the pro.pl, I use a prolog c interface…
lllllllllllll
  • 8,519
  • 9
  • 45
  • 80
2
votes
1 answer

findall/3 returns an empty list instead of solutions

I use GNU Prolog to solve a problem. I have defined the following predicate : % P is the product of X and Y produit(X,Y,P) :- between(2,200,X), between(2,200,Y), X #<# Y, X*Y #=# P. % S is the sum of X and Y somme(X,Y,S) :- …
Saroupille
  • 609
  • 8
  • 14
2
votes
4 answers

gprolog - Simple way to determine whether one list is a permutation of another

I'm trying to write a prolog program that determines whether one list is a permutation of another. Input is of the form perm(L,M), which will be true if and only if list L is a permutation of list M. This is for my AI class, so I cannot just use…
norman
  • 5,128
  • 13
  • 44
  • 75