# Conjunction with WFS

**URL:** <https://swi-prolog.discourse.group/t/conjunction-with-wfs/814>\
**Category:** General\
**Created:** [June 14, 2019, 12:33am UTC](https://swi-prolog.discourse.group/t/conjunction-with-wfs/814 "2019-06-14T00:33:46Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![swi](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@swi](https://swi-prolog.discourse.group/u/swi)\
**Post date:** [June 14, 2019, 12:33am UTC](https://swi-prolog.discourse.group/t/conjunction-with-wfs/814/1 "2019-06-14T00:33:46Z")

</div>

Suppose we have the following program:

```prolog
:- table p/0, q/0.

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

```

Notice that the following query prints `hello`:

```prolog
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`?

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [June 14, 2019, 6:43am UTC](https://swi-prolog.discourse.group/t/conjunction-with-wfs/814/2 "2019-06-14T06:43:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![EricGT](https://avatars.discourse-cdn.com/v4/letter/e/f1d935/32.png) [@EricGT](https://swi-prolog.discourse.group/u/EricGT)\
**Post date:** [June 14, 2019, 8:43am UTC](https://swi-prolog.discourse.group/t/conjunction-with-wfs/814/3 "2019-06-14T08:43:30Z")

</div>

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](https://www.swi-prolog.org/pldoc/man?section=WFS)

---

<div class="post-metadata">

**Author:** ![prodog](https://avatars.discourse-cdn.com/v4/letter/p/57b2e6/32.png) [@prodog](https://swi-prolog.discourse.group/u/prodog)\
**Post date:** [June 14, 2019, 1:57pm UTC](https://swi-prolog.discourse.group/t/conjunction-with-wfs/814/4 "2019-06-14T13:57:19Z")

</div>

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

> **[FS93-01-015.pdf](https://www.aaai.org/Papers/Symposia/Fall/1993/FS-93-01/FS93-01-015.pdf)**
>
> 581.44 KB

---

<div class="post-metadata">

**Author:** ![swi](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@swi](https://swi-prolog.discourse.group/u/swi)\
**Post date:** [June 14, 2019, 6:23pm UTC](https://swi-prolog.discourse.group/t/conjunction-with-wfs/814/5 "2019-06-14T18:23:34Z")

</div>

With this program:

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

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

a(true).

```

I get the following:

```prolog
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:

```prolog
22 ?- q,tnot(q).

```

I get the following error:

```prolog
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?

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [June 15, 2019, 2:28pm UTC](https://swi-prolog.discourse.group/t/conjunction-with-wfs/814/6 "2019-06-15T14:28:22Z")

</div>

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 ☹

---

<div class="post-metadata">

**Author:** ![swi](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@swi](https://swi-prolog.discourse.group/u/swi)\
**Post date:** [June 15, 2019, 5:02pm UTC](https://swi-prolog.discourse.group/t/conjunction-with-wfs/814/7 "2019-06-15T17:02:43Z")

</div>

Thanks! The fix is working now.

```prolog
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.

```
