Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!rochester!cornellcs!newsstand.cit.cornell.edu!portc01.blue.aol.com!portc02.blue.aol.com!howland.erols.net!cam-news-hub1.bbnplanet.com!news.bbnplanet.com!cpk-news-hub1.bbnplanet.com!news-peer.gsl.net!news.gsl.net!EU.net!uknet!usenet1.news.uk.psi.net!uknet!uknet!newsfeed.ed.ac.uk!dcs.ed.ac.uk!cnews
From: David Plume <dbp@dcs.ed.ac.uk>
Subject: undo, assert, retract
X-Nntp-Posting-Host: raasay.dcs.ed.ac.uk
Content-Type: text/plain; charset=us-ascii
Message-ID: <32E753FE.600C@dcs.ed.ac.uk>
Sender: cnews@dcs.ed.ac.uk (UseNet News Admin)
Content-Transfer-Encoding: 7bit
Organization: Department of Computer Science, Edinburgh University
Mime-Version: 1.0
Date: Thu, 23 Jan 1997 12:05:18 GMT
X-Mailer: Mozilla 2.02 (X11; I; SunOS 5.5.1 sun4m)
Lines: 55

Hi ...

Wonder if anyone can help.

I'm trying to write a qualitative simulation program in Sicstus prolog.
Part of it involves performing a sort of depth first search. What I'm
trying to do it this:

I won't go into too much detail, but here's an example.

I assert two instances of c(1). Then, I fail the second line so that as
it backtracks it does a retract(c(1)). What I want to happen is for this
to result in retracting *one* instance of c(1). In fact, it retracts
both of them.

  Any ideas??

	Cheers.  Dave.

eg:

| ?- c(1).
 
no
| ?- assert(c(1)).
 
yes
| ?- assert(c(1)),undo(retract(c(1))),fail.                   
 
no
| ?- c(1).
 
no
| ?- 


========= FOR COMPARISON =========

| ?- c(1).
 
no
| ?- assert(c(1)).
 
yes
| ?- assert(c(1)),fail.
 
no
| ?- c(A).
 
A = 1 ? ;
 
A = 1 ? ;
 
no
| ?-
