Firstly, the document of po(PI) is confusion.
po (PI)
Partial Ordering . The new answer is added iff
call(PI, +Old, +Answer)succeeds. For example,po('<'/2)accumulates the largest result. In SWI-Prolog the arity (2) may be omitted, resulting inpo(<).
IMO, the po('<'/2) should accumulate the smallest result instead of the largest result.
For example,
:- table
path(_,po('<'/2)).
path(X,P) :-
( X=1,P=1
; X=1,P=3
).
?- path(X,P).
X = P, P = 1.
Clearly, it is accumulating smallest result, otherwise the result should be X=1,P=3.
Secondly, there is a subtle difference between XSB and SWI-Prolog about mode directed tabling po(PI).
For example,
:- table
path(_,po(myls/2)).
myls(1,2).
myls(3,4).
path(X,P) :-
( X=1,P=1
; X=1,P=2
).
In SWI-Prolog
?- path(X,P).
X = P, P = 1.
In XSB
| ?- path(X,P).
X = 1
P = 1;
no
That is correct.
However, the following example,
:- table
path(_,po(myls/2)).
myls(1,2).
myls(3,4).
path(X,P) :-
( X=1,P=1
; X=1,P=3
).
In SWI-Prolog
?- path(X,P).
X = 1,
P = 3.
In XSB
In XSB
| ?- path(X,P).
X = 1
P = 3;
X = 1
P = 1
I think the XSB result is correct, because po(PI) means partial ordering, not total ordering. However, the po(PI) in SWI-Prolog means total ordering.