Path: 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 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