swi
June 14, 2019, 12:33am
1
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
jan
June 14, 2019, 6:43am
2
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
EricGT
June 14, 2019, 8:43am
3
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
prodog
June 14, 2019, 1:57pm
4
Does WFS have any overlaps with defeasible Prolog due to their shared feature of the ability to tolerate contradicting rules?:
swi
June 14, 2019, 6:23pm
5
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?
jan
June 15, 2019, 2:28pm
6
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
swi
June 15, 2019, 5:02pm
7
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.