[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Info-gnuprologjava] Issue in dynamic predicates
From: |
Aseem Rastogi |
Subject: |
[Info-gnuprologjava] Issue in dynamic predicates |
Date: |
Wed, 28 Sep 2011 03:48:15 -0700 |
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.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Info-gnuprologjava] Issue in dynamic predicates,
Aseem Rastogi <=