next up previous contents index
Next: Meta-Logical Up: Standard Predicates Previous: Convenience   Contents   Index


Negation and Control

'!'/0

Cut (discard) all choice points made since the parent goal started execution. Cuts across tabled predicates are not valid. The compiler checks for such cuts, although whether the scope of a cut includes a tabled predicate is undecidable in the presence of meta-predicates like call/1. Further discussion of conditions allowing cuts and of their actions can be found in Section 5.1.

fail_if(+P)

If the goal P has a solution, fails, otherwise it succeeds. Equivalently, it is true iff call(P) (see section 6.8) is false. Argument P must be ground for sound negation as failure, although no runtime checks are made by the system.

The standard predicate fail_if/1 is compiled by the XSB compiler.

Exceptions:

instantiation_error
P is not instantiated.
type_error
P is not a callable term.

$\backslash$+ +P

Exactly the same as fail_if/1. Its existence is only for compatibility with other Prolog systems.

not +P

If the goal P has a solution, fails, otherwise it succeeds. It is defined by:

	not(P) :- call(P), !, fail.
	not(_).

Argument P must be ground for sound negation, although no runtime checks are made by the system.

Note that in contrast to the other two kinds of negation as failure ( ${\tt '\backslash+'/1}$ and fail_if/1), predicate not/1 is not compiled by the compiler but the above definition is used.

Exceptions: The same as call/1 (see section 6.8).

tnot(+P)
Tabling
The semantics of tnot/1 allows for correct execution of programs with according to the well-founded semantics. P must be a tabled predicate, For a detailed description of the actions of tabled negation for in XSB Version 2.2 see [35,37]. Chapter 5 contains further discussion of the functionality of tnot/1.

Exceptions:

instantiation_error
P is not ground (floundering occurs).
type_error
P is not a callable term.
table_error
P is not a call to a tabled predicate.

sk_not(+P)
Tabling
Same as tnot/1 but does not check for floundering. Thus it permits variables in its subgoal argument and gives the semantics similar to Prolog's when there are variables. (This replaces the 't not'/1 predicate of earlier XSB versions whose implementation and semantics were dubious.)

P -> Q ; R

Analogous to if P then Q else R, i.e. defined as if by

	(P -> Q ; R) :- P, !, Q.
	(P -> Q ; R) :- R.

P -> Q

When occurring other than as one of the alternatives of a disjunction, is equivalent to:
P -> Q ; fail.

repeat

Generates an infinite sequence of choice points (in other words it provides a very convenient way of executing a loop). It is defined by the clauses:

	repeat.
	repeat :- repeat.


next up previous contents index
Next: Meta-Logical Up: Standard Predicates Previous: Convenience   Contents   Index
Baoqiu Cui
2000-04-23