Article View: comp.lang.prolog
Article #4230Re: Legitimate uses of "assert"?
From: Matthew Huntbach
Date: Wed, 28 Feb 1990 12:11
Date: Wed, 28 Feb 1990 12:11
41 lines
1901 bytes
1901 bytes
In article <8205@pt.cs.cmu.edu> fp@PROOF.ERGO.CS.CMU.EDU (Frank Pfenning) writes: >I am looking for papers/reports/code/information on "legitimate" uses >of "assert" and "retract" in logic programming, that is, uses which are >considered to be in good taste by the connoisseurs of the field. "assert" and "retract" are best used to get round what I believe is a very awkward problem with Prolog, the fact that computations on the OR-branches of search trees cannot otherwise communicate. e.g pred(<args1>) :- body1 pred(<args2>) :- body2 Suppose body1 fails, but some of the partial calculations done within it are useful in body2. Then you have to use "assert" to pass them on. I still don't think this is in good taste. I would prefer something like: pred(<args>) :- body1',body2'. where body1' passes on any information required to body2' and has a flag which if set to "true" causes body2' to immediately halt. This is, of course, an argument against backtracking in Prolog, and an argument for the non-backtracking languages like Parlog. Relevant paper: "Compiling OR-parallelism into AND-parallelism" Codish & Shapiro, 3rd Int. Conf. Log. Prog. 1986. A good example of this is something like branch-and-bound search where body1 might produce bounds which restrict the amount of search done in body2. An unpublished paper of mine discusses this in great detail. Matthew Huntbach
Technical Details
Message-ID:
<1708@sequent.cs.qmw.ac.uk>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!mcsun!ukc!icdoc!qmw-cs!mmhReferences:
<8205@pt.cs.cmu.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!mcsun!ukc!icdoc!qmw-cs!mmh From: mmh@cs.qmw.ac.uk (Matthew Huntbach) Newsgroups: comp.lang.prolog Subject: Re: Legitimate uses of "assert"? Message-ID: <1708@sequent.cs.qmw.ac.uk> Date: 28 Feb 90 12:11:29 GMT References: <8205@pt.cs.cmu.edu> Reply-To: mmh@cs.qmc.ac.uk (Matthew Huntbach) Organization: Computer Science Dept, Queen Mary and Westfield College, U of London, UK. Lines: 41