next up previous contents index
Next: Trouble in Paradise: Answer Up: Non-stratified Programs Previous: When Conditional Answers are   Contents   Index


Programming in the Well-founded Semantics

XSB delays literals for non-LRD-stratified programs and later simplifies them away. But how can the programmer determine when all simplification has been done? One method is to use local evaluation, discussed below in Section 5.4.1. A second method is to make a top-level call for a predicate, p as follows:

?- p,fail ; p.
when the second p in this query is called, all simplification on p will have been performed. However, this query will succeed if p is true or undefined.

Exercise 5.3.6   Write a predicate wfs_call(+Tpred,?Val) such that if Tpred is a ground call to a tabled predicate, wfs_call(+Tpred,?Val) calls Tpred and unifies Val with the truth value of Tpred under the well-founded semantics. Hint: use get_residual/2.

How would you modify wfs_call(?Tpred,?Val) so that it properly handled cases in which Tpred is non-ground.



Luis Fernando P. de Castro 2003-06-27