Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!sdd.hp.com!think.com!mintaka!bloom-beacon!eru!hagbard!sunic!sics.se!sics.se!roland From: roland@sics.se (Roland Karlsson) Newsgroups: comp.lang.prolog Subject: Re: immediate update Message-ID: <1990Nov27.095143.28162@sics.se> Date: 27 Nov 90 09:51:43 GMT References: <1386@n_kulcscs.kuleuven.ac.be> Sender: news@sics.se Organization: Swedish Institute of Computer Science, Kista Lines: 32 In-Reply-To: bimbart@kulcs.cs.kuleuven.ac.be's message of 26 Nov 90 21:45:46 GMT > a/1 is dynamic (and immediate) and there is one clause for a/1: > a(1) . > question 1 > what is the output of the query > ?- a(X) , write(X) , retract(a(1)) , asserta(a(2)) , fail . > question 2 > what is the output of the query > ?- a(X) , write(X) , retract(a(1)) , assertz(a(2)) , fail . In Aurora and Muse parallel Prologs there are similar implementations of immediate update of the data base. Both implementations keep a choice point until ready with the immediate predicate. So the above queries should give the output '1' and '12' respectively. But unfortunately both implementations are WRONG. If you remove the retract(a(1)) literal from both queries above then they will correctly give the output '1" and '12222...' respectively. As the one who have programmed this code for Muse I feel very ashamed (:-). I thought it was RIGHT. Looking at the code I see that retract will incorrectly remove the clause a(1) from the list of possible clauses. When adding a(2) then it will be added non reachable from the removed clause a(1). Muse had a correct, but more inefficient, implementation before. Then all clauses was kept, until reaching prolog top level, and only marked as dead. After a while this implementation resultet in VERY long search time in long lists of dead clauses. Hmmmm... Might there be an efficient AND correct solution? -- Roland Karlsson SICS, PO Box 1263, S-164 28 KISTA, SWEDEN Internet: roland@sics.se Tel: +46 8 752 15 40 Ttx: 812 61 54 SICS S Fax: +46 8 751 72 30