[comp.lang.prolog] More than once/1.

dan@sics.se (Dan Sahlin) (04/09/90)

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