Article View: comp.lang.prolog
Article #781Re: More than once/1.
From: Dan Sahlin
Date: Mon, 09 Apr 1990 10:06
Date: Mon, 09 Apr 1990 10:06
23 lines
1291 bytes
1291 bytes
stolcke@icsib12.berkeley.edu (Andreas Stolcke) writes: >I want a predicate >default_to_true/1 that can be wrapped around any predicate call P to >let default_to_true(P) succeed for the case that P can*not* be proven. >If, however, P *can* be proven (has at least one solution) then >default(P) should behave exactly as call(P), i.e. produce all >solutions of P (and only those) upon backtracking. I had a similar problem when writing a theorem prover in SICStus Prolog, and I convinced Mats Carlsson to introduce a new if-then-else- construct "if(P,Q,R)". It behaves as follows: if P fails then R is executed. If P succeeds at least once, it behaves as the conjunction (P,Q), that is backtracking into P is allowed. The natural solution to your problem using this construct is now simply "if(P,true,true)". /Dan Sahlin SICS email: dan@sics.se
Technical Details
Message-ID:
<1990Apr9.100611.17219@sics.se>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!apple!snorkelwacker!bloom-beacon!eru!luth!sunic!sics.se!danReferences:
<23611@pasteur.Berkeley.EDU>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!apple!snorkelwacker!bloom-beacon!eru!luth!sunic!sics.se!dan From: dan@sics.se (Dan Sahlin) Newsgroups: comp.lang.prolog Subject: Re: More than once/1. Message-ID: <1990Apr9.100611.17219@sics.se> Date: 9 Apr 90 10:06:11 GMT References: <23611@pasteur.Berkeley.EDU> Sender: news@sics.se Organization: SICS, Swedish Inst. of Computer Science Lines: 23