I’ve pushed a series of commits in the context of bringing SWI-Prolog tabling closer to XSB. This part deals with negation and implements tnot/1. This implements delaying negative goals that allows us to solve problems like this (from the XSB test suite):
:- table a/0, b/0, c/0, d/0.
a :- b, tnot(c).
b :- a.
b :- d.
b.
c :- tnot(d).
d :- b, fail.
The code passes the XSB negation test suite, but should still be considered experimental. Please give it a try.
All this was relatively easy to do thanks to regular discussions with Theresa Swift, David Warren and Fabrizio Riguzzi, initiated by Kyndi.