Conjunction with WFS

Suppose we have the following program:

:- table p/0, q/0.

p :- tnot(q).
q :- tnot(p).

Notice that the following query prints hello:

16 ?- p,write(hello).
hello
% WFS residual program
    p :-
        tnot(q).
    q :-
        tnot(p).
p.

In other words, the predicate p --even though it returns a conditional answer-- is treated as if it succeded. Is there any way to execute write(hello) only if p is true?

2 Likes

There are two ways to find that an answer is (un)conditional/defined. One is that if both G and tnot(G) succeed it is undefined. The other is to call call_delays(G, Condition), where Condition is true if the answer is unconditional.

1 Like

For those like me who have a slight clue about this topic but want to know more see WFS

https://www.swi-prolog.org/pldoc/man?section=WFS

1 Like

Does WFS have any overlaps with defeasible Prolog due to their shared feature of the ability to tolerate contradicting rules?:

With this program:

:- table p/0, q/0, a/1.

p :- tnot(q).
q :- tnot(p).

a(true).

I get the following:

20 ?- call_delays(q,C).
false.

21 ?- call_delays(a(A),C).
false.

I would expect those two to be different?

Also if I run:

22 ?- q,tnot(q).

I get the following error:

OOPS: Missing Call? (system:(tnot(q),q))
ERROR: Arguments are not sufficiently instantiated
ERROR: In:
ERROR:   [17] '$tbl_table_status'(_224,_226,system:(...,q),_230)
ERROR:   [16] wfs:residual_program(user:(...,q),[],_276,_278,[]) at /home/u/tmp/swipl-dev
el/build.release/home/library/wfs.pl:125

I would expect true based on your comment?

Thanks. Toplevel and module issues are not yet addressed correctly. I pushed a couple of fixes that fix this and some more. Time to write some tests :frowning:

Thanks! The fix is working now.

4 ?- p,tnot(p).
% WFS residual program
    p :-
        tnot(q).
    q :-
        tnot(p).
(tnot(p), p).

5 ?- call_delays(p,C).
% WFS residual program
    p :-
        tnot(q).
    q :-
        tnot(p).
C = p,
p.

9 ?- call_delays((p,q),C),writeln(C).
q,p
% WFS residual program
    q :-
        tnot(p).
    p :-
        tnot(q).
C =  (q, p),
(q, p).

10 ?- call_delays((a(A),q),C),writeln(C).
q
% WFS residual program
    q :-
        tnot(p).
    p :-
        tnot(q).
A = true,
C = q,
q.