next up previous contents index
Next: Stable Models Up: On Beyond Zebra: Implementing Previous: On Beyond Zebra: Implementing   Contents   Index

The Residual Program

Given a program $P$ and query $Q$, the residual program for $Q$ and $P$ consists of all (conditional and unconditional) answers created in the complete evaluation of $Q$.

Exercise 5.3.8   Consider the following program.

     :- table ppgte_p/0,ppgte_q/0,ppgte_r/0,ppgte_s/0,
              ppgte_t/0,ppgte_u/0,ppgte_v/0.
     ppgte_p:- ppgte_q.          ppgte_p:- ppgte_r.

     ppgte_q:- ppgte_s.          ppgte_r:- ppgte_u.
     ppgte_q:- ppgte_t.          ppgte_r:- ppgte_v.

     ppgte_s:- ppgte_w.          ppgte_u:- undefined.
     ppgte_t:- ppgte_x.          ppgte_v:- undefined.

     ppgte_w:- ppgte(1).         ppgte_x:- ppgte(0).
     ppgte_w:- undefined.        ppgte_x:- undefined.

     ppgte(0).

     :- table undefined/0.
     undefined:- tnot(undefined).
Write a routine that uses get_residual/2 to print out the residual program for the query ?- ppgte_p,fail. Try altering the tabling declarations, in particular by making ppgte_q/0, ppgte_r/0, ppgte_s/0 and ppgte_t/0 non-tabled. What effect does altering the tabling declarations have on the residual program?

When XSB returns a conditional answer to a literal $L$, it does not propagate the delay list of the conditional answer, but rather delays $L$ itself, even if $L$ does not occur in a negative loop. This has the advantage of ensuring that delayed literals are not propagated exponentially through conditional answers.



Baoqiu Cui
2000-04-23