info-gnuprologjava
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Info-gnuprologjava] Issue in dynamic predicates


From: Daniel Thomas
Subject: Re: [Info-gnuprologjava] Issue in dynamic predicates
Date: Mon, 07 May 2012 15:06:06 +0100

Hello,

Sorry for the completely unacceptable delay.

I can't seem to reproduce the problem:
$ java -jar '/home/daniel/dev/gnuprolog/releases/0.2.6/gnuprologjava-0.2.6.jar' 
coerce.pl 'reduce_fun3(a,b,c);reduce_fun3(a,b,c)'
GNU Prolog for Java (0.2.6) Goal runner (c) Constantine Plotnikov, 1997-1999.
_A0 to b
Adding coercion from _A0 to b
Did not exist, adding ...
Done with assert
_A0 to b
Adding coercion from _A0 to b
Exists, failing
time = 31ms
FAIL

Perhaps I need to so something more specific in the way that I run it in
order to trigger this problem?

Daniel

On Wed, 2011-09-28 at 03:48 -0700, Aseem Rastogi wrote:
> Hi All:
> 
> I am using GNU Prolog for Java to solve a system of constraints. The 
> algorithm starts with a bunch of constraints and then adds more constraints 
> until it reaches a fixed point and then computes some solutions.
> 
> In my program, I represent the constraints using a dynamic predicate 
> coerce/2. To add new constraints, I use asserta/1. I am facing a problem 
> where, an assert doesn't seem to be taking effect. I am using 0.2.6 release 
> of gnuprolog for java. My (relevant) code and debug messages are as follows:
> 
> Code:
> -------
> 
> :- dynamic(coerce/2).
> 
> add_coercion(X, Y, Flag) :-
>       write('Adding coercion from '), write(X), write(' to '), write(Y), nl,
>       (
>           coerce(X, Y)
>           -> write('Exists, failing'), nl, fail
>           ;  write('Did not exist, adding ...'), nl, asserta(coerce(X, Y)), 
> write('Done with assert'), nl,
>              Flag = n,
>              true
>       ).
> 
> reduce_fun3(X, Y, Flag) :-
>         ....
>       write(T), write(' to '), write(Y), nl,
>       add_coercion(T, Y, Flag).
> 
> The code of add_coercion checks if coerce(X, Y) exists already. If it does, 
> the predicate fails otherwise it asserts the predicate. reduce_fun3 calls 
> add_coercion.
> 
> The debug messages are as follows:
> 
> int to x16
> Adding coercion from int to x16
> Did not exist, adding ...
> Done with assert
> 
> 
> int to x16
> Adding coercion from int to x16
> Did not exist, adding ...
> Done with assert
> 
> 
> int to x16
> Adding coercion from int to x16
> Did not exist, adding ...
> Done with assert
> 
> As you can see, I keep getting the same messages again and again which means 
> the assert is not taking effect.
> 
> Am I doing something wrong or is this a bug in GNU Prolog code ? Please let 
> me know.
> 
> Thanks in advance,
> 
> -Aseem.

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]