bugGNU Prolog for Java - Bugs: bug #32560, Problem with retract and assertz

 
 

bug #32560: Problem with retract and assertz

Submitted by:  None
Submitted on:  Mon 21 Feb 2011 05:25:13 PM UTC  
 
Category: Standards ComplianceSeverity: 3 - Normal
Item Group: NoneStatus: Works For Me
Privacy: PublicAssigned to: None
Open/Closed: ClosedPlanned Release: None

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Fri 06 May 2011 08:02:49 AM UTC, comment #6:

The bug in your code is that you are not doing:
environment.runInitialization(interpreter);
after running ensureLoaded. If you do this then your code will execute as expected.

(the code in question was provided via separate email and is:
Environment environment;
Interpreter interpreter;
environment = new
Environment(); environment.ensureLoaded(AtomTerm.get("src/brain/"+files[i]+""));
interpreter = environment.createInterpreter();
Term[] args = {new IntegerTerm(10)} ;
CompoundTerm goalTerm = new CompoundTerm(AtomTerm.get("test"), args);
Goal goal = interpreter.prepareGoal(goalTerm);
interpreter.execute(goal);

Daniel Thomas <drt24>
Project Administrator
Thu 05 May 2011 04:43:04 PM UTC, comment #5:

ok, now I explain my problem.
if I paste this on Gnu Prolog shell :

asserta(iola(10)),iola(Z),retract(iola(_)),iola(Q),write(Q).

Prolog say no, and it's correct because the retract remove all iola predicates, also iola(Z); so iola(Q) fails.

If I do this from Java code, I get 10, and this because between iola's asserta and his retract I call iola(Z).
The complete java code is:
Term[] args = new IntegerTerm(10)} ;
CompoundTerm goalTerm = new CompoundTerm(AtomTerm.get("test"), args);
Goal goal = interpreter.prepareGoal(goalTerm);
interpreter.execute(goal);

and test is:

test(X) :- asserta(iola(10)),iola(Z),retract(iola(_)),iola(Q),write(Q).

What's wrong in my method?

Nicola <sandycs>
Fri 01 Apr 2011 08:53:37 AM UTC, comment #4:

We have added some tests based on your report and they are all working correctly.
Are you sure that you are using 0.2.6? This was a bug that was in 0.2.5 and was fixed in 0.2.6.

Daniel Thomas <drt24>
Project Administrator
Mon 28 Feb 2011 09:31:13 AM UTC, comment #3:

assertz(res(100)),writeRes,retract(res(_)),assertz(res(200)),res(X),write(X).

writeRes :- res(X), write(X).

Anonymous
Wed 23 Feb 2011 09:51:35 AM UTC, comment #2:

The problem occurs if between assert and retract you invoke a rule using the variable that has been asserted.

Anonymous
Tue 22 Feb 2011 05:45:06 PM UTC, comment #1:

Bugs like this should have been fixed in 2.6 so I am concerned that it appears that they are not.

I tried

testassertz :- assertz(res(a)), retract(res(_)), assertz(res(b)), listing(res), res(Z), write(Z).

At the bottom of your attached pana.txt and ran it using GoalRunner but I got:

res(b) :- true.

b

Which is the expected output. Please could you give the exact sequence of instructions which causes this bug to manifest itself.

Thank you,

Daniel

Daniel Thomas <drt24>
Project Administrator
Mon 21 Feb 2011 05:25:13 PM UTC, original submission:

Hello, i found a BUG using gnuprologjava 2.6.
I have a rule that assert a fact names res(X); later I retract it and assert new one(Y is X*2,assertz(res(Y))).
When I write "listing(res)" I have the correct value of res (that is X*2), but if I do res(Z),write(Z) i have the old value of res, X and not Y.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #22748:  pana.txt added by None (380B - text/plain)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by sandycs (Posted a comment)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 06 May 2011 08:02:49 AM UTCdrt24Open/ClosedOpen=>Closed
    Fri 01 Apr 2011 08:53:37 AM UTCdrt24StatusIn Progress=>Works For Me
    Thu 31 Mar 2011 02:44:27 PM UTCdrt24StatusNeed Info=>In Progress
    Tue 22 Feb 2011 05:45:06 PM UTCdrt24CategoryNone=>Standards Compliance
      StatusNone=>Need Info
    Mon 21 Feb 2011 05:25:13 PM UTCNoneAttached File-=>Added pana.txt, #22748

    Back to the top


    Powered by Savane 3.1-cleanup1