Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!uunet!mcsun!hp4nl!solist!maestro!jand From: jand@maestro.htsa.aha.nl (Jan Derriks) Newsgroups: comp.lang.prolog Subject: What does/should your Prolog make of this ? Keywords: cut assert fail backtracking Message-ID: <1557@maestro.htsa.aha.nl> Date: 6 Mar 90 11:19:13 GMT References: <1990Mar1.210219.5687@Neon.Stanford.EDU> Sender: uucp@solist.htsa.aha.nl Reply-To: jand@maestro.htsa.aha.nl (Jan Derriks) Organization: AHA-TMF (Technical Institute), Amsterdam, The Netherlands Lines: 37 In article <1990Mar1.210219.5687@Neon.Stanford.EDU> feldman@Neon.Stanford.EDU (Todd J. Feldman) writes: > >Can someone please help me with a bug in the following Prolog fragment: > Maybe this problem is related to Feldman's: In the book 'AI Through Prolog', Neil Rowe uses something like this: (1) doo :- agenda(X), assertz(agenda(next)), write(X), fail. When this rule starts there is ONE fact 'agenda(start)' in the database, so the first query agenda(X) succeeds with X=start. Now the problem with all of our Prolog interpreters (Prolog-2 from Expert Systems International Ltd, Xprolog, SBprolog) is that they are so 'smart' as to see that with only ONE agenda() fact in the database, there is no need to keep a backtrack-point there, so that fact is interpreted as agenda(start) :- !. And following assertz'ed agenda's are NOT found by backtracking, so the output is just 'start no', while what was intended is: 'startnextnextnextnextnextnext....' (database full) as a result. When you start with TWO agenda facts it works as intended (try calling 'doo' a second time) My question: Is there ANY prolog interpreter that does what I (and apparantly N. Rowe too) expect ? BTW, the workaround is of course to always have two 'dummy' facts in the database for cases like this. (or is there a better way ?) -- Jan Derriks | AHA-TMF (H.T.S. 'Amsterdam'), jand@maestro.htsa.aha.nl | Europaboulevard 23, (or ..hp4nl!htsa!jand) | 1079 PC Amsterdam, phone: +31 20423827 | the Netherlands.