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


5.3.2.0.2 Programming in the Well-founded Semantics

XSB delays literals for non-LRD-stratified programs and later simplifies them away. In Local Scheduling, all simplification will be done before the first answer is returned to the user. In Batched Scheduling it is usually better 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.



Terrance Swift 2007-10-05